From 9f6878c35af7333ce7818c41fd39e4810e80d2a8 Mon Sep 17 00:00:00 2001 From: Jonathon Jongsma Date: Wed, 15 Jan 2014 12:01:26 -0600 Subject: [PATCH] Load ui files first from installed location virt_viewer_util_load_ui() looks first in the current directory, and then looks in the system data dirs for a ui file to load, but if you install virt-viewer in a different prefix, it will load the system UI file rather than the one from the install prefix. Try to load the ui file from pkgdatadir first. --- src/Makefile.am | 2 ++ src/virt-viewer-util.c | 26 ++++++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 12f71f3..b3a9637 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -135,6 +135,8 @@ if OS_WIN32 remote_viewer_LDFLAGS += -Wl,--subsystem,windows endif +AM_CPPFLAGS = -DPACKAGE_DATADIR=\""$(pkgdatadir)"\" + VIRT_VIEWER_RES = virt-viewer.rc virt-viewer.manifest ICONDIR = $(top_builddir)/icons MANIFESTDIR = $(srcdir) diff --git a/src/virt-viewer-util.c b/src/virt-viewer-util.c index e4db928..9deddad 100644 --- a/src/virt-viewer-util.c +++ b/src/virt-viewer-util.c @@ -57,20 +57,26 @@ GtkBuilder *virt_viewer_util_load_ui(const char *name) if (stat(name, &sb) >= 0) { gtk_builder_add_from_file(builder, name, &error); } else { - const gchar * const * dirs = g_get_system_data_dirs(); - g_return_val_if_fail(dirs != NULL, NULL); + gchar *path = g_build_filename(PACKAGE_DATADIR, "ui", name, NULL); + gboolean success = (gtk_builder_add_from_file(builder, path, NULL) != 0); + g_free(path); - while (dirs[0] != NULL) { - gchar *path = g_build_filename(dirs[0], PACKAGE, "ui", name, NULL); - if (gtk_builder_add_from_file(builder, path, NULL) != 0) { + if (!success) { + const gchar * const * dirs = g_get_system_data_dirs(); + g_return_val_if_fail(dirs != NULL, NULL); + + while (dirs[0] != NULL) { + path = g_build_filename(dirs[0], PACKAGE, "ui", name, NULL); + if (gtk_builder_add_from_file(builder, path, NULL) != 0) { + g_free(path); + break; + } g_free(path); - break; + dirs++; } - g_free(path); - dirs++; + if (dirs[0] == NULL) + goto failed; } - if (dirs[0] == NULL) - goto failed; } if (error) {