[PATCH 1/1] Added close-after-file-select functionality for one-off searches.

Michael Kielstra pmkielstra at outlook.com
Sun Nov 11 21:25:33 CET 2018


From: Michael Kielstra <Michaelkielstra at users.noreply.github.com>

---
 catfish/CatfishWindow.py       | 14 +++++-
 catfish_lib/CatfishSettings.py |  1 +
 catfish_lib/Window.py          |  5 +-
 data/ui/CatfishWindow.ui       | 19 +++++++
 po/catfish.pot                 | 92 ++++++++++++++++++----------------
 5 files changed, 83 insertions(+), 48 deletions(-)

diff --git a/catfish/CatfishWindow.py b/catfish/CatfishWindow.py
index b09d8f1..4a69e14 100644
--- a/catfish/CatfishWindow.py
+++ b/catfish/CatfishWindow.py
@@ -134,6 +134,8 @@ class CatfishWindow(Window):
         self.fulltext = builder.get_named_object("menus.application.fulltext")
         self.sidebar_toggle_menu = builder.get_named_object(
             "menus.application.advanced")
+        self.close_after_select = builder.get_named_object(
+            "menus.application.closeafterselect")

         # -- Sidebar -- #
         self.button_time_custom = builder.get_named_object(
@@ -345,10 +347,10 @@ class CatfishWindow(Window):
         self.app_menu_event = not self.app_menu_event
         if not self.app_menu_event:
             return
-        if listbox.get_row_at_index(5) == row:
+        if listbox.get_row_at_index(6) == row:
             listbox.get_parent().hide()
             self.on_menu_update_index_activate(row)
-        if listbox.get_row_at_index(6) == row:
+        if listbox.get_row_at_index(7) == row:
             listbox.get_parent().hide()
             self.on_mnu_about_activate(row)

@@ -497,6 +499,8 @@ class CatfishWindow(Window):
         self.fulltext.set_active(self.options.fulltext)
         self.sidebar_toggle_menu.set_active(
             self.settings.get_setting('show-sidebar'))
+        self.close_after_select.set_active(
+            self.settings.get_setting('close-after-select'))

         self.show_thumbnail = self.options.thumbnails

@@ -873,6 +877,10 @@ class CatfishWindow(Window):
     def on_menu_update_index_activate(self, widget):
         """Show the Update Search Index dialog."""
         self.update_index_dialog.show()
+
+    def on_menu_closeafterselect_toggled(self, widget):
+        active = widget.get_active()
+        self.settings.set_setting('close-after-select', active)

     # -- Sidebar -- #
     def on_sidebar_toggle_toggled(self, widget):
@@ -950,6 +958,8 @@ class CatfishWindow(Window):
             command = ['xdg-open', filename]
         try:
             subprocess.Popen(command, shell=False)
+            if(self.settings.get_setting('close-after-select')):
+               self.destroy()
             return
         except Exception as msg:
             logger.debug('Exception encountered while opening %s.' +
diff --git a/catfish_lib/CatfishSettings.py b/catfish_lib/CatfishSettings.py
index f1b0626..bb4fb0f 100644
--- a/catfish_lib/CatfishSettings.py
+++ b/catfish_lib/CatfishSettings.py
@@ -24,6 +24,7 @@ default_settings = {
     'use-headerbar': True,
     'show-hidden-files': False,
     'show-sidebar': False,
+    'close-after-select': True,
     'window-width': 650,
     'window-height': 470,
     'window-x': -1,
diff --git a/catfish_lib/Window.py b/catfish_lib/Window.py
index 61cb005..3aa2f47 100644
--- a/catfish_lib/Window.py
+++ b/catfish_lib/Window.py
@@ -56,7 +56,8 @@ __builder__ = {
             "hidden": "application_menu_hidden",
             "fulltext": "application_menu_fulltext",
             "advanced": "application_menu_advanced",
-            "update": "application_menu_update"
+            "update": "application_menu_update",
+            "closeafterselect": "application_menu_closeafterselect"
         },
         # File Context Menu
         "file": {
@@ -348,4 +349,4 @@ class Window(Gtk.Window):
     def on_catfish_window_configure_event(self, widget, event):
         pos = self.get_position()
         self.settings.set_setting('window-x', pos.root_x)
-        self.settings.set_setting('window-y', pos.root_y)
\ No newline at end of file
+        self.settings.set_setting('window-y', pos.root_y)
diff --git a/data/ui/CatfishWindow.ui b/data/ui/CatfishWindow.ui
index 73820c1..0c4f627 100644
--- a/data/ui/CatfishWindow.ui
+++ b/data/ui/CatfishWindow.ui
@@ -1221,6 +1221,25 @@
         </child>
       </object>
     </child>
+    <child>
+      <object class="GtkListBoxRow" id="listboxrow8">
+        <property name="width_request">100</property>
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <child>
+          <object class="GtkCheckButton" id="application_menu_closeafterselect">
+            <property name="label" translatable="yes">Close _on Selection</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="use_underline">True</property>
+            <property name="xalign">0</property>
+            <property name="draw_indicator">True</property>
+            <signal name="toggled" handler="on_menu_closeafterselect_toggled" swapped="no"/>
+          </object>
+        </child>
+      </object>
+    </child>
     <child>
       <object class="GtkListBoxRow" id="application_menu_update">
         <property name="visible">True</property>
diff --git a/po/catfish.pot b/po/catfish.pot
index 5a1dbf9..c050589 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: 2018-09-02 07:56-0400\n"
+"POT-Creation-Date: 2018-11-11 13:20-0500\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"

 #: ../catfish.desktop.in.h:1 ../data/ui/CatfishWindow.ui.h:28
-#: ../catfish/CatfishWindow.py:665
+#: ../catfish/CatfishWindow.py:669
 msgid "Catfish File Search"
 msgstr ""

@@ -121,7 +121,7 @@ msgstr ""
 msgid "<b>End Date</b>"
 msgstr ""

-#: ../data/ui/CatfishWindow.ui.h:23 ../catfish_lib/Window.py:217
+#: ../data/ui/CatfishWindow.ui.h:23 ../catfish_lib/Window.py:218
 msgid "Catfish"
 msgstr ""

@@ -137,7 +137,7 @@ msgstr ""
 msgid "File Type"
 msgstr ""

-#: ../data/ui/CatfishWindow.ui.h:27 ../catfish/CatfishWindow.py:1132
+#: ../data/ui/CatfishWindow.ui.h:27 ../catfish/CatfishWindow.py:1142
 msgid "Modified"
 msgstr ""

@@ -191,34 +191,38 @@ msgid "Show _Sidebar"
 msgstr ""

 #: ../data/ui/CatfishWindow.ui.h:39
-msgid "_Update Search Index…"
+msgid "Close _on Selection"
 msgstr ""

 #: ../data/ui/CatfishWindow.ui.h:40
-msgid "_About"
+msgid "_Update Search Index…"
 msgstr ""

 #: ../data/ui/CatfishWindow.ui.h:41
-msgid "Update Search Database"
+msgid "_About"
 msgstr ""

 #: ../data/ui/CatfishWindow.ui.h:42
-msgid "Unlock"
+msgid "Update Search Database"
 msgstr ""

 #: ../data/ui/CatfishWindow.ui.h:43
-msgid "<b>Database:</b>"
+msgid "Unlock"
 msgstr ""

 #: ../data/ui/CatfishWindow.ui.h:44
-msgid "<b>Updated:</b>"
+msgid "<b>Database:</b>"
 msgstr ""

 #: ../data/ui/CatfishWindow.ui.h:45
-msgid "<big><b>Update Search Database</b></big>"
+msgid "<b>Updated:</b>"
 msgstr ""

 #: ../data/ui/CatfishWindow.ui.h:46
+msgid "<big><b>Update Search Database</b></big>"
+msgstr ""
+
+#: ../data/ui/CatfishWindow.ui.h:47
 msgid ""
 "For faster search results, the search database needs to be refreshed.\n"
 "This action requires administrative rights."
@@ -274,152 +278,152 @@ msgstr ""
 msgid "%s (invalid encoding)"
 msgstr ""

-#: ../catfish/CatfishWindow.py:237
+#: ../catfish/CatfishWindow.py:239
 msgid "Unknown"
 msgstr ""

-#: ../catfish/CatfishWindow.py:241
+#: ../catfish/CatfishWindow.py:243
 msgid "Never"
 msgstr ""

-#: ../catfish/CatfishWindow.py:633
+#: ../catfish/CatfishWindow.py:637
 msgid "An error occurred while updating the database."
 msgstr ""

-#: ../catfish/CatfishWindow.py:635
+#: ../catfish/CatfishWindow.py:639
 msgid "Authentication failed."
 msgstr ""

-#: ../catfish/CatfishWindow.py:641
+#: ../catfish/CatfishWindow.py:645
 msgid "Authentication cancelled."
 msgstr ""

-#: ../catfish/CatfishWindow.py:647
+#: ../catfish/CatfishWindow.py:651
 msgid "Search database updated successfully."
 msgstr ""

 #. Set the dialog status to running.
-#: ../catfish/CatfishWindow.py:722
+#: ../catfish/CatfishWindow.py:726
 msgid "Updating..."
 msgstr ""

-#: ../catfish/CatfishWindow.py:756
+#: ../catfish/CatfishWindow.py:760
 msgid "Stop Search"
 msgstr ""

-#: ../catfish/CatfishWindow.py:757
+#: ../catfish/CatfishWindow.py:761
 msgid ""
 "Search is in progress...\n"
 "Press the cancel button or the Escape key to stop."
 msgstr ""

-#: ../catfish/CatfishWindow.py:766
+#: ../catfish/CatfishWindow.py:770
 msgid "Begin Search"
 msgstr ""

-#: ../catfish/CatfishWindow.py:958
+#: ../catfish/CatfishWindow.py:968
 #, python-format
 msgid "\"%s\" could not be opened."
 msgstr ""

-#: ../catfish/CatfishWindow.py:1004
+#: ../catfish/CatfishWindow.py:1014
 #, python-format
 msgid "\"%s\" could not be saved."
 msgstr ""

-#: ../catfish/CatfishWindow.py:1021
+#: ../catfish/CatfishWindow.py:1031
 #, python-format
 msgid "\"%s\" could not be deleted."
 msgstr ""

-#: ../catfish/CatfishWindow.py:1061
+#: ../catfish/CatfishWindow.py:1071
 #, python-format
 msgid "Save \"%s\" as…"
 msgstr ""

-#: ../catfish/CatfishWindow.py:1096
+#: ../catfish/CatfishWindow.py:1106
 #, python-format
 msgid ""
 "Are you sure that you want to \n"
 "permanently delete \"%s\"?"
 msgstr ""

-#: ../catfish/CatfishWindow.py:1100
+#: ../catfish/CatfishWindow.py:1110
 #, python-format
 msgid ""
 "Are you sure that you want to \n"
 "permanently delete the %i selected files?"
 msgstr ""

-#: ../catfish/CatfishWindow.py:1103
+#: ../catfish/CatfishWindow.py:1113
 msgid "If you delete a file, it is permanently lost."
 msgstr ""

-#: ../catfish/CatfishWindow.py:1126
+#: ../catfish/CatfishWindow.py:1136
 msgid "Filename"
 msgstr ""

-#: ../catfish/CatfishWindow.py:1128
+#: ../catfish/CatfishWindow.py:1138
 msgid "Size"
 msgstr ""

-#: ../catfish/CatfishWindow.py:1130
+#: ../catfish/CatfishWindow.py:1140
 msgid "Location"
 msgstr ""

-#: ../catfish/CatfishWindow.py:1142
+#: ../catfish/CatfishWindow.py:1152
 msgid "Preview"
 msgstr ""

-#: ../catfish/CatfishWindow.py:1150
+#: ../catfish/CatfishWindow.py:1160
 msgid "Details"
 msgstr ""

-#: ../catfish/CatfishWindow.py:1369
+#: ../catfish/CatfishWindow.py:1379
 msgid "Today"
 msgstr ""

-#: ../catfish/CatfishWindow.py:1371
+#: ../catfish/CatfishWindow.py:1381
 msgid "Yesterday"
 msgstr ""

-#: ../catfish/CatfishWindow.py:1452
+#: ../catfish/CatfishWindow.py:1462
 msgid "No files found."
 msgstr ""

-#: ../catfish/CatfishWindow.py:1454
+#: ../catfish/CatfishWindow.py:1464
 msgid ""
 "Try making your search less specific\n"
 "or try another directory."
 msgstr ""

-#: ../catfish/CatfishWindow.py:1460
+#: ../catfish/CatfishWindow.py:1470
 msgid "1 file found."
 msgstr ""

-#: ../catfish/CatfishWindow.py:1462
+#: ../catfish/CatfishWindow.py:1472
 #, python-format
 msgid "%i files found."
 msgstr ""

-#: ../catfish/CatfishWindow.py:1468
+#: ../catfish/CatfishWindow.py:1478
 msgid "bytes"
 msgstr ""

-#: ../catfish/CatfishWindow.py:1576 ../catfish/CatfishWindow.py:1585
+#: ../catfish/CatfishWindow.py:1586 ../catfish/CatfishWindow.py:1595
 msgid "Searching…"
 msgstr ""

-#: ../catfish/CatfishWindow.py:1578
+#: ../catfish/CatfishWindow.py:1588
 msgid "Results will be displayed as soon as they are found."
 msgstr ""

-#: ../catfish/CatfishWindow.py:1583
+#: ../catfish/CatfishWindow.py:1593
 #, python-format
 msgid "Searching for \"%s\""
 msgstr ""

-#: ../catfish/CatfishWindow.py:1672
+#: ../catfish/CatfishWindow.py:1682
 #, python-format
 msgid "Search results for \"%s\""
 msgstr ""
--
2.17.1

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.xfce.org/pipermail/xfce4-dev/attachments/20181111/e2b32c3c/attachment-0001.html>


More information about the Xfce4-dev mailing list