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
This commit is contained in:
Matthias Clasen
2007-03-12 03:13:51 +00:00
committed by Matthias Clasen
parent aa16f8e09b
commit d58a93a023
2 changed files with 22 additions and 4 deletions

View File

@ -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);