Add buttons to select and unselect all nodes, make the popup menu actually
2004-08-04 Matthias Clasen <mclasen@redhat.com> * tests/testiconview.c: Add buttons to select and unselect all nodes, make the popup menu actually work. * gtk/gtkiconview.c: Make GTK_SELECTION_BROWSE work as intended, let button 3 presses through to the app, to make popup menus work.
This commit is contained in:
committed by
Matthias Clasen
parent
8a7fd5b04f
commit
ea94ec3672
@@ -1,5 +1,12 @@
|
||||
2004-08-04 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/testiconview.c: Add buttons to select and unselect all
|
||||
nodes, make the popup menu actually work.
|
||||
|
||||
* gtk/gtkiconview.c: Make GTK_SELECTION_BROWSE work as intended,
|
||||
let button 3 presses through to the app, to make popup menus
|
||||
work.
|
||||
|
||||
* tests/Makefile.am: Add testiconview.
|
||||
* tests/testiconview.c: A test for GtkIconView
|
||||
* tests/gnome-textfile.png: ...which uses this image.
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
2004-08-04 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/testiconview.c: Add buttons to select and unselect all
|
||||
nodes, make the popup menu actually work.
|
||||
|
||||
* gtk/gtkiconview.c: Make GTK_SELECTION_BROWSE work as intended,
|
||||
let button 3 presses through to the app, to make popup menus
|
||||
work.
|
||||
|
||||
* tests/Makefile.am: Add testiconview.
|
||||
* tests/testiconview.c: A test for GtkIconView
|
||||
* tests/gnome-textfile.png: ...which uses this image.
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
2004-08-04 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/testiconview.c: Add buttons to select and unselect all
|
||||
nodes, make the popup menu actually work.
|
||||
|
||||
* gtk/gtkiconview.c: Make GTK_SELECTION_BROWSE work as intended,
|
||||
let button 3 presses through to the app, to make popup menus
|
||||
work.
|
||||
|
||||
* tests/Makefile.am: Add testiconview.
|
||||
* tests/testiconview.c: A test for GtkIconView
|
||||
* tests/gnome-textfile.png: ...which uses this image.
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
2004-08-04 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/testiconview.c: Add buttons to select and unselect all
|
||||
nodes, make the popup menu actually work.
|
||||
|
||||
* gtk/gtkiconview.c: Make GTK_SELECTION_BROWSE work as intended,
|
||||
let button 3 presses through to the app, to make popup menus
|
||||
work.
|
||||
|
||||
* tests/Makefile.am: Add testiconview.
|
||||
* tests/testiconview.c: A test for GtkIconView
|
||||
* tests/gnome-textfile.png: ...which uses this image.
|
||||
|
||||
@@ -971,7 +971,8 @@ gtk_icon_view_button_press (GtkWidget *widget,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (icon_view->priv->selection_mode == GTK_SELECTION_MULTIPLE &&
|
||||
if ((icon_view->priv->selection_mode == GTK_SELECTION_MULTIPLE ||
|
||||
((icon_view->priv->selection_mode == GTK_SELECTION_SINGLE) && item->selected)) &&
|
||||
(event->state & GDK_CONTROL_MASK))
|
||||
{
|
||||
item->selected = !item->selected;
|
||||
@@ -1038,7 +1039,7 @@ gtk_icon_view_button_press (GtkWidget *widget,
|
||||
if (dirty)
|
||||
g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0);
|
||||
|
||||
return TRUE;
|
||||
return event->button == 1;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -1277,10 +1278,9 @@ gtk_icon_view_unselect_all_internal (GtkIconView *icon_view)
|
||||
gboolean dirty = FALSE;
|
||||
GList *items;
|
||||
|
||||
if (icon_view->priv->selection_mode == GTK_SELECTION_NONE ||
|
||||
icon_view->priv->selection_mode == GTK_SELECTION_BROWSE)
|
||||
if (icon_view->priv->selection_mode == GTK_SELECTION_NONE)
|
||||
return FALSE;
|
||||
|
||||
|
||||
for (items = icon_view->priv->items; items; items = items->next)
|
||||
{
|
||||
GtkIconViewItem *item = items->data;
|
||||
@@ -1365,9 +1365,6 @@ gtk_icon_view_real_select_all (GtkIconView *icon_view)
|
||||
static void
|
||||
gtk_icon_view_real_unselect_all (GtkIconView *icon_view)
|
||||
{
|
||||
if (icon_view->priv->selection_mode == GTK_SELECTION_BROWSE)
|
||||
return;
|
||||
|
||||
gtk_icon_view_unselect_all (icon_view);
|
||||
}
|
||||
|
||||
@@ -3345,6 +3342,9 @@ gtk_icon_view_unselect_all (GtkIconView *icon_view)
|
||||
|
||||
g_return_if_fail (GTK_IS_ICON_VIEW (icon_view));
|
||||
|
||||
if (icon_view->priv->selection_mode == GTK_SELECTION_BROWSE)
|
||||
return;
|
||||
|
||||
dirty = gtk_icon_view_unselect_all_internal (icon_view);
|
||||
|
||||
if (dirty)
|
||||
|
||||
@@ -134,6 +134,17 @@ add_many (GtkWidget *button, GtkIconView *icon_list)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
select_all (GtkWidget *button, GtkIconView *icon_list)
|
||||
{
|
||||
gtk_icon_view_select_all (icon_list);
|
||||
}
|
||||
|
||||
static void
|
||||
unselect_all (GtkWidget *button, GtkIconView *icon_list)
|
||||
{
|
||||
gtk_icon_view_unselect_all (icon_list);
|
||||
}
|
||||
|
||||
static void
|
||||
selection_changed (GtkIconView *icon_list)
|
||||
@@ -141,21 +152,32 @@ selection_changed (GtkIconView *icon_list)
|
||||
g_print ("Selection changed!\n");
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GtkIconView *icon_list;
|
||||
GtkTreePath *path;
|
||||
} ItemData;
|
||||
|
||||
static void
|
||||
item_cb (GtkWidget *menuitem,
|
||||
GtkTreePath *path,
|
||||
GtkIconView *icon_list)
|
||||
free_item_data (ItemData *data)
|
||||
{
|
||||
gtk_tree_path_free (data->path);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
static void
|
||||
item_cb (GtkWidget *menuitem,
|
||||
ItemData *data)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
gchar *text;
|
||||
model = gtk_icon_view_get_model (icon_list);
|
||||
model = gtk_icon_view_get_model (data->icon_list);
|
||||
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
gtk_tree_model_get_iter (model, &iter, data->path);
|
||||
|
||||
gtk_tree_model_get (model, &iter,
|
||||
1, &text, -1);
|
||||
gtk_tree_model_get (model, &iter, 1, &text, -1);
|
||||
g_print ("Item activated, text is %s\n", text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -166,6 +188,7 @@ do_popup_menu (GtkWidget *icon_list,
|
||||
GtkWidget *menuitem;
|
||||
GtkTreePath *path;
|
||||
int button, event_time;
|
||||
ItemData *data;
|
||||
|
||||
path = gtk_icon_view_get_path_at_pos (GTK_ICON_VIEW (icon_list),
|
||||
event->x, event->y);
|
||||
@@ -176,10 +199,15 @@ do_popup_menu (GtkWidget *icon_list,
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
|
||||
data = g_new0 (ItemData, 1);
|
||||
data->icon_list = GTK_ICON_VIEW (icon_list);
|
||||
data->path = path;
|
||||
g_object_set_data_full (G_OBJECT (menu), "item-path", data, free_item_data);
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label ("Activate");
|
||||
gtk_widget_show (menuitem);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||
g_signal_connect (menuitem, "activate", G_CALLBACK (item_cb), path);
|
||||
g_signal_connect (menuitem, "activate", G_CALLBACK (item_cb), data);
|
||||
|
||||
if (event)
|
||||
{
|
||||
@@ -194,7 +222,6 @@ do_popup_menu (GtkWidget *icon_list,
|
||||
|
||||
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
|
||||
button, event_time);
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
|
||||
@@ -280,6 +307,14 @@ main (gint argc, gchar **argv)
|
||||
button = gtk_button_new_with_label ("Remove selected");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (foreach_selected_remove), icon_list);
|
||||
gtk_box_pack_start_defaults (GTK_BOX (bbox), button);
|
||||
|
||||
button = gtk_button_new_with_label ("Select all");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (select_all), icon_list);
|
||||
gtk_box_pack_start_defaults (GTK_BOX (bbox), button);
|
||||
|
||||
button = gtk_button_new_with_label ("Unselect all");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (unselect_all), icon_list);
|
||||
gtk_box_pack_start_defaults (GTK_BOX (bbox), button);
|
||||
|
||||
gtk_paned_pack1 (GTK_PANED (paned), vbox, TRUE, FALSE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user