[nautilus: 17/47] window-slot: trivial cleanups



commit 79ef5be141a55ccce67daf42b73aa0a4affa7a13
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Dec 28 17:31:50 2010 +0100

    window-slot: trivial cleanups

 src/nautilus-window-manage-views.c |   61 --------------
 src/nautilus-window-slot.c         |  154 ++++++++++++++++++++++++------------
 2 files changed, 102 insertions(+), 113 deletions(-)
---
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 9861f1b..5670809 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -632,67 +632,6 @@ nautilus_window_slot_open_location_full (NautilusWindowSlot *slot,
 	}
 }
 
-void
-nautilus_window_slot_go_home (NautilusWindowSlot *slot,
-			      gboolean new_tab)
-{			      
-	GFile *home;
-	NautilusWindowOpenFlags flags;
-
-	g_return_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot));
-
-	if (new_tab) {
-		flags = NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB;
-	} else {
-		flags = 0;
-	}
-
-	home = g_file_new_for_path (g_get_home_dir ());
-	nautilus_window_slot_open_location_full (slot, home, 
-						 NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, 
-						 flags, NULL, NULL, NULL);
-	g_object_unref (home);
-}
-
-void
-nautilus_window_slot_go_up (NautilusWindowSlot *slot,
-			    gboolean close_behind,
-			    gboolean new_tab)
-{
-	GFile *parent;
-	GList *selection;
-	NautilusWindowOpenFlags flags;
-
-	if (slot->location == NULL) {
-		return;
-	}
-	
-	parent = g_file_get_parent (slot->location);
-
-	if (parent == NULL) {
-		return;
-	}
-	
-	selection = g_list_prepend (NULL, g_object_ref (slot->location));
-	
-	flags = 0;
-	if (close_behind) {
-		flags |= NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND;
-	}
-	if (new_tab) {
-		flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB;
-	}
-
-	nautilus_window_slot_open_location (slot, parent, 
-					    NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
-					    flags,
-					    selection);
-	
-	g_object_unref (parent);
-
-	g_list_free_full (selection, g_object_unref);
-}
-
 static char *
 nautilus_window_slot_get_view_error_label (NautilusWindowSlot *slot)
 {
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index a83c584..2bd93c9 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -32,10 +32,6 @@
 #include <eel/eel-gtk-macros.h>
 #include <eel/eel-string.h>
 
-static void nautilus_window_slot_init       (NautilusWindowSlot *slot);
-static void nautilus_window_slot_class_init (NautilusWindowSlotClass *class);
-static void nautilus_window_slot_dispose    (GObject *object);
-
 G_DEFINE_TYPE (NautilusWindowSlot, nautilus_window_slot, G_TYPE_OBJECT);
 #define parent_class nautilus_window_slot_parent_class
 
@@ -167,6 +163,61 @@ nautilus_window_slot_init (NautilusWindowSlot *slot)
 }
 
 static void
+nautilus_window_slot_dispose (GObject *object)
+{
+	NautilusWindowSlot *slot;
+	GtkWidget *widget;
+
+	slot = NAUTILUS_WINDOW_SLOT (object);
+
+	if (slot->content_view) {
+		widget = nautilus_view_get_widget (slot->content_view);
+		gtk_widget_destroy (widget);
+		g_object_unref (slot->content_view);
+		slot->content_view = NULL;
+	}
+
+	if (slot->new_content_view) {
+		widget = nautilus_view_get_widget (slot->new_content_view);
+		gtk_widget_destroy (widget);
+		g_object_unref (slot->new_content_view);
+		slot->new_content_view = NULL;
+	}
+
+	nautilus_window_slot_set_viewed_file (slot, NULL);
+	/* TODO? why do we unref here? the file is NULL.
+	 * It was already here before the slot move, though */
+	nautilus_file_unref (slot->viewed_file);
+
+	if (slot->location) {
+		/* TODO? why do we ref here, instead of unreffing?
+		 * It was already here before the slot migration, though */
+		g_object_ref (slot->location);
+	}
+
+	g_list_free_full (slot->pending_selection, g_free);
+	slot->pending_selection = NULL;
+
+	g_clear_object (&slot->current_location_bookmark);
+	g_clear_object (&slot->last_location_bookmark);
+
+	if (slot->find_mount_cancellable != NULL) {
+		g_cancellable_cancel (slot->find_mount_cancellable);
+		slot->find_mount_cancellable = NULL;
+	}
+
+	slot->pane = NULL;
+
+	g_free (slot->title);
+	slot->title = NULL;
+
+	g_free (slot->status_text);
+	slot->status_text = NULL;
+
+	G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
 nautilus_window_slot_class_init (NautilusWindowSlotClass *class)
 {
 	class->active = real_active;
@@ -527,63 +578,62 @@ nautilus_window_slot_get_current_view (NautilusWindowSlot *slot)
 	return NULL;
 }
 
-static void
-nautilus_window_slot_dispose (GObject *object)
-{
-	NautilusWindowSlot *slot;
-	GtkWidget *widget;
-
-	slot = NAUTILUS_WINDOW_SLOT (object);
-
-	if (slot->content_view) {
-		widget = nautilus_view_get_widget (slot->content_view);
-		gtk_widget_destroy (widget);
-		g_object_unref (slot->content_view);
-		slot->content_view = NULL;
+void
+nautilus_window_slot_go_home (NautilusWindowSlot *slot,
+			      gboolean new_tab)
+{			      
+	GFile *home;
+	NautilusWindowOpenFlags flags;
+
+	g_return_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot));
+
+	if (new_tab) {
+		flags = NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB;
+	} else {
+		flags = 0;
 	}
 
-	if (slot->new_content_view) {
-		widget = nautilus_view_get_widget (slot->new_content_view);
-		gtk_widget_destroy (widget);
-		g_object_unref (slot->new_content_view);
-		slot->new_content_view = NULL;
-	}
+	home = g_file_new_for_path (g_get_home_dir ());
+	nautilus_window_slot_open_location_full (slot, home, 
+						 NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, 
+						 flags, NULL, NULL, NULL);
+	g_object_unref (home);
+}
 
-	nautilus_window_slot_set_viewed_file (slot, NULL);
-	/* TODO? why do we unref here? the file is NULL.
-	 * It was already here before the slot move, though */
-	nautilus_file_unref (slot->viewed_file);
+void
+nautilus_window_slot_go_up (NautilusWindowSlot *slot,
+			    gboolean close_behind,
+			    gboolean new_tab)
+{
+	GFile *parent;
+	GList *selection;
+	NautilusWindowOpenFlags flags;
 
-	if (slot->location) {
-		/* TODO? why do we ref here, instead of unreffing?
-		 * It was already here before the slot migration, though */
-		g_object_ref (slot->location);
+	if (slot->location == NULL) {
+		return;
 	}
+	
+	parent = g_file_get_parent (slot->location);
 
-	g_list_free_full (slot->pending_selection, g_free);
-	slot->pending_selection = NULL;
-
-	if (slot->current_location_bookmark != NULL) {
-		g_object_unref (slot->current_location_bookmark);
-		slot->current_location_bookmark = NULL;
+	if (parent == NULL) {
+		return;
 	}
-	if (slot->last_location_bookmark != NULL) {
-		g_object_unref (slot->last_location_bookmark);
-		slot->last_location_bookmark = NULL;
+	
+	selection = g_list_prepend (NULL, g_object_ref (slot->location));
+	
+	flags = 0;
+	if (close_behind) {
+		flags |= NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND;
 	}
-
-	if (slot->find_mount_cancellable != NULL) {
-		g_cancellable_cancel (slot->find_mount_cancellable);
-		slot->find_mount_cancellable = NULL;
+	if (new_tab) {
+		flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB;
 	}
 
-	slot->pane = NULL;
+	nautilus_window_slot_open_location (slot, parent, 
+					    NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
+					    flags,
+					    selection);
 
-	g_free (slot->title);
-	slot->title = NULL;
-
-	g_free (slot->status_text);
-	slot->status_text = NULL;
-
-	G_OBJECT_CLASS (parent_class)->dispose (object);
+	g_object_unref (parent);
+	g_list_free_full (selection, g_object_unref);
 }



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