[gedit] docinfo: use gresource
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] docinfo: use gresource
- Date: Sun, 26 Feb 2012 19:20:46 +0000 (UTC)
commit dc980fbbdaf5bee7beb82d939f5882d6b664c60b
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sun Feb 26 20:20:45 2012 +0100
docinfo: use gresource
plugins/docinfo/Makefile.am | 9 ++--
plugins/docinfo/gedit-docinfo-plugin.c | 70 +++++++++------------------
plugins/docinfo/gedit-docinfo.gresource.xml | 6 ++
3 files changed, 34 insertions(+), 51 deletions(-)
---
diff --git a/plugins/docinfo/Makefile.am b/plugins/docinfo/Makefile.am
index fd7ad77..f81ad5e 100644
--- a/plugins/docinfo/Makefile.am
+++ b/plugins/docinfo/Makefile.am
@@ -11,13 +11,14 @@ plugin_LTLIBRARIES = libdocinfo.la
libdocinfo_la_SOURCES = \
gedit-docinfo-plugin.h \
- gedit-docinfo-plugin.c
+ gedit-docinfo-plugin.c \
+ gedit-docinfo-resources.c
libdocinfo_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
libdocinfo_la_LIBADD = $(GEDIT_LIBS)
-uidir = $(GEDIT_PLUGINS_DATA_DIR)/docinfo
-ui_DATA = gedit-docinfo-plugin.ui
+gedit-docinfo-resources.c: gedit-docinfo.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies gedit-docinfo.gresource.xml)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source gedit-docinfo.gresource.xml
plugin_in_files = docinfo.plugin.desktop.in
@@ -25,7 +26,7 @@ plugin_in_files = docinfo.plugin.desktop.in
plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
-EXTRA_DIST = $(ui_DATA) $(plugin_in_files)
+EXTRA_DIST = $(plugin_in_files)
CLEANFILES = $(plugin_DATA)
DISTCLEANFILES = $(plugin_DATA)
diff --git a/plugins/docinfo/gedit-docinfo-plugin.c b/plugins/docinfo/gedit-docinfo-plugin.c
index 4714c8d..885ad63 100644
--- a/plugins/docinfo/gedit-docinfo-plugin.c
+++ b/plugins/docinfo/gedit-docinfo-plugin.c
@@ -323,58 +323,34 @@ static void
create_docinfo_dialog (GeditDocinfoPlugin *plugin)
{
GeditDocinfoPluginPrivate *priv;
- gchar *data_dir;
- gchar *ui_file;
- GtkWidget *content;
- GtkWidget *error_widget;
- gboolean ret;
+ GtkBuilder *builder;
gedit_debug (DEBUG_PLUGINS);
priv = plugin->priv;
- data_dir = peas_extension_base_get_data_dir (PEAS_EXTENSION_BASE (plugin));
-
- ui_file = g_build_filename (data_dir, "gedit-docinfo-plugin.ui", NULL);
- ret = gedit_utils_get_ui_objects (ui_file,
- NULL,
- &error_widget,
- "dialog", &priv->dialog,
- "docinfo_dialog_content", &content,
- "file_name_label", &priv->file_name_label,
- "words_label", &priv->words_label,
- "bytes_label", &priv->bytes_label,
- "lines_label", &priv->lines_label,
- "chars_label", &priv->chars_label,
- "chars_ns_label", &priv->chars_ns_label,
- "document_label", &priv->document_label,
- "document_words_label", &priv->document_words_label,
- "document_bytes_label", &priv->document_bytes_label,
- "document_lines_label", &priv->document_lines_label,
- "document_chars_label", &priv->document_chars_label,
- "document_chars_ns_label", &priv->document_chars_ns_label,
- "selection_label", &priv->selection_label,
- "selected_words_label", &priv->selected_words_label,
- "selected_bytes_label", &priv->selected_bytes_label,
- "selected_lines_label", &priv->selected_lines_label,
- "selected_chars_label", &priv->selected_chars_label,
- "selected_chars_ns_label", &priv->selected_chars_ns_label,
- NULL);
-
- g_free (data_dir);
- g_free (ui_file);
-
- if (!ret)
- {
- const gchar *err_message;
-
- err_message = gtk_label_get_label (GTK_LABEL (error_widget));
- gedit_warning (GTK_WINDOW (priv->window), "%s", err_message);
-
- gtk_widget_destroy (error_widget);
-
- return;
- }
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_resource (builder, "/org/gnome/gedit/plugins/docinfo/ui/gedit-docinfo-plugin.ui", NULL);
+ priv->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "dialog"));
+ priv->file_name_label = GTK_WIDGET (gtk_builder_get_object (builder, "file_name_label"));
+ priv->words_label = GTK_WIDGET (gtk_builder_get_object (builder, "words_label"));
+ priv->bytes_label = GTK_WIDGET (gtk_builder_get_object (builder, "bytes_label"));
+ priv->lines_label = GTK_WIDGET (gtk_builder_get_object (builder, "lines_label"));
+ priv->chars_label = GTK_WIDGET (gtk_builder_get_object (builder, "chars_label"));
+ priv->chars_ns_label = GTK_WIDGET (gtk_builder_get_object (builder, "chars_ns_label"));
+ priv->document_label = GTK_WIDGET (gtk_builder_get_object (builder, "document_label"));
+ priv->document_words_label = GTK_WIDGET (gtk_builder_get_object (builder, "document_words_label"));
+ priv->document_bytes_label = GTK_WIDGET (gtk_builder_get_object (builder, "document_bytes_label"));
+ priv->document_lines_label = GTK_WIDGET (gtk_builder_get_object (builder, "document_lines_label"));
+ priv->document_chars_label = GTK_WIDGET (gtk_builder_get_object (builder, "document_chars_label"));
+ priv->document_chars_ns_label = GTK_WIDGET (gtk_builder_get_object (builder, "document_chars_ns_label"));
+ priv->selection_label = GTK_WIDGET (gtk_builder_get_object (builder, "selection_label"));
+ priv->selected_words_label = GTK_WIDGET (gtk_builder_get_object (builder, "selected_words_label"));
+ priv->selected_bytes_label = GTK_WIDGET (gtk_builder_get_object (builder, "selected_bytes_label"));
+ priv->selected_lines_label = GTK_WIDGET (gtk_builder_get_object (builder, "selected_lines_label"));
+ priv->selected_chars_label = GTK_WIDGET (gtk_builder_get_object (builder, "selected_chars_label"));
+ priv->selected_chars_ns_label = GTK_WIDGET (gtk_builder_get_object (builder, "selected_chars_ns_label"));
+ g_object_unref (builder);
gtk_dialog_set_default_response (GTK_DIALOG (priv->dialog),
GTK_RESPONSE_OK);
diff --git a/plugins/docinfo/gedit-docinfo.gresource.xml b/plugins/docinfo/gedit-docinfo.gresource.xml
new file mode 100644
index 0000000..817c60f
--- /dev/null
+++ b/plugins/docinfo/gedit-docinfo.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/gedit/plugins/docinfo/ui">
+ <file preprocess="xml-stripblanks">gedit-docinfo-plugin.ui</file>
+ </gresource>
+</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]