static void gimp_container_entry_init (GimpContainerEntry *entry) { GtkEntryCompletion *completion; GtkTreeModel *model; GtkCellRenderer *cell; GType types[GIMP_CONTAINER_TREE_STORE_N_COLUMNS]; gint n_types = 0; completion = g_object_new (GTK_TYPE_ENTRY_COMPLETION, "inline-completion", TRUE, "popup-single-match", FALSE, "popup-set-width", FALSE, NULL); gimp_container_tree_store_columns_init (types, &n_types); model = gimp_container_tree_store_new (GIMP_CONTAINER_VIEW (entry), n_types, types); gimp_container_tree_store_set_use_name (GIMP_CONTAINER_TREE_STORE (model), TRUE); gtk_entry_completion_set_model (completion, model); g_object_unref (model); gtk_entry_set_completion (GTK_ENTRY (entry), completion); g_signal_connect (completion, "match-selected", G_CALLBACK (gimp_container_entry_match_selected), entry); g_object_unref (completion); /* FIXME: This can be done better with GTK+ 2.6. */ cell = gimp_cell_renderer_viewable_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion), cell, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (completion), cell, "renderer", GIMP_CONTAINER_TREE_STORE_COLUMN_RENDERER, NULL); gimp_container_tree_store_add_renderer_cell (GIMP_CONTAINER_TREE_STORE (model), cell); gtk_entry_completion_set_text_column (completion, GIMP_CONTAINER_TREE_STORE_COLUMN_NAME); g_signal_connect (entry, "changed", G_CALLBACK (gimp_container_entry_changed), entry); }
static void gimp_container_combo_box_init (GimpContainerComboBox *combo) { GtkTreeModel *model; GtkCellLayout *layout; GtkCellRenderer *cell; GType types[GIMP_CONTAINER_TREE_STORE_N_COLUMNS]; gint n_types = 0; gimp_container_tree_store_columns_init (types, &n_types); model = gimp_container_tree_store_new (GIMP_CONTAINER_VIEW (combo), n_types, types); gtk_combo_box_set_model (GTK_COMBO_BOX (combo), model); g_object_unref (model); layout = GTK_CELL_LAYOUT (combo); cell = gimp_cell_renderer_viewable_new (); gtk_cell_layout_pack_start (layout, cell, FALSE); gtk_cell_layout_set_attributes (layout, cell, "renderer", GIMP_CONTAINER_TREE_STORE_COLUMN_RENDERER, NULL); gimp_container_tree_store_add_renderer_cell (GIMP_CONTAINER_TREE_STORE (model), cell); combo->viewable_renderer = cell; cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (layout, cell, TRUE); gtk_cell_layout_set_attributes (layout, cell, "text", GIMP_CONTAINER_TREE_STORE_COLUMN_NAME, NULL); combo->text_renderer = cell; g_signal_connect (combo, "changed", G_CALLBACK (gimp_container_combo_box_changed), combo); gtk_widget_set_sensitive (GTK_WIDGET (combo), FALSE); }
static void gimp_container_combo_box_init (GimpContainerComboBox *combo_box) { GtkListStore *store; GtkCellLayout *layout; GtkCellRenderer *cell; store = gtk_list_store_new (NUM_COLUMNS, GIMP_TYPE_VIEW_RENDERER, G_TYPE_STRING); gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store)); g_object_unref (store); layout = GTK_CELL_LAYOUT (combo_box); cell = gimp_cell_renderer_viewable_new (); gtk_cell_layout_pack_start (layout, cell, FALSE); gtk_cell_layout_set_attributes (layout, cell, "renderer", COLUMN_RENDERER, NULL); combo_box->viewable_renderer = cell; cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (layout, cell, TRUE); gtk_cell_layout_set_attributes (layout, cell, "text", COLUMN_NAME, NULL); combo_box->text_renderer = cell; g_signal_connect (combo_box, "changed", G_CALLBACK (gimp_container_combo_box_changed), combo_box); gtk_widget_set_sensitive (GTK_WIDGET (combo_box), FALSE); }
static void gimp_component_editor_init (GimpComponentEditor *editor) { GtkWidget *frame; GtkListStore *list; frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (editor), frame, FALSE, FALSE, 0); gtk_widget_show (frame); list = gtk_list_store_new (NUM_COLUMNS, G_TYPE_INT, G_TYPE_BOOLEAN, GIMP_TYPE_VIEW_RENDERER, G_TYPE_STRING); editor->model = GTK_TREE_MODEL (list); editor->view = GTK_TREE_VIEW (gtk_tree_view_new_with_model (editor->model)); g_object_unref (list); gtk_tree_view_set_headers_visible (editor->view, FALSE); editor->eye_column = gtk_tree_view_column_new (); gtk_tree_view_append_column (editor->view, editor->eye_column); editor->eye_cell = gimp_cell_renderer_toggle_new (GIMP_STOCK_VISIBLE); gtk_tree_view_column_pack_start (editor->eye_column, editor->eye_cell, FALSE); gtk_tree_view_column_set_attributes (editor->eye_column, editor->eye_cell, "active", COLUMN_VISIBLE, NULL); g_signal_connect (editor->eye_cell, "clicked", G_CALLBACK (gimp_component_editor_clicked), editor); editor->renderer_cell = gimp_cell_renderer_viewable_new (); gtk_tree_view_insert_column_with_attributes (editor->view, -1, NULL, editor->renderer_cell, "renderer", COLUMN_RENDERER, NULL); gtk_tree_view_insert_column_with_attributes (editor->view, -1, NULL, gtk_cell_renderer_text_new (), "text", COLUMN_NAME, NULL); gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (editor->view)); gtk_widget_show (GTK_WIDGET (editor->view)); g_signal_connect (editor->view, "button-press-event", G_CALLBACK (gimp_component_editor_button_press), editor); editor->selection = gtk_tree_view_get_selection (editor->view); gtk_tree_selection_set_mode (editor->selection, GTK_SELECTION_MULTIPLE); gtk_tree_selection_set_select_function (editor->selection, gimp_component_editor_select, editor, NULL); gimp_dnd_component_source_add (GTK_WIDGET (editor->view), gimp_component_editor_drag_component, editor); }