[Xfce4-commits] [apps/catfish] 01/01: Save window placement. Revert to safe defaults if window size is greater than screen size (bug #14504)
noreply at xfce.org
noreply at xfce.org
Sat Jun 30 14:39:51 CEST 2018
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 9be582142ac10ef9d09e3867a5d5d79a9df005fa
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Sat Jun 30 08:39:46 2018 -0400
Save window placement. Revert to safe defaults if window size is greater than screen size (bug #14504)
---
catfish/CatfishWindow.py | 29 ++++++++++++++++++
catfish_lib/CatfishSettings.py | 8 +++--
catfish_lib/Window.py | 7 ++++-
data/ui/CatfishWindow.ui | 1 +
po/catfish.pot | 68 +++++++++++++++++++++---------------------
5 files changed, 75 insertions(+), 38 deletions(-)
diff --git a/catfish/CatfishWindow.py b/catfish/CatfishWindow.py
index aa50b33..15ab6d6 100644
--- a/catfish/CatfishWindow.py
+++ b/catfish/CatfishWindow.py
@@ -265,6 +265,25 @@ class CatfishWindow(Window):
paned.set_property('height_request', self.settings.get_setting('window-height'))
paned.set_property('width_request', self.settings.get_setting('window-width'))
+ window_width = self.settings.get_setting('window-width')
+ window_height = self.settings.get_setting('window-height')
+ window_x = self.settings.get_setting('window-x')
+ window_y = self.settings.get_setting('window-y')
+ (screen_width, screen_height) = self.get_screen_size()
+ (display_width, display_height) = self.get_display_size()
+
+ if (window_height > screen_height or window_width > screen_width):
+ window_width = min(display_width, 650)
+ window_height = min(display_height, 470)
+
+ paned.set_property('height_request', window_height)
+ paned.set_property('width_request', window_width)
+
+ if (window_x >= 0 and window_y >= 0):
+ if (window_x + window_width <= screen_width) and \
+ (window_y + window_height <= screen_height):
+ self.move(window_x, window_y)
+
self.refresh_search_entry()
filetype_filters = builder.get_object("filetype_options")
@@ -292,6 +311,16 @@ class CatfishWindow(Window):
self.thumbnailer = Thumbnailer.Thumbnailer()
+ def get_screen_size(self):
+ s = Gdk.Screen.get_default()
+ return (s.get_width(), s.get_height())
+
+ def get_display_size(self):
+ s = self.get_screen()
+ m = s.get_monitor_at_window(s.get_active_window())
+ monitor = s.get_monitor_geometry(m)
+ return (monitor.width, monitor.height)
+
def on_calendar_day_changed(self, widget):
start_calendar = self.builder.get_named_object(
"dialogs.date.start_calendar")
diff --git a/catfish_lib/CatfishSettings.py b/catfish_lib/CatfishSettings.py
index 0528be8..f1b0626 100644
--- a/catfish_lib/CatfishSettings.py
+++ b/catfish_lib/CatfishSettings.py
@@ -24,8 +24,10 @@ default_settings = {
'use-headerbar': True,
'show-hidden-files': False,
'show-sidebar': False,
- 'window-width': 760,
- 'window-height': 520
+ 'window-width': 650,
+ 'window-height': 470,
+ 'window-x': -1,
+ 'window-y': -1
}
@@ -47,7 +49,7 @@ class CatfishSettings:
def get_setting(self, key):
"""Return current setting for specified key."""
if key in self.settings:
- if (key in ['window-height', 'window-width']):
+ if (key.startswith('window')):
return int(self.settings[key])
return self.settings[key]
else:
diff --git a/catfish_lib/Window.py b/catfish_lib/Window.py
index 1b7ef02..61cb005 100644
--- a/catfish_lib/Window.py
+++ b/catfish_lib/Window.py
@@ -343,4 +343,9 @@ class Window(Gtk.Window):
self.settings.set_setting('window-height', allocation.height)
self.settings.set_setting('window-width', allocation.width)
paned.set_property('height_request', -1)
- paned.set_property('width_request', -1)
\ No newline at end of file
+ paned.set_property('width_request', -1)
+
+ 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
diff --git a/data/ui/CatfishWindow.ui b/data/ui/CatfishWindow.ui
index 4b5f940..363ab2d 100644
--- a/data/ui/CatfishWindow.ui
+++ b/data/ui/CatfishWindow.ui
@@ -468,6 +468,7 @@
<property name="title" translatable="yes">Catfish</property>
<property name="window_position">center</property>
<property name="icon_name">catfish</property>
+ <signal name="configure-event" handler="on_catfish_window_configure_event" swapped="no"/>
<signal name="key-press-event" handler="on_catfish_window_key_press_event" swapped="no"/>
<signal name="key-release-event" handler="on_catfish_window_key_press_event" swapped="no"/>
<signal name="size-allocate" handler="on_catfish_window_size_allocate" swapped="no"/>
diff --git a/po/catfish.pot b/po/catfish.pot
index 6a03759..3ec8ea0 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-06-30 07:36-0400\n"
+"POT-Creation-Date: 2018-06-30 08:38-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"
#: ../catfish.desktop.in.h:1 ../data/ui/CatfishWindow.ui.h:28
-#: ../catfish/CatfishWindow.py:636
+#: ../catfish/CatfishWindow.py:665
msgid "Catfish File Search"
msgstr ""
@@ -137,7 +137,7 @@ msgstr ""
msgid "File Type"
msgstr ""
-#: ../data/ui/CatfishWindow.ui.h:27 ../catfish/CatfishWindow.py:1100
+#: ../data/ui/CatfishWindow.ui.h:27 ../catfish/CatfishWindow.py:1129
msgid "Modified"
msgstr ""
@@ -277,144 +277,144 @@ msgstr ""
msgid "Never"
msgstr ""
-#: ../catfish/CatfishWindow.py:604
+#: ../catfish/CatfishWindow.py:633
msgid "An error occurred while updating the database."
msgstr ""
-#: ../catfish/CatfishWindow.py:606
+#: ../catfish/CatfishWindow.py:635
msgid "Authentication failed."
msgstr ""
-#: ../catfish/CatfishWindow.py:612
+#: ../catfish/CatfishWindow.py:641
msgid "Authentication cancelled."
msgstr ""
-#: ../catfish/CatfishWindow.py:618
+#: ../catfish/CatfishWindow.py:647
msgid "Search database updated successfully."
msgstr ""
#. Set the dialog status to running.
-#: ../catfish/CatfishWindow.py:693
+#: ../catfish/CatfishWindow.py:722
msgid "Updating..."
msgstr ""
-#: ../catfish/CatfishWindow.py:727
+#: ../catfish/CatfishWindow.py:756
msgid "Stop Search"
msgstr ""
-#: ../catfish/CatfishWindow.py:728
+#: ../catfish/CatfishWindow.py:757
msgid ""
"Search is in progress...\n"
"Press the cancel button or the Escape key to stop."
msgstr ""
-#: ../catfish/CatfishWindow.py:737
+#: ../catfish/CatfishWindow.py:766
msgid "Begin Search"
msgstr ""
-#: ../catfish/CatfishWindow.py:926
+#: ../catfish/CatfishWindow.py:955
#, python-format
msgid "\"%s\" could not be opened."
msgstr ""
-#: ../catfish/CatfishWindow.py:972
+#: ../catfish/CatfishWindow.py:1001
#, python-format
msgid "\"%s\" could not be saved."
msgstr ""
-#: ../catfish/CatfishWindow.py:989
+#: ../catfish/CatfishWindow.py:1018
#, python-format
msgid "\"%s\" could not be deleted."
msgstr ""
-#: ../catfish/CatfishWindow.py:1029
+#: ../catfish/CatfishWindow.py:1058
#, python-format
msgid "Save \"%s\" as…"
msgstr ""
-#: ../catfish/CatfishWindow.py:1064
+#: ../catfish/CatfishWindow.py:1093
#, python-format
msgid ""
"Are you sure that you want to \n"
"permanently delete \"%s\"?"
msgstr ""
-#: ../catfish/CatfishWindow.py:1068
+#: ../catfish/CatfishWindow.py:1097
#, python-format
msgid ""
"Are you sure that you want to \n"
"permanently delete the %i selected files?"
msgstr ""
-#: ../catfish/CatfishWindow.py:1071
+#: ../catfish/CatfishWindow.py:1100
msgid "If you delete a file, it is permanently lost."
msgstr ""
-#: ../catfish/CatfishWindow.py:1094
+#: ../catfish/CatfishWindow.py:1123
msgid "Filename"
msgstr ""
-#: ../catfish/CatfishWindow.py:1096
+#: ../catfish/CatfishWindow.py:1125
msgid "Size"
msgstr ""
-#: ../catfish/CatfishWindow.py:1098
+#: ../catfish/CatfishWindow.py:1127
msgid "Location"
msgstr ""
-#: ../catfish/CatfishWindow.py:1110
+#: ../catfish/CatfishWindow.py:1139
msgid "Preview"
msgstr ""
-#: ../catfish/CatfishWindow.py:1118
+#: ../catfish/CatfishWindow.py:1147
msgid "Details"
msgstr ""
-#: ../catfish/CatfishWindow.py:1337
+#: ../catfish/CatfishWindow.py:1366
msgid "Today"
msgstr ""
-#: ../catfish/CatfishWindow.py:1339
+#: ../catfish/CatfishWindow.py:1368
msgid "Yesterday"
msgstr ""
-#: ../catfish/CatfishWindow.py:1420
+#: ../catfish/CatfishWindow.py:1449
msgid "No files found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1422
+#: ../catfish/CatfishWindow.py:1451
msgid ""
"Try making your search less specific\n"
"or try another directory."
msgstr ""
-#: ../catfish/CatfishWindow.py:1428
+#: ../catfish/CatfishWindow.py:1457
msgid "1 file found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1430
+#: ../catfish/CatfishWindow.py:1459
#, python-format
msgid "%i files found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1436
+#: ../catfish/CatfishWindow.py:1465
msgid "bytes"
msgstr ""
-#: ../catfish/CatfishWindow.py:1544 ../catfish/CatfishWindow.py:1553
+#: ../catfish/CatfishWindow.py:1573 ../catfish/CatfishWindow.py:1582
msgid "Searching…"
msgstr ""
-#: ../catfish/CatfishWindow.py:1546
+#: ../catfish/CatfishWindow.py:1575
msgid "Results will be displayed as soon as they are found."
msgstr ""
-#: ../catfish/CatfishWindow.py:1551
+#: ../catfish/CatfishWindow.py:1580
#, python-format
msgid "Searching for \"%s\""
msgstr ""
-#: ../catfish/CatfishWindow.py:1640
+#: ../catfish/CatfishWindow.py:1669
#, 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