[gnome-logs] Use g_type_ensure() instead of *_get_type()
- From: Jonathan Kang <jonathankang src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-logs] Use g_type_ensure() instead of *_get_type()
- Date: Sat, 15 Dec 2018 09:53:07 +0000 (UTC)
commit 49965b27ec9995a7c1798cddc43b081a720a3c0c
Author: Jonathan Kang <jonathankang gnome org>
Date: Sat Dec 15 17:39:58 2018 +0800
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
src/gl-application.c | 6 ------
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]