[gnome-commander/remove-search] Use the search command string for starting the file search



commit df372ac6c1078b2415fb6261620b29b4b89f19e0
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Thu Jan 13 23:43:10 2022 +0100

    Use the search command string for starting the file search

 src/gnome-cmd-user-actions.cc | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index afbeff76..321501ad 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -773,10 +773,25 @@ void file_edit_new_doc (GtkMenuItem *menuitem, gpointer not_used)
 
 void file_search (GtkMenuItem *menuitem, gpointer not_used)
 {
-    if (!main_win->file_search_dlg)
-        main_win->file_search_dlg = new GnomeCmdSearchDialog(gnome_cmd_data.search_defaults);
+           gchar       *command;
+
+           command = g_strdup (gnome_cmd_data.options.search);
+           if (!command || strlen(command) == 0)
+           {
+               DEBUG ('g', "Search command is empty.\n");
+               gnome_cmd_show_message (*main_win, _("No search command given."), _("You can set a command 
for a search tool in the program options."));
+               return;
+           }
 
-    main_win->file_search_dlg->show_and_set_focus();
+        gint     argc;
+        gchar  **argv  = nullptr;
+        GError  *error = nullptr;
+        DEBUG ('g', "Executing: %s\n", command);
+        g_shell_parse_argv (command, &argc, &argv, nullptr);
+        if (!g_spawn_async (nullptr, argv, nullptr, G_SPAWN_SEARCH_PATH, nullptr, nullptr, nullptr, &error))
+           gnome_cmd_error_message (_("Unable to execute command."), error);
+        g_strfreev (argv);
+        g_free (command);
 }
 
 


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