[gnome-keyring] gcr: Remove stock icon code, add gcr_icon_for_token_info()
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring] gcr: Remove stock icon code, add gcr_icon_for_token_info()
- Date: Tue, 27 Sep 2011 07:22:43 +0000 (UTC)
commit 71fdbb795e368641579bcd6f8f45945f5a383f4c
Author: Stef Walter <stefw collabora co uk>
Date: Tue Sep 27 09:19:49 2011 +0200
gcr: Remove stock icon code, add gcr_icon_for_token_info()
* gcr-icons.h is public
* Remove old stock icon code, and use themed icons properly
* Add gcr_icon_for_token_info() function which looks up an
appropriate icon for a token.
gcr/Makefile.am | 1 +
gcr/gcr-base.h | 1 +
gcr/gcr-certificate-renderer.c | 1 -
gcr/gcr-failure-renderer.c | 2 -
gcr/gcr-icons.c | 70 +++++++--------------------------------
gcr/gcr-icons.h | 7 +++-
gcr/gcr-key-renderer.c | 2 -
gcr/gcr-unlock-renderer.c | 2 -
8 files changed, 20 insertions(+), 66 deletions(-)
---
diff --git a/gcr/Makefile.am b/gcr/Makefile.am
index 28a51cb..eb8585e 100644
--- a/gcr/Makefile.am
+++ b/gcr/Makefile.am
@@ -20,6 +20,7 @@ HEADER_BASE_FILES = \
gcr-collection.h \
gcr-comparable.h \
gcr-deprecated-base.h \
+ gcr-icons.h \
gcr-library.h \
gcr-parser.h \
gcr-pkcs11-certificate.h \
diff --git a/gcr/gcr-base.h b/gcr/gcr-base.h
index 218030a..f70720b 100644
--- a/gcr/gcr-base.h
+++ b/gcr/gcr-base.h
@@ -38,6 +38,7 @@
#include "gcr-certificate-chain.h"
#include "gcr-deprecated-base.h"
#include "gcr-enum-types-base.h"
+#include "gcr-icons.h"
#include "gcr-library.h"
#include "gcr-parser.h"
#include "gcr-pkcs11-certificate.h"
diff --git a/gcr/gcr-certificate-renderer.c b/gcr/gcr-certificate-renderer.c
index 6c8535d..4516199 100644
--- a/gcr/gcr-certificate-renderer.c
+++ b/gcr/gcr-certificate-renderer.c
@@ -549,7 +549,6 @@ gcr_certificate_renderer_class_init (GcrCertificateRendererClass *klass)
g_param_spec_string ("label", "Label", "Certificate Label",
"", G_PARAM_READWRITE));
- _gcr_icons_register ();
gcr_certificate_mixin_class_init (gobject_class);
/* Register this as a renderer which can be loaded */
diff --git a/gcr/gcr-failure-renderer.c b/gcr/gcr-failure-renderer.c
index 8f75956..b6f829f 100644
--- a/gcr/gcr-failure-renderer.c
+++ b/gcr/gcr-failure-renderer.c
@@ -126,8 +126,6 @@ _gcr_failure_renderer_class_init (GcrFailureRendererClass *klass)
g_object_class_install_property (gobject_class, PROP_ATTRIBUTES,
g_param_spec_boxed ("attributes", "Attributes", "Certificate pkcs11 attributes",
GCK_TYPE_ATTRIBUTES, G_PARAM_READWRITE));
-
- _gcr_icons_register ();
}
static void
diff --git a/gcr/gcr-icons.c b/gcr/gcr-icons.c
index 9f2994e..ba946f7 100644
--- a/gcr/gcr-icons.c
+++ b/gcr/gcr-icons.c
@@ -1,7 +1,7 @@
/*
* gnome-keyring
*
- * Copyright (C) 2010 Stefan Walter
+ * Copyright (C) 2011 Collabora Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -17,70 +17,26 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
+ *
+ * Author: Stef Walter <stefw collabora co uk>
*/
#include "config.h"
-#include "gcr.h"
-#include "gcr-types.h"
+#include "gcr-base.h"
#include "gcr-icons.h"
-#include "gcr-internal.h"
-
-static gboolean registered_icons = FALSE;
-static const gchar *themed_icons[] = {
- GCR_ICON_CERTIFICATE,
- GCR_ICON_KEY,
- GCR_ICON_KEY_PAIR,
- NULL,
-};
-static void
-add_theme_source (GtkIconSet *iconset, const gchar *icon, GtkIconSize size)
+GIcon *
+gcr_icon_for_token_info (GckTokenInfo *token_info)
{
- GtkIconSource *source;
-
- source = gtk_icon_source_new ();
- gtk_icon_source_set_icon_name (source, icon);
- gtk_icon_source_set_direction_wildcarded (source, TRUE);
- gtk_icon_source_set_state_wildcarded (source, TRUE);
-
- if (size == -1) {
- gtk_icon_source_set_size_wildcarded (source, TRUE);
- } else {
- gtk_icon_source_set_size_wildcarded (source, FALSE);
- gtk_icon_source_set_size (source, size);
- }
-
- gtk_icon_set_add_source (iconset, source);
- gtk_icon_source_free (source);
-}
-
-void
-_gcr_icons_register (void)
-{
- GtkIconFactory *factory;
- GtkIconSet *iconset;
- const gchar **name;
-
- if (registered_icons)
- return;
+ GIcon *icon;
- /* Setup the icon factory. */
- factory = gtk_icon_factory_new ();
- gtk_icon_factory_add_default (factory);
+ g_return_val_if_fail (token_info != NULL, NULL);
- for (name = themed_icons; name && *name; name++) {
- iconset = gtk_icon_set_new ();
- add_theme_source (iconset, *name, GTK_ICON_SIZE_BUTTON);
- add_theme_source (iconset, *name, GTK_ICON_SIZE_MENU);
- add_theme_source (iconset, *name, GTK_ICON_SIZE_LARGE_TOOLBAR);
- add_theme_source (iconset, *name, GTK_ICON_SIZE_SMALL_TOOLBAR);
- add_theme_source (iconset, *name, GTK_ICON_SIZE_DIALOG);
- add_theme_source (iconset, *name, -1);
- gtk_icon_factory_add (factory, *name, iconset);
- gtk_icon_set_unref (iconset);
- }
+ if (g_strcmp0 (token_info->manufacturer_id, "Gnome Keyring") == 0)
+ icon = g_themed_icon_new (GCR_ICON_HOME_DIRECTORY);
+ else
+ icon = g_themed_icon_new (GCR_ICON_SMART_CARD);
- g_object_unref (factory);
- registered_icons = TRUE;
+ return icon;
}
diff --git a/gcr/gcr-icons.h b/gcr/gcr-icons.h
index 2974ae3..f0e8b69 100644
--- a/gcr/gcr-icons.h
+++ b/gcr/gcr-icons.h
@@ -2,6 +2,7 @@
* gnome-keyring
*
* Copyright (C) 2010 Stefan Walter
+ * Copyright (C) 2011 Collabora Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -29,9 +30,11 @@ G_BEGIN_DECLS
#define GCR_ICON_CERTIFICATE "application-certificate"
#define GCR_ICON_KEY "gcr-key"
#define GCR_ICON_KEY_PAIR "gcr-key-pair"
+#define GCR_ICON_SMART_CARD "gcr-smart-card"
+#define GCR_ICON_HOME_DIRECTORY "user-home"
-void _gcr_icons_register (void);
+GIcon * gcr_icon_for_token_info (GckTokenInfo *token_info);
G_END_DECLS
-#endif /* __GCR_TOKEN_MANAGER_H__ */
+#endif /* __GCR_SMART_CARD_H__ */
diff --git a/gcr/gcr-key-renderer.c b/gcr/gcr-key-renderer.c
index 242d842..b9248fd 100644
--- a/gcr/gcr-key-renderer.c
+++ b/gcr/gcr-key-renderer.c
@@ -225,8 +225,6 @@ gcr_key_renderer_class_init (GcrKeyRendererClass *klass)
g_object_class_override_property (gobject_class, PROP_LABEL, "label");
g_object_class_override_property (gobject_class, PROP_ATTRIBUTES, "attributes");
- _gcr_icons_register ();
-
/* Register this as a view which can be loaded */
registered = gck_attributes_new ();
gck_attributes_add_ulong (registered, CKA_CLASS, CKO_PRIVATE_KEY);
diff --git a/gcr/gcr-unlock-renderer.c b/gcr/gcr-unlock-renderer.c
index 106c2bc..9d15678 100644
--- a/gcr/gcr-unlock-renderer.c
+++ b/gcr/gcr-unlock-renderer.c
@@ -265,8 +265,6 @@ _gcr_unlock_renderer_class_init (GcrUnlockRendererClass *klass)
g_object_class_install_property (gobject_class, PROP_ATTRIBUTES,
g_param_spec_boxed ("attributes", "Attributes", "Certificate pkcs11 attributes",
GCK_TYPE_ATTRIBUTES, G_PARAM_READWRITE));
-
- _gcr_icons_register ();
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]