summaryrefslogtreecommitdiff
path: root/gcr
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2022-06-26 21:56:06 +0200
committerNiels De Graef <nielsdegraef@gmail.com>2022-06-27 15:31:28 +0200
commit022837ad41282cb21151ce1277397f5e90fe07ef (patch)
treeda6afb3aa5cee0230248119ebe69fcfcf2184c18 /gcr
parent39864e7c2195051f7454c7ad62ced513fbc91aef (diff)
downloadgcr-022837ad41282cb21151ce1277397f5e90fe07ef.tar.gz
Drop custom icons in gcr
Icons are problematic to provide within gcr, as different DEs that are using it, have different expectations what such an icon should look like: one wants it to be colorful, another wants it to be monochrome, yet another wants everything skeumorphic etc. Let's not deal with this in gcr4 and drop any icons. If applications want to provide an icon, they can do that themselves much better then we ever can.
Diffstat (limited to 'gcr')
-rw-r--r--gcr/gcr-certificate.c34
-rw-r--r--gcr/gcr-certificate.h2
-rw-r--r--gcr/gcr-gnupg-importer.c17
-rw-r--r--gcr/gcr-gnupg-key.c44
-rw-r--r--gcr/gcr-gnupg-key.h2
-rw-r--r--gcr/gcr-gnupg-records.c79
-rw-r--r--gcr/gcr-gnupg-records.h2
-rw-r--r--gcr/gcr-icons.c64
-rw-r--r--gcr/gcr-icons.h46
-rw-r--r--gcr/gcr-importer.c10
-rw-r--r--gcr/gcr-memory-icon.c223
-rw-r--r--gcr/gcr-memory-icon.h66
-rw-r--r--gcr/gcr-pkcs11-importer.c21
-rw-r--r--gcr/gcr.h1
-rw-r--r--gcr/meson.build4
-rw-r--r--gcr/test-memory-icon.c218
16 files changed, 1 insertions, 832 deletions
diff --git a/gcr/gcr-certificate.c b/gcr/gcr-certificate.c
index 714f4a9..71a1416 100644
--- a/gcr/gcr-certificate.c
+++ b/gcr/gcr-certificate.c
@@ -22,7 +22,6 @@
#include "gcr-certificate.h"
#include "gcr-certificate-extensions.h"
#include "gcr-comparable.h"
-#include "gcr-icons.h"
#include "gcr-internal.h"
#include "gcr-subject-public-key.h"
@@ -106,7 +105,6 @@ enum {
PROP_LABEL,
PROP_MARKUP,
PROP_DESCRIPTION,
- PROP_ICON,
PROP_SUBJECT,
PROP_ISSUER,
PROP_EXPIRY
@@ -281,15 +279,6 @@ gcr_certificate_default_init (GcrCertificateIface *iface)
"", G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
- * GcrCertificate:icon:
- *
- * An icon representing the certificate
- */
- g_object_interface_install_property (iface,
- g_param_spec_object ("icon", "Icon", "Icon for the object being rendered",
- G_TYPE_ICON, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- /**
* GcrCertificate:subject:
*
* Common name part of the certificate subject
@@ -339,7 +328,6 @@ const GcrColumn*
gcr_certificate_get_columns (void)
{
static GcrColumn columns[] = {
- { "icon", /* later */ 0, /* later */ 0, NULL, 0 },
{ "label", G_TYPE_STRING, G_TYPE_STRING, NC_("column", "Name"),
GCR_COLUMN_SORTABLE },
{ "issuer", G_TYPE_STRING, G_TYPE_STRING, NC_("column", "Issued By"),
@@ -349,7 +337,6 @@ gcr_certificate_get_columns (void)
{ NULL }
};
- columns[0].property_type = columns[0].column_type = G_TYPE_ICON;
columns[3].property_type = G_TYPE_DATE;
return columns;
}
@@ -988,22 +975,6 @@ gcr_certificate_get_serial_number_hex (GcrCertificate *self)
}
/**
- * gcr_certificate_get_icon: (skip)
- * @self: The certificate
- *
- * Get the icon for a certificate.
- *
- * Returns: (transfer full): the icon for this certificate, which should be
- * released with g_object_unref()
- */
-GIcon *
-gcr_certificate_get_icon (GcrCertificate *self)
-{
- g_return_val_if_fail (GCR_IS_CERTIFICATE (self), FALSE);
- return g_themed_icon_new (GCR_ICON_CERTIFICATE);
-}
-
-/**
* gcr_certificate_get_basic_constraints:
* @self: the certificate
* @is_ca: (out) (optional): location to place a %TRUE if is an authority
@@ -1113,8 +1084,6 @@ gcr_certificate_mixin_class_init (GObjectClass *object_class)
g_object_class_override_property (object_class, PROP_MARKUP, "markup");
if (!g_object_class_find_property (object_class, "label"))
g_object_class_override_property (object_class, PROP_LABEL, "label");
- if (!g_object_class_find_property (object_class, "icon"))
- g_object_class_override_property (object_class, PROP_ICON, "icon");
if (!g_object_class_find_property (object_class, "subject"))
g_object_class_override_property (object_class, PROP_SUBJECT, "subject");
if (!g_object_class_find_property (object_class, "issuer"))
@@ -1180,9 +1149,6 @@ gcr_certificate_mixin_get_property (GObject *obj, guint prop_id,
case PROP_SUBJECT:
g_value_take_string (value, gcr_certificate_get_subject_name (cert));
break;
- case PROP_ICON:
- g_value_set_object (value, gcr_certificate_get_icon (cert));
- break;
case PROP_DESCRIPTION:
g_value_set_string (value, _("Certificate"));
break;
diff --git a/gcr/gcr-certificate.h b/gcr/gcr-certificate.h
index 12a1275..d6a60b9 100644
--- a/gcr/gcr-certificate.h
+++ b/gcr/gcr-certificate.h
@@ -126,8 +126,6 @@ gchar* gcr_certificate_get_fingerprint_hex (GcrCertificate *self
gchar * gcr_certificate_get_markup_text (GcrCertificate *self);
-GIcon* gcr_certificate_get_icon (GcrCertificate *self);
-
gboolean gcr_certificate_get_basic_constraints (GcrCertificate *self,
gboolean *is_ca,
gint *path_len);
diff --git a/gcr/gcr-gnupg-importer.c b/gcr/gcr-gnupg-importer.c
index 5fa93bd..36c40c4 100644
--- a/gcr/gcr-gnupg-importer.c
+++ b/gcr/gcr-gnupg-importer.c
@@ -30,7 +30,6 @@
enum {
PROP_0,
PROP_LABEL,
- PROP_ICON,
PROP_IMPORTED,
PROP_DIRECTORY,
PROP_INTERACTION,
@@ -97,18 +96,6 @@ calculate_label (GcrGnupgImporter *self)
return g_strdup_printf (_("GnuPG Keyring: %s"), directory);
}
-static GIcon *
-calculate_icon (GcrGnupgImporter *self)
-{
- const gchar *directory;
-
- directory = _gcr_gnupg_process_get_directory (self->pv->process);
- if (directory == NULL)
- return g_themed_icon_new ("user-home");
- else
- return g_themed_icon_new ("folder");
-}
-
static gchar *
calculate_uri (GcrGnupgImporter *self)
{
@@ -203,9 +190,6 @@ _gcr_gnupg_importer_get_property (GObject *obj,
case PROP_LABEL:
g_value_take_string (value, calculate_label (self));
break;
- case PROP_ICON:
- g_value_take_object (value, calculate_icon (self));
- break;
case PROP_IMPORTED:
g_value_set_boxed (value, _gcr_gnupg_importer_get_imported (self));
break;
@@ -236,7 +220,6 @@ _gcr_gnupg_importer_class_init (GcrGnupgImporterClass *klass)
gobject_class->get_property = _gcr_gnupg_importer_get_property;
g_object_class_override_property (gobject_class, PROP_LABEL, "label");
- g_object_class_override_property (gobject_class, PROP_ICON, "icon");
g_object_class_override_property (gobject_class, PROP_INTERACTION, "interaction");
g_object_class_override_property (gobject_class, PROP_URI, "uri");
diff --git a/gcr/gcr-gnupg-key.c b/gcr/gcr-gnupg-key.c
index f412665..defeaaf 100644
--- a/gcr/gcr-gnupg-key.c
+++ b/gcr/gcr-gnupg-key.c
@@ -22,7 +22,6 @@
#include "gcr-gnupg-key.h"
#include "gcr-gnupg-records.h"
#include "gcr-record.h"
-#include "gcr-memory-icon.h"
#include "gck/gck.h"
@@ -37,13 +36,12 @@ enum {
PROP_MARKUP,
PROP_DESCRIPTION,
PROP_SHORT_KEYID,
- PROP_ICON
+ N_PROPS
};
struct _GcrGnupgKeyPrivate {
GPtrArray *public_records;
GPtrArray *secret_records;
- GIcon *icon;
};
G_DEFINE_TYPE_WITH_PRIVATE (GcrGnupgKey, _gcr_gnupg_key, G_TYPE_OBJECT);
@@ -148,9 +146,6 @@ _gcr_gnupg_key_get_property (GObject *obj, guint prop_id, GValue *value,
case PROP_SHORT_KEYID:
g_value_set_string (value, _gcr_gnupg_records_get_short_keyid (self->pv->public_records));
break;
- case PROP_ICON:
- g_value_set_object (value, _gcr_gnupg_key_get_icon (self));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -231,15 +226,6 @@ _gcr_gnupg_key_class_init (GcrGnupgKeyClass *klass)
g_object_class_install_property (gobject_class, PROP_SHORT_KEYID,
g_param_spec_string ("short-keyid", "Short Key ID", "Display key identifier",
"", G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- /**
- * GcrGnupgKey:icon:
- *
- * Icon for this key.
- */
- g_object_class_install_property (gobject_class, PROP_ICON,
- g_param_spec_object ("icon", "Icon", "Icon for this key",
- G_TYPE_ICON, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
}
/**
@@ -389,32 +375,6 @@ _gcr_gnupg_key_get_keyid (GcrGnupgKey *self)
}
/**
- * _gcr_gnupg_key_get_icon:
- * @self: A gnupg key.
- *
- * Get the display icon for this key.
- *
- * Return value: (transfer none): The icon, owned by the key.
- */
-GIcon*
-_gcr_gnupg_key_get_icon (GcrGnupgKey *self)
-{
- g_return_val_if_fail (GCR_IS_GNUPG_KEY (self), NULL);
-
- if (self->pv->icon == NULL) {
- self->pv->icon = _gcr_gnupg_records_get_icon (self->pv->public_records);
- if (self->pv->icon == NULL) {
- if (self->pv->secret_records)
- self->pv->icon = g_themed_icon_new ("gcr-key-pair");
- else
- self->pv->icon = g_themed_icon_new ("gcr-key");
- }
- }
-
- return self->pv->icon;
-}
-
-/**
* _gcr_gnupg_key_get_columns:
*
* Get the columns that we should display for gnupg keys.
@@ -425,7 +385,6 @@ const GcrColumn*
_gcr_gnupg_key_get_columns (void)
{
static GcrColumn columns[] = {
- { "icon", /* later */ 0, /* later */ 0, NULL, 0, NULL, 0 },
{ "label", G_TYPE_STRING, G_TYPE_STRING, NC_("column", "Name"),
GCR_COLUMN_SORTABLE, NULL, 0 },
{ "short-keyid", G_TYPE_STRING, G_TYPE_STRING, NC_("column", "Key ID"),
@@ -433,6 +392,5 @@ _gcr_gnupg_key_get_columns (void)
{ NULL }
};
- columns[0].property_type = columns[0].column_type = G_TYPE_ICON;
return columns;
}
diff --git a/gcr/gcr-gnupg-key.h b/gcr/gcr-gnupg-key.h
index 9a3da2b..cceb71b 100644
--- a/gcr/gcr-gnupg-key.h
+++ b/gcr/gcr-gnupg-key.h
@@ -72,8 +72,6 @@ GPtrArray* _gcr_gnupg_key_get_secret_records (GcrGnupgKey *s
void _gcr_gnupg_key_set_secret_records (GcrGnupgKey *self,
GPtrArray *records);
-GIcon* _gcr_gnupg_key_get_icon (GcrGnupgKey *self);
-
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GcrGnupgKey, g_object_unref)
G_END_DECLS
diff --git a/gcr/gcr-gnupg-records.c b/gcr/gcr-gnupg-records.c
index f8ee6bb..222f3dd 100644
--- a/gcr/gcr-gnupg-records.c
+++ b/gcr/gcr-gnupg-records.c
@@ -21,7 +21,6 @@
#include "gcr-gnupg-records.h"
#include "gcr-record.h"
-#include "gcr-memory-icon.h"
#include "gck/gck.h"
@@ -184,81 +183,3 @@ _gcr_gnupg_records_get_fingerprint (GPtrArray *records)
return _gcr_record_get_raw (record, GCR_RECORD_FPR_FINGERPRINT);
return NULL;
}
-
-#define TYPE_IMAGE 0x01
-#define IMAGE_HEADER_LEN 0x10
-#define IMAGE_JPEG_SIG "\x10\x00\x01\x01"
-#define IMAGE_JPEG_SIG_LEN 4
-
-static void
-add_emblem_to_icon (GIcon **icon,
- const gchar *emblem_name)
-{
- GIcon *emblem_icon;
- GIcon *result;
- GEmblem *emblem;
-
- emblem_icon = g_themed_icon_new (emblem_name);
- emblem = g_emblem_new_with_origin (emblem_icon, G_EMBLEM_ORIGIN_LIVEMETADATA);
- result = g_emblemed_icon_new (*icon, emblem);
- g_object_unref (*icon);
- *icon = result;
- g_object_unref (emblem);
- g_object_unref (emblem_icon);
-}
-
-GIcon *
-_gcr_gnupg_records_get_icon (GPtrArray *records)
-{
- GcrRecord *record;
- gchar validity;
- guchar *data;
- gsize n_data;
- guint type;
- GIcon *icon;
- guint i;
-
- for (i = 0; i < records->len; i++) {
- record = records->pdata[i];
- if (GCR_RECORD_SCHEMA_XA1 != _gcr_record_get_schema (record))
- continue;
- if (!_gcr_record_get_uint (record, GCR_RECORD_XA1_TYPE, &type))
- continue;
- if (type != TYPE_IMAGE)
- continue;
-
- data = _gcr_record_get_base64 (record, GCR_RECORD_XA1_DATA, &n_data);
- g_return_val_if_fail (data != NULL, NULL);
-
- /* Header is 16 bytes long */
- if (n_data <= IMAGE_HEADER_LEN) {
- g_free (data);
- continue;
- }
-
- /* These are the header bytes. See gnupg doc/DETAILS */
- g_assert (IMAGE_JPEG_SIG_LEN < IMAGE_HEADER_LEN);
- if (memcmp (data, IMAGE_JPEG_SIG, IMAGE_JPEG_SIG_LEN) != 0) {
- g_free (data);
- continue;
- }
-
- icon = G_ICON (_gcr_memory_icon_new_full ("image/jpeg", data,
- n_data, IMAGE_HEADER_LEN,
- g_free));
-
- validity = _gcr_record_get_char (record, GCR_RECORD_XA1_TRUST);
- if (validity != 0 && validity != 'm' && validity != 'f' && validity != 'u')
- add_emblem_to_icon (&icon, "dialog-question");
-
- /* We have a valid header */
- return icon;
- }
-
- if (_gcr_records_find (records, GCR_RECORD_SCHEMA_SEC))
- return g_themed_icon_new ("gcr-key-pair");
- else
- return g_themed_icon_new ("gcr-key");
-
- return NULL;
-}
diff --git a/gcr/gcr-gnupg-records.h b/gcr/gcr-gnupg-records.h
index 1f26538..bbc6859 100644
--- a/gcr/gcr-gnupg-records.h
+++ b/gcr/gcr-gnupg-records.h
@@ -39,8 +39,6 @@ gboolean _gcr_gnupg_records_parse_user_id (const gchar *user_
gchar **email,
gchar **comment);
-GIcon * _gcr_gnupg_records_get_icon (GPtrArray *records);
-
G_END_DECLS
#endif /* __GCR_GNUPG_RECORD_H__ */
diff --git a/gcr/gcr-icons.c b/gcr/gcr-icons.c
deleted file mode 100644
index 7183c70..0000000
--- a/gcr/gcr-icons.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * gnome-keyring
- *
- * 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
- * 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/>.
- *
- * Author: Stef Walter <stefw@collabora.co.uk>
- */
-
-#include "config.h"
-
-#include "gcr-icons.h"
-
-#define ICON_SYSTEM "applications-system"
-#define ICON_FOLDER "folder"
-
-/**
- * gcr_icon_for_token:
- * @token_info: the token info
- *
- * Get an appropriate icon for the token
- *
- * Returns: (transfer full): the icon
- */
-GIcon *
-gcr_icon_for_token (GckTokenInfo *token_info)
-{
- GIcon *icon;
-
- g_return_val_if_fail (token_info != NULL, NULL);
-
- if (g_strcmp0 (token_info->manufacturer_id, "Gnome Keyring") == 0) {
- icon = g_themed_icon_new (GCR_ICON_HOME_DIRECTORY);
-
- } else if (g_strcmp0 (token_info->model, "p11-kit-trust") == 0) {
- if (g_strcmp0 (token_info->label, "Default Trust") == 0 ||
- g_strcmp0 (token_info->label, "System Trust") == 0) {
- icon = g_themed_icon_new (ICON_SYSTEM);
- } else {
- icon = g_themed_icon_new (ICON_FOLDER);
- }
-
- } else if (g_strcmp0 (token_info->manufacturer_id, "Mozilla Foundation") == 0 &&
- g_strcmp0 (token_info->model, "NSS 3") == 0) {
- icon = g_themed_icon_new (GCR_ICON_HOME_DIRECTORY);
-
- } else {
- icon = g_themed_icon_new (GCR_ICON_SMART_CARD);
- }
-
- return icon;
-}
diff --git a/gcr/gcr-icons.h b/gcr/gcr-icons.h
deleted file mode 100644
index 4915fe1..0000000
--- a/gcr/gcr-icons.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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
- * 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_ICONS_H__
-#define __GCR_ICONS_H__
-
-#if !defined (__GCR_INSIDE_HEADER__) && !defined (GCR_COMPILATION)
-#error "Only <gcr/gcr.h> can be included directly."
-#endif
-
-#include <gck/gck.h>
-
-#include <gio/gio.h>
-
-G_BEGIN_DECLS
-
-#define GCR_ICON_CERTIFICATE "application-certificate"
-#define GCR_ICON_PASSWORD "gcr-password"
-#define GCR_ICON_GNUPG "gcr-gnupg"
-#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"
-
-GIcon * gcr_icon_for_token (GckTokenInfo *token_info);
-
-G_END_DECLS
-
-#endif /* __GCR_SMART_CARD_H__ */
diff --git a/gcr/gcr-importer.c b/gcr/gcr-importer.c
index f1916f0..0b98a61 100644
--- a/gcr/gcr-importer.c
+++ b/gcr/gcr-importer.c
@@ -91,16 +91,6 @@ gcr_importer_default_init (GcrImporterInterface *iface)
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
- * GcrImporter:icon:
- *
- * The icon for the importer.
- */
- g_object_interface_install_property (iface,
- g_param_spec_object ("icon", "Icon", "The icon for the importer",
- G_TYPE_ICON,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- /**
* GcrImporter:interaction:
*
* The interaction for the importer.
diff --git a/gcr/gcr-memory-icon.c b/gcr/gcr-memory-icon.c
deleted file mode 100644
index b37f9a5..0000000
--- a/gcr/gcr-memory-icon.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * 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
- * 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/>.
- *
- * Author: Stef Walter <stefw@collabora.co.uk>
- */
-
-#include "config.h"
-
-#include "gcr-memory-icon.h"
-
-#include <string.h>
-
-struct _GcrMemoryIconPrivate {
- gpointer data;
- gsize n_data;
- goffset offset;
- gchar *image_type;
- GDestroyNotify destroy;
-};
-
-/* Forward declarations */
-static void _gcr_memory_icon_iface_icon (GIconIface *iface);
-static void _gcr_memory_icon_iface_loadable_icon (GLoadableIconIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (GcrMemoryIcon, _gcr_memory_icon, G_TYPE_OBJECT,
- G_ADD_PRIVATE (GcrMemoryIcon);
- G_IMPLEMENT_INTERFACE (G_TYPE_ICON, _gcr_memory_icon_iface_icon);
- G_IMPLEMENT_INTERFACE (G_TYPE_LOADABLE_ICON, _gcr_memory_icon_iface_loadable_icon);
-);
-
-
-static void
-_gcr_memory_icon_init (GcrMemoryIcon *self)
-{
- self->pv = _gcr_memory_icon_get_instance_private (self);
-}
-
-static void
-_gcr_memory_icon_finalize (GObject *obj)
-{
- GcrMemoryIcon *self = GCR_MEMORY_ICON (obj);
-
- if (self->pv->destroy)
- (self->pv->destroy) (self->pv->data);
- g_free (self->pv->image_type);
-
- G_OBJECT_CLASS (_gcr_memory_icon_parent_class)->finalize (obj);
-}
-
-static void
-_gcr_memory_icon_class_init (GcrMemoryIconClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = _gcr_memory_icon_finalize;
-}
-
-static gboolean
-_gcr_memory_icon_equal (GIcon *icon1, GIcon *icon2)
-{
- GcrMemoryIcon *one = GCR_MEMORY_ICON (icon1);
- GcrMemoryIcon *two = GCR_MEMORY_ICON (icon2);
-
- if (icon1 == icon2)
- return TRUE;
- if (!g_str_equal (one->pv->image_type, two->pv->image_type))
- return FALSE;
- if ((one->pv->n_data - one->pv->offset) != (two->pv->n_data - two->pv->offset))
- return FALSE;
- return memcmp ((guchar*)one->pv->data + one->pv->offset,
- (guchar*)two->pv->data + two->pv->offset,
- one->pv->n_data - one->pv->offset) == 0;
-}
-
-static guint
-_gcr_memory_icon_hash (GIcon *icon)
-{
- GcrMemoryIcon *self = GCR_MEMORY_ICON (icon);
- const signed char *p, *end;
- guint32 hash;
-
- hash = g_str_hash (self->pv->image_type);
-
- /* Adapted from g_str_hash */
- p = self->pv->data;
- end = p + self->pv->n_data;
- p += self->pv->offset;
- while (p < end)
- hash = (hash << 5) + hash + *(p++);
-
- return hash;
-}
-
-static void
-_gcr_memory_icon_iface_icon (GIconIface *iface)
-{
- iface->equal = _gcr_memory_icon_equal;
- iface->hash = _gcr_memory_icon_hash;
-}
-
-static GInputStream *
-_gcr_memory_icon_load (GLoadableIcon *icon, int size, gchar **type,
- GCancellable *cancellable, GError **error)
-{
- GcrMemoryIcon *self = GCR_MEMORY_ICON (icon);
- GInputStream *is;
-
- if (type != NULL)
- *type = g_strdup (self->pv->image_type);
-
- is = g_memory_input_stream_new_from_data ((guchar*)self->pv->data + self->pv->offset,
- self->pv->n_data, NULL);
-
- /*
- * Hold a reference to this object from the stream, so that we can rely
- * on the data hanging around.
- */
- g_object_set_data_full (G_OBJECT (is), "back-reference", g_object_ref (self),
- g_object_unref);
-
- return is;
-}
-
-static void
-_gcr_memory_icon_load_async (GLoadableIcon *icon, int size, GCancellable *cancellable,
- GAsyncReadyCallback callback, gpointer user_data)
-{
- GTask *task;
-
- task = g_task_new (icon, cancellable, callback, user_data);
- g_task_set_source_tag (task, _gcr_memory_icon_load_async);
-
- /* We don't do anything with the task value, so just return a bogus value */
- g_task_return_pointer (task, NULL, NULL);
- g_object_unref (task);
-}
-
-static GInputStream*
-_gcr_memory_icon_finish (GLoadableIcon *icon, GAsyncResult *res, char **type,
- GError **error)
-{
- g_return_val_if_fail (g_task_is_valid (res, icon), NULL);
-
- return _gcr_memory_icon_load (icon, 0, type, NULL, error);
-}
-
-
-static void
-_gcr_memory_icon_iface_loadable_icon (GLoadableIconIface *iface)
-{
- iface->load = _gcr_memory_icon_load;
- iface->load_async = _gcr_memory_icon_load_async;
- iface->load_finish = _gcr_memory_icon_finish;
-}
-
-/**
- * _gcr_memory_icon_new:
- * @image_type: MIME content-type of the image.
- * @data: Data for the image.
- * @n_data: Length of data.
- *
- * Create a new GIcon based on image data in memory. The data will be copied
- * by the new icon.
- *
- * Returns: (transfer full) (type Gcr.MemoryIcon): A newly allocated icon.
- */
-GIcon*
-_gcr_memory_icon_new (const gchar *image_type, gconstpointer data, gsize n_data)
-{
- g_return_val_if_fail (image_type != NULL, NULL);
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (n_data != 0, NULL);
-
- return _gcr_memory_icon_new_full (image_type, g_memdup2 (data, n_data),
- n_data, 0, g_free);
-}
-
-/**
- * _gcr_memory_icon_new_full:
- * @image_type: MIME content-type of the image.
- * @data: Data for the image.
- * @n_data: Length of data.
- * @offset: Offset of the start of the image in @data.
- * @destroy: Callback to free or release @data when no longer needed.
- *
- * Create a new GIcon based on image data in memory. The data will be used
- * directly from the @data passed. Use @destroy to control the lifetime of
- * the data in memory.
- *
- * Returns: (transfer full): A newly allocated icon.
- */
-GIcon*
-_gcr_memory_icon_new_full (const gchar *image_type, gpointer data, gsize n_data,
- goffset offset, GDestroyNotify destroy)
-{
- GcrMemoryIcon *self;
-
- g_return_val_if_fail (image_type != NULL, NULL);
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (offset < n_data, NULL);
-
- self = g_object_new (GCR_TYPE_MEMORY_ICON, NULL);
- self->pv->data = data;
- self->pv->n_data = n_data;
- self->pv->offset = offset;
- self->pv->destroy = destroy;
- self->pv->image_type = g_strdup (image_type);
-
- return G_ICON (self);
-}
diff --git a/gcr/gcr-memory-icon.h b/gcr/gcr-memory-icon.h
deleted file mode 100644
index afe85ba..0000000
--- a/gcr/gcr-memory-icon.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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
- * 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/>.
- *
- * Author: Stef Walter <stefw@collabora.co.uk>
- */
-
-#ifndef GCR_MEMORY_ICON_H
-#define GCR_MEMORY_ICON_H
-
-#include <glib-object.h>
-#include <gio/gio.h>
-
-G_BEGIN_DECLS
-
-#define GCR_MEMORY_ICON_COLUMNS (_gcr_memory_icon_get_columns ())
-#define GCR_TYPE_MEMORY_ICON (_gcr_memory_icon_get_type ())
-#define GCR_MEMORY_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCR_TYPE_MEMORY_ICON, GcrMemoryIcon))
-#define GCR_MEMORY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCR_TYPE_MEMORY_ICON, GcrMemoryIconClass))
-#define GCR_IS_MEMORY_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCR_TYPE_MEMORY_ICON))
-#define GCR_IS_MEMORY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCR_TYPE_MEMORY_ICON))
-#define GCR_MEMORY_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCR_TYPE_MEMORY_ICON, GcrMemoryIconClass))
-
-typedef struct _GcrMemoryIcon GcrMemoryIcon;
-typedef struct _GcrMemoryIconClass GcrMemoryIconClass;
-typedef struct _GcrMemoryIconPrivate GcrMemoryIconPrivate;
-
-struct _GcrMemoryIcon {
- /*< private >*/
- GObject parent;
- GcrMemoryIconPrivate *pv;
-};
-
-struct _GcrMemoryIconClass {
- GObjectClass parent_class;
-};
-
-GType _gcr_memory_icon_get_type (void) G_GNUC_CONST;
-
-GIcon* _gcr_memory_icon_new (const gchar *image_type,
- gconstpointer data,
- gsize n_data);
-
-GIcon* _gcr_memory_icon_new_full (const gchar *image_type,
- gpointer data,
- gsize n_data,
- goffset offset,
- GDestroyNotify destroy);
-
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (GcrMemoryIcon, g_object_unref)
-
-G_END_DECLS
-
-#endif /* __GCR_MEMORY_ICON_H__ */
diff --git a/gcr/gcr-pkcs11-importer.c b/gcr/gcr-pkcs11-importer.c
index 8f65f35..e65e95f 100644
--- a/gcr/gcr-pkcs11-importer.c
+++ b/gcr/gcr-pkcs11-importer.c
@@ -23,7 +23,6 @@
#include "config.h"
#include "gcr-fingerprint.h"
-#include "gcr-icons.h"
#include "gcr-internal.h"
#include "gcr-library.h"
#include "gcr-import-interaction.h"
@@ -42,7 +41,6 @@
enum {
PROP_0,
PROP_LABEL,
- PROP_ICON,
PROP_INTERACTION,
PROP_SLOT,
PROP_IMPORTED,
@@ -605,21 +603,6 @@ calculate_label (GcrPkcs11Importer *self)
return result;
}
-static GIcon *
-calculate_icon (GcrPkcs11Importer *self,
- GckTokenInfo *token_info)
-{
- GckTokenInfo *info = NULL;
- GIcon *result;
-
- if (token_info == NULL)
- info = token_info = gck_slot_get_token_info (self->slot);
- result = gcr_icon_for_token (token_info);
- gck_token_info_free (info);
-
- return result;
-}
-
static gchar *
calculate_uri (GcrPkcs11Importer *self)
{
@@ -647,9 +630,6 @@ _gcr_pkcs11_importer_get_property (GObject *obj,
case PROP_LABEL:
g_value_take_string (value, calculate_label (self));
break;
- case PROP_ICON:
- g_value_take_object (value, calculate_icon (self, NULL));
- break;
case PROP_SLOT:
g_value_set_object (value, _gcr_pkcs11_importer_get_slot (self));
break;
@@ -683,7 +663,6 @@ _gcr_pkcs11_importer_class_init (GcrPkcs11ImporterClass *klass)
gobject_class->get_property = _gcr_pkcs11_importer_get_property;
g_object_class_override_property (gobject_class, PROP_LABEL, "label");
- g_object_class_override_property (gobject_class, PROP_ICON, "icon");
g_object_class_override_property (gobject_class, PROP_INTERACTION, "interaction");
g_object_class_override_property (gobject_class, PROP_URI, "uri");
diff --git a/gcr/gcr.h b/gcr/gcr.h
index aaa2982..7135e81 100644
--- a/gcr/gcr.h
+++ b/gcr/gcr.h
@@ -38,7 +38,6 @@
#include <gcr/gcr-column.h>
#include <gcr/gcr-enum-types.h>
#include <gcr/gcr-fingerprint.h>
-#include <gcr/gcr-icons.h>
#include <gcr/gcr-importer.h>
#include <gcr/gcr-library.h>
#include <gcr/gcr-mock-prompter.h>
diff --git a/gcr/meson.build b/gcr/meson.build
index 5a9ba05..9fbd67c 100644
--- a/gcr/meson.build
+++ b/gcr/meson.build
@@ -7,7 +7,6 @@ gcr_public_sources = files(
'gcr-certificate-request.c',
'gcr-comparable.c',
'gcr-fingerprint.c',
- 'gcr-icons.c',
'gcr-importer.c',
'gcr-import-interaction.c',
'gcr-library.c',
@@ -34,7 +33,6 @@ gcr_private_sources = files(
'gcr-gnupg-records.c',
'gcr-gnupg-util.c',
'gcr-key-mechanisms.c',
- 'gcr-memory-icon.c',
'gcr-openpgp.c',
'gcr-openssh.c',
'gcr-pkcs11-importer.c',
@@ -51,7 +49,6 @@ gcr_headers = files(
'gcr-column.h',
'gcr-comparable.h',
'gcr-fingerprint.h',
- 'gcr-icons.h',
'gcr-importer.h',
'gcr-import-interaction.h',
'gcr-library.h',
@@ -314,7 +311,6 @@ gcr_test_names = [
'trust',
'parser',
'record',
- 'memory-icon',
'gnupg-key',
'gnupg-process',
'system-prompt',
diff --git a/gcr/test-memory-icon.c b/gcr/test-memory-icon.c
deleted file mode 100644
index 283dcd9..0000000
--- a/gcr/test-memory-icon.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/*
- Copyright (C) 2011 Collabora Ltd
-
- The Gnome Keyring Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Keyring 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- see <http://www.gnu.org/licenses/>.
-
- Author: Stef Walter <stefw@collabora.co.uk>
-*/
-
-#include "config.h"
-
-#include "gcr/gcr-memory-icon.h"
-
-#include "egg/egg-testing.h"
-
-#include <glib.h>
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-typedef struct {
- GIcon *icon;
- GAsyncResult *result;
-} Test;
-
-static const guint8 test_data[256] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
- 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
- 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
- 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
- 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
- 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
- 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
- 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
- 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
- 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
-};
-
-static void
-setup (Test *test, gconstpointer unused)
-{
- test->icon = _gcr_memory_icon_new ("application/octet-stream",
- test_data, sizeof (test_data));
- g_object_add_weak_pointer (G_OBJECT (test->icon), (gpointer *)&test->icon);
-}
-
-static void
-teardown (Test *test, gconstpointer unused)
-{
- g_object_unref (test->icon);
-
- if (test->result) {
- g_object_unref (test->result);
- g_assert (test->result == NULL);
- }
-
- g_assert (test->icon == NULL);
-}
-
-
-static void
-test_equal_same (Test *test, gconstpointer unused)
-{
- g_assert (g_icon_equal (test->icon, test->icon) == TRUE);
-}
-
-static void
-test_equal_not (Test *test, gconstpointer unused)
-{
- GIcon *icon;
-
- icon = g_themed_icon_new ("folder");
- g_assert (g_icon_equal (test->icon, icon) == FALSE);
- g_object_unref (icon);
-}
-
-static void
-test_equal_data (Test *test, gconstpointer unused)
-{
- GIcon *icon;
-
- icon = _gcr_memory_icon_new ("application/octet-stream",
- test_data, sizeof (test_data));
- g_assert (g_icon_equal (test->icon, icon) == TRUE);
- g_assert_cmpuint (g_icon_hash (test->icon), ==, g_icon_hash (icon));
- g_object_unref (icon);
-}
-
-static void
-test_different_type (Test *test, gconstpointer unused)
-{
- GIcon *icon;
-
- icon = _gcr_memory_icon_new ("application/x-other",
- test_data, sizeof (test_data));
- g_assert (g_icon_equal (test->icon, icon) == FALSE);
- g_assert_cmpuint (g_icon_hash (test->icon), !=, g_icon_hash (icon));
- g_object_unref (icon);
-}
-
-static void
-test_different_offset (Test *test, gconstpointer unused)
-{
- GIcon *icon;
-
- icon = _gcr_memory_icon_new_full ("application/octet-stream", (gpointer)test_data,
- sizeof (test_data) - 16, 16, NULL);
- g_assert (g_icon_equal (test->icon, icon) == FALSE);
- g_assert_cmpuint (g_icon_hash (test->icon), !=, g_icon_hash (icon));
- g_object_unref (icon);
-}
-
-static void
-test_load_sync (Test *test, gconstpointer unused)
-{
- GError *error = NULL;
- GInputStream *is;
- gchar buf[1024];
- gsize length;
- gchar *type;
-
- is = g_loadable_icon_load (G_LOADABLE_ICON (test->icon), 0, &type, NULL, &error);
- g_assert (is != NULL);
- g_assert_no_error (error);
- g_assert_cmpstr (type, ==, "application/octet-stream");
-
- if (!g_input_stream_read_all (is, buf, sizeof (buf), &length, NULL, &error))
- g_assert_not_reached ();
- g_assert_no_error (error);
- egg_assert_cmpsize (length, ==, sizeof (test_data));
- egg_assert_cmpmem (buf, length, ==, test_data, sizeof (test_data));
-
- g_free (type);
- g_object_unref (is);
-}
-
-static void
-on_async_ready (GObject *source, GAsyncResult *result, gpointer user_data)
-{
- Test *test = user_data;
- GObject *result_source;
-
- g_assert (G_OBJECT (test->icon) == source);
- g_assert (test->result == NULL);
-
- result_source = g_async_result_get_source_object (result);
- g_assert (result_source == source);
- g_object_unref (result_source);
-
- test->result = g_object_ref (result);
- g_object_add_weak_pointer (G_OBJECT (test->result), (gpointer *)&test->result);
- egg_test_wait_stop ();
-}
-
-static void
-test_load_async (Test *test, gconstpointer unused)
-{
- GError *error = NULL;
- GInputStream *is;
- gchar buf[1024];
- gsize length;
- gchar *type;
-
- g_loadable_icon_load_async (G_LOADABLE_ICON (test->icon), 0, NULL, on_async_ready, test);
- egg_test_wait_until (500);
-
- g_assert (test->result);
- is = g_loadable_icon_load_finish (G_LOADABLE_ICON (test->icon), test->result, &type, &error);
- g_assert (is != NULL);
- g_assert_no_error (error);
- g_assert_cmpstr (type, ==, "application/octet-stream");
- g_object_add_weak_pointer (G_OBJECT (is), (gpointer *)&is);
-
- if (!g_input_stream_read_all (is, buf, sizeof (buf), &length, NULL, &error))
- g_assert_not_reached ();
- g_assert_no_error (error);
- egg_assert_cmpsize (length, ==, sizeof (test_data));
- egg_assert_cmpmem (buf, length, ==, test_data, sizeof (test_data));
-
- g_free (type);
- g_object_unref (is);
- g_assert (is == NULL);
-}
-
-int
-main (int argc, char **argv)
-{
- g_test_init (&argc, &argv, NULL);
-
- g_test_add ("/gcr/memory-icon/equal_same", Test, NULL, setup, test_equal_same, teardown);
- g_test_add ("/gcr/memory-icon/equal_not", Test, NULL, setup, test_equal_not, teardown);
- g_test_add ("/gcr/memory-icon/equal_data", Test, NULL, setup, test_equal_data, teardown);
- g_test_add ("/gcr/memory-icon/different_type", Test, NULL, setup, test_different_type, teardown);
- g_test_add ("/gcr/memory-icon/different_offset", Test, NULL, setup, test_different_offset, teardown);
- g_test_add ("/gcr/memory-icon/load_sync", Test, NULL, setup, test_load_sync, teardown);
- g_test_add ("/gcr/memory-icon/load_async", Test, NULL, setup, test_load_async, teardown);
-
- return egg_tests_run_with_loop ();
-}