[network-manager-fortisslvpn] properties: use gresources



commit 8f6033c3421f20b204b4846b188139aa1fa35c2e
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Mon Jul 10 19:07:24 2017 +0200

    properties: use gresources

 .gitignore                         |    1 +
 Makefile.am                        |   16 +++++++++++++++-
 configure.ac                       |    1 +
 properties/gresource.xml           |    6 ++++++
 properties/nm-fortisslvpn-editor.c |   13 ++-----------
 5 files changed, 25 insertions(+), 12 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 524d4a3..cf9d9ac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,6 +36,7 @@ network-manager-fortisslvpn.metainfo.xml
 auth-dialog/nm-fortisslvpn-auth-dialog
 nm-fortisslvpn-service.name
 nm-fortisslvpn.desktop
+properties/resources.[ch]
 src/nm-fortisslvpn-pppd-service-dbus.c
 src/nm-fortisslvpn-pppd-service-dbus.h
 src/nm-fortisslvpn-service
diff --git a/Makefile.am b/Makefile.am
index c51a356..28ab80f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -94,20 +94,34 @@ src_nm_fortisslvpn_service_LDADD = \
 
 ###############################################################################
 
+properties/resources.h: properties/gresource.xml
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(srcdir)/properties 
--generate-header --internal
+
+properties/resources.c: properties/gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) 
--sourcedir=$(srcdir)/properties --generate-dependencies $(srcdir)/properties/gresource.xml)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(srcdir)/properties 
--generate-source --internal
+
 plugin_sources = \
        properties/nm-fortisslvpn-editor-plugin.c \
        properties/nm-fortisslvpn-editor-plugin.h
 
 editor_sources = \
+       properties/resources.c \
+       properties/resources.h \
        properties/nm-fortisslvpn-editor.c \
        properties/nm-fortisslvpn-editor.h
 
 properties_cppflags = \
-       -DUIDIR=\""$(uidir)"\" \
        -DLOCALEDIR=\"$(datadir)/locale\" \
        -I$(srcdir)/shared \
        $(GLIB_CFLAGS)
 
+CLEANFILES += \
+       properties/resources.c \
+       properties/resources.h
+
+EXTRA_DIST += \
+       properties/gresource.xml
+
 ###############################################################################
 
 noinst_LTLIBRARIES += properties/libnm-vpn-plugin-fortisslvpn-utils.la
diff --git a/configure.ac b/configure.ac
index b9e568b..8a13285 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,6 +19,7 @@ AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_INSTALL
 AC_PROG_LIBTOOL
+AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
 
 dnl
 dnl Required headers
diff --git a/properties/gresource.xml b/properties/gresource.xml
new file mode 100644
index 0000000..e591761
--- /dev/null
+++ b/properties/gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+       <gresource prefix="/org/freedesktop/network-manager-fortisslvpn">
+               <file preprocess="xml-stripblanks">nm-fortisslvpn-dialog.ui</file>
+       </gresource>
+</gresources>
diff --git a/properties/nm-fortisslvpn-editor.c b/properties/nm-fortisslvpn-editor.c
index 2476054..e9066e5 100644
--- a/properties/nm-fortisslvpn-editor.c
+++ b/properties/nm-fortisslvpn-editor.c
@@ -438,7 +438,6 @@ nm_fortisslvpn_editor_new (NMConnection *connection, GError **error)
 {
        NMVpnEditor *object;
        FortisslvpnEditorPrivate *priv;
-       char *ui_file;
        gboolean new = TRUE;
        NMSettingVpn *s_vpn;
 
@@ -453,22 +452,14 @@ nm_fortisslvpn_editor_new (NMConnection *connection, GError **error)
 
        priv = FORTISSLVPN_EDITOR_GET_PRIVATE (object);
 
-       ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-fortisslvpn-dialog.ui");
        priv->builder = gtk_builder_new ();
 
        gtk_builder_set_translation_domain (priv->builder, GETTEXT_PACKAGE);
 
-       if (!gtk_builder_add_from_file (priv->builder, ui_file, error)) {
-               g_warning ("Couldn't load builder file: %s",
-                          error && *error ? (*error)->message : "(unknown)");
-               g_clear_error (error);
-               g_set_error (error, NMV_EDITOR_PLUGIN_ERROR, 0,
-                            "could not load required resources at %s", ui_file);
-               g_free (ui_file);
+       if (!gtk_builder_add_from_resource (priv->builder, 
"/org/freedesktop/network-manager-fortisslvpn/nm-fortisslvpn-dialog.ui", error)) {
                g_object_unref (object);
-               return NULL;
+               g_return_val_if_reached (NULL);
        }
-       g_free (ui_file);
 
        priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "fortisslvpn-vbox"));
        if (!priv->widget) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]