[gcr] Display proper certificate icon.
authorStef Walter <stef@memberwebs.com>
Sun, 20 Jun 2010 17:20:19 +0000 (17:20 +0000)
committerStef Walter <stef@memberwebs.com>
Tue, 13 Jul 2010 03:04:15 +0000 (03:04 +0000)
gcr/Makefile.am
gcr/gcr-certificate-widget.c
gcr/gcr-display-view.c
gcr/gcr-icons.c [new file with mode: 0644]
gcr/gcr-icons.h [new file with mode: 0644]

index 397b37a..d78b32c 100644 (file)
@@ -48,6 +48,7 @@ libgcr_la_SOURCES = \
        gcr-certificate-basics-widget.c gcr-certificate-basics-widget.h \
        gcr-certificate-details-widget.c gcr-certificate-details-widget.h \
        gcr-display-view.c gcr-display-view.h \
+       gcr-icons.c gcr-icons.h \
        gcr-import-dialog.c gcr-import-dialog.h \
        gcr-importer.c gcr-importer.h  \
        gcr-internal.h \
index 5d81b5b..7b81d7f 100644 (file)
@@ -22,6 +22,7 @@
 #include "gcr-certificate.h"
 #include "gcr-certificate-widget.h"
 #include "gcr-display-view.h"
+#include "gcr-icons.h"
 
 #include "egg/egg-asn1.h"
 #include "egg/egg-oid.h"
@@ -170,16 +171,8 @@ refresh_display (GcrCertificateWidget *self)
        /* TODO: Calculate name properly */
        _gcr_display_view_append_title (self->pv->view, "Certificate Name");
 
-#if 0
-       _gcr_display_view_append_table ()
-
-       Issued To:
-       Issued By:
-       Expires:
-#endif
-
        display = egg_asn1_read_dn_part (asn, "tbsCertificate.subject.rdnSequence", "CN");
-       _gcr_display_view_append_content (self->pv->view, _("Identifies"), display);
+       _gcr_display_view_append_content (self->pv->view, _("Identity"), display);
        g_free (display);
 
        display = egg_asn1_read_dn_part (asn, "tbsCertificate.issuer.rdnSequence", "CN");
@@ -310,7 +303,7 @@ gcr_certificate_widget_constructor (GType type, guint n_props, GObjectConstructP
        self = GCR_CERTIFICATE_WIDGET (obj);
 
        self->pv->view = _gcr_display_view_new ();
-       _gcr_display_view_set_stock_image (self->pv->view, GTK_STOCK_DIALOG_AUTHENTICATION);
+       _gcr_display_view_set_stock_image (self->pv->view, GCR_ICON_CERTIFICATE);
 
        scroll = gtk_scrolled_window_new (NULL, NULL);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
@@ -399,6 +392,8 @@ gcr_certificate_widget_class_init (GcrCertificateWidgetClass *klass)
        g_object_class_install_property (gobject_class, PROP_CERTIFICATE,
                   g_param_spec_object("certificate", "Certificate", "Certificate to display.",
                                       GCR_TYPE_CERTIFICATE, G_PARAM_READWRITE));
+
+       _gcr_icons_register ();
 }
 
 /* -----------------------------------------------------------------------------
index 86b3f4d..a66456c 100644 (file)
@@ -127,7 +127,6 @@ static void
 on_expander_realize (GtkWidget *widget, gpointer user_data)
 {
        GdkCursor *cursor = gdk_cursor_new (GDK_ARROW);
-       g_printerr ("realize cursor\n");
        gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
        gdk_cursor_unref (cursor);
 }
@@ -230,7 +229,6 @@ _gcr_display_view_realize (GtkWidget *widget)
        if (GTK_WIDGET_CLASS (_gcr_display_view_parent_class)->realize)
                GTK_WIDGET_CLASS (_gcr_display_view_parent_class)->realize (widget);
 
-       g_printerr ("setting color\n");
        style = gtk_widget_get_style (widget);
        gtk_widget_modify_bg (self->pv->details_widget, GTK_STATE_NORMAL, &style->base[GTK_STATE_NORMAL]);
 }
diff --git a/gcr/gcr-icons.c b/gcr/gcr-icons.c
new file mode 100644 (file)
index 0000000..9b6c38f
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * gnome-keyring
+ *
+ * Copyright (C) 2010 Stefan Walter
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "gcr.h"
+#include "gcr-types.h"
+#include "gcr-icons.h"
+#include "gcr-internal.h"
+
+static gboolean registered_icons = FALSE;
+static const gchar *themed_icons[] = {
+       GCR_ICON_FOLDER,
+       GCR_ICON_CERTIFICATE,
+       NULL,
+};
+
+static void
+add_theme_source (GtkIconSet *iconset, const gchar *icon, GtkIconSize size)
+{
+       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;
+
+       /* Setup the icon factory. */
+       factory = gtk_icon_factory_new ();
+       gtk_icon_factory_add_default (factory);
+
+       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);
+       }
+
+       g_object_unref (factory);
+       registered_icons = TRUE;
+}
diff --git a/gcr/gcr-icons.h b/gcr/gcr-icons.h
new file mode 100644 (file)
index 0000000..7465438
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * gnome-keyring
+ *
+ * Copyright (C) 2010 Stefan Walter
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef __GCR_ICONS_H__
+#define __GCR_ICONS_H__
+
+#include "gcr-internal.h"
+
+G_BEGIN_DECLS
+
+#define GCR_ICON_FOLDER         "folder"
+#define GCR_ICON_CERTIFICATE    "application-certificate"
+
+void         _gcr_icons_register         (void);
+
+G_END_DECLS
+
+#endif /* __GCR_TOKEN_MANAGER_H__ */