[network-manager-openvpn/lr/cert-chooser: 3/6] all: use gresources
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn/lr/cert-chooser: 3/6] all: use gresources
- Date: Mon, 3 Jul 2017 09:25:23 +0000 (UTC)
commit dbfedc83688ffa0db641fdfafc997fa651178016
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Mon Mar 6 19:48:09 2017 +0100
all: use gresources
It makes removes some overhead and makes debugging easier without the
need to install the .ui files.
.gitignore | 1 +
Makefile.am | 20 +++++++++++++++-----
configure.ac | 1 +
properties/auth-helpers.c | 12 +++---------
properties/gresource.xml | 6 ++++++
properties/nm-openvpn-editor.c | 16 +++-------------
6 files changed, 29 insertions(+), 27 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index a118062..179c3fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,5 +48,6 @@ src/nm-openvpn-service
src/nm-openvpn-service-openvpn-helper
properties/tests/test-import-export
properties/tests/test-import-export-glib
+properties/resources.[ch]
/NetworkManager-openvpn*.tar*
/po/NetworkManager-openvpn.pot
diff --git a/Makefile.am b/Makefile.am
index 3ae429e..e0fcb08 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -87,6 +87,19 @@ EXTRA_src_nm_openvpn_service_openvpn_helper_DEPENDENCIES = \
###############################################################################
+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
+
+CLEANFILES += \
+ properties/resources.c \
+ properties/resources.h
+
+EXTRA_DIST += \
+ properties/gresource.xml
+
plugin_sources = \
properties/nm-openvpn-editor-plugin.c \
properties/nm-openvpn-editor-plugin.h \
@@ -94,6 +107,8 @@ plugin_sources = \
properties/import-export.h
editor_sources = \
+ properties/resources.c \
+ properties/resources.h \
properties/nm-openvpn-editor.c \
properties/nm-openvpn-editor.h \
properties/auth-helpers.c \
@@ -154,10 +169,6 @@ properties_libnm_vpn_plugin_openvpn_la_LDFLAGS = \
###############################################################################
if WITH_GNOME
-ui_DATA += properties/nm-openvpn-dialog.ui
-endif
-
-if WITH_GNOME
plugin_LTLIBRARIES += properties/libnm-vpn-plugin-openvpn-editor.la
endif
@@ -314,7 +325,6 @@ auth_dialog_nm_openvpn_auth_dialog_SOURCES = \
auth-dialog/main.c
auth_dialog_nm_openvpn_auth_dialog_CPPFLAGS = \
-DICONDIR=\""$(datadir)/pixmaps"\" \
- -DUIDIR=\""$(uidir)"\" \
-DBINDIR=\""$(bindir)"\" \
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
-I$(srcdir)/shared \
diff --git a/configure.ac b/configure.ac
index b0634c8..24a26f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,6 +25,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/auth-helpers.c b/properties/auth-helpers.c
index e7173e9..605f7bd 100644
--- a/properties/auth-helpers.c
+++ b/properties/auth-helpers.c
@@ -1682,7 +1682,6 @@ advanced_dialog_new (GHashTable *hash, const char *contype)
{
GtkBuilder *builder;
GtkWidget *dialog = NULL;
- char *ui_file = NULL;
GtkWidget *widget, *combo, *spin, *entry, *ok_button;
const char *value, *value2;
const char *dev, *dev_type, *tap_dev;
@@ -1695,22 +1694,20 @@ advanced_dialog_new (GHashTable *hash, const char *contype)
g_return_val_if_fail (hash != NULL, NULL);
- ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-openvpn-dialog.ui");
builder = gtk_builder_new ();
gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
- if (!gtk_builder_add_from_file (builder, ui_file, &error)) {
- g_warning ("Couldn't load builder file: %s", error->message);
+ if (!gtk_builder_add_from_resource (builder,
"/org/freedesktop/network-manager-openvpn/nm-openvpn-dialog.ui", &error)) {
g_error_free (error);
g_object_unref (G_OBJECT (builder));
- goto out;
+ g_return_val_if_reached (NULL);
}
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "openvpn-advanced-dialog"));
if (!dialog) {
g_object_unref (G_OBJECT (builder));
- goto out;
+ g_return_val_if_reached (NULL);
}
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
@@ -2023,9 +2020,6 @@ advanced_dialog_new (GHashTable *hash, const char *contype)
_builder_init_optional_spinbutton (builder, "max_routes_checkbutton", "max_routes_spinbutton",
!!value,
_nm_utils_ascii_str_to_int64 (value, 10, 0, 100000000, 100));
-
-out:
- g_free (ui_file);
return dialog;
}
diff --git a/properties/gresource.xml b/properties/gresource.xml
new file mode 100644
index 0000000..f71de10
--- /dev/null
+++ b/properties/gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/freedesktop/network-manager-openvpn">
+ <file preprocess="xml-stripblanks">nm-openvpn-dialog.ui</file>
+ </gresource>
+</gresources>
diff --git a/properties/nm-openvpn-editor.c b/properties/nm-openvpn-editor.c
index c8fe8a4..31e12b6 100644
--- a/properties/nm-openvpn-editor.c
+++ b/properties/nm-openvpn-editor.c
@@ -487,7 +487,6 @@ openvpn_editor_new (NMConnection *connection, GError **error)
{
NMVpnEditor *object;
OpenvpnEditorPrivate *priv;
- char *ui_file;
gboolean new = TRUE;
NMSettingVpn *s_vpn;
@@ -502,29 +501,20 @@ openvpn_editor_new (NMConnection *connection, GError **error)
priv = OPENVPN_EDITOR_GET_PRIVATE (object);
- ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-openvpn-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 from %s", ui_file);
- g_free (ui_file);
+ if (!gtk_builder_add_from_resource (priv->builder,
"/org/freedesktop/network-manager-openvpn/nm-openvpn-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, "openvpn-vbox"));
if (!priv->widget) {
g_set_error_literal (error, NMV_EDITOR_PLUGIN_ERROR, 0, _("could not load UI widget"));
g_object_unref (object);
- return NULL;
+ g_return_val_if_reached (NULL);
}
g_object_ref_sink (priv->widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]