[ghex] Use resources framework
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ghex] Use resources framework
- Date: Thu, 1 Mar 2012 23:51:46 +0000 (UTC)
commit 3999be846981b9c468dd35bce1bdf7fdf2f5c90e
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Feb 2 03:48:28 2012 -0500
Use resources framework
https://bugzilla.gnome.org/show_bug.cgi?id=671101
src/Makefile.am | 20 +++++++++++++-------
src/ghex-window.c | 31 +++----------------------------
src/ghex.gresource.xml | 6 ++++++
3 files changed, 22 insertions(+), 35 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 0a1fce1..8958d00 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,9 +10,18 @@ INCLUDES = \
$(WARN_CFLAGS) \
$(DISABLE_DEPRECATED)
+ghex-resources.c: ghex.gresource.xml ghex-ui.xml
+ glib-compile-resources --target=$@ --generate-source --c-name ghex --sourcedir=$(srcdir) $<
+
+ghex-resources.h: ghex.gresource.xml
+ glib-compile-resources --target=$@ --generate-header --c-name ghex --sourcedir=$(srcdir) $<
+
BUILT_SOURCES = \
ghex-marshal.c \
- ghex-marshal.h
+ ghex-marshal.h \
+ ghex-resources.c \
+ ghex-resources.h \
+ $(NULL)
bin_PROGRAMS = ghex
@@ -20,8 +29,6 @@ lib_LTLIBRARIES = libgtkhex-3.la
gtkhexincludedir = $(includedir)/gtkhex-3/
-uidir = $(pkgdatadir)
-
libgtkhex_3_la_SOURCES = \
hex-document.c \
gtkhex.c \
@@ -56,11 +63,10 @@ ghex-marshal.c: ghex-marshal.list $(GLIB_GENMARSHAL)
echo "#include \"ghex-marshal.h\"" > $@ && \
$(GLIB_GENMARSHAL) $< --body --prefix=ghex_marshal >> $@
-ui_DATA = ghex-ui.xml
-
EXTRA_DIST = \
- $(ui_DATA) \
- ghex-marshal.list
+ ghex-marshal.list \
+ ghex-ui.xml \
+ ghex.gresource.xml
LDADD = \
libgtkhex-3.la \
diff --git a/src/ghex-window.c b/src/ghex-window.c
index d1ff6c6..3354138 100644
--- a/src/ghex-window.c
+++ b/src/ghex-window.c
@@ -512,23 +512,6 @@ ghex_window_destroy_contents (GHexWindow *win)
win->contents = NULL;
}
-static gchar *
-ghex_datadir (void)
-{
- gchar *datadir;
-#ifdef G_OS_WIN32
- gchar *dir;
-
- dir = g_win32_get_package_installation_directory_of_module (NULL);
- datadir = g_build_filename (dir, "share", "ghex", NULL);
- g_free (dir);
-#else
- datadir = g_strdup (GHEXDATADIR);
-#endif
-
- return datadir;
-}
-
static GObject *
ghex_window_constructor (GType type,
guint n_construct_properties,
@@ -538,8 +521,6 @@ ghex_window_constructor (GType type,
GHexWindow *window;
GtkWidget *menubar;
GError *error = NULL;
- gchar *datadir;
- gchar *ui_path;
object = G_OBJECT_CLASS (ghex_window_parent_class)->constructor (type,
n_construct_properties,
@@ -578,17 +559,11 @@ ghex_window_constructor (GType type,
gtk_ui_manager_insert_action_group (window->ui_manager,
window->doc_list_action_group, 0);
- /* Load menu description from file */
- datadir = ghex_datadir ();
- ui_path = g_build_filename (datadir, "ghex-ui.xml", NULL);
- if (!gtk_ui_manager_add_ui_from_file (window->ui_manager, ui_path, &error)) {
- gchar *msg = g_strdup_printf (_("Failed to load UI: %s"), error->message);
+ /* Load menu description from resources framework */
+ if (!gtk_ui_manager_add_ui_from_resource (window->ui_manager, "/org/gnome/ghex/ghex-ui.xml", &error)) {
+ g_warning ("Failed to load ui: %s", error->message);
g_error_free (error);
- display_error_dialog (window, msg);
- g_free (msg);
}
- g_free (ui_path);
- g_free (datadir);
window->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
diff --git a/src/ghex.gresource.xml b/src/ghex.gresource.xml
new file mode 100644
index 0000000..4cccbc5
--- /dev/null
+++ b/src/ghex.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/ghex">
+ <file preprocess="xml-stripblanks">ghex-ui.xml</file>
+ </gresource>
+</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]