[nautilus/wip/gaction_: 20/38] nautilus-view: drop save search



commit 00f4db4a043d5cade3908ce04de0818a41dccc3a
Author: Carlos Soriano <carlos sorian89 gmail com>
Date:   Mon Jan 5 14:02:19 2015 +0100

    nautilus-view: drop save search
    
    Seacrhing normally is a matter of just typing at the moment what you
    want to search. Probably saving a search and opening it again is more
    time cost and a burden than just type what you want to search.
    So drop this action.

 libnautilus-private/nautilus-directory.c        |    7 +-
 libnautilus-private/nautilus-search-directory.c |   64 +--------
 libnautilus-private/nautilus-search-directory.h |    3 -
 src/nautilus-actions.h                          |    2 -
 src/nautilus-directory-view-ui.xml              |    2 -
 src/nautilus-view.c                             |  175 -----------------------
 6 files changed, 2 insertions(+), 251 deletions(-)
---
diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c
index 9b94c26..1ab1e51 100644
--- a/libnautilus-private/nautilus-directory.c
+++ b/libnautilus-private/nautilus-directory.c
@@ -546,14 +546,12 @@ nautilus_directory_new (GFile *location)
        NautilusDirectory *directory;
        GType type;
        char *uri;
-       gboolean is_saved_search;
 
        uri = g_file_get_uri (location);
-       is_saved_search = g_str_has_suffix (uri, NAUTILUS_SAVED_SEARCH_EXTENSION);
 
        if (eel_uri_is_desktop (uri)) {
                type = NAUTILUS_TYPE_DESKTOP_DIRECTORY;
-       } else if (eel_uri_is_search (uri) || is_saved_search) {
+       } else if (eel_uri_is_search (uri)) {
                type = NAUTILUS_TYPE_SEARCH_DIRECTORY;
        } else {
                type = NAUTILUS_TYPE_VFS_DIRECTORY;
@@ -562,9 +560,6 @@ nautilus_directory_new (GFile *location)
        g_free (uri);
 
        directory = g_object_new (type, "location", location, NULL);
-       if (is_saved_search) {
-               nautilus_search_directory_set_saved_search (NAUTILUS_SEARCH_DIRECTORY (directory), location);
-       }
 
        return directory;
 }
diff --git a/libnautilus-private/nautilus-search-directory.c b/libnautilus-private/nautilus-search-directory.c
index 3f9144c..0ec70e0 100644
--- a/libnautilus-private/nautilus-search-directory.c
+++ b/libnautilus-private/nautilus-search-directory.c
@@ -38,7 +38,6 @@
 
 struct NautilusSearchDirectoryDetails {
        NautilusQuery *query;
-       char *saved_search_uri;
        gboolean modified;
 
        NautilusSearchEngine *engine;
@@ -752,7 +751,6 @@ search_finalize (GObject *object)
        NautilusSearchDirectory *search;
 
        search = NAUTILUS_SEARCH_DIRECTORY (object);
-       g_free (search->details->saved_search_uri);
 
        g_hash_table_destroy (search->details->files_hash);
 
@@ -893,7 +891,7 @@ nautilus_search_directory_set_query (NautilusSearchDirectory *search,
        }
 
        file = nautilus_directory_get_existing_corresponding_file (NAUTILUS_DIRECTORY (search));
-       if ((file != NULL) && (search->details->saved_search_uri == NULL)) {
+       if (file != NULL) {
                nautilus_search_directory_file_update_display_name (NAUTILUS_SEARCH_DIRECTORY_FILE (file));
        }
        nautilus_file_unref (file);
@@ -909,68 +907,8 @@ nautilus_search_directory_get_query (NautilusSearchDirectory *search)
        return NULL;
 }
 
-void
-nautilus_search_directory_set_saved_search (NautilusSearchDirectory *search,
-                                           GFile *saved_search)
-{
-       NautilusQuery *query;
-       char *file;
-
-       search->details->saved_search_uri = g_file_get_uri (saved_search);
-       file = g_file_get_path (saved_search);
-
-       if (file != NULL) {
-               query = nautilus_query_load (file);
-               if (query != NULL) {
-                       nautilus_search_directory_set_query (search, query);
-                       g_object_unref (query);
-               }
-               g_free (file);
-       } else {
-               g_warning ("Non-local saved searches not supported");
-       }
-
-       search->details->modified = FALSE;
-}
-
-gboolean
-nautilus_search_directory_is_saved_search (NautilusSearchDirectory *search)
-{
-       return search->details->saved_search_uri != NULL;
-}
-
 gboolean
 nautilus_search_directory_is_modified (NautilusSearchDirectory *search)
 {
        return search->details->modified;
 }
-
-void
-nautilus_search_directory_save_to_file (NautilusSearchDirectory *search,
-                                       const char              *save_file_uri)
-{
-       char *file;
-       
-       file = g_filename_from_uri (save_file_uri, NULL, NULL);
-       if (file == NULL) {
-               return;
-       }
-
-       if (search->details->query != NULL) {
-               nautilus_query_save (search->details->query, file);
-       }
-       
-       g_free (file);
-}
-
-void
-nautilus_search_directory_save_search (NautilusSearchDirectory *search)
-{
-       if (search->details->saved_search_uri == NULL) {
-               return;
-       }
-
-       nautilus_search_directory_save_to_file (search,
-                                               search->details->saved_search_uri);
-       search->details->modified = FALSE;
-}
diff --git a/libnautilus-private/nautilus-search-directory.h b/libnautilus-private/nautilus-search-directory.h
index fe56cfd..6eb7e53 100644
--- a/libnautilus-private/nautilus-search-directory.h
+++ b/libnautilus-private/nautilus-search-directory.h
@@ -57,9 +57,6 @@ void           nautilus_search_directory_set_saved_search (NautilusSearchDirecto
                                                           GFile                   *saved_search);
 gboolean       nautilus_search_directory_is_saved_search (NautilusSearchDirectory *search);
 gboolean       nautilus_search_directory_is_modified     (NautilusSearchDirectory *search);
-void           nautilus_search_directory_save_search     (NautilusSearchDirectory *search);
-void           nautilus_search_directory_save_to_file    (NautilusSearchDirectory *search,
-                                                         const char              *save_file_uri);
 
 NautilusQuery *nautilus_search_directory_get_query       (NautilusSearchDirectory *search);
 void           nautilus_search_directory_set_query       (NautilusSearchDirectory *search,
diff --git a/src/nautilus-actions.h b/src/nautilus-actions.h
index 576d020..61c13b2 100644
--- a/src/nautilus-actions.h
+++ b/src/nautilus-actions.h
@@ -64,8 +64,6 @@
 #define NAUTILUS_ACTION_PROPERTIES_ACCEL "PropertiesAccel"
 #define NAUTILUS_ACTION_LOCATION_PROPERTIES "LocationProperties"
 #define NAUTILUS_ACTION_EMPTY_TRASH "Empty Trash"
-#define NAUTILUS_ACTION_SAVE_SEARCH "Save Search"
-#define NAUTILUS_ACTION_SAVE_SEARCH_AS "Save Search As"
 #define NAUTILUS_ACTION_CUT "Cut"
 #define NAUTILUS_ACTION_LOCATION_CUT "LocationCut"
 #define NAUTILUS_ACTION_COPY "Copy"
diff --git a/src/nautilus-directory-view-ui.xml b/src/nautilus-directory-view-ui.xml
index 4c4fade..d375b3a 100644
--- a/src/nautilus-directory-view-ui.xml
+++ b/src/nautilus-directory-view-ui.xml
@@ -19,8 +19,6 @@
   </placeholder>
   <placeholder name="Global File Items Placeholder">
     <menuitem name="Empty Trash" action="Empty Trash"/>
-    <menuitem name="Save Search" action="Save Search"/>
-    <menuitem name="Save Search As" action="Save Search As"/>
   </placeholder>
   <placeholder name="Edit Actions">
     <placeholder name="Undostack Actions">
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 022e6ea..6cacd92 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -1444,147 +1444,6 @@ action_select_pattern_callback (GtkAction *action,
 }
 
 static void
-action_save_search_callback (GtkAction *action,
-                            gpointer callback_data)
-{                
-       NautilusSearchDirectory *search;
-       NautilusView    *directory_view;
-       
-        directory_view = NAUTILUS_VIEW (callback_data);
-
-       if (directory_view->details->model &&
-           NAUTILUS_IS_SEARCH_DIRECTORY (directory_view->details->model)) {
-               search = NAUTILUS_SEARCH_DIRECTORY (directory_view->details->model);
-               nautilus_search_directory_save_search (search);
-
-               /* Save search is disabled */
-               schedule_update_menus (directory_view);
-       }
-}
-
-static void
-query_name_entry_changed_cb  (GtkWidget *entry, GtkWidget *button)
-{
-       const char *text;
-       gboolean sensitive;
-       
-       text = gtk_entry_get_text (GTK_ENTRY (entry));
-
-       sensitive = (text != NULL) && (*text != 0);
-
-       gtk_widget_set_sensitive (button, sensitive);
-}
-
-
-static void
-action_save_search_as_callback (GtkAction *action,
-                               gpointer callback_data)
-{
-       NautilusView    *directory_view;
-       NautilusSearchDirectory *search;
-       GtkWidget *dialog, *grid, *label, *entry, *chooser, *save_button;
-       const char *entry_text;
-       char *filename, *filename_utf8, *dirname, *path, *uri;
-       GFile *location;
-       
-        directory_view = NAUTILUS_VIEW (callback_data);
-
-       if (directory_view->details->model &&
-           NAUTILUS_IS_SEARCH_DIRECTORY (directory_view->details->model)) {
-               search = NAUTILUS_SEARCH_DIRECTORY (directory_view->details->model);
-               
-               dialog = gtk_dialog_new_with_buttons (_("Save Search as"),
-                                                     nautilus_view_get_containing_window (directory_view),
-                                                     0,
-                                                     _("_Cancel"), GTK_RESPONSE_CANCEL,
-                                                     NULL);
-               save_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
-                                                    _("_Save"), GTK_RESPONSE_OK);
-               gtk_dialog_set_default_response (GTK_DIALOG (dialog),
-                                                GTK_RESPONSE_OK);
-               gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-               gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
-               gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-
-               grid = gtk_grid_new ();
-               g_object_set (grid,
-                             "orientation", GTK_ORIENTATION_VERTICAL,
-                             "border-width", 5,
-                             "row-spacing", 6,
-                             "column-spacing", 12,
-                             NULL);
-               gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), grid, TRUE, 
TRUE, 0);
-               gtk_widget_show (grid);
-               
-               label = gtk_label_new_with_mnemonic (_("Search _name:"));
-               gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-               gtk_container_add (GTK_CONTAINER (grid), label);
-               gtk_widget_show (label);
-
-               entry = gtk_entry_new ();
-               gtk_widget_set_hexpand (entry, TRUE);
-               gtk_grid_attach_next_to (GTK_GRID (grid), entry, label,
-                                        GTK_POS_RIGHT, 1, 1);
-               gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
-               gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
-               
-               gtk_widget_set_sensitive (save_button, FALSE);
-               g_signal_connect (entry, "changed",
-                                 G_CALLBACK (query_name_entry_changed_cb), save_button);
-               
-               gtk_widget_show (entry);
-               label = gtk_label_new_with_mnemonic (_("_Folder:"));
-               gtk_misc_set_alignment (GTK_MISC(label), 0.0, 0.5);
-               gtk_container_add (GTK_CONTAINER (grid), label);
-               gtk_widget_show (label);
-
-               chooser = gtk_file_chooser_button_new (_("Select Folder to Save Search In"),
-                                                      GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
-               gtk_widget_set_hexpand (chooser, TRUE);
-               gtk_grid_attach_next_to (GTK_GRID (grid), chooser, label,
-                                        GTK_POS_RIGHT, 1, 1);
-               gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser);
-               gtk_widget_show (chooser);
-
-               gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), TRUE);
-
-               gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser),
-                                                    g_get_home_dir ());
-               
-               if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
-                       entry_text = gtk_entry_get_text (GTK_ENTRY (entry));
-                       if (g_str_has_suffix (entry_text, NAUTILUS_SAVED_SEARCH_EXTENSION)) {
-                               filename_utf8 = g_strdup (entry_text);
-                       } else {
-                               filename_utf8 = g_strconcat (entry_text, NAUTILUS_SAVED_SEARCH_EXTENSION, 
NULL);
-                       }
-
-                       filename = g_filename_from_utf8 (filename_utf8, -1, NULL, NULL, NULL);
-                       g_free (filename_utf8);
-
-                       dirname = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
-                       
-                       path = g_build_filename (dirname, filename, NULL);
-                       g_free (filename);
-                       g_free (dirname);
-
-                       uri = g_filename_to_uri (path, NULL, NULL);
-                       g_free (path);
-                       
-                       nautilus_search_directory_save_to_file (search, uri);
-                       location = g_file_new_for_uri (uri);
-                       nautilus_file_changes_queue_file_added (location);
-                       g_object_unref (location);
-                       nautilus_file_changes_consume_changes (TRUE);
-                       g_free (uri);
-               }
-               
-               gtk_widget_destroy (dialog);
-       }
-}
-
-
-static void
 action_empty_trash_callback (GtkAction *action,
                             gpointer callback_data)
 {                
@@ -7126,14 +6985,6 @@ static const GtkActionEntry directory_view_entries[] = {
   /* label, accelerator */       N_("Open File and Close window"), "<alt><shift>Down",
   /* tooltip */                  NULL,
                                 G_CALLBACK (action_open_close_parent_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_SAVE_SEARCH, NULL,
-  /* label, accelerator */       N_("Sa_ve Search"), NULL,
-  /* tooltip */                  N_("Save the edited search"),
-                                G_CALLBACK (action_save_search_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_SAVE_SEARCH_AS, NULL,
-  /* label, accelerator */       N_("Sa_ve Search As…"), NULL,
-  /* tooltip */                  N_("Save the current search as a file"),
-                                G_CALLBACK (action_save_search_as_callback) },
 
   /* Location-specific actions */
   /* name, stock id */         { NAUTILUS_ACTION_LOCATION_OPEN_ALTERNATE, NULL,
@@ -8242,9 +8093,6 @@ real_update_menus (NautilusView *view)
        gboolean show_open_in_new_tab;
        gboolean can_open;
        gboolean show_app, show_run;
-       gboolean show_save_search;
-       gboolean save_search_sensitive;
-       gboolean show_save_search_as;
        GtkAction *action;
        GAppInfo *app;
        GIcon *app_icon;
@@ -8528,29 +8376,6 @@ real_update_menus (NautilusView *view)
        gtk_action_set_sensitive (action, !nautilus_trash_monitor_is_empty ());
        gtk_action_set_visible (action, should_show_empty_trash (view));
 
-       show_save_search = FALSE;
-       save_search_sensitive = FALSE;
-       show_save_search_as = FALSE;
-       if (selection_contains_search) {
-               NautilusSearchDirectory *search;
-
-               search = NAUTILUS_SEARCH_DIRECTORY (view->details->model);
-               if (nautilus_search_directory_is_saved_search (search)) {
-                       show_save_search = TRUE;
-                       save_search_sensitive = nautilus_search_directory_is_modified (search);
-               } else {
-                       show_save_search_as = TRUE;
-               }
-       } 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_SAVE_SEARCH);
-       gtk_action_set_visible (action, show_save_search);
-       gtk_action_set_sensitive (action, save_search_sensitive);
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_SAVE_SEARCH_AS);
-       gtk_action_set_visible (action, show_save_search_as);
-
-
        action = gtk_action_group_get_action (view->details->dir_action_group,
                                              NAUTILUS_ACTION_SELECT_ALL);
        gtk_action_set_sensitive (action, !nautilus_view_is_empty (view));


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