[nautilus] window: never sync the View As actions for the desktop



commit b9f26a571fd34db656005742fae9df5b515ea514
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Aug 28 17:30:49 2012 -0400

    window: never sync the View As actions for the desktop
    
    Since doing so can set a view_id != NAUTILUS_DESKTOP_CANVAS_VIEW_ID to
    its view, which will have bad consequences (i.e. a crash) when
    finalizing the views at application quit.
    This commit fixes it by making sync_view_as_menus an overriddable class
    method.

 src/nautilus-desktop-window.c |    8 ++++++++
 src/nautilus-window-private.h |    3 ++-
 src/nautilus-window.c         |   31 ++++++++++++++++++++-----------
 src/nautilus-window.h         |    1 +
 4 files changed, 31 insertions(+), 12 deletions(-)
---
diff --git a/src/nautilus-desktop-window.c b/src/nautilus-desktop-window.c
index 10ea225..6b78ca3 100644
--- a/src/nautilus-desktop-window.c
+++ b/src/nautilus-desktop-window.c
@@ -278,6 +278,13 @@ real_window_close (NautilusWindow *window)
 }
 
 static void
+real_sync_view_as_menus (NautilusWindow *window)
+{
+	/* stub, does nothing */
+	return;
+}
+
+static void
 nautilus_desktop_window_class_init (NautilusDesktopWindowClass *klass)
 {
 	GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
@@ -292,6 +299,7 @@ nautilus_desktop_window_class_init (NautilusDesktopWindowClass *klass)
 	wclass->delete_event = nautilus_desktop_window_delete_event;
 
 	nclass->sync_title = real_sync_title;
+	nclass->sync_view_as_menus = real_sync_view_as_menus;
 	nclass->get_icon = real_get_icon;
 	nclass->close = real_window_close;
 
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index ca9e57e..fce6e9f 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -96,7 +96,6 @@ struct NautilusWindowDetails
 typedef void (*NautilusBookmarkFailedCallback) (NautilusWindow *window,
                                                 NautilusBookmark *bookmark);
 
-void               nautilus_window_sync_view_as_menus                    (NautilusWindow    *window);
 void               nautilus_window_load_extension_menus                  (NautilusWindow    *window);
 
 NautilusWindowSlot *nautilus_window_get_slot_for_view                    (NautilusWindow *window,
@@ -115,6 +114,8 @@ void nautilus_window_sync_title            (NautilusWindow *window,
 					    NautilusWindowSlot *slot);
 void nautilus_window_sync_zoom_widgets     (NautilusWindow *window);
 void nautilus_window_sync_up_button        (NautilusWindow *window);
+void nautilus_window_sync_view_as_menus    (NautilusWindow *window);
+
 
 void nautilus_window_set_search_visible   (NautilusWindow *window,
                                            gboolean        visible);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index a2497f9..95bf43c 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1445,17 +1445,8 @@ nautilus_window_key_press_event (GtkWidget *widget,
  * Main API
  */
 
-/**
- * nautilus_window_sync_view_as_menus:
- * 
- * Set the visible item of the "View as" option menu and
- * the marked "View as" item in the View menu to
- * match the current content view.
- * 
- * @window: The NautilusWindow whose "View as" option menu should be synched.
- */
-void
-nautilus_window_sync_view_as_menus (NautilusWindow *window)
+static void
+real_sync_view_as_menus (NautilusWindow *window)
 {
 	NautilusWindowSlot *slot;
 	GtkActionGroup *action_group;
@@ -1480,6 +1471,23 @@ nautilus_window_sync_view_as_menus (NautilusWindow *window)
 	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
 }
 
+/**
+ * nautilus_window_sync_view_as_menus:
+ *
+ * Set the visible item of the "View as" option menu and
+ * the marked "View as" item in the View menu to
+ * match the current content view.
+ *
+ * @window: The NautilusWindow whose "View as" option menu should be synched.
+ */
+void
+nautilus_window_sync_view_as_menus (NautilusWindow *window)
+{
+	if (NAUTILUS_WINDOW_CLASS (G_OBJECT_GET_CLASS (window))->sync_view_as_menus != NULL) {
+		NAUTILUS_WINDOW_CLASS (G_OBJECT_GET_CLASS (window))->sync_view_as_menus (window);
+	}
+}
+
 void
 nautilus_window_sync_up_button (NautilusWindow *window)
 {
@@ -1925,6 +1933,7 @@ nautilus_window_class_init (NautilusWindowClass *class)
 
 	class->get_icon = real_get_icon;
 	class->close = real_window_close;
+	class->sync_view_as_menus = real_sync_view_as_menus;
 
 	properties[PROP_DISABLE_CHROME] =
 		g_param_spec_boolean ("disable-chrome",
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index 8a79966..ecc200f 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -78,6 +78,7 @@ typedef struct {
 
         void   (* sync_title) (NautilusWindow *window,
 			       NautilusWindowSlot *slot);
+        void   (* sync_view_as_menus) (NautilusWindow *window);
         NautilusIconInfo * (* get_icon) (NautilusWindow *window,
                                          NautilusWindowSlot *slot);
 



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