[nautilus-actions] NactTreeView: open the context menu with keybindings
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] NactTreeView: open the context menu with keybindings
- Date: Thu, 2 Feb 2012 21:43:18 +0000 (UTC)
commit fe497fb0ad6959644564eb1921c08c4314bd5b7e
Author: Pierre Wieser <pwieser trychlos org>
Date: Thu Feb 2 20:08:50 2012 +0100
NactTreeView: open the context menu with keybindings
ChangeLog | 6 ++++++
src/nact/nact-menubar.c | 10 ++++++++--
src/nact/nact-tree-view.c | 32 +++++++++++++++++++++++++-------
3 files changed, 39 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9641dac..49fe70f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2012-02-02 Pierre Wieser <pwieser trychlos org>
+ * src/nact/nact-menubar.c (on_open_context_menu): Manages if event is
+ NULL.
+
+ * src/nact/nact-tree-view.c: Manages to open the context menu with
+ keyboard.
+
* src/core/na-iprefs.c: Fix enumeration maps as it only works for data
greater than zero.
diff --git a/src/nact/nact-menubar.c b/src/nact/nact-menubar.c
index 78b5fe8..c4f9fb1 100644
--- a/src/nact/nact-menubar.c
+++ b/src/nact/nact-menubar.c
@@ -627,6 +627,7 @@ on_menu_item_deselected( GtkMenuItem *proxy, BaseWindow *window )
static void
on_open_context_menu( BaseWindow *window, GdkEventButton *event, const gchar *popup, gpointer user_data )
{
+ static const gchar *thisfn = "nact_menubar_on_open_context_menu";
GtkWidget *menu;
BAR_WINDOW_VOID( window );
@@ -639,8 +640,13 @@ on_open_context_menu( BaseWindow *window, GdkEventButton *event, const gchar *po
"selection-done",
G_CALLBACK( on_popup_selection_done ),
window );
-
- gtk_menu_popup( GTK_MENU( menu ), NULL, NULL, NULL, NULL, event->button, event->time );
+ if( event ){
+ gtk_menu_popup( GTK_MENU( menu ), NULL, NULL, NULL, NULL, event->button, event->time );
+ } else {
+ gtk_menu_popup( GTK_MENU( menu ), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
+ }
+ } else {
+ g_warning( "%s: menu not found: %s", thisfn, popup );
}
}
diff --git a/src/nact/nact-tree-view.c b/src/nact/nact-tree-view.c
index 8145e24..d8f7153 100644
--- a/src/nact/nact-tree-view.c
+++ b/src/nact/nact-tree-view.c
@@ -131,6 +131,7 @@ static gboolean on_button_press_event( GtkWidget *widget, GdkEventButton *even
static gboolean on_focus_in( GtkWidget *widget, GdkEventFocus *event, BaseWindow *window );
static gboolean on_focus_out( GtkWidget *widget, GdkEventFocus *event, BaseWindow *window );
static gboolean on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, BaseWindow *window );
+static gboolean on_popup_menu( GtkWidget *widget, BaseWindow *window );
static void on_selection_changed( GtkTreeSelection *selection, BaseWindow *window );
static void on_selection_changed_cleanup_handler( BaseWindow *window, GList *selected_items );
static void on_tree_view_realized( GtkWidget *treeview, BaseWindow *window );
@@ -142,7 +143,7 @@ static GtkWidget *get_tree_view( NactTreeView *items_view );
static void iter_on_selection( NactTreeView *view, FnIterOnSelection fn_iter, gpointer user_data );
static void navigate_to_child( NactTreeView *view );
static void navigate_to_parent( NactTreeView *view );
-static void open_popup( BaseWindow *window, GdkEventButton *event );
+static void do_open_popup( BaseWindow *window, GdkEventButton *event );
static void select_row_at_path_by_string( NactTreeView *view, const gchar *path );
static void toggle_collapse( NactTreeView *view );
static gboolean toggle_collapse_iter( NactTreeView *view, GtkTreeModel *model, GtkTreeIter *iter, NAObject *object, gpointer user_data );
@@ -773,7 +774,7 @@ on_button_press_event( GtkWidget *widget, GdkEventButton *event, BaseWindow *win
/* single click on right button */
if( event->type == GDK_BUTTON_PRESS && event->button == 3 ){
- open_popup( window, event );
+ do_open_popup( window, event );
stop = TRUE;
}
@@ -834,6 +835,15 @@ on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, BaseWindow *window
}
/*
+ * triggered by the "popup-menu" signal, itself triggered by the keybindings
+ */
+static gboolean
+on_popup_menu( GtkWidget *widget, BaseWindow *window )
+{
+ do_open_popup( window, NULL );
+ return( TRUE );
+}
+/*
* handles the "changed" signal emitted on the GtkTreeSelection
*/
static void
@@ -902,6 +912,12 @@ on_tree_view_realized( GtkWidget *treeview, BaseWindow *window )
"button-press-event",
G_CALLBACK( on_button_press_event ));
+ base_window_signal_connect(
+ window,
+ G_OBJECT( treeview ),
+ "popup-menu",
+ G_CALLBACK( on_popup_menu ));
+
/* force the treeview to have the focus at start
* and select the first row if it exists
*/
@@ -1399,16 +1415,18 @@ navigate_to_parent( NactTreeView *view )
}
static void
-open_popup( BaseWindow *window, GdkEventButton *event )
+do_open_popup( BaseWindow *window, GdkEventButton *event )
{
NactTreeView *items_view;
GtkTreePath *path;
- items_view = NACT_TREE_VIEW( g_object_get_data( G_OBJECT( window ), WINDOW_DATA_TREE_VIEW ));
+ if( event ){
+ items_view = NACT_TREE_VIEW( g_object_get_data( G_OBJECT( window ), WINDOW_DATA_TREE_VIEW ));
- if( gtk_tree_view_get_path_at_pos( items_view->private->tree_view, event->x, event->y, &path, NULL, NULL, NULL )){
- nact_tree_view_select_row_at_path( items_view, path );
- gtk_tree_path_free( path );
+ if( gtk_tree_view_get_path_at_pos( items_view->private->tree_view, event->x, event->y, &path, NULL, NULL, NULL )){
+ nact_tree_view_select_row_at_path( items_view, path );
+ gtk_tree_path_free( path );
+ }
}
g_signal_emit_by_name( window, MAIN_SIGNAL_CONTEXT_MENU, event, "/ui/TreeContext" );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]