gnome-keyring [PATCH 5/9] ui: add PKCS#11 object chooser interface



Will be implmented by the widget, dialog and possibly a button in
future.
---
 ui/Makefile.am          |  2 ++
 ui/gcr-object-chooser.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++
 ui/gcr-object-chooser.h | 41 ++++++++++++++++++++++
 ui/gcr-ui.symbols       |  3 ++
 4 files changed, 139 insertions(+)
 create mode 100644 ui/gcr-object-chooser.c
 create mode 100644 ui/gcr-object-chooser.h

diff --git a/ui/Makefile.am b/ui/Makefile.am
index b1e5468..4466ecb 100644
--- a/ui/Makefile.am
+++ b/ui/Makefile.am
@@ -59,6 +59,7 @@ ui_HEADER_FILES = \
        ui/gcr-key-widget.h \
        ui/gcr-import-button.h \
        ui/gcr-list-selector.h \
+       ui/gcr-object-chooser.h \
        ui/gcr-prompt-dialog.h \
        ui/gcr-renderer.h \
        ui/gcr-secure-entry-buffer.h \
@@ -84,6 +85,7 @@ ui_PUBLIC_FILES = \
        ui/gcr-key-widget.c ui/gcr-key-widget.h \
        ui/gcr-import-button.c  ui/gcr-import-button.h \
        ui/gcr-list-selector.c ui/gcr-list-selector.h \
+       ui/gcr-object-chooser.c ui/gcr-object-chooser.h \
        ui/gcr-prompt-dialog.c ui/gcr-prompt-dialog.h \
        ui/gcr-renderer.c ui/gcr-renderer.h \
        ui/gcr-secure-entry-buffer.c ui/gcr-secure-entry-buffer.h \
diff --git a/ui/gcr-object-chooser.c b/ui/gcr-object-chooser.c
new file mode 100644
index 0000000..6a9f869
--- /dev/null
+++ b/ui/gcr-object-chooser.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2016 Lubomir Rintel
+ *
+ * This program 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program 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 program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gcr-object-chooser.h"
+#include "gcr-tokens-sidebar.h"
+
+#include <gtk/gtk.h>
+
+/**
+ * SECTION:gcr-object-chooser
+ * @title: GcrObjectChooser
+ * @short_description: The PKCS11 Object Chooser Interface
+ * @see_also: #GcrObjectChooserDialog
+ *
+ * #GcrObjectChooser is an interface for PKCS11 object chooser widgets.
+ */
+
+G_DEFINE_INTERFACE (GcrObjectChooser, gcr_object_chooser, G_TYPE_OBJECT)
+
+static void
+gcr_object_chooser_default_init (GcrObjectChooserInterface *iface)
+{
+
+       /**
+        * GcrObjectChooser::object-activated
+        *
+        * Emitted when an object choice is confirmed (e.g. with a double click).
+        */
+       g_signal_new ("object-activated",
+                     G_TYPE_FROM_INTERFACE (iface),
+                     G_SIGNAL_RUN_LAST,
+                     0, NULL, NULL,
+                     g_cclosure_marshal_VOID__VOID,
+                     G_TYPE_NONE, 0);
+
+       /**
+        * GcrObjectChooser::object-selected
+        *
+        * Emitted when the object is selected; not yet confirmed.
+        */
+       g_signal_new ("object-selected",
+                     G_TYPE_FROM_INTERFACE (iface),
+                     G_SIGNAL_RUN_LAST,
+                     0, NULL, NULL,
+                     g_cclosure_marshal_VOID__VOID,
+                     G_TYPE_NONE, 0);
+}
+
+/**
+ * gcr_object_chooser_set_uri:
+ * @self: the #GcrObjectChooser
+ * @uri: the object URI
+ *
+ * Set the URI of the focused object. If it's not yet added, then it will
+ * be focused as soon as it appears.
+ */
+void
+gcr_object_chooser_set_uri (GcrObjectChooser *self, const gchar *uri)
+{
+       g_return_if_fail (GCR_IS_OBJECT_CHOOSER (self));
+
+       GCR_OBJECT_CHOOSER_GET_IFACE (self)->set_uri (self, uri);
+}
+
+/**
+ * gcr_object_chooser_get_uri:
+ * @self: the #GcrObjectChooser
+ *
+ * Get the URI of the currently selected object.
+ *
+ * Returns: (transfer full): the URI of the object.
+ */
+gchar *
+gcr_object_chooser_get_uri (GcrObjectChooser *self)
+{
+       g_return_val_if_fail (GCR_IS_OBJECT_CHOOSER (self), NULL);
+
+       return GCR_OBJECT_CHOOSER_GET_IFACE (self)->get_uri (self);
+}
diff --git a/ui/gcr-object-chooser.h b/ui/gcr-object-chooser.h
new file mode 100644
index 0000000..204be13
--- /dev/null
+++ b/ui/gcr-object-chooser.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2016 Lubomir Rintel
+ *
+ * This program 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program 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 program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __GCR_OBJECT_CHOOSER_H__
+#define __GCR_OBJECT_CHOOSER_H__
+
+#include <gtk/gtk.h>
+
+typedef struct _GcrObjectChooser GcrObjectChooser;
+
+struct _GcrObjectChooserInterface
+{
+       GTypeInterface g_iface;
+
+       void (*set_uri) (GcrObjectChooser *self, const gchar *uri);
+       gchar *(*get_uri) (GcrObjectChooser *self);
+};
+
+#define GCR_TYPE_OBJECT_CHOOSER gcr_object_chooser_get_type ()
+G_DECLARE_INTERFACE (GcrObjectChooser, gcr_object_chooser, GCR, OBJECT_CHOOSER, GObject)
+
+void gcr_object_chooser_set_uri (GcrObjectChooser *self, const gchar *uri);
+
+gchar *gcr_object_chooser_get_uri (GcrObjectChooser *self);
+
+#endif /* __GCR_OBJECT_CHOOSER_H__ */
diff --git a/ui/gcr-ui.symbols b/ui/gcr-ui.symbols
index d7f4188..443d598 100644
--- a/ui/gcr-ui.symbols
+++ b/ui/gcr-ui.symbols
@@ -62,6 +62,9 @@ gcr_list_selector_get_selected
 gcr_list_selector_get_type
 gcr_list_selector_new
 gcr_list_selector_set_selected
+gcr_object_chooser_get_type
+gcr_object_chooser_get_uri
+gcr_object_chooser_set_uri
 gcr_prompt_dialog_get_type
 gcr_renderer_create
 gcr_renderer_emit_data_changed
-- 
2.9.3



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