[gupnp-tools] av-cp: Enable menu key on TreeView



commit b276f1356de23df9a3849daa0669d8cee7ced611
Author: Jens Georg <mail jensge org>
Date:   Mon Sep 5 19:05:07 2016 +0200

    av-cp: Enable menu key on TreeView
    
    Signed-off-by: Jens Georg <mail jensge org>

 data/gupnp-av-cp.ui.in        |    1 +
 src/av-cp/playlist-treeview.c |   35 ++++++++++++++++++++++++++++-------
 2 files changed, 29 insertions(+), 7 deletions(-)
---
diff --git a/data/gupnp-av-cp.ui.in b/data/gupnp-av-cp.ui.in
index ee4a463..5ac435f 100644
--- a/data/gupnp-av-cp.ui.in
+++ b/data/gupnp-av-cp.ui.in
@@ -621,6 +621,7 @@
                         <property name="model">playlist-tree-store</property>
                         <property name="headers_visible">False</property>
                         <signal name="button-release-event" handler="on_playlist_treeview_button_release" 
swapped="no"/>
+                        <signal name="popup-menu" handler="on_playlist_treeview_popup_menu" swapped="no"/>
                         <signal name="row-activated" handler="on_play_button_clicked" swapped="no"/>
                         <signal name="row-collapsed" handler="on_playlist_row_collapsed" swapped="no"/>
                         <signal name="row-expanded" handler="on_playlist_row_expanded" swapped="no"/>
diff --git a/src/av-cp/playlist-treeview.c b/src/av-cp/playlist-treeview.c
index f198e37..f5a0bee 100644
--- a/src/av-cp/playlist-treeview.c
+++ b/src/av-cp/playlist-treeview.c
@@ -78,6 +78,9 @@ void
 on_didl_menuitem_activate (GtkMenuItem *menuitem,
                            gpointer     user_data);
 
+gboolean
+on_playlist_treeview_popup_menu (GtkWidget *widget, gpointer user_data);
+
 static void
 on_proxy_ready (GObject *source_object,
                 GAsyncResult *res,
@@ -150,6 +153,21 @@ browse (AVCPMediaServer *content_dir,
         guint32          starting_index,
         guint32          requested_count);
 
+static void
+do_popup_menu (GtkMenu *menu, GtkWidget *widget, GdkEventButton *event)
+{
+        int button = 0;
+        int event_time;
+        if (event) {
+                button = event->button;
+                event_time = event->time;
+        } else {
+                event_time = gtk_get_current_event_time ();
+        }
+
+        gtk_menu_popup (menu, NULL, NULL, NULL, NULL, button, event_time);
+}
+
 G_MODULE_EXPORT
 gboolean
 on_playlist_treeview_button_release (GtkWidget      *widget,
@@ -171,13 +189,16 @@ on_playlist_treeview_button_release (GtkWidget      *widget,
         if (!gtk_tree_selection_get_selected (selection, &model, &iter))
                 return FALSE;
 
-        gtk_menu_popup (GTK_MENU (popup),
-                        NULL,
-                        NULL,
-                        NULL,
-                        NULL,
-                        event->button,
-                        event->time);
+        do_popup_menu (GTK_MENU (popup), treeview, event);
+
+        return TRUE;
+}
+
+G_MODULE_EXPORT
+gboolean
+on_playlist_treeview_popup_menu (GtkWidget *widget, gpointer user_data)
+{
+        do_popup_menu (GTK_MENU (popup), treeview, NULL);
 
         return TRUE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]