[gssdp] sniffer: Change to use UI from resource
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gssdp] sniffer: Change to use UI from resource
- Date: Fri, 26 Oct 2018 16:57:12 +0000 (UTC)
commit 69a233babc855fe937098a3004204e2fc2bc0ead
Author: Jens Georg <mail jensge org>
Date: Fri Oct 26 16:43:49 2018 +0200
sniffer: Change to use UI from resource
tools/gssdp-device-sniffer.c | 20 ++------------------
tools/gssdp-device-sniffer.gresource.xml | 6 ++++++
tools/meson.build | 22 ++++++++++++++--------
3 files changed, 22 insertions(+), 26 deletions(-)
---
diff --git a/tools/gssdp-device-sniffer.c b/tools/gssdp-device-sniffer.c
index 96442d6..55bd76c 100644
--- a/tools/gssdp-device-sniffer.c
+++ b/tools/gssdp-device-sniffer.c
@@ -24,7 +24,7 @@
#include <string.h>
#include <stdlib.h>
-#define UI_FILE "gssdp-device-sniffer.ui"
+#define UI_RESOURCE "/org/gupnp/GSSDP/DeviceSniffer.ui"
#define MAX_IP_LEN 16
static char *interface = NULL;
@@ -581,7 +581,6 @@ init_ui (gint *argc, gchar **argv[])
{
GtkWidget *main_window;
gint window_width, window_height;
- const gchar *ui_path = NULL;
GError *error = NULL;
GOptionContext *context;
double w, h;
@@ -596,23 +595,8 @@ init_ui (gint *argc, gchar **argv[])
return FALSE;
}
- /* Try to fetch the ui file from the CWD first */
- ui_path = UI_FILE;
- if (!g_file_test (ui_path, G_FILE_TEST_EXISTS)) {
- /* Then Try to fetch it from the system path */
- ui_path = UI_DIR "/" UI_FILE;
-
- if (!g_file_test (ui_path, G_FILE_TEST_EXISTS))
- ui_path = NULL;
- }
-
- if (ui_path == NULL) {
- g_critical ("Unable to load the GUI file %s", UI_FILE);
- return FALSE;
- }
-
builder = gtk_builder_new();
- if (gtk_builder_add_from_file(builder, ui_path, NULL) == 0)
+ if (gtk_builder_add_from_resource(builder, UI_RESOURCE, NULL) == 0)
return FALSE;
main_window = GTK_WIDGET(gtk_builder_get_object (builder, "main-window"));
diff --git a/tools/gssdp-device-sniffer.gresource.xml b/tools/gssdp-device-sniffer.gresource.xml
new file mode 100644
index 0000000..dd36bc0
--- /dev/null
+++ b/tools/gssdp-device-sniffer.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gupnp/GSSDP">
+ <file preprocess="xml-stripblanks" alias="DeviceSniffer.ui">gssdp-device-sniffer.ui</file>
+ </gresource>
+</gresources>
diff --git a/tools/meson.build b/tools/meson.build
index 3a5e891..b4b7aee 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -1,9 +1,15 @@
-sniffer_uidir = join_paths(get_option('datadir'), 'gssdp-1.2')
+resource = gnome.compile_resources(
+ 'org.gupnp.GSSDP.DeviceSniffer',
+ 'gssdp-device-sniffer.gresource.xml'
+)
-sniffer = executable('gssdp-device-sniffer',
- ['gssdp-device-sniffer.c'],
- dependencies : [gssdp, gtk],
- install: true,
- c_args : '-DUI_DIR="@0@"'.format(sniffer_uidir)
- )
-install_data('gssdp-device-sniffer.ui', install_dir : sniffer_uidir)
+sniffer = executable(
+ 'gssdp-device-sniffer',
+ [
+ 'gssdp-device-sniffer.c',
+ resource
+ ],
+ dependencies : [gssdp, gtk],
+ install: true,
+ export_dynamic : true
+)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]