[gtranslator] Use GResource



commit 443db0471b9747df8e21ba12946a0cf253003f0f
Author: Daniel Mustieles <daniel mustieles gmail com>
Date:   Tue Apr 17 23:07:45 2012 +0200

    Use GResource

 src/Makefile.am              |   37 +++++++++-------
 src/gtr-header-dialog.c      |   62 +++++++++++----------------
 src/gtr-jump-dialog.c        |   34 ++++++---------
 src/gtr-languages-fetcher.c  |   70 +++++++++++++-----------------
 src/gtr-preferences-dialog.c |   96 ++++++++++++++++--------------------------
 src/gtr-profile-dialog.c     |   49 ++++++++++-----------
 src/gtr-search-dialog.c      |   64 +++++++++-------------------
 7 files changed, 167 insertions(+), 245 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index a87e77a..5369a60 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,8 +4,7 @@
 
 SUBDIRS = toolbareditor
 
-noinst_LTLIBRARIES = \
-	libgtranslator.la
+noinst_LTLIBRARIES = libgtranslator.la
 
 lib_LTLIBRARIES = libgtranslator-private.la
 
@@ -21,21 +20,11 @@ INCLUDES = \
 	-DDATADIR=\""$(datadir)"\"				\
 	-DLIBDIR=\""$(libdir)"\"
 
-uidir = $(pkgdatadir)/ui
-ui_DATA =  \
-	gtr-preferences-dialog.ui \
-	gtr-search-dialog.ui \
-	gtr-header-dialog.ui \
-	gtr-profile-dialog.ui \
-	gtr-jump-dialog.ui \
-	gtr-languages-fetcher.ui
-
 bin_PROGRAMS = \
 	gtranslator
 
 gtranslator_SOURCES = main.c
 
-
 gtranslator_LDADD =			\
 	libgtranslator.la		\
 	libgtranslator-private.la	\
@@ -59,6 +48,9 @@ BUILT_SOURCES = \
 	gtr-enum-types.h \
 	gtr-enum-types.c
 
+BUILT_SOURCES_PRIVATE = \
+	gtr-resources.c
+
 if PLATFORM_WIN32
 gtranslator-res.o: gtranslator.rc
 	$(WINDRES) -i gtranslator.rc --input-format=rc -o gtranslator-res.o -O coff
@@ -112,9 +104,10 @@ headerdir = $(prefix)/include/gtranslator- GTR_API_VERSION@/gtranslator
 header_DATA = \
 	$(INST_H_FILES)
 
-libgtranslator_private_la_SOURCES =	\
+libgtranslator_private_la_SOURCES = \
 	gtr-tab-activatable.c \
-	gtr-window-activatable.c
+	gtr-window-activatable.c \
+	gtr-resources.c
 
 libgtranslator_c_files = \
 	gtr-actions-documents.c \
@@ -182,11 +175,20 @@ gtr-marshal.h: gtr-marshal.list $(GLIB_GENMARSHAL)
 gtr-marshal.c: gtr-marshal.list $(GLIB_GENMARSHAL)
 	$(AM_V_GEN) $(GLIB_GENMARSHAL) $< --body --header --prefix=gtr_marshal > $@
 
+gtr-resources.c: gtranslator.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies $(srcdir)/gtranslator.gresource.xml)
+	$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source $(srcdir)/gtranslator.gresource.xml
+
 EXTRA_DIST =	\
-	$(ui_DATA)	\
 	gtr-marshal.list	\
 	gtr-enum-types.h.template	\
-	gtr-enum-types.c.template
+	gtr-enum-types.c.template	\
+	gtranslator.gresource.xml	\
+	gtr-header-dialog.ui	\
+	gtr-jump-dialog.ui	\
+	gtr-languages-fetcher.ui	\
+	gtr-preferences-dialog.ui	\
+	gtr-profile-dialog.ui	\
+	gtr-search-dialog.ui
 
 
 if HAVE_INTROSPECTION
@@ -210,7 +212,8 @@ typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
 CLEANFILES =	\
 	$(gir_DATA)	\
 	$(typelib_DATA)	\
-	$(BUILT_SOURCES)
+	$(BUILT_SOURCES) \
+	$(BUILT_SOURCES_PRIVATE)
 endif
 
 -include $(top_srcdir)/git.mk
diff --git a/src/gtr-header-dialog.c b/src/gtr-header-dialog.c
index 6d2a5d2..1511f05 100644
--- a/src/gtr-header-dialog.c
+++ b/src/gtr-header-dialog.c
@@ -233,16 +233,17 @@ gtr_header_dialog_fill_from_header (GtrHeaderDialog * dlg)
 static void
 gtr_header_dialog_init (GtrHeaderDialog * dlg)
 {
-  gboolean ret;
-  GtkWidget *error_widget, *action_area;
+  GtrHeaderDialogPrivate *priv;
+  GtkWidget *action_area;
   GtkBox *content_area;
-  gchar *path;
+  GtkBuilder *builder;
   gchar *root_objects[] = {
     "main_box",
     NULL
   };
 
   dlg->priv = GTR_HEADER_DIALOG_GET_PRIVATE (dlg);
+  priv = dlg->priv;
 
   dlg->priv->settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
 
@@ -263,40 +264,27 @@ gtr_header_dialog_init (GtrHeaderDialog * dlg)
 
   g_signal_connect (dlg, "response", G_CALLBACK (gtk_widget_destroy), NULL);
 
-  path = gtr_dirs_get_ui_file ("gtr-header-dialog.ui");
-  ret = gtr_utils_get_ui_objects (path,
-                                  root_objects,
-                                  &error_widget,
-                                  "main_box", &dlg->priv->main_box,
-                                  "notebook", &dlg->priv->notebook,
-                                  "lang_vbox", &dlg->priv->lang_vbox,
-                                  "prj_id_version",
-                                  &dlg->priv->prj_id_version, "rmbt",
-                                  &dlg->priv->rmbt, "prj_comment",
-                                  &dlg->priv->prj_comment,
-                                  "take_my_options",
-                                  &dlg->priv->take_my_options,
-                                  "tr_name", &dlg->priv->translator,
-                                  "tr_email", &dlg->priv->tr_email,
-                                  "pot_date", &dlg->priv->pot_date,
-                                  "po_date", &dlg->priv->po_date,
-                                  "language_entry",
-                                  &dlg->priv->language,
-                                  "lg_email_entry",
-                                  &dlg->priv->lg_email,
-                                  "charset_entry",
-                                  &dlg->priv->charset,
-                                  "encoding_entry",
-                                  &dlg->priv->encoding, NULL);
-  g_free (path);
-
-  if (!ret)
-    {
-      gtk_widget_show (error_widget);
-      gtk_box_pack_start (content_area, error_widget, TRUE, TRUE, 0);
-
-      return;
-    }
+  builder = gtk_builder_new ();
+  gtk_builder_add_objects_from_resource (builder, "/org/gnome/gtranslator/ui/gtr-header-dialog.ui",
+                                         root_objects, NULL);
+
+  priv->main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+  g_object_ref (priv->main_box);
+  dlg->priv->notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+  dlg->priv->lang_vbox = GTK_WIDGET (gtk_builder_get_object (builder, "lang_vbox"));
+  dlg->priv->prj_id_version = GTK_WIDGET (gtk_builder_get_object (builder, "prj_id_version"));
+  dlg->priv->rmbt = GTK_WIDGET (gtk_builder_get_object (builder, "rmbt"));
+  dlg->priv->prj_comment = GTK_WIDGET (gtk_builder_get_object (builder, "prj_comment"));
+  dlg->priv->take_my_options = GTK_WIDGET (gtk_builder_get_object (builder, "take_my_options"));
+  dlg->priv->translator = GTK_WIDGET (gtk_builder_get_object (builder, "tr_name"));
+  dlg->priv->tr_email = GTK_WIDGET (gtk_builder_get_object (builder, "tr_email"));
+  dlg->priv->pot_date = GTK_WIDGET (gtk_builder_get_object (builder, "pot_date"));
+  dlg->priv->po_date = GTK_WIDGET (gtk_builder_get_object (builder, "po_date"));
+  dlg->priv->language = GTK_WIDGET (gtk_builder_get_object (builder, "language_entry"));
+  dlg->priv->lg_email = GTK_WIDGET (gtk_builder_get_object (builder, "lg_email_entry"));
+  dlg->priv->charset = GTK_WIDGET (gtk_builder_get_object (builder, "charset_entry"));
+  dlg->priv->encoding = GTK_WIDGET (gtk_builder_get_object (builder, "encoding_entry"));
+  g_object_unref (builder);
 
   gtk_box_pack_start (content_area, dlg->priv->main_box, FALSE, FALSE, 0);
 
diff --git a/src/gtr-jump-dialog.c b/src/gtr-jump-dialog.c
index a5127d8..e85d77e 100644
--- a/src/gtr-jump-dialog.c
+++ b/src/gtr-jump-dialog.c
@@ -72,10 +72,10 @@ G_DEFINE_TYPE (GtrJumpDialog, gtr_jump_dialog, GTK_TYPE_DIALOG)
 static void
 gtr_jump_dialog_init (GtrJumpDialog * dlg)
 {
-  gboolean ret;
-  GtkWidget *error_widget, *action_area;
+  GtrJumpDialogPrivate *priv;
+  GtkWidget *action_area;
   GtkBox *content_area;
-  gchar *path;
+  GtkBuilder *builder;
   gchar *root_objects[] = {
     "adjustment1",
     "main_box",
@@ -83,6 +83,7 @@ gtr_jump_dialog_init (GtrJumpDialog * dlg)
   };
 
   dlg->priv = GTR_JUMP_DIALOG_GET_PRIVATE (dlg);
+  priv = dlg->priv;
 
   gtk_dialog_add_buttons (GTK_DIALOG (dlg),
                           GTK_STOCK_OK,
@@ -108,26 +109,17 @@ gtr_jump_dialog_init (GtrJumpDialog * dlg)
   g_signal_connect (dlg,
                     "response", G_CALLBACK (dialog_response_handler), NULL);
 
-  /*Glade */
-  path = gtr_dirs_get_ui_file ("gtr-jump-dialog.ui");
-  ret = gtr_utils_get_ui_objects (path,
-                                  root_objects,
-                                  &error_widget,
-                                  "main_box", &dlg->priv->main_box,
-                                  "jump", &dlg->priv->jump, NULL);
-  g_free (path);
+  builder = gtk_builder_new ();
+  gtk_builder_add_objects_from_resource (builder, "/org/gnome/gtranslator/ui/gtr-jump-dialog.ui",
+                                         root_objects, NULL);
+  priv->main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+  g_object_ref (priv->main_box);
+  priv->jump = GTK_WIDGET (gtk_builder_get_object (builder, "jump"));
+  g_object_unref (builder);
 
-  if (!ret)
-    {
-      gtk_widget_show (error_widget);
-      gtk_box_pack_start (content_area, error_widget, TRUE, TRUE, 0);
-
-      return;
-    }
-
-  gtk_box_pack_start (content_area, dlg->priv->main_box, TRUE, TRUE, 0);
+  gtk_box_pack_start (content_area, priv->main_box, TRUE, TRUE, 0);
 
-  gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
+  gtk_container_set_border_width (GTK_CONTAINER (priv->main_box), 5);
 }
 
 static void
diff --git a/src/gtr-languages-fetcher.c b/src/gtr-languages-fetcher.c
index 0a9cb8d..92141c3 100644
--- a/src/gtr-languages-fetcher.c
+++ b/src/gtr-languages-fetcher.c
@@ -293,10 +293,9 @@ on_combo_box_changed (GtkWidget           *widget,
 static void
 gtr_languages_fetcher_init (GtrLanguagesFetcher *fetcher)
 {
-  GtkWidget *error_widget;
-  GtkWidget *main_box;
-  gboolean ret;
-  gchar *path;
+  GtrLanguagesFetcherPrivate *priv;
+  GtkWidget *content;
+  GtkBuilder *builder;
   gchar *root_objects[] = {
     "main_box",
     "language_store",
@@ -305,74 +304,65 @@ gtr_languages_fetcher_init (GtrLanguagesFetcher *fetcher)
   };
 
   fetcher->priv = GTR_LANGUAGES_FETCHER_GET_PRIVATE (fetcher);
+  priv = fetcher->priv;
 
   gtk_orientable_set_orientation (GTK_ORIENTABLE (fetcher),
                                   GTK_ORIENTATION_VERTICAL);
 
-  path = gtr_dirs_get_ui_file ("gtr-languages-fetcher.ui");
-  ret = gtr_utils_get_ui_objects (path,
-                                  root_objects,
-                                  &error_widget,
-                                  "main_box", &main_box,
-                                  "language", &fetcher->priv->language,
-                                  "language_code", &fetcher->priv->language_code,
-                                  "charset", &fetcher->priv->charset,
-                                  "encoding", &fetcher->priv->encoding,
-                                  "team_email", &fetcher->priv->team_email,
-                                  "plural_forms", &fetcher->priv->plural_forms,
-
-                                  "language_store", &fetcher->priv->language_store,
-                                  "code_store", &fetcher->priv->code_store,
-                                  NULL);
-  g_free (path);
-
-  if (!ret)
-    {
-      gtk_widget_show (error_widget);
-      gtk_box_pack_start (GTK_BOX (fetcher), error_widget, TRUE, TRUE, 0);
-
-      return;
-    }
-
-  gtk_box_pack_start (GTK_BOX (fetcher), main_box, FALSE, FALSE, 0);
+  builder = gtk_builder_new ();
+  gtk_builder_add_objects_from_resource (builder, "/org/gnome/gtranslator/ui/gtr-languages-fetcher.ui",
+                                         root_objects, NULL);
+  content = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+  g_object_ref (content);
+  priv->language = GTK_WIDGET (gtk_builder_get_object (builder, "language"));
+  priv->language_code = GTK_WIDGET (gtk_builder_get_object (builder, "language_code"));
+  priv->charset = GTK_WIDGET (gtk_builder_get_object (builder, "charset"));
+  priv->encoding = GTK_WIDGET (gtk_builder_get_object (builder, "encoding"));
+  priv->team_email = GTK_WIDGET (gtk_builder_get_object (builder, "team_email"));
+  priv->plural_forms = GTK_WIDGET (gtk_builder_get_object (builder, "plural_forms"));
+  priv->language_store = GTK_LIST_STORE (gtk_builder_get_object (builder, "language_store"));
+  priv->code_store = GTK_LIST_STORE (gtk_builder_get_object (builder, "code_store"));
+  g_object_unref (builder);
+
+  gtk_box_pack_start (GTK_BOX (fetcher), content, FALSE, FALSE, 0);
 
   /* add items to comboboxes */
   append_from_languages (fetcher);
 
-  g_signal_connect (gtk_bin_get_child (GTK_BIN (fetcher->priv->language)),
+  g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->language)),
                     "activate",
                     G_CALLBACK (on_language_activate),
                     fetcher);
-  g_signal_connect (gtk_bin_get_child (GTK_BIN (fetcher->priv->language)),
+  g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->language)),
                     "focus-out-event",
                     G_CALLBACK (on_language_focus_out_event),
                     fetcher);
-  g_signal_connect (gtk_bin_get_child (GTK_BIN (fetcher->priv->language_code)),
+  g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->language_code)),
                     "activate",
                     G_CALLBACK (on_language_code_activate),
                     fetcher);
-  g_signal_connect (gtk_bin_get_child (GTK_BIN (fetcher->priv->language_code)),
+  g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->language_code)),
                     "focus-out-event",
                     G_CALLBACK (on_language_code_focus_out_event),
                     fetcher);
 
   /* To emit the changed signal */
-  g_signal_connect (fetcher->priv->language, "changed",
+  g_signal_connect (priv->language, "changed",
                     G_CALLBACK (on_combo_box_changed),
                     fetcher);
-  g_signal_connect (fetcher->priv->language_code, "changed",
+  g_signal_connect (priv->language_code, "changed",
                     G_CALLBACK (on_combo_box_changed),
                     fetcher);
-  g_signal_connect (fetcher->priv->charset, "changed",
+  g_signal_connect (priv->charset, "changed",
                     G_CALLBACK (on_combo_box_changed),
                     fetcher);
-  g_signal_connect (fetcher->priv->encoding, "changed",
+  g_signal_connect (priv->encoding, "changed",
                     G_CALLBACK (on_combo_box_changed),
                     fetcher);
-  g_signal_connect (fetcher->priv->team_email, "changed",
+  g_signal_connect (priv->team_email, "changed",
                     G_CALLBACK (on_combo_box_changed),
                     fetcher);
-  g_signal_connect (fetcher->priv->plural_forms, "changed",
+  g_signal_connect (priv->plural_forms, "changed",
                     G_CALLBACK (on_combo_box_changed),
                     fetcher);
 }
diff --git a/src/gtr-preferences-dialog.c b/src/gtr-preferences-dialog.c
index c44e823..4fc6a8c 100644
--- a/src/gtr-preferences-dialog.c
+++ b/src/gtr-preferences-dialog.c
@@ -612,10 +612,11 @@ dialog_response_handler (GtkDialog * dlg, gint res_id)
 static void
 gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
 {
-  gboolean ret;
-  GtkWidget *error_widget, *action_area;
+  GtrPreferencesDialogPrivate *priv;
+  GtkWidget *action_area;
   GtkWidget *profiles_toolbar;
   GtkWidget *profiles_scrolled_window;
+  GtkBuilder *builder;
   GtkBox *content_area;
   GtkStyleContext *context;
   gchar *root_objects[] = {
@@ -626,13 +627,13 @@ gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
     "model1",
     NULL
   };
-  gchar *path;
 
   dlg->priv = GTR_PREFERENCES_DIALOG_GET_PRIVATE (dlg);
+  priv = dlg->priv;
 
-  dlg->priv->ui_settings = g_settings_new ("org.gnome.gtranslator.preferences.ui");
-  dlg->priv->editor_settings = g_settings_new ("org.gnome.gtranslator.preferences.editor");
-  dlg->priv->files_settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
+  priv->ui_settings = g_settings_new ("org.gnome.gtranslator.preferences.ui");
+  priv->editor_settings = g_settings_new ("org.gnome.gtranslator.preferences.editor");
+  priv->files_settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
 
   gtk_dialog_add_buttons (GTK_DIALOG (dlg),
                           GTK_STOCK_CLOSE,
@@ -655,60 +656,35 @@ gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
   g_signal_connect (dlg,
                     "response", G_CALLBACK (dialog_response_handler), NULL);
 
-  /*Glade */
-
-  path = gtr_dirs_get_ui_file ("gtr-preferences-dialog.ui");
-  ret = gtr_utils_get_ui_objects (path,
-                                  root_objects,
-                                  &error_widget,
-                                  "notebook", &dlg->priv->notebook,
-                                  "warn_if_fuzzy_checkbutton",
-                                  &dlg->
-                                  priv->warn_if_contains_fuzzy_checkbutton,
-                                  "autosave_checkbutton",
-                                  &dlg->priv->autosave_checkbutton,
-                                  "autosave_interval_spinbutton",
-                                  &dlg->priv->autosave_interval_spinbutton,
-                                  "autosave_hbox", &dlg->priv->autosave_hbox,
-                                  "create_backup_checkbutton",
-                                  &dlg->priv->create_backup_checkbutton,
-                                  "highlight_checkbutton",
-                                  &dlg->priv->highlight_syntax_checkbutton,
-                                  "visible_whitespace_checkbutton",
-                                  &dlg->priv->visible_whitespace_checkbutton,
-                                  "use_custom_font_checkbutton",
-                                  &dlg->priv->use_custom_font_checkbutton,
-                                  "editor_font_fontbutton",
-                                  &dlg->priv->editor_font_fontbutton,
-                                  "editor_font_hbox",
-                                  &dlg->priv->editor_font_hbox,
-                                  "unmark_fuzzy_checkbutton",
-                                  &dlg->
-                                  priv->unmark_fuzzy_when_changed_checkbutton,
-                                  "spellcheck_checkbutton",
-                                  &dlg->priv->spellcheck_checkbutton,
-                                  "profile_treeview",
-                                  &dlg->priv->profile_treeview, "add-button",
-                                  &dlg->priv->add_button, "edit-button",
-                                  &dlg->priv->edit_button, "delete-button",
-                                  &dlg->priv->delete_button,
-                                  "profiles-toolbar", &profiles_toolbar,
-                                  "profiles-scrolledwindow", &profiles_scrolled_window,
-                                  "plugins_box", &dlg->priv->plugins_box,
-                                  NULL);
-  g_free (path);
-
-  if (!ret)
-    {
-      gtk_widget_show (error_widget);
-      gtk_box_pack_start (content_area, error_widget, TRUE, TRUE, 0);
-
-      return;
-    }
-
-  gtk_box_pack_start (content_area, dlg->priv->notebook, FALSE, FALSE, 0);
-
-  gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->notebook), 5);
+  builder = gtk_builder_new ();
+  gtk_builder_add_objects_from_resource (builder, "/org/gnome/gtranslator/ui/gtr-preferences-dialog.ui",
+                                         root_objects, NULL);
+  priv->notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+  g_object_ref (priv->notebook);
+  priv->warn_if_contains_fuzzy_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "warn_if_fuzzy_checkbutton"));
+  priv->autosave_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "autosave_checkbutton"));
+  priv->autosave_interval_spinbutton = GTK_WIDGET (gtk_builder_get_object (builder, "autosave_interval_spinbutton"));
+  priv->autosave_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "autosave_hbox"));
+  priv->create_backup_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "create_backup_checkbutton"));
+  priv->highlight_syntax_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "highlight_checkbutton"));
+  priv->visible_whitespace_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "visible_whitespace_checkbutton"));
+  priv->use_custom_font_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "use_custom_font_checkbutton"));
+  priv->editor_font_fontbutton = GTK_WIDGET (gtk_builder_get_object (builder, "editor_font_fontbutton"));
+  priv->editor_font_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "editor_font_hbox"));
+  priv->unmark_fuzzy_when_changed_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "unmark_fuzzy_checkbutton"));
+  priv->spellcheck_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "spellcheck_checkbutton"));
+  priv->profile_treeview = GTK_WIDGET (gtk_builder_get_object (builder, "profile_treeview"));
+  priv->add_button = GTK_WIDGET (gtk_builder_get_object (builder, "add-button"));
+  priv->edit_button = GTK_WIDGET (gtk_builder_get_object (builder, "edit-button"));
+  priv->delete_button = GTK_WIDGET (gtk_builder_get_object (builder, "delete-button"));
+  profiles_toolbar = GTK_WIDGET (gtk_builder_get_object (builder, "profiles-toolbar"));
+  profiles_scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, "profiles-scrolledwindow"));
+  priv->plugins_box = GTK_WIDGET (gtk_builder_get_object (builder, "plugins_box"));
+  g_object_unref (builder);
+
+  gtk_box_pack_start (content_area, priv->notebook, FALSE, FALSE, 0);
+
+  gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), 5);
 
   context = gtk_widget_get_style_context (profiles_scrolled_window);
   gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
diff --git a/src/gtr-profile-dialog.c b/src/gtr-profile-dialog.c
index c24195e..035735f 100644
--- a/src/gtr-profile-dialog.c
+++ b/src/gtr-profile-dialog.c
@@ -63,17 +63,18 @@ gtr_profile_dialog_class_init (GtrProfileDialogClass *klass)
 static void
 gtr_profile_dialog_init (GtrProfileDialog *dlg)
 {
-  gboolean ret;
-  GtkWidget *error_widget, *action_area;
+  GtrProfileDialogPrivate *priv;
+  GtkWidget *action_area;
   GtkBox *content_area;
   GtkWidget *fetcher_box;
-  gchar *path;
+  GtkBuilder *builder;
   gchar *root_objects[] = {
     "main_box",
     NULL
   };
 
   dlg->priv = GTR_PROFILE_DIALOG_GET_PRIVATE (dlg);
+  priv = dlg->priv;
 
   gtk_dialog_add_button (GTK_DIALOG (dlg),
                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
@@ -92,31 +93,27 @@ gtr_profile_dialog_init (GtrProfileDialog *dlg)
   gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
   gtk_box_set_spacing (GTK_BOX (action_area), 4);
 
-  path = gtr_dirs_get_ui_file ("gtr-profile-dialog.ui");
-  ret = gtr_utils_get_ui_objects (path,
-                                  root_objects,
-                                  &error_widget,
-                                  "main_box", &dlg->priv->main_box,
-                                  "profile_name", &dlg->priv->profile_name,
-                                  "name", &dlg->priv->author_name,
-                                  "email", &dlg->priv->author_email,
-                                  "fetcher_box", &fetcher_box,
-                                  NULL);
-  g_free (path);
-
-  if (!ret)
-    {
-      gtk_widget_show (error_widget);
-      gtk_box_pack_start (content_area, error_widget, TRUE, TRUE, 0);
-
-      return;
-    }
-
-  gtk_box_pack_start (content_area, dlg->priv->main_box, FALSE, FALSE, 0);
+  builder = gtk_builder_new ();
+  GError *error = NULL;
+  gtk_builder_add_objects_from_resource (builder, "/org/gnome/gtranslator/ui/gtr-profile-dialog.ui",
+                                         root_objects, &error);
+  if (error)
+  {
+    g_message(error->message);
+  }
+  priv->main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+  g_object_ref (priv->main_box);
+  priv->profile_name = GTK_WIDGET (gtk_builder_get_object (builder, "profile_name"));
+  priv->author_name = GTK_WIDGET (gtk_builder_get_object (builder, "name"));
+  priv->author_email = GTK_WIDGET (gtk_builder_get_object (builder, "email"));
+  fetcher_box = GTK_WIDGET (gtk_builder_get_object (builder, "fetcher_box"));
+  g_object_unref (builder);
+
+  gtk_box_pack_start (content_area, priv->main_box, FALSE, FALSE, 0);
 
   dlg->priv->languages_fetcher = gtr_languages_fetcher_new ();
-  gtk_widget_show (dlg->priv->languages_fetcher);
-  gtk_box_pack_start (GTK_BOX (fetcher_box), dlg->priv->languages_fetcher,
+  gtk_widget_show (priv->languages_fetcher);
+  gtk_box_pack_start (GTK_BOX (fetcher_box), priv->languages_fetcher,
                       TRUE, TRUE, 0);
 }
 
diff --git a/src/gtr-search-dialog.c b/src/gtr-search-dialog.c
index 3e0077c..22962d0 100644
--- a/src/gtr-search-dialog.c
+++ b/src/gtr-search-dialog.c
@@ -355,10 +355,9 @@ static void
 gtr_search_dialog_init (GtrSearchDialog * dlg)
 {
   GtkWidget *content;
-  GtkWidget *error_widget, *action_area;
+  GtkWidget *action_area;
+  GtkBuilder *builder;
   GtkBox *content_area;
-  gboolean ret;
-  gchar *path;
   gchar *root_objects[] = {
     "search_dialog_content",
     NULL
@@ -381,50 +380,27 @@ gtr_search_dialog_init (GtrSearchDialog * dlg)
   gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
   gtk_box_set_spacing (GTK_BOX (action_area), 6);
 
-  path = gtr_dirs_get_ui_file ("gtr-search-dialog.ui");
-  ret = gtr_utils_get_ui_objects (path,
-                                  root_objects,
-                                  &error_widget,
-                                  "search_dialog_content", &content,
-                                  "grid", &dlg->priv->grid,
-                                  "search_label",
-                                  &dlg->priv->search_label,
-                                  "replace_with_label",
-                                  &dlg->priv->replace_label,
-                                  "original_text_checkbutton",
-                                  &dlg->priv->original_text_checkbutton,
-                                  "translated_text_checkbutton",
-                                  &dlg->priv->translated_text_checkbutton,
-                                  "fuzzy_checkbutton",
-                                  &dlg->priv->fuzzy_checkbutton,
-                                  "match_case_checkbutton",
-                                  &dlg->priv->match_case_checkbutton,
-                                  "entire_word_checkbutton",
-                                  &dlg->priv->entire_word_checkbutton,
-                                  "search_backwards_checkbutton",
-                                  &dlg->priv->backwards_checkbutton,
-                                  "wrap_around_checkbutton",
-                                  &dlg->priv->wrap_around_checkbutton, NULL);
-  g_free (path);
-
-  if (!ret)
-    {
-      gtk_widget_show (error_widget);
-
-      gtk_box_pack_start (content_area, error_widget, TRUE, TRUE, 0);
-
-      gtk_container_set_border_width (GTK_CONTAINER (error_widget), 5);
-
-      dlg->priv->glade_error = TRUE;
-
-      return;
-    }
+  builder = gtk_builder_new ();
+  gtk_builder_add_objects_from_resource (builder, "/org/gnome/gtranslator/ui/gtr-search-dialog.ui",
+                                         root_objects, NULL);
+  content = GTK_WIDGET (gtk_builder_get_object (builder, "search_dialog_content"));
+  g_object_ref (content);
+  dlg->priv->grid = GTK_WIDGET (gtk_builder_get_object (builder, "grid"));
+  dlg->priv->search_label = GTK_WIDGET (gtk_builder_get_object (builder, "search_label"));
+  dlg->priv->replace_label = GTK_WIDGET (gtk_builder_get_object (builder, "replace_with_label"));
+  dlg->priv->original_text_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "original_text_checkbutton"));
+  dlg->priv->translated_text_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "translated_text_checkbutton"));
+  dlg->priv->fuzzy_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "fuzzy_checkbutton"));
+  dlg->priv->match_case_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "match_case_checkbutton"));
+  dlg->priv->entire_word_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "entire_word_checkbutton"));
+  dlg->priv->backwards_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "search_backwards_checkbutton"));
+  dlg->priv->wrap_around_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "wrap_around_checkbutton"));
+  g_object_unref (builder);
 
   dlg->priv->search_entry = gtr_history_entry_new ("search-for-entry", TRUE);
   gtk_widget_set_size_request (dlg->priv->search_entry, 300, -1);
-  gtr_history_entry_set_escape_func
-    (GTR_HISTORY_ENTRY (dlg->priv->search_entry),
-     (GtrHistoryEntryEscapeFunc) gtr_utils_escape_search_text);
+  gtr_history_entry_set_escape_func (GTR_HISTORY_ENTRY (dlg->priv->search_entry),
+                                     (GtrHistoryEntryEscapeFunc) gtr_utils_escape_search_text);
   gtk_widget_set_hexpand (GTK_WIDGET (dlg->priv->search_entry), TRUE);
 
   dlg->priv->search_text_entry = gtr_history_entry_get_entry (GTR_HISTORY_ENTRY (dlg->priv->search_entry));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]