[virt-tools-list] [PATCH 1/5] app: Set the resource base path

Fabiano Fidêncio fidencio at redhat.com
Sat Dec 17 16:50:08 UTC 2016

GApplication's resource base path is based on the application-id, for
 - virt-viewer's resource base path: /org/virt-manager/virt-viewer, as
   the virt-viewer's application id is: org.virt-manager.virt-viewer.
 - remote-viewer's resource bash path: /org/virt-manager/remote-viewer
   as remote-viewer's application id is: org.virt-manager.remote-viewer

It's a issue because our resources have /org/virt-manager/virt-viewer
and Gtk, when trying to automatically load ui files (as done for
gtk/menu.ui, gtk/menus-appmenu.ui, gtk/menus-tradicional.ui and
gtk/help-overlay.ui), searches for these files in the base path.

For solving this issue, we can basically set the resource path using
g_application_set_resource_base_path() method. A check could be done and
this method could be called only when running remote-viewer, but as it's
a simple call, called only when the application starts I decided to go
without the application-id's check.

g_application_set_resource_base_path() was introduced in GLib 2.42 and
that's the reason I'm also bumping GLib dependency's version. Currently
it makes impossible to build virt-viewer on SLES 12 SP1 as it still has
GLib 2.38, so postponing this patch till SLES 12 SP2 release is

Signed-off-by: Fabiano Fidêncio <fabiano at fidencio.org>
 configure.ac          | 4 ++--
 src/virt-viewer-app.c | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index ce71349..b9b6550 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,8 +13,8 @@ m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
 # Keep these two definitions in agreement.
 # Keep these two definitions in agreement.
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index bf32315..28b4f60 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -1792,6 +1792,8 @@ virt_viewer_app_on_application_startup(GApplication *app)
     VirtViewerApp *self = VIRT_VIEWER_APP(app);
     GError *error = NULL;
+    g_application_set_resource_base_path(app, "/org/virt-manager/virt-viewer");
     self->priv->resource = virt_viewer_get_resource();

More information about the virt-tools-list mailing list