[nautilus] window: cleanup delete-event handling



commit c00d47b32c60869d6dcdfd1e15368b3a22ac3fcb
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Apr 23 18:31:59 2012 -0400

    window: cleanup delete-event handling
    
    Always handle it in a class handler.

 src/nautilus-desktop-window.c |   18 +++++++++---------
 src/nautilus-window.c         |   11 +++++++++--
 2 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/src/nautilus-desktop-window.c b/src/nautilus-desktop-window.c
index 55ee447..d0d48cc 100644
--- a/src/nautilus-desktop-window.c
+++ b/src/nautilus-desktop-window.c
@@ -132,13 +132,6 @@ nautilus_desktop_window_init (NautilusDesktopWindow *window)
 			   GINT_TO_POINTER (1));
 }
 
-static gint
-nautilus_desktop_window_delete_event (NautilusDesktopWindow *window)
-{
-	/* Returning true tells GTK+ not to delete the window. */
-	return TRUE;
-}
-
 static void
 nautilus_desktop_window_screen_size_changed (GdkScreen             *screen,
 					     NautilusDesktopWindow *window)
@@ -173,8 +166,6 @@ nautilus_desktop_window_new (GdkScreen *screen)
 	/* Special sawmill setting*/
 	gtk_window_set_wmclass (GTK_WINDOW (window), "desktop_window", "Nautilus");
 
-	g_signal_connect (window, "delete_event", G_CALLBACK (nautilus_desktop_window_delete_event), NULL);
-
 	/* Point window at the desktop folder.
 	 * Note that nautilus_desktop_window_init is too early to do this.
 	 */
@@ -183,6 +174,14 @@ nautilus_desktop_window_new (GdkScreen *screen)
 	return window;
 }
 
+static gboolean
+nautilus_desktop_window_delete_event (GtkWidget *widget,
+				      GdkEventAny *event)
+{
+	/* Returning true tells GTK+ not to delete the window. */
+	return TRUE;
+}
+
 static void
 map (GtkWidget *widget)
 {
@@ -310,6 +309,7 @@ nautilus_desktop_window_class_init (NautilusDesktopWindowClass *klass)
 	wclass->realize = realize;
 	wclass->unrealize = unrealize;
 	wclass->map = map;
+	wclass->delete_event = nautilus_desktop_window_delete_event;
 
 	nclass->sync_title = real_sync_title;
 	nclass->get_icon = real_get_icon;
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index a141465..f0cc616 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -532,8 +532,6 @@ nautilus_window_constructed (GObject *self)
 
 	G_OBJECT_CLASS (nautilus_window_parent_class)->constructed (self);
 
-	g_signal_connect_after (window, "delete-event",
-				G_CALLBACK (nautilus_window_close), NULL);
 
 	grid = gtk_grid_new ();
 	gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
@@ -1800,6 +1798,14 @@ nautilus_window_state_event (GtkWidget *widget,
 }
 
 static gboolean
+nautilus_window_delete_event (GtkWidget *widget,
+			      GdkEventAny *event)
+{
+	nautilus_window_close (NAUTILUS_WINDOW (widget));
+	return FALSE;
+}
+
+static gboolean
 nautilus_window_button_press_event (GtkWidget *widget,
 				    GdkEventButton *event)
 {
@@ -1915,6 +1921,7 @@ nautilus_window_class_init (NautilusWindowClass *class)
 	wclass->key_press_event = nautilus_window_key_press_event;
 	wclass->window_state_event = nautilus_window_state_event;
 	wclass->button_press_event = nautilus_window_button_press_event;
+	wclass->delete_event = nautilus_window_delete_event;
 
 	class->get_icon = real_get_icon;
 	class->close = real_window_close;



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