[network-manager-pptp/lr/non-recursive-make: 2/2] all: use gresources



commit 638da2ec0ed9f35a3cc5c60acf868a6dd7466ff6
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Mon Jul 24 13:35:06 2017 +0200

    all: use gresources

 Makefile.am                  |   19 ++++++++++++++-----
 configure.ac                 |    1 +
 properties/advanced-dialog.c |   11 +++--------
 properties/gresource.xml     |    6 ++++++
 properties/nm-pptp-editor.c  |   12 +-----------
 5 files changed, 25 insertions(+), 24 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 5a5bde4..cd95650 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,9 +26,6 @@ dbusservice_DATA = nm-pptp-service.conf
 nmvpnservicedir = $(NM_VPN_SERVICE_DIR)
 nmvpnservice_DATA = nm-pptp-service.name
 
-uidir = $(datadir)/gnome-vpn-properties/pptp
-ui_DATA =
-
 BUILT_SOURCES =
 
 ###############################################################################
@@ -119,7 +116,11 @@ src_nm_pptp_pppd_plugin_la_LIBADD = \
 
 ###############################################################################
 
-ui_DATA += properties/nm-pptp-dialog.ui
+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 = \
        shared/nm-utils/nm-vpn-plugin-macros.h \
@@ -129,6 +130,8 @@ plugin_sources = \
 editor_sources = \
        $(shared_sources) \
        shared/nm-utils/nm-vpn-plugin-utils.h \
+       properties/resources.c \
+       properties/resources.h \
        properties/advanced-dialog.c \
        properties/advanced-dialog.h \
        properties/nm-pptp-editor.c \
@@ -136,11 +139,15 @@ editor_sources = \
 
 properties_cppflags = \
        -DLOCALEDIR=\"$(datadir)/locale\" \
-       -DUIDIR=\""$(uidir)"\" \
        -I$(top_srcdir)/shared
 
+CLEANFILES += \
+       properties/resources.c \
+       properties/resources.h
+
 EXTRA_DIST += \
        properties/nm-pptp-dialog.ui \
+       properties/gresource.xml \
        properties/libnm-pptp-properties.ver \
        properties/libnm-vpn-plugin-pptp.ver \
        properties/libnm-vpn-plugin-pptp-editor.ver
@@ -225,6 +232,8 @@ endif
 
 auth_dialog_nm_pptp_auth_dialog_SOURCES = \
        $(shared_sources) \
+       properties/resources.c \
+       properties/resources.h \
        auth-dialog/main.c
 auth_dialog_nm_pptp_auth_dialog_CFLAGS = \
        $(GLIB_CFLAGS) \
diff --git a/configure.ac b/configure.ac
index 24ad29c..84e5609 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/advanced-dialog.c b/properties/advanced-dialog.c
index 3d06173..0e62061 100644
--- a/properties/advanced-dialog.c
+++ b/properties/advanced-dialog.c
@@ -388,7 +388,6 @@ advanced_dialog_new (GHashTable *hash)
 {
        GtkBuilder *builder;
        GtkWidget *dialog = NULL;
-       char *ui_file = NULL;
        GtkWidget *widget, *spin;
        const char *value;
        gboolean mppe = FALSE;
@@ -396,22 +395,20 @@ advanced_dialog_new (GHashTable *hash)
 
        g_return_val_if_fail (hash != NULL, NULL);
 
-       ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-pptp-dialog.ui");
        builder = gtk_builder_new ();
-
        gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
-       if (!gtk_builder_add_from_file (builder, ui_file, &error)) {
+       if (!gtk_builder_add_from_resource (builder, 
"/org/freedesktop/network-manager-pptp/nm-pptp-dialog.ui", &error)) {
                g_warning ("Couldn't load builder file: %s",
                           error ? error->message : "(unknown)");
                g_clear_error (&error);
                g_object_unref (G_OBJECT (builder));
-               goto out;
+               return NULL;
        }
 
        dialog = GTK_WIDGET (gtk_builder_get_object (builder, "pptp-advanced-dialog"));
        if (!dialog) {
                g_object_unref (G_OBJECT (builder));
-               goto out;
+               return NULL;
        }
        gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
 
@@ -501,8 +498,6 @@ advanced_dialog_new (GHashTable *hash)
                gtk_widget_set_sensitive (widget, FALSE);
        }
 
-out:
-       g_free (ui_file);
        return dialog;
 }
 
diff --git a/properties/gresource.xml b/properties/gresource.xml
new file mode 100644
index 0000000..f43d3b8
--- /dev/null
+++ b/properties/gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+       <gresource prefix="/org/freedesktop/network-manager-pptp">
+               <file preprocess="xml-stripblanks">nm-pptp-dialog.ui</file>
+       </gresource>
+</gresources>
diff --git a/properties/nm-pptp-editor.c b/properties/nm-pptp-editor.c
index 28ea50a..337c73e 100644
--- a/properties/nm-pptp-editor.c
+++ b/properties/nm-pptp-editor.c
@@ -408,7 +408,6 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
 {
        NMVpnEditor *object;
        PptpPluginUiWidgetPrivate *priv;
-       char *ui_file;
        gboolean new = TRUE;
        NMSettingVpn *s_vpn;
 
@@ -423,21 +422,12 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
 
        priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (object);
 
-       ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-pptp-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-pptp/nm-pptp-dialog.ui", error)) {
                g_object_unref (object);
                return NULL;
        }
-       g_free (ui_file);
 
        priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "pptp-vbox"));
        if (!priv->widget) {


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