[nautilus-sendto] Fix loading packer UI file from uninstalled



commit 68fda37e38eac8be4d8aace46ca0222617b94228
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Aug 16 14:37:12 2010 +0100

    Fix loading packer UI file from uninstalled

 src/nautilus-sendto-command.c |    6 ++++--
 src/plugins/Makefile.am       |    5 ++++-
 src/plugins/nst-common.c      |   11 ++++++++---
 3 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/src/nautilus-sendto-command.c b/src/nautilus-sendto-command.c
index e6d249d..72c765d 100644
--- a/src/nautilus-sendto-command.c
+++ b/src/nautilus-sendto-command.c
@@ -334,10 +334,12 @@ nautilus_sendto_create_ui (void)
 	const char *ui_file;
 
 	app = gtk_builder_new ();
-	if (run_from_build_dir)
+	if (run_from_build_dir) {
 		ui_file = "nautilus-sendto.ui";
-	else
+		g_setenv ("NST_RUN_FROM_BUILDDIR", "1", TRUE);
+	} else {
 		ui_file = UIDIR "/" "nautilus-sendto.ui";
+	}
 
 	if (!gtk_builder_add_from_file (app, ui_file, &error)) {
 		g_warning ("Couldn't load builder file: %s", error->message);
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 1f4710f..5d07dfd 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -6,7 +6,7 @@ NST_COMMON_SOURCES = nst-common.c nst-common.h
 
 noinst_LTLIBRARIES = libnstcommon.la
 libnstcommon_la_SOURCES = $(NST_COMMON_SOURCES)
-libnstcommon_la_CFLAGS = $(NAUTILUS_SENDTO_CFLAGS)
+libnstcommon_la_CFLAGS = $(NAUTILUS_SENDTO_CFLAGS) -DUIDIR=\""$(uidir)"\"
 libnstcommon_la_LIBADD = $(NAUTILUS_SENDTO_LIBS)
 
 EXTRA_DIST = $(NST_COMMON_SOURCES)
@@ -19,6 +19,9 @@ libnautilussendto_1_0_la_SOURCES = nautilus-sendto-plugin.h nautilus-sendto-plug
 libnautilussendto_1_0_la_LIBADD = $(NAUTILUS_SENDTO_LIBS)
 libnautilussendto_1_0_la_CFLAGS = $(NAUTILUS_SENDTO_CFLAGS)
 
+ui_DATA = pack-entry.ui
+uidir = $(datadir)/nautilus-sendto/ui
+
 if HAVE_INTROSPECTION
 -include $(INTROSPECTION_MAKEFILE)
 INTROSPECTION_GIRS = NautilusSendto-1.0.gir
diff --git a/src/plugins/nst-common.c b/src/plugins/nst-common.c
index d0703f4..61a8c6b 100644
--- a/src/plugins/nst-common.c
+++ b/src/plugins/nst-common.c
@@ -217,14 +217,19 @@ nst_pack_widget_init (NstPackWidget *self)
 	GtkWidget *vbox;
 	NstPackWidgetPrivate *priv;
 	GSettings *settings;
+	const char *ui_file;
 
 	self->priv = NST_PACK_WIDGET_GET_PRIVATE (self);
 	priv = self->priv;
 
 	builder = gtk_builder_new ();
-	//FIXME load from system
-	if (!gtk_builder_add_from_file (builder, "plugins/pack-entry.ui", &error)) {
-		g_warning ("Couldn't load builder file: %s", error->message);
+	if (g_getenv ("NST_RUN_FROM_BUILDDIR") != NULL)
+		ui_file = "plugins/pack-entry.ui";
+	else
+		ui_file = UIDIR "/" "pack-entry.ui";
+
+	if (!gtk_builder_add_from_file (builder, ui_file, &error)) {
+		g_warning ("Couldn't load builder file '%s': %s", ui_file, error->message);
 		g_error_free (error);
 	}
 



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