summaryrefslogtreecommitdiff
path: root/tests/testiconview.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2007-03-12 03:13:51 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2007-03-12 03:13:51 +0000
commitd58a93a023f97d8d4af5766653d720bd1fb1383e (patch)
treea7d8383423d5d420c2f543ede53f9d7ae0785c57 /tests/testiconview.c
parentaa16f8e09b8a9ba332e2eed2b789e3f6b1e09eae (diff)
downloadgtk+-d58a93a023f97d8d4af5766653d720bd1fb1383e.tar.gz
Handle Menu key presses without crash. (#385637, Christian Persch)
2007-03-11 Matthias Clasen <mclasen@redhat.com> * tests/testiconview.c: Handle Menu key presses without crash. (#385637, Christian Persch) svn path=/trunk/; revision=17485
Diffstat (limited to 'tests/testiconview.c')
-rw-r--r--tests/testiconview.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/tests/testiconview.c b/tests/testiconview.c
index 1ef1464cfe..42d49a8fa4 100644
--- a/tests/testiconview.c
+++ b/tests/testiconview.c
@@ -329,14 +329,27 @@ static void
do_popup_menu (GtkWidget *icon_list,
GdkEventButton *event)
{
+ GtkIconView *icon_view = GTK_ICON_VIEW (icon_list);
GtkWidget *menu;
GtkWidget *menuitem;
- GtkTreePath *path;
+ GtkTreePath *path = NULL;
int button, event_time;
ItemData *data;
+ GList *list;
- path = gtk_icon_view_get_path_at_pos (GTK_ICON_VIEW (icon_list),
- event->x, event->y);
+ if (event)
+ path = gtk_icon_view_get_path_at_pos (icon_view, event->x, event->y);
+ else
+ {
+ list = gtk_icon_view_get_selected_items (icon_view);
+
+ if (list)
+ {
+ path = (GtkTreePath*)list->data;
+ g_list_foreach (list->next, gtk_tree_path_free, NULL);
+ g_list_free (list);
+ }
+ }
if (!path)
return;
@@ -344,7 +357,7 @@ do_popup_menu (GtkWidget *icon_list,
menu = gtk_menu_new ();
data = g_new0 (ItemData, 1);
- data->icon_list = GTK_ICON_VIEW (icon_list);
+ data->icon_list = icon_view;
data->path = path;
g_object_set_data_full (G_OBJECT (menu), "item-path", data, (GDestroyNotify)free_item_data);