[SF#971] Improve option to open folder in terminal.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Mon, 13 Jul 2015 16:36:06 +0000 (19:36 +0300)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Mon, 13 Jul 2015 16:36:06 +0000 (19:36 +0300)
It should work with gvfs paths that have resolvable local path as well.

NEWS
src/main-win.c
src/pcmanfm.c
src/pcmanfm.h
src/tab-page.c

diff --git a/NEWS b/NEWS
index 9d54e57..0ee7af3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,9 @@
 
 * Fixed stuck tooltip after click on the item.
 
+* Improved option to open folder in terminal, it should work with gvfs
+    paths that have resolvable local path as well.
+
 
 Changes on 1.2.3 since 1.2.2:
 
index fc78071..574a7d2 100644 (file)
@@ -319,12 +319,13 @@ static void update_file_menu(FmMainWin* win, FmPath *path)
 {
     GtkAction *act;
     /* FmFolderView *fv = win->folder_view; */
+    gboolean can_term = pcmanfm_can_open_path_in_terminal(path);
 
     act = gtk_ui_manager_get_action(win->ui, "/menubar/ToolMenu/Term");
-    gtk_action_set_sensitive(act, path && fm_path_is_native(path));
+    gtk_action_set_sensitive(act, path && can_term);
 #if FM_CHECK_VERSION(1, 2, 0)
     act = gtk_ui_manager_get_action(win->ui, "/menubar/ToolMenu/Launch");
-    gtk_action_set_sensitive(act, path && fm_path_is_native(path));
+    gtk_action_set_sensitive(act, path && can_term);
 #endif
     act = gtk_ui_manager_get_action(win->ui, "/menubar/GoMenu/Up");
     gtk_action_set_sensitive(act, path && fm_path_get_parent(path));
index a5d2ba1..9be80f7 100644 (file)
@@ -2,7 +2,7 @@
  *      pcmanfm.c
  *
  *      Copyright 2009 - 2010 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
- *      Copyright 2012-2014 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ *      Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
  *
  *      This program is free software; you can redistribute it and/or modify
  *      it under the terms of the GNU General Public License as published by
@@ -600,6 +600,20 @@ void pcmanfm_save_config(gboolean immediate)
     }
 }
 
+gboolean pcmanfm_can_open_path_in_terminal(FmPath* dir)
+{
+    GFile *gf;
+    char *wd;
+
+    if (fm_path_is_native(dir))
+        return TRUE;
+    gf = fm_path_to_gfile(dir);
+    wd = g_file_get_path(gf);
+    g_object_unref(gf);
+    g_free(wd);
+    return (wd != NULL);
+}
+
 void pcmanfm_open_folder_in_terminal(GtkWindow* parent, FmPath* dir)
 {
 #if !FM_CHECK_VERSION(1, 2, 0)
index f47f02e..507177c 100644 (file)
@@ -45,6 +45,7 @@ gboolean pcmanfm_open_folder(GAppLaunchContext* ctx, GList* folder_infos, gpoint
 char* pcmanfm_get_profile_dir(gboolean create);
 void pcmanfm_save_config(gboolean immediate);
 
+gboolean pcmanfm_can_open_path_in_terminal(FmPath* dir);
 void pcmanfm_open_folder_in_terminal(GtkWindow* parent, FmPath* dir);
 
 G_END_DECLS
index 97badcf..9a46cc9 100644 (file)
@@ -828,7 +828,7 @@ static void update_files_popup(FmFolderView* fv, GtkWindow* win,
     for(l = fm_file_info_list_peek_head_link(files); l; l = l->next)
         if(!fm_file_info_is_dir(l->data))
             return; /* actions are valid only if all selected are directories */
-        else if (!fm_file_info_is_native(l->data))
+        else if (!pcmanfm_can_open_path_in_terminal(fm_file_info_get_path(l->data)))
             all_native = FALSE;
     g_object_set_qdata_full(G_OBJECT(act_grp), popup_qdata,
                             fm_file_info_list_ref(files),
@@ -879,7 +879,7 @@ void _update_sidepane_popup(FmSidePane* sp, GtkUIManager* ui,
                                  G_N_ELEMENTS(folder_menu_actions), win);
     /* we use the same XML for simplicity */
     gtk_ui_manager_add_ui_from_string(ui, folder_menu_xml, -1, NULL);
-    if (!fm_file_info_is_native(file))
+    if (!pcmanfm_can_open_path_in_terminal(fm_file_info_get_path(file)))
         gtk_action_set_visible(gtk_action_group_get_action(act_grp, "Term"), FALSE);
 }
 #endif