[NetworkManager-libreswan/lr/gtk-4.0: 3/7] editor: load the GtkBuilder data from a resource
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [NetworkManager-libreswan/lr/gtk-4.0: 3/7] editor: load the GtkBuilder data from a resource
- Date: Wed, 20 Oct 2021 09:43:19 +0000 (UTC)
commit c53d7e9ae371d0dd37982f7d5d52541a0096e4c1
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Tue Oct 19 16:55:48 2021 +0200
editor: load the GtkBuilder data from a resource
This makes some useful things possible, such as running from a built source
tree or, in future, using a modified version of the file for Gtk4 version.
.gitignore | 2 ++
Makefile.am | 35 +++++++++++++++++++++++++----------
configure.ac | 1 +
properties/gresource.xml | 6 ++++++
properties/nm-libreswan-editor.c | 12 ++----------
5 files changed, 36 insertions(+), 20 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 2b1b157..4cfc7d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,5 +40,7 @@ src/show-xfrm
src/nm-libreswan-helper-service-dbus.c
src/nm-libreswan-helper-service-dbus.h
man/nm-settings-libreswan.5
+properties/resources.c
+properties/resources.h
/NetworkManager-libreswan*.tar*
diff --git a/Makefile.am b/Makefile.am
index 5ed9317..fbc3747 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -29,13 +29,14 @@ dbusservice_DATA = nm-libreswan-service.conf
nmvpnservicedir = $(NM_VPN_SERVICE_DIR)
nmvpnservice_DATA = nm-libreswan-service.name
-uidir = $(datadir)/gnome-vpn-properties/libreswan
-if WITH_GNOME
-ui_DATA = properties/nm-libreswan-dialog.ui
-endif
-
###############################################################################
+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-libreswan-editor-plugin.c \
properties/nm-libreswan-editor-plugin.h
@@ -45,8 +46,6 @@ editor_sources = \
properties/nm-libreswan-editor.h
common_CFLAGS = \
- -DICONDIR=\""$(datadir)/pixmaps"\" \
- -DUIDIR=\""$(uidir)"\" \
-DLOCALEDIR=\"$(datadir)/locale\" \
-I$(srcdir)/shared \
$(GLIB_CFLAGS)
@@ -102,6 +101,10 @@ properties_libnm_vpn_plugin_libreswan_editor_la_CFLAGS = \
$(LIBNM_CFLAGS) \
$(LIBNMA_CFLAGS)
+noinst_properties_libnm_vpn_plugin_libreswan_editor_la_SOURCES = \
+ properties/resources.h \
+ properties/resources.c
+
properties_libnm_vpn_plugin_libreswan_editor_la_SOURCES = \
$(editor_sources)
@@ -130,6 +133,10 @@ properties_libnm_libreswan_properties_la_CFLAGS = \
$(LIBNM_GLIB_CFLAGS) \
$(LIBNM_GTK_CFLAGS)
+noinst_properties_libnm_libreswan_properties_la_SOURCES = \
+ properties/resources.h \
+ properties/resources.c
+
properties_libnm_libreswan_properties_la_SOURCES = \
shared/utils.c \
shared/utils.h \
@@ -160,7 +167,6 @@ libexec_PROGRAMS += auth-dialog/nm-libreswan-auth-dialog
endif
auth_dialog_nm_libreswan_auth_dialog_CPPFLAGS = \
- -DICONDIR=\""$(datadir)/pixmaps"\" \
-DBINDIR=\""$(bindir)"\" \
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
-I$(srcdir)/shared \
@@ -276,12 +282,21 @@ src_show_xfrm_LDADD = \
###############################################################################
+BUILT_SOURCES = \
+ src/nm-libreswan-helper-service-dbus.h \
+ src/nm-libreswan-helper-service-dbus.c \
+ properties/resources.c \
+ properties/resources.h
+
CLEANFILES += \
src/nm-libreswan-helper-service-dbus.h \
- src/nm-libreswan-helper-service-dbus.c
+ src/nm-libreswan-helper-service-dbus.c \
+ properties/resources.c \
+ properties/resources.h
EXTRA_DIST += \
- src/nm-libreswan-helper-service.xml
+ src/nm-libreswan-helper-service.xml \
+ properties/gresource.xml
###############################################################################
diff --git a/configure.ac b/configure.ac
index 151a389..9218d46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,6 +29,7 @@ AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PROG_LN_S
AC_PROG_MKDIR_P
+AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
AC_GNU_SOURCE
diff --git a/properties/gresource.xml b/properties/gresource.xml
new file mode 100644
index 0000000..1ba2753
--- /dev/null
+++ b/properties/gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/freedesktop/network-manager-libreswan">
+ <file preprocess="xml-stripblanks">nm-libreswan-dialog.ui</file>
+ </gresource>
+</gresources>
diff --git a/properties/nm-libreswan-editor.c b/properties/nm-libreswan-editor.c
index ea58ba2..d880bf0 100644
--- a/properties/nm-libreswan-editor.c
+++ b/properties/nm-libreswan-editor.c
@@ -668,7 +668,6 @@ nm_vpn_editor_new (NMConnection *connection, GError **error)
{
NMVpnEditor *object;
LibreswanEditorPrivate *priv;
- char *ui_file;
NMSettingVpn *s_vpn;
gboolean is_new = TRUE;
@@ -683,23 +682,16 @@ nm_vpn_editor_new (NMConnection *connection, GError **error)
priv = LIBRESWAN_EDITOR_GET_PRIVATE (object);
- ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-libreswan-dialog.ui");
priv->builder = gtk_builder_new ();
g_assert (priv->builder);
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-libreswan/nm-libreswan-dialog.ui", error)) {
+ g_warning ("Couldn't load builder file: %s", error && *error ? (*error)->message :
"(unknown)");
g_object_unref (object);
return NULL;
}
- g_free (ui_file);
priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "libreswan-vbox"));
if (!priv->widget) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]