mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/virt-viewer
synced 2025-12-27 23:00:54 +00:00
Lookup UI file correctly, to fix Windows support
This commit is contained in:
parent
76bcf50dc4
commit
1002a220a4
@ -52,5 +52,4 @@ virt_viewer_CFLAGS = \
|
||||
@LIBXML2_CFLAGS@ \
|
||||
@LIBVIRT_CFLAGS@ \
|
||||
@WARN_CFLAGS@ \
|
||||
-DBUILDER_XML_DIR="\"$(builderxmldir)\"" \
|
||||
-DLOCALE_DIR=\""$(datadir)/locale"\"
|
||||
|
||||
@ -42,16 +42,34 @@ GtkBuilder *virt_viewer_util_load_ui(const char *name)
|
||||
if (stat(name, &sb) >= 0) {
|
||||
gtk_builder_add_from_file(builder, name, &error);
|
||||
} else {
|
||||
gchar *path = g_strdup_printf("%s/%s", BUILDER_XML_DIR, name);
|
||||
gtk_builder_add_from_file(builder, path, &error);
|
||||
g_free(path);
|
||||
const gchar * const * dirs = g_get_system_data_dirs();
|
||||
g_return_val_if_fail(dirs != NULL, NULL);
|
||||
|
||||
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) {
|
||||
g_free(path);
|
||||
break;
|
||||
}
|
||||
g_free(path);
|
||||
dirs++;
|
||||
}
|
||||
if (dirs[0] == NULL)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (error)
|
||||
if (error) {
|
||||
g_error("Cannot load UI description %s: %s", name,
|
||||
error->message);
|
||||
g_clear_error(&error);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
return builder;
|
||||
failed:
|
||||
g_error("failed to find UI description file");
|
||||
g_object_unref(builder);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Loading…
Reference in New Issue
Block a user