[PATCH] No way to get contextmenu for current folder in list view



Hi,
I've posted a patch to solve long-standing issue
http://bugs.gnome.org/94618 , please see my attachment comment at the
bug, I took care of nested elements and also made a suggestion about
improving on them..

Thanks!
From b00458d9586854adb2bb834c6a11e111e20f09b4 Mon Sep 17 00:00:00 2001
From: Nelson Benitez Leon <nbenitezl gmail com>
Date: Mon, 12 Dec 2011 17:36:20 +0100
Subject: [PATCH] [List view] Show background contextual menu when clicking on
 blank space

Ignore it for blank space on nested elements because the contextual
menu shown is only for the current view folder.

Fixes bug 94618
---
 src/nautilus-list-view.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 969197c..167d51a 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -642,11 +642,13 @@ button_press_callback (GtkWidget *widget, GdkEventButton *event, gpointer callba
 	int double_click_time;
 	int expander_size, horizontal_separator;
 	gboolean on_expander;
+	gboolean blank_click;
 
 	view = NAUTILUS_LIST_VIEW (callback_data);
 	tree_view = GTK_TREE_VIEW (widget);
 	tree_view_class = GTK_WIDGET_GET_CLASS (tree_view);
 	selection = gtk_tree_view_get_selection (tree_view);
+	blank_click = FALSE;
 
 	if (event->window != gtk_tree_view_get_bin_window (tree_view)) {
 		return FALSE;
@@ -736,7 +738,10 @@ button_press_callback (GtkWidget *widget, GdkEventButton *event, gpointer callba
 			 * want that; we want the right click menu or single
 			 * click to apply to everything that's currently selected. */
 			
-			if (event->button == 3 && gtk_tree_selection_path_is_selected (selection, path)) {
+			if (event->button == 3 && 
+			    (gtk_tree_selection_path_is_selected (selection, path)
+			      || ((blank_click = gtk_tree_view_is_blank_at_pos (tree_view, event->x, event->y, NULL, NULL, NULL, NULL))
+				&& gtk_tree_path_get_depth (path) == 1))) {
 				call_parent = FALSE;
 			} 
 			
@@ -805,6 +810,9 @@ button_press_callback (GtkWidget *widget, GdkEventButton *event, gpointer callba
 			}
 			
 			if (event->button == 3) {
+				if (blank_click && gtk_tree_path_get_depth (path) == 1) {
+					gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (tree_view));
+				}
 				do_popup_menu (widget, view, event);
 			}
 		}
-- 
1.7.7.3



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