[network-manager-applet/lr/pkcs11: 17/19] fixup! libnma: add a certificate picker interface
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/lr/pkcs11: 17/19] fixup! libnma: add a certificate picker interface
- Date: Tue, 7 Mar 2017 12:02:29 +0000 (UTC)
commit d77fc3b5a86c48d723b83587608be4d6963d891b
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Tue Mar 7 12:25:29 2017 +0100
fixup! libnma: add a certificate picker interface
Turn it into a grid subclass; this makes it easy to instantiate from
glade.
Turn the flags and the title into properties so that they're more easily
set from glade and communicated to the subclasses.
src/libnma/nma-cert-chooser.c | 401 +++++++++++++++++++++++++----------------
src/libnma/nma-cert-chooser.h | 59 ++++---
2 files changed, 285 insertions(+), 175 deletions(-)
---
diff --git a/src/libnma/nma-cert-chooser.c b/src/libnma/nma-cert-chooser.c
index 1443e71..95888be 100644
--- a/src/libnma/nma-cert-chooser.c
+++ b/src/libnma/nma-cert-chooser.c
@@ -39,6 +39,15 @@
*/
enum {
+ PROP_0,
+ PROP_TITLE,
+ PROP_FLAGS,
+ LAST_PROP,
+};
+
+static GParamSpec *properties[LAST_PROP];
+
+enum {
CERT_VALIDATE,
CERT_PASSWORD_VALIDATE,
KEY_VALIDATE,
@@ -49,7 +58,7 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_INTERFACE (NMACertChooser, nma_cert_chooser, G_TYPE_OBJECT)
+G_DEFINE_TYPE (NMACertChooser, nma_cert_chooser, GTK_TYPE_GRID)
static gboolean
accu_validation_error (GSignalInvocationHint *ihint,
@@ -65,100 +74,6 @@ accu_validation_error (GSignalInvocationHint *ihint,
return TRUE;
}
-static void
-nma_cert_chooser_default_init (NMACertChooserInterface *cert_chooser_iface)
-{
- static volatile gsize initialized = 0;
-
- if (!g_once_init_enter (&initialized))
- return;
-
- /**
- * NMACertChooser::cert-validate:
- *
- * Emitted when the certificate needs validation. The handlers can indicate that
- * the certificate is invalid by returning an error, which blocks further
- * signal processing and causes a call to nma_cert_chooser_validate()
- * to fail.
- *
- * Since: 1.8.0
- */
- signals[CERT_VALIDATE] = g_signal_new ("cert-validate",
- NMA_TYPE_CERT_CHOOSER,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NMACertChooserInterface, cert_validate),
- accu_validation_error, NULL, NULL,
- G_TYPE_ERROR, 0);
-
- /**
- * NMACertChooser::cert-password-validate:
- *
- * Emitted when the certificate password needs validation. The handlers
- * can indicate that the password is invalid by returning an error, which blocks further
- * signal processing and causes a call to nma_cert_chooser_validate()
- * to fail.
- *
- * Since: 1.8.0
- */
- signals[CERT_PASSWORD_VALIDATE] = g_signal_new ("cert-password-validate",
- NMA_TYPE_CERT_CHOOSER,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NMACertChooserInterface,
cert_password_validate),
- accu_validation_error, NULL, NULL,
- G_TYPE_ERROR, 0);
-
- /**
- * NMACertChooser::key-validate:
- *
- * Emitted when the key needs validation. The handlers can indicate that
- * the key is invalid by returning an error, which blocks further
- * signal processing and causes a call to nma_cert_chooser_validate()
- * to fail.
- *
- * Since: 1.8.0
- */
- signals[KEY_VALIDATE] = g_signal_new ("key-validate",
- NMA_TYPE_CERT_CHOOSER,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NMACertChooserInterface, key_validate),
- accu_validation_error, NULL, NULL,
- G_TYPE_ERROR, 0);
-
- /**
- * NMACertChooser::key-password-validate:
- *
- * Emitted when the key password needs validation. The handlers can indicate
- * that the password is invalid by returning an error, which blocks further
- * signal processing and causes a call to nma_cert_chooser_validate()
- * to fail.
- *
- * Since: 1.8.0
- */
- signals[KEY_PASSWORD_VALIDATE] = g_signal_new ("key-password-validate",
- NMA_TYPE_CERT_CHOOSER,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NMACertChooserInterface,
key_password_validate),
- accu_validation_error, NULL, NULL,
- G_TYPE_ERROR, 0);
-
- /**
- * NMACertChooser::changed:
- *
- * Emitted when anything changes in the certificate chooser, be it a certificate,
- * a key or associated passwords.
- *
- * Since: 1.8.0
- */
- signals[CHANGED] = g_signal_new ("changed",
- NMA_TYPE_CERT_CHOOSER,
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (NMACertChooserInterface, changed),
- NULL, NULL, NULL,
- G_TYPE_NONE, 0);
-
- g_once_init_leave (&initialized, 1);
-}
-
/**
* nma_cert_chooser_set_cert:
* @cert_chooser: certificate chooser button instance
@@ -172,13 +87,13 @@ nma_cert_chooser_default_init (NMACertChooserInterface *cert_chooser_iface)
void
nma_cert_chooser_set_cert (NMACertChooser *cert_chooser, const gchar *value, NMSetting8021xCKScheme scheme)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
- if (!iface->set_cert)
+ if (!klass->set_cert)
return;
- iface->set_cert (cert_chooser, value, scheme);
+ klass->set_cert (cert_chooser, value, scheme);
}
/**
@@ -195,12 +110,12 @@ nma_cert_chooser_set_cert (NMACertChooser *cert_chooser, const gchar *value, NMS
gchar *
nma_cert_chooser_get_cert (NMACertChooser *cert_chooser, NMSetting8021xCKScheme *scheme)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser), NULL);
- g_return_val_if_fail (iface->get_cert, NULL);
+ g_return_val_if_fail (klass->get_cert, NULL);
- return iface->get_cert (cert_chooser, scheme);
+ return klass->get_cert (cert_chooser, scheme);
}
/**
@@ -215,12 +130,12 @@ nma_cert_chooser_get_cert (NMACertChooser *cert_chooser, NMSetting8021xCKScheme
void
nma_cert_chooser_set_cert_password (NMACertChooser *cert_chooser, const gchar *password)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
- if (iface->set_cert_password)
- iface->set_cert_password (cert_chooser, password);
+ if (klass->set_cert_password)
+ klass->set_cert_password (cert_chooser, password);
else
g_warning ("Can't set certificate password");
}
@@ -238,13 +153,13 @@ nma_cert_chooser_set_cert_password (NMACertChooser *cert_chooser, const gchar *p
const gchar *
nma_cert_chooser_get_cert_password (NMACertChooser *cert_chooser)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser), NULL);
- if (!iface->get_cert_password)
+ if (!klass->get_cert_password)
return NULL;
- return iface->get_cert_password (cert_chooser);
+ return klass->get_cert_password (cert_chooser);
}
@@ -261,13 +176,13 @@ nma_cert_chooser_get_cert_password (NMACertChooser *cert_chooser)
void
nma_cert_chooser_set_key (NMACertChooser *cert_chooser, const gchar *value, NMSetting8021xCKScheme scheme)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
- if (!iface->set_key)
+ if (!klass->set_key)
return;
- iface->set_key (cert_chooser, value, scheme);
+ klass->set_key (cert_chooser, value, scheme);
}
/**
@@ -284,12 +199,12 @@ nma_cert_chooser_set_key (NMACertChooser *cert_chooser, const gchar *value, NMSe
gchar *
nma_cert_chooser_get_key (NMACertChooser *cert_chooser, NMSetting8021xCKScheme *scheme)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser), NULL);
- g_return_val_if_fail (iface->get_key, NULL);
+ g_return_val_if_fail (klass->get_key, NULL);
- return iface->get_key (cert_chooser, scheme);
+ return klass->get_key (cert_chooser, scheme);
}
/**
@@ -304,12 +219,12 @@ nma_cert_chooser_get_key (NMACertChooser *cert_chooser, NMSetting8021xCKScheme *
void
nma_cert_chooser_set_key_password (NMACertChooser *cert_chooser, const gchar *password)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
- g_return_if_fail (iface->set_key_password);
+ g_return_if_fail (klass->set_key_password);
- iface->set_key_password (cert_chooser, password);
+ klass->set_key_password (cert_chooser, password);
}
/**
@@ -325,13 +240,13 @@ nma_cert_chooser_set_key_password (NMACertChooser *cert_chooser, const gchar *pa
const gchar *
nma_cert_chooser_get_key_password (NMACertChooser *cert_chooser)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser), NULL);
- if (!iface->get_key_password)
+ if (!klass->get_key_password)
return NULL;
- return iface->get_key_password (cert_chooser);
+ return klass->get_key_password (cert_chooser);
}
/**
@@ -350,12 +265,12 @@ nma_cert_chooser_get_key_password (NMACertChooser *cert_chooser)
void
nma_cert_chooser_add_to_size_group (NMACertChooser *cert_chooser, GtkSizeGroup *group)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
- if (iface->add_to_size_group)
- iface->add_to_size_group (cert_chooser, group);
+ if (klass->add_to_size_group)
+ klass->add_to_size_group (cert_chooser, group);
}
/**
@@ -374,13 +289,13 @@ nma_cert_chooser_add_to_size_group (NMACertChooser *cert_chooser, GtkSizeGroup *
gboolean
nma_cert_chooser_validate (NMACertChooser *cert_chooser, GError **error)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser), TRUE);
- if (!iface->validate)
+ if (!klass->validate)
return TRUE;
- return iface->validate (cert_chooser, error);
+ return klass->validate (cert_chooser, error);
}
/**
@@ -405,12 +320,12 @@ nma_cert_chooser_setup_cert_password_storage (NMACertChooser *cert_chooser,
gboolean with_not_required,
gboolean ask_mode)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
- if (iface->setup_cert_password_storage) {
- iface->setup_cert_password_storage (cert_chooser,
+ if (klass->setup_cert_password_storage) {
+ klass->setup_cert_password_storage (cert_chooser,
initial_flags,
setting,
password_flags_name,
@@ -437,12 +352,12 @@ nma_cert_chooser_update_cert_password_storage (NMACertChooser *cert_chooser,
NMSetting *setting,
const char *password_flags_name)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
- if (iface->update_cert_password_storage) {
- iface->update_cert_password_storage (cert_chooser,
+ if (klass->update_cert_password_storage) {
+ klass->update_cert_password_storage (cert_chooser,
secret_flags,
setting,
password_flags_name);
@@ -465,14 +380,14 @@ nma_cert_chooser_update_cert_password_storage (NMACertChooser *cert_chooser,
NMSettingSecretFlags
nma_cert_chooser_get_cert_password_flags (NMACertChooser *cert_chooser)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser),
NM_SETTING_SECRET_FLAG_NONE);
- if (!iface->get_cert_password_flags)
+ if (!klass->get_cert_password_flags)
return NM_SETTING_SECRET_FLAG_NONE;
- return iface->get_cert_password_flags (cert_chooser);
+ return klass->get_cert_password_flags (cert_chooser);
}
@@ -498,12 +413,12 @@ nma_cert_chooser_setup_key_password_storage (NMACertChooser *cert_chooser,
gboolean with_not_required,
gboolean ask_mode)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
- if (iface->setup_key_password_storage) {
- iface->setup_key_password_storage (cert_chooser,
+ if (klass->setup_key_password_storage) {
+ klass->setup_key_password_storage (cert_chooser,
initial_flags,
setting,
password_flags_name,
@@ -530,12 +445,12 @@ nma_cert_chooser_update_key_password_storage (NMACertChooser *cert_chooser,
NMSetting *setting,
const char *password_flags_name)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser));
- if (iface->update_key_password_storage) {
- iface->update_key_password_storage (cert_chooser,
+ if (klass->update_key_password_storage) {
+ klass->update_key_password_storage (cert_chooser,
secret_flags,
setting,
password_flags_name);
@@ -558,14 +473,202 @@ nma_cert_chooser_update_key_password_storage (NMACertChooser *cert_chooser,
NMSettingSecretFlags
nma_cert_chooser_get_key_password_flags (NMACertChooser *cert_chooser)
{
- NMACertChooserInterface *iface = NMA_CERT_CHOOSER_GET_INTERFACE (cert_chooser);
+ NMACertChooserClass *klass = NMA_CERT_CHOOSER_GET_CLASS (cert_chooser);
g_return_val_if_fail (NMA_IS_CERT_CHOOSER (cert_chooser),
NM_SETTING_SECRET_FLAG_NONE);
- if (!iface->get_key_password_flags)
+ if (!klass->get_key_password_flags)
return NM_SETTING_SECRET_FLAG_NONE;
- return iface->get_key_password_flags (cert_chooser);
+ return klass->get_key_password_flags (cert_chooser);
+}
+
+static GObject *
+constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties)
+{
+ NMACertChooserFlags flags = NMA_CERT_CHOOSER_FLAG_NONE;
+ int i;
+
+ if (type == NMA_TYPE_CERT_CHOOSER) {
+ for (i = 0; i < n_construct_properties; i++) {
+ if (strcmp (construct_properties[i].pspec->name, "flags") == 0)
+ flags |= g_value_get_uint (construct_properties[i].value);
+ }
+ type = NMA_TYPE_FILE_CERT_CHOOSER;
+#if LIBNM_BUILD && WITH_GCR
+ if ((flags & NMA_CERT_CHOOSER_FLAG_PEM) == 0)
+ type = NMA_TYPE_PKCS11_CERT_CHOOSER;
+#endif
+ }
+
+ return G_OBJECT_CLASS (nma_cert_chooser_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_properties);
+}
+
+static void
+set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+ NMACertChooserClass *cert_chooser_class = NMA_CERT_CHOOSER_GET_CLASS (object);
+
+ switch (property_id) {
+ case PROP_TITLE:
+ g_return_if_fail (cert_chooser_class->set_title);
+ cert_chooser_class->set_title (NMA_CERT_CHOOSER (object),
+ g_value_get_string (value));
+ break;
+ case PROP_FLAGS:
+ g_return_if_fail (cert_chooser_class->set_flags);
+ cert_chooser_class->set_flags (NMA_CERT_CHOOSER (object),
+ g_value_get_uint (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+nma_cert_chooser_class_init (NMACertChooserClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructor = constructor;
+ object_class->get_property = get_property;
+ object_class->set_property = set_property;
+
+ /**
+ * NMACertChooser::title:
+ *
+ * Name of the certificate or certificate/key pair to be chosen.
+ * Used in labels and chooser dialog titles.
+ *
+ * Since: 1.8.0
+ */
+ properties[PROP_TITLE] = g_param_spec_string ("title",
+ "Title",
+ "Certificate Chooser Title",
+ NULL,
+ G_PARAM_WRITABLE
+ | G_PARAM_CONSTRUCT_ONLY
+ | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * NMACertChooser::flags:
+ *
+ * The #NMACertChooserFlags flags that influnce which chooser
+ * implementation is used and configure its behavior.
+ *
+ * Since: 1.8.0
+ */
+ properties[PROP_FLAGS] = g_param_spec_uint ("flags",
+ "Flags",
+ "Certificate Chooser Flags",
+ NMA_CERT_CHOOSER_FLAG_NONE,
+ NMA_CERT_CHOOSER_FLAG_CERT
+ | NMA_CERT_CHOOSER_FLAG_PASSWORDS
+ | NMA_CERT_CHOOSER_FLAG_PEM,
+ NMA_CERT_CHOOSER_FLAG_NONE,
+ G_PARAM_READWRITE
+ | G_PARAM_CONSTRUCT_ONLY
+ | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, properties);
+
+ /**
+ * NMACertChooser::cert-validate:
+ *
+ * Emitted when the certificate needs validation. The handlers can indicate that
+ * the certificate is invalid by returning an error, which blocks further
+ * signal processing and causes a call to nma_cert_chooser_validate()
+ * to fail.
+ *
+ * Since: 1.8.0
+ */
+ signals[CERT_VALIDATE] = g_signal_new ("cert-validate",
+ NMA_TYPE_CERT_CHOOSER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (NMACertChooserClass, cert_validate),
+ accu_validation_error, NULL, NULL,
+ G_TYPE_ERROR, 0);
+
+ /**
+ * NMACertChooser::cert-password-validate:
+ *
+ * Emitted when the certificate password needs validation. The handlers
+ * can indicate that the password is invalid by returning an error, which blocks further
+ * signal processing and causes a call to nma_cert_chooser_validate()
+ * to fail.
+ *
+ * Since: 1.8.0
+ */
+ signals[CERT_PASSWORD_VALIDATE] = g_signal_new ("cert-password-validate",
+ NMA_TYPE_CERT_CHOOSER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (NMACertChooserClass,
cert_password_validate),
+ accu_validation_error, NULL, NULL,
+ G_TYPE_ERROR, 0);
+
+ /**
+ * NMACertChooser::key-validate:
+ *
+ * Emitted when the key needs validation. The handlers can indicate that
+ * the key is invalid by returning an error, which blocks further
+ * signal processing and causes a call to nma_cert_chooser_validate()
+ * to fail.
+ *
+ * Since: 1.8.0
+ */
+ signals[KEY_VALIDATE] = g_signal_new ("key-validate",
+ NMA_TYPE_CERT_CHOOSER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (NMACertChooserClass, key_validate),
+ accu_validation_error, NULL, NULL,
+ G_TYPE_ERROR, 0);
+
+ /**
+ * NMACertChooser::key-password-validate:
+ *
+ * Emitted when the key password needs validation. The handlers can indicate
+ * that the password is invalid by returning an error, which blocks further
+ * signal processing and causes a call to nma_cert_chooser_validate()
+ * to fail.
+ *
+ * Since: 1.8.0
+ */
+ signals[KEY_PASSWORD_VALIDATE] = g_signal_new ("key-password-validate",
+ NMA_TYPE_CERT_CHOOSER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (NMACertChooserClass,
key_password_validate),
+ accu_validation_error, NULL, NULL,
+ G_TYPE_ERROR, 0);
+
+ /**
+ * NMACertChooser::changed:
+ *
+ * Emitted when anything changes in the certificate chooser, be it a certificate,
+ * a key or associated passwords.
+ *
+ * Since: 1.8.0
+ */
+ signals[CHANGED] = g_signal_new ("changed",
+ NMA_TYPE_CERT_CHOOSER,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (NMACertChooserClass, changed),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
+}
+
+static void
+nma_cert_chooser_init (NMACertChooser *file_cert_chooser)
+{
}
/**
@@ -583,12 +686,8 @@ nma_cert_chooser_get_key_password_flags (NMACertChooser *cert_chooser)
GtkWidget *
nma_cert_chooser_new (const gchar *title, NMACertChooserFlags flags)
{
-#if LIBNM_BUILD && WITH_GCR
- if (flags & NMA_CERT_CHOOSER_FLAG_PEM)
- return nma_file_cert_chooser_new (title, flags);
-
- return nma_pkcs11_cert_chooser_new (title, flags);
-#else
- return nma_file_cert_chooser_new (title, flags);
-#endif
+ return g_object_new (NMA_TYPE_CERT_CHOOSER,
+ "title", title,
+ "flags", flags,
+ NULL);
}
diff --git a/src/libnma/nma-cert-chooser.h b/src/libnma/nma-cert-chooser.h
index b30f6ac..ae804ef 100644
--- a/src/libnma/nma-cert-chooser.h
+++ b/src/libnma/nma-cert-chooser.h
@@ -32,15 +32,39 @@ G_BEGIN_DECLS
#define NMA_TYPE_CERT_CHOOSER (nma_cert_chooser_get_type ())
#define NMA_CERT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_CERT_CHOOSER,
NMACertChooser))
+#define NMA_CERT_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_CERT_CHOOSER,
NMACertChooserClass))
#define NMA_IS_CERT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_CERT_CHOOSER))
-#define NMA_CERT_CHOOSER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj),
NMA_TYPE_CERT_CHOOSER, NMACertChooserInterface))
+#define NMA_IS_CERT_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_CERT_CHOOSER))
+#define NMA_CERT_CHOOSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_CERT_CHOOSER,
NMACertChooserClass))
NMA_AVAILABLE_IN_1_8
-typedef struct _NMACertChooser NMACertChooser;
+typedef struct {
+ GtkGrid parent;
+} NMACertChooser;
+
+/**
+ * NMACertChooserFlags:
+ * @NMA_CERT_CHOOSER_FLAG_CERT: Only pick a certificate, not a key
+ * @NMA_CERT_CHOOSER_FLAG_PASSWORDS: Hide all controls but the secrets entries
+ * @NMA_CERT_CHOOSER_FLAG_PEM: Ensure the chooser only selects regular PEM files
+ *
+ * Flags that controls what is the certificate chooser button able to pick.
+ * Currently only local files are supported, but might be extended to use URIs,
+ * such as PKCS\#11 certificate URIs in future as well.
+ *
+ * Since: 1.8.0
+ */
+NMA_AVAILABLE_IN_1_8
+typedef enum {
+ NMA_CERT_CHOOSER_FLAG_NONE = 0x0,
+ NMA_CERT_CHOOSER_FLAG_CERT = 0x1,
+ NMA_CERT_CHOOSER_FLAG_PASSWORDS = 0x2,
+ NMA_CERT_CHOOSER_FLAG_PEM = 0x4,
+} NMACertChooserFlags;
/**
- * NMACertChooserInterface:
- * @parent_iface: The parent interface.
+ * NMACertChooserClass:
+ * @parent_class: The parent class.
* @set_cert: Set the certificate location for the chooser button.
* @get_cert: Get the real certificate location from the chooser button along
* with the scheme.
@@ -77,7 +101,7 @@ typedef struct _NMACertChooser NMACertChooser;
*/
NMA_AVAILABLE_IN_1_8
typedef struct {
- GTypeInterface parent_iface;
+ GtkGridClass parent_class;
/* virtual methods */
void (*set_cert) (NMACertChooser *cert_chooser,
@@ -131,26 +155,13 @@ typedef struct {
GError *(*key_validate) (NMACertChooser *cert_chooser);
GError *(*key_password_validate) (NMACertChooser *cert_chooser);
void (*changed) (NMACertChooser *cert_chooser);
-} NMACertChooserInterface;
-/**
- * NMACertChooserFlags:
- * @NMA_CERT_CHOOSER_FLAG_CERT: Only pick a certificate, not a key
- * @NMA_CERT_CHOOSER_FLAG_PASSWORDS: Hide all controls but the secrets entries
- * @NMA_CERT_CHOOSER_FLAG_PEM: Ensure the chooser only selects regular PEM files
- *
- * Flags that controls what is the certificate chooser button able to pick.
- * Currently only local files are supported, but might be extended to use URIs,
- * such as PKCS\#11 certificate URIs in future as well.
- *
- * Since: 1.8.0
- */
-NMA_AVAILABLE_IN_1_8
-typedef enum {
- NMA_CERT_CHOOSER_FLAG_CERT = 0x1,
- NMA_CERT_CHOOSER_FLAG_PASSWORDS = 0x2,
- NMA_CERT_CHOOSER_FLAG_PEM = 0x4,
-} NMACertChooserFlags;
+ /*< private >*/
+ void (*set_title) (NMACertChooser *cert_chooser,
+ const gchar *title);
+ void (*set_flags) (NMACertChooser *cert_chooser,
+ NMACertChooserFlags flags);
+} NMACertChooserClass;
NMA_AVAILABLE_IN_1_8
GType nma_cert_chooser_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]