[PATCH] Double-clicking on desktop background brings desktop up-front



Hi, I've implemented a feature I wanted to have in nautilus, that is double-clicking on the Desktop background will show desktop (minimise all opened windows).

The typical usecase is that I have some windows opened covering the desktop, I want to access some icon in the desktop so I have to spot the minimise button on each window and click it.. or go to the "show desktop" button on the left-bottom of the panel.. but is quickier to double click in some desktop space that is not covered by the opened windows.. Besides, I think it's a natural behaviour to bring the desktop up-front when you double click on it...

Hope you like the idea.

The patch is attached to this email and in http://bugzilla.gnome.org/show_bug.cgi?id=361796
Index: src/file-manager/fm-desktop-icon-view.c
===================================================================
--- src/file-manager/fm-desktop-icon-view.c	(revisión: 14183)
+++ src/file-manager/fm-desktop-icon-view.c	(copia de trabajo)
@@ -64,6 +64,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <libwnck/screen.h>
 
 /* Timeout to check the desktop directory for updates */
 #define RESCAN_TIMEOUT 4000
@@ -350,6 +351,21 @@ fm_desktop_icon_view_handle_middle_click
 }
 
 static void
+fm_desktop_icon_view_handle_double_click (NautilusIconContainer *icon_container,
+					  GdkEventButton *event,
+					  FMDesktopIconView *desktop_icon_view)
+{
+	GdkScreen       *screen;
+	WnckScreen *wnck_screen;
+	
+	screen = gtk_widget_get_screen (GTK_WIDGET (icon_container));
+	wnck_screen = wnck_screen_get (gdk_screen_get_number (screen));
+	if (wnck_screen != NULL) {
+		wnck_screen_toggle_showing_desktop (wnck_screen, TRUE);
+	}
+}
+
+static void
 unrealized_callback (GtkWidget *widget, FMDesktopIconView *desktop_icon_view)
 {
 	g_return_if_fail (desktop_icon_view->details->root_window != NULL);
@@ -571,6 +587,8 @@ fm_desktop_icon_view_init (FMDesktopIcon
 
 	g_signal_connect_object (icon_container, "middle_click",
 				 G_CALLBACK (fm_desktop_icon_view_handle_middle_click), desktop_icon_view, 0);
+	g_signal_connect_object (icon_container, "dbl_click",
+				 G_CALLBACK (fm_desktop_icon_view_handle_double_click), desktop_icon_view, 0);
 	g_signal_connect_object (desktop_icon_view, "realize",
 				 G_CALLBACK (realized_callback), desktop_icon_view, 0);
 	g_signal_connect_object (desktop_icon_view, "unrealize",
Index: configure.in
===================================================================
--- configure.in	(revisión: 14183)
+++ configure.in	(copia de trabajo)
@@ -20,6 +20,7 @@ m4_define(beagle_minver,               0
 m4_define(tracker_minver,              0.0.1)
 m4_define(exempi_minver,               1.99.2)
 m4_define(exempi_minver_newapi,        1.99.5)
+m4_define(wnck_minver,                 1.99.5)
 
 dnl 1. If the library code has changed at all since last release, then increment revision.
 dnl 2. If any interfaces have been added, then increment current and set revision to 0.
@@ -52,6 +53,7 @@ AC_SUBST(GTK_REQUIRED, [gtk_minver])
 AC_SUBST(RSVG_REQUIRED, [rsvg_minver])
 AC_SUBST(XML_REQUIRED, [xml_minver])
 AC_SUBST(STARTUP_NOTIFICATION_REQUIRED, [startup_notification_minver])
+AC_SUBST(WNCK_REQUIRED, [wnck_minver])
 
 dnl We need to decrement current by one in the calculation of the age because
 dnl the library was started with version "1:0:0" instead of "0:0:0"
@@ -99,6 +101,7 @@ PKG_CHECK_MODULES(ALL, [
 	libgnomeui-2.0		>= gnome_ui_minver
 	librsvg-2.0		>= rsvg_minver
 	libxml-2.0		>= xml_minver
+	libwnck-1.0		>= wnck_minver
 	$STARTUP_NOTIFICATION_PACKAGE
 ])
 dnl ==========================================================================
@@ -399,7 +402,7 @@ LIBNAUTILUS_EXTENSION_LIBS="`$PKG_CONFIG
 AC_SUBST(LIBNAUTILUS_EXTENSION_LIBS)
 
 dnl core nautilus (must list bonobo-activation and libbonobo because idldir does not respect "requires")
-CORE_MODULES="glib-2.0 eel-2.0 librsvg-2.0 bonobo-activation-2.0 libbonobo-2.0 gnome-desktop-2.0 gio-2.0 gio-unix-2.0 $EXTRA_CORE_MODULES"
+CORE_MODULES="glib-2.0 eel-2.0 librsvg-2.0 bonobo-activation-2.0 libbonobo-2.0 gnome-desktop-2.0 gio-2.0 gio-unix-2.0 libwnck-1.0 $EXTRA_CORE_MODULES"
 CORE_CFLAGS="`$PKG_CONFIG --cflags $CORE_MODULES` $x_cflags $WARNING_CFLAGS"
 AC_SUBST(CORE_CFLAGS)
 CORE_LIBS="`$PKG_CONFIG --libs $CORE_MODULES` $x_libs"
Index: libnautilus-private/nautilus-icon-container.c
===================================================================
--- libnautilus-private/nautilus-icon-container.c	(revisión: 14183)
+++ libnautilus-private/nautilus-icon-container.c	(copia de trabajo)
@@ -241,6 +241,7 @@ enum {
 	CONTEXT_CLICK_BACKGROUND,
 	CONTEXT_CLICK_SELECTION,
 	MIDDLE_CLICK,
+	DBL_CLICK,
 	GET_CONTAINER_URI,
 	GET_ICON_URI,
 	GET_ICON_DROP_TARGET_URI,
@@ -3672,10 +3673,11 @@ button_press_event (GtkWidget *widget,
 		return TRUE;
 	}
 
-	/* An item didn't take the press, so it's a background press.
-         * We ignore double clicks on the desktop for now.
-	 */
+	/* An item didn't take the press, so it's a background press.*/
+
 	if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) {
+		/* Double click on desktop background */
+		g_signal_emit (widget, signals[DBL_CLICK], 0, event);
 		return TRUE;
 	}
 
@@ -5045,6 +5047,16 @@ nautilus_icon_container_class_init (Naut
 		                g_cclosure_marshal_VOID__POINTER,
 		                G_TYPE_NONE, 1,
 				G_TYPE_POINTER);
+	signals[DBL_CLICK]
+		= g_signal_new ("dbl_click",
+		                G_TYPE_FROM_CLASS (class),
+		                G_SIGNAL_RUN_LAST,
+		                G_STRUCT_OFFSET (NautilusIconContainerClass,
+						 dbl_click),
+		                NULL, NULL,
+		                g_cclosure_marshal_VOID__POINTER,
+		                G_TYPE_NONE, 1,
+				G_TYPE_POINTER);
 	signals[ICON_POSITION_CHANGED]
 		= g_signal_new ("icon_position_changed",
 		                G_TYPE_FROM_CLASS (class),
Index: libnautilus-private/nautilus-icon-container.h
===================================================================
--- libnautilus-private/nautilus-icon-container.h	(revisión: 14183)
+++ libnautilus-private/nautilus-icon-container.h	(copia de trabajo)
@@ -85,6 +85,8 @@ typedef struct {
 						   GdkEventButton *event);
 	void         (* middle_click) 		  (NautilusIconContainer *container,
 						   GdkEventButton *event);
+	void         (* dbl_click) 		  (NautilusIconContainer *container,
+						   GdkEventButton *event);
 
 	/* Operations on icons. */
 	void         (* activate)	  	  (NautilusIconContainer *container,


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