diff options
author | Jonathan Kang <jonathankang@gnome.org> | 2018-12-15 17:39:58 +0800 |
---|---|---|
committer | Jonathan Kang <jonathankang@gnome.org> | 2018-12-15 17:39:58 +0800 |
commit | 49965b27ec9995a7c1798cddc43b081a720a3c0c (patch) | |
tree | abc7598aeef68a43eb012f293330ece459b1ebfc | |
parent | 60994e0e58432693e995643fe8762fbcd9f53519 (diff) | |
download | gnome-logs-49965b27ec9995a7c1798cddc43b081a720a3c0c.tar.gz |
Use g_type_ensure() instead of *_get_type()
Use g_type_ensure() to ensure that those types have been registered
before calling gtk_widget_init_template(). For more infomation, see
the documentation of g_type_ensure()[1].
*[1] https://developer.gnome.org/gobject/stable/gobject-Type-Information.html#g-type-ensure
-rw-r--r-- | src/gl-application.c | 6 | ||||
-rw-r--r-- | src/gl-window.c | 7 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/gl-application.c b/src/gl-application.c index daaded4..d7082d8 100644 --- a/src/gl-application.c +++ b/src/gl-application.c @@ -196,12 +196,6 @@ gl_application_startup (GApplication *application) /* gtk_init() calls setlocale(), so gettext must be called after that. */ g_set_application_name (_(PACKAGE_NAME)); gtk_window_set_default_icon_name (PACKAGE_TARNAME); - - /* Must register custom types before using them from GtkBuilder. */ - gl_window_get_type (); - gl_category_list_get_type (); - gl_event_toolbar_get_type (); - gl_event_view_list_get_type (); } static void diff --git a/src/gl-window.c b/src/gl-window.c index b6dbee2..3b3716a 100644 --- a/src/gl-window.c +++ b/src/gl-window.c @@ -402,6 +402,13 @@ gl_window_init (GlWindow *window) gboolean ignore; GlJournalModel *model; + /* Ensure these types that are used by the template have been + * registered before calling gtk_widget_init_template(). + */ + g_type_ensure(GL_TYPE_CATEGORY_LIST); + g_type_ensure(GL_TYPE_EVENT_TOOLBAR); + g_type_ensure(GL_TYPE_EVENT_VIEW_LIST); + gtk_widget_init_template (GTK_WIDGET (window)); priv = gl_window_get_instance_private (window); |