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); }
/** * gcr_union_collection_take: * @self: The union collection * @collection: The collection whose objects to add * * Add objects from this collection to the union. Do not add an additional * reference to the collection. */ void gcr_union_collection_take (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_insert (self->pv->collections, collection, collection); connect_to_collection (self, collection); objects = gcr_collection_get_objects (collection); for (l = objects; l != NULL; l = g_list_next (l)) on_collection_added (collection, l->data, self); g_list_free (objects); g_object_unref (collection); }