[gedit] spell: use gresource



commit 2019b3940c0f3af2d8e9460be516eb2bf0991f9e
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Thu Mar 1 18:15:51 2012 +0100

    spell: use gresource

 plugins/spell/Makefile.am                   |   13 +++---
 plugins/spell/gedit-spell-checker-dialog.c  |   58 ++++++++++----------------
 plugins/spell/gedit-spell-language-dialog.c |   30 ++++----------
 3 files changed, 37 insertions(+), 64 deletions(-)
---
diff --git a/plugins/spell/Makefile.am b/plugins/spell/Makefile.am
index 21b4cf3..d6940a3 100644
--- a/plugins/spell/Makefile.am
+++ b/plugins/spell/Makefile.am
@@ -11,7 +11,8 @@ INCLUDES = 							\
 
 BUILT_SOURCES = 					\
 	gedit-spell-marshal.c				\
-	gedit-spell-marshal.h
+	gedit-spell-marshal.h				\
+	gedit-spell-resources.c
 
 plugin_LTLIBRARIES = libspell.la
 
@@ -50,9 +51,6 @@ libosx_la_SOURCES = 		\
 libspell_la_LIBADD += libosx.la  $(GTK_MAC_LIBS)
 endif
 
-uidir = $(GEDIT_PLUGINS_DATA_DIR)/spell
-ui_DATA = spell-checker.ui languages-dialog.ui
-
 gedit-spell-marshal.h: gedit-spell-marshal.list $(GLIB_GENMARSHAL)
 	$(AM_V_GEN) $(GLIB_GENMARSHAL) $< --header --prefix=gedit_marshal > $@
 
@@ -60,6 +58,9 @@ gedit-spell-marshal.c: gedit-spell-marshal.list $(GLIB_GENMARSHAL)
 	$(AM_V_GEN) echo "#include \"gedit-spell-marshal.h\"" > $@ && \
 	$(GLIB_GENMARSHAL) $< --body --prefix=gedit_marshal >> $@
 
+gedit-spell-resources.c: gedit-spell.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies gedit-spell.gresource.xml)
+	$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source gedit-spell.gresource.xml
+
 plugin_in_files = spell.plugin.desktop.in
 
 %.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
@@ -67,9 +68,9 @@ plugin_in_files = spell.plugin.desktop.in
 plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
 
 EXTRA_DIST = 					\
-	$(ui_DATA)				\
 	$(plugin_in_files)			\
-	gedit-spell-marshal.list 
+	gedit-spell-marshal.list		\
+	gedit-spell.gresource.xml
 
 CLEANFILES = $(BUILT_SOURCES) $(plugin_DATA)
 
diff --git a/plugins/spell/gedit-spell-checker-dialog.c b/plugins/spell/gedit-spell-checker-dialog.c
index 3a3806d..34784d2 100644
--- a/plugins/spell/gedit-spell-checker-dialog.c
+++ b/plugins/spell/gedit-spell-checker-dialog.c
@@ -207,7 +207,7 @@ static void
 create_dialog (GeditSpellCheckerDialog *dlg,
 	       const gchar *data_dir)
 {
-	GtkWidget *error_widget;
+	GtkBuilder *builder;
 	GtkWidget *content;
 	GtkTreeViewColumn *column;
 	GtkCellRenderer *cell;
@@ -216,49 +216,35 @@ create_dialog (GeditSpellCheckerDialog *dlg,
 		"content",
 		"check_word_image",
 		"add_word_image",
-                "ignore_image",
-                "change_image",
-                "ignore_all_image",
-                "change_all_image",
+		"ignore_image",
+		"change_image",
+		"ignore_all_image",
+		"change_all_image",
 		NULL
 	};
-	gboolean ret;
-	gchar *ui_file;
 	
 	g_return_if_fail (dlg != NULL);
 
 	dlg->spell_checker = NULL;
 	dlg->misspelled_word = NULL;
 
-	ui_file = g_build_filename (data_dir, "spell-checker.ui", NULL);
-	ret = gedit_utils_get_ui_objects (ui_file,
-		root_objects,
-		&error_widget,
-
-		"content", &content,
-		"misspelled_word_label", &dlg->misspelled_word_label,
-		"word_entry", &dlg->word_entry,
-		"check_word_button", &dlg->check_word_button,
-		"ignore_button", &dlg->ignore_button,
-		"ignore_all_button", &dlg->ignore_all_button,
-		"change_button", &dlg->change_button,
-		"change_all_button", &dlg->change_all_button,
-		"add_word_button", &dlg->add_word_button,
-		"close_button", &dlg->close_button,
-		"suggestions_list", &dlg->suggestions_list,
-		"language_label", &dlg->language_label,
-		NULL);
-	g_free (ui_file);
-
-	if (!ret)
-	{
-		gtk_widget_show (error_widget);
-
-		gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
-				    error_widget, TRUE, TRUE, 0);
-
-		return;
-	}
+	builder = gtk_builder_new ();
+	gtk_builder_add_objects_from_resource (builder, "/org/gnome/gedit/plugins/spell/ui/spell-checker.ui",
+	                                       root_objects, NULL);
+	content = GTK_WIDGET (gtk_builder_get_object (builder, "content"));
+	g_object_ref (content);
+	dlg->misspelled_word_label = GTK_WIDGET (gtk_builder_get_object (builder, "misspelled_word_label"));
+	dlg->word_entry = GTK_WIDGET (gtk_builder_get_object (builder, "word_entry"));
+	dlg->check_word_button = GTK_WIDGET (gtk_builder_get_object (builder, "check_word_button"));
+	dlg->ignore_button = GTK_WIDGET (gtk_builder_get_object (builder, "ignore_button"));
+	dlg->ignore_all_button = GTK_WIDGET (gtk_builder_get_object (builder, "ignore_all_button"));
+	dlg->change_button = GTK_WIDGET (gtk_builder_get_object (builder, "change_button"));
+	dlg->change_all_button = GTK_WIDGET (gtk_builder_get_object (builder, "change_all_button"));
+	dlg->add_word_button = GTK_WIDGET (gtk_builder_get_object (builder, "add_word_button"));
+	dlg->close_button = GTK_WIDGET (gtk_builder_get_object (builder, "close_button"));
+	dlg->suggestions_list = GTK_WIDGET (gtk_builder_get_object (builder, "suggestions_list"));
+	dlg->language_label = GTK_WIDGET (gtk_builder_get_object (builder, "language_label"));
+	g_object_unref (builder);
 
 	gtk_label_set_label (GTK_LABEL (dlg->misspelled_word_label), "");
 	gtk_widget_set_sensitive (dlg->word_entry, FALSE);
diff --git a/plugins/spell/gedit-spell-language-dialog.c b/plugins/spell/gedit-spell-language-dialog.c
index 61c7833..36f5d8f 100644
--- a/plugins/spell/gedit-spell-language-dialog.c
+++ b/plugins/spell/gedit-spell-language-dialog.c
@@ -119,12 +119,10 @@ static void
 create_dialog (GeditSpellLanguageDialog *dlg,
 	       const gchar *data_dir)
 {
-	GtkWidget *error_widget;
+	GtkBuilder *builder;
 	GtkWidget *content;
-	gboolean ret;
 	GtkCellRenderer *cell;
 	GtkTreeViewColumn *column;
-	gchar *ui_file;
 	gchar *root_objects[] = {
 		"content",
 		NULL
@@ -157,25 +155,13 @@ create_dialog (GeditSpellLanguageDialog *dlg,
 			  G_CALLBACK (dialog_response_handler),
 			  NULL);
 
-	ui_file = g_build_filename (data_dir, "languages-dialog.ui", NULL);
-	ret = gedit_utils_get_ui_objects (ui_file,
-					  root_objects,	
-					  &error_widget,
-					  "content", &content,
-					  "languages_treeview", &dlg->languages_treeview,
-					  NULL);
-	g_free (ui_file);
-	
-	if (!ret)
-	{
-		gtk_widget_show (error_widget);
-
-		gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
-		                    error_widget,
-		                    TRUE, TRUE, 0);
-
-		return;
-	}
+	builder = gtk_builder_new ();
+	gtk_builder_add_objects_from_resource (builder, "/org/gnome/gedit/plugins/spell/ui/languages-dialog.ui",
+	                                       root_objects, NULL);
+	content = GTK_WIDGET (gtk_builder_get_object (builder, "content"));
+	g_object_ref (content);
+	dlg->languages_treeview = GTK_WIDGET (gtk_builder_get_object (builder, "languages_treeview"));
+	g_object_unref (builder);
 
 	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
 			    content, TRUE, TRUE, 0);



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