From 7f527c149ea36b3c7006fb1654a783fa398a8a2e Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sun, 8 Jun 2014 13:12:24 +0200 Subject: gtkui: popup-menu event handler --- plugins/gtkui/ddblistview.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'plugins') diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c index e5e5d584..83c8d7d6 100644 --- a/plugins/gtkui/ddblistview.c +++ b/plugins/gtkui/ddblistview.c @@ -203,6 +203,9 @@ ddb_listview_list_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data); +gboolean +ddb_listview_list_popup_menu (GtkWidget *widget, gpointer user_data); + gboolean ddb_listview_list_drag_motion (GtkWidget *widget, GdkDragContext *drag_context, @@ -446,6 +449,9 @@ ddb_listview_init(DdbListview *listview) g_signal_connect_after ((gpointer) listview->list, "button_press_event", G_CALLBACK (ddb_listview_list_button_press_event), NULL); + g_signal_connect ((gpointer) listview->list, "popup_menu", + G_CALLBACK (ddb_listview_list_popup_menu), + NULL); g_signal_connect ((gpointer) listview->list, "scroll_event", G_CALLBACK (ddb_listview_vscroll_event), NULL); @@ -2154,6 +2160,23 @@ ddb_listview_handle_keypress (DdbListview *ps, int keyval, int state) { return TRUE; } +gboolean +ddb_listview_list_popup_menu (GtkWidget *widget, gpointer user_data) { + DdbListview *ps = DDB_LISTVIEW (g_object_get_data (G_OBJECT (widget), "owner")); + DdbListviewIter it = ps->binding->head (); + while (it && !ps->binding->is_selected (it)) { + DdbListviewIter next = ps->binding->next (it); + ps->binding->unref (it); + it = next; + } + if (it) { + int sel = ps->binding->get_idx (it); + ps->binding->list_context_menu (ps, it, sel); + ps->binding->unref (it); + } + return TRUE; +} + int ddb_listview_dragdrop_get_row_from_coord (DdbListview *listview, int y) { if (y == -1) { -- cgit v1.2.3