[gnome-terminal] application: Use GResource for about data



commit 04fe1c444a6e3efb8357e5a6ead3ee16a088e703
Author: Christian Persch <chpe gnome org>
Date:   Sat Apr 14 22:42:00 2012 +0200

    application: Use GResource for about data

 src/Makefile.am            |    6 +-----
 src/terminal-util.c        |   20 +++++++++++++-------
 src/terminal.gresource.xml |    1 +
 3 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 1fb6190..ca3e43a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -261,11 +261,6 @@ gnome_terminal_migration_LDADD = \
 	$(MIGRATOR_LIBS) \
 	$(INTLLIBS)
 
-aboutdir = $(pkgdatadir)
-about_DATA = \
-	terminal.about \
-	$(NULL)
-
 builder_in_files = \
 	encodings-dialog.glade \
 	find-dialog.glade \
@@ -290,6 +285,7 @@ CLEANFILES = \
 	$(BUILT_SOURCES)
 
 EXTRA_DIST = \
+	terminal.about \
 	terminal.xml \
 	terminal-appmenu.ui \
 	terminal.gresource.xml \
diff --git a/src/terminal-util.c b/src/terminal-util.c
index 5ee2339..47d908a 100644
--- a/src/terminal-util.c
+++ b/src/terminal-util.c
@@ -179,25 +179,31 @@ terminal_util_show_about (GtkWindow *transient_parent)
     "Copyright  2007â2012 Christian Persch";
   char *licence_text;
   GKeyFile *key_file;
+  GBytes *bytes;
+  const guint8 *data;
+  gsize data_len;
   GError *error = NULL;
   char **authors, **contributors, **artists, **documenters, **array_strv;
   gsize n_authors = 0, n_contributors = 0, n_artists = 0, n_documenters = 0 , i;
   GPtrArray *array;
 
+  bytes = g_resources_lookup_data (TERMINAL_RESOURCES_PATH_PREFIX "ui/terminal.about", 
+                                   G_RESOURCE_LOOKUP_FLAGS_NONE,
+                                   &error);
+  g_assert_no_error (error);
+
+  data = g_bytes_get_data (bytes, &data_len);
   key_file = g_key_file_new ();
-  if (!g_key_file_load_from_file (key_file, TERM_PKGDATADIR G_DIR_SEPARATOR_S "terminal.about", 0, &error))
-    {
-      g_warning ("Couldn't load about data: %s\n", error->message);
-      g_error_free (error);
-      g_key_file_free (key_file);
-      return;
-    }
+  g_key_file_load_from_data (key_file, (const char *) data, data_len, 0, &error);
+  g_assert_no_error (error);
 
   authors = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Authors", &n_authors, NULL);
   contributors = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Contributors", &n_contributors, NULL);
   artists = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Artists", &n_artists, NULL);
   documenters = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Documenters", &n_documenters, NULL);
+
   g_key_file_free (key_file);
+  g_bytes_unref (bytes);
 
   array = g_ptr_array_new ();
 
diff --git a/src/terminal.gresource.xml b/src/terminal.gresource.xml
index ed3bf1a..84cc1f6 100644
--- a/src/terminal.gresource.xml
+++ b/src/terminal.gresource.xml
@@ -19,5 +19,6 @@
   <gresource prefix="/org/gnome/terminal">
     <file alias="ui/terminal.xml" compressed="true" preprocess="xml-stripblanks">terminal.xml</file>
     <file alias="ui/terminal-appmenu.ui" compressed="true" preprocess="xml-stripblanks">terminal-appmenu.ui</file>
+    <file alias="ui/terminal.about" compressed="true">terminal.about</file>
   </gresource>
 </gresources>



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