Commit b9f26a57 authored by Cosimo Cecchi's avatar Cosimo Cecchi

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.
parent 34c7916d
......@@ -277,6 +277,13 @@ real_window_close (NautilusWindow *window)
return;
}
static void
real_sync_view_as_menus (NautilusWindow *window)
{
/* stub, does nothing */
return;
}
static void
nautilus_desktop_window_class_init (NautilusDesktopWindowClass *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;
......
......@@ -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);
......
......@@ -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",
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment