seahorse r2280 - in trunk: gkr libseahorse pgp pkcs11 src ssh
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: seahorse r2280 - in trunk: gkr libseahorse pgp pkcs11 src ssh
- Date: Fri, 18 Jul 2008 22:05:15 +0000 (UTC)
Author: nnielsen
Date: Fri Jul 18 22:05:15 2008
New Revision: 2280
URL: http://svn.gnome.org/viewvc/seahorse?rev=2280&view=rev
Log:
berwebs.com>
* gkr/seahorse-gkeyring-item.c:
* gkr/seahorse-gkeyring-item.h:
* gkr/seahorse-gkeyring-item-properties.c:
* gkr/seahorse-gkr-commands.vala:
* libseahorse/libseahorse-c.vapi:
* libseahorse/Makefile.am:
* libseahorse/seahorse-context.c:
* libseahorse/seahorse-key.c:
* libseahorse/seahorse-key.h:
* libseahorse/seahorse-object.vala:
* libseahorse/seahorse-set-model.c: (added)
* libseahorse/seahorse-set-model.h: (added)
* libseahorse/seahorse-types.vala:
* libseahorse/seahorse-unknown-key.c:
* libseahorse/seahorse-unknown-key.h:
* libseahorse/seahorse-view.vala:
* pgp/libseahorse-pgp-c.vapi:
* pgp/Makefile.am:
* pgp/seahorse-pgp-commands.vala:
* pgp/seahorse-pgp-key.c:
* pgp/seahorse-pgp-key.h:
* pgp/seahorse-pgp-key-op.c:
* pgp/seahorse-pgp-key-properties.c:
* pgp/seahorse-pgp-source.c:
* pgp/seahorse-pgp-uid.c:
* pgp/seahorse-pgp-uid.h:
* src/seahorse-key-manager.vala:
* src/seahorse-key-manager-store.c:
* src/seahorse-key-manager-store.h:
* src/seahorse-keyserver-results.vala:
* src/seahorse-viewer.vala:
* ssh/seahorse-ssh-commands.vala:
* ssh/seahorse-ssh-key.c:
* ssh/seahorse-ssh-key.h: Add real GtkTreeModel for displaying
objects. And use real parent/child relationships for tree.
* pgp/seahorse-pgp-source.c: Preven
Added:
trunk/libseahorse/seahorse-set-model.c
trunk/libseahorse/seahorse-set-model.h
trunk/pgp/seahorse-pgp-uid.c
trunk/pgp/seahorse-pgp-uid.h
Modified:
trunk/gkr/seahorse-gkeyring-item-properties.c
trunk/gkr/seahorse-gkeyring-item.c
trunk/gkr/seahorse-gkeyring-item.h
trunk/gkr/seahorse-gkr-commands.c
trunk/gkr/seahorse-gkr-commands.vala
trunk/gkr/vala-build.stamp
trunk/libseahorse/Makefile.am
trunk/libseahorse/libseahorse-c.vapi
trunk/libseahorse/libseahorse.gidl
trunk/libseahorse/libseahorse.vapi
trunk/libseahorse/seahorse-commands.c
trunk/libseahorse/seahorse-context.c
trunk/libseahorse/seahorse-key.c
trunk/libseahorse/seahorse-key.h
trunk/libseahorse/seahorse-object.c
trunk/libseahorse/seahorse-object.h
trunk/libseahorse/seahorse-object.vala
trunk/libseahorse/seahorse-types.c
trunk/libseahorse/seahorse-types.h
trunk/libseahorse/seahorse-types.vala
trunk/libseahorse/seahorse-unknown-key.c
trunk/libseahorse/seahorse-unknown-key.h
trunk/libseahorse/seahorse-view.c
trunk/libseahorse/seahorse-view.h
trunk/libseahorse/seahorse-view.vala
trunk/libseahorse/vala-build.stamp
trunk/pgp/Makefile.am
trunk/pgp/libseahorse-pgp-c.vapi
trunk/pgp/seahorse-pgp-commands.c
trunk/pgp/seahorse-pgp-commands.vala
trunk/pgp/seahorse-pgp-key-op.c
trunk/pgp/seahorse-pgp-key-properties.c
trunk/pgp/seahorse-pgp-key.c
trunk/pgp/seahorse-pgp-key.h
trunk/pgp/seahorse-pgp-source.c
trunk/pgp/vala-build.stamp
trunk/pkcs11/ (props changed)
trunk/pkcs11/vala-build.stamp
trunk/src/seahorse-generate-select.c
trunk/src/seahorse-key-manager-store.c
trunk/src/seahorse-key-manager-store.h
trunk/src/seahorse-key-manager.c
trunk/src/seahorse-key-manager.vala
trunk/src/seahorse-keyserver-results.c
trunk/src/seahorse-keyserver-results.vala
trunk/src/seahorse-viewer.c
trunk/src/seahorse-viewer.vala
trunk/src/vala-build.stamp
trunk/ssh/seahorse-ssh-commands.c
trunk/ssh/seahorse-ssh-commands.vala
trunk/ssh/seahorse-ssh-key.c
trunk/ssh/seahorse-ssh-key.h
trunk/ssh/vala-build.stamp
Modified: trunk/gkr/seahorse-gkeyring-item-properties.c
==============================================================================
--- trunk/gkr/seahorse-gkeyring-item-properties.c (original)
+++ trunk/gkr/seahorse-gkeyring-item-properties.c Fri Jul 18 22:05:15 2008
@@ -64,6 +64,7 @@
GtkWidget *widget;
gchar *text;
const gchar *label;
+ gchar *stock_id;
gboolean network = FALSE;
key = SEAHORSE_KEY_WIDGET (swidget)->skey;
@@ -71,9 +72,11 @@
/* Image */
widget = seahorse_widget_get_widget (swidget, "key-image");
- if (widget)
- gtk_image_set_from_stock (GTK_IMAGE (widget), seahorse_key_get_stock_id (key),
- GTK_ICON_SIZE_DIALOG);
+ if (widget) {
+ stock_id = seahorse_key_get_stock_id (key);
+ gtk_image_set_from_stock (GTK_IMAGE (widget), stock_id, GTK_ICON_SIZE_DIALOG);
+ g_free (stock_id);
+ }
/* Description */
widget = seahorse_widget_get_widget (swidget, "description-field");
Modified: trunk/gkr/seahorse-gkeyring-item.c
==============================================================================
--- trunk/gkr/seahorse-gkeyring-item.c (original)
+++ trunk/gkr/seahorse-gkeyring-item.c Fri Jul 18 22:05:15 2008
@@ -378,17 +378,17 @@
switch (git->info ? gnome_keyring_item_info_get_type (git->info) : -1)
{
case GNOME_KEYRING_ITEM_GENERIC_SECRET:
- g_value_set_pointer (value, GNOME_STOCK_AUTHENTICATION);
+ g_value_set_string (value, GNOME_STOCK_AUTHENTICATION);
break;
case GNOME_KEYRING_ITEM_NETWORK_PASSWORD:
- g_value_set_pointer (value, is_network_item (git, "http") ?
+ g_value_set_string (value, is_network_item (git, "http") ?
SEAHORSE_THEMED_WEBBROWSER : GTK_STOCK_NETWORK);
break;
case GNOME_KEYRING_ITEM_NOTE:
- g_value_set_pointer (value, GNOME_STOCK_BOOK_OPEN);
+ g_value_set_string (value, GNOME_STOCK_BOOK_OPEN);
break;
default:
- g_value_set_pointer (value, GNOME_STOCK_BLANK);
+ g_value_set_string (value, GNOME_STOCK_BLANK);
break;
}
break;
@@ -520,8 +520,8 @@
0, G_MAXUINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, PROP_STOCK_ID,
- g_param_spec_pointer ("stock-id", "The stock icon", "The stock icon id",
- G_PARAM_READABLE));
+ g_param_spec_string ("stock-id", "The stock icon", "The stock icon id",
+ NULL, G_PARAM_READABLE));
}
Modified: trunk/gkr/seahorse-gkeyring-item.h
==============================================================================
--- trunk/gkr/seahorse-gkeyring-item.h (original)
+++ trunk/gkr/seahorse-gkeyring-item.h Fri Jul 18 22:05:15 2008
@@ -33,7 +33,7 @@
* trust: (SeahorseValidity) Trust for the key.
* expires: (gulong) Date this key expires or 0.
* length: (gint) The length of the key in bits.
- * stock-id: (gpointer/string) The stock icon id.
+ * stock-id: (string) The stock icon id.
*/
#ifndef __SEAHORSE_GKEYRING_ITEM_H__
Modified: trunk/gkr/seahorse-gkr-commands.c
==============================================================================
--- trunk/gkr/seahorse-gkr-commands.c (original)
+++ trunk/gkr/seahorse-gkr-commands.c Fri Jul 18 22:05:15 2008
@@ -75,7 +75,7 @@
if (num == 1) {
char* _tmp0;
_tmp0 = NULL;
- prompt = (_tmp0 = g_strdup_printf (_ ("Are you sure you want to delete the password '%s'?"), seahorse_object_get_description (((SeahorseObject*) (((SeahorseObject*) (keys->data)))))), (prompt = (g_free (prompt), NULL)), _tmp0);
+ prompt = (_tmp0 = g_strdup_printf (_ ("Are you sure you want to delete the password '%s'?"), seahorse_object_get_display_name (((SeahorseObject*) (((SeahorseObject*) (keys->data)))))), (prompt = (g_free (prompt), NULL)), _tmp0);
} else {
char* _tmp1;
_tmp1 = NULL;
Modified: trunk/gkr/seahorse-gkr-commands.vala
==============================================================================
--- trunk/gkr/seahorse-gkr-commands.vala (original)
+++ trunk/gkr/seahorse-gkr-commands.vala Fri Jul 18 22:05:15 2008
@@ -60,7 +60,7 @@
string prompt;
if (num == 1)
- prompt = _("Are you sure you want to delete the password '%s'?").printf(keys.data.description);
+ prompt = _("Are you sure you want to delete the password '%s'?").printf(keys.data.display_name);
else
prompt = _("Are you sure you want to delete %d passwords?").printf(num);
Modified: trunk/gkr/vala-build.stamp
==============================================================================
--- trunk/gkr/vala-build.stamp (original)
+++ trunk/gkr/vala-build.stamp Fri Jul 18 22:05:15 2008
@@ -1 +1 @@
-1216254164
+1216417233
Modified: trunk/libseahorse/Makefile.am
==============================================================================
--- trunk/libseahorse/Makefile.am (original)
+++ trunk/libseahorse/Makefile.am Fri Jul 18 22:05:15 2008
@@ -60,6 +60,7 @@
seahorse-context.c seahorse-context.h \
seahorse-widget.c seahorse-widget.h \
seahorse-set.c seahorse-set.h \
+ seahorse-set-model.c seahorse-set-model.h \
seahorse-key-model.c seahorse-key-model.h \
seahorse-util.c seahorse-util.h \
seahorse-validity.c seahorse-validity.h \
Modified: trunk/libseahorse/libseahorse-c.vapi
==============================================================================
--- trunk/libseahorse/libseahorse-c.vapi (original)
+++ trunk/libseahorse/libseahorse-c.vapi Fri Jul 18 22:05:15 2008
@@ -171,10 +171,10 @@
[CCode (cheader_filename = "seahorse-key-manager-store.h")]
public class KeyManagerStore : GLib.Object {
public KeyManagerStore(Set set, Gtk.TreeView view);
- public static GLib.List<weak Key> get_selected_keys (Gtk.TreeView view);
- public static void set_selected_keys (Gtk.TreeView view, GLib.List<Key> keys);
- public static weak Key? get_selected_key (Gtk.TreeView view, out uint uid);
- public static weak Key? get_key_from_path (Gtk.TreeView view, Gtk.TreePath path, out uint uid);
+ public static GLib.List<weak Object> get_selected_objects (Gtk.TreeView view);
+ public static void set_selected_objects (Gtk.TreeView view, GLib.List<Object> objects);
+ public static weak Object? get_selected_object (Gtk.TreeView view);
+ public static weak Object? get_object_from_path (Gtk.TreeView view, Gtk.TreePath path);
}
[CCode (cheader_filename = "seahorse-windows.h")]
Modified: trunk/libseahorse/libseahorse.gidl
==============================================================================
--- trunk/libseahorse/libseahorse.gidl (original)
+++ trunk/libseahorse/libseahorse.gidl Fri Jul 18 22:05:15 2008
@@ -14,6 +14,7 @@
<member name="SEAHORSE_USAGE_PUBLIC_KEY"/>
<member name="SEAHORSE_USAGE_PRIVATE_KEY"/>
<member name="SEAHORSE_USAGE_CREDENTIALS"/>
+ <member name="SEAHORSE_USAGE_IDENTITY"/>
<member name="SEAHORSE_USAGE_OTHER"/>
</enum>
<object name="Commands" parent="GLib.Object" type-name="SeahorseCommands" get-type="seahorse_commands_get_type">
@@ -72,9 +73,9 @@
<property name="flags" type="uint" readable="1"/>
<property name="source" type="Seahorse.Source*" readable="1" writable="1"/>
<property name="preferred" type="Seahorse.Object*" readable="1" writable="1"/>
- <property name="description" type="string*" readable="1"/>
+ <property name="display_name" type="string*" readable="1"/>
<property name="markup" type="string*" readable="1"/>
- <property name="stock_icon" type="string*" readable="1"/>
+ <property name="stock_id" type="string*" readable="1"/>
<property name="parent" type="Seahorse.Object*" readable="1" writable="1"/>
<signal name="changed">
<parameters>
@@ -175,13 +176,6 @@
</parameters>
<return-type type="void"/>
</method>
- <method name="get_selected_object_and_uid" symbol="seahorse_view_get_selected_object_and_uid">
- <parameters>
- <parameter name="self" type="Seahorse.View*"/>
- <parameter name="uid" type="uint" direction="out" transfer="full"/>
- </parameters>
- <return-type type="Seahorse.Object*"/>
- </method>
<property name="selected" type="Seahorse.Object*" readable="1" writable="1"/>
<property name="current_set" type="Seahorse.Set*" readable="1"/>
<property name="window" type="Gtk.Window*" readable="1"/>
Modified: trunk/libseahorse/libseahorse.vapi
==============================================================================
--- trunk/libseahorse/libseahorse.vapi (original)
+++ trunk/libseahorse/libseahorse.vapi Fri Jul 18 22:05:15 2008
@@ -17,6 +17,7 @@
PUBLIC_KEY,
PRIVATE_KEY,
CREDENTIALS,
+ IDENTITY,
OTHER
}
[CCode (cheader_filename = "seahorse-commands.h")]
@@ -46,7 +47,7 @@
protected Seahorse.Location _location;
protected Seahorse.Usage _usage;
protected uint _flags;
- public Seahorse.Context attached_to;
+ public weak Seahorse.Context attached_to;
public GLib.List<weak Seahorse.Object> get_children ();
protected void fire_changed (Seahorse.Object.Change what);
public GLib.Quark tag { get; }
@@ -56,9 +57,9 @@
public uint flags { get; }
public Seahorse.Source source { get; set; }
public Seahorse.Object preferred { get; set; }
- public abstract string# description { get; }
+ public abstract string# display_name { get; }
public abstract string# markup { get; }
- public abstract string# stock_icon { get; }
+ public abstract string# stock_id { get; }
public Seahorse.Object? parent { get; set; }
public signal void changed (Seahorse.Object.Change what);
public signal void hierarchy ();
@@ -92,7 +93,6 @@
public interface View : GLib.Object {
public abstract GLib.List<weak Seahorse.Object> get_selected_objects ();
public abstract void set_selected_objects (GLib.List<Seahorse.Object> objects);
- public abstract weak Seahorse.Object? get_selected_object_and_uid (out uint uid);
public abstract Seahorse.Object? selected { get; set; }
public abstract Seahorse.Set? current_set { get; }
public abstract Gtk.Window window { get; }
Modified: trunk/libseahorse/seahorse-commands.c
==============================================================================
--- trunk/libseahorse/seahorse-commands.c (original)
+++ trunk/libseahorse/seahorse-commands.c Fri Jul 18 22:05:15 2008
@@ -36,17 +36,33 @@
SEAHORSE_COMMANDS_COMMAND_ACTIONS,
SEAHORSE_COMMANDS_UI_DEFINITION
};
+static void seahorse_commands_real_show_properties (SeahorseCommands* self, SeahorseObject* obj);
+static void seahorse_commands_real_delete_objects (SeahorseCommands* self, GList* obj, GError** error);
static void seahorse_commands_set_view (SeahorseCommands* self, SeahorseView* value);
static gpointer seahorse_commands_parent_class = NULL;
static void seahorse_commands_dispose (GObject * obj);
+static void seahorse_commands_real_show_properties (SeahorseCommands* self, SeahorseObject* obj) {
+ g_return_if_fail (SEAHORSE_IS_COMMANDS (self));
+ g_critical ("Type `%s' does not implement abstract method `seahorse_commands_show_properties'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
+ return;
+}
+
+
void seahorse_commands_show_properties (SeahorseCommands* self, SeahorseObject* obj) {
SEAHORSE_COMMANDS_GET_CLASS (self)->show_properties (self, obj);
}
+static void seahorse_commands_real_delete_objects (SeahorseCommands* self, GList* obj, GError** error) {
+ g_return_if_fail (SEAHORSE_IS_COMMANDS (self));
+ g_critical ("Type `%s' does not implement abstract method `seahorse_commands_delete_objects'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
+ return;
+}
+
+
void seahorse_commands_delete_objects (SeahorseCommands* self, GList* obj, GError** error) {
SEAHORSE_COMMANDS_GET_CLASS (self)->delete_objects (self, obj, error);
}
@@ -65,6 +81,7 @@
_tmp2 = NULL;
_tmp1 = NULL;
self->priv->_view = (_tmp2 = (_tmp1 = value, (_tmp1 == NULL ? NULL : g_object_ref (_tmp1))), (self->priv->_view == NULL ? NULL : (self->priv->_view = (g_object_unref (self->priv->_view), NULL))), _tmp2);
+ g_object_notify (((GObject *) (self)), "view");
}
@@ -126,6 +143,8 @@
G_OBJECT_CLASS (klass)->get_property = seahorse_commands_get_property;
G_OBJECT_CLASS (klass)->set_property = seahorse_commands_set_property;
G_OBJECT_CLASS (klass)->dispose = seahorse_commands_dispose;
+ SEAHORSE_COMMANDS_CLASS (klass)->show_properties = seahorse_commands_real_show_properties;
+ SEAHORSE_COMMANDS_CLASS (klass)->delete_objects = seahorse_commands_real_delete_objects;
g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_COMMANDS_VIEW, g_param_spec_object ("view", "view", "view", SEAHORSE_TYPE_VIEW, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_COMMANDS_KTYPE, g_param_spec_uint ("ktype", "ktype", "ktype", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_COMMANDS_COMMAND_ACTIONS, g_param_spec_object ("command-actions", "command-actions", "command-actions", GTK_TYPE_ACTION_GROUP, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
Modified: trunk/libseahorse/seahorse-context.c
==============================================================================
--- trunk/libseahorse/seahorse-context.c (original)
+++ trunk/libseahorse/seahorse-context.c Fri Jul 18 22:05:15 2008
@@ -128,10 +128,10 @@
}
-static gboolean
-remove_each (gpointer object, gpointer value, gpointer user_data)
+static void
+hash_to_slist (gpointer object, gpointer value, gpointer user_data)
{
- return TRUE;
+ *((GSList**)user_data) = g_slist_prepend (*((GSList**)user_data), value);
}
/* release all references */
@@ -139,13 +139,16 @@
seahorse_context_dispose (GObject *gobject)
{
SeahorseContext *sctx;
- GSList *l;
+ GSList *objects, *l;
sctx = SEAHORSE_CONTEXT (gobject);
- /* All the objects */
- g_hash_table_foreach_remove (sctx->pv->objects_by_source, remove_each, NULL);
- g_hash_table_foreach_remove (sctx->pv->objects_by_type, remove_each, NULL);
+ /* Release all the objects */
+ objects = NULL;
+ g_hash_table_foreach (sctx->pv->objects_by_source, hash_to_slist, &objects);
+ for (l = objects; l; l = g_slist_next (l))
+ seahorse_context_remove_object (sctx, l->data);
+ g_slist_free (objects);
/* Gconf notification */
if (sctx->pv->notify_id)
Modified: trunk/libseahorse/seahorse-key.c
==============================================================================
--- trunk/libseahorse/seahorse-key.c (original)
+++ trunk/libseahorse/seahorse-key.c Fri Jul 18 22:05:15 2008
@@ -34,7 +34,9 @@
PROP_KEY_DESC,
PROP_KTYPE,
PROP_ETYPE,
- PROP_LOADED
+ PROP_LOADED,
+ PROP_MARKUP,
+ PROP_DISPLAY_NAME
};
/* Special fields */
@@ -86,6 +88,12 @@
/* Pass on to SeahorseObject */
g_object_get_property(object, "id", value);
break;
+ case PROP_MARKUP:
+ g_value_take_string (value, seahorse_key_get_name_markup (skey, 0));
+ break;
+ case PROP_DISPLAY_NAME:
+ g_value_take_string (value, seahorse_key_get_name_cn (skey, 0));
+ break;
case PROP_RAW_ID:
g_value_set_string (value, skey->rawid);
break;
@@ -151,6 +159,14 @@
g_param_spec_uint ("loaded", "Loaded Information", "Which parts of the key are loaded. See SeahorseKeyLoaded",
0, G_MAXUINT, SKEY_INFO_NONE, G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, PROP_DISPLAY_NAME,
+ g_param_spec_string ("display-name", "Key Label", "Label of this key",
+ NULL, G_PARAM_READABLE));
+
+ g_object_class_install_property (gobject_class, PROP_MARKUP,
+ g_param_spec_string ("markup", "Key Label Markup", "Markup for this key",
+ NULL, G_PARAM_READABLE));
+
/* Some special fields */
special_properties[PROP_SPECIAL_KEY_ID] = g_quark_from_static_string ("key-id");
special_properties[PROP_SPECIAL_DISPLAY_NAME] = g_quark_from_static_string ("display-name");
@@ -379,10 +395,10 @@
return length;
}
-const gchar*
+gchar*
seahorse_key_get_stock_id (SeahorseKey *skey)
{
- const gchar* stock_id;
+ gchar* stock_id;
g_object_get (skey, "stock-id", &stock_id, NULL);
return stock_id;
}
Modified: trunk/libseahorse/seahorse-key.h
==============================================================================
--- trunk/libseahorse/seahorse-key.h (original)
+++ trunk/libseahorse/seahorse-key.h Fri Jul 18 22:05:15 2008
@@ -55,7 +55,7 @@
* trust: (SeahorseValidity) Trust for the key.
* expires: (gulong) Date this key expires or 0.
* length: (guint) The length of the key in bits.
- * stock-id: (gpointer/string) The icon stock id
+ * stock-id: (string) The icon stock id
*/
#ifndef __SEAHORSE_KEY_H__
@@ -200,7 +200,7 @@
guint seahorse_key_get_length (SeahorseKey *skey);
-const gchar* seahorse_key_get_stock_id (SeahorseKey *skey);
+gchar* seahorse_key_get_stock_id (SeahorseKey *skey);
gboolean seahorse_key_lookup_property (SeahorseKey *skey,
guint uid,
Modified: trunk/libseahorse/seahorse-object.c
==============================================================================
--- trunk/libseahorse/seahorse-object.c (original)
+++ trunk/libseahorse/seahorse-object.c Fri Jul 18 22:05:15 2008
@@ -21,9 +21,9 @@
SEAHORSE_OBJECT_FLAGS,
SEAHORSE_OBJECT_SOURCE,
SEAHORSE_OBJECT_PREFERRED,
- SEAHORSE_OBJECT_DESCRIPTION,
+ SEAHORSE_OBJECT_DISPLAY_NAME,
SEAHORSE_OBJECT_MARKUP,
- SEAHORSE_OBJECT_STOCK_ICON,
+ SEAHORSE_OBJECT_STOCK_ID,
SEAHORSE_OBJECT_PARENT
};
static void seahorse_object_register_child (SeahorseObject* self, SeahorseObject* child);
@@ -97,6 +97,7 @@
g_return_if_fail (SEAHORSE_IS_OBJECT (self));
self->_location = value;
seahorse_object_fire_changed (self, SEAHORSE_OBJECT_CHANGE_LOCATION);
+ g_object_notify (((GObject *) (self)), "location");
}
@@ -127,6 +128,7 @@
if (self->priv->_source != NULL) {
g_object_add_weak_pointer (G_OBJECT (self->priv->_source), &self->priv->_source);
}
+ g_object_notify (((GObject *) (self)), "source");
}
@@ -149,12 +151,13 @@
g_object_add_weak_pointer (G_OBJECT (self->priv->_preferred), &self->priv->_preferred);
}
seahorse_object_fire_changed (self, SEAHORSE_OBJECT_CHANGE_PREFERRED);
+ g_object_notify (((GObject *) (self)), "preferred");
}
-char* seahorse_object_get_description (SeahorseObject* self) {
+char* seahorse_object_get_display_name (SeahorseObject* self) {
char* value;
- g_object_get (G_OBJECT (self), "description", &value, NULL);
+ g_object_get (G_OBJECT (self), "display-name", &value, NULL);
return value;
}
@@ -166,9 +169,9 @@
}
-char* seahorse_object_get_stock_icon (SeahorseObject* self) {
+char* seahorse_object_get_stock_id (SeahorseObject* self) {
char* value;
- g_object_get (G_OBJECT (self), "stock-icon", &value, NULL);
+ g_object_get (G_OBJECT (self), "stock-id", &value, NULL);
return value;
}
@@ -181,6 +184,10 @@
void seahorse_object_set_parent (SeahorseObject* self, SeahorseObject* value) {
g_return_if_fail (SEAHORSE_IS_OBJECT (self));
+ g_assert (self->priv->_parent != self);
+ if (value == self->priv->_parent) {
+ return;
+ }
/* Set the new parent/child relationship */
if (self->priv->_parent != NULL) {
seahorse_object_unregister_child (self->priv->_parent, self);
@@ -191,6 +198,7 @@
g_assert (self->priv->_parent == value);
/* Fire a signal to let watchers know this changed */
g_signal_emit_by_name (G_OBJECT (self), "hierarchy");
+ g_object_notify (((GObject *) (self)), "parent");
}
@@ -315,9 +323,9 @@
g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_OBJECT_FLAGS, g_param_spec_uint ("flags", "flags", "flags", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_OBJECT_SOURCE, g_param_spec_object ("source", "source", "source", SEAHORSE_TYPE_SOURCE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_OBJECT_PREFERRED, g_param_spec_object ("preferred", "preferred", "preferred", SEAHORSE_TYPE_OBJECT, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_OBJECT_DESCRIPTION, g_param_spec_string ("description", "description", "description", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_OBJECT_DISPLAY_NAME, g_param_spec_string ("display-name", "display-name", "display-name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_OBJECT_MARKUP, g_param_spec_string ("markup", "markup", "markup", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_OBJECT_STOCK_ICON, g_param_spec_string ("stock-icon", "stock-icon", "stock-icon", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_OBJECT_STOCK_ID, g_param_spec_string ("stock-id", "stock-id", "stock-id", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_OBJECT_PARENT, g_param_spec_object ("parent", "parent", "parent", SEAHORSE_TYPE_OBJECT, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
g_signal_new ("changed", SEAHORSE_TYPE_OBJECT, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__ENUM, G_TYPE_NONE, 1, SEAHORSE_OBJECT_TYPE_CHANGE);
g_signal_new ("hierarchy", SEAHORSE_TYPE_OBJECT, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
@@ -336,6 +344,8 @@
{
SeahorseObject* _tmp0;
SeahorseObject* new_parent;
+ /* Fire our destroy signal, so that any watchers can go away */
+ g_signal_emit_by_name (G_OBJECT (self), "destroy");
if (self->priv->_source != NULL) {
g_object_remove_weak_pointer (G_OBJECT (self->priv->_source), &self->priv->_source);
}
@@ -369,11 +379,8 @@
}
}
}
- /* Fire our destroy signal, so that any watchers can go away */
- g_signal_emit_by_name (G_OBJECT (self), "destroy");
(new_parent == NULL ? NULL : (new_parent = (g_object_unref (new_parent), NULL)));
}
- (self->attached_to == NULL ? NULL : (self->attached_to = (g_object_unref (self->attached_to), NULL)));
G_OBJECT_CLASS (seahorse_object_parent_class)->dispose (obj);
}
Modified: trunk/libseahorse/seahorse-object.h
==============================================================================
--- trunk/libseahorse/seahorse-object.h (original)
+++ trunk/libseahorse/seahorse-object.h Fri Jul 18 22:05:15 2008
@@ -78,9 +78,9 @@
void seahorse_object_set_source (SeahorseObject* self, SeahorseSource* value);
SeahorseObject* seahorse_object_get_preferred (SeahorseObject* self);
void seahorse_object_set_preferred (SeahorseObject* self, SeahorseObject* value);
-char* seahorse_object_get_description (SeahorseObject* self);
+char* seahorse_object_get_display_name (SeahorseObject* self);
char* seahorse_object_get_markup (SeahorseObject* self);
-char* seahorse_object_get_stock_icon (SeahorseObject* self);
+char* seahorse_object_get_stock_id (SeahorseObject* self);
SeahorseObject* seahorse_object_get_parent (SeahorseObject* self);
void seahorse_object_set_parent (SeahorseObject* self, SeahorseObject* value);
gboolean seahorse_object_predicate_match (SeahorseObjectPredicate *self, SeahorseObject* obj);
Modified: trunk/libseahorse/seahorse-object.vala
==============================================================================
--- trunk/libseahorse/seahorse-object.vala (original)
+++ trunk/libseahorse/seahorse-object.vala Fri Jul 18 22:05:15 2008
@@ -107,21 +107,25 @@
}
}
- public Context attached_to;
+ public weak Context attached_to;
public signal void changed(Change what);
public signal void hierarchy();
public signal void destroy();
- public abstract string# description { get; }
+ public abstract string# display_name { get; }
public abstract string# markup { get; }
- public abstract weak string# stock_icon { get; }
+ public abstract weak string# stock_id { get; }
public Object? parent {
get {
return _parent;
}
set {
+ assert (_parent != this);
+ if (value == _parent)
+ return;
+
/* Set the new parent/child relationship */
if(_parent != null)
_parent.unregister_child(this);
@@ -155,7 +159,10 @@
}
~Object () {
-
+
+ /* Fire our destroy signal, so that any watchers can go away */
+ this.destroy();
+
if (_source != null)
_source.remove_weak_pointer (&_source);
if (_preferred != null)
@@ -176,9 +183,6 @@
/* Fire signal to let anyone know this has moved */
child.hierarchy();
}
-
- /* Fire our destroy signal, so that any watchers can go away */
- this.destroy();
}
private void register_child(Object child)
Added: trunk/libseahorse/seahorse-set-model.c
==============================================================================
--- (empty file)
+++ trunk/libseahorse/seahorse-set-model.c Fri Jul 18 22:05:15 2008
@@ -0,0 +1,749 @@
+/*
+ * Seahorse
+ * Copyright (C) 2006 Stefan Walter
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ * You should have received a copy of the GNU 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 "seahorse-set-model.h"
+
+enum {
+ PROP_0,
+ PROP_SET
+};
+
+typedef struct _SeahorseSetModelPrivate {
+ GHashTable *object_to_node;
+ gint last_stamp;
+ GNode *root_node;
+ gchar **column_names;
+ guint n_columns;
+ GType *column_types;
+} SeahorseSetModelPrivate;
+
+static void remove_object (SeahorseSetModel *smodel, SeahorseObject *sobj);
+static GNode* add_object (SeahorseSetModel *smodel, SeahorseObject *sobj);
+static void seahorse_set_model_implement_tree_model (GtkTreeModelIface *iface);
+
+G_DEFINE_TYPE_EXTENDED (SeahorseSetModel, seahorse_set_model, G_TYPE_OBJECT, 0,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, seahorse_set_model_implement_tree_model));
+
+#define SEAHORSE_SET_MODEL_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), SEAHORSE_TYPE_SET_MODEL, SeahorseSetModelPrivate))
+
+/* -----------------------------------------------------------------------------
+ * INTERNAL
+ */
+static GNode*
+node_for_iter (SeahorseSetModelPrivate *pv, const GtkTreeIter *iter)
+{
+ GNode *node;
+
+ g_return_val_if_fail (iter, NULL);
+ g_return_val_if_fail (iter->stamp == pv->last_stamp, NULL);
+ g_assert (SEAHORSE_IS_OBJECT (iter->user_data));
+
+ node = iter->user_data2;
+ g_assert (g_hash_table_lookup (pv->object_to_node, iter->user_data) == node);
+ return node;
+}
+
+static void
+iter_for_node (SeahorseSetModelPrivate *pv, GNode *node, GtkTreeIter *iter)
+{
+ g_assert (node);
+ g_assert (SEAHORSE_IS_OBJECT (node->data));
+ g_assert (g_hash_table_lookup (pv->object_to_node, node->data) == node);
+
+ memset (iter, 0, sizeof (*iter));
+ iter->stamp = pv->last_stamp;
+ iter->user_data = node->data;
+ iter->user_data2 = node;
+}
+
+static void
+key_hierarchy (SeahorseObject *sobj, SeahorseSetModel *smodel)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (smodel);
+
+ g_return_if_fail (SEAHORSE_SET_MODEL (smodel));
+ g_return_if_fail (SEAHORSE_IS_OBJECT (sobj));
+ g_return_if_fail (g_hash_table_lookup (pv->object_to_node, sobj) != NULL);
+
+ remove_object (smodel, sobj);
+ add_object (smodel, sobj);
+}
+
+static GNode*
+add_object (SeahorseSetModel *smodel, SeahorseObject *sobj)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (smodel);
+ SeahorseObject *parent_obj;
+ GNode *parent_node, *node;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GList *children, *l;
+ gboolean had;
+
+ g_assert (g_hash_table_lookup (pv->object_to_node, sobj) == NULL);
+
+ /* Find the parent of this object */
+ parent_obj = seahorse_object_get_parent (sobj);
+ g_return_val_if_fail (parent_obj != sobj, NULL);
+
+ /* A root node */
+ if (parent_obj == NULL) {
+ parent_node = pv->root_node;
+ } else {
+ /* Do we have the parent of this node? */
+ parent_node = g_hash_table_lookup (pv->object_to_node, parent_obj);
+
+ /* If not, we add it */
+ if (!parent_node)
+ parent_node = add_object (smodel, parent_obj);
+ }
+
+ /* Now that we have a parent, add this node */
+ g_return_val_if_fail (parent_node, NULL);
+ had = parent_node->children ? TRUE : FALSE;
+ node = g_node_append_data (parent_node, sobj);
+ g_hash_table_insert (pv->object_to_node, sobj, node);
+ g_signal_connect (sobj, "hierarchy", G_CALLBACK (key_hierarchy), smodel);
+
+ pv->last_stamp++;
+
+ /* Fire signal for this added row */
+ iter_for_node (pv, node, &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (smodel), &iter);
+ g_return_val_if_fail (path, NULL);
+ gtk_tree_model_row_inserted (GTK_TREE_MODEL (smodel), path, &iter);
+ pv->last_stamp++;
+ gtk_tree_path_free (path);
+
+ /* The first row was added, fire signal on parent */
+ if (!had && parent_node != pv->root_node) {
+ iter_for_node (pv, parent_node, &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (smodel), &iter);
+ g_return_val_if_fail (path, NULL);
+ gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (smodel), path, &iter);
+ pv->last_stamp++;
+ gtk_tree_path_free (path);
+ }
+
+ /* Now if this object is in the set, and has children, add each child */
+ if (seahorse_set_has_object (smodel->set, sobj)) {
+ children = seahorse_object_get_children (sobj);
+ for (l = children; l; l = g_list_next (l)) {
+ if (!g_hash_table_lookup (pv->object_to_node, l->data))
+ add_object (smodel, l->data);
+ }
+ }
+
+ return node;
+}
+
+static gboolean
+remove_each_object (GNode *node, SeahorseSetModel *smodel)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (smodel);
+ GNode *parent_node;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+
+ /* This happens during dispose */
+ if (node == pv->root_node)
+ return FALSE;
+
+ g_assert (SEAHORSE_IS_OBJECT (node->data));
+ g_assert (g_hash_table_lookup (pv->object_to_node, node->data) == node);
+
+ /* Create the path for firing the event */
+ iter_for_node (pv, node, &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (smodel), &iter);
+ g_return_val_if_fail (path, TRUE);
+
+ /* Remove the actual node */
+ parent_node = node->parent;
+ g_hash_table_remove (pv->object_to_node, node->data);
+ g_signal_handlers_disconnect_by_func (node->data, key_hierarchy, smodel);
+ g_node_destroy (node);
+
+ /* Fire signal for this removed row */
+ gtk_tree_model_row_deleted (GTK_TREE_MODEL (smodel), path);
+ pv->last_stamp++;
+ gtk_tree_path_free (path);
+
+ /* If this is the last child, then fire toggled */
+ if (!parent_node->children && parent_node != pv->root_node) {
+ iter_for_node (pv, parent_node, &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (smodel), &iter);
+ g_return_val_if_fail (path, TRUE);
+ gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (smodel), path, &iter);
+ pv->last_stamp++;
+ gtk_tree_path_free (path);
+ }
+
+ return FALSE;
+}
+
+static void
+remove_object (SeahorseSetModel *smodel, SeahorseObject *sobj)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (smodel);
+ GNode *node;
+ SeahorseObject *parent_obj;
+
+ node = g_hash_table_lookup (pv->object_to_node, sobj);
+ g_assert (node);
+ g_assert (node != pv->root_node);
+ g_assert (node->data == sobj);
+
+ /* Remove this object and any children */
+ g_node_traverse (node, G_POST_ORDER, G_TRAVERSE_ALL, -1,
+ (GNodeTraverseFunc)remove_each_object, smodel);
+
+ /*
+ * Now check if the parent of this object is actually in the set, or was
+ * just added for the sake of holding the child (see add_object above)
+ */
+ parent_obj = seahorse_object_get_parent (sobj);
+ if (parent_obj && !seahorse_set_has_object (smodel->set, parent_obj))
+ remove_object (smodel, sobj);
+}
+
+static void
+set_added (SeahorseSet *set, SeahorseObject *sobj, SeahorseSetModel *smodel)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (smodel);
+
+ g_return_if_fail (SEAHORSE_SET_MODEL (smodel));
+ g_return_if_fail (SEAHORSE_IS_OBJECT (sobj));
+
+ /* We may have added this as a parent */
+ if (g_hash_table_lookup (pv->object_to_node, sobj))
+ return;
+ /* Add a node to the table, plus all parents */
+ add_object (smodel, sobj);
+}
+
+static void
+set_removed (SeahorseSet *set, SeahorseObject *sobj, gpointer closure,
+ SeahorseSetModel *smodel)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (smodel);
+
+ g_return_if_fail (SEAHORSE_SET_MODEL (smodel));
+ g_return_if_fail (SEAHORSE_IS_OBJECT (sobj));
+
+ /* This should always already be added */
+ g_return_if_fail (g_hash_table_lookup (pv->object_to_node, sobj) != NULL);
+ remove_object (smodel, sobj);
+}
+
+static void
+set_changed (SeahorseSet *set, SeahorseObject *sobj, SeahorseObjectChange change,
+ gpointer closure, SeahorseSetModel *smodel)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (smodel);
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GNode *node;
+
+ g_return_if_fail (SEAHORSE_SET_MODEL (smodel));
+
+ node = g_hash_table_lookup (pv->object_to_node, sobj);
+ g_return_if_fail (node != NULL);
+
+ memset (&iter, 0, sizeof (iter));
+ iter_for_node (pv, node, &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (smodel), &iter);
+ g_return_if_fail (path);
+ gtk_tree_model_row_changed (GTK_TREE_MODEL (smodel), path, &iter);
+ pv->last_stamp++;
+ gtk_tree_path_free (path);
+}
+
+static void
+populate_model (SeahorseSetModel *smodel)
+{
+ GList *objects, *l;
+ objects = seahorse_set_get_objects (smodel->set);
+ for (l = objects; l; l = g_list_next (l))
+ set_added (smodel->set, SEAHORSE_OBJECT (l->data), smodel);
+}
+
+/* -----------------------------------------------------------------------------
+ * OBJECT
+ */
+
+static GtkTreeModelFlags
+seahorse_set_model_get_flags (GtkTreeModel *tree_model)
+{
+ /* TODO: Maybe we can eventually GTK_TREE_MODEL_ITERS_PERSIST */
+ return 0;
+}
+
+static gint
+seahorse_set_model_get_n_columns (GtkTreeModel *tree_model)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (tree_model);
+ g_return_val_if_fail (SEAHORSE_SET_MODEL (tree_model), 0);
+ return pv->n_columns;
+}
+
+static GType
+seahorse_set_model_get_column_type (GtkTreeModel *tree_model, gint index)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (tree_model);
+ g_return_val_if_fail (SEAHORSE_SET_MODEL (tree_model), 0);
+ g_return_val_if_fail (index >= 0 && index < pv->n_columns, 0);
+ return pv->column_types[index];
+}
+
+static gboolean
+seahorse_set_model_get_iter (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (tree_model);
+ gint i, count;
+ gint *indices;
+ GNode *node;
+
+ g_return_val_if_fail (SEAHORSE_SET_MODEL (tree_model), FALSE);
+
+ node = pv->root_node;
+ g_assert (node);
+
+ count = gtk_tree_path_get_depth (path);
+ g_return_val_if_fail (count > 0, FALSE);
+ indices = gtk_tree_path_get_indices (path);
+
+ for (i = 0; i < count; ++i) {
+ node = g_node_nth_child (node, indices[i]);
+ if (!node)
+ return FALSE;
+ }
+
+ iter_for_node (pv, node, iter);
+ return TRUE;
+}
+
+static GtkTreePath*
+seahorse_set_model_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (tree_model);
+ GtkTreePath *path;
+ GNode *node;
+ gint index;
+
+ g_return_val_if_fail (SEAHORSE_SET_MODEL (tree_model), NULL);
+ node = node_for_iter (pv, iter);
+ g_return_val_if_fail (node != NULL, NULL);
+ path = gtk_tree_path_new ();
+ for (;;) {
+ if (!node->parent)
+ break;
+ index = g_node_child_position (node->parent, node);
+ g_assert (index >= 0);
+ gtk_tree_path_prepend_index (path, index);
+ node = node->parent;
+ }
+
+ return path;
+}
+
+static void
+seahorse_set_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter,
+ gint column, GValue *value)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (tree_model);
+ SeahorseObject *sobj;
+ const gchar *property;
+ GParamSpec *spec;
+ GType type;
+
+ g_return_if_fail (SEAHORSE_SET_MODEL (tree_model));
+ sobj = seahorse_set_model_object_for_iter (SEAHORSE_SET_MODEL (tree_model), iter);
+ g_return_if_fail (SEAHORSE_IS_OBJECT (sobj));
+ g_return_if_fail (column >= 0 && column < pv->n_columns);
+
+ /* Figure out which property */
+ type = pv->column_types[column];
+ property = pv->column_names[column];
+ g_assert (property);
+ g_value_init (value, type);
+
+ /* Lookup the property on the object */
+ spec = g_object_class_find_property (G_OBJECT_GET_CLASS (sobj), property);
+ if (spec) {
+ if (spec->value_type != type) {
+ g_value_set_string (value, "");
+ g_warning ("%s property of %s class was of type %s instead of type %s",
+ property, G_OBJECT_TYPE_NAME (sobj),
+ g_type_name (spec->value_type), g_type_name (type));
+ return;
+ }
+
+ g_object_get_property (G_OBJECT (sobj), property, value);
+
+ } else if (type == G_TYPE_STRING) {
+
+ /* All the number types have sane defaults */
+ g_value_set_string (value, "");
+ }
+}
+
+static gboolean
+seahorse_set_model_iter_next (GtkTreeModel *tree_model, GtkTreeIter *iter)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (tree_model);
+ GNode *node;
+
+ g_return_val_if_fail (SEAHORSE_SET_MODEL (tree_model), FALSE);
+
+ node = node_for_iter (pv, iter);
+ g_return_val_if_fail (node != NULL, FALSE);
+ node = g_node_next_sibling (node);
+ if (node == NULL)
+ return FALSE;
+
+ iter_for_node (pv, node, iter);
+ return TRUE;
+}
+
+static gboolean
+seahorse_set_model_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (tree_model);
+ GNode *node;
+
+ g_return_val_if_fail (SEAHORSE_SET_MODEL (tree_model), FALSE);
+ if (parent == NULL)
+ node = pv->root_node;
+ else
+ node = node_for_iter (pv, parent);
+ g_return_val_if_fail (node != NULL, FALSE);
+ node = node->children;
+ if (node == NULL)
+ return FALSE;
+
+ iter_for_node (pv, node, iter);
+ return TRUE;
+}
+
+static gboolean
+seahorse_set_model_iter_has_child (GtkTreeModel *tree_model, GtkTreeIter *iter)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (tree_model);
+ GNode *node;
+
+ g_return_val_if_fail (SEAHORSE_SET_MODEL (tree_model), FALSE);
+ node = node_for_iter (pv, iter);
+ g_return_val_if_fail (node != NULL, FALSE);
+ return node->children != NULL ? TRUE : FALSE;
+}
+
+static gint
+seahorse_set_model_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (tree_model);
+ GNode *node;
+
+ g_return_val_if_fail (SEAHORSE_SET_MODEL (tree_model), FALSE);
+ if (iter == NULL)
+ node = pv->root_node;
+ else
+ node = node_for_iter (pv, iter);
+ g_return_val_if_fail (node != NULL, FALSE);
+ return g_node_n_children (node);
+}
+
+static gboolean
+seahorse_set_model_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter,
+ GtkTreeIter *parent, gint n)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (tree_model);
+ GNode *node;
+
+ g_return_val_if_fail (SEAHORSE_SET_MODEL (tree_model), FALSE);
+ node = node_for_iter (pv, parent);
+ g_return_val_if_fail (node != NULL, FALSE);
+ node = g_node_nth_child (node, n);
+ if (node == NULL)
+ return FALSE;
+
+ iter_for_node (pv, node, iter);
+ return TRUE;
+}
+
+static gboolean
+seahorse_set_model_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (tree_model);
+ GNode *node;
+
+ g_return_val_if_fail (SEAHORSE_SET_MODEL (tree_model), FALSE);
+
+ node = node_for_iter (pv, child);
+ g_return_val_if_fail (node != NULL, FALSE);
+ node = node->parent;
+ if (!node || G_NODE_IS_ROOT (node))
+ return FALSE;
+
+ iter_for_node (pv, node, iter);
+ return TRUE;
+}
+
+static void
+seahorse_set_model_ref_node (GtkTreeModel *tree_model, GtkTreeIter *iter)
+{
+ /* Nothing to do */
+}
+
+static void
+seahorse_set_model_unref_node (GtkTreeModel *tree_model, GtkTreeIter *iter)
+{
+ /* Nothing to do */
+}
+
+static void
+seahorse_set_model_implement_tree_model (GtkTreeModelIface *iface)
+{
+ iface->get_flags = seahorse_set_model_get_flags;
+ iface->get_n_columns = seahorse_set_model_get_n_columns;
+ iface->get_column_type = seahorse_set_model_get_column_type;
+ iface->get_iter = seahorse_set_model_get_iter;
+ iface->get_path = seahorse_set_model_get_path;
+ iface->get_value = seahorse_set_model_get_value;
+ iface->iter_next = seahorse_set_model_iter_next;
+ iface->iter_children = seahorse_set_model_iter_children;
+ iface->iter_has_child = seahorse_set_model_iter_has_child;
+ iface->iter_n_children = seahorse_set_model_iter_n_children;
+ iface->iter_nth_child = seahorse_set_model_iter_nth_child;
+ iface->iter_parent = seahorse_set_model_iter_parent;
+ iface->ref_node = seahorse_set_model_ref_node;
+ iface->unref_node = seahorse_set_model_unref_node;
+}
+
+static void
+seahorse_set_model_init (SeahorseSetModel *smodel)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (smodel);
+ pv->object_to_node = g_hash_table_new (g_direct_hash, g_direct_equal);
+ pv->root_node = g_node_new (NULL);
+ pv->column_names = NULL;
+ pv->n_columns = 0;
+ pv->column_types = NULL;
+ pv->last_stamp = 0x1000;
+}
+
+static void
+seahorse_set_model_set_property (GObject *gobject, guint prop_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ SeahorseSetModel *smodel = SEAHORSE_SET_MODEL (gobject);
+
+ switch (prop_id) {
+ case PROP_SET:
+ g_return_if_fail (smodel->set == NULL);
+ smodel->set = g_value_dup_object (value);
+ if (smodel->set) {
+ g_signal_connect_after (smodel->set, "added", G_CALLBACK (set_added), smodel);
+ g_signal_connect_after (smodel->set, "removed", G_CALLBACK (set_removed), smodel);
+ g_signal_connect_after (smodel->set, "changed", G_CALLBACK (set_changed), smodel);
+ populate_model (smodel);
+ }
+ break;
+ }
+}
+
+static void
+seahorse_set_model_get_property (GObject *gobject, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ SeahorseSetModel *smodel = SEAHORSE_SET_MODEL (gobject);
+
+ switch (prop_id) {
+ case PROP_SET:
+ g_value_set_object (value, smodel->set);
+ break;
+ }
+}
+
+static void
+seahorse_set_model_dispose (GObject *gobject)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (gobject);
+ SeahorseSetModel *smodel = SEAHORSE_SET_MODEL (gobject);
+
+ /* Remove all rows */
+ if (pv->root_node) {
+ g_node_traverse (pv->root_node, G_POST_ORDER, G_TRAVERSE_ALL, -1,
+ (GNodeTraverseFunc)remove_each_object, smodel);
+ }
+
+ /* Disconnect from the set */
+ if (smodel->set) {
+ g_signal_handlers_disconnect_by_func (smodel->set, set_added, smodel);
+ g_signal_handlers_disconnect_by_func (smodel->set, set_removed, smodel);
+ g_signal_handlers_disconnect_by_func (smodel->set, set_changed, smodel);
+ g_object_unref (smodel->set);
+ smodel->set = NULL;
+ }
+
+ G_OBJECT_CLASS (seahorse_set_model_parent_class)->dispose (gobject);
+}
+
+static void
+seahorse_set_model_finalize (GObject *gobject)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (gobject);
+ SeahorseSetModel *smodel = SEAHORSE_SET_MODEL (gobject);
+ g_assert (!smodel->set);
+
+ if (pv->object_to_node) {
+ g_assert (g_hash_table_size (pv->object_to_node) == 0);
+ g_hash_table_unref (pv->object_to_node);
+ pv->object_to_node = NULL;
+ }
+
+ if (pv->root_node) {
+ g_assert (!g_node_first_child (pv->root_node));
+ g_node_destroy (pv->root_node);
+ pv->root_node = NULL;
+ }
+
+ if (pv->column_names) {
+ g_strfreev (pv->column_names);
+ pv->column_names = NULL;
+ pv->n_columns = 0;
+ }
+
+ if (pv->column_types) {
+ g_free (pv->column_types);
+ pv->column_types = NULL;
+ }
+
+ G_OBJECT_CLASS (seahorse_set_model_parent_class)->finalize (gobject);
+}
+
+static void
+seahorse_set_model_class_init (SeahorseSetModelClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ seahorse_set_model_parent_class = g_type_class_peek_parent (klass);
+ gobject_class->dispose = seahorse_set_model_dispose;
+ gobject_class->finalize = seahorse_set_model_finalize;
+ gobject_class->set_property = seahorse_set_model_set_property;
+ gobject_class->get_property = seahorse_set_model_get_property;
+
+ g_object_class_install_property (gobject_class, PROP_SET,
+ g_param_spec_object ("set", "Object Set", "Set to get objects from",
+ SEAHORSE_TYPE_SET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_type_class_add_private (klass, sizeof (SeahorseSetModelPrivate));
+}
+
+/* -----------------------------------------------------------------------------
+ * PUBLIC
+ */
+
+SeahorseSetModel*
+seahorse_set_model_new (SeahorseSet *set, ...)
+{
+ GArray *array = g_array_new (TRUE, TRUE, sizeof (SeahorseSetModelColumn));
+ SeahorseSetModelColumn column;
+ SeahorseSetModel *smodel;
+ const gchar *arg;
+ va_list va;
+
+ va_start (va, set);
+ while ((arg = va_arg (va, const gchar*)) != NULL) {
+ column.property = arg;
+ column.type = va_arg (va, GType);
+ column.data = NULL;
+ g_array_append_val (array, column);
+ }
+ va_end (va);
+
+ smodel = seahorse_set_model_new_full (set, (SeahorseSetModelColumn*)array->data, array->len);
+ g_array_free (array, TRUE);
+ return smodel;
+}
+
+SeahorseSetModel*
+seahorse_set_model_new_full (SeahorseSet *set, const SeahorseSetModelColumn *columns, guint n_columns)
+{
+ SeahorseSetModel *smodel = g_object_new (SEAHORSE_TYPE_SET, NULL);
+ seahorse_set_model_set_columns (smodel, columns, n_columns);
+ return smodel;
+}
+
+gint
+seahorse_set_model_set_columns (SeahorseSetModel *smodel, const SeahorseSetModelColumn *columns,
+ guint n_columns)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (smodel);
+ guint i;
+
+ g_return_val_if_fail (SEAHORSE_IS_SET_MODEL (smodel), -1);
+ g_return_val_if_fail (pv->n_columns == 0, -1);
+
+ pv->column_names = g_new0 (gchar*, n_columns + 1);
+ pv->column_types = g_new0 (GType, n_columns + 1);
+ pv->n_columns = n_columns;
+
+ for (i = 0; i < n_columns; ++i) {
+ pv->column_names[i] = g_strdup (columns[i].property);
+ pv->column_types[i] = columns[i].type;
+ }
+
+ return n_columns - 1;
+}
+
+SeahorseObject*
+seahorse_set_model_object_for_iter (SeahorseSetModel *smodel, const GtkTreeIter *iter)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (smodel);
+ SeahorseObject *sobj;
+
+ g_return_val_if_fail (SEAHORSE_IS_SET_MODEL (smodel), NULL);
+ g_return_val_if_fail (iter, NULL);
+ g_return_val_if_fail (iter->stamp == pv->last_stamp, NULL);
+ g_return_val_if_fail (SEAHORSE_IS_OBJECT (iter->user_data), NULL);
+
+ sobj = SEAHORSE_OBJECT (iter->user_data);
+ g_return_val_if_fail (g_hash_table_lookup (pv->object_to_node, sobj) == iter->user_data2, NULL);
+ return sobj;
+}
+
+gboolean
+seahorse_set_model_iter_for_object (SeahorseSetModel *smodel, SeahorseObject *sobj,
+ GtkTreeIter *iter)
+{
+ SeahorseSetModelPrivate *pv = SEAHORSE_SET_MODEL_GET_PRIVATE (smodel);
+ GNode *node;
+
+ g_return_val_if_fail (SEAHORSE_IS_SET_MODEL (smodel), FALSE);
+ g_return_val_if_fail (SEAHORSE_IS_OBJECT (sobj), FALSE);
+ g_return_val_if_fail (iter, FALSE);
+
+ node = g_hash_table_lookup (pv->object_to_node, sobj);
+ if (node == NULL)
+ return FALSE;
+
+ iter_for_node (pv, node, iter);
+ return TRUE;
+}
+
Added: trunk/libseahorse/seahorse-set-model.h
==============================================================================
--- (empty file)
+++ trunk/libseahorse/seahorse-set-model.h Fri Jul 18 22:05:15 2008
@@ -0,0 +1,79 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2006 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ * You should have received a copy of the GNU 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.
+ */
+
+/**
+ * SeahorseSetModel: A GtkTreeModel which represents all objects
+ * in a SeahorseSet
+ */
+
+#ifndef __SEAHORSE_SET_MODEL_H__
+#define __SEAHORSE_SET_MODEL_H__
+
+#include <gtk/gtk.h>
+#include "seahorse-object.h"
+#include "seahorse-set.h"
+
+typedef struct _SeahorseSetModelColumn {
+ const gchar *property;
+ GType type;
+ gpointer data;
+} SeahorseSetModelColumn;
+
+#define SEAHORSE_TYPE_SET_MODEL (seahorse_set_model_get_type ())
+#define SEAHORSE_SET_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_SET_MODEL, SeahorseSetModel))
+#define SEAHORSE_SET_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_SET_MODEL, SeahorseSetModelClass))
+#define SEAHORSE_IS_SET_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_SET_MODEL))
+#define SEAHORSE_IS_SET_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_SET_MODEL))
+#define SEAHORSE_SET_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_SET_MODEL, SeahorseSetModelClass))
+
+typedef struct _SeahorseSetModel SeahorseSetModel;
+typedef struct _SeahorseSetModelClass SeahorseSetModelClass;
+
+struct _SeahorseSetModel {
+ GObject parent;
+ SeahorseSet *set;
+};
+
+struct _SeahorseSetModelClass {
+ GObjectClass parent_class;
+};
+
+GType seahorse_set_model_get_type (void);
+
+SeahorseSetModel* seahorse_set_model_new (SeahorseSet *set,
+ ...) G_GNUC_NULL_TERMINATED;
+
+SeahorseSetModel* seahorse_set_model_new_full (SeahorseSet *set,
+ const SeahorseSetModelColumn *columns,
+ guint n_columns);
+
+gint seahorse_set_model_set_columns (SeahorseSetModel *smodel,
+ const SeahorseSetModelColumn *columns,
+ guint n_columns);
+
+SeahorseObject* seahorse_set_model_object_for_iter (SeahorseSetModel *smodel,
+ const GtkTreeIter *iter);
+
+gboolean seahorse_set_model_iter_for_object (SeahorseSetModel *smodel,
+ SeahorseObject *object,
+ GtkTreeIter *iter);
+
+#endif /* __SEAHORSE_SET_H__ */
Modified: trunk/libseahorse/seahorse-types.c
==============================================================================
--- trunk/libseahorse/seahorse-types.c (original)
+++ trunk/libseahorse/seahorse-types.c Fri Jul 18 22:05:15 2008
@@ -22,7 +22,7 @@
GType seahorse_usage_get_type (void) {
static GType seahorse_usage_type_id = 0;
if (G_UNLIKELY (seahorse_usage_type_id == 0)) {
- static const GEnumValue values[] = {{SEAHORSE_USAGE_NONE, "SEAHORSE_USAGE_NONE", "none"}, {SEAHORSE_USAGE_SYMMETRIC_KEY, "SEAHORSE_USAGE_SYMMETRIC_KEY", "symmetric-key"}, {SEAHORSE_USAGE_PUBLIC_KEY, "SEAHORSE_USAGE_PUBLIC_KEY", "public-key"}, {SEAHORSE_USAGE_PRIVATE_KEY, "SEAHORSE_USAGE_PRIVATE_KEY", "private-key"}, {SEAHORSE_USAGE_CREDENTIALS, "SEAHORSE_USAGE_CREDENTIALS", "credentials"}, {SEAHORSE_USAGE_OTHER, "SEAHORSE_USAGE_OTHER", "other"}, {0, NULL, NULL}};
+ static const GEnumValue values[] = {{SEAHORSE_USAGE_NONE, "SEAHORSE_USAGE_NONE", "none"}, {SEAHORSE_USAGE_SYMMETRIC_KEY, "SEAHORSE_USAGE_SYMMETRIC_KEY", "symmetric-key"}, {SEAHORSE_USAGE_PUBLIC_KEY, "SEAHORSE_USAGE_PUBLIC_KEY", "public-key"}, {SEAHORSE_USAGE_PRIVATE_KEY, "SEAHORSE_USAGE_PRIVATE_KEY", "private-key"}, {SEAHORSE_USAGE_CREDENTIALS, "SEAHORSE_USAGE_CREDENTIALS", "credentials"}, {SEAHORSE_USAGE_IDENTITY, "SEAHORSE_USAGE_IDENTITY", "identity"}, {SEAHORSE_USAGE_OTHER, "SEAHORSE_USAGE_OTHER", "other"}, {0, NULL, NULL}};
seahorse_usage_type_id = g_enum_register_static ("SeahorseUsage", values);
}
return seahorse_usage_type_id;
Modified: trunk/libseahorse/seahorse-types.h
==============================================================================
--- trunk/libseahorse/seahorse-types.h (original)
+++ trunk/libseahorse/seahorse-types.h Fri Jul 18 22:05:15 2008
@@ -31,6 +31,7 @@
SEAHORSE_USAGE_PUBLIC_KEY = 2,
SEAHORSE_USAGE_PRIVATE_KEY = 3,
SEAHORSE_USAGE_CREDENTIALS = 4,
+ SEAHORSE_USAGE_IDENTITY = 5,
SEAHORSE_USAGE_OTHER = 10
} SeahorseUsage;
Modified: trunk/libseahorse/seahorse-types.vala
==============================================================================
--- trunk/libseahorse/seahorse-types.vala (original)
+++ trunk/libseahorse/seahorse-types.vala Fri Jul 18 22:05:15 2008
@@ -19,6 +19,7 @@
PUBLIC_KEY = 2,
PRIVATE_KEY = 3,
CREDENTIALS = 4,
+ IDENTITY = 5,
OTHER = 10
}
}
Modified: trunk/libseahorse/seahorse-unknown-key.c
==============================================================================
--- trunk/libseahorse/seahorse-unknown-key.c (original)
+++ trunk/libseahorse/seahorse-unknown-key.c Fri Jul 18 22:05:15 2008
@@ -134,8 +134,7 @@
g_value_set_ulong (value, 0);
break;
case PROP_STOCK_ID:
- /* We use a pointer so we don't copy the string every time */
- g_value_set_pointer (value, "");
+ g_value_set_string (value, "");
break;
}
}
@@ -211,8 +210,8 @@
0, G_MAXULONG, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, PROP_STOCK_ID,
- g_param_spec_pointer ("stock-id", "The stock icon", "The stock icon id",
- G_PARAM_READABLE));
+ g_param_spec_string ("stock-id", "The stock icon", "The stock icon id",
+ "", G_PARAM_READABLE));
}
Modified: trunk/libseahorse/seahorse-unknown-key.h
==============================================================================
--- trunk/libseahorse/seahorse-unknown-key.h (original)
+++ trunk/libseahorse/seahorse-unknown-key.h Fri Jul 18 22:05:15 2008
@@ -32,7 +32,7 @@
* validity: (SeahorseValidity) The key validity.
* trust: (SeahorseValidity) Trust for the key.
* expires: (gulong) Date this key expires or 0.
- * stock-id: (gpointer/string) The stock icon id.
+ * stock-id: (string) The stock icon id.
*/
#ifndef __SEAHORSE_UNKNOWN_KEY_H__
Modified: trunk/libseahorse/seahorse-view.c
==============================================================================
--- trunk/libseahorse/seahorse-view.c (original)
+++ trunk/libseahorse/seahorse-view.c Fri Jul 18 22:05:15 2008
@@ -37,11 +37,6 @@
}
-SeahorseObject* seahorse_view_get_selected_object_and_uid (SeahorseView* self, guint* uid) {
- return SEAHORSE_VIEW_GET_INTERFACE (self)->get_selected_object_and_uid (self, uid);
-}
-
-
SeahorseObject* seahorse_view_get_selected (SeahorseView* self) {
SeahorseObject* value;
g_object_get (G_OBJECT (self), "selected", &value, NULL);
Modified: trunk/libseahorse/seahorse-view.h
==============================================================================
--- trunk/libseahorse/seahorse-view.h (original)
+++ trunk/libseahorse/seahorse-view.h Fri Jul 18 22:05:15 2008
@@ -43,13 +43,11 @@
GTypeInterface parent_iface;
GList* (*get_selected_objects) (SeahorseView* self);
void (*set_selected_objects) (SeahorseView* self, GList* objects);
- SeahorseObject* (*get_selected_object_and_uid) (SeahorseView* self, guint* uid);
};
GList* seahorse_view_get_selected_objects (SeahorseView* self);
void seahorse_view_set_selected_objects (SeahorseView* self, GList* objects);
-SeahorseObject* seahorse_view_get_selected_object_and_uid (SeahorseView* self, guint* uid);
SeahorseObject* seahorse_view_get_selected (SeahorseView* self);
void seahorse_view_set_selected (SeahorseView* self, SeahorseObject* value);
SeahorseSet* seahorse_view_get_current_set (SeahorseView* self);
Modified: trunk/libseahorse/seahorse-view.vala
==============================================================================
--- trunk/libseahorse/seahorse-view.vala (original)
+++ trunk/libseahorse/seahorse-view.vala Fri Jul 18 22:05:15 2008
@@ -27,7 +27,6 @@
public abstract GLib.List<weak Object> get_selected_objects ();
public abstract void set_selected_objects (GLib.List<Object> objects);
- public abstract weak Object? get_selected_object_and_uid (out uint uid);
public abstract weak Object? selected { get; set; }
public abstract weak Set? current_set { get; }
Modified: trunk/libseahorse/vala-build.stamp
==============================================================================
--- trunk/libseahorse/vala-build.stamp (original)
+++ trunk/libseahorse/vala-build.stamp Fri Jul 18 22:05:15 2008
@@ -1 +1 @@
-1216254157
+1216417226
Modified: trunk/pgp/Makefile.am
==============================================================================
--- trunk/pgp/Makefile.am (original)
+++ trunk/pgp/Makefile.am Fri Jul 18 22:05:15 2008
@@ -80,6 +80,7 @@
seahorse-pgp-revoke.c \
seahorse-pgp-source.c seahorse-pgp-source.h \
seahorse-pgp-sign.c \
+ seahorse-pgp-uid.c seahorse-pgp-uid.h \
seahorse-signer.c seahorse-pgp-dialogs.h \
$(VALA_CFILES) $(VALA_HFILES) \
$(KEYSERVER_SRCS) \
Modified: trunk/pgp/libseahorse-pgp-c.vapi
==============================================================================
--- trunk/pgp/libseahorse-pgp-c.vapi (original)
+++ trunk/pgp/libseahorse-pgp-c.vapi Fri Jul 18 22:05:15 2008
@@ -21,12 +21,19 @@
[CCode (cprefix = "SeahorsePGP", lower_case_cprefix = "seahorse_pgp_")]
namespace Seahorse.Pgp {
+
[CCode (cheader_filename = "seahorse-pgp-dialogs.h")]
public class Sign : GLib.Object {
public static void prompt (Key key, uint uid, Gtk.Window parent);
}
[CCode (cheader_filename = "seahorse-pgp-dialogs.h")]
+ public class Delete : GLib.Object {
+ public static void show (GLib.List<Key> keys);
+ public static void userid_show (Key key, uint index);
+ }
+
+ [CCode (cheader_filename = "seahorse-pgp-dialogs.h")]
public class Generate : GLib.Object {
public static void show (Pgp.Source sksrc, Gtk.Window? parent);
}
@@ -45,5 +52,10 @@
public class Key : Seahorse.Key {
}
+
+ [CCode (cheader_filename = "seahorse-pgp-uid.h")]
+ public class Uid : Seahorse.Object {
+ public uint index { get; }
+ }
}
Modified: trunk/pgp/seahorse-pgp-commands.c
==============================================================================
--- trunk/pgp/seahorse-pgp-commands.c (original)
+++ trunk/pgp/seahorse-pgp-commands.c Fri Jul 18 22:05:15 2008
@@ -24,8 +24,7 @@
#include <seahorse-pgp-dialogs.h>
#include <seahorse-pgp-key.h>
#include <seahorse-view.h>
-#include <seahorse-util.h>
-#include <seahorse-source.h>
+#include <seahorse-pgp-uid.h>
#include <config.h>
#include <common/seahorse-registry.h>
#include "seahorse-pgp.h"
@@ -44,8 +43,8 @@
SEAHORSE_PGP_COMMANDS_UI_DEFINITION,
SEAHORSE_PGP_COMMANDS_COMMAND_ACTIONS
};
-static void seahorse_pgp_commands_real_show_properties (SeahorseCommands* base, SeahorseObject* key);
-static void seahorse_pgp_commands_real_delete_objects (SeahorseCommands* base, GList* keys, GError** error);
+static void seahorse_pgp_commands_real_show_properties (SeahorseCommands* base, SeahorseObject* obj);
+static void seahorse_pgp_commands_real_delete_objects (SeahorseCommands* base, GList* objects, GError** error);
static void seahorse_pgp_commands_on_key_sign (SeahorsePGPCommands* self, GtkAction* action);
static void seahorse_pgp_commands_on_view_selection_changed (SeahorsePGPCommands* self, SeahorseView* view);
static void _seahorse_pgp_commands_on_key_sign_gtk_action_activate (GtkAction* _sender, gpointer self);
@@ -58,60 +57,73 @@
static const char* SEAHORSE_PGP_COMMANDS_UI_DEF = "\n\t\t\t<ui>\n\t\t\t\n\t\t\t<menubar>\n\t\t\t\t<menu name='Key' action='key-menu'>\n\t\t\t\t\t<placeholder name=\"KeyCommands\">\n\t\t\t\t\t\t<menuitem action=\"key-sign\"/>\n\t\t\t\t\t</placeholder>\n\t\t\t\t</menu>\n\t\t\t</menubar>\n\t\t\t\n\t\t\t<toolbar name=\"MainToolbar\">\n\t\t\t\t<placeholder name=\"ToolItems\">\n\t\t\t\t\t<toolitem action=\"key-sign\"/>\n\t\t\t\t</placeholder>\n\t\t\t</toolbar>\n\n\t\t\t<popup name=\"KeyPopup\">\n\t\t\t\t<menuitem action=\"key-sign\"/>\n\t\t\t</popup>\n \n\t\t\t</ui>\n\t\t";
-static void seahorse_pgp_commands_real_show_properties (SeahorseCommands* base, SeahorseObject* key) {
+static void seahorse_pgp_commands_real_show_properties (SeahorseCommands* base, SeahorseObject* obj) {
SeahorsePGPCommands * self;
self = SEAHORSE_PGP_COMMANDS (base);
- g_return_if_fail (SEAHORSE_IS_OBJECT (key));
- g_return_if_fail (seahorse_object_get_tag (key) == SEAHORSE_PGP_TYPE);
- seahorse_pgp_key_properties_show (SEAHORSE_PGP_KEY (key), seahorse_view_get_window (seahorse_commands_get_view (SEAHORSE_COMMANDS (self))));
+ g_return_if_fail (SEAHORSE_IS_OBJECT (obj));
+ g_return_if_fail (seahorse_object_get_tag (obj) == SEAHORSE_PGP_TYPE);
+ if (G_TYPE_FROM_INSTANCE (G_OBJECT (obj)) == SEAHORSE_PGP_TYPE_UID) {
+ obj = seahorse_object_get_parent (obj);
+ }
+ g_return_if_fail (G_TYPE_FROM_INSTANCE (G_OBJECT (obj)) == SEAHORSE_PGP_TYPE_KEY);
+ seahorse_pgp_key_properties_show (SEAHORSE_PGP_KEY (obj), seahorse_view_get_window (seahorse_commands_get_view (SEAHORSE_COMMANDS (self))));
}
-static void seahorse_pgp_commands_real_delete_objects (SeahorseCommands* base, GList* keys, GError** error) {
+static void seahorse_pgp_commands_real_delete_objects (SeahorseCommands* base, GList* objects, GError** error) {
SeahorsePGPCommands * self;
- GError * inner_error;
guint num;
- char* prompt;
self = SEAHORSE_PGP_COMMANDS (base);
- g_return_if_fail (keys != NULL);
- inner_error = NULL;
- num = g_list_length (keys);
+ g_return_if_fail (objects != NULL);
+ num = g_list_length (objects);
if (num == 0) {
return;
}
- prompt = NULL;
- if (num == 1) {
- char* _tmp0;
- _tmp0 = NULL;
- prompt = (_tmp0 = g_strdup_printf (_ ("Are you sure you want to delete the PGP key '%s'?"), seahorse_object_get_description (((SeahorseObject*) (((SeahorseObject*) (keys->data)))))), (prompt = (g_free (prompt), NULL)), _tmp0);
- } else {
- char* _tmp1;
- _tmp1 = NULL;
- prompt = (_tmp1 = g_strdup_printf (_ ("Are you sure you want to delete %d PGP keys?"), num), (prompt = (g_free (prompt), NULL)), _tmp1);
- }
- if (seahorse_util_prompt_delete (prompt)) {
- seahorse_source_delete_objects (keys, &inner_error);
- if (inner_error != NULL) {
- g_propagate_error (error, inner_error);
- prompt = (g_free (prompt), NULL);
- return;
+ {
+ GList* obj_collection;
+ GList* obj_it;
+ obj_collection = objects;
+ for (obj_it = obj_collection; obj_it != NULL; obj_it = obj_it->next) {
+ SeahorseObject* _tmp1;
+ SeahorseObject* obj;
+ _tmp1 = NULL;
+ obj = (_tmp1 = ((SeahorseObject*) (obj_it->data)), (_tmp1 == NULL ? NULL : g_object_ref (_tmp1)));
+ {
+ /*
+ * Delete all the user ids first, if parent key is
+ * not on the chopping block already.
+ */
+ if (G_TYPE_FROM_INSTANCE (G_OBJECT (obj)) == SEAHORSE_PGP_TYPE_UID) {
+ SeahorsePGPUid* _tmp0;
+ SeahorsePGPUid* uid;
+ _tmp0 = NULL;
+ uid = (_tmp0 = SEAHORSE_PGP_UID (obj), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
+ if (g_list_find (objects, seahorse_object_get_parent (SEAHORSE_OBJECT (uid))) == NULL) {
+ seahorse_pgp_delete_userid_show (SEAHORSE_PGP_KEY (seahorse_object_get_parent (SEAHORSE_OBJECT (uid))), seahorse_pgp_uid_get_index (uid));
+ }
+ objects = g_list_remove (objects, obj);
+ (uid == NULL ? NULL : (uid = (g_object_unref (uid), NULL)));
+ } else {
+ g_return_if_fail (G_TYPE_FROM_INSTANCE (G_OBJECT (obj)) != SEAHORSE_PGP_TYPE_KEY);
+ }
+ (obj == NULL ? NULL : (obj = (g_object_unref (obj), NULL)));
+ }
}
}
- prompt = (g_free (prompt), NULL);
+ seahorse_pgp_delete_show (objects);
}
static void seahorse_pgp_commands_on_key_sign (SeahorsePGPCommands* self, GtkAction* action) {
- guint uid;
SeahorseObject* _tmp0;
SeahorseObject* key;
g_return_if_fail (SEAHORSE_PGP_IS_COMMANDS (self));
g_return_if_fail (GTK_IS_ACTION (action));
- uid = 0U;
_tmp0 = NULL;
- key = (_tmp0 = seahorse_view_get_selected_object_and_uid (seahorse_commands_get_view (SEAHORSE_COMMANDS (self)), &uid), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
+ key = (_tmp0 = seahorse_view_get_selected (seahorse_commands_get_view (SEAHORSE_COMMANDS (self))), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
+ /* TODO: Make signing a specific UID work again */
if (key != NULL && seahorse_object_get_tag (key) == SEAHORSE_PGP_TYPE) {
- seahorse_pgp_sign_prompt (SEAHORSE_PGP_KEY (key), uid, seahorse_view_get_window (seahorse_commands_get_view (SEAHORSE_COMMANDS (self))));
+ seahorse_pgp_sign_prompt (SEAHORSE_PGP_KEY (key), ((guint) (0)), seahorse_view_get_window (seahorse_commands_get_view (SEAHORSE_COMMANDS (self))));
}
(key == NULL ? NULL : (key = (g_object_unref (key), NULL)));
}
Modified: trunk/pgp/seahorse-pgp-commands.vala
==============================================================================
--- trunk/pgp/seahorse-pgp-commands.vala (original)
+++ trunk/pgp/seahorse-pgp-commands.vala Fri Jul 18 22:05:15 2008
@@ -62,31 +62,44 @@
}
}
- public override void show_properties (Object key) {
- return_if_fail (key.tag == Seahorse.Pgp.TYPE);
- KeyProperties.show ((Pgp.Key)key, view.window);
+ public override void show_properties (Object obj) {
+ return_if_fail (obj.tag == Seahorse.Pgp.TYPE);
+ if (obj.get_type() == typeof (Pgp.Uid))
+ obj = obj.parent;
+ return_if_fail (obj.get_type() == typeof (Pgp.Key));
+ KeyProperties.show ((Pgp.Key)obj, view.window);
}
- public override void delete_objects (List<Object> keys) throws GLib.Error {
- uint num = keys.length();
+ public override void delete_objects (List<Object> objects) throws GLib.Error {
+ uint num = objects.length();
if (num == 0)
return;
- string prompt;
- if (num == 1)
- prompt = _("Are you sure you want to delete the PGP key '%s'?").printf(keys.data.description);
- else
- prompt = _("Are you sure you want to delete %d PGP keys?").printf(num);
+ foreach (var obj in objects) {
+
+ /*
+ * Delete all the user ids first, if parent key is
+ * not on the chopping block already.
+ */
+
+ if (obj.get_type() == typeof (Pgp.Uid)) {
+ Pgp.Uid uid = (Pgp.Uid)obj;
+ if (objects.find(uid.parent) == null)
+ Delete.userid_show ((Pgp.Key)uid.parent, uid.index);
+ objects.remove (obj);
+ } else {
+ return_if_fail (obj.get_type() != typeof (Pgp.Key));
+ }
+ }
- if (Util.prompt_delete (prompt))
- Seahorse.Source.delete_objects (keys);
+ Delete.show(objects);
}
private void on_key_sign (Action action) {
- uint uid;
- var key = view.get_selected_object_and_uid (out uid);
+ var key = view.selected;
+ /* TODO: Make signing a specific UID work again */
if (key != null && key.tag == Seahorse.Pgp.TYPE)
- Sign.prompt ((Pgp.Key)key, uid, view.window);
+ Sign.prompt ((Pgp.Key)key, 0, view.window);
}
private void on_view_selection_changed (View view) {
Modified: trunk/pgp/seahorse-pgp-key-op.c
==============================================================================
--- trunk/pgp/seahorse-pgp-key-op.c (original)
+++ trunk/pgp/seahorse-pgp-key-op.c Fri Jul 18 22:05:15 2008
@@ -492,7 +492,7 @@
SeahorseEditParm *parms;
gpgme_error_t err;
guint real_index = seahorse_pgp_key_get_actual_uid(pkey, index);
- guint num_userids = seahorse_pgp_key_get_num_userids (pkey);
+ guint num_userids = seahorse_pgp_key_get_num_uids (pkey);
guint num_photoids = seahorse_pgp_key_get_num_photoids (pkey);
g_return_val_if_fail (SEAHORSE_IS_PGP_KEY (pkey), GPG_E (GPG_ERR_WRONG_KEY_USAGE));
@@ -1957,18 +1957,18 @@
{
PrimaryParm *pri_parm;
SeahorseEditParm *parms;
- gpgme_user_id_t uid;
+ SeahorsePGPUid *uid;
guint real_index = seahorse_pgp_key_get_actual_uid(pkey, index);
g_return_val_if_fail (SEAHORSE_IS_PGP_KEY (pkey), GPG_E (GPG_ERR_WRONG_KEY_USAGE));
/* Check index range */
- g_return_val_if_fail (real_index >= 1 && real_index <= (seahorse_pgp_key_get_num_userids (pkey) + seahorse_pgp_key_get_num_photoids(pkey)), GPG_E (GPG_ERR_INV_VALUE));
+ g_return_val_if_fail (real_index >= 1 && real_index <= (seahorse_pgp_key_get_num_uids (pkey) + seahorse_pgp_key_get_num_photoids(pkey)), GPG_E (GPG_ERR_INV_VALUE));
/* Make sure not revoked */
- uid = seahorse_pgp_key_get_nth_userid (pkey, index - 1);
- g_return_val_if_fail (uid != NULL && !uid->revoked && !uid->invalid,
- GPG_E (GPG_ERR_INV_VALUE));
+ uid = seahorse_pgp_key_get_uid (pkey, index - 1);
+ g_return_val_if_fail (uid != NULL && !uid->userid->revoked && !uid->userid->invalid,
+ GPG_E (GPG_ERR_INV_VALUE));
pri_parm = g_new0 (PrimaryParm, 1);
pri_parm->index = real_index;
@@ -2108,18 +2108,18 @@
{
DelUidParm *del_uid_parm;
SeahorseEditParm *parms;
- gpgme_user_id_t uid;
+ SeahorsePGPUid *uid;
guint real_index = seahorse_pgp_key_get_actual_uid(pkey, index);
g_return_val_if_fail (SEAHORSE_IS_KEY (pkey), GPG_E (GPG_ERR_WRONG_KEY_USAGE));
/* Check index range */
DEBUG_OPERATION(("Del UID: uid %u\n", index));
- g_return_val_if_fail (real_index >= 1 && real_index <= (seahorse_pgp_key_get_num_userids (pkey) + seahorse_pgp_key_get_num_photoids(pkey)), GPG_E (GPG_ERR_INV_VALUE));
+ g_return_val_if_fail (real_index >= 1 && real_index <= (seahorse_pgp_key_get_num_uids (pkey) + seahorse_pgp_key_get_num_photoids(pkey)), GPG_E (GPG_ERR_INV_VALUE));
/* Make sure not revoked */
- uid = seahorse_pgp_key_get_nth_userid (pkey, index - 1);
- g_return_val_if_fail (uid != NULL && !uid->revoked && !uid->invalid,
+ uid = seahorse_pgp_key_get_uid (pkey, index - 1);
+ g_return_val_if_fail (uid != NULL && !uid->userid->revoked && !uid->userid->invalid,
GPG_E (GPG_ERR_INV_VALUE));
del_uid_parm = g_new0 (DelUidParm, 1);
Modified: trunk/pgp/seahorse-pgp-key-properties.c
==============================================================================
--- trunk/pgp/seahorse-pgp-key-properties.c (original)
+++ trunk/pgp/seahorse-pgp-key-properties.c Fri Jul 18 22:05:15 2008
@@ -789,7 +789,7 @@
{
SeahorseKey *skey;
SeahorsePGPKey *pkey;
- gpgme_user_id_t uid;
+ SeahorsePGPUid *uid;
GtkWidget *widget;
GtkCellRenderer *renderer;
GtkListStore *store;
@@ -834,9 +834,10 @@
(flags & SKEY_FLAG_REVOKED) || (flags & SKEY_FLAG_DISABLED)));
/* Hide or show the uids area */
- show_glade_widget (swidget, "uids-area", seahorse_pgp_key_get_num_userids (pkey) > 1);
-
- if ((text = seahorse_pgp_key_get_userid_name (pkey, 0)) != NULL) {
+ show_glade_widget (swidget, "uids-area", seahorse_pgp_key_get_num_uids (pkey) > 1);
+ uid = seahorse_pgp_key_get_uid (pkey, 0);
+
+ if ((text = seahorse_pgp_uid_get_name (uid)) != NULL) {
widget = glade_xml_get_widget (swidget->xml, "owner-name-label");
gtk_label_set_text (GTK_LABEL (widget), text);
@@ -845,13 +846,13 @@
g_free (text);
}
- if ((text = seahorse_pgp_key_get_userid_email (pkey, 0)) != NULL) {
+ if ((text = seahorse_pgp_uid_get_email (uid)) != NULL) {
widget = glade_xml_get_widget (swidget->xml, "owner-email-label");
gtk_label_set_text (GTK_LABEL (widget), text);
g_free (text);
}
- if ((text = seahorse_pgp_key_get_userid_comment (pkey, 0)) != NULL) {
+ if ((text = seahorse_pgp_uid_get_comment (uid)) != NULL) {
widget = glade_xml_get_widget (swidget->xml, "owner-comment-label");
gtk_label_set_text (GTK_LABEL (widget), text);
g_free (text);
@@ -886,7 +887,7 @@
"markup", UID_MARKUP, NULL);
}
- for (i = 1, uid = pkey->pubkey->uids; uid; uid = uid->next, i++) {
+ for (i = 1; i <= seahorse_pgp_key_get_num_uids (pkey); i++) {
markup = seahorse_key_get_name_markup (SEAHORSE_KEY (pkey), i - 1);
@@ -1548,7 +1549,7 @@
show_glade_widget (swidget, "signatures-empty-label", FALSE);
/* Fill in trust labels with name .This only happens once, so it sits here. */
- user = seahorse_pgp_key_get_userid_name (SEAHORSE_PGP_KEY (skey), 0);
+ user = seahorse_key_get_name (skey, 0);
printf_glade_widget (swidget, "trust-marginal-check", user);
printf_glade_widget (swidget, "trust-sign-label", user);
printf_glade_widget (swidget, "trust-revoke-label", user);
Modified: trunk/pgp/seahorse-pgp-key.c
==============================================================================
--- trunk/pgp/seahorse-pgp-key.c (original)
+++ trunk/pgp/seahorse-pgp-key.c Fri Jul 18 22:05:15 2008
@@ -27,6 +27,7 @@
#include "seahorse-context.h"
#include "seahorse-source.h"
#include "seahorse-gtkstock.h"
+#include "seahorse-util.h"
#include "pgp/seahorse-gpgmex.h"
#include "pgp/seahorse-pgp-key.h"
@@ -40,8 +41,11 @@
PROP_SIMPLE_NAME,
PROP_FINGERPRINT,
PROP_VALIDITY,
+ PROP_VALIDITY_STR,
PROP_TRUST,
+ PROP_TRUST_STR,
PROP_EXPIRES,
+ PROP_EXPIRES_STR,
PROP_LENGTH,
PROP_STOCK_ID
};
@@ -110,14 +114,14 @@
static SeahorseValidity
calc_validity (SeahorsePGPKey *pkey)
{
- g_return_val_if_fail (pkey->pubkey, SEAHORSE_VALIDITY_UNKNOWN);
- g_return_val_if_fail (pkey->pubkey->uids, SEAHORSE_VALIDITY_UNKNOWN);
+ g_return_val_if_fail (pkey->pubkey, SEAHORSE_VALIDITY_UNKNOWN);
+ g_return_val_if_fail (pkey->uids, SEAHORSE_VALIDITY_UNKNOWN);
- if (pkey->pubkey->revoked)
- return SEAHORSE_VALIDITY_REVOKED;
- if (pkey->pubkey->disabled)
- return SEAHORSE_VALIDITY_DISABLED;
- return gpgmex_validity_to_seahorse (pkey->pubkey->uids->validity);
+ if (pkey->pubkey->revoked)
+ return SEAHORSE_VALIDITY_REVOKED;
+ if (pkey->pubkey->disabled)
+ return SEAHORSE_VALIDITY_DISABLED;
+ return seahorse_pgp_uid_get_validity (pkey->uids->data);
}
static SeahorseValidity
@@ -127,6 +131,62 @@
return gpgmex_validity_to_seahorse (pkey->pubkey->owner_trust);
}
+static gchar*
+calc_short_name (SeahorsePGPKey *pkey)
+{
+ SeahorsePGPUid *uid = pkey->uids->data;
+ return uid ? seahorse_pgp_uid_get_name (uid) : NULL;
+}
+
+static void
+update_uids (SeahorsePGPKey *pkey)
+{
+ gpgme_user_id_t guid;
+ SeahorsePGPUid *uid;
+ GList *l;
+ guint index = 1;
+
+ l = pkey->uids;
+ guid = pkey->pubkey ? pkey->pubkey->uids : NULL;
+
+ /* Look for out of sync or missing UIDs */
+ while (l != NULL) {
+ g_return_if_fail (SEAHORSE_IS_PGP_UID (l->data));
+ uid = SEAHORSE_PGP_UID (l->data);
+ l = g_list_next (l);
+
+ /* Remove if no uid */
+ if (!guid) {
+ pkey->uids = g_list_remove (pkey->uids, uid);
+ seahorse_object_set_parent (l->data, NULL);
+ g_object_unref (uid);
+ } else {
+ /* Bring this UID up to date */
+ g_object_set (uid, "userid", guid, "index", index, NULL);
+ ++index;
+ }
+
+ if (guid)
+ guid = guid->next;
+ }
+
+ /* Add new UIDs */
+ while (guid != NULL) {
+ uid = seahorse_pgp_uid_new (pkey->pubkey, guid);
+ g_object_set (uid, "index", index, NULL);
+ ++index;
+ pkey->uids = g_list_append (pkey->uids, uid);
+ guid = guid->next;
+ }
+
+ /* Set 'parent' on all UIDs but the first one */
+ l = pkey->uids;
+ if (l != NULL)
+ seahorse_object_set_parent (SEAHORSE_OBJECT (l->data), NULL);
+ for (l = g_list_next (l); l; l = g_list_next (l))
+ seahorse_object_set_parent (SEAHORSE_OBJECT (l->data), SEAHORSE_OBJECT (pkey));
+}
+
static void
changed_key (SeahorsePGPKey *pkey)
{
@@ -147,6 +207,9 @@
} else {
+ /* Update the sub UIDs */
+ update_uids (pkey);
+
/* The key id */
if (pkey->pubkey->subkeys) {
obj->_id = seahorse_pgp_key_get_cannonical_id (pkey->pubkey->subkeys->keyid);
@@ -226,110 +289,60 @@
static guint
seahorse_pgp_key_get_num_names (SeahorseKey *skey)
{
- SeahorsePGPKey *pkey;
- gint index = 0;
- gpgme_user_id_t uid;
-
- g_assert (SEAHORSE_IS_PGP_KEY (skey));
-
- pkey = SEAHORSE_PGP_KEY (skey);
- g_assert (pkey->pubkey != NULL);
-
- uid = pkey->pubkey->uids;
- while (uid) {
- uid = uid->next;
- index++;
- }
-
- return index;
+ SeahorsePGPKey *pkey;
+ g_return_val_if_fail (SEAHORSE_IS_PGP_KEY (skey), 0);
+ pkey = SEAHORSE_PGP_KEY (skey);
+ return g_list_length (pkey->uids);
}
static gchar*
seahorse_pgp_key_get_name (SeahorseKey *skey, guint index)
{
- SeahorsePGPKey *pkey;
- gpgme_user_id_t uid;
-
- g_assert (SEAHORSE_IS_PGP_KEY (skey));
- pkey = SEAHORSE_PGP_KEY (skey);
-
- uid = seahorse_pgp_key_get_nth_userid (pkey, index);
- return uid ? convert_string (uid->uid, FALSE) : NULL;
+ SeahorsePGPKey *pkey;
+ SeahorsePGPUid *uid;
+ g_return_val_if_fail (SEAHORSE_IS_PGP_KEY (skey), NULL);
+ pkey = SEAHORSE_PGP_KEY (skey);
+ uid = g_list_nth_data (pkey->uids, index);
+ return uid ? seahorse_pgp_uid_get_display_name (uid) : NULL;
}
static gchar*
-seahorse_pgp_key_get_name_cn (SeahorseKey *skey, guint index)
+seahorse_pgp_key_get_name_markup (SeahorseKey *skey, guint index)
{
- SeahorsePGPKey *pkey;
- gpgme_user_id_t uid;
-
- g_assert (SEAHORSE_IS_PGP_KEY (skey));
- pkey = SEAHORSE_PGP_KEY (skey);
-
- uid = seahorse_pgp_key_get_nth_userid (pkey, index);
- return uid && uid->email ? g_strdup (uid->email) : NULL;
+ SeahorsePGPKey *pkey;
+ SeahorsePGPUid *uid;
+ g_return_val_if_fail (SEAHORSE_IS_PGP_KEY (skey), NULL);
+ pkey = SEAHORSE_PGP_KEY (skey);
+ uid = g_list_nth_data (pkey->uids, index);
+ return uid ? seahorse_pgp_uid_get_markup (uid, seahorse_key_get_flags (skey)) : NULL;
}
-static gchar*
-seahorse_pgp_key_get_name_markup (SeahorseKey *skey, guint index)
+static gchar*
+seahorse_pgp_key_get_name_cn (SeahorseKey *skey, guint index)
{
- SeahorsePGPKey *pkey;
- gpgme_user_id_t uid;
- gchar *email, *name, *comment, *ret;
- gboolean strike = FALSE;
- guint flags;
-
- g_assert (SEAHORSE_IS_PGP_KEY (skey));
- pkey = SEAHORSE_PGP_KEY (skey);
-
- uid = seahorse_pgp_key_get_nth_userid (pkey, index);
- g_return_val_if_fail (uid != NULL, NULL);
-
- name = convert_string (uid->name, TRUE);
- email = convert_string (uid->email, TRUE);
- comment = convert_string (uid->comment, TRUE);
-
- flags = seahorse_key_get_flags (skey);
- if (uid->revoked || flags & CRYPTUI_FLAG_EXPIRED ||
- flags & CRYPTUI_FLAG_REVOKED || flags & CRYPTUI_FLAG_DISABLED)
- strike = TRUE;
-
- ret = g_strconcat (strike ? "<span strikethrough='true'>" : "",
- name,
- "<span foreground='#555555' size='small' rise='0'>",
- email && email[0] ? " " : "",
- email && email[0] ? email : "",
- comment && comment[0] ? " '" : "",
- comment && comment[0] ? comment : "",
- comment && comment[0] ? "'" : "",
- "</span>",
- strike ? "</span>" : "",
- NULL);
-
- g_free (name);
- g_free (comment);
- g_free (email);
-
- return ret;
+ SeahorsePGPKey *pkey;
+ SeahorsePGPUid *uid;
+ g_return_val_if_fail (SEAHORSE_IS_PGP_KEY (skey), NULL);
+ pkey = SEAHORSE_PGP_KEY (skey);
+ uid = g_list_nth_data (pkey->uids, index);
+ return uid ? seahorse_pgp_uid_get_email (uid) : NULL;
}
static SeahorseValidity
seahorse_pgp_key_get_name_validity (SeahorseKey *skey, guint index)
{
- SeahorsePGPKey *pkey;
- gpgme_user_id_t uid;
-
- g_assert (SEAHORSE_IS_PGP_KEY (skey));
- pkey = SEAHORSE_PGP_KEY (skey);
- g_return_val_if_fail (pkey->pubkey, SEAHORSE_VALIDITY_UNKNOWN);
-
- if (pkey->pubkey->revoked)
- return SEAHORSE_VALIDITY_REVOKED;
- if (pkey->pubkey->disabled)
- return SEAHORSE_VALIDITY_DISABLED;
+ SeahorsePGPKey *pkey;
+ SeahorsePGPUid *uid;
+ g_return_val_if_fail (SEAHORSE_IS_PGP_KEY (skey), SEAHORSE_VALIDITY_UNKNOWN);
+ pkey = SEAHORSE_PGP_KEY (skey);
+ uid = g_list_nth_data (pkey->uids, index);
+
+ if (pkey->pubkey->revoked)
+ return SEAHORSE_VALIDITY_REVOKED;
+ if (pkey->pubkey->disabled)
+ return SEAHORSE_VALIDITY_DISABLED;
- uid = seahorse_pgp_key_get_nth_userid (pkey, index);
- return uid ? gpgmex_validity_to_seahorse (uid->validity) : SEAHORSE_VALIDITY_UNKNOWN;
+ return uid ? seahorse_pgp_uid_get_validity (uid) : SEAHORSE_VALIDITY_UNKNOWN;
}
static void
@@ -338,6 +351,7 @@
{
SeahorsePGPKey *pkey = SEAHORSE_PGP_KEY (object);
SeahorseKey *skey = SEAHORSE_KEY (object);
+ gchar *expires;
switch (prop_id) {
case PROP_PUBKEY:
@@ -353,7 +367,7 @@
g_value_set_string (value, seahorse_key_get_short_keyid (SEAHORSE_KEY (pkey)));
break;
case PROP_SIMPLE_NAME:
- g_value_take_string (value, seahorse_pgp_key_get_userid_name (pkey, 0));
+ g_value_take_string (value, calc_short_name(pkey));
break;
case PROP_FINGERPRINT:
g_value_take_string (value, calc_fingerprint(pkey));
@@ -361,20 +375,36 @@
case PROP_VALIDITY:
g_value_set_uint (value, calc_validity (pkey));
break;
+ case PROP_VALIDITY_STR:
+ g_value_set_string (value, seahorse_validity_get_string (calc_validity (pkey)));
+ break;
case PROP_TRUST:
g_value_set_uint (value, calc_trust (pkey));
break;
+ case PROP_TRUST_STR:
+ g_value_set_string (value, seahorse_validity_get_string (calc_trust (pkey)));
+ break;
case PROP_EXPIRES:
if (pkey->pubkey)
g_value_set_ulong (value, pkey->pubkey->subkeys->expires);
break;
+ case PROP_EXPIRES_STR:
+ if (seahorse_key_get_flags (skey) & SKEY_FLAG_EXPIRED) {
+ expires = g_strdup (_("Expired"));
+ } else {
+ if (pkey->pubkey->subkeys->expires == 0)
+ expires = g_strdup ("");
+ else
+ expires = seahorse_util_get_date_string (pkey->pubkey->subkeys->expires);
+ }
+ g_value_take_string (value, expires);
+ break;
case PROP_LENGTH:
if (pkey->pubkey)
g_value_set_uint (value, pkey->pubkey->subkeys->length);
break;
case PROP_STOCK_ID:
- /* We use a pointer so we don't copy the string every time */
- g_value_set_pointer (value,
+ g_value_set_string (value,
SEAHORSE_OBJECT (skey)->_usage == SEAHORSE_USAGE_PRIVATE_KEY ? SEAHORSE_STOCK_SECRET : SEAHORSE_STOCK_KEY);
break;
}
@@ -407,9 +437,29 @@
}
static void
+seahorse_pgp_key_object_dispose (GObject *gobject)
+{
+ SeahorsePGPKey *pkey = SEAHORSE_PGP_KEY (gobject);
+ GList *l;
+
+ /* Free all the attached UIDs */
+ for (l = pkey->uids; l; l = g_list_next (l)) {
+ seahorse_object_set_parent (l->data, NULL);
+ g_object_unref (l->data);
+ }
+
+ g_list_free (pkey->uids);
+ pkey->uids = NULL;
+
+ G_OBJECT_CLASS (seahorse_pgp_key_parent_class)->dispose (gobject);
+}
+
+static void
seahorse_pgp_key_object_finalize (GObject *gobject)
{
SeahorsePGPKey *skey = SEAHORSE_PGP_KEY (gobject);
+
+ g_assert (skey->uids == NULL);
if (skey->pubkey)
gpgmex_key_unref (skey->pubkey);
@@ -433,6 +483,7 @@
seahorse_pgp_key_parent_class = g_type_class_peek_parent (klass);
gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->dispose = seahorse_pgp_key_object_dispose;
gobject_class->finalize = seahorse_pgp_key_object_finalize;
gobject_class->set_property = seahorse_pgp_key_set_property;
gobject_class->get_property = seahorse_pgp_key_get_property;
@@ -473,21 +524,33 @@
g_param_spec_uint ("validity", "Validity", "Validity of this key",
0, G_MAXUINT, 0, G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, PROP_VALIDITY_STR,
+ g_param_spec_string ("validity-str", "Validity String", "Validity of this key as a string",
+ "", G_PARAM_READABLE));
+
g_object_class_install_property (gobject_class, PROP_TRUST,
g_param_spec_uint ("trust", "Trust", "Trust in this key",
0, G_MAXUINT, 0, G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, PROP_TRUST_STR,
+ g_param_spec_string ("trust-str", "Trust String", "Trust in this key as a string",
+ "", G_PARAM_READABLE));
+
g_object_class_install_property (gobject_class, PROP_EXPIRES,
g_param_spec_ulong ("expires", "Expires On", "Date this key expires on",
0, G_MAXULONG, 0, G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, PROP_EXPIRES_STR,
+ g_param_spec_string ("expires-str", "Expires String", "Readable expiry date",
+ "", G_PARAM_READABLE));
+
g_object_class_install_property (gobject_class, PROP_LENGTH,
g_param_spec_uint ("length", "Length", "The length of this key.",
0, G_MAXUINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, PROP_STOCK_ID,
- g_param_spec_pointer ("stock-id", "The stock icon", "The stock icon id",
- G_PARAM_READABLE));
+ g_param_spec_string ("stock-id", "The stock icon", "The stock icon id",
+ NULL, G_PARAM_READABLE));
}
@@ -566,117 +629,20 @@
return subkey;
}
-/**
- * seahorse_key_get_userid:
- * @skey: #SeahorseKey
- * @index: Which user ID
- *
- * Gets the formatted user ID of @skey at @index.
- *
- * Returns: UTF8 valid name of @skey at @index,
- * or NULL if @index is out of bounds.
- **/
-gchar*
-seahorse_pgp_key_get_userid (SeahorsePGPKey *pkey, guint index)
-{
- gpgme_user_id_t uid = seahorse_pgp_key_get_nth_userid (pkey, index);
- return uid ? convert_string (uid->uid, FALSE) : NULL;
-}
-
-/**
- * seahorse_key_get_userid_name:
- * @skey: #SeahorseKey
- * @index: Which user ID
- *
- * Gets the formatted user ID name of @skey at @index.
- *
- * Returns: UTF8 valid name of @skey at @index,
- * or NULL if @index is out of bounds.
- **/
-gchar*
-seahorse_pgp_key_get_userid_name (SeahorsePGPKey *pkey, guint index)
-{
- gpgme_user_id_t uid = seahorse_pgp_key_get_nth_userid (pkey, index);
- return uid ? convert_string (uid->name, FALSE) : NULL;
-}
-
-/**
- * seahorse_key_get_userid_email:
- * @skey: #SeahorseKey
- * @index: Which user ID
- *
- * Gets the formatted email of @skey at @index.
- *
- * Returns: UTF8 valid email of @skey at @index,
- * or NULL if @index is out of bounds.
- **/
-gchar*
-seahorse_pgp_key_get_userid_email (SeahorsePGPKey *pkey, guint index)
-{
- gpgme_user_id_t uid = seahorse_pgp_key_get_nth_userid (pkey, index);
- return uid ? convert_string (uid->email, FALSE) : NULL;
-}
-
-/**
- * seahorse_key_get_userid_comment:
- * @skey: #SeahorseKey
- * @index: Which user ID
- *
- * Gets the formatted comment of @skey at @index.
- *
- * Returns: UTF8 valid comment of @skey at @index,
- * or NULL if @index is out of bounds.
- **/
-gchar*
-seahorse_pgp_key_get_userid_comment (SeahorsePGPKey *pkey, guint index)
+SeahorsePGPUid*
+seahorse_pgp_key_get_uid (SeahorsePGPKey *pkey, guint index)
{
- gpgme_user_id_t uid = seahorse_pgp_key_get_nth_userid (pkey, index);
- return uid ? convert_string (uid->comment, FALSE) : NULL;
+ g_return_val_if_fail (SEAHORSE_IS_PGP_KEY (pkey), NULL);
+ return g_list_nth_data (pkey->uids, index);
}
guint
-seahorse_pgp_key_get_num_userids (SeahorsePGPKey *pkey)
+seahorse_pgp_key_get_num_uids (SeahorsePGPKey *pkey)
{
- gint index = 0;
- gpgme_user_id_t uid;
-
- g_return_val_if_fail (SEAHORSE_IS_PGP_KEY (pkey), 0);
- g_return_val_if_fail (pkey->pubkey != NULL, 0);
-
- uid = pkey->pubkey->uids;
- while (uid) {
- uid = uid->next;
- index++;
- }
-
- return index;
+ g_return_val_if_fail (SEAHORSE_IS_PGP_KEY (pkey), 0);
+ return g_list_length (pkey->uids);
}
-/**
- * seahorse_key_get_nth_userid:
- * @skey: #SeahorseKey
- * @index: Which userid
- *
- * Gets the the subkey at @index of @skey.
- *
- * Returns: subkey of @skey at @index, or NULL if @index is out of bounds
- */
-gpgme_user_id_t
-seahorse_pgp_key_get_nth_userid (SeahorsePGPKey *pkey, guint index)
-{
- gpgme_user_id_t uid;
- guint n;
-
- g_return_val_if_fail (pkey != NULL && SEAHORSE_IS_PGP_KEY (pkey), NULL);
- g_return_val_if_fail (pkey->pubkey != NULL, NULL);
-
- uid = pkey->pubkey->uids;
- for (n = index; uid && n; n--)
- uid = uid->next;
-
- return uid;
-}
-
const gchar*
seahorse_pgp_key_get_algo (SeahorsePGPKey *pkey, guint index)
{
@@ -788,7 +754,7 @@
g_return_val_if_fail (pkey != NULL && SEAHORSE_IS_PGP_KEY (pkey), 0);
- num_uids = seahorse_pgp_key_get_num_userids(pkey);
+ num_uids = seahorse_pgp_key_get_num_uids (pkey);
num_photoids = seahorse_pgp_key_get_num_photoids(pkey);
uids = num_uids + num_photoids;
Modified: trunk/pgp/seahorse-pgp-key.h
==============================================================================
--- trunk/pgp/seahorse-pgp-key.h (original)
+++ trunk/pgp/seahorse-pgp-key.h Fri Jul 18 22:05:15 2008
@@ -34,7 +34,7 @@
* trust: (SeahorseValidity) Trust for the key.
* expires: (gulong) Date this key expires or 0.
* length: (gint) The length of the key in bits.
- * stock-id: (gpointer/string) The stock icon id.
+ * stock-id: (string) The stock icon id.
*/
#ifndef __SEAHORSE_PGP_KEY_H__
@@ -45,9 +45,10 @@
#include "seahorse-key.h"
-#include "pgp/seahorse-pgp-module.h"
#include "pgp/seahorse-gpgmex.h"
+#include "pgp/seahorse-pgp-module.h"
#include "pgp/seahorse-pgp-source.h"
+#include "pgp/seahorse-pgp-uid.h"
enum {
SKEY_PGPSIG_TRUSTED = 0x0001,
@@ -76,6 +77,7 @@
gpgme_key_t pubkey; /* The public key */
gpgme_key_t seckey; /* The secret key */
gpgmex_photo_id_t photoids; /* List of photos */
+ GList *uids; /* All the UID objects */
};
struct _SeahorsePGPKeyClass {
@@ -93,22 +95,11 @@
gpgme_subkey_t seahorse_pgp_key_get_nth_subkey (SeahorsePGPKey *pkey,
guint index);
-guint seahorse_pgp_key_get_num_userids (SeahorsePGPKey *pkey);
-
-gpgme_user_id_t seahorse_pgp_key_get_nth_userid (SeahorsePGPKey *pkey,
- guint index);
-
-gchar* seahorse_pgp_key_get_userid (SeahorsePGPKey *pkey,
- guint index);
+guint seahorse_pgp_key_get_num_uids (SeahorsePGPKey *pkey);
-gchar* seahorse_pgp_key_get_userid_name (SeahorsePGPKey *pkey,
- guint index);
+SeahorsePGPUid* seahorse_pgp_key_get_uid (SeahorsePGPKey *pkey,
+ guint index);
-gchar* seahorse_pgp_key_get_userid_email (SeahorsePGPKey *pkey,
- guint index);
-
-gchar* seahorse_pgp_key_get_userid_comment (SeahorsePGPKey *pkey,
- guint index);
const gchar* seahorse_pgp_key_get_algo (SeahorsePGPKey *pkey,
guint index);
Modified: trunk/pgp/seahorse-pgp-source.c
==============================================================================
--- trunk/pgp/seahorse-pgp-source.c (original)
+++ trunk/pgp/seahorse-pgp-source.c Fri Jul 18 22:05:15 2008
@@ -648,7 +648,6 @@
gchar *name;
if (event_type == G_FILE_MONITOR_EVENT_CHANGED ||
- event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT ||
event_type == G_FILE_MONITOR_EVENT_DELETED ||
event_type == G_FILE_MONITOR_EVENT_CREATED) {
Added: trunk/pgp/seahorse-pgp-uid.c
==============================================================================
--- (empty file)
+++ trunk/pgp/seahorse-pgp-uid.c Fri Jul 18 22:05:15 2008
@@ -0,0 +1,341 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2008 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ * You should have received a copy of the GNU 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 "seahorse-gpgmex.h"
+#include "seahorse-pgp-key.h"
+#include "seahorse-pgp-uid.h"
+
+#include <string.h>
+
+#include <glib/gi18n.h>
+
+enum {
+ PROP_0,
+ PROP_PUBKEY,
+ PROP_USERID,
+ PROP_INDEX,
+ PROP_DISPLAY_NAME,
+ PROP_MARKUP,
+ PROP_SIMPLE_NAME,
+ PROP_VALIDITY,
+ PROP_VALIDITY_STR,
+ PROP_STOCK_ID
+};
+
+G_DEFINE_TYPE (SeahorsePGPUid, seahorse_pgp_uid, SEAHORSE_TYPE_OBJECT);
+
+/* -----------------------------------------------------------------------------
+ * INTERNAL HELPERS
+ */
+
+static gchar*
+convert_string (const gchar *str, gboolean escape)
+{
+ gchar *t, *ret;
+
+ if (!str)
+ return NULL;
+
+ /* If not utf8 valid, assume latin 1 */
+ if (!g_utf8_validate (str, -1, NULL)) {
+ ret = g_convert (str, -1, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
+ if (escape) {
+ t = ret;
+ ret = g_markup_escape_text (t, -1);
+ g_free (t);
+ }
+
+ return ret;
+ }
+
+ if (escape)
+ return g_markup_escape_text (str, -1);
+ else
+ return g_strdup (str);
+}
+
+static void
+changed_uid (SeahorsePGPUid *uid)
+{
+ SeahorseObject *obj = SEAHORSE_OBJECT (uid);
+
+ obj->_id = 0;
+ obj->_tag = SEAHORSE_PGP;
+
+ if (!uid->userid || !uid->pubkey) {
+
+ obj->_usage = SEAHORSE_USAGE_NONE;
+ obj->_flags = SKEY_FLAG_DISABLED;
+
+ } else {
+
+ /* The key id */
+ if (uid->pubkey->subkeys)
+ obj->_id = seahorse_pgp_key_get_cannonical_id (uid->pubkey->subkeys->keyid);
+
+ /* The location */
+ if (uid->pubkey->keylist_mode & GPGME_KEYLIST_MODE_EXTERN &&
+ obj->_location <= SEAHORSE_LOCATION_REMOTE)
+ obj->_location = SEAHORSE_LOCATION_REMOTE;
+
+ else if (obj->_location <= SEAHORSE_LOCATION_LOCAL)
+ obj->_location = SEAHORSE_LOCATION_LOCAL;
+
+ /* The type */
+ obj->_usage = SEAHORSE_USAGE_IDENTITY;
+
+ /* The flags */
+ obj->_flags = 0;
+ }
+
+ if (!obj->_id)
+ obj->_id = g_quark_from_string (SEAHORSE_PGP_STR ":UNKNOWN UNKNOWN ");
+
+ seahorse_object_fire_changed (obj, SEAHORSE_OBJECT_CHANGE_ALL);
+}
+
+/* -----------------------------------------------------------------------------
+ * OBJECT
+ */
+
+static void
+seahorse_pgp_uid_init (SeahorsePGPUid *uid)
+{
+
+}
+
+static void
+seahorse_pgp_uid_get_property (GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ SeahorsePGPUid *uid = SEAHORSE_PGP_UID (object);
+
+ switch (prop_id) {
+ case PROP_PUBKEY:
+ g_value_set_pointer (value, uid->pubkey);
+ break;
+ case PROP_USERID:
+ g_value_set_pointer (value, uid->userid);
+ break;
+ case PROP_INDEX:
+ g_value_set_uint (value, uid->index);
+ break;
+ case PROP_DISPLAY_NAME:
+ g_value_take_string (value, seahorse_pgp_uid_get_display_name (uid));
+ break;
+ case PROP_MARKUP:
+ g_value_take_string (value, seahorse_pgp_uid_get_markup (uid, 0));
+ break;
+ case PROP_SIMPLE_NAME:
+ g_value_take_string (value, seahorse_pgp_uid_get_name (uid));
+ break;
+ case PROP_VALIDITY:
+ g_value_set_uint (value, seahorse_pgp_uid_get_validity (uid));
+ break;
+ case PROP_VALIDITY_STR:
+ g_value_set_string (value, seahorse_validity_get_string (seahorse_pgp_uid_get_validity (uid)));
+ break;
+ case PROP_STOCK_ID:
+ g_value_set_string (value, "");
+ break;
+ }
+}
+
+static void
+seahorse_pgp_uid_set_property (GObject *object, guint prop_id, const GValue *value,
+ GParamSpec *pspec)
+{
+ SeahorsePGPUid *uid = SEAHORSE_PGP_UID (object);
+
+ switch (prop_id) {
+ case PROP_PUBKEY:
+ g_return_if_fail (!uid->pubkey);
+ uid->pubkey = g_value_get_pointer (value);
+ if (uid->pubkey)
+ gpgmex_key_ref (uid->pubkey);
+ break;
+ case PROP_INDEX:
+ uid->index = g_value_get_uint (value);
+ break;
+ case PROP_USERID:
+ uid->userid = g_value_get_pointer (value);
+ changed_uid (uid);
+ break;
+ }
+}
+
+static void
+seahorse_pgp_uid_object_finalize (GObject *gobject)
+{
+ SeahorsePGPUid *uid = SEAHORSE_PGP_UID (gobject);
+
+ /* Unref the key */
+ if (uid->pubkey)
+ gpgmex_key_unref (uid->pubkey);
+ uid->pubkey = NULL;
+ uid->userid = NULL;
+
+ G_OBJECT_CLASS (seahorse_pgp_uid_parent_class)->finalize (gobject);
+}
+
+static void
+seahorse_pgp_uid_class_init (SeahorsePGPUidClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ seahorse_pgp_uid_parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->finalize = seahorse_pgp_uid_object_finalize;
+ gobject_class->set_property = seahorse_pgp_uid_set_property;
+ gobject_class->get_property = seahorse_pgp_uid_get_property;
+
+ g_object_class_install_property (gobject_class, PROP_PUBKEY,
+ g_param_spec_pointer ("pubkey", "Gpgme Public Key", "Gpgme Public Key that this uid is on",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (gobject_class, PROP_USERID,
+ g_param_spec_pointer ("userid", "Gpgme User ID", "Gpgme User ID",
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class, PROP_INDEX,
+ g_param_spec_uint ("index", "Index", "Gpgme User ID Index",
+ 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class, PROP_DISPLAY_NAME,
+ g_param_spec_string ("display-name", "Display Name", "User Displayable name for this uid",
+ "", G_PARAM_READABLE));
+
+ g_object_class_install_property (gobject_class, PROP_MARKUP,
+ g_param_spec_string ("markup", "Display Markup", "GLib Markup",
+ "", G_PARAM_READABLE));
+
+ g_object_class_install_property (gobject_class, PROP_SIMPLE_NAME,
+ g_param_spec_string ("simple-name", "Simple Name", "Simple name for this user id",
+ "", G_PARAM_READABLE));
+
+ g_object_class_install_property (gobject_class, PROP_VALIDITY,
+ g_param_spec_uint ("validity", "Validity", "Validity of this identity",
+ 0, G_MAXUINT, 0, G_PARAM_READABLE));
+
+ g_object_class_install_property (gobject_class, PROP_VALIDITY_STR,
+ g_param_spec_string ("validity-str", "Validity String", "Validity of this identity as a string",
+ "", G_PARAM_READABLE));
+
+ g_object_class_install_property (gobject_class, PROP_STOCK_ID,
+ g_param_spec_string ("stock-id", "The stock icon", "The stock icon id",
+ NULL, G_PARAM_READABLE));
+}
+
+/* -----------------------------------------------------------------------------
+ * PUBLIC
+ */
+
+SeahorsePGPUid*
+seahorse_pgp_uid_new (gpgme_key_t pubkey, gpgme_user_id_t userid)
+{
+ return g_object_new (SEAHORSE_TYPE_PGP_UID, "pubkey", pubkey, "userid", userid, NULL);
+}
+
+gchar*
+seahorse_pgp_uid_get_display_name (SeahorsePGPUid *uid)
+{
+ g_return_val_if_fail (SEAHORSE_IS_PGP_UID (uid), NULL);
+ g_return_val_if_fail (uid->userid, NULL);
+ return convert_string (uid->userid->uid, FALSE);
+}
+
+gchar*
+seahorse_pgp_uid_get_markup (SeahorsePGPUid *uid, guint flags)
+{
+ gchar *email, *name, *comment, *ret;
+ const gchar *format;
+ gboolean strike = FALSE;
+
+ g_return_val_if_fail (SEAHORSE_IS_PGP_UID (uid), NULL);
+ g_return_val_if_fail (uid->userid, NULL);
+
+ name = convert_string (uid->userid->name, TRUE);
+ email = convert_string (uid->userid->email, TRUE);
+ comment = convert_string (uid->userid->comment, TRUE);
+
+ if (uid->userid->revoked || flags & CRYPTUI_FLAG_EXPIRED ||
+ flags & CRYPTUI_FLAG_REVOKED || flags & CRYPTUI_FLAG_DISABLED)
+ strike = TRUE;
+
+ if (strike)
+ format = "<span strikethrough='true'>%s<span foreground='#555555' size='small' rise='0'>%s%s%s%s%s</span></span>";
+ else
+ format = "%s<span foreground='#555555' size='small' rise='0'>%s%s%s%s%s</span>";
+
+ ret = g_markup_printf_escaped (format, name,
+ email && email[0] ? " " : "",
+ email && email[0] ? email : "",
+ comment && comment[0] ? " '" : "",
+ comment && comment[0] ? comment : "",
+ comment && comment[0] ? "'" : "");
+
+ g_free (name);
+ g_free (comment);
+ g_free (email);
+
+ return ret;
+}
+
+gchar*
+seahorse_pgp_uid_get_name (SeahorsePGPUid *uid)
+{
+ g_return_val_if_fail (SEAHORSE_IS_PGP_UID (uid), NULL);
+ g_return_val_if_fail (uid->userid, NULL);
+ return convert_string (uid->userid->name, FALSE);
+}
+
+
+gchar*
+seahorse_pgp_uid_get_email (SeahorsePGPUid *uid)
+{
+ g_return_val_if_fail (SEAHORSE_IS_PGP_UID (uid), NULL);
+ g_return_val_if_fail (uid->userid, NULL);
+ return convert_string (uid->userid->email, FALSE);
+}
+
+gchar*
+seahorse_pgp_uid_get_comment (SeahorsePGPUid *uid)
+{
+ g_return_val_if_fail (SEAHORSE_IS_PGP_UID (uid), NULL);
+ g_return_val_if_fail (uid->userid, NULL);
+ return convert_string (uid->userid->comment, FALSE);
+}
+
+SeahorseValidity
+seahorse_pgp_uid_get_validity (SeahorsePGPUid *uid)
+{
+ g_return_val_if_fail (SEAHORSE_IS_PGP_UID (uid), SEAHORSE_VALIDITY_UNKNOWN);
+ g_return_val_if_fail (uid->userid, SEAHORSE_VALIDITY_UNKNOWN);
+ return gpgmex_validity_to_seahorse (uid->userid->validity);
+}
+
+guint
+seahorse_pgp_uid_get_index (SeahorsePGPUid *uid)
+{
+ g_return_val_if_fail (SEAHORSE_IS_PGP_UID (uid), 0);
+ return uid->index;
+}
Added: trunk/pgp/seahorse-pgp-uid.h
==============================================================================
--- (empty file)
+++ trunk/pgp/seahorse-pgp-uid.h Fri Jul 18 22:05:15 2008
@@ -0,0 +1,97 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2008 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ * You should have received a copy of the GNU 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.
+ */
+
+/**
+ * SeahorsePGPUid: Represents a PGP UID loaded via GPGME.
+ *
+ * - Derived from SeahorseKey
+ *
+ * Properties:
+ * label: (gchar*) The display name for the UID.
+ * markup:
+ * simple-name:
+ * validity: (SeahorseValidity) The key validity.
+ * stock-id:
+ */
+
+#ifndef __SEAHORSE_PGP_UID_H__
+#define __SEAHORSE_PGP_UID_H__
+
+#include <gtk/gtk.h>
+#include <gpgme.h>
+
+#include "seahorse-key.h"
+
+#include "pgp/seahorse-pgp-module.h"
+#include "pgp/seahorse-gpgmex.h"
+
+#define SEAHORSE_TYPE_PGP_UID (seahorse_pgp_uid_get_type ())
+
+/* For vala's sake */
+#define SEAHORSE_PGP_TYPE_UID SEAHORSE_TYPE_PGP_UID
+
+#define SEAHORSE_PGP_UID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_PGP_UID, SeahorsePGPUid))
+#define SEAHORSE_PGP_UID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_PGP_UID, SeahorsePGPUidClass))
+#define SEAHORSE_IS_PGP_UID(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_PGP_UID))
+#define SEAHORSE_IS_PGP_UID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_PGP_UID))
+#define SEAHORSE_PGP_UID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_PGP_UID, SeahorsePGPUidClass))
+
+
+typedef struct _SeahorsePGPUid SeahorsePGPUid;
+typedef struct _SeahorsePGPUidClass SeahorsePGPUidClass;
+
+struct _SeahorsePGPUid {
+ SeahorseObject parent;
+
+ /*< public >*/
+ gpgme_key_t pubkey; /* The public key that this uid is part of */
+ gpgme_user_id_t userid; /* The userid referred to */
+ guint index; /* The index of the UID */
+};
+
+struct _SeahorsePGPUidClass {
+ SeahorseObjectClass parent_class;
+};
+
+SeahorsePGPUid* seahorse_pgp_uid_new (gpgme_key_t pubkey,
+ gpgme_user_id_t userid);
+
+GType seahorse_pgp_uid_get_type (void);
+
+gboolean seahorse_pgp_uid_equal (SeahorsePGPUid *uid,
+ gpgme_user_id_t userid);
+
+gchar* seahorse_pgp_uid_get_display_name (SeahorsePGPUid *uid);
+
+gchar* seahorse_pgp_uid_get_markup (SeahorsePGPUid *uid,
+ guint flags);
+
+gchar* seahorse_pgp_uid_get_name (SeahorsePGPUid *uid);
+
+gchar* seahorse_pgp_uid_get_email (SeahorsePGPUid *uid);
+
+gchar* seahorse_pgp_uid_get_comment (SeahorsePGPUid *uid);
+
+SeahorseValidity seahorse_pgp_uid_get_validity (SeahorsePGPUid *uid);
+
+guint seahorse_pgp_uid_get_index (SeahorsePGPUid *uid);
+
+#endif /* __SEAHORSE_PGP_UID_H__ */
Modified: trunk/pgp/vala-build.stamp
==============================================================================
--- trunk/pgp/vala-build.stamp (original)
+++ trunk/pgp/vala-build.stamp Fri Jul 18 22:05:15 2008
@@ -1 +1 @@
-1216254293
+1216417244
Modified: trunk/pkcs11/vala-build.stamp
==============================================================================
--- trunk/pkcs11/vala-build.stamp (original)
+++ trunk/pkcs11/vala-build.stamp Fri Jul 18 22:05:15 2008
@@ -1 +1 @@
-1216227443
+1216417239
Modified: trunk/src/seahorse-generate-select.c
==============================================================================
--- trunk/src/seahorse-generate-select.c (original)
+++ trunk/src/seahorse-generate-select.c Fri Jul 18 22:05:15 2008
@@ -258,11 +258,11 @@
_tmp13 = NULL;
_tmp12 = NULL;
self->priv->_view = (_tmp13 = (_tmp12 = GTK_TREE_VIEW (seahorse_widget_get_widget (SEAHORSE_WIDGET (self), "keytype-tree")), (_tmp12 == NULL ? NULL : g_object_ref (_tmp12))), (self->priv->_view == NULL ? NULL : (self->priv->_view = (g_object_unref (self->priv->_view), NULL))), _tmp13);
- pixcell = g_object_ref_sink (gtk_cell_renderer_pixbuf_new ());
+ pixcell = g_object_ref_sink (((GtkCellRendererPixbuf*) (gtk_cell_renderer_pixbuf_new ())));
g_object_set (pixcell, "stock-size", ((guint) (GTK_ICON_SIZE_DIALOG)), NULL);
gtk_tree_view_insert_column_with_attributes (self->priv->_view, -1, "", GTK_CELL_RENDERER (pixcell), "stock-id", SEAHORSE_GENERATE_SELECT_COLUMN_ICON, NULL, NULL);
_tmp15 = NULL;
- gtk_tree_view_insert_column_with_attributes (self->priv->_view, -1, "", GTK_CELL_RENDERER ((_tmp15 = g_object_ref_sink (gtk_cell_renderer_text_new ()))), "markup", SEAHORSE_GENERATE_SELECT_COLUMN_TEXT, NULL, NULL);
+ gtk_tree_view_insert_column_with_attributes (self->priv->_view, -1, "", GTK_CELL_RENDERER ((_tmp15 = g_object_ref_sink (((GtkCellRendererText*) (gtk_cell_renderer_text_new ()))))), "markup", SEAHORSE_GENERATE_SELECT_COLUMN_TEXT, NULL, NULL);
(_tmp15 == NULL ? NULL : (_tmp15 = (g_object_unref (_tmp15), NULL)));
gtk_tree_view_set_model (self->priv->_view, GTK_TREE_MODEL (self->priv->_store));
/* Setup selection, select first item */
Modified: trunk/src/seahorse-key-manager-store.c
==============================================================================
--- trunk/src/seahorse-key-manager-store.c (original)
+++ trunk/src/seahorse-key-manager-store.c Fri Jul 18 22:05:15 2008
@@ -27,28 +27,27 @@
#include <glib/gi18n.h>
+#include "seahorse-gconf.h"
#include "seahorse-key-manager-store.h"
#include "seahorse-preferences.h"
-#include "seahorse-validity.h"
#include "seahorse-util.h"
-#include "seahorse-gconf.h"
+#include "seahorse-validity.h"
+
#include "eggtreemultidnd.h"
#define KEY_MANAGER_SORT_KEY "/apps/seahorse/listing/sort_by"
enum {
PROP_0,
- PROP_KEYSET,
PROP_MODE,
PROP_FILTER
};
enum {
- COL_PAIR,
+ COL_USAGE,
COL_STOCK_ID,
COL_NAME,
COL_KEYID,
- COL_UID,
COL_VALIDITY_STR,
COL_TRUST_STR,
COL_TYPE,
@@ -59,34 +58,18 @@
N_COLS
};
-static const gchar* col_ids[] = {
- "pair",
- NULL,
- "name",
- "id",
- NULL,
- "validity",
- "trust",
- "type",
- "expires",
- "validity",
- "expires",
- "trust"
-};
-
-static const GType col_types[] = {
- G_TYPE_BOOLEAN,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_INT,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_INT,
- G_TYPE_LONG,
- G_TYPE_INT
+static const SeahorseSetModelColumn column_info[] = {
+ { "usage", G_TYPE_INT, "usage" },
+ { "stock-id", G_TYPE_STRING, NULL },
+ { "markup", G_TYPE_STRING, "name" },
+ { "display-id", G_TYPE_STRING, "id" },
+ { "validity-str", G_TYPE_STRING, "validity" },
+ { "trust-str", G_TYPE_STRING, "trust" },
+ { "type", G_TYPE_STRING, "type" },
+ { "expires-str", G_TYPE_STRING, "expires" },
+ { "validity", G_TYPE_INT, "validity" },
+ { "expires", G_TYPE_LONG, "expires" },
+ { "trust", G_TYPE_INT, "trust" }
};
enum {
@@ -114,10 +97,10 @@
gchar *drag_destination;
GError *drag_error;
- GList *drag_keys;
+ GList *drag_objects;
};
-G_DEFINE_TYPE (SeahorseKeyManagerStore, seahorse_key_manager_store, SEAHORSE_TYPE_KEY_MODEL);
+G_DEFINE_TYPE (SeahorseKeyManagerStore, seahorse_key_manager_store, SEAHORSE_TYPE_SET_MODEL);
/* -----------------------------------------------------------------------------
* INTERNAL
@@ -179,26 +162,22 @@
return NULL;
}
-/* Given an iterator find the associated key */
-static SeahorseKey*
-key_from_iterator (GtkTreeModel* model, GtkTreeIter* iter, guint *uid)
-{
- GtkTreeIter i;
- SeahorseKey *skey = NULL;
-
- /* Convert to base iter if necessary */
- if (!SEAHORSE_IS_KEY_MANAGER_STORE (model)) {
- SeahorseKeyManagerStore* skstore = key_store_from_model (model);
- get_base_iter (skstore, &i, iter);
+/* Given an iterator find the associated object */
+static SeahorseObject*
+object_from_iterator (GtkTreeModel* model, GtkTreeIter* iter)
+{
+ GtkTreeIter i;
+
+ /* Convert to base iter if necessary */
+ if (!SEAHORSE_IS_KEY_MANAGER_STORE (model)) {
+ SeahorseKeyManagerStore* skstore = key_store_from_model (model);
+ get_base_iter (skstore, &i, iter);
- iter = &i;
- model = GTK_TREE_MODEL (skstore);
- }
+ iter = &i;
+ model = GTK_TREE_MODEL (skstore);
+ }
- skey = seahorse_key_model_get_row_key (SEAHORSE_KEY_MODEL (model), iter);
- if (skey && uid)
- gtk_tree_model_get (model, iter, COL_UID, uid, -1);
- return skey;
+ return seahorse_set_model_object_for_iter (SEAHORSE_SET_MODEL (model), iter);
}
/* Search through row for text */
@@ -274,7 +253,7 @@
static gboolean
refilter_now (SeahorseKeyManagerStore* skstore)
{
- seahorse_set_refresh (skstore->skset);
+ seahorse_set_refresh (SEAHORSE_SET_MODEL (skstore)->set);
gtk_tree_model_filter_refilter (skstore->priv->filter);
skstore->priv->filter_stag = 0;
return FALSE;
@@ -289,186 +268,6 @@
skstore->priv->filter_stag = g_timeout_add (200, (GSourceFunc)refilter_now, skstore);
}
-/* Sets Name and KeyID */
-static void
-update_key_row (SeahorseKeyManagerStore *skstore, SeahorseKey *skey, guint uid,
- GtkTreeIter *iter)
-{
- SeahorseValidity validity, trust;
- SeahorseObjectPredicate *pred;
- SeahorseSource *sksrc;
- const gchar *stockid;
- gulong expires_date;
- gchar *markup;
- gboolean sec;
- gchar *expires;
- gchar *type;
-
- markup = seahorse_key_get_name_markup (skey, uid);
- sec = seahorse_key_get_usage (skey) == SEAHORSE_USAGE_PRIVATE_KEY;
- stockid = seahorse_key_get_stock_id (skey);
- validity = seahorse_key_get_name_validity (skey, uid);
-
- if (uid == 0) {
-
- trust = seahorse_key_get_trust (skey);
-
- if (seahorse_key_get_flags (skey) & SKEY_FLAG_EXPIRED) {
- expires = g_strdup (_("Expired"));
- expires_date = -1;
- } else {
- expires_date = seahorse_key_get_expires (skey);
-
- if (expires_date == 0) {
- expires = g_strdup ("");
- expires_date = G_MAXLONG;
- }
- else
- expires = seahorse_util_get_display_date_string (expires_date);
- }
-
- /* Only differentiate if the view shows more than one type of key */
- g_object_get (skstore->skset, "predicate", &pred, NULL);
-
- /* If mixed etypes, then get specific description */
- if (pred->usage == 0 || pred->usage == SEAHORSE_USAGE_CREDENTIALS) {
- type = g_strdup (seahorse_key_get_desc (skey));
-
- /* Otherwise general description */
- } else {
- sksrc = seahorse_key_get_source (skey);
- g_return_if_fail (sksrc);
- g_object_get (sksrc, "key-desc", &type, NULL);
- }
-
- gtk_tree_store_set (GTK_TREE_STORE (skstore), iter,
- COL_PAIR, uid == 0 ? sec : FALSE,
- COL_STOCK_ID, uid == 0 ? stockid : NULL,
- COL_NAME, markup,
- COL_KEYID, seahorse_key_get_short_keyid (skey),
- COL_UID, uid,
- COL_VALIDITY_STR, validity == SEAHORSE_VALIDITY_UNKNOWN ? "" : seahorse_validity_get_string (validity),
- COL_VALIDITY, validity,
- COL_TRUST_STR, trust == SEAHORSE_VALIDITY_UNKNOWN ? "" : seahorse_validity_get_string (trust),
- COL_TRUST, trust,
- COL_TYPE, type,
- COL_EXPIRES_STR, expires ? expires : "",
- COL_EXPIRES, expires_date,
- -1);
-
- g_free (type);
- g_free (expires);
-
- } else {
-
- gtk_tree_store_set (GTK_TREE_STORE (skstore), iter,
- COL_KEYID, "",
- COL_NAME, markup,
- COL_UID, uid,
- COL_VALIDITY_STR, validity == SEAHORSE_VALIDITY_UNKNOWN ? "" : seahorse_validity_get_string (validity),
- COL_VALIDITY, validity,
- COL_TYPE, _("User ID"),
- -1);
- }
-
- g_free (markup);
-}
-
-static gboolean
-append_key_row (SeahorseKeyManagerStore *skstore, SeahorseKey *skey, guint uid,
- GtkTreeIter *iter)
-{
- GtkTreeIter child;
-
- if (uid == 0) {
- gtk_tree_store_append (GTK_TREE_STORE (skstore), iter, NULL);
- update_key_row (skstore, skey, uid, iter);
- seahorse_key_model_set_row_key (SEAHORSE_KEY_MODEL (skstore), iter, skey);
- } else {
- gtk_tree_store_append (GTK_TREE_STORE (skstore), &child, iter);
- update_key_row (skstore, skey, uid, &child);
- seahorse_key_model_set_row_key (SEAHORSE_KEY_MODEL (skstore), &child, skey);
- }
-
- return TRUE;
-}
-
-static void
-key_added (SeahorseSet *skset, SeahorseKey *skey, SeahorseKeyManagerStore *skstore)
-{
- GtkTreeIter iter = { 0, };
- guint i, uids = seahorse_key_get_num_names (skey);
-
- for (i = 0; i < uids; i++) {
- if (!append_key_row (skstore, skey, i, &iter))
- break;
- }
-}
-
-static void
-key_removed (SeahorseSet *skset, SeahorseKey *skey, gpointer closure,
- SeahorseKeyManagerStore *skstore)
-{
- seahorse_key_model_remove_rows_for_key (SEAHORSE_KEY_MODEL (skstore), skey);
-}
-
-static void
-key_changed (SeahorseSet *skset, SeahorseKey *skey, SeahorseKeyChange change,
- gpointer closure, SeahorseKeyManagerStore *skstore)
-{
- guint i, uid, old_uids, num_uids;
- GtkTreeIter first;
- GtkTreeIter *iter;
- GSList *rows, *l;
-
- old_uids = 0;
- num_uids = seahorse_key_get_num_names (skey);
- rows = seahorse_key_model_get_rows_for_key (SEAHORSE_KEY_MODEL (skstore), skey);
-
- for (l = rows; l; l = g_slist_next (l)) {
-
- iter = (GtkTreeIter*)l->data;
- gtk_tree_model_get (GTK_TREE_MODEL (skstore), iter, COL_UID, &uid, -1);
-
- /* Remove any extra rows */
- if (uid >= num_uids) {
- seahorse_key_model_set_row_key (SEAHORSE_KEY_MODEL (skstore), iter, NULL);
- gtk_tree_store_remove (GTK_TREE_STORE (skstore), iter);
- continue;
- }
-
- update_key_row (skstore, skey, uid, iter);
-
- /* The top parent row */
- if (uid == 0)
- memcpy (&first, iter, sizeof (first));
-
- /* Find the max uid on the rows */
- if (uid >= old_uids)
- old_uids = uid + 1;
- }
-
- /* Add all new rows */
- for (i = old_uids; i < num_uids; i++)
- append_key_row (skstore, skey, i, &first);
-
- seahorse_key_model_free_rows (rows);
-}
-
-static void
-populate_store (SeahorseKeyManagerStore *skstore)
-{
- GList *keys, *list = NULL;
- SeahorseKey *skey;
-
- keys = list = seahorse_set_get_objects (skstore->skset);
- while (list != NULL && (skey = list->data) != NULL) {
- key_added (skstore->skset, skey, skstore);
- list = g_list_next (list);
- }
- g_list_free (keys);
-}
-
/* Update the sort order for a column */
static void
set_sort_to (SeahorseKeyManagerStore *skstore, const gchar *name)
@@ -492,9 +291,9 @@
name++;
}
- /* Find the column id */
+ /* Find the column sort id */
for (i = N_COLS - 1; i >= 0 ; i--) {
- n = col_ids[i];
+ n = column_info[i].data;
if (n && g_ascii_strcasecmp (name, n) == 0) {
id = i;
break;
@@ -522,7 +321,7 @@
/* We have a sort so save it */
if (gtk_tree_sortable_get_sort_column_id (sort, &id, &ord)) {
if (id >= 0 && id < N_COLS) {
- t = col_ids[id];
+ t = column_info[id].data;
if (t != NULL) {
x = g_strconcat (ord == GTK_SORT_DESCENDING ? "-" : "", t, NULL);
seahorse_gconf_set_string (KEY_MANAGER_SORT_KEY, x);
@@ -577,7 +376,7 @@
static GtkTreeViewColumn*
append_text_column (SeahorseKeyManagerStore *skstore, GtkTreeView *view,
- const gchar *label, const gint index)
+ const gchar *label, const gint index)
{
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
@@ -650,53 +449,53 @@
g_clear_error (&skstore->priv->drag_error);
- g_list_free (skstore->priv->drag_keys);
- skstore->priv->drag_keys = seahorse_key_manager_store_get_selected_keys (view);
- if (skstore->priv->drag_keys)
+ g_list_free (skstore->priv->drag_objects);
+ skstore->priv->drag_objects = seahorse_key_manager_store_get_selected_objects (view);
+ if (skstore->priv->drag_objects)
gdk_property_change (context->source_window, XDS_ATOM, TEXT_ATOM,
8, GDK_PROP_MODE_REPLACE, (guchar*)XDS_FILENAME,
strlen (XDS_FILENAME));
DBG_PRINT (("drag_begin <--\n"));
- return skstore->priv->drag_keys ? TRUE : FALSE;
+ return skstore->priv->drag_objects ? TRUE : FALSE;
}
static gboolean
-export_keys_to_output (GList *keys, GOutputStream *output, GError **error)
+export_keys_to_output (GList *objects, GOutputStream *output, GError **error)
{
SeahorseMultiOperation *mop = NULL;
SeahorseOperation *op;
SeahorseSource *sksrc;
- SeahorseKey *skey;
+ SeahorseObject *sobj;
GList *next;
gboolean ret;
- keys = seahorse_util_objects_sort (keys);
- DBG_PRINT (("exporting %d keys\n", g_list_length (keys)));
+ objects = seahorse_util_objects_sort (objects);
+ DBG_PRINT (("exporting %d objects\n", g_list_length (objects)));
- while (keys) {
+ while (objects) {
/* Break off one set (same keysource) */
- next = seahorse_util_objects_splice (keys);
+ next = seahorse_util_objects_splice (objects);
- g_assert (SEAHORSE_IS_KEY (keys->data));
- skey = SEAHORSE_KEY (keys->data);
+ g_assert (SEAHORSE_IS_OBJECT (objects->data));
+ sobj = SEAHORSE_OBJECT (objects->data);
/* Export from this key source */
- sksrc = seahorse_key_get_source (skey);
+ sksrc = seahorse_object_get_source (sobj);
g_return_val_if_fail (sksrc != NULL, FALSE);
if (!mop)
mop = seahorse_multi_operation_new ();
/* We pass our own data object, to which data is appended */
- op = seahorse_source_export (sksrc, keys, FALSE, output);
+ op = seahorse_source_export (sksrc, objects, FALSE, output);
g_return_val_if_fail (op != NULL, FALSE);
seahorse_multi_operation_take (mop, op);
- g_list_free (keys);
- keys = next;
+ g_list_free (objects);
+ objects = next;
}
/* Make sure it's complete before we can return data */
@@ -722,8 +521,8 @@
ret = FALSE;
- g_return_val_if_fail (skstore->priv->drag_keys, FALSE);
- keys = g_list_copy (skstore->priv->drag_keys);
+ g_return_val_if_fail (skstore->priv->drag_objects, FALSE);
+ keys = g_list_copy (skstore->priv->drag_objects);
DBG_PRINT (("exporting to text\n"));
@@ -760,8 +559,8 @@
DBG_PRINT (("exporting to %s\n", filename));
ret = FALSE;
- g_return_val_if_fail (skstore->priv->drag_keys, FALSE);
- keys = g_list_copy (skstore->priv->drag_keys);
+ g_return_val_if_fail (skstore->priv->drag_objects, FALSE);
+ keys = g_list_copy (skstore->priv->drag_objects);
uri = seahorse_util_uri_unique (filename);
@@ -784,20 +583,19 @@
}
static gboolean
-drag_data_get (GtkWidget *widget, GdkDragContext *context,
- GtkSelectionData *selection_data, guint info,
- guint time, SeahorseKeyManagerStore *skstore)
+drag_data_get (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data,
+ guint info, guint time, SeahorseKeyManagerStore *skstore)
{
gchar *destination;
gboolean ret;
DBG_PRINT (("drag_data_get %d -->\n", info));
- g_return_val_if_fail (skstore->priv->drag_keys, FALSE);
+ g_return_val_if_fail (skstore->priv->drag_objects, FALSE);
/* The caller wants plain text */
if (info == DRAG_INFO_TEXT) {
- DBG_PRINT (("returning key text\n"));
+ DBG_PRINT (("returning object text\n"));
export_to_text (skstore, selection_data);
/* The caller wants XDS */
@@ -830,9 +628,9 @@
DBG_PRINT (("drag_end -->\n"));
if (skstore->priv->drag_destination && !skstore->priv->drag_error) {
- g_return_if_fail (skstore->priv->drag_keys);
+ g_return_if_fail (skstore->priv->drag_objects);
- name = seahorse_util_filename_for_keys (skstore->priv->drag_keys);
+ name = seahorse_util_filename_for_keys (skstore->priv->drag_objects);
g_return_if_fail (name);
filename = g_build_filename (skstore->priv->drag_destination, name, NULL);
@@ -848,8 +646,8 @@
}
g_clear_error (&skstore->priv->drag_error);
- g_list_free (skstore->priv->drag_keys);
- skstore->priv->drag_keys = NULL;
+ g_list_free (skstore->priv->drag_objects);
+ skstore->priv->drag_objects = NULL;
g_free (skstore->priv->drag_destination);
skstore->priv->drag_destination = NULL;
@@ -873,14 +671,6 @@
{
/* init private vars */
skstore->priv = g_new0 (SeahorseKeyManagerStorePriv, 1);
-
- /* Setup the store */
- seahorse_key_model_set_column_types (SEAHORSE_KEY_MODEL (skstore), N_COLS, (GType *) col_types);
-
- /* Setup the sort and filter */
- skstore->priv->filter = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (GTK_TREE_MODEL (skstore), NULL));
- gtk_tree_model_filter_set_visible_func (skstore->priv->filter, filter_callback, skstore, NULL);
- skstore->priv->sort = GTK_TREE_MODEL_SORT (gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (skstore->priv->filter)));
}
static void
@@ -890,10 +680,7 @@
SeahorseKeyManagerStore *skstore = SEAHORSE_KEY_MANAGER_STORE (gobject);
switch (prop_id) {
- case PROP_KEYSET:
- g_value_set_object (value, skstore->skset);
- break;
-
+
/* The filtering mode */
case PROP_MODE:
g_value_set_uint (value, skstore->priv->filter_mode);
@@ -919,14 +706,6 @@
const gchar* t;
switch (prop_id) {
- case PROP_KEYSET:
- g_assert (skstore->skset == NULL);
- skstore->skset = g_value_get_object (value);
- g_object_ref (skstore->skset);
- g_signal_connect_after (skstore->skset, "added", G_CALLBACK (key_added), skstore);
- g_signal_connect_after (skstore->skset, "removed", G_CALLBACK (key_removed), skstore);
- g_signal_connect_after (skstore->skset, "changed", G_CALLBACK (key_changed), skstore);
- break;
/* The filtering mode */
case PROP_MODE:
@@ -962,36 +741,9 @@
}
static void
-seahorse_key_manager_store_dispose (GObject *gobject)
-{
- SeahorseKeyManagerStore *skstore;
-
- /*
- * Note that after this executes the rest of the object should
- * still work without a segfault. This basically nullifies the
- * object, but doesn't free it.
- *
- * This function should also be able to run multiple times.
- */
-
- skstore = SEAHORSE_KEY_MANAGER_STORE (gobject);
-
- if (skstore->skset) {
- g_signal_handlers_disconnect_by_func (skstore->skset, key_added, skstore);
- g_signal_handlers_disconnect_by_func (skstore->skset, key_removed, skstore);
- g_signal_handlers_disconnect_by_func (skstore->skset, key_changed, skstore);
- g_object_unref (skstore->skset);
- skstore->skset = NULL;
- }
-
- G_OBJECT_CLASS (seahorse_key_manager_store_parent_class)->dispose (gobject);
-}
-
-static void
seahorse_key_manager_store_finalize (GObject *gobject)
{
SeahorseKeyManagerStore *skstore = SEAHORSE_KEY_MANAGER_STORE (gobject);
- g_assert (skstore->skset == NULL);
/* These were allocated in the constructor */
g_object_unref (skstore->priv->sort);
@@ -1010,18 +762,12 @@
seahorse_key_manager_store_parent_class = g_type_class_peek_parent (klass);
/* Some simple checks to make sure all column info is on the same page */
- g_assert (N_COLS == G_N_ELEMENTS (col_ids));
- g_assert (N_COLS == G_N_ELEMENTS (col_types));
+ g_assert (N_COLS == G_N_ELEMENTS (column_info));
gobject_class->finalize = seahorse_key_manager_store_finalize;
- gobject_class->dispose = seahorse_key_manager_store_dispose;
gobject_class->set_property = seahorse_key_manager_store_set_property;
gobject_class->get_property = seahorse_key_manager_store_get_property;
- g_object_class_install_property (gobject_class, PROP_KEYSET,
- g_param_spec_object ("keyset", "Seahorse Keyset", "Current Seahorse Key Source to use",
- SEAHORSE_TYPE_SET, G_PARAM_READWRITE));
-
g_object_class_install_property (gobject_class, PROP_MODE,
g_param_spec_uint ("mode", "Key Store Mode", "Key store mode controls which keys to display",
0, KEY_STORE_MODE_FILTERED, KEY_STORE_MODE_ALL, G_PARAM_READWRITE));
@@ -1043,13 +789,18 @@
SeahorseObjectPredicate *pred;
GtkCellRenderer *renderer;
gchar *sort;
+ gint last;
- skstore = g_object_new (SEAHORSE_TYPE_KEY_MANAGER_STORE, "keyset", skset, NULL);
+ skstore = g_object_new (SEAHORSE_TYPE_KEY_MANAGER_STORE, "set", skset, NULL);
+ last = seahorse_set_model_set_columns (SEAHORSE_SET_MODEL (skstore), column_info, N_COLS);
+ g_return_val_if_fail (last == N_COLS - 1, NULL);
- populate_store (skstore);
+ /* Setup the sort and filter */
+ skstore->priv->filter = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (GTK_TREE_MODEL (skstore), NULL));
+ gtk_tree_model_filter_set_visible_func (skstore->priv->filter, filter_callback, skstore, NULL);
+ skstore->priv->sort = GTK_TREE_MODEL_SORT (gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (skstore->priv->filter)));
/* The sorted model is the top level model */
- g_assert (GTK_IS_TREE_MODEL (skstore->priv->sort));
gtk_tree_view_set_model (view, GTK_TREE_MODEL (skstore->priv->sort));
/* add the icon column */
@@ -1059,7 +810,7 @@
col = gtk_tree_view_column_new_with_attributes ("", renderer, "stock-id", COL_STOCK_ID, NULL);
gtk_tree_view_column_set_resizable (col, FALSE);
gtk_tree_view_append_column (view, col);
- gtk_tree_view_column_set_sort_column_id (col, COL_PAIR);
+ gtk_tree_view_column_set_sort_column_id (col, COL_USAGE);
/* Name column */
renderer = gtk_cell_renderer_text_new ();
@@ -1130,8 +881,8 @@
return skstore;
}
-SeahorseKey*
-seahorse_key_manager_store_get_key_from_path (GtkTreeView *view, GtkTreePath *path, guint *uid)
+SeahorseObject*
+seahorse_key_manager_store_get_object_from_path (GtkTreeView *view, GtkTreePath *path)
{
GtkTreeModel *model;
GtkTreeIter iter;
@@ -1141,24 +892,24 @@
model = gtk_tree_view_get_model (view);
g_return_val_if_fail (gtk_tree_model_get_iter (model, &iter, path), NULL);
- return key_from_iterator (model, &iter, uid);
+ return object_from_iterator (model, &iter);
}
GList*
-seahorse_key_manager_store_get_all_keys (GtkTreeView *view)
+seahorse_key_manager_store_get_all_objects (GtkTreeView *view)
{
SeahorseKeyManagerStore* skstore;
g_return_val_if_fail (GTK_IS_TREE_VIEW (view), NULL);
skstore = key_store_from_model (gtk_tree_view_get_model (view));
- return seahorse_set_get_objects (skstore->skset);
+ return seahorse_set_get_objects (SEAHORSE_SET_MODEL (skstore)->set);
}
GList*
-seahorse_key_manager_store_get_selected_keys (GtkTreeView *view)
+seahorse_key_manager_store_get_selected_objects (GtkTreeView *view)
{
- SeahorseKey *skey;
- GList *l, *keys = NULL;
+ SeahorseObject *sobj;
+ GList *l, *objects = NULL;
SeahorseKeyManagerStore* skstore;
GList *list, *paths = NULL;
GtkTreeSelection *selection;
@@ -1170,11 +921,11 @@
selection = gtk_tree_view_get_selection (view);
paths = gtk_tree_selection_get_selected_rows (selection, NULL);
- /* make key list */
+ /* make object list */
for (list = paths; list != NULL; list = g_list_next (list)) {
- skey = seahorse_key_manager_store_get_key_from_path (view, list->data, NULL);
- if (skey != NULL)
- keys = g_list_append (keys, skey);
+ sobj = seahorse_key_manager_store_get_object_from_path (view, list->data);
+ if (sobj != NULL)
+ objects = g_list_append (objects, sobj);
}
/* free selected paths */
@@ -1182,81 +933,75 @@
g_list_free (paths);
/* Remove duplicates */
- keys = g_list_sort (keys, compare_pointers);
- for (l = keys; l; l = g_list_next (l)) {
+ objects = g_list_sort (objects, compare_pointers);
+ for (l = objects; l; l = g_list_next (l)) {
while (l->next && l->data == l->next->data)
- keys = g_list_delete_link (keys, l->next);
+ objects = g_list_delete_link (objects, l->next);
}
- return keys;
+ return objects;
}
void
-seahorse_key_manager_store_set_selected_keys (GtkTreeView *view, GList* keys)
+seahorse_key_manager_store_set_selected_objects (GtkTreeView *view, GList* objects)
{
- SeahorseKeyManagerStore* skstore;
- GtkTreeSelection* selection;
- gboolean first = TRUE;
- GtkTreePath *path;
- GList *l;
- GSList *rows, *rl;
- GtkTreeIter it;
-
- g_return_if_fail (GTK_IS_TREE_VIEW (view));
- selection = gtk_tree_view_get_selection (view);
- gtk_tree_selection_unselect_all (selection);
-
- skstore = key_store_from_model (gtk_tree_view_get_model (view));
- g_return_if_fail (SEAHORSE_IS_KEY_MANAGER_STORE (skstore));
-
- for(l = keys; l; l = g_list_next (l)) {
-
- /* Get all the rows for that key .... */
- rows = seahorse_key_model_get_rows_for_key (SEAHORSE_KEY_MODEL (skstore),
- SEAHORSE_KEY (l->data));
- for(rl = rows; rl; rl = g_slist_next (rl)) {
-
- /* And select them ... */
- if (get_upper_iter(skstore, &it, (GtkTreeIter*)rl->data)) {
- gtk_tree_selection_select_iter (selection, &it);
-
- /* Scroll the first row selected into view */
- if (first) {
- path = gtk_tree_model_get_path (gtk_tree_view_get_model (view), &it);
- gtk_tree_view_scroll_to_cell (view, path, NULL, FALSE, 0.0, 0.0);
- gtk_tree_path_free (path);
- first = FALSE;
- }
- }
- }
-
- seahorse_key_model_free_rows (rows);
- }
+ SeahorseKeyManagerStore* skstore;
+ GtkTreeSelection* selection;
+ gboolean first = TRUE;
+ GtkTreePath *path;
+ GList *l;
+ GtkTreeIter iter, upper;
+
+ g_return_if_fail (GTK_IS_TREE_VIEW (view));
+ selection = gtk_tree_view_get_selection (view);
+ gtk_tree_selection_unselect_all (selection);
+
+ skstore = key_store_from_model (gtk_tree_view_get_model (view));
+ g_return_if_fail (SEAHORSE_IS_KEY_MANAGER_STORE (skstore));
+
+ for (l = objects; l; l = g_list_next (l)) {
+ if (seahorse_set_model_iter_for_object (SEAHORSE_SET_MODEL (skstore),
+ SEAHORSE_OBJECT (l->data), &iter)) {
+ /* And select them ... */
+ if (get_upper_iter (skstore, &upper, &iter)) {
+
+ gtk_tree_selection_select_iter (selection, &upper);
+
+ /* Scroll the first row selected into view */
+ if (first) {
+ path = gtk_tree_model_get_path (gtk_tree_view_get_model (view), &upper);
+ gtk_tree_view_scroll_to_cell (view, path, NULL, FALSE, 0.0, 0.0);
+ gtk_tree_path_free (path);
+ first = FALSE;
+ }
+ }
+ }
+ }
}
-SeahorseKey*
-seahorse_key_manager_store_get_selected_key (GtkTreeView *view, guint *uid)
+SeahorseObject*
+seahorse_key_manager_store_get_selected_object (GtkTreeView *view)
{
- SeahorseKeyManagerStore* skstore;
- SeahorseKey *skey = NULL;
- GList *paths = NULL;
- GtkTreeSelection *selection;
-
- g_return_val_if_fail (GTK_IS_TREE_VIEW (view), NULL);
- skstore = key_store_from_model (gtk_tree_view_get_model (view));
- g_return_val_if_fail (SEAHORSE_IS_KEY_MANAGER_STORE (skstore), NULL);
-
- selection = gtk_tree_view_get_selection (view);
- paths = gtk_tree_selection_get_selected_rows (selection, NULL);
-
- /* make key list */
- if (paths != NULL) {
- skey = seahorse_key_manager_store_get_key_from_path (view, paths->data, uid);
+ SeahorseKeyManagerStore* skstore;
+ SeahorseObject *sobj = NULL;
+ GList *paths = NULL;
+ GtkTreeSelection *selection;
+
+ g_return_val_if_fail (GTK_IS_TREE_VIEW (view), NULL);
+ skstore = key_store_from_model (gtk_tree_view_get_model (view));
+ g_return_val_if_fail (SEAHORSE_IS_KEY_MANAGER_STORE (skstore), NULL);
+
+ selection = gtk_tree_view_get_selection (view);
+ paths = gtk_tree_selection_get_selected_rows (selection, NULL);
+
+ /* choose first object */
+ if (paths != NULL) {
+ sobj = seahorse_key_manager_store_get_object_from_path (view, paths->data);
- /* free selected paths */
- g_list_foreach (paths, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (paths);
- }
+ /* free selected paths */
+ g_list_foreach (paths, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free (paths);
+ }
- return skey;
+ return sobj;
}
Modified: trunk/src/seahorse-key-manager-store.h
==============================================================================
--- trunk/src/seahorse-key-manager-store.h (original)
+++ trunk/src/seahorse-key-manager-store.h Fri Jul 18 22:05:15 2008
@@ -27,7 +27,7 @@
#include "seahorse-context.h"
#include "seahorse-set.h"
-#include "seahorse-key-model.h"
+#include "seahorse-set-model.h"
#define SEAHORSE_TYPE_KEY_MANAGER_STORE (seahorse_key_manager_store_get_type ())
#define SEAHORSE_KEY_MANAGER_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_KEY_MANAGER_STORE, SeahorseKeyManagerStore))
@@ -41,39 +41,34 @@
typedef struct _SeahorseKeyManagerStoreClass SeahorseKeyManagerStoreClass;
typedef enum _SeahorseKeyManagerStoreMode {
- KEY_STORE_MODE_ALL,
- KEY_STORE_MODE_FILTERED
+ KEY_STORE_MODE_ALL,
+ KEY_STORE_MODE_FILTERED
} SeahorseKeyManagerStoreMode;
struct _SeahorseKeyManagerStore {
- SeahorseKeyModel parent;
-
- /*< public >*/
- SeahorseSet *skset;
-
- /*< private >*/
- SeahorseKeyManagerStorePriv *priv;
+ SeahorseSetModel parent;
+
+ /*< private >*/
+ SeahorseKeyManagerStorePriv *priv;
};
struct _SeahorseKeyManagerStoreClass {
- SeahorseKeyModelClass parent_class;
+ SeahorseSetModelClass parent_class;
};
-SeahorseKeyManagerStore* seahorse_key_manager_store_new (SeahorseSet *skset,
- GtkTreeView *view);
+SeahorseKeyManagerStore* seahorse_key_manager_store_new (SeahorseSet *skset,
+ GtkTreeView *view);
-SeahorseKey* seahorse_key_manager_store_get_key_from_path (GtkTreeView *view,
- GtkTreePath *path,
- guint *uid);
+SeahorseObject* seahorse_key_manager_store_get_object_from_path (GtkTreeView *view,
+ GtkTreePath *path);
-GList* seahorse_key_manager_store_get_all_keys (GtkTreeView *view);
+GList* seahorse_key_manager_store_get_all_objects (GtkTreeView *view);
-void seahorse_key_manager_store_set_selected_keys (GtkTreeView *view,
- GList* keys);
+void seahorse_key_manager_store_set_selected_objects (GtkTreeView *view,
+ GList* objects);
-GList* seahorse_key_manager_store_get_selected_keys (GtkTreeView *view);
+GList* seahorse_key_manager_store_get_selected_objects (GtkTreeView *view);
-SeahorseKey* seahorse_key_manager_store_get_selected_key (GtkTreeView *view,
- guint *uid);
+SeahorseObject* seahorse_key_manager_store_get_selected_object (GtkTreeView *view);
#endif /* __SEAHORSE_KEY_MANAGER_STORE_H__ */
Modified: trunk/src/seahorse-key-manager.c
==============================================================================
--- trunk/src/seahorse-key-manager.c (original)
+++ trunk/src/seahorse-key-manager.c Fri Jul 18 22:05:15 2008
@@ -94,7 +94,6 @@
static SeahorseKeyManager* seahorse_key_manager_new (const char* ident);
static GList* seahorse_key_manager_real_get_selected_objects (SeahorseView* base);
static void seahorse_key_manager_real_set_selected_objects (SeahorseView* base, GList* objects);
-static SeahorseObject* seahorse_key_manager_real_get_selected_object_and_uid (SeahorseView* base, guint* uid);
static SeahorseKeyManagerTabInfo* seahorse_key_manager_get_tab_for_object (SeahorseKeyManager* self, SeahorseObject* obj);
static GtkTreeView* seahorse_key_manager_get_current_view (SeahorseKeyManager* self);
static guint seahorse_key_manager_get_tab_id (SeahorseKeyManager* self, SeahorseKeyManagerTabInfo* tab);
@@ -235,7 +234,7 @@
if (tab == NULL) {
return NULL;
}
- return seahorse_key_manager_store_get_selected_keys ((*tab).view);
+ return seahorse_key_manager_store_get_selected_objects ((*tab).view);
}
@@ -292,7 +291,7 @@
highest_tab = tab;
}
/* Select the objects on that tab */
- seahorse_key_manager_store_set_selected_keys ((*tab).view, list);
+ seahorse_key_manager_store_set_selected_objects ((*tab).view, list);
}
}
/* Change to the tab with the most objects */
@@ -303,18 +302,6 @@
}
-static SeahorseObject* seahorse_key_manager_real_get_selected_object_and_uid (SeahorseView* base, guint* uid) {
- SeahorseKeyManager * self;
- SeahorseKeyManagerTabInfo* tab;
- self = SEAHORSE_KEY_MANAGER (base);
- tab = seahorse_key_manager_get_tab_info (self, -1);
- if (tab == NULL) {
- return NULL;
- }
- return SEAHORSE_OBJECT (seahorse_key_manager_store_get_selected_key ((*tab).view, &(*uid)));
-}
-
-
static SeahorseKeyManagerTabInfo* seahorse_key_manager_get_tab_for_object (SeahorseKeyManager* self, SeahorseObject* obj) {
g_return_val_if_fail (SEAHORSE_IS_KEY_MANAGER (self), NULL);
g_return_val_if_fail (SEAHORSE_IS_OBJECT (obj), NULL);
@@ -485,18 +472,18 @@
static void seahorse_key_manager_on_row_activated (SeahorseKeyManager* self, GtkTreeView* view, GtkTreePath* path, GtkTreeViewColumn* column) {
- SeahorseKey* _tmp0;
- SeahorseKey* key;
+ SeahorseObject* _tmp0;
+ SeahorseObject* obj;
g_return_if_fail (SEAHORSE_IS_KEY_MANAGER (self));
g_return_if_fail (GTK_IS_TREE_VIEW (view));
g_return_if_fail (path != NULL);
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (column));
_tmp0 = NULL;
- key = (_tmp0 = seahorse_key_manager_store_get_key_from_path (view, path, NULL), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
- if (key != NULL) {
- seahorse_viewer_show_properties (SEAHORSE_VIEWER (self), SEAHORSE_OBJECT (key));
+ obj = (_tmp0 = seahorse_key_manager_store_get_object_from_path (view, path), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
+ if (obj != NULL) {
+ seahorse_viewer_show_properties (SEAHORSE_VIEWER (self), obj);
}
- (key == NULL ? NULL : (key = (g_object_unref (key), NULL)));
+ (obj == NULL ? NULL : (obj = (g_object_unref (obj), NULL)));
}
@@ -707,7 +694,7 @@
* BUG: We cast to get around this bug:
* http://bugzilla.gnome.org/show_bug.cgi?id=540662
*/
- input = G_MEMORY_INPUT_STREAM (g_memory_input_stream_new_from_data (text, len, g_free));
+ input = G_MEMORY_INPUT_STREAM (((GMemoryInputStream*) (g_memory_input_stream_new_from_data (text, len, g_free))));
op = seahorse_source_import (sksrc, G_INPUT_STREAM (input));
seahorse_progress_show (op, _ ("Importing Keys"), TRUE);
seahorse_operation_watch (op, _seahorse_key_manager_imported_keys_seahorse_done_func, self, NULL, NULL);
@@ -1013,7 +1000,7 @@
if (tab == NULL) {
return NULL;
}
- return SEAHORSE_OBJECT (seahorse_key_manager_store_get_selected_key ((*tab).view, NULL));
+ return seahorse_key_manager_store_get_selected_object ((*tab).view);
}
@@ -1024,6 +1011,7 @@
objects = g_list_prepend (objects, value);
seahorse_viewer_set_selected_objects (SEAHORSE_VIEWER (self), objects);
(objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
+ g_object_notify (((GObject *) (self)), "selected");
}
@@ -1232,21 +1220,21 @@
GtkLabel* _tmp17;
GtkToolItem* item;
/* Insert a separator to right align the filter */
- sep = g_object_ref_sink (gtk_separator_tool_item_new ());
+ sep = g_object_ref_sink (((GtkSeparatorToolItem*) (gtk_separator_tool_item_new ())));
gtk_separator_tool_item_set_draw (sep, FALSE);
gtk_tool_item_set_expand (GTK_TOOL_ITEM (sep), TRUE);
gtk_widget_show_all (GTK_WIDGET (sep));
gtk_toolbar_insert (toolbar, GTK_TOOL_ITEM (sep), -1);
/* Insert a filter bar */
- box = GTK_BOX (g_object_ref_sink (gtk_hbox_new (FALSE, 0)));
+ box = GTK_BOX (g_object_ref_sink (((GtkHBox*) (gtk_hbox_new (FALSE, 0)))));
_tmp15 = NULL;
- gtk_box_pack_start (box, GTK_WIDGET ((_tmp15 = g_object_ref_sink (gtk_label_new (_ ("Filter:"))))), FALSE, TRUE, ((guint) (3)));
+ gtk_box_pack_start (box, GTK_WIDGET ((_tmp15 = g_object_ref_sink (((GtkLabel*) (gtk_label_new (_ ("Filter:"))))))), FALSE, TRUE, ((guint) (3)));
(_tmp15 == NULL ? NULL : (_tmp15 = (g_object_unref (_tmp15), NULL)));
_tmp16 = NULL;
- self->priv->_filter_entry = (_tmp16 = g_object_ref_sink (gtk_entry_new ()), (self->priv->_filter_entry == NULL ? NULL : (self->priv->_filter_entry = (g_object_unref (self->priv->_filter_entry), NULL))), _tmp16);
+ self->priv->_filter_entry = (_tmp16 = g_object_ref_sink (((GtkEntry*) (gtk_entry_new ()))), (self->priv->_filter_entry == NULL ? NULL : (self->priv->_filter_entry = (g_object_unref (self->priv->_filter_entry), NULL))), _tmp16);
gtk_box_pack_start (box, GTK_WIDGET (self->priv->_filter_entry), FALSE, TRUE, ((guint) (0)));
_tmp17 = NULL;
- gtk_box_pack_start (box, GTK_WIDGET ((_tmp17 = g_object_ref_sink (gtk_label_new (NULL)))), FALSE, FALSE, ((guint) (0)));
+ gtk_box_pack_start (box, GTK_WIDGET ((_tmp17 = g_object_ref_sink (((GtkLabel*) (gtk_label_new (NULL)))))), FALSE, FALSE, ((guint) (0)));
(_tmp17 == NULL ? NULL : (_tmp17 = (g_object_unref (_tmp17), NULL)));
gtk_widget_show_all (GTK_WIDGET (box));
item = g_object_ref_sink (gtk_tool_item_new ());
@@ -1334,7 +1322,6 @@
G_OBJECT_CLASS (klass)->dispose = seahorse_key_manager_dispose;
SEAHORSE_VIEWER_CLASS (klass)->get_selected_objects = seahorse_key_manager_real_get_selected_objects;
SEAHORSE_VIEWER_CLASS (klass)->set_selected_objects = seahorse_key_manager_real_set_selected_objects;
- SEAHORSE_VIEWER_CLASS (klass)->get_selected_object_and_uid = seahorse_key_manager_real_get_selected_object_and_uid;
g_object_class_override_property (G_OBJECT_CLASS (klass), SEAHORSE_KEY_MANAGER_SELECTED, "selected");
}
@@ -1343,7 +1330,6 @@
seahorse_key_manager_seahorse_view_parent_iface = g_type_interface_peek_parent (iface);
iface->get_selected_objects = seahorse_key_manager_real_get_selected_objects;
iface->set_selected_objects = seahorse_key_manager_real_set_selected_objects;
- iface->get_selected_object_and_uid = seahorse_key_manager_real_get_selected_object_and_uid;
}
Modified: trunk/src/seahorse-key-manager.vala
==============================================================================
--- trunk/src/seahorse-key-manager.vala (original)
+++ trunk/src/seahorse-key-manager.vala Fri Jul 18 22:05:15 2008
@@ -278,7 +278,7 @@
TabInfo* tab = get_tab_info ();
if (tab == null)
return new List<weak Object>();
- return KeyManagerStore.get_selected_keys (tab->view);
+ return KeyManagerStore.get_selected_objects (tab->view);
}
public override void set_selected_objects (List<Object> objects) {
@@ -308,7 +308,7 @@
}
/* Select the objects on that tab */
- KeyManagerStore.set_selected_keys (tab->view, list);
+ KeyManagerStore.set_selected_objects (tab->view, list);
}
/* Change to the tab with the most objects */
@@ -321,7 +321,7 @@
TabInfo* tab = get_tab_info ();
if (tab == null)
return null;
- return KeyManagerStore.get_selected_key (tab->view, null);
+ return KeyManagerStore.get_selected_object (tab->view);
}
set {
List<weak Object> objects = new List<weak Object>();
@@ -330,13 +330,6 @@
}
}
- public override weak Object? get_selected_object_and_uid (out uint uid) {
- TabInfo* tab = get_tab_info ();
- if (tab == null)
- return null;
- return KeyManagerStore.get_selected_key (tab->view, out uid);
- }
-
private TabInfo* get_tab_for_object (Object obj) {
for (int i = 0; i < (int)Tabs.NUM_TABS; ++i) {
TabInfo* tab = &_tabs[i];
@@ -435,9 +428,9 @@
private void on_row_activated (Gtk.TreeView view, Gtk.TreePath path,
Gtk.TreeViewColumn column) {
- Key key = KeyManagerStore.get_key_from_path (view, path, null);
- if (key != null)
- show_properties (key);
+ Object obj = KeyManagerStore.get_object_from_path (view, path);
+ if (obj != null)
+ show_properties (obj);
}
private bool on_key_list_button_pressed (Gtk.Widget widget, Gdk.EventButton event) {
Modified: trunk/src/seahorse-keyserver-results.c
==============================================================================
--- trunk/src/seahorse-keyserver-results.c (original)
+++ trunk/src/seahorse-keyserver-results.c Fri Jul 18 22:05:15 2008
@@ -39,7 +39,7 @@
struct _SeahorseKeyserverResultsPrivate {
char* _search_string;
GtkTreeView* _view;
- GtkActionGroup* _key_actions;
+ GtkActionGroup* _object_actions;
SeahorseKeyManagerStore* _store;
SeahorseSet* _objects;
SeahorseObjectPredicate _pred;
@@ -54,7 +54,6 @@
static SeahorseKeyserverResults* seahorse_keyserver_results_new (const char* search_text);
static GList* seahorse_keyserver_results_real_get_selected_objects (SeahorseView* base);
static void seahorse_keyserver_results_real_set_selected_objects (SeahorseView* base, GList* keys);
-static SeahorseObject* seahorse_keyserver_results_real_get_selected_object_and_uid (SeahorseView* base, guint* uid);
static gboolean seahorse_keyserver_results_on_filter_objects (SeahorseKeyserverResults* self, SeahorseObject* obj);
static gboolean _seahorse_keyserver_results_fire_selection_changed_gsource_func (gpointer self);
static void seahorse_keyserver_results_on_view_selection_changed (SeahorseKeyserverResults* self, GtkTreeSelection* selection);
@@ -140,7 +139,7 @@
static GList* seahorse_keyserver_results_real_get_selected_objects (SeahorseView* base) {
SeahorseKeyserverResults * self;
self = SEAHORSE_KEYSERVER_RESULTS (base);
- return seahorse_key_manager_store_get_selected_keys (self->priv->_view);
+ return seahorse_key_manager_store_get_selected_objects (self->priv->_view);
}
@@ -148,14 +147,7 @@
SeahorseKeyserverResults * self;
self = SEAHORSE_KEYSERVER_RESULTS (base);
g_return_if_fail (keys != NULL);
- seahorse_key_manager_store_set_selected_keys (self->priv->_view, keys);
-}
-
-
-static SeahorseObject* seahorse_keyserver_results_real_get_selected_object_and_uid (SeahorseView* base, guint* uid) {
- SeahorseKeyserverResults * self;
- self = SEAHORSE_KEYSERVER_RESULTS (base);
- return SEAHORSE_OBJECT (seahorse_key_manager_store_get_selected_key (self->priv->_view, &(*uid)));
+ seahorse_key_manager_store_set_selected_objects (self->priv->_view, keys);
}
@@ -190,18 +182,18 @@
static void seahorse_keyserver_results_on_row_activated (SeahorseKeyserverResults* self, GtkTreeView* view, GtkTreePath* path, GtkTreeViewColumn* column) {
- SeahorseKey* _tmp0;
- SeahorseKey* key;
+ SeahorseObject* _tmp0;
+ SeahorseObject* obj;
g_return_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self));
g_return_if_fail (GTK_IS_TREE_VIEW (view));
g_return_if_fail (path != NULL);
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (column));
_tmp0 = NULL;
- key = (_tmp0 = seahorse_key_manager_store_get_key_from_path (view, path, NULL), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
- if (key != NULL) {
- seahorse_viewer_show_properties (SEAHORSE_VIEWER (self), SEAHORSE_OBJECT (key));
+ obj = (_tmp0 = seahorse_key_manager_store_get_object_from_path (view, path), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
+ if (obj != NULL) {
+ seahorse_viewer_show_properties (SEAHORSE_VIEWER (self), obj);
}
- (key == NULL ? NULL : (key = (g_object_unref (key), NULL)));
+ (obj == NULL ? NULL : (obj = (g_object_unref (obj), NULL)));
}
@@ -315,7 +307,7 @@
selection = (_tmp0 = gtk_tree_view_get_selection (self->priv->_view), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
rows = gtk_tree_selection_count_selected_rows (selection);
seahorse_viewer_set_numbered_status (SEAHORSE_VIEWER (self), ngettext ("Selected %d key", "Selected %d keys", rows), rows);
- gtk_action_group_set_sensitive (self->priv->_key_actions, rows > 0);
+ gtk_action_group_set_sensitive (self->priv->_object_actions, rows > 0);
g_signal_emit_by_name (G_OBJECT (SEAHORSE_VIEW (self)), "selection-changed");
return (_tmp1 = FALSE, (selection == NULL ? NULL : (selection = (g_object_unref (selection), NULL))), _tmp1);
}
@@ -338,12 +330,13 @@
_tmp2 = NULL;
self->priv->_search_string = (_tmp2 = g_utf8_casefold (g_strstrip (str), -1), (self->priv->_search_string = (g_free (self->priv->_search_string), NULL)), _tmp2);
str = (g_free (str), NULL);
+ g_object_notify (((GObject *) (self)), "search");
}
static SeahorseObject* seahorse_keyserver_results_real_get_selected (SeahorseKeyserverResults* self) {
g_return_val_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self), NULL);
- return SEAHORSE_OBJECT (seahorse_key_manager_store_get_selected_key (self->priv->_view, NULL));
+ return seahorse_key_manager_store_get_selected_object (self->priv->_view);
}
@@ -356,6 +349,7 @@
}
seahorse_viewer_set_selected_objects (SEAHORSE_VIEWER (self), keys);
(keys == NULL ? NULL : (keys = (g_list_free (keys), NULL)));
+ g_object_notify (((GObject *) (self)), "selected");
}
@@ -460,12 +454,12 @@
g_signal_connect_object (gtk_action_group_get_action (actions, "remote-find"), "activate", ((GCallback) (_seahorse_keyserver_results_on_remote_find_gtk_action_activate)), self, 0);
seahorse_viewer_include_actions (SEAHORSE_VIEWER (self), actions);
_tmp4 = NULL;
- self->priv->_key_actions = (_tmp4 = gtk_action_group_new ("key"), (self->priv->_key_actions == NULL ? NULL : (self->priv->_key_actions = (g_object_unref (self->priv->_key_actions), NULL))), _tmp4);
- gtk_action_group_set_translation_domain (self->priv->_key_actions, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (self->priv->_key_actions, SEAHORSE_KEYSERVER_RESULTS_KEY_ENTRIES, G_N_ELEMENTS (SEAHORSE_KEYSERVER_RESULTS_KEY_ENTRIES), self);
- g_signal_connect_object (gtk_action_group_get_action (self->priv->_key_actions, "key-import-keyring"), "activate", ((GCallback) (_seahorse_keyserver_results_on_key_import_keyring_gtk_action_activate)), self, 0);
- g_object_set (gtk_action_group_get_action (self->priv->_key_actions, "key-import-keyring"), "is-important", TRUE, NULL);
- seahorse_viewer_include_actions (SEAHORSE_VIEWER (self), self->priv->_key_actions);
+ self->priv->_object_actions = (_tmp4 = gtk_action_group_new ("key"), (self->priv->_object_actions == NULL ? NULL : (self->priv->_object_actions = (g_object_unref (self->priv->_object_actions), NULL))), _tmp4);
+ gtk_action_group_set_translation_domain (self->priv->_object_actions, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (self->priv->_object_actions, SEAHORSE_KEYSERVER_RESULTS_KEY_ENTRIES, G_N_ELEMENTS (SEAHORSE_KEYSERVER_RESULTS_KEY_ENTRIES), self);
+ g_signal_connect_object (gtk_action_group_get_action (self->priv->_object_actions, "key-import-keyring"), "activate", ((GCallback) (_seahorse_keyserver_results_on_key_import_keyring_gtk_action_activate)), self, 0);
+ g_object_set (gtk_action_group_get_action (self->priv->_object_actions, "key-import-keyring"), "is-important", TRUE, NULL);
+ seahorse_viewer_include_actions (SEAHORSE_VIEWER (self), self->priv->_object_actions);
/* init key list & selection settings */
_tmp7 = NULL;
_tmp6 = NULL;
@@ -542,7 +536,6 @@
G_OBJECT_CLASS (klass)->dispose = seahorse_keyserver_results_dispose;
SEAHORSE_VIEWER_CLASS (klass)->get_selected_objects = seahorse_keyserver_results_real_get_selected_objects;
SEAHORSE_VIEWER_CLASS (klass)->set_selected_objects = seahorse_keyserver_results_real_set_selected_objects;
- SEAHORSE_VIEWER_CLASS (klass)->get_selected_object_and_uid = seahorse_keyserver_results_real_get_selected_object_and_uid;
g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_KEYSERVER_RESULTS_SEARCH, g_param_spec_string ("search", "search", "search", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_override_property (G_OBJECT_CLASS (klass), SEAHORSE_KEYSERVER_RESULTS_SELECTED, "selected");
}
@@ -552,7 +545,6 @@
seahorse_keyserver_results_seahorse_view_parent_iface = g_type_interface_peek_parent (iface);
iface->get_selected_objects = seahorse_keyserver_results_real_get_selected_objects;
iface->set_selected_objects = seahorse_keyserver_results_real_set_selected_objects;
- iface->get_selected_object_and_uid = seahorse_keyserver_results_real_get_selected_object_and_uid;
}
@@ -566,7 +558,7 @@
self = SEAHORSE_KEYSERVER_RESULTS (obj);
self->priv->_search_string = (g_free (self->priv->_search_string), NULL);
(self->priv->_view == NULL ? NULL : (self->priv->_view = (g_object_unref (self->priv->_view), NULL)));
- (self->priv->_key_actions == NULL ? NULL : (self->priv->_key_actions = (g_object_unref (self->priv->_key_actions), NULL)));
+ (self->priv->_object_actions == NULL ? NULL : (self->priv->_object_actions = (g_object_unref (self->priv->_object_actions), NULL)));
(self->priv->_store == NULL ? NULL : (self->priv->_store = (g_object_unref (self->priv->_store), NULL)));
(self->priv->_objects == NULL ? NULL : (self->priv->_objects = (g_object_unref (self->priv->_objects), NULL)));
G_OBJECT_CLASS (seahorse_keyserver_results_parent_class)->dispose (obj);
Modified: trunk/src/seahorse-keyserver-results.vala
==============================================================================
--- trunk/src/seahorse-keyserver-results.vala (original)
+++ trunk/src/seahorse-keyserver-results.vala Fri Jul 18 22:05:15 2008
@@ -28,7 +28,7 @@
private string _search_string;
private Gtk.TreeView _view;
- private Gtk.ActionGroup _key_actions;
+ private Gtk.ActionGroup _object_actions;
private KeyManagerStore _store;
private Set _objects;
private Object.Predicate _pred;
@@ -86,12 +86,12 @@
actions.get_action ("remote-find").activate += on_remote_find;
include_actions (actions);
- _key_actions = new Gtk.ActionGroup("key");
- _key_actions.set_translation_domain (Config.GETTEXT_PACKAGE);
- _key_actions.add_actions (KEY_ENTRIES, this);
- _key_actions.get_action ("key-import-keyring").activate += on_key_import_keyring;
- _key_actions.get_action ("key-import-keyring").is_important = true;
- include_actions (_key_actions);
+ _object_actions = new Gtk.ActionGroup("key");
+ _object_actions.set_translation_domain (Config.GETTEXT_PACKAGE);
+ _object_actions.add_actions (KEY_ENTRIES, this);
+ _object_actions.get_action ("key-import-keyring").activate += on_key_import_keyring;
+ _object_actions.get_action ("key-import-keyring").is_important = true;
+ include_actions (_object_actions);
/* init key list & selection settings */
@@ -143,15 +143,15 @@
}
public override List<weak Object> get_selected_objects () {
- return KeyManagerStore.get_selected_keys (_view);
+ return KeyManagerStore.get_selected_objects (_view);
}
public override void set_selected_objects (List<Object> keys) {
- KeyManagerStore.set_selected_keys (_view, keys);
+ KeyManagerStore.set_selected_objects (_view, keys);
}
public override weak Object? selected {
- get { return KeyManagerStore.get_selected_key (_view, null); }
+ get { return KeyManagerStore.get_selected_object (_view); }
set {
List<weak Object> keys = new List<weak Object>();
if (value != null)
@@ -160,10 +160,6 @@
}
}
- public override weak Object? get_selected_object_and_uid (out uint uid) {
- return KeyManagerStore.get_selected_key (_view, out uid);
- }
-
private bool on_filter_objects (Object obj) {
if (_search_string.len() == 0)
return true;
@@ -178,9 +174,9 @@
private void on_row_activated (Gtk.TreeView view, Gtk.TreePath path,
Gtk.TreeViewColumn column) {
- Key key = KeyManagerStore.get_key_from_path (view, path, null);
- if (key != null)
- show_properties (key);
+ Object? obj = KeyManagerStore.get_object_from_path (view, path);
+ if (obj != null)
+ show_properties (obj);
}
private bool on_key_list_button_pressed (Gtk.Widget widget, Gdk.EventButton event) {
@@ -251,7 +247,7 @@
set_numbered_status (Bugs.ngettext ("Selected %d key",
"Selected %d keys", rows), rows);
- _key_actions.set_sensitive (rows > 0);
+ _object_actions.set_sensitive (rows > 0);
this.selection_changed();
return false;
Modified: trunk/src/seahorse-viewer.c
==============================================================================
--- trunk/src/seahorse-viewer.c (original)
+++ trunk/src/seahorse-viewer.c Fri Jul 18 22:05:15 2008
@@ -282,7 +282,7 @@
seahorse_viewer__about_initialized = TRUE;
gtk_about_dialog_set_url_hook (_seahorse_viewer_on_about_link_clicked_gtk_about_dialog_activate_link_func, NULL, NULL);
}
- about = g_object_ref_sink (gtk_about_dialog_new ());
+ about = g_object_ref_sink (((GtkAboutDialog*) (gtk_about_dialog_new ())));
gtk_about_dialog_set_artists (about, artists);
gtk_about_dialog_set_authors (about, authors);
gtk_about_dialog_set_documenters (about, documenters);
@@ -463,7 +463,7 @@
if (num == 1) {
char* _tmp1;
_tmp1 = NULL;
- prompt = (_tmp1 = g_strdup_printf (_ ("%s is a private key. Are you sure you want to proceed?"), seahorse_object_get_description (((SeahorseObject*) (((SeahorseObject*) (objects->data)))))), (prompt = (g_free (prompt), NULL)), _tmp1);
+ prompt = (_tmp1 = g_strdup_printf (_ ("%s is a private key. Are you sure you want to proceed?"), seahorse_object_get_display_name (((SeahorseObject*) (((SeahorseObject*) (objects->data)))))), (prompt = (g_free (prompt), NULL)), _tmp1);
} else {
char* _tmp3;
const char* _tmp2;
@@ -579,7 +579,7 @@
(objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
return;
}
- output = G_OUTPUT_STREAM (g_memory_output_stream_new (NULL, ((gulong) (0)), _g_realloc_grealloc_func, _g_free_gdestroy_notify));
+ output = G_OUTPUT_STREAM (((GMemoryOutputStream*) (g_memory_output_stream_new (NULL, ((gulong) (0)), _g_realloc_grealloc_func, _g_free_gdestroy_notify))));
op = seahorse_source_export_objects (objects, output);
seahorse_progress_show (op, _ ("Retrieving keys"), TRUE);
seahorse_operation_watch (op, _seahorse_viewer_on_copy_complete_seahorse_done_func, self, NULL, NULL);
@@ -733,6 +733,7 @@
objects = g_list_prepend (objects, value);
seahorse_viewer_set_selected_objects (self, objects);
(objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
+ g_object_notify (((GObject *) (self)), "selected");
}
@@ -923,7 +924,6 @@
seahorse_viewer_seahorse_view_parent_iface = g_type_interface_peek_parent (iface);
iface->get_selected_objects = seahorse_viewer_get_selected_objects;
iface->set_selected_objects = seahorse_viewer_set_selected_objects;
- iface->get_selected_object_and_uid = seahorse_viewer_get_selected_object_and_uid;
}
Modified: trunk/src/seahorse-viewer.vala
==============================================================================
--- trunk/src/seahorse-viewer.vala (original)
+++ trunk/src/seahorse-viewer.vala Fri Jul 18 22:05:15 2008
@@ -305,7 +305,7 @@
if (object.usage == Usage.PRIVATE_KEY) {
string prompt;
if (num == 1)
- prompt = _("%s is a private key. Are you sure you want to proceed?").printf(objects.data.description);
+ prompt = _("%s is a private key. Are you sure you want to proceed?").printf(objects.data.display_name);
else
prompt = _("One or more of the deleted keys are private keys. Are you sure you want to proceed?");
if (!Util.prompt_delete (prompt))
Modified: trunk/src/vala-build.stamp
==============================================================================
--- trunk/src/vala-build.stamp (original)
+++ trunk/src/vala-build.stamp Fri Jul 18 22:05:15 2008
@@ -1 +1 @@
-1216254703
+1216417260
Modified: trunk/ssh/seahorse-ssh-commands.c
==============================================================================
--- trunk/ssh/seahorse-ssh-commands.c (original)
+++ trunk/ssh/seahorse-ssh-commands.c Fri Jul 18 22:05:15 2008
@@ -84,7 +84,7 @@
if (num == 1) {
char* _tmp0;
_tmp0 = NULL;
- prompt = (_tmp0 = g_strdup_printf (_ ("Are you sure you want to delete the secure shell key '%s'?"), seahorse_object_get_description (((SeahorseObject*) (((SeahorseObject*) (keys->data)))))), (prompt = (g_free (prompt), NULL)), _tmp0);
+ prompt = (_tmp0 = g_strdup_printf (_ ("Are you sure you want to delete the secure shell key '%s'?"), seahorse_object_get_display_name (((SeahorseObject*) (((SeahorseObject*) (keys->data)))))), (prompt = (g_free (prompt), NULL)), _tmp0);
} else {
char* _tmp1;
_tmp1 = NULL;
Modified: trunk/ssh/seahorse-ssh-commands.vala
==============================================================================
--- trunk/ssh/seahorse-ssh-commands.vala (original)
+++ trunk/ssh/seahorse-ssh-commands.vala Fri Jul 18 22:05:15 2008
@@ -74,7 +74,7 @@
string prompt;
if (num == 1)
- prompt = _("Are you sure you want to delete the secure shell key '%s'?").printf(keys.data.description);
+ prompt = _("Are you sure you want to delete the secure shell key '%s'?").printf(keys.data.display_name);
else
prompt = _("Are you sure you want to delete %d secure shell keys?").printf(num);
Modified: trunk/ssh/seahorse-ssh-key.c
==============================================================================
--- trunk/ssh/seahorse-ssh-key.c (original)
+++ trunk/ssh/seahorse-ssh-key.c Fri Jul 18 22:05:15 2008
@@ -227,8 +227,7 @@
g_value_set_uint (value, skey->keydata ? skey->keydata->length : 0);
break;
case PROP_STOCK_ID:
- /* We use a pointer so we don't copy the string every time */
- g_value_set_pointer (value, SEAHORSE_STOCK_KEY_SSH);
+ g_value_set_string (value, SEAHORSE_STOCK_KEY_SSH);
break;
}
}
@@ -329,8 +328,8 @@
0, G_MAXUINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, PROP_STOCK_ID,
- g_param_spec_pointer ("stock-id", "The stock icon", "The stock icon id",
- G_PARAM_READABLE));
+ g_param_spec_string ("stock-id", "The stock icon", "The stock icon id",
+ NULL, G_PARAM_READABLE));
}
/* -----------------------------------------------------------------------------
Modified: trunk/ssh/seahorse-ssh-key.h
==============================================================================
--- trunk/ssh/seahorse-ssh-key.h (original)
+++ trunk/ssh/seahorse-ssh-key.h Fri Jul 18 22:05:15 2008
@@ -33,7 +33,7 @@
* trust: (SeahorseValidity) Trust for the key.
* expires: (gulong) Date this key expires or 0.
* length: (guint) The length of the key in bits.
- * stock-id: (gpointer/string) The stock icon id.
+ * stock-id: (string) The stock icon id.
*/
#ifndef __SEAHORSE_SSH_KEY_H__
Modified: trunk/ssh/vala-build.stamp
==============================================================================
--- trunk/ssh/vala-build.stamp (original)
+++ trunk/ssh/vala-build.stamp Fri Jul 18 22:05:15 2008
@@ -1 +1 @@
-1216254350
+1216417251
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]