nm: Load GtkBuilder data from resource instead of file
This makes it easier to build a GTK4 version later.
This commit is contained in:
@@ -11,3 +11,5 @@ config.guess.cdbs-orig
|
||||
config.sub.cdbs-orig
|
||||
NetworkManager-strongswan.metainfo.xml
|
||||
NetworkManager-strongswan.pot
|
||||
properties/nm-strongswan-resources.c
|
||||
properties/nm-strongswan-resources.h
|
||||
@@ -15,6 +15,7 @@ AM_PROG_CC_C_O
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LIBTOOL
|
||||
PKG_PROG_PKG_CONFIG
|
||||
AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
|
||||
|
||||
dnl
|
||||
dnl Required headers
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
nm_plugin_LTLIBRARIES = libnm-vpn-plugin-strongswan.la
|
||||
|
||||
nm-strongswan-resources.h: nm-strongswan-dialog.gresource.xml
|
||||
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(srcdir) \
|
||||
--generate-header --internal
|
||||
|
||||
nm-strongswan-resources.c: nm-strongswan-dialog.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/nm-strongswan-dialog.gresource.xml)
|
||||
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(srcdir) \
|
||||
--generate-source --internal
|
||||
|
||||
nodist_libnm_vpn_plugin_strongswan_la_SOURCES = \
|
||||
nm-strongswan-resources.c \
|
||||
nm-strongswan-resources.h
|
||||
|
||||
libnm_vpn_plugin_strongswan_la_SOURCES = \
|
||||
nm-strongswan.c \
|
||||
nm-strongswan.h
|
||||
|
||||
uidir = $(datadir)/gnome-vpn-properties/strongswan
|
||||
ui_DATA = nm-strongswan-dialog.ui
|
||||
|
||||
common_CFLAGS = \
|
||||
$(GTK_CFLAGS) \
|
||||
-DUIDIR=\""$(uidir)"\" \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
-DGDK_DISABLE_DEPRECATED
|
||||
|
||||
@@ -26,4 +34,14 @@ libnm_vpn_plugin_strongswan_la_LIBADD = \
|
||||
libnm_vpn_plugin_strongswan_la_LDFLAGS = \
|
||||
-avoid-version
|
||||
|
||||
EXTRA_DIST = $(ui_DATA)
|
||||
BUILT_SOURCES = \
|
||||
nm-strongswan-resources.c \
|
||||
nm-strongswan-resources.h
|
||||
|
||||
CLEANFILES = \
|
||||
nm-strongswan-resources.c \
|
||||
nm-strongswan-resources.h
|
||||
|
||||
EXTRA_DIST = \
|
||||
nm-strongswan-dialog.ui \
|
||||
nm-strongswan-dialog.gresource.xml
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/org/freedesktop/NetworkManager/strongswan">
|
||||
<file preprocess="xml-stripblanks">nm-strongswan-dialog.ui</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
@@ -36,6 +36,8 @@
|
||||
#define STRONGSWAN_PLUGIN_DESC _("IPsec with the IKEv2 key exchange protocol.")
|
||||
#define STRONGSWAN_PLUGIN_SERVICE "org.freedesktop.NetworkManager.strongswan"
|
||||
#define NM_DBUS_SERVICE_STRONGSWAN "org.freedesktop.NetworkManager.strongswan"
|
||||
#define NM_DBUS_PATH_STRONGSWAN "/org/freedesktop/NetworkManager/strongswan"
|
||||
#define STRONGSWAN_UI_RESOURCE NM_DBUS_PATH_STRONGSWAN "/nm-strongswan-dialog.ui"
|
||||
|
||||
/************** plugin class **************/
|
||||
|
||||
@@ -676,7 +678,6 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
|
||||
{
|
||||
NMVpnEditor *object;
|
||||
StrongswanPluginUiWidgetPrivate *priv;
|
||||
char *ui_file;
|
||||
|
||||
if (error)
|
||||
g_return_val_if_fail (*error == NULL, NULL);
|
||||
@@ -688,22 +689,16 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
|
||||
}
|
||||
|
||||
priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE ((StrongswanPluginUiWidget*)object);
|
||||
ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-strongswan-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)) {
|
||||
if (!gtk_builder_add_from_resource (priv->builder, STRONGSWAN_UI_RESOURCE, error)) {
|
||||
g_warning ("Couldn't load builder file: %s",
|
||||
error && *error ? (*error)->message : "(unknown)");
|
||||
g_clear_error (error);
|
||||
g_set_error (error, STRONGSWAN_PLUGIN_UI_ERROR, 0,
|
||||
"could not load required resources at %s", ui_file);
|
||||
g_free (ui_file);
|
||||
g_object_unref (object);
|
||||
return NULL;
|
||||
}
|
||||
g_free (ui_file);
|
||||
|
||||
priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "strongswan-vbox") );
|
||||
if (!priv->widget) {
|
||||
|
||||
Reference in New Issue
Block a user