[network-manager-applet/lr/pkcs11: 11/22] libnma: add a file certificate chooser



commit d0133943106196c78ff634a72daa50e9c79c07e5
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Wed Feb 22 18:43:53 2017 +0100

    libnma: add a file certificate chooser
    
    This is a simple certificate chooser that allows selecting the
    certificate and key pair from plain files.
    
    This one is available from libnm-gtk too, otherwise the cert chooser
    interface alone would be useless.

 Makefile.am                        |   17 +-
 po/POTFILES.in                     |    1 +
 src/libnm-gtk/libnm-gtk.ver        |    2 +
 src/libnma/nma-cert-chooser.c      |    8 +-
 src/libnma/nma-file-cert-chooser.c |  425 ++++++++++++++++++++++++++++++++++++
 src/libnma/nma-file-cert-chooser.h |   50 +++++
 6 files changed, 497 insertions(+), 6 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 4a3505c..fe3c718 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -361,6 +361,7 @@ libnm_gtk_c_real = \
        src/libnm-gtk/nm-mobile-providers.c \
        src/libnm-gtk/nm-vpn-password-dialog.c \
        src/libnma/nma-cert-chooser.c \
+       src/libnma/nma-file-cert-chooser.c \
        src/libnm-gtk/init.c
 
 src_libnm_gtk_libnmgtkdir = $(includedir)/libnm-gtk
@@ -491,7 +492,11 @@ libnma_c_real = \
        src/libnma/nma-vpn-password-dialog.c \
        src/libnma/nma-ui-utils.c \
        src/libnma/init.c \
-       src/libnma/nma-cert-chooser.c
+       src/libnma/nma-cert-chooser.c \
+       src/libnma/nma-file-cert-chooser.c
+
+libnma_h_priv_real = \
+       src/libnma/nma-file-cert-chooser.h
 
 src_libnma_libnmadir = $(includedir)/libnma
 
@@ -501,9 +506,11 @@ src_libnma_libnma_HEADERS = \
 lib_LTLIBRARIES += src/libnma/libnma.la
 
 src_libnma_libnma_la_SOURCES = \
+       $(libnma_h_priv_real) \
        $(libnma_c_real)
 
 nodist_src_libnma_libnma_la_SOURCES = \
+       $(libnma_h_priv_gen) \
        $(libnma_c_gen)
 
 src_libnma_libnma_la_CFLAGS = \
@@ -529,8 +536,6 @@ src_libnma_libnma_la_LIBADD = \
        $(LIBNM_LIBS) \
        $(GUDEV_LIBS)
 
-$(src_libnma_libnma_la_OBJECTS): $(libnma_h_priv_gen)
-
 EXTRA_src_libnma_libnma_la_DEPENDENCIES = src/libnma/libnma.ver
 
 src_libnma_libnma_la_LDFLAGS = \
@@ -854,10 +859,12 @@ CFILE_GLOB = $(top_srcdir)/src/libnma/*.c
 
 IGNORE_HFILES = \
        nma-resources.h \
-       nma-version.h
+       nma-version.h \
+       nma-file-cert-chooser.h
 
 mkdb_ignore_c_files = \
-       nma-resources.c
+       nma-resources.c \
+       nma-file-cert-chooser.c
 
 MKDB_OPTIONS = --ignore-files "$(IGNORE_HFILES) $(mkdb_ignore_c_files)"
 
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b696c3e..983b3ef 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -75,6 +75,7 @@ src/connection-editor/vpn-helpers.c
 src/ethernet-dialog.c
 [type: gettext/glade]src/gsm-unlock.ui
 [type: gettext/glade]src/info.ui
+src/libnma/nma-file-cert-chooser.c
 src/libnma/nma-mobile-providers.c
 src/libnma/nma-mobile-wizard.c
 src/libnma/nma-ui-utils.c
diff --git a/src/libnm-gtk/libnm-gtk.ver b/src/libnm-gtk/libnm-gtk.ver
index 2c5eaae..6e9d3b1 100644
--- a/src/libnm-gtk/libnm-gtk.ver
+++ b/src/libnm-gtk/libnm-gtk.ver
@@ -39,4 +39,6 @@ global:
        nma_cert_chooser_update_cert_password_storage;
        nma_cert_chooser_update_key_password_storage;
        nma_cert_chooser_validate;
+local:
+       nma_file_cert_chooser_*;
 } libnm_gtk_1_0_6;
diff --git a/src/libnma/nma-cert-chooser.c b/src/libnma/nma-cert-chooser.c
index 18c3ede..ef07b97 100644
--- a/src/libnma/nma-cert-chooser.c
+++ b/src/libnma/nma-cert-chooser.c
@@ -22,6 +22,7 @@
 
 #include "nm-default.h"
 #include "nma-cert-chooser.h"
+#include "nma-file-cert-chooser.h"
 
 /**
  * SECTION:nma-cert-chooser
@@ -636,7 +637,12 @@ nma_cert_chooser_get_key_password_flags (NMACertChooser *cert_chooser)
 static GObject *
 constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties)
 {
-       g_return_val_if_reached (NULL);
+       if (type == NMA_TYPE_CERT_CHOOSER)
+               type = NMA_TYPE_FILE_CERT_CHOOSER;
+
+       return G_OBJECT_CLASS (nma_cert_chooser_parent_class)->constructor (type,
+                                                                           n_construct_properties,
+                                                                           construct_properties);
 }
 
 static void
diff --git a/src/libnma/nma-file-cert-chooser.c b/src/libnma/nma-file-cert-chooser.c
new file mode 100644
index 0000000..4f53f07
--- /dev/null
+++ b/src/libnma/nma-file-cert-chooser.c
@@ -0,0 +1,425 @@
+/* NetworkManager Applet -- allow user control over networking
+ *
+ * Dan Williams <dcbw redhat com>
+ * Lubomir Rintel <lkundrak v3 sk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright (C) 2015,2017 Red Hat, Inc.
+ */
+
+#include "nm-default.h"
+#include "nma-file-cert-chooser.h"
+#ifdef LIBNM_BUILD
+#include "nma-ui-utils.h"
+#else
+#include "nm-ui-utils.h"
+#endif
+#include "utils.h"
+
+typedef struct {
+       GtkWidget *key_button_label;
+       GtkWidget *key_password_label;
+       GtkWidget *cert_button_label;
+       GtkWidget *key_button;
+       GtkWidget *key_password;
+       GtkWidget *cert_button;
+       GtkWidget *show_password;
+} NMAFileCertChooserPrivate;
+
+#define NMA_FILE_CERT_CHOOSER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+                                              NMA_TYPE_FILE_CERT_CHOOSER, \
+                                              NMAFileCertChooserPrivate))
+
+G_DEFINE_TYPE (NMAFileCertChooser, nma_file_cert_chooser, NMA_TYPE_CERT_CHOOSER)
+
+static void
+set_key_password (NMACertChooser *cert_chooser, const gchar *password)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+
+       g_return_if_fail (priv->key_password != NULL);
+       gtk_entry_set_text (GTK_ENTRY (priv->key_password), password);
+}
+
+static const gchar *
+get_key_password (NMACertChooser *cert_chooser)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+
+       g_return_val_if_fail (priv->key_password != NULL, NULL);
+       return gtk_entry_get_text (GTK_ENTRY (priv->key_password));
+}
+
+static void
+set_key_uri (NMACertChooser *cert_chooser, const gchar *uri)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+
+       if (uri)
+               gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (priv->key_button), uri);
+}
+
+static gchar *
+get_key_uri (NMACertChooser *cert_chooser)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+
+       return gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (priv->key_button));
+}
+
+static void
+set_cert_uri (NMACertChooser *cert_chooser, const gchar *uri)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+
+       if (uri)
+               gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (priv->cert_button), uri);
+}
+
+static gchar *
+get_cert_uri (NMACertChooser *cert_chooser)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+
+       return gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (priv->cert_button));
+}
+
+static void
+add_to_size_group (NMACertChooser *cert_chooser, GtkSizeGroup *group)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+
+       gtk_size_group_add_widget (group, priv->cert_button_label);
+       gtk_size_group_add_widget (group, priv->key_button_label);
+       gtk_size_group_add_widget (group, priv->key_password_label);
+}
+
+static gboolean
+validate (NMACertChooser *cert_chooser, GError **error)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+       GError *local = NULL;
+       char *tmp;
+
+       tmp = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (priv->cert_button));
+       if (tmp) {
+               g_free (tmp);
+       } else {
+               g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("No certificate set"));
+               return FALSE;
+       }
+
+       g_signal_emit_by_name (cert_chooser, "cert-validate", &local);
+       if (local) {
+               widget_set_error (priv->cert_button);
+               g_propagate_error (error, local);
+               return FALSE;
+       } else {
+               widget_unset_error (priv->cert_button);
+       }
+
+       if (gtk_widget_get_visible (priv->key_button)) {
+               tmp = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (priv->key_button));
+               if (tmp) {
+                       g_free (tmp);
+               } else {
+                       g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("No key set"));
+                       return FALSE;
+               }
+
+               g_signal_emit_by_name (cert_chooser, "key-validate", &local);
+               if (local) {
+                       widget_set_error (priv->key_button);
+                       g_propagate_error (error, local);
+                       return FALSE;
+               } else {
+                       widget_unset_error (priv->key_button);
+               }
+
+               g_signal_emit_by_name (cert_chooser, "key-password-validate", &local);
+               if (local) {
+                       widget_set_error (priv->key_password);
+                       g_propagate_error (error, local);
+                       return FALSE;
+               } else {
+                       widget_unset_error (priv->key_password);
+               }
+       }
+
+       return TRUE;
+}
+
+static void
+setup_key_password_storage (NMACertChooser *cert_chooser,
+                            NMSettingSecretFlags initial_flags,
+                            NMSetting *setting,
+                            const char *password_flags_name,
+                            gboolean with_not_required,
+                            gboolean ask_mode)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+
+       nma_utils_setup_password_storage (priv->key_password,
+                                         initial_flags,
+                                         setting,
+                                         password_flags_name,
+                                         with_not_required,
+                                         ask_mode);
+}
+
+static void
+update_key_password_storage (NMACertChooser *cert_chooser,
+                             NMSettingSecretFlags secret_flags,
+                             NMSetting *setting,
+                             const char *password_flags_name)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+
+       nma_utils_update_password_storage (priv->key_password,
+                                          secret_flags,
+                                          setting,
+                                          password_flags_name);
+}
+
+
+static NMSettingSecretFlags
+get_key_password_flags (NMACertChooser *cert_chooser)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+
+       return nma_utils_menu_to_secret_flags (priv->key_password);
+}
+
+static void
+reset_filter (GtkWidget *widget, GParamSpec *spec, gpointer user_data)
+{
+       if (!gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (widget))) {
+               g_signal_handlers_block_by_func (widget, reset_filter, user_data);
+               gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (widget), GTK_FILE_FILTER (user_data));
+               g_signal_handlers_unblock_by_func (widget, reset_filter, user_data);
+       }
+}
+
+static void
+cert_changed_cb (GtkFileChooserButton *file_chooser_button, gpointer user_data)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (user_data);
+
+       if (gtk_widget_get_visible (priv->key_button)) {
+               gtk_widget_set_sensitive (priv->key_button, TRUE);
+               gtk_widget_set_sensitive (priv->key_button_label, TRUE);
+       }
+       g_signal_emit_by_name (user_data, "changed");
+}
+
+static void
+key_changed_cb (GtkFileChooserButton *file_chooser_button, gpointer user_data)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (user_data);
+
+       gtk_widget_set_sensitive (priv->key_password, TRUE);
+       gtk_widget_set_sensitive (priv->key_password_label, TRUE);
+       g_signal_emit_by_name (user_data, "changed");
+}
+
+static void
+key_password_changed_cb (GtkEntry *entry, gpointer user_data)
+{
+       g_signal_emit_by_name (user_data, "changed");
+}
+
+static void
+show_toggled_cb (GtkCheckButton *button, gpointer user_data)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (user_data);
+
+       gtk_entry_set_visibility (GTK_ENTRY (priv->key_password),
+                                 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
+}
+
+static void
+set_title (NMACertChooser *cert_chooser, const gchar *title)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+       gchar *text;
+
+       text = g_strdup_printf (_("Choose a key for %s Certificate"), title);
+       gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON (priv->key_button), text);
+       g_free (text);
+
+       text = g_strdup_printf (_("%s private _key:"), title);
+       gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->key_button_label), text);
+       g_free (text);
+
+       text = g_strdup_printf (_("%s key _password:"), title);
+       gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->key_password_label), text);
+       g_free (text);
+
+       text = g_strdup_printf (_("Choose %s Certificate"), title);
+       gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON (priv->cert_button), text);
+       g_free (text);
+
+       text = g_strdup_printf (_("%s _certificate:"), title);
+       gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->cert_button_label), text);
+       g_free (text);
+}
+
+static void
+set_flags (NMACertChooser *cert_chooser, NMACertChooserFlags flags)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+
+       if (flags & NMA_CERT_CHOOSER_FLAG_CERT) {
+               gtk_widget_hide (priv->key_button);
+               gtk_widget_hide (priv->key_button_label);
+               gtk_widget_hide (priv->key_password);
+               gtk_widget_hide (priv->key_password_label);
+               gtk_widget_hide (priv->show_password);
+       }
+
+       if (flags & NMA_CERT_CHOOSER_FLAG_PASSWORDS) {
+               gtk_widget_hide (priv->cert_button);
+               gtk_widget_hide (priv->cert_button_label);
+               gtk_widget_hide (priv->key_button);
+               gtk_widget_hide (priv->key_button_label);
+       }
+}
+
+static void
+nma_file_cert_chooser_class_init (NMAFileCertChooserClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       NMACertChooserClass *chooser_class = NMA_CERT_CHOOSER_CLASS (klass);
+
+       g_type_class_add_private (object_class, sizeof (NMAFileCertChooserPrivate));
+
+       chooser_class->set_title = set_title;
+       chooser_class->set_flags = set_flags;
+
+       chooser_class->set_cert_uri = set_cert_uri;
+       chooser_class->get_cert_uri = get_cert_uri;
+       chooser_class->set_key_uri = set_key_uri;
+       chooser_class->get_key_uri = get_key_uri;
+       chooser_class->set_key_password = set_key_password;
+       chooser_class->get_key_password = get_key_password;
+
+       chooser_class->add_to_size_group = add_to_size_group;
+       chooser_class->validate = validate;
+
+       chooser_class->setup_key_password_storage = setup_key_password_storage;
+       chooser_class->update_key_password_storage = update_key_password_storage;
+       chooser_class->get_key_password_flags = get_key_password_flags;
+}
+
+static void
+nma_file_cert_chooser_init (NMAFileCertChooser *file_cert_chooser)
+{
+       NMAFileCertChooserPrivate *priv = NMA_FILE_CERT_CHOOSER_GET_PRIVATE (file_cert_chooser);
+       GtkFileFilter *filter;
+
+       gtk_grid_insert_column (GTK_GRID (file_cert_chooser), 2);
+       gtk_grid_set_row_spacing (GTK_GRID (file_cert_chooser), 6);
+       gtk_grid_set_column_spacing (GTK_GRID (file_cert_chooser), 12);
+
+       /* The key chooser */
+       gtk_grid_insert_row (GTK_GRID (file_cert_chooser), 0);
+
+       priv->key_button = g_object_new (GTK_TYPE_FILE_CHOOSER_BUTTON,
+                                         "action", GTK_FILE_CHOOSER_ACTION_OPEN,
+                                         "filter", utils_key_filter (),
+                                         "local-only", TRUE,
+                                         NULL);
+       gtk_grid_attach (GTK_GRID (file_cert_chooser), priv->key_button, 1, 0, 1, 1);
+       gtk_widget_set_hexpand (priv->key_button, TRUE);
+       gtk_widget_set_sensitive (priv->key_button, FALSE);
+       gtk_widget_show (priv->key_button);
+       gtk_widget_set_no_show_all (priv->key_button, TRUE);
+
+        g_signal_connect (priv->key_button, "selection-changed",
+                         G_CALLBACK (key_changed_cb), file_cert_chooser);
+
+       priv->key_button_label = gtk_label_new (NULL);
+       g_object_set (priv->key_button_label, "xalign", (gfloat) 0, NULL);
+       gtk_label_set_mnemonic_widget (GTK_LABEL (priv->key_button_label), priv->key_button);
+       gtk_grid_attach (GTK_GRID (file_cert_chooser), priv->key_button_label, 0, 0, 1, 1);
+       gtk_widget_set_sensitive (priv->key_button_label, FALSE);
+       gtk_widget_show (priv->key_button_label);
+       gtk_widget_set_no_show_all (priv->key_button_label, TRUE);
+
+       /* The key password entry */
+       gtk_grid_insert_row (GTK_GRID (file_cert_chooser), 1);
+
+       priv->key_password = gtk_entry_new ();
+       gtk_entry_set_visibility (GTK_ENTRY (priv->key_password), FALSE);
+       gtk_grid_attach (GTK_GRID (file_cert_chooser), priv->key_password, 1, 1, 1, 1);
+       gtk_widget_set_hexpand (priv->key_password, TRUE);
+       gtk_widget_set_sensitive (priv->key_password, FALSE);
+       gtk_widget_show (priv->key_password);
+       gtk_widget_set_no_show_all (priv->key_password, TRUE);
+
+        g_signal_connect (priv->key_password, "changed",
+                         G_CALLBACK (key_password_changed_cb), file_cert_chooser);
+
+       priv->key_password_label = gtk_label_new (NULL);
+       g_object_set (priv->key_password_label, "xalign", (gfloat) 0, NULL);
+       gtk_label_set_mnemonic_widget (GTK_LABEL (priv->key_password_label), priv->key_password);
+       gtk_grid_attach (GTK_GRID (file_cert_chooser), priv->key_password_label, 0, 1, 1, 1);
+       gtk_widget_set_sensitive (priv->key_password_label, FALSE);
+       gtk_widget_show (priv->key_password_label);
+       gtk_widget_set_no_show_all (priv->key_password_label, TRUE);
+
+       /* Show password */
+       gtk_grid_insert_row (GTK_GRID (file_cert_chooser), 2);
+       priv->show_password = gtk_check_button_new_with_mnemonic ("Sho_w password");
+       gtk_grid_attach (GTK_GRID (file_cert_chooser), priv->show_password, 1, 2, 1, 1);
+       gtk_widget_show (priv->show_password);
+       gtk_widget_set_no_show_all (priv->show_password, TRUE);
+       g_signal_connect (priv->show_password, "toggled",
+                         G_CALLBACK (show_toggled_cb), file_cert_chooser);
+
+       /* The certificate chooser */
+       gtk_grid_insert_row (GTK_GRID (file_cert_chooser), 0);
+
+       filter = utils_cert_filter ();
+       priv->cert_button = g_object_new (GTK_TYPE_FILE_CHOOSER_BUTTON,
+                                         "action", GTK_FILE_CHOOSER_ACTION_OPEN,
+                                         "filter", filter,
+                                         "local-only", TRUE,
+                                         NULL);
+       gtk_grid_attach (GTK_GRID (file_cert_chooser), priv->cert_button, 1, 0, 1, 1);
+       gtk_widget_set_hexpand (priv->cert_button, TRUE);
+       gtk_widget_show (priv->cert_button);
+       gtk_widget_set_no_show_all (priv->cert_button, TRUE);
+
+       /* For some reason, GTK+ calls set_current_filter (..., NULL) from
+        * gtkfilechooserdefault.c::show_and_select_files_finished_loading() on our
+        * dialog; so force-reset the filter to what we want it to be whenever
+        * it gets cleared.
+        */
+       g_signal_connect (priv->cert_button, "notify::filter",
+                         G_CALLBACK (reset_filter), filter);
+
+       g_signal_connect (priv->cert_button, "selection-changed",
+                         G_CALLBACK (cert_changed_cb), file_cert_chooser);
+
+       priv->cert_button_label = gtk_label_new (NULL);
+       g_object_set (priv->cert_button_label, "xalign", (gfloat) 0, NULL);
+       gtk_label_set_mnemonic_widget (GTK_LABEL (priv->cert_button_label), priv->cert_button);
+       gtk_grid_attach (GTK_GRID (file_cert_chooser), priv->cert_button_label, 0, 0, 1, 1);
+       gtk_widget_show (priv->cert_button_label);
+       gtk_widget_set_no_show_all (priv->cert_button_label, TRUE);
+}
diff --git a/src/libnma/nma-file-cert-chooser.h b/src/libnma/nma-file-cert-chooser.h
new file mode 100644
index 0000000..fb95650
--- /dev/null
+++ b/src/libnma/nma-file-cert-chooser.h
@@ -0,0 +1,50 @@
+/* NetworkManager Applet -- allow user control over networking
+ *
+ * Lubomir Rintel <lkundrak v3 sk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright (C) 2015,2017 Red Hat, Inc.
+ */
+
+#ifndef NMA_FILE_CERT_CHOOSER_H
+#define NMA_FILE_CERT_CHOOSER_H
+
+#include <gtk/gtk.h>
+#include "nma-cert-chooser.h"
+
+G_BEGIN_DECLS
+
+#define NMA_TYPE_FILE_CERT_CHOOSER                   (nma_file_cert_chooser_get_type ())
+#define NMA_FILE_CERT_CHOOSER(obj)                   (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
NMA_TYPE_FILE_CERT_CHOOSER, NMAFileCertChooser))
+#define NMA_FILE_CERT_CHOOSER_CLASS(klass)           (G_TYPE_CHECK_CLASS_CAST ((klass), 
NMA_TYPE_FILE_CERT_CHOOSER, NMAFileCertChooserClass))
+#define NMA_IS_FILE_CERT_CHOOSER(obj)                (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
NMA_TYPE_FILE_CERT_CHOOSER))
+#define NMA_IS_FILE_CERT_CHOOSER_CLASS(klass)        (G_TYPE_CHECK_CLASS_TYPE ((klass), 
NMA_TYPE_FILE_CERT_CHOOSER))
+#define NMA_FILE_CERT_CHOOSER_GET_CLASS(obj)         (G_TYPE_INSTANCE_GET_CLASS ((obj), 
NMA_TYPE_FILE_CERT_CHOOSER, NMAFileCertChooserClass))
+
+typedef struct {
+       NMACertChooser parent;
+} NMAFileCertChooser;
+
+typedef struct {
+       NMACertChooserClass parent_class;
+} NMAFileCertChooserClass;
+
+GType nma_file_cert_chooser_get_type (void);
+
+G_END_DECLS
+
+#endif /* NMA_FILE_CERT_CHOOSER_H */


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