[nautilus] desktop-window: cleanups



commit ef13366e667f848adc6b96509612e3321554d188
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sat Aug 21 10:40:06 2010 +0200

    desktop-window: cleanups

 src/nautilus-desktop-window.c |   68 ++++++++++++++++++-----------------------
 1 files changed, 30 insertions(+), 38 deletions(-)
---
diff --git a/src/nautilus-desktop-window.c b/src/nautilus-desktop-window.c
index edc70ad..aa7b422 100644
--- a/src/nautilus-desktop-window.c
+++ b/src/nautilus-desktop-window.c
@@ -30,7 +30,6 @@
 #include <X11/Xatom.h>
 #include <gdk/gdkx.h>
 #include <gtk/gtk.h>
-#include <eel/eel-gtk-macros.h>
 #include <eel/eel-vfs-extensions.h>
 #include <libnautilus-private/nautilus-file-utilities.h>
 #include <libnautilus-private/nautilus-icon-names.h>
@@ -38,11 +37,9 @@
 #include <glib/gi18n.h>
 
 struct NautilusDesktopWindowDetails {
-	int dummy;
+	gulong size_changed_id;
 };
 
-static void set_wmspec_desktop_hint (GdkWindow *window);
-
 G_DEFINE_TYPE (NautilusDesktopWindow, nautilus_desktop_window, 
 	       NAUTILUS_TYPE_SPATIAL_WINDOW);
 
@@ -51,8 +48,9 @@ nautilus_desktop_window_init (NautilusDesktopWindow *window)
 {
 	GtkAction *action;
 	AtkObject *accessible;
-	
-	window->details = g_new0 (NautilusDesktopWindowDetails, 1);
+
+	window->details = G_TYPE_INSTANCE_GET_PRIVATE (window, NAUTILUS_TYPE_DESKTOP_WINDOW,
+						       NautilusDesktopWindowDetails);
 
 	gtk_window_move (GTK_WINDOW (window), 0, 0);
 
@@ -75,8 +73,10 @@ nautilus_desktop_window_init (NautilusDesktopWindow *window)
 
 	/* Set the accessible name so that it doesn't inherit the cryptic desktop URI. */
 	accessible = gtk_widget_get_accessible (GTK_WIDGET (window));
-	if (accessible)
+
+	if (accessible) {
 		atk_object_set_name (accessible, _("Desktop"));
+	}
 }
 
 static gint
@@ -146,18 +146,6 @@ nautilus_desktop_window_new (NautilusApplication *application,
 }
 
 static void
-finalize (GObject *object)
-{
-	NautilusDesktopWindow *window;
-
-	window = NAUTILUS_DESKTOP_WINDOW (object);
-
-	g_free (window->details);
-
-	G_OBJECT_CLASS (nautilus_desktop_window_parent_class)->finalize (object);
-}
-
-static void
 map (GtkWidget *widget)
 {
 	/* Chain up to realize our children */
@@ -165,14 +153,15 @@ map (GtkWidget *widget)
 	gdk_window_lower (gtk_widget_get_window (widget));
 }
 
-
 static void
 unrealize (GtkWidget *widget)
 {
 	NautilusDesktopWindow *window;
+	NautilusDesktopWindowDetails *details;
 	GdkWindow *root_window;
 
 	window = NAUTILUS_DESKTOP_WINDOW (widget);
+	details = window->details;
 
 	root_window = gdk_screen_get_root_window (
 				gtk_window_get_screen (GTK_WINDOW (window)));
@@ -180,10 +169,12 @@ unrealize (GtkWidget *widget)
 	gdk_property_delete (root_window,
 			     gdk_atom_intern ("NAUTILUS_DESKTOP_WINDOW_ID", TRUE));
 
-	g_signal_handlers_disconnect_by_func (gtk_window_get_screen (GTK_WINDOW (window)),
-					      G_CALLBACK (nautilus_desktop_window_screen_size_changed),
-					      window);
-		
+	if (details->size_changed_id != 0) {
+		g_signal_handler_disconnect (gtk_window_get_screen (GTK_WINDOW (window)),
+					     details->size_changed_id);
+		details->size_changed_id = 0;
+	}
+
 	GTK_WIDGET_CLASS (nautilus_desktop_window_parent_class)->unrealize (widget);
 }
 
@@ -224,8 +215,10 @@ static void
 realize (GtkWidget *widget)
 {
 	NautilusDesktopWindow *window;
+	NautilusDesktopWindowDetails *details;
 
 	window = NAUTILUS_DESKTOP_WINDOW (widget);
+	details = window->details;
 
 	/* Make sure we get keyboard events */
 	gtk_widget_set_events (widget, gtk_widget_get_events (widget) 
@@ -239,8 +232,9 @@ realize (GtkWidget *widget)
 
 	set_desktop_window_id (window, gtk_widget_get_window (widget));
 
-	g_signal_connect (gtk_window_get_screen (GTK_WINDOW (window)), "size_changed",
-			  G_CALLBACK (nautilus_desktop_window_screen_size_changed), window);
+	details->size_changed_id =
+		g_signal_connect (gtk_window_get_screen (GTK_WINDOW (window)), "size_changed",
+				  G_CALLBACK (nautilus_desktop_window_screen_size_changed), window);
 }
 
 static char *
@@ -257,20 +251,18 @@ real_get_icon (NautilusWindow *window,
 }
 
 static void
-nautilus_desktop_window_class_init (NautilusDesktopWindowClass *class)
+nautilus_desktop_window_class_init (NautilusDesktopWindowClass *klass)
 {
-	G_OBJECT_CLASS (class)->finalize = finalize;
-	GTK_WIDGET_CLASS (class)->realize = realize;
-	GTK_WIDGET_CLASS (class)->unrealize = unrealize;
-
-
-	GTK_WIDGET_CLASS (class)->map = map;
+	GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
+	NautilusWindowClass *nclass = NAUTILUS_WINDOW_CLASS (klass);
 
-	NAUTILUS_WINDOW_CLASS (class)->window_type = NAUTILUS_WINDOW_DESKTOP;
+	wclass->realize = realize;
+	wclass->unrealize = unrealize;
+	wclass->map = map;
 
-	NAUTILUS_WINDOW_CLASS (class)->get_title 
-		= real_get_title;
-	NAUTILUS_WINDOW_CLASS (class)->get_icon
-		= real_get_icon;
+	nclass->window_type = NAUTILUS_WINDOW_DESKTOP;
+	nclass->get_title = real_get_title;
+	nclass->get_icon = real_get_icon;
 
+	g_type_class_add_private (klass, sizeof (NautilusDesktopWindowDetails));
 }



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