diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2017-07-03 12:40:55 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2017-07-03 12:40:55 +0200 |
commit | 48d334acbeb665aae9c2f9f4867ff0afe836e7d3 (patch) | |
tree | 6ca13a6fbf4ef00eee73b5c76e2c9e1cbaa20293 /bin/gui/uca-camera-control.c | |
parent | f6b224b1cb6a7004a46c3606413db63f5101b816 (diff) | |
download | uca-48d334acbeb665aae9c2f9f4867ff0afe836e7d3.tar.gz uca-48d334acbeb665aae9c2f9f4867ff0afe836e7d3.tar.bz2 uca-48d334acbeb665aae9c2f9f4867ff0afe836e7d3.tar.xz uca-48d334acbeb665aae9c2f9f4867ff0afe836e7d3.zip |
gui: use glib-resources to bake in UI
Diffstat (limited to 'bin/gui/uca-camera-control.c')
-rw-r--r-- | bin/gui/uca-camera-control.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/bin/gui/uca-camera-control.c b/bin/gui/uca-camera-control.c index f59460d..375de2f 100644 --- a/bin/gui/uca-camera-control.c +++ b/bin/gui/uca-camera-control.c @@ -23,12 +23,12 @@ #include <cairo.h> #include <string.h> -#include "config.h" #include "uca-camera.h" #include "uca-plugin-manager.h" #include "uca-ring-buffer.h" #include "egg-property-tree-view.h" #include "egg-histogram-view.h" +#include "resources.h" typedef enum { IDLE, @@ -1548,6 +1548,29 @@ create_choice_window (GtkBuilder *builder) g_list_free (camera_types); } +static gboolean +builder_add_from_resource (GtkBuilder *builder, const gchar *resource_path, GError **error) +{ + GBytes *data; + const gchar *buffer; + gsize length; + gboolean ret; + + g_assert (error && *error == NULL); + data = g_resources_lookup_data (resource_path, 0, error); + + if (data == NULL) + return FALSE; + + length = 0; + buffer = g_bytes_get_data (data, &length); + g_assert (buffer != NULL); + + ret = gtk_builder_add_from_string (builder, buffer, length, error) > 0; + g_bytes_unref (data); + return ret; +} + int main (int argc, char *argv[]) { @@ -1578,15 +1601,9 @@ main (int argc, char *argv[]) builder = gtk_builder_new (); - if (!gtk_builder_add_from_file (builder, CONTROL_GLADE_PATH, &error)) { - g_warning ("Cannot load UI: `%s'. Trying in current working directory.", error->message); - g_error_free (error); - error = NULL; - - if (!gtk_builder_add_from_file (builder, "control.glade", &error)) { - g_warning ("Cannot load UI: `%s'.", error->message); - return 1; - } + if (!builder_add_from_resource (builder, "/edu/kit/ipe/uca-camera-control/uca-camera-control.glade", &error)) { + g_warning ("Could not load UI: %s", error->message); + return 1; } plugin_manager = uca_plugin_manager_new (); |