static void on_remote_sync (GtkAction* action, gpointer user_data) { SeahorseActions *actions = SEAHORSE_ACTIONS (user_data); SeahorseGpgmeKeyring *keyring; SeahorseCatalog *catalog; GList *objects = NULL; GList *keys = NULL; GList *l; catalog = seahorse_actions_get_catalog (actions); if (catalog != NULL) { objects = seahorse_catalog_get_selected_objects (catalog); for (l = objects; l != NULL; l = g_list_next (l)) { if (SEAHORSE_IS_PGP_KEY (l->data)) keys = g_list_prepend (keys, l->data); } g_list_free (objects); } g_object_unref (catalog); if (keys == NULL) { keyring = seahorse_pgp_backend_get_default_keyring (NULL); keys = gcr_collection_get_objects (GCR_COLLECTION (keyring)); } seahorse_keyserver_sync_show (keys, seahorse_action_get_window (action)); g_list_free (keys); }
/* Called to filter each row */ static gboolean on_filter_visible (GObject *obj, gpointer user_data) { SeahorseKeyManagerStore* self = SEAHORSE_KEY_MANAGER_STORE (user_data); GList *children, *l; gboolean ret = FALSE; /* Check the row requested */ switch (self->priv->filter_mode) { case KEY_STORE_MODE_FILTERED: ret = object_contains_filtered_text (obj, self->priv->filter_text); break; case KEY_STORE_MODE_ALL: ret = TRUE; break; default: g_assert_not_reached (); break; }; /* If current is not being shown, double check with children */ if (!ret && GCR_IS_COLLECTION (obj)) { children = gcr_collection_get_objects (GCR_COLLECTION (obj)); for (l = children; !ret && l != NULL; l = g_list_next (l)) ret = on_filter_visible (l->data, user_data); } return ret; }
GList* seahorse_key_manager_store_get_all_objects (GtkTreeView *view) { SeahorseKeyManagerStore* skstore; g_return_val_if_fail (GTK_IS_TREE_VIEW (view), NULL); skstore = SEAHORSE_KEY_MANAGER_STORE (gtk_tree_view_get_model (view)); g_return_val_if_fail (SEAHORSE_IS_KEY_MANAGER_STORE (skstore), NULL); return gcr_collection_get_objects (gcr_collection_model_get_collection (GCR_COLLECTION_MODEL (skstore))); }
void seahorse_combo_keys_attach (GtkComboBox *combo, GcrCollection *collection, const gchar *none_option) { GtkTreeModel *model; GtkTreeIter iter; GtkCellRenderer *renderer; GList *l, *objects; g_object_set_data_full (G_OBJECT (combo), "combo-keys-closure", combo_closure_new (), combo_closure_free); /* Setup the None Option */ model = gtk_combo_box_get_model (combo); if (!model) { model = GTK_TREE_MODEL (gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER)); gtk_combo_box_set_model (combo, model); gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo)); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "markup", COMBO_MARKUP); } /* Setup the object list */ objects = gcr_collection_get_objects (collection); for (l = objects; l != NULL; l = g_list_next (l)) on_collection_added (collection, l->data, combo); g_list_free (objects); g_signal_connect_after (collection, "added", G_CALLBACK (on_collection_added), combo); g_signal_connect_after (collection, "removed", G_CALLBACK (on_collection_removed), combo); if (none_option) { gtk_list_store_prepend (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, COMBO_LABEL, NULL, COMBO_MARKUP, none_option, COMBO_POINTER, NULL, -1); } gtk_tree_model_get_iter_first (model, &iter); gtk_combo_box_set_active_iter (combo, &iter); g_signal_connect_data (combo, "destroy", G_CALLBACK (on_combo_destroy), g_object_ref (collection), (GClosureNotify)g_object_unref, 0); }
static void on_combo_destroy (GtkComboBox *combo, gpointer user_data) { GcrCollection *collection = GCR_COLLECTION (user_data); GList *objects, *l; objects = gcr_collection_get_objects (collection); for (l = objects; l != NULL; l = g_list_next (l)) g_signal_handlers_disconnect_by_func (l->data, on_label_changed, combo); g_list_free (objects); g_signal_handlers_disconnect_by_func (collection, on_collection_added, combo); g_signal_handlers_disconnect_by_func (collection, on_collection_removed, combo); }
/** * gcr_union_collection_remove: * @self: The collection * @collection: The collection whose objects to remove * * Remove an object from the collection. */ void gcr_union_collection_remove (GcrUnionCollection *self, GcrCollection *collection) { GList *objects, *l; g_return_if_fail (GCR_IS_UNION_COLLECTION (self)); g_return_if_fail (GCR_IS_COLLECTION (collection)); g_return_if_fail (g_hash_table_lookup (self->pv->collections, collection)); g_object_ref (collection); g_hash_table_remove (self->pv->collections, collection); disconnect_from_collection (self, collection); objects = gcr_collection_get_objects (collection); for (l = objects; l != NULL; l = g_list_next (l)) on_collection_removed (collection, l->data, self); g_list_free (objects); g_object_unref (collection); }