[nautilus] search: use a separate view setting for search



commit a88310dd2143476bf34d2d892807d0457d2f7d85
Author: Carlos Soriano <csoriano gnome org>
Date:   Wed Feb 10 21:35:33 2016 +0100

    search: use a separate view setting for search
    
    So we can select what type of view do we want for search independently
    of what we normally use.
    
    This is needed since we default to switch to list view for search, but
    we would like to allow users to select a different view. However,
    instead of adding a preference in the preference dialog, we can do it
    more straightforward and change the setting when we are in search.
    
    On the way, rework all the enums and views id for a saner code...

 data/org.gnome.nautilus.gschema.xml               |    8 +-
 libnautilus-private/nautilus-global-preferences.c |   21 ----
 libnautilus-private/nautilus-global-preferences.h |   12 +--
 src/nautilus-canvas-view.c                        |    4 +-
 src/nautilus-desktop-canvas-view.c                |    4 +-
 src/nautilus-empty-view.c                         |    4 +-
 src/nautilus-files-view.c                         |   22 ++--
 src/nautilus-files-view.h                         |   22 ++--
 src/nautilus-list-view.c                          |    4 +-
 src/nautilus-window-slot.c                        |  131 ++++++++-------------
 src/resources/ui/nautilus-toolbar-view-menu.ui    |    4 +-
 11 files changed, 89 insertions(+), 147 deletions(-)
---
diff --git a/data/org.gnome.nautilus.gschema.xml b/data/org.gnome.nautilus.gschema.xml
index 463200c..7b735c5 100644
--- a/data/org.gnome.nautilus.gschema.xml
+++ b/data/org.gnome.nautilus.gschema.xml
@@ -192,10 +192,10 @@
       <summary>Whether to show hidden files</summary>
       <description>This key is deprecated and ignored. The "show-hidden" key from 
"org.gtk.Settings.FileChooser" is now used instead.</description>
     </key>
-    <key type="b" name="list-view-on-search">
-      <default>true</default>
-      <summary>Whether to switch to the list view on search</summary>
-      <description>If this is set to true, view mode will be switched to the list view while searching. 
However, if the user changes the mode manually, this will be disabled.</description>
+    <key name="search-view" enum="org.gnome.nautilus.FolderView">
+      <default>'icon-view'</default>
+      <summary>What viewer should be used when searching</summary>
+      <description>When searching Nautilus will switch to the type of view in this setting.</description>
     </key>
     <key type="ay" name="bulk-rename-tool">
       <default>[]</default>
diff --git a/libnautilus-private/nautilus-global-preferences.c 
b/libnautilus-private/nautilus-global-preferences.c
index 15d8f80..7a0788b 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -45,27 +45,6 @@ GSettings *gnome_background_preferences;
 GSettings *gnome_interface_preferences;
 GSettings *gnome_privacy_preferences;
 
-/*
- * Public functions
- */
-char *
-nautilus_global_preferences_get_default_folder_viewer_preference_as_iid (void)
-{
-       int preference_value;
-       const char *viewer_iid;
-
-       preference_value =
-               g_settings_get_enum (nautilus_preferences, NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER);
-
-       if (preference_value == NAUTILUS_DEFAULT_FOLDER_VIEWER_LIST_VIEW) {
-               viewer_iid = NAUTILUS_LIST_VIEW_ID;
-       } else {
-               viewer_iid = NAUTILUS_CANVAS_VIEW_ID;
-       }
-
-       return g_strdup (viewer_iid);
-}
-
 void
 nautilus_global_preferences_init (void)
 {
diff --git a/libnautilus-private/nautilus-global-preferences.h 
b/libnautilus-private/nautilus-global-preferences.h
index 727ff32..cd0e134 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -78,13 +78,6 @@ typedef enum
 /* The default folder viewer - one of the two enums below */
 #define NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER             "default-folder-viewer"
 
-enum
-{
-       NAUTILUS_DEFAULT_FOLDER_VIEWER_ICON_VIEW,
-       NAUTILUS_DEFAULT_FOLDER_VIEWER_LIST_VIEW,
-       NAUTILUS_DEFAULT_FOLDER_VIEWER_OTHER
-};
-
 /* Icon View */
 #define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL              "default-zoom-level"
 
@@ -159,8 +152,8 @@ typedef enum
 /* Move to trash shorcut changed dialog */
 #define NAUTILUS_PREFERENCES_SHOW_MOVE_TO_TRASH_SHORTCUT_CHANGED_DIALOG 
"show-move-to-trash-shortcut-changed-dialog"
 
-/* Switch to list view while searching */
-#define NAUTILUS_PREFERENCES_LIST_VIEW_ON_SEARCH "list-view-on-search"
+/* Default view when searching */
+#define NAUTILUS_PREFERENCES_SEARCH_VIEW "search-view"
 
 /* Search behaviour */
 #define NAUTILUS_PREFERENCES_LOCAL_RECURSIVE_SEARCH "local-recursive-search"
@@ -171,7 +164,6 @@ typedef enum
 #define NAUTILUS_PREFERENCES_SHOW_CREATE_LINK "show-create-link"
 
 void nautilus_global_preferences_init                      (void);
-char *nautilus_global_preferences_get_default_folder_viewer_preference_as_iid (void);
 
 extern GSettings *nautilus_preferences;
 extern GSettings *nautilus_icon_view_preferences;
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index 1d498e0..a5de12a 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -1811,10 +1811,10 @@ canvas_view_scroll_to_file (NautilusFilesView *view,
        }
 }
 
-static const char *
+static guint
 nautilus_canvas_view_get_id (NautilusFilesView *view)
 {
-       return NAUTILUS_CANVAS_VIEW_ID;
+       return NAUTILUS_VIEW_GRID_ID;
 }
 
 static void
diff --git a/src/nautilus-desktop-canvas-view.c b/src/nautilus-desktop-canvas-view.c
index 49224aa..361d205 100644
--- a/src/nautilus-desktop-canvas-view.c
+++ b/src/nautilus-desktop-canvas-view.c
@@ -216,10 +216,10 @@ desktop_canvas_view_property_filter (GdkXEvent *gdk_xevent,
        return GDK_FILTER_CONTINUE;
 }
 
-static const char *
+static guint
 real_get_id (NautilusFilesView *view)
 {
-       return NAUTILUS_DESKTOP_VIEW_ID;
+       return NAUTILUS_VIEW_DESKTOP_ID;
 }
 
 static void
diff --git a/src/nautilus-empty-view.c b/src/nautilus-empty-view.c
index f87351d..5f42620 100644
--- a/src/nautilus-empty-view.c
+++ b/src/nautilus-empty-view.c
@@ -223,10 +223,10 @@ nautilus_empty_view_sort_directories_first_changed (NautilusFilesView *view)
 {
 }
 
-static const char *
+static guint
 nautilus_empty_view_get_id (NautilusFilesView *view)
 {
-       return NAUTILUS_EMPTY_VIEW_ID;
+       return NAUTILUS_VIEW_EMPTY_ID;
 }
 
 static GIcon*
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index cb89274..bdb1a3e 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -876,7 +876,7 @@ nautilus_files_view_is_searching (NautilusView *view)
   return NAUTILUS_IS_SEARCH_DIRECTORY (files_view->details->model);
 }
 
-const char *
+guint
 nautilus_files_view_get_view_id (NautilusFilesView *view)
 {
         return NAUTILUS_FILES_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_view_id (view);
@@ -8290,26 +8290,30 @@ nautilus_files_view_init (NautilusFilesView *view)
 }
 
 NautilusFilesView *
-nautilus_files_view_new (const gchar        *id,
+nautilus_files_view_new (guint                id,
                          NautilusWindowSlot *slot)
 {
         NautilusFilesView *view = NULL;
 
-        if (g_strcmp0 (id, NAUTILUS_CANVAS_VIEW_ID) == 0) {
+        switch (id) {
+        case NAUTILUS_VIEW_GRID_ID:
                 view = nautilus_canvas_view_new (slot);
-        } else if (g_strcmp0 (id, NAUTILUS_LIST_VIEW_ID) == 0) {
+        break;
+        case NAUTILUS_VIEW_LIST_ID:
                 view = nautilus_list_view_new (slot);
-        } else if (g_strcmp0 (id, NAUTILUS_DESKTOP_VIEW_ID) == 0) {
+        break;
+        case NAUTILUS_VIEW_DESKTOP_ID:
                 view = nautilus_desktop_canvas_view_new (slot);
-        }
+        break;
 #if ENABLE_EMPTY_VIEW
-        else if (g_strcmp0 (id, NAUTILUS_EMPTY_VIEW_ID) == 0) {
+        case NAUTILUS_VIEW_EMPTY_ID:
                 view = nautilus_empty_view_new (slot);
-        }
+        break;
 #endif
+        }
 
         if (view == NULL) {
-                g_critical ("Unknown view type ID: %s", id);
+                g_critical ("Unknown view type ID: %d", id);
         } else if (g_object_is_floating (view)) {
                 g_object_ref_sink (view);
         }
diff --git a/src/nautilus-files-view.h b/src/nautilus-files-view.h
index 4873fa5..4fb1c52 100644
--- a/src/nautilus-files-view.h
+++ b/src/nautilus-files-view.h
@@ -39,13 +39,13 @@ typedef struct NautilusFilesViewClass NautilusFilesViewClass;
 #include "nautilus-window.h"
 #include "nautilus-window-slot.h"
 
-#if ENABLE_EMPTY_VIEW
-#define NAUTILUS_EMPTY_VIEW_ID "empty"
-#endif
-
-#define NAUTILUS_CANVAS_VIEW_ID "grid"
-#define NAUTILUS_DESKTOP_VIEW_ID "desktop"
-#define NAUTILUS_LIST_VIEW_ID "list"
+enum {
+  NAUTILUS_VIEW_GRID_ID,
+  NAUTILUS_VIEW_LIST_ID,
+  NAUTILUS_VIEW_DESKTOP_ID,
+  NAUTILUS_VIEW_EMPTY_ID,
+  NAUTILUS_VIEW_INVALID_ID,
+};
 
 #define NAUTILUS_TYPE_FILES_VIEW nautilus_files_view_get_type()
 #define NAUTILUS_FILES_VIEW(obj)\
@@ -265,8 +265,8 @@ struct NautilusFilesViewClass {
         void        (* click_policy_changed) (NautilusFilesView *view);
         void        (* sort_directories_first_changed) (NautilusFilesView *view);
 
-        /* Get the id string for this view. Its a constant string, not memory managed */
-        const char *   (* get_view_id)       (NautilusFilesView *view);
+        /* Get the id for this view. Its a guint*/
+        guint        (* get_view_id)       (NautilusFilesView *view);
 
         /* Return the uri of the first visible file */
         char *         (* get_first_visible_file) (NautilusFilesView          *view);
@@ -285,7 +285,7 @@ struct NautilusFilesViewClass {
 /* GObject support */
 GType               nautilus_files_view_get_type                         (void);
 
-NautilusFilesView *      nautilus_files_view_new                         (const gchar        *id,
+NautilusFilesView *      nautilus_files_view_new                         (guint               id,
                                                                           NautilusWindowSlot *slot);
 
 /* Functions callable from the user interface and elsewhere. */
@@ -339,7 +339,7 @@ gboolean            nautilus_files_view_is_editable              (NautilusFilesV
 NautilusWindow *    nautilus_files_view_get_window               (NautilusFilesView      *view);
 
 /* NautilusFilesView methods */
-const char *      nautilus_files_view_get_view_id                (NautilusFilesView      *view);
+guint               nautilus_files_view_get_view_id                (NautilusFilesView      *view);
 
 /* file operations */
 char *            nautilus_files_view_get_backing_uri            (NautilusFilesView      *view);
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 3fde3f9..9de03be 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -3061,10 +3061,10 @@ nautilus_list_view_end_loading (NautilusFilesView *view,
        list_view_notify_clipboard_info (monitor, info, NAUTILUS_LIST_VIEW (view));
 }
 
-static const char *
+static guint
 nautilus_list_view_get_id (NautilusFilesView *view)
 {
-       return NAUTILUS_LIST_VIEW_ID;
+       return NAUTILUS_VIEW_LIST_ID;
 }
 
 static GdkRectangle*
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 9d20fb2..92a88a2 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
 
    nautilus-window-slot.c: Nautilus window slot
  
@@ -122,8 +122,8 @@ struct NautilusWindowSlotDetails {
        GCancellable *mount_cancellable;
        GError *mount_error;
        gboolean tried_mount;
-        gchar *view_mode_before_search;
-        gchar *view_mode_before_places;
+        gint view_mode_before_search;
+        gint view_mode_before_places;
 };
 
 static guint signals[LAST_SIGNAL] = { 0 };
@@ -135,9 +135,9 @@ static void hide_query_editor (NautilusWindowSlot *slot);
 static void nautilus_window_slot_sync_actions (NautilusWindowSlot *slot);
 static void nautilus_window_slot_connect_new_content_view (NautilusWindowSlot *slot);
 static void nautilus_window_slot_disconnect_content_view (NautilusWindowSlot *slot);
-static gboolean nautilus_window_slot_content_view_matches (NautilusWindowSlot *slot, const char *iid);
+static gboolean nautilus_window_slot_content_view_matches (NautilusWindowSlot *slot, guint id);
 static NautilusView* nautilus_window_slot_get_view_for_location (NautilusWindowSlot *slot, GFile *location);
-static void nautilus_window_slot_set_content_view (NautilusWindowSlot *slot, const char        *id);
+static void nautilus_window_slot_set_content_view (NautilusWindowSlot *slot, guint id);
 static void nautilus_window_slot_set_loading (NautilusWindowSlot *slot, gboolean loading);
 char * nautilus_window_slot_get_location_uri (NautilusWindowSlot *slot);
 static void nautilus_window_slot_set_search_visible (NautilusWindowSlot *slot,
@@ -163,56 +163,47 @@ nautilus_window_slot_get_view_for_location (NautilusWindowSlot *slot,
         * for the desktop window.
         */
         if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
-                view = NAUTILUS_VIEW (nautilus_files_view_new (NAUTILUS_DESKTOP_VIEW_ID, slot));
+                view = NAUTILUS_VIEW (nautilus_files_view_new (NAUTILUS_VIEW_DESKTOP_ID, slot));
         } else if (nautilus_file_is_other_locations (file)) {
                 view = NAUTILUS_VIEW (nautilus_places_view_new ());
 
                 /* Save the current view, so we can go back after places view */
                 if (slot->details->content_view && NAUTILUS_IS_FILES_VIEW (slot->details->content_view)) {
-                        g_clear_pointer (&slot->details->view_mode_before_places, g_free);
-                        slot->details->view_mode_before_places = g_strdup (nautilus_files_view_get_view_id 
(NAUTILUS_FILES_VIEW (slot->details->content_view)));
+                        slot->details->view_mode_before_places = nautilus_files_view_get_view_id 
(NAUTILUS_FILES_VIEW (slot->details->content_view));
                 }
         } else {
-                gchar *view_id;
+                guint view_id;
 
-                view_id = NULL;
+                view_id = NAUTILUS_VIEW_INVALID_ID;
 
-                /* If we are in search, try to use by default list view. This will be deactivated
-                 * if the user manually switch to a diferent view mode */
+                /* If we are in search, try to use by default list view. */
                 if (nautilus_file_is_in_search (file)) {
-                        if (g_settings_get_boolean (nautilus_preferences, 
NAUTILUS_PREFERENCES_LIST_VIEW_ON_SEARCH)) {
-                                /* If it's already set, is because we already made the change to search mode,
-                                 * so the view mode of the current view will be the one search is using,
-                                 * which is not the one we are interested in */
-                                if (slot->details->view_mode_before_search == NULL) {
-                                        slot->details->view_mode_before_search = g_strdup 
(nautilus_files_view_get_view_id (NAUTILUS_FILES_VIEW (slot->details->content_view)));
-                                }
-                                view_id = g_strdup (NAUTILUS_LIST_VIEW_ID);
-                        } else {
-                                g_free (slot->details->view_mode_before_search);
-                                slot->details->view_mode_before_search = NULL;
+                        /* If it's already set, is because we already made the change to search mode,
+                         * so the view mode of the current view will be the one search is using,
+                         * which is not the one we are interested in */
+                        if (slot->details->view_mode_before_search == NAUTILUS_VIEW_INVALID_ID) {
+                                slot->details->view_mode_before_search = nautilus_files_view_get_view_id 
(NAUTILUS_FILES_VIEW (slot->details->content_view));
                         }
-                }
-
-                /* If there is already a view, just use the view mode that it's currently using, or
-                 * if we were on search before, use what we were using before entering
-                 * search mode */
-               if (slot->details->content_view != NULL && view_id == NULL) {
-                        if (slot->details->view_mode_before_search != NULL) {
+                        view_id = g_settings_get_enum (nautilus_preferences, 
NAUTILUS_PREFERENCES_SEARCH_VIEW);
+                } else if (slot->details->content_view != NULL) {
+                        /* If there is already a view, just use the view mode that it's currently using, or
+                         * if we were on search before, use what we were using before entering
+                         * search mode */
+                        if (slot->details->view_mode_before_search != NAUTILUS_VIEW_INVALID_ID) {
                                 view_id = slot->details->view_mode_before_search;
-                                slot->details->view_mode_before_search = NULL;
+                                slot->details->view_mode_before_search = NAUTILUS_VIEW_INVALID_ID;
                         } else if (NAUTILUS_IS_PLACES_VIEW (slot->details->content_view)) {
                                 view_id = slot->details->view_mode_before_places;
-                                slot->details->view_mode_before_places = NULL;
+                                slot->details->view_mode_before_places = NAUTILUS_VIEW_INVALID_ID;
                         } else {
-                               view_id = g_strdup (nautilus_files_view_get_view_id (NAUTILUS_FILES_VIEW 
(slot->details->content_view)));
+                               view_id = nautilus_files_view_get_view_id (NAUTILUS_FILES_VIEW 
(slot->details->content_view));
                         }
                }
 
                 /* If there is not previous view in this slot, use the default view mode
                  * from preferences */
-               if (view_id == NULL) {
-                       view_id = nautilus_global_preferences_get_default_folder_viewer_preference_as_iid ();
+               if (view_id == NAUTILUS_VIEW_INVALID_ID) {
+                       view_id = g_settings_get_enum (nautilus_preferences, 
NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER);
                }
 
                 /* Try to reuse the current view */
@@ -221,8 +212,6 @@ nautilus_window_slot_get_view_for_location (NautilusWindowSlot *slot,
                 } else {
                         view = NAUTILUS_VIEW (nautilus_files_view_new (view_id, slot));
                 }
-
-                g_free (view_id);
         }
 
         nautilus_file_unref (file);
@@ -232,16 +221,16 @@ nautilus_window_slot_get_view_for_location (NautilusWindowSlot *slot,
 
 static gboolean
 nautilus_window_slot_content_view_matches (NautilusWindowSlot *slot,
-                                           const char         *iid)
+                                           guint                id)
 {
        if (slot->details->content_view == NULL) {
                return FALSE;
        }
 
-        if (!iid && NAUTILUS_IS_PLACES_VIEW (slot->details->content_view)) {
+        if (id == NAUTILUS_VIEW_INVALID_ID && NAUTILUS_IS_PLACES_VIEW (slot->details->content_view)) {
                 return TRUE;
-        } else if (iid && NAUTILUS_IS_FILES_VIEW (slot->details->content_view)){
-                return g_strcmp0 (nautilus_files_view_get_view_id (NAUTILUS_FILES_VIEW 
(slot->details->content_view)), iid) == 0;
+        } else if (id != NAUTILUS_VIEW_INVALID_ID && NAUTILUS_IS_FILES_VIEW (slot->details->content_view)){
+                return nautilus_files_view_get_view_id (NAUTILUS_FILES_VIEW (slot->details->content_view)) 
== id;
         } else {
                 return FALSE;
         }
@@ -304,7 +293,7 @@ nautilus_window_slot_sync_actions (NautilusWindowSlot *slot)
         action =  g_action_map_lookup_action (G_ACTION_MAP (slot->details->slot_action_group), 
"files-view-mode");
         if (NAUTILUS_IS_FILES_VIEW (nautilus_window_slot_get_current_view (slot)) &&
             !NAUTILUS_IS_DESKTOP_CANVAS_VIEW (nautilus_window_slot_get_current_view (slot))) {
-                variant = g_variant_new_string (nautilus_files_view_get_view_id (NAUTILUS_FILES_VIEW 
(nautilus_window_slot_get_current_view (slot))));
+                variant = g_variant_new_uint32 (nautilus_files_view_get_view_id (NAUTILUS_FILES_VIEW 
(nautilus_window_slot_get_current_view (slot))));
                 g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
                 g_action_change_state (action, variant);
         } else {
@@ -667,45 +656,29 @@ action_files_view_mode (GSimpleAction *action,
                        GVariant      *value,
                        gpointer       user_data)
 {
-        const gchar *name;
         NautilusWindowSlot *slot;
+        const gchar *preferences_key;
+        guint view_id;
 
-        name =  g_variant_get_string (value, NULL);
+        view_id =  g_variant_get_uint32 (value);
         slot = NAUTILUS_WINDOW_SLOT (user_data);
 
         if (!NAUTILUS_IS_FILES_VIEW (nautilus_window_slot_get_current_view (slot)))
-          return;
-
-        nautilus_window_slot_set_content_view (slot, name);
-        if (g_strcmp0 (name, "list") == 0) {
-                    /* If this change is caused because of the automatic list view
-                     * switch for search, don't set as default list view */
-                    if (!(nautilus_view_is_searching (nautilus_window_slot_get_current_view (slot))  &&
-                          g_settings_get_boolean (nautilus_preferences, 
NAUTILUS_PREFERENCES_LIST_VIEW_ON_SEARCH))) {
-                            g_settings_set_enum (nautilus_preferences,
-                                                 NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER,
-                                                 NAUTILUS_DEFAULT_FOLDER_VIEWER_LIST_VIEW);
-                    }
-        } else if (g_strcmp0 (name, "grid") == 0) {
-                    /* If the user manually changed the view mode to grid, disable the automatic
-                     * switch to list view on search */
-                    if (nautilus_view_is_searching (nautilus_window_slot_get_current_view (slot))) {
-                          g_settings_set_boolean (nautilus_preferences,
-                                                  NAUTILUS_PREFERENCES_LIST_VIEW_ON_SEARCH,
-                                                  FALSE);
-                    }
-                    g_settings_set_enum (nautilus_preferences,
-                                         NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER,
-                                         NAUTILUS_DEFAULT_FOLDER_VIEWER_ICON_VIEW);
-        } else {
-                g_assert_not_reached ();
-        }
+                return;
+
+        nautilus_window_slot_set_content_view (slot, view_id);
+        preferences_key = nautilus_view_is_searching (nautilus_window_slot_get_current_view (slot)) ?
+                          NAUTILUS_PREFERENCES_SEARCH_VIEW :
+                          NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER;
+
+        g_settings_set_enum (nautilus_preferences, preferences_key, view_id);
 
         g_simple_action_set_state (action, value);
 }
 
 const GActionEntry slot_entries[] = {
-        { "files-view-mode", NULL, "s", "''", action_files_view_mode },
+        /* 4 is NAUTILUS_VIEW_INVALID_ID */
+        { "files-view-mode", NULL, "u", "uint32 4", action_files_view_mode },
         { "search-visible", NULL, NULL, "false", action_search_visible },
 };
 
@@ -727,8 +700,8 @@ nautilus_window_slot_init (NautilusWindowSlot *slot)
         gtk_widget_insert_action_group (GTK_WIDGET (slot),
                                         "slot",
                                         G_ACTION_GROUP (slot->details->slot_action_group));
-        nautilus_application_add_accelerator (app, "slot.files-view-mode('list')", "<control>1");
-        nautilus_application_add_accelerator (app, "slot.files-view-mode('grid')", "<control>2");
+        nautilus_application_add_accelerator (app, "slot.files-view-mode(1)", "<control>1");
+        nautilus_application_add_accelerator (app, "slot.files-view-mode(0)", "<control>2");
         nautilus_application_add_accelerator (app, "slot.search-visible", "<control>f");
 }
 
@@ -1544,19 +1517,18 @@ free_location_change (NautilusWindowSlot *slot)
         }
 }
 
-void
+static void
 nautilus_window_slot_set_content_view (NautilusWindowSlot *slot,
-                                      const char *id)
+                                       guint                id)
 {
         NautilusFilesView *view;
         GList *selection;
        char *uri;
 
        g_assert (slot != NULL);
-       g_assert (id != NULL);
 
        uri = nautilus_window_slot_get_location_uri (slot);
-       DEBUG ("Change view of window %s to %s", uri, id);
+       DEBUG ("Change view of window %s to %d", uri, id);
        g_free (uri);
 
        if (nautilus_window_slot_content_view_matches (slot, id)) {
@@ -2248,11 +2220,6 @@ nautilus_window_slot_dispose (GObject *object)
 
         g_clear_object (&slot->details->location);
 
-        if (slot->details->view_mode_before_search) {
-                g_free (slot->details->view_mode_before_search);
-                slot->details->view_mode_before_search = NULL;
-        }
-
        nautilus_file_list_free (slot->details->pending_selection);
        slot->details->pending_selection = NULL;
 
diff --git a/src/resources/ui/nautilus-toolbar-view-menu.ui b/src/resources/ui/nautilus-toolbar-view-menu.ui
index d8d57e4..fe863be 100644
--- a/src/resources/ui/nautilus-toolbar-view-menu.ui
+++ b/src/resources/ui/nautilus-toolbar-view-menu.ui
@@ -21,7 +21,7 @@
                 <property name="visible">True</property>
                 <property name="text">Grid</property>
                 <property name="action-name">slot.files-view-mode</property>
-                <property name="action-target">'grid'</property>
+                <property name="action-target">uint32 0</property>
                 <property name="iconic">True</property>
                 <property name="centered">True</property>
                 <property name="icon">icon_grid</property>
@@ -37,7 +37,7 @@
                 <property name="visible">True</property>
                 <property name="text">List</property>
                 <property name="action-name">slot.files-view-mode</property>
-                <property name="action-target">'list'</property>
+                <property name="action-target">uint32 1</property>
                 <property name="iconic">True</property>
                 <property name="centered">True</property>
                 <property name="icon">icon_list</property>


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