[gtranslator] Codeview plugin using Gresource



commit 724ca4b37e9893c2b170e8d30d0412177bbae3f5
Author: Daniel Mustieles <daniel mustieles gmail com>
Date:   Thu Apr 12 13:39:23 2012 +0200

    Codeview plugin using Gresource

 plugins/codeview/Makefile.am                |   19 +++++++++------
 plugins/codeview/gtr-codeview-plugin.c      |   33 +++++++++-----------------
 plugins/codeview/gtr-codeview.gresource.xml |    6 +++++
 3 files changed, 29 insertions(+), 29 deletions(-)
---
diff --git a/plugins/codeview/Makefile.am b/plugins/codeview/Makefile.am
index 847293b..6b152a0 100644
--- a/plugins/codeview/Makefile.am
+++ b/plugins/codeview/Makefile.am
@@ -8,6 +8,9 @@ INCLUDES = \
 	$(WARN_CFLAGS)					\
 	$(DISABLE_DEPRECATED)
 
+BUILT_SOURCES = \
+	gtr-codeview-resources.c
+
 plugin_LTLIBRARIES = \
 	libsourcecodeview.la
 
@@ -15,17 +18,16 @@ libsourcecodeview_la_SOURCES = \
 	gtr-codeview-plugin.c \
 	gtr-codeview-plugin.h \
 	gtr-viewer.c \
-	gtr-viewer.h
+	gtr-viewer.h \
+	$(BUILT_SOURCES)
 
 libsourcecodeview_la_LDFLAGS = \
 	$(PLUGIN_LIBTOOL_FLAGS)				\
 	$(GTRANSLATOR_LIBS)
 
-uidir = $(pkgdatadir)/ui
 
-ui_DATA =  \
-	gtr-viewer.ui \
-	gtr-codeview-dialog.ui
+gtr-codeview-resources.c: gtr-codeview.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies gtr-codeview.gresource.xml)
+			$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source gtr-codeview.gresource.xml
 
 # Plugin Info
 
@@ -43,11 +45,12 @@ gsettings_SCHEMAS = org.gnome.gtranslator.plugins.codeview.gschema.xml
 
 EXTRA_DIST =	\
 	$(plugin_in_files)	\
-	$(ui_DATA)		\
+	gtr-codeview.gresource.xml	\
+	gtr-codeview-dialog.ui	\
 	org.gnome.gtranslator.plugins.codeview.gschema.xml.in.in
 
-CLEANFILES = $(plugin_DATA) $(gsettings_SCHEMAS)
-DISTCLEANFILES = $(plugin_DATA) $(gsettings_SCHEMAS)
+CLEANFILES = $(plugin_DATA) $(gsettings_SCHEMAS) $(BUILT_SOURCES)
+DISTCLEANFILES = $(plugin_DATA) $(gsettings_SCHEMAS) $(BUILT_SOURCES)
 
 MAINTAINERCLEANFILES = $(gsettings_SCHEMAS:.xml=.valid)
 
diff --git a/plugins/codeview/gtr-codeview-plugin.c b/plugins/codeview/gtr-codeview-plugin.c
index 5e817c3..456dcd3 100644
--- a/plugins/codeview/gtr-codeview-plugin.c
+++ b/plugins/codeview/gtr-codeview-plugin.c
@@ -636,10 +636,9 @@ configure_widget_destroyed (GtkWidget *widget,
 static GtkWidget *
 get_configuration_dialog (GtrCodeViewPlugin *plugin)
 {
+
   GtrCodeViewConfigureWidget *widget;
-  gboolean ret;
-  GtkWidget *error_widget;
-  gchar *path;
+  GtkBuilder *builder;
   gchar *root_objects[] = {
     "main_box",
     NULL
@@ -648,24 +647,16 @@ get_configuration_dialog (GtrCodeViewPlugin *plugin)
   widget = g_slice_new (GtrCodeViewConfigureWidget);
   widget->settings = g_object_ref (plugin->priv->settings);
 
-  path = gtr_dirs_get_ui_file ("gtr-codeview-dialog.ui");
-  ret = gtr_utils_get_ui_objects (path,
-                                  root_objects,
-                                  &error_widget,
-                                  "main_box", &widget->main_box,
-                                  "use_editor", &widget->use_editor_checkbutton,
-                                  "program_box", &widget->program_box,
-                                  "program_cmd", &widget->program_cmd_entry,
-                                  "line_cmd", &widget->line_cmd_entry, NULL);
-
-  if (!ret)
-    {
-      g_error ("Error loading file \"%s\"", path);
-      g_free (path);
-      return NULL;
-    }
-
-  g_free (path);
+  builder = gtk_builder_new ();
+  gtk_builder_add_objects_from_resource (builder, "/org/gnome/gtranslator/plugins/codeview/ui/gtr-codeview-dialog.ui",
+					 root_objects, NULL);
+  widget->main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+  g_object_ref (widget->main_box);
+  widget->use_editor_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "use_editor"));
+  widget->program_box = GTK_WIDGET (gtk_builder_get_object (builder, "program_box"));
+  widget->program_cmd_entry = GTK_WIDGET (gtk_builder_get_object (builder, "program_cmd"));
+  widget->line_cmd_entry = GTK_WIDGET (gtk_builder_get_object (builder, "line_cmd"));
+  g_object_unref (builder);
 
   /* Use editor */
   gtk_widget_set_sensitive (widget->program_box,
diff --git a/plugins/codeview/gtr-codeview.gresource.xml b/plugins/codeview/gtr-codeview.gresource.xml
new file mode 100644
index 0000000..835ae54
--- /dev/null
+++ b/plugins/codeview/gtr-codeview.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/gtranslator/plugins/codeview/ui">
+  <file preprocess="xml-stripblanks">gtr-codeview-dialog.ui</file>
+ </gresource>
+</gresources>



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