[Xfce4-commits] [apps/catfish] 01/01: Select file after clicking 'Show in File Manager' (thunar) (bug #14494)
noreply at xfce.org
noreply at xfce.org
Mon Jul 22 22:04:44 CEST 2019
This is an automated email from the git hooks/post-receive script.
b l u e s a b r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/catfish.
commit 01aa98ff32259ac45bd343d8ad55d21c79d5cea0
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Mon Jul 22 16:04:38 2019 -0400
Select file after clicking 'Show in File Manager' (thunar) (bug #14494)
---
catfish/CatfishWindow.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++
po/catfish.pot | 74 ++++++++++++++++++++++++------------------------
2 files changed, 109 insertions(+), 37 deletions(-)
diff --git a/catfish/CatfishWindow.py b/catfish/CatfishWindow.py
index 27f00e1..30e84ce 100644
--- a/catfish/CatfishWindow.py
+++ b/catfish/CatfishWindow.py
@@ -27,6 +27,10 @@ from locale import gettext as _
from shutil import copy2, rmtree
from xml.sax.saxutils import escape
+# Thunar Integration
+import dbus
+import urllib
+
import pexpect
import gi
gi.require_version('GLib', '2.0')
@@ -948,6 +952,68 @@ class CatfishWindow(Window):
# Reload the results filter.
self.refilter()
+ def thunar_display_path(self, path):
+ bus = dbus.SessionBus()
+ obj = bus.get_object('org.xfce.Thunar', '/org/xfce/FileManager')
+ iface = dbus.Interface(obj, 'org.xfce.FileManager')
+
+ path = os.path.realpath(urllib.parse.urlparse(path).path)
+ url = urllib.parse.urljoin('file:', urllib.request.pathname2url(path))
+
+ if os.path.isfile(path):
+ method = iface.get_dbus_method('DisplayFolderAndSelect')
+ dirname = os.path.dirname(url)
+ filename = os.path.basename(url)
+ method(dirname, filename, '', '')
+
+ else:
+ method = iface.get_dbus_method('DisplayFolder')
+ method(url, '', '')
+
+ def get_exo_preferred_applications(self, filename):
+ apps = {}
+ if os.path.exists(filename):
+ with open(filename, "r") as infile:
+ for line in infile.readlines():
+ line = line.strip()
+ if "=" in line:
+ key, value = line.split("=", 2)
+ if len(value) > 0:
+ apps[key] = value
+ return apps
+
+ def get_exo_preferred_file_manager(self):
+ tmp = [GLib.get_user_config_dir()] + GLib.get_system_config_dirs()
+ config_dirs = []
+ for config_dir in tmp:
+ if config_dir not in config_dirs:
+ if os.path.exists(config_dir):
+ config_dirs.append(config_dir)
+
+ for config_dir in config_dirs:
+ cfg = "%s/xfce4/helpers.rc" % config_dir
+ if os.path.exists(cfg):
+ apps = self.get_exo_preferred_applications(cfg)
+ if "FileManager" in apps:
+ return apps["FileManager"]
+
+ return "Thunar"
+
+ def using_thunar_fm(self):
+ if os.environ.get("XDG_CURRENT_DESKTOP", "").lower() == 'xfce':
+ fm = self.get_exo_preferred_file_manager()
+ return "thunar" in fm.lower()
+
+ fm = subprocess.check_output(['xdg-mime','query','default', 'inode/directory'])
+ if "thunar" in fm.lower():
+ return True
+
+ if "exo-file-manager" in fm.lower():
+ fm = self.get_exo_preferred_file_manager()
+ return "thunar" in fm.lower()
+
+ return False
+
def open_file(self, filename):
"""Open the specified filename in its default application."""
logger.debug("Opening %s" % filename)
@@ -978,6 +1044,12 @@ class CatfishWindow(Window):
"""Open the selected file in the default file manager."""
logger.debug("Opening file manager for %i path(s)" %
len(self.selected_filenames))
+
+ if self.using_thunar_fm():
+ for filename in self.selected_filenames:
+ self.thunar_display_path(filename)
+ return
+
dirs = []
for filename in self.selected_filenames:
path = os.path.split(filename)[0]
diff --git a/po/catfish.pot b/po/catfish.pot
index 66ffd7a..37606cd 100644
--- a/po/catfish.pot
+++ b/po/catfish.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-07-22 13:50-0400\n"
+"POT-Creation-Date: 2019-07-22 16:02-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <LL at li.org>\n"
@@ -18,7 +18,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
#: ../org.xfce.Catfish.desktop.in.h:1 ../data/ui/CatfishWindow.ui.h:28
-#: ../catfish/CatfishWindow.py:675
+#: ../catfish/CatfishWindow.py:679
msgid "Catfish File Search"
msgstr ""
@@ -137,7 +137,7 @@ msgstr ""
msgid "File Type"
msgstr ""
-#: ../data/ui/CatfishWindow.ui.h:27 ../catfish/CatfishWindow.py:1142
+#: ../data/ui/CatfishWindow.ui.h:27 ../catfish/CatfishWindow.py:1214
msgid "Modified"
msgstr ""
@@ -278,157 +278,157 @@ msgstr ""
#. Translators: this text is displayed next to
#. a filename that is not utf-8 encoded.
-#: ../catfish/CatfishWindow.py:91
+#: ../catfish/CatfishWindow.py:95
#, python-format
msgid "%s (invalid encoding)"
msgstr ""
-#: ../catfish/CatfishWindow.py:245
+#: ../catfish/CatfishWindow.py:249
msgid "Unknown"
msgstr ""
-#: ../catfish/CatfishWindow.py:249
+#: ../catfish/CatfishWindow.py:253
msgid "Never"
msgstr ""
-#: ../catfish/CatfishWindow.py:643
+#: ../catfish/CatfishWindow.py:647
msgid "An error occurred while updating the database."
msgstr ""
-#: ../catfish/CatfishWindow.py:645
+#: ../catfish/CatfishWindow.py:649
msgid "Authentication failed."
msgstr ""
-#: ../catfish/CatfishWindow.py:651
+#: ../catfish/CatfishWindow.py:655
msgid "Authentication cancelled."
msgstr ""
-#: ../catfish/CatfishWindow.py:657
+#: ../catfish/CatfishWindow.py:661
msgid "Search database updated successfully."
msgstr ""
#. Set the dialog status to running.
-#: ../catfish/CatfishWindow.py:732
+#: ../catfish/CatfishWindow.py:736
msgid "Updating..."
msgstr ""
-#: ../catfish/CatfishWindow.py:766
+#: ../catfish/CatfishWindow.py:770
msgid "Stop Search"
msgstr ""
-#: ../catfish/CatfishWindow.py:767
+#: ../catfish/CatfishWindow.py:771
msgid ""
"Search is in progress...\n"
"Press the cancel button or the Escape key to stop."
msgstr ""
-#: ../catfish/CatfishWindow.py:776
+#: ../catfish/CatfishWindow.py:780
msgid "Begin Search"
msgstr ""
-#: ../catfish/CatfishWindow.py:968
+#: ../catfish/CatfishWindow.py:1034
#, python-format
msgid "\"%s\" could not be opened."
msgstr ""
-#: ../catfish/CatfishWindow.py:1014
+#: ../catfish/CatfishWindow.py:1086
#, python-format
msgid "\"%s\" could not be saved."
msgstr ""
-#: ../catfish/CatfishWindow.py:1031
+#: ../catfish/CatfishWindow.py:1103
#, python-format
msgid "\"%s\" could not be deleted."
msgstr ""
-#: ../catfish/CatfishWindow.py:1071
+#: ../catfish/CatfishWindow.py:1143
#, python-format
msgid "Save \"%s\" as..."
msgstr ""
-#: ../catfish/CatfishWindow.py:1106
+#: ../catfish/CatfishWindow.py:1178
#, python-format
msgid ""
"Are you sure that you want to \n"
"permanently delete \"%s\"?"
msgstr ""
-#: ../catfish/CatfishWindow.py:1110
+#: ../catfish/CatfishWindow.py:1182
#, python-format
msgid ""
"Are you sure that you want to \n"
"permanently delete the %i selected files?"
msgstr ""
-#: ../catfish/CatfishWindow.py:1113
+#: ../catfish/CatfishWindow.py:1185
msgid "If you delete a file, it is permanently lost."
msgstr ""
-#: ../catfish/CatfishWindow.py:1136
+#: ../catfish/CatfishWindow.py:1208
msgid "Filename"
msgstr ""
-#: ../catfish/CatfishWindow.py:1138
+#: ../catfish/CatfishWindow.py:1210
msgid "Size"
msgstr ""
-#: ../catfish/CatfishWindow.py:1140
+#: ../catfish/CatfishWindow.py:1212
msgid "Location"
msgstr ""
-#: ../catfish/CatfishWindow.py:1152
+#: ../catfish/CatfishWindow.py:1224
msgid "Preview"
msgstr ""
-#: ../catfish/CatfishWindow.py:1160
+#: ../catfish/CatfishWindow.py:1232
msgid "Details"
msgstr ""
-#: ../catfish/CatfishWindow.py:1383
+#: ../catfish/CatfishWindow.py:1455
msgid "Today"
msgstr ""
-#: ../catfish/CatfishWindow.py:1385
+#: ../catfish/CatfishWindow.py:1457
msgid "Yesterday"
msgstr ""
-#: ../catfish/CatfishWindow.py:1466
+#: ../catfish/CatfishWindow.py:1538
msgid "No files found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1468
+#: ../catfish/CatfishWindow.py:1540
msgid ""
"Try making your search less specific\n"
"or try another directory."
msgstr ""
-#: ../catfish/CatfishWindow.py:1474
+#: ../catfish/CatfishWindow.py:1546
msgid "1 file found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1476
+#: ../catfish/CatfishWindow.py:1548
#, python-format
msgid "%i files found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1482
+#: ../catfish/CatfishWindow.py:1554
msgid "bytes"
msgstr ""
-#: ../catfish/CatfishWindow.py:1590 ../catfish/CatfishWindow.py:1599
+#: ../catfish/CatfishWindow.py:1662 ../catfish/CatfishWindow.py:1671
msgid "Searching..."
msgstr ""
-#: ../catfish/CatfishWindow.py:1592
+#: ../catfish/CatfishWindow.py:1664
msgid "Results will be displayed as soon as they are found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1597
+#: ../catfish/CatfishWindow.py:1669
#, python-format
msgid "Searching for \"%s\""
msgstr ""
-#: ../catfish/CatfishWindow.py:1687
+#: ../catfish/CatfishWindow.py:1759
#, python-format
msgid "Search results for \"%s\""
msgstr ""
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list