[gnome-commander: 163/170] Bring back opening a file from own gnomeCmdApp




commit 7b2f05dfd5040b48551516f29255e14087eabadf
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Wed Dec 23 22:22:53 2020 +0100

    Bring back opening a file from own gnomeCmdApp

 src/gnome-cmd-file-popmenu.cc | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/src/gnome-cmd-file-popmenu.cc b/src/gnome-cmd-file-popmenu.cc
index 5701ff28..a2faf29f 100644
--- a/src/gnome-cmd-file-popmenu.cc
+++ b/src/gnome-cmd-file-popmenu.cc
@@ -77,11 +77,36 @@ static void do_mime_exec_multiple (gpointer *args)
 
     if (files)
     {
-        string cmdString = gnome_cmd_app_get_command (gnomeCmdApp);
+        if(gnomeCmdApp->gAppInfo != nullptr)
+        {
+            // gio app
+            DEBUG('g', "Launching \"%s\"\n", g_app_info_get_commandline(gnomeCmdApp->gAppInfo));
+            g_app_info_launch(gnomeCmdApp->gAppInfo, files, nullptr, nullptr);
+        }
+        else
+        {
+            // own app
+            string cmdString = gnome_cmd_app_get_command (gnomeCmdApp);
+
+            set<string> dirs;
+            auto files_tmp = files;
 
-        DEBUG('g', "Launching \"%s\"\n", g_app_info_get_commandline(gnomeCmdApp->gAppInfo));
+            for (; files_tmp; files_tmp = files_tmp->next)
+            {
+                cmdString += ' ';
+                cmdString += stringify (g_shell_quote ( g_file_get_path((GFile *) files_tmp->data)));
 
-        g_app_info_launch(gnomeCmdApp->gAppInfo, files, nullptr, nullptr);
+                gchar *dpath = g_path_get_dirname (g_file_get_path((GFile *) files_tmp->data));
+
+                if (dpath)
+                    dirs.insert (stringify (dpath));
+            }
+
+            if (dirs.size()==1)
+                run_command_indir (cmdString.c_str(), dirs.begin()->c_str(), 
gnome_cmd_app_get_requires_terminal (gnomeCmdApp));
+            else
+                run_command_indir (cmdString.c_str(), nullptr, gnome_cmd_app_get_requires_terminal 
(gnomeCmdApp));
+        }
 
         g_list_free (files);
     }


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