/** * Crée le GtkIconView * * \param nom de l'icône * * \return le GtkIconView rempli avec l'icône sélectionnée au premier plan * * */ GtkWidget * gsb_select_icon_create_icon_view ( gchar * name_icon ) { GtkTreePath * tree_path; /* construct the GtkIconView */ icon_view = gtk_icon_view_new (); gtk_icon_view_set_margin ( GTK_ICON_VIEW ( icon_view ), 0 ); gtk_icon_view_set_spacing (GTK_ICON_VIEW ( icon_view ), 0 ); gtk_icon_view_set_selection_mode (GTK_ICON_VIEW ( icon_view ), GTK_SELECTION_SINGLE ); gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW ( icon_view ), PIXBUF_COLUMN); gtk_icon_view_set_text_column (GTK_ICON_VIEW ( icon_view ), TEXT_COLUMN); /* remplissage et positionnement initial du curseur dans le GtkIconView */ tree_path = gsb_select_icon_fill_icon_view ( name_icon ); gtk_icon_view_select_path ( GTK_ICON_VIEW ( icon_view ), tree_path ); gtk_icon_view_set_cursor (GTK_ICON_VIEW ( icon_view ), tree_path, NULL, TRUE); gtk_icon_view_scroll_to_path (GTK_ICON_VIEW ( icon_view ), tree_path, TRUE, 0.5, 0 ); return icon_view; }
AmiDesktop *ami_desktop_new(GdkScreen *gscreen) { AmiDesktop *desktop; g_return_val_if_fail(gscreen, NULL); desktop = g_new(AmiDesktop, 1); desktop->gscreen = gscreen; desktop->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); desktop->icon_view = gtk_icon_view_new(); return desktop; }
static VALUE iview_initialize(int argc, VALUE *argv, VALUE self) { VALUE model; rb_scan_args(argc, argv, "01", &model); if (NIL_P(model)){ RBGTK_INITIALIZE(self, gtk_icon_view_new()); } else { G_CHILD_SET(self, id_model, model); RBGTK_INITIALIZE(self, gtk_icon_view_new_with_model(GTK_TREE_MODEL(RVAL2GOBJ(model)))); } return Qnil; }
/* test that we have a cell area after new() */ static void test_iconview_new (void) { GtkWidget *view; GtkCellArea *area; view = gtk_icon_view_new (); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (view)); g_assert (GTK_IS_CELL_AREA_BOX (area)); g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == gtk_icon_view_get_item_orientation (GTK_ICON_VIEW (view))); g_object_ref_sink (view); g_object_unref (view); }
static void budgie_media_view_init(BudgieMediaView *self) { GtkWidget *icon_view, *scroll; /* Set up our icon view */ icon_view = gtk_icon_view_new(); self->icon_view = icon_view; scroll = gtk_scrolled_window_new(NULL, NULL); gtk_container_add(GTK_CONTAINER(scroll), icon_view); gtk_container_add(GTK_CONTAINER(self), scroll); /* Relevant columns */ gtk_icon_view_set_markup_column(GTK_ICON_VIEW(icon_view), ALBUM_TITLE); gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW(icon_view), ALBUM_PIXBUF); gtk_icon_view_set_item_width(GTK_ICON_VIEW(icon_view), 200); gtk_icon_view_set_item_orientation(GTK_ICON_VIEW(icon_view), GTK_ORIENTATION_HORIZONTAL); }
void toolbar2___::init__(GtkWidget* box1, icon_item___* item) { if(item->is_init_) return; item->is_init_ = true; init1__(box1, item); GtkWidget *view = gtk_icon_view_new(); item->widget_ = view; GtkIconView *view2 = item->icon_view__(); gtk_container_add(item->container__(),view); gtk_icon_view_set_item_width (view2, 0); g_signal_connect (view, "selection-changed", G_CALLBACK (selection_changed__), NULL); g_signal_connect (view, "item-activated", G_CALLBACK (item_activated__), NULL); init2__(item); GtkListStore *store = gtk_list_store_new (COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING); item->store_ = store; gtk_icon_view_set_model (view2, item->model__()); gtk_icon_view_set_pixbuf_column (view2, PIXBUF_COLUMN); //gtk_icon_view_set_text_column (view2, TITLE_COLUMN); gtk_icon_view_set_markup_column (view2, TITLE_COLUMN); }
static GtkWidget * simple_iconview (void) { GtkTreeModel *model; GtkWidget *iconview; GtkCellArea *area; GtkCellRenderer *renderer; iconview = gtk_icon_view_new (); gtk_widget_show (iconview); model = simple_list_model (); gtk_icon_view_set_model (GTK_ICON_VIEW (iconview), model); gtk_icon_view_set_item_orientation (GTK_ICON_VIEW (iconview), GTK_ORIENTATION_HORIZONTAL); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview)); cell_1 = renderer = gtk_cell_renderer_text_new (); gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, FALSE, FALSE); gtk_cell_area_attribute_connect (area, renderer, "text", SIMPLE_COLUMN_NAME); cell_2 = renderer = gtk_cell_renderer_pixbuf_new (); g_object_set (G_OBJECT (renderer), "xalign", 0.0F, NULL); gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, TRUE, FALSE, FALSE); gtk_cell_area_attribute_connect (area, renderer, "icon-name", SIMPLE_COLUMN_ICON); cell_3 = renderer = gtk_cell_renderer_text_new (); g_object_set (G_OBJECT (renderer), "wrap-mode", PANGO_WRAP_WORD, "wrap-width", 215, NULL); gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE, FALSE); gtk_cell_area_attribute_connect (area, renderer, "text", SIMPLE_COLUMN_DESCRIPTION); return iconview; }
JNIEXPORT jlong JNICALL Java_org_gnome_gtk_GtkIconView_gtk_1icon_1view_1new ( JNIEnv* env, jclass cls ) { GtkWidget* result; jlong _result; // call function result = gtk_icon_view_new(); // translate return value to JNI type _result = (jlong) result; // cleanup return value if (result != NULL) { bindings_java_memory_cleanup((GObject*)result, TRUE); } // and finally return _result; }
/* The main GUI function for saving multi-paged PDFs */ static gboolean gui_multi (void) { GtkWidget *window; GtkWidget *vbox; GtkWidget *file_label; GtkWidget *file_entry; GtkWidget *file_browse; GtkWidget *file_hbox; GtkWidget *vectorize_c; GtkWidget *ignore_hidden_c; GtkWidget *apply_c; GtkWidget *scroll; GtkWidget *page_view; GtkWidget *h_but_box; GtkWidget *del; GtkWidget *h_box; GtkWidget *img_combo; GtkWidget *add_image; gboolean run; const gchar *temp; gimp_ui_init (PLUG_IN_BINARY, FALSE); window = gimp_export_dialog_new ("PDF", PLUG_IN_ROLE, SAVE_MULTI_PROC); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10); gtk_box_pack_start (GTK_BOX (gimp_export_dialog_get_content_area (window)), vbox, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (window), 12); file_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); file_label = gtk_label_new (_("Save to:")); file_entry = gtk_entry_new (); if (file_name != NULL) gtk_entry_set_text (GTK_ENTRY (file_entry), file_name); file_browse = gtk_button_new_with_label (_("Browse...")); file_choose = gtk_file_chooser_dialog_new (_("Multipage PDF export"), GTK_WINDOW (window), GTK_FILE_CHOOSER_ACTION_SAVE, "gtk-save", GTK_RESPONSE_OK, "gtk-cancel", GTK_RESPONSE_CANCEL, NULL); gtk_box_pack_start (GTK_BOX (file_hbox), file_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (file_hbox), file_entry, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (file_hbox), file_browse, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), file_hbox, TRUE, TRUE, 0); page_view = gtk_icon_view_new (); model = create_model (); gtk_icon_view_set_model (GTK_ICON_VIEW (page_view), model); gtk_icon_view_set_reorderable (GTK_ICON_VIEW (page_view), TRUE); gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (page_view), GTK_SELECTION_MULTIPLE); gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (page_view), THUMB); gtk_icon_view_set_text_column (GTK_ICON_VIEW (page_view), PAGE_NUMBER); gtk_icon_view_set_tooltip_column (GTK_ICON_VIEW (page_view), IMAGE_NAME); scroll = gtk_scrolled_window_new (NULL, NULL); gtk_widget_set_size_request (scroll, -1, 300); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_container_add (GTK_CONTAINER (scroll), page_view); gtk_box_pack_start (GTK_BOX (vbox), scroll, TRUE, TRUE, 0); h_but_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); gtk_button_box_set_layout (GTK_BUTTON_BOX (h_but_box), GTK_BUTTONBOX_START); del = gtk_button_new_with_label (_("Remove the selected pages")); gtk_box_pack_start (GTK_BOX (h_but_box), del, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), h_but_box, FALSE, FALSE, 0); h_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); img_combo = gimp_image_combo_box_new (NULL, NULL); gtk_box_pack_start (GTK_BOX (h_box), img_combo, FALSE, FALSE, 0); add_image = gtk_button_new_with_label (_("Add this image")); gtk_box_pack_start (GTK_BOX (h_box), add_image, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), h_box, FALSE, FALSE, 0); ignore_hidden_c = gtk_check_button_new_with_label (_("Omit hidden layers and layers with zero opacity")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ignore_hidden_c), optimize.ignore_hidden); gtk_box_pack_end (GTK_BOX (vbox), ignore_hidden_c, FALSE, FALSE, 0); vectorize_c = gtk_check_button_new_with_label (_("Convert bitmaps to vector graphics where possible")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vectorize_c), optimize.vectorize); gtk_box_pack_end (GTK_BOX (vbox), vectorize_c, FALSE, FALSE, 0); apply_c = gtk_check_button_new_with_label (_("Apply layer masks before saving")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (apply_c), optimize.apply_masks); gtk_box_pack_end (GTK_BOX (vbox), apply_c, FALSE, FALSE, 0); gimp_help_set_help_data (apply_c, _("Keeping the masks will not change the output"), NULL); gtk_widget_show_all (window); g_signal_connect (G_OBJECT (file_browse), "clicked", G_CALLBACK (choose_file_call), G_OBJECT (file_entry)); g_signal_connect (G_OBJECT (add_image), "clicked", G_CALLBACK (add_image_call), G_OBJECT (img_combo)); g_signal_connect (G_OBJECT (del), "clicked", G_CALLBACK (del_image_call), G_OBJECT (page_view)); g_signal_connect (G_OBJECT (model), "row-deleted", G_CALLBACK (remove_call), NULL); run = gtk_dialog_run (GTK_DIALOG (window)) == GTK_RESPONSE_OK; run &= get_image_list (); temp = gtk_entry_get_text (GTK_ENTRY (file_entry)); g_stpcpy (file_name, temp); optimize.ignore_hidden = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ignore_hidden_c)); optimize.vectorize = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (vectorize_c)); optimize.apply_masks = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (apply_c)); gtk_widget_destroy (window); return run; }
static GtkWidget* create_icon_view () { GtkWidget *scroll = gtk_scrolled_window_new (NULL, NULL); GtkWidget *icon_view = gtk_icon_view_new (); int col_text = 0,col_icon = 1; GtkTreeModel *list_model = gtk_list_store_new (2, G_TYPE_STRING, GDK_TYPE_PIXBUF ); gtk_icon_view_set_model (GTK_ICON_VIEW (icon_view), list_model); gtk_icon_view_set_text_column (GTK_ICON_VIEW (icon_view), col_text); gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (icon_view), col_icon); gtk_icon_view_set_item_width (GTK_ICON_VIEW (icon_view), 100); GtkTreeIter iter; GtkIconTheme *icon_theme = gtk_icon_theme_get_default (); GList *contxt_list, *icon_names_list, *ctx, *icn; gint max_icons = 100; gint icon_size = 32; ctx = contxt_list = gtk_icon_theme_list_contexts (icon_theme); while (ctx && max_icons) { gchar *context = ctx->data; icn = icon_names_list = gtk_icon_theme_list_icons (icon_theme, context); g_debug ("Context %s: %d icons listed", context, g_list_length (icn)); while (icn && max_icons) { gchar *icon_name = icn->data; g_debug (" - %s", icon_name); GdkPixbuf *pixbuf = NULL; pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name, icon_size, GTK_ICON_LOOKUP_FORCE_SVG, NULL); if (pixbuf != NULL){ gtk_list_store_append (list_model, &iter); gtk_list_store_set (list_model, &iter, col_text, icon_name, col_icon, pixbuf, -1); --max_icons; }else{ g_free (icon_name); } icn = g_list_next (icn); } g_list_free (icon_names_list); g_free (context); ctx = g_list_next (ctx); } g_list_free (contxt_list); gtk_container_add (GTK_CONTAINER (scroll), icon_view); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_set_name (scroll, "Icon View"); return scroll; }
GtkWidget* create_icon_selection_dialog (void) { GtkWidget *icon_selection_dialog; GtkWidget *dialog_vbox1; GtkWidget *hbox4; GtkWidget *scrolledwindow3; GtkWidget *categories_treeview; GtkWidget *scrolledwindow2; GtkWidget *iconview; GtkWidget *dialog_action_area2; GtkWidget *cancel_button; GtkWidget *ok_button; icon_selection_dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (icon_selection_dialog), "Select icon"); gtk_window_set_default_size (GTK_WINDOW (icon_selection_dialog), 540, 420); gtk_window_set_type_hint (GTK_WINDOW (icon_selection_dialog), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_dialog_set_has_separator (GTK_DIALOG (icon_selection_dialog), FALSE); dialog_vbox1 = gtk_dialog_get_content_area (GTK_DIALOG (icon_selection_dialog)); gtk_widget_show (dialog_vbox1); hbox4 = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox4); gtk_box_pack_start (GTK_BOX (dialog_vbox1), hbox4, TRUE, TRUE, 0); scrolledwindow3 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scrolledwindow3); gtk_box_pack_start (GTK_BOX (hbox4), scrolledwindow3, FALSE, FALSE, 0); gtk_widget_set_size_request (scrolledwindow3, 140, -1); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow3), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow3), GTK_SHADOW_IN); categories_treeview = gtk_tree_view_new (); gtk_widget_show (categories_treeview); gtk_container_add (GTK_CONTAINER (scrolledwindow3), categories_treeview); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (categories_treeview), FALSE); scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scrolledwindow2); gtk_box_pack_start (GTK_BOX (hbox4), scrolledwindow2, TRUE, TRUE, 0); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_SHADOW_IN); iconview = gtk_icon_view_new (); gtk_widget_show (iconview); gtk_container_add (GTK_CONTAINER (scrolledwindow2), iconview); dialog_action_area2 = gtk_dialog_get_action_area (GTK_DIALOG (icon_selection_dialog)); gtk_widget_show (dialog_action_area2); gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area2), GTK_BUTTONBOX_END); cancel_button = gtk_button_new_from_stock ("gtk-cancel"); gtk_widget_show (cancel_button); gtk_dialog_add_action_widget (GTK_DIALOG (icon_selection_dialog), cancel_button, GTK_RESPONSE_CANCEL); gtk_widget_set_can_default(cancel_button, TRUE); ok_button = gtk_button_new_from_stock ("gtk-ok"); gtk_widget_show (ok_button); gtk_dialog_add_action_widget (GTK_DIALOG (icon_selection_dialog), ok_button, GTK_RESPONSE_OK); gtk_widget_set_sensitive (ok_button, FALSE); gtk_widget_set_can_default(ok_button, TRUE); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (icon_selection_dialog, icon_selection_dialog, "icon_selection_dialog"); GLADE_HOOKUP_OBJECT_NO_REF (icon_selection_dialog, dialog_vbox1, "dialog_vbox1"); GLADE_HOOKUP_OBJECT (icon_selection_dialog, hbox4, "hbox4"); GLADE_HOOKUP_OBJECT (icon_selection_dialog, scrolledwindow3, "scrolledwindow3"); GLADE_HOOKUP_OBJECT (icon_selection_dialog, categories_treeview, "categories_treeview"); GLADE_HOOKUP_OBJECT (icon_selection_dialog, scrolledwindow2, "scrolledwindow2"); GLADE_HOOKUP_OBJECT (icon_selection_dialog, iconview, "iconview"); GLADE_HOOKUP_OBJECT_NO_REF (icon_selection_dialog, dialog_action_area2, "dialog_action_area2"); GLADE_HOOKUP_OBJECT (icon_selection_dialog, cancel_button, "cancel_button"); GLADE_HOOKUP_OBJECT (icon_selection_dialog, ok_button, "ok_button"); return icon_selection_dialog; }
gint main (gint argc, gchar **argv) { GtkWidget *paned, *tv; GtkWidget *window, *icon_list, *scrolled_window; GtkWidget *vbox, *bbox; GtkWidget *button; GtkWidget *prop_editor; GtkTreeModel *model; GtkCellRenderer *cell; GtkTreeViewColumn *tvc; gtk_init (&argc, &argv); /* to test rtl layout, set RTL=1 in the environment */ if (g_getenv ("RTL")) gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 700, 400); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (window), vbox); paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start (GTK_BOX (vbox), paned, TRUE, TRUE, 0); icon_list = gtk_icon_view_new (); gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_list), GTK_SELECTION_MULTIPLE); tv = gtk_tree_view_new (); tvc = gtk_tree_view_column_new (); gtk_tree_view_append_column (GTK_TREE_VIEW (tv), tvc); g_signal_connect_after (icon_list, "button_press_event", G_CALLBACK (button_press_event_handler), NULL); g_signal_connect (icon_list, "selection_changed", G_CALLBACK (selection_changed), NULL); g_signal_connect (icon_list, "popup_menu", G_CALLBACK (popup_menu_handler), NULL); g_signal_connect (icon_list, "item_activated", G_CALLBACK (item_activated), NULL); model = create_model (); gtk_icon_view_set_model (GTK_ICON_VIEW (icon_list), model); gtk_tree_view_set_model (GTK_TREE_VIEW (tv), model); fill_model (model); #if 0 gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (icon_list), 0); gtk_icon_view_set_text_column (GTK_ICON_VIEW (icon_list), 1); #else cell = gtk_cell_renderer_toggle_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (icon_list), cell, FALSE); g_object_set (cell, "activatable", TRUE, NULL); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_list), cell, "active", 4, NULL); g_signal_connect (cell, "toggled", G_CALLBACK (toggled), model); cell = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (icon_list), cell, FALSE); g_object_set (cell, "follow-state", TRUE, NULL); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_list), cell, "pixbuf", 0, NULL); cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (icon_list), cell, FALSE); g_object_set (cell, "editable", TRUE, "xalign", 0.5, "wrap-mode", PANGO_WRAP_WORD_CHAR, "wrap-width", 100, NULL); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_list), cell, "text", 1, NULL); g_signal_connect (cell, "edited", G_CALLBACK (edited), model); /* now the tree view... */ cell = gtk_cell_renderer_toggle_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (tvc), cell, FALSE); g_object_set (cell, "activatable", TRUE, NULL); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (tvc), cell, "active", 4, NULL); g_signal_connect (cell, "toggled", G_CALLBACK (toggled), model); cell = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (tvc), cell, FALSE); g_object_set (cell, "follow-state", TRUE, NULL); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (tvc), cell, "pixbuf", 0, NULL); cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (tvc), cell, FALSE); g_object_set (cell, "editable", TRUE, NULL); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (tvc), cell, "text", 1, NULL); g_signal_connect (cell, "edited", G_CALLBACK (edited), model); #endif /* Allow DND between the icon view and the tree view */ gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (icon_list), GDK_BUTTON1_MASK, item_targets, G_N_ELEMENTS (item_targets), GDK_ACTION_MOVE); gtk_icon_view_enable_model_drag_dest (GTK_ICON_VIEW (icon_list), item_targets, G_N_ELEMENTS (item_targets), GDK_ACTION_MOVE); gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tv), GDK_BUTTON1_MASK, item_targets, G_N_ELEMENTS (item_targets), GDK_ACTION_MOVE); gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (tv), item_targets, G_N_ELEMENTS (item_targets), GDK_ACTION_MOVE); prop_editor = create_prop_editor (G_OBJECT (icon_list), 0); gtk_widget_show_all (prop_editor); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (scrolled_window), icon_list); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_paned_add1 (GTK_PANED (paned), scrolled_window); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (scrolled_window), tv); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_paned_add2 (GTK_PANED (paned), scrolled_window); bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_START); gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); button = gtk_button_new_with_label ("Add some"); g_signal_connect (button, "clicked", G_CALLBACK (add_some), icon_list); gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0); button = gtk_button_new_with_label ("Add many"); g_signal_connect (button, "clicked", G_CALLBACK (add_many), icon_list); gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0); button = gtk_button_new_with_label ("Add large"); g_signal_connect (button, "clicked", G_CALLBACK (add_large), icon_list); gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0); button = gtk_button_new_with_label ("Remove selected"); g_signal_connect (button, "clicked", G_CALLBACK (foreach_selected_remove), icon_list); gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0); button = gtk_button_new_with_label ("Swap"); g_signal_connect (button, "clicked", G_CALLBACK (swap_rows), icon_list); gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0); bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_START); gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); button = gtk_button_new_with_label ("Select all"); g_signal_connect (button, "clicked", G_CALLBACK (select_all), icon_list); gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0); button = gtk_button_new_with_label ("Unselect all"); g_signal_connect (button, "clicked", G_CALLBACK (unselect_all), icon_list); gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0); button = gtk_button_new_with_label ("Select nonexisting"); g_signal_connect (button, "clicked", G_CALLBACK (select_nonexisting), icon_list); gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0); icon_list = gtk_icon_view_new (); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (scrolled_window), icon_list); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_paned_add2 (GTK_PANED (paned), scrolled_window); gtk_widget_show_all (window); gtk_main (); return 0; }
static GtkWidget * focus_iconview (gboolean color_bg, GtkCellRenderer **focus, GtkCellRenderer **sibling) { GtkTreeModel *model; GtkWidget *iconview; GtkCellArea *area; GtkCellRenderer *renderer, *toggle; iconview = gtk_icon_view_new (); gtk_widget_show (iconview); model = focus_list_model (); gtk_icon_view_set_model (GTK_ICON_VIEW (iconview), model); gtk_icon_view_set_item_orientation (GTK_ICON_VIEW (iconview), GTK_ORIENTATION_HORIZONTAL); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview)); renderer = gtk_cell_renderer_text_new (); g_object_set (G_OBJECT (renderer), "editable", TRUE, NULL); gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, TRUE, FALSE, FALSE); gtk_cell_area_attribute_connect (area, renderer, "text", FOCUS_COLUMN_NAME); if (color_bg) g_object_set (G_OBJECT (renderer), "cell-background", "red", NULL); g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (cell_edited), iconview); toggle = renderer = gtk_cell_renderer_toggle_new (); g_object_set (G_OBJECT (renderer), "xalign", 0.0F, NULL); gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE, FALSE); gtk_cell_area_attribute_connect (area, renderer, "active", FOCUS_COLUMN_CHECK); if (color_bg) g_object_set (G_OBJECT (renderer), "cell-background", "green", NULL); if (focus) *focus = renderer; g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (cell_toggled), iconview); renderer = gtk_cell_renderer_text_new (); g_object_set (G_OBJECT (renderer), "wrap-mode", PANGO_WRAP_WORD, "wrap-width", 150, NULL); if (color_bg) g_object_set (G_OBJECT (renderer), "cell-background", "blue", NULL); if (sibling) *sibling = renderer; gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE, FALSE); gtk_cell_area_attribute_connect (area, renderer, "text", FOCUS_COLUMN_STATIC_TEXT); gtk_cell_area_add_focus_sibling (area, toggle, renderer); return iconview; }