static void on_collection_removed (GcrCollection *collection, GObject *object, gpointer user_data) { GcrUnionCollection *self = GCR_UNION_COLLECTION (user_data); gint *count; g_object_ref (object); count = g_hash_table_lookup (self->pv->items, object); if (count != NULL) { g_assert (*count > 0); (*count)--; if (*count == 0) { g_hash_table_remove (self->pv->items, object); gcr_collection_emit_removed (GCR_COLLECTION (self), object); } } else { g_warning ("Object of type %s that exists in an underlying " "collection of a GcrUnionCollection appeared without " "emitting 'added' signal.", G_OBJECT_TYPE_NAME (object)); } g_object_unref (object); }
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); }
/** * gcr_simple_collection_contains: * @self: The collection * @object: The object to check * * Check if the collection contains a certain object. * * Deprecated: use gcr_collection_contains() instead * * Returns: %TRUE if the collection contains the object. */ gboolean gcr_simple_collection_contains (GcrSimpleCollection *self, GObject *object) { g_return_val_if_fail (GCR_IS_SIMPLE_COLLECTION (self), FALSE); g_return_val_if_fail (G_IS_OBJECT (object), FALSE); return gcr_collection_contains (GCR_COLLECTION (self), object); }
/* 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; }
/** * gcr_simple_collection_add: * @self: The collection * @object: The object to add * * Add an object to this collection */ void gcr_simple_collection_add (GcrSimpleCollection *self, GObject *object) { g_return_if_fail (GCR_IS_SIMPLE_COLLECTION (self)); g_return_if_fail (G_IS_OBJECT (object)); g_return_if_fail (!g_hash_table_lookup (self->pv->items, object)); g_hash_table_insert (self->pv->items, g_object_ref (object), UNUSED_VALUE); gcr_collection_emit_added (GCR_COLLECTION (self), object); }
/** * gcr_simple_collection_remove: * @self: The collection * @object: The object to remove from the collection * * Remove an object from the collection. */ void gcr_simple_collection_remove (GcrSimpleCollection *self, GObject *object) { g_return_if_fail (GCR_IS_SIMPLE_COLLECTION (self)); g_return_if_fail (G_IS_OBJECT (object)); g_return_if_fail (g_hash_table_lookup (self->pv->items, object)); g_object_ref (object); g_hash_table_remove (self->pv->items, object); gcr_collection_emit_removed (GCR_COLLECTION (self), object); g_object_unref (object); }
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); }
static void on_collection_added (GcrCollection *collection, GObject *object, gpointer user_data) { GcrUnionCollection *self = GCR_UNION_COLLECTION (user_data); gint *count; g_object_ref (object); count = g_hash_table_lookup (self->pv->items, object); if (count == NULL) { count = g_new0 (gint, 1); *count = 1; g_hash_table_insert (self->pv->items, object, count); gcr_collection_emit_added (GCR_COLLECTION (self), object); } else { g_assert (*count > 0); (*count)++; } g_object_unref (object); }
static void seahorse_keyserver_results_constructed (GObject *obj) { SeahorseKeyserverResults *self = SEAHORSE_KEYSERVER_RESULTS (obj); GtkActionGroup* actions; GtkTreeSelection *selection; GtkWindow *window; GtkBuilder *builder; char* title; G_OBJECT_CLASS (seahorse_keyserver_results_parent_class)->constructed (obj); if (g_utf8_strlen (self->pv->search_string, -1) == 0) { title = g_strdup (_("Remote Keys")); } else { title = g_strdup_printf (_ ("Remote Keys Containing '%s'"), self->pv->search_string); } window = seahorse_catalog_get_window (SEAHORSE_CATALOG (self)); gtk_window_set_default_geometry(window, 640, 476); gtk_widget_set_events (GTK_WIDGET (window), GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); gtk_window_set_title (window, title); gtk_widget_set_visible (GTK_WIDGET (window), TRUE); g_free (title); g_signal_connect (window, "delete-event", G_CALLBACK (on_delete_event), self); actions = gtk_action_group_new ("general"); gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE); gtk_action_group_add_actions (actions, GENERAL_ENTRIES, G_N_ELEMENTS (GENERAL_ENTRIES), self); seahorse_catalog_include_actions (SEAHORSE_CATALOG (self), actions); actions = gtk_action_group_new ("keyserver"); gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE); gtk_action_group_add_actions (actions, SERVER_ENTRIES, G_N_ELEMENTS (SERVER_ENTRIES), self); seahorse_catalog_include_actions (SEAHORSE_CATALOG (self), actions); self->pv->import_actions = gtk_action_group_new ("import"); gtk_action_group_set_translation_domain (self->pv->import_actions, GETTEXT_PACKAGE); gtk_action_group_add_actions (self->pv->import_actions, IMPORT_ENTRIES, G_N_ELEMENTS (IMPORT_ENTRIES), self); g_object_set (gtk_action_group_get_action (self->pv->import_actions, "key-import-keyring"), "is-important", TRUE, NULL); seahorse_catalog_include_actions (SEAHORSE_CATALOG (self), self->pv->import_actions); /* init key list & selection settings */ builder = seahorse_catalog_get_builder (SEAHORSE_CATALOG (self)); self->pv->view = GTK_TREE_VIEW (gtk_builder_get_object (builder, "key_list")); selection = gtk_tree_view_get_selection (self->pv->view); gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE); g_signal_connect_object (selection, "changed", G_CALLBACK (on_view_selection_changed), self, 0); g_signal_connect_object (self->pv->view, "row-activated", G_CALLBACK (on_row_activated), self, 0); g_signal_connect_object (self->pv->view, "button-press-event", G_CALLBACK (on_key_list_button_pressed), self, 0); g_signal_connect_object (self->pv->view, "popup-menu", G_CALLBACK (on_key_list_popup_menu), self, 0); gtk_widget_realize (GTK_WIDGET (self->pv->view)); /* Set focus to the current key list */ gtk_widget_grab_focus (GTK_WIDGET (self->pv->view)); /* To avoid flicker */ seahorse_catalog_ensure_updated (SEAHORSE_CATALOG (self)); gtk_widget_show (GTK_WIDGET (self)); self->pv->store = seahorse_key_manager_store_new (GCR_COLLECTION (self->pv->collection), self->pv->view, &self->pv->pred, self->pv->settings); on_view_selection_changed (selection, self); /* Include actions from the backend */ actions = NULL; g_object_get (seahorse_pgp_backend_get (), "actions", &actions, NULL); seahorse_catalog_include_actions (SEAHORSE_CATALOG (self), actions); g_object_unref (actions); }