seahorse r2672 - in trunk: . libseahorse pgp src



Author: nnielsen
Date: Tue Dec 16 17:27:25 2008
New Revision: 2672
URL: http://svn.gnome.org/viewvc/seahorse?rev=2672&view=rev

Log:
	* src/seahorse-key-manager-store.c: Fix cyclical reference,
	with the filter and sort models.
	
	* libseahorse/seahorse-context.c: Don't automatically try 
	and refresh remote key sources.
	
	* libseahorse/seahorse-object.c: Don't try to realize properties
	for which we already have a value.

2008-12-16  Stef Walter  <stef memberwebs com>
	
	* pgp/seahorse-gpgme-key.c:
	* pgp/seahorse-hkp-source.c:
	* pgp/seahorse-ldap-source.c:
	* pgp/seahorse-pgp-key.c:
	* src/seahorse-keyserver-results.c: Fix bugs relating to searching
	for remote keys, that resulted from recent refactoring.


Modified:
   trunk/ChangeLog
   trunk/libseahorse/seahorse-context.c
   trunk/libseahorse/seahorse-object.c
   trunk/pgp/seahorse-gpgme-key.c
   trunk/pgp/seahorse-hkp-source.c
   trunk/pgp/seahorse-ldap-source.c
   trunk/pgp/seahorse-pgp-key.c
   trunk/src/seahorse-key-manager-store.c
   trunk/src/seahorse-key-manager.c
   trunk/src/seahorse-keyserver-results.c

Modified: trunk/libseahorse/seahorse-context.c
==============================================================================
--- trunk/libseahorse/seahorse-context.c	(original)
+++ trunk/libseahorse/seahorse-context.c	Tue Dec 16 17:27:25 2008
@@ -271,7 +271,8 @@
 	g_return_val_if_fail (SEAHORSE_IS_SOURCE (sksrc), FALSE);
 	if (!g_slist_find (sctx->pv->sources, sksrc)) {
 		sctx->pv->sources = g_slist_append (sctx->pv->sources, sksrc);
-		if (sctx->pv->refresh_ops) {
+		if (seahorse_source_get_location (sksrc) == SEAHORSE_LOCATION_LOCAL && 
+		    sctx->pv->refresh_ops != NULL) {
 			operation = seahorse_source_load (sksrc);
 			g_return_val_if_fail (operation, TRUE);
 			seahorse_multi_operation_take (sctx->pv->refresh_ops, operation);

Modified: trunk/libseahorse/seahorse-object.c
==============================================================================
--- trunk/libseahorse/seahorse-object.c	(original)
+++ trunk/libseahorse/seahorse-object.c	Tue Dec 16 17:27:25 2008
@@ -249,7 +249,8 @@
 	self->pv->description = g_strdup ("");
 	self->pv->icon = g_strdup ("gtk-missing-image");
 	self->pv->identifier = g_strdup ("");
-	self->pv->location = SEAHORSE_LOCATION_LOCAL;
+	self->pv->location = SEAHORSE_LOCATION_INVALID;
+	self->pv->usage = SEAHORSE_USAGE_NONE;
 }
 
 static void
@@ -601,7 +602,8 @@
 seahorse_object_get_id (SeahorseObject *self)
 {
 	g_return_val_if_fail (SEAHORSE_IS_OBJECT (self), 0);
-	seahorse_object_realize (self);
+	if (!self->pv->id)
+		seahorse_object_realize (self);
 	return self->pv->id;
 }
 
@@ -609,7 +611,8 @@
 seahorse_object_get_tag (SeahorseObject *self)
 {
 	g_return_val_if_fail (SEAHORSE_IS_OBJECT (self), 0);
-	seahorse_object_realize (self);
+	if (!self->pv->tag)
+		seahorse_object_realize (self);
 	return self->pv->tag;	
 }
 
@@ -674,7 +677,6 @@
 seahorse_object_get_parent (SeahorseObject *self)
 {
 	g_return_val_if_fail (SEAHORSE_IS_OBJECT (self), NULL);
-	seahorse_object_realize (self);
 	return self->pv->parent;
 }
 
@@ -767,7 +769,8 @@
 seahorse_object_get_location (SeahorseObject *self)
 {
 	g_return_val_if_fail (SEAHORSE_IS_OBJECT (self), SEAHORSE_LOCATION_INVALID);
-	seahorse_object_realize (self);
+	if (self->pv->location == SEAHORSE_LOCATION_INVALID)
+		seahorse_object_realize (self);
 	return self->pv->location;
 }
 
@@ -775,7 +778,8 @@
 seahorse_object_get_usage (SeahorseObject *self)
 {
 	g_return_val_if_fail (SEAHORSE_IS_OBJECT (self), SEAHORSE_USAGE_NONE);
-	seahorse_object_realize (self);
+	if (self->pv->usage == SEAHORSE_USAGE_NONE)
+		seahorse_object_realize (self);
 	return self->pv->usage;	
 }
 

Modified: trunk/pgp/seahorse-gpgme-key.c
==============================================================================
--- trunk/pgp/seahorse-gpgme-key.c	(original)
+++ trunk/pgp/seahorse-gpgme-key.c	Tue Dec 16 17:27:25 2008
@@ -280,8 +280,6 @@
 	SeahorseGpgmeKey *self = SEAHORSE_GPGME_KEY (obj);
 	SeahorseLocation loc;
 	SeahorseUsage usage;
-	const gchar *description, *icon, *identifier;
-	GQuark id;
 	guint flags;
 	
 	if (!self->pv->pubkey)
@@ -326,12 +324,6 @@
 
 	g_object_set (obj, "flags", flags, NULL);
 	
-	SEAHORSE_OBJECT_CLASS (seahorse_gpgme_key_parent_class)->realize (obj);
-	
-	/* The key id */
-	g_return_if_fail (self->pv->pubkey->subkeys);
-	identifier = self->pv->pubkey->subkeys->keyid;
-
 	/* The location */
 	loc = seahorse_object_get_location (obj);
 	
@@ -342,23 +334,17 @@
 	else if (loc <= SEAHORSE_LOCATION_LOCAL)
 		loc = SEAHORSE_LOCATION_LOCAL;
 
+	g_object_set (obj, "location", loc, NULL);
+
 	/* The type */
-	if (self->pv->seckey) {
+	if (self->pv->seckey)
 		usage = SEAHORSE_USAGE_PRIVATE_KEY;
-		description = _("Private GPGME Key");
-		icon = SEAHORSE_STOCK_SECRET;
-	} else {
+	else
 		usage = SEAHORSE_USAGE_PUBLIC_KEY;
-		description = _("Public GPGME Key");
-		icon = SEAHORSE_STOCK_KEY;
-	}
 
-	g_object_set (obj,
-		      "icon", icon,
-		      "usage", usage,
-		      "description", description,
-		      "location", loc,
-		      NULL);
+	g_object_set (obj, "usage", usage, NULL);
+	
+	SEAHORSE_OBJECT_CLASS (seahorse_gpgme_key_parent_class)->realize (obj);
 }
 
 static void

Modified: trunk/pgp/seahorse-hkp-source.c
==============================================================================
--- trunk/pgp/seahorse-hkp-source.c	(original)
+++ trunk/pgp/seahorse-hkp-source.c	Tue Dec 16 17:27:25 2008
@@ -431,6 +431,7 @@
 
 				key = seahorse_pgp_key_new ();
 				keys = g_list_prepend (keys, key);
+		        	g_object_set (key, "location", SEAHORSE_LOCATION_REMOTE, NULL);
 
 				/* Cut the length and fingerprint */
 				fpr = strchr (v[0], '/');
@@ -502,9 +503,8 @@
 			/* TODO: Implement signatures */
             
 		/* Other junk */
-		} else {
+		} else if (key) {
             
-			/* Allocate a new key */
 			seahorse_pgp_key_set_uids (SEAHORSE_PGP_KEY (key), uids);
 			seahorse_object_list_free (uids);
 			seahorse_pgp_key_set_subkeys (SEAHORSE_PGP_KEY (key), subkeys);

Modified: trunk/pgp/seahorse-ldap-source.c
==============================================================================
--- trunk/pgp/seahorse-ldap-source.c	(original)
+++ trunk/pgp/seahorse-ldap-source.c	Tue Dec 16 17:27:25 2008
@@ -831,6 +831,7 @@
         	list = g_list_prepend (NULL, subkey);
         	seahorse_pgp_key_set_subkeys (key, list);
         	seahorse_object_list_free (list);
+        	g_object_set (key, "location", SEAHORSE_LOCATION_REMOTE, NULL);
         
         	add_key (lop->lsrc, key);
         	g_object_unref (key);

Modified: trunk/pgp/seahorse-pgp-key.c
==============================================================================
--- trunk/pgp/seahorse-pgp-key.c	(original)
+++ trunk/pgp/seahorse-pgp-key.c	Tue Dec 16 17:27:25 2008
@@ -169,7 +169,9 @@
 {
 	SeahorsePgpKey *self = SEAHORSE_PGP_KEY (obj);
 	const gchar *identifier, *nickname;
+	const gchar *description, *icon;
 	gchar *markup, *name;
+	SeahorseUsage usage;
 	GList *subkeys;
 	
 	
@@ -183,12 +185,28 @@
 	name = calc_name (self);
 	markup = calc_markup (self, seahorse_object_get_flags (obj));
 	nickname = calc_short_name (self);
+	
+	g_object_get (obj, "usage", &usage, NULL);
 		
+	/* The type */
+	if (usage == SEAHORSE_USAGE_PRIVATE_KEY) {
+		description = _("Private PGP Key");
+		icon = SEAHORSE_STOCK_SECRET;
+	} else {
+		description = _("Public PGP Key");
+		icon = SEAHORSE_STOCK_KEY;
+		if (usage == SEAHORSE_USAGE_NONE)
+			g_object_set (obj, "usage", SEAHORSE_USAGE_PUBLIC_KEY, NULL);
+	}
+	
+	
 	g_object_set (obj,
 		      "label", name,
 		      "markup", markup,
 		      "nickname", nickname,
 		      "identifier", identifier,
+		      "description", description,
+		      "icon", icon,
 		      NULL);
 		
 	g_free (markup);
@@ -239,9 +257,10 @@
 		g_value_set_string (value, seahorse_pgp_key_get_algo (self));
 		break;
 	case PROP_VALIDITY:
+		g_value_set_uint (value, SEAHORSE_VALIDITY_UNKNOWN);
+		break;
 	case PROP_TRUST:
-		g_warning ("This property %s getter must be overridden in class %s",
-		           pspec->name, G_OBJECT_TYPE_NAME (object));
+		g_value_set_uint (value, SEAHORSE_VALIDITY_UNKNOWN);
 		break;
 	}
 }

Modified: trunk/src/seahorse-key-manager-store.c
==============================================================================
--- trunk/src/seahorse-key-manager-store.c	(original)
+++ trunk/src/seahorse-key-manager-store.c	Tue Dec 16 17:27:25 2008
@@ -111,11 +111,10 @@
 get_base_iter (SeahorseKeyManagerStore *skstore, GtkTreeIter *base_iter, 
                const GtkTreeIter *iter)
 {
-    GtkTreeIter i;
-    g_assert (skstore->priv->sort && skstore->priv->filter);
-    
-    gtk_tree_model_sort_convert_iter_to_child_iter (skstore->priv->sort, &i, (GtkTreeIter*)iter);
-    gtk_tree_model_filter_convert_iter_to_child_iter (skstore->priv->filter, base_iter, &i);
+	GtkTreeIter i;
+	g_return_if_fail (skstore->priv->sort && skstore->priv->filter);
+	gtk_tree_model_sort_convert_iter_to_child_iter (skstore->priv->sort, &i, (GtkTreeIter*)iter);
+	gtk_tree_model_filter_convert_iter_to_child_iter (skstore->priv->filter, base_iter, &i);
 }
 
 /* Given a base store iter, get the treeview iter */
@@ -127,6 +126,7 @@
     GtkTreePath *child_path, *path;
     gboolean ret;
     
+    g_return_val_if_fail (skstore->priv->filter, FALSE);
     child_path = gtk_tree_model_get_path (gtk_tree_model_filter_get_model (skstore->priv->filter), 
                                           (GtkTreeIter*)iter);
     g_return_val_if_fail (child_path != NULL, FALSE);
@@ -142,6 +142,7 @@
     if (!ret)
         return FALSE;
   
+    g_return_val_if_fail (skstore->priv->sort, FALSE);
     gtk_tree_model_sort_convert_child_iter_to_iter (skstore->priv->sort, upper_iter, &i);
     return TRUE;
 }
@@ -253,6 +254,7 @@
 static gboolean
 refilter_now (SeahorseKeyManagerStore* skstore)
 {
+    g_return_if_fail (skstore->priv->filter);
     seahorse_set_refresh (SEAHORSE_SET_MODEL (skstore)->set);
     gtk_tree_model_filter_refilter (skstore->priv->filter);    
     skstore->priv->filter_stag = 0;
@@ -301,6 +303,7 @@
     }
     
     if (id != -1) {
+        g_return_if_fail (skstore->priv->sort);
         sort = GTK_TREE_SORTABLE (skstore->priv->sort);
         gtk_tree_sortable_set_sort_column_id (sort, id, ord);
     }
@@ -317,7 +320,8 @@
     gchar* x;
     
     skstore = SEAHORSE_KEY_MANAGER_STORE (user_data);
-        
+    g_return_if_fail (skstore->priv->sort);
+    
     /* We have a sort so save it */
     if (gtk_tree_sortable_get_sort_column_id (sort, &id, &ord)) {
         if (id >= 0 && id < N_COLS) {
@@ -745,11 +749,16 @@
 {
     SeahorseKeyManagerStore *skstore = SEAHORSE_KEY_MANAGER_STORE (gobject);
 
-    g_signal_handlers_disconnect_by_func (skstore->priv->sort, sort_changed, skstore);
-
-    /* These were allocated in the constructor */
-    g_object_unref (skstore->priv->sort);
-    g_object_unref (skstore->priv->filter);
+    if (skstore->priv->sort) {
+        g_signal_handlers_disconnect_by_func (skstore->priv->sort, sort_changed, skstore);
+        g_object_remove_weak_pointer (G_OBJECT (skstore->priv->sort), (gpointer*)&skstore->priv->sort);
+        skstore->priv->sort = NULL;
+    }
+    
+    if (skstore->priv->filter) {
+        g_object_remove_weak_pointer (G_OBJECT (skstore->priv->filter), (gpointer*)&skstore->priv->filter);
+        skstore->priv->filter = NULL;
+    }
      
     /* Allocated in property setter */
     g_free (skstore->priv->filter_text); 
@@ -865,7 +874,7 @@
     if ((sort = seahorse_gconf_get_string (KEY_MANAGER_SORT_KEY)) != NULL) {
         set_sort_to (skstore, sort);
         g_free (sort);
-    }  
+    } 
     
     seahorse_gconf_notify_lazy (LISTING_SCHEMAS, (GConfClientNotifyFunc)gconf_notification, 
                                 view, GTK_WIDGET (view));
@@ -880,6 +889,12 @@
     gtk_drag_source_set (GTK_WIDGET (view), GDK_BUTTON1_MASK,
                          store_targets, G_N_ELEMENTS (store_targets), GDK_ACTION_COPY);
 
+    /* We keep track of these but not as a strong reference */
+    g_object_add_weak_pointer (G_OBJECT (skstore->priv->filter), (gpointer*)&skstore->priv->filter);
+    g_object_unref (skstore->priv->filter);
+    g_object_add_weak_pointer (G_OBJECT (skstore->priv->sort), (gpointer*)&skstore->priv->sort);
+    g_object_unref (skstore->priv->sort);
+    
     return skstore;
 }
 

Modified: trunk/src/seahorse-key-manager.c
==============================================================================
--- trunk/src/seahorse-key-manager.c	(original)
+++ trunk/src/seahorse-key-manager.c	Tue Dec 16 17:27:25 2008
@@ -880,7 +880,7 @@
 	gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
 	gtk_action_group_add_actions (actions, SERVER_ENTRIES, G_N_ELEMENTS (SERVER_ENTRIES), self);
 	seahorse_viewer_include_actions (SEAHORSE_VIEWER (self), actions);
-#endif WITH_KEYSERVER
+#endif /* WITH_KEYSERVER */
 	
 	self->pv->view_actions = gtk_action_group_new ("view");
 	gtk_action_group_set_translation_domain (self->pv->view_actions, GETTEXT_PACKAGE);
@@ -1091,5 +1091,6 @@
 seahorse_key_manager_show (void) 
 {
 	SeahorseKeyManager *man = g_object_new (SEAHORSE_TYPE_KEY_MANAGER, "name", "key-manager", NULL);
+	g_object_ref_sink (man);
 	return GTK_WINDOW (seahorse_widget_get_toplevel (SEAHORSE_WIDGET (man)));
 }

Modified: trunk/src/seahorse-keyserver-results.c
==============================================================================
--- trunk/src/seahorse-keyserver-results.c	(original)
+++ trunk/src/seahorse-keyserver-results.c	Tue Dec 16 17:27:25 2008
@@ -337,7 +337,6 @@
 	
 	/* Our predicate for filtering keys */
 	self->pv->pred.tag = g_quark_from_string ("openpgp");
-	self->pv->pred.usage = SEAHORSE_USAGE_PUBLIC_KEY;
 	self->pv->pred.location = SEAHORSE_LOCATION_REMOTE;
 	self->pv->pred.custom = (SeahorseObjectPredicateFunc)on_filter_objects;
 	self->pv->pred.custom_target = self;
@@ -376,6 +375,10 @@
 		g_object_unref (self->pv->store);
 	self->pv->store = NULL;
 	
+	if (self->pv->view)
+		gtk_tree_view_set_model (self->pv->view, NULL);
+	self->pv->view = NULL;
+	
 	G_OBJECT_CLASS (seahorse_keyserver_results_parent_class)->finalize (obj);
 }
 
@@ -453,12 +456,6 @@
  * PUBLIC 
  */
 
-SeahorseKeyserverResults*
-seahorse_keyserver_results_new (void)
-{
-	return g_object_new (SEAHORSE_TYPE_KEYSERVER_RESULTS, NULL);
-}
-
 void 
 seahorse_keyserver_results_show (SeahorseOperation* op, GtkWindow* parent, const char* search_text) 
 {



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