From d39df99bf420117c9abcc30cb524f496cb730620 Mon Sep 17 00:00:00 2001 From: Adam Montano Date: Tue, 15 Oct 2024 10:36:10 -0700 Subject: [PATCH 1/5] Added rudimentary support for defining terminal window size by pixels (width,height), spin boxes in preferences update new settings in schema --- guake/data/org.guake.gschema.xml | 10 ++++++ guake/data/prefs.glade | 57 ++++++++++++++++++++++++++++++-- guake/gsettings.py | 2 ++ guake/prefs.py | 9 +++++ guake/utils.py | 8 ++++- 5 files changed, 82 insertions(+), 4 deletions(-) diff --git a/guake/data/org.guake.gschema.xml b/guake/data/org.guake.gschema.xml index d8846e77b..55980311b 100644 --- a/guake/data/org.guake.gschema.xml +++ b/guake/data/org.guake.gschema.xml @@ -181,6 +181,16 @@ Window height. Percent of the screen that will be used by guake terminal vertically. + + 100 + Window pixel width. + Resolution of the screen that will be used by guake terminal horizontally. + + + 100 + Window pixel height. + Resolution of the screen that will be used by guake terminal vertically. + 0 Horizontal window displacement. diff --git a/guake/data/prefs.glade b/guake/data/prefs.glade index f1b2c2db2..b81c3c09e 100644 --- a/guake/data/prefs.glade +++ b/guake/data/prefs.glade @@ -68,11 +68,23 @@ 1 10 + + 100 + 5000 + 100 + 10 + 10000000 10 10 + + 100 + 5000 + 100 + 10 + 10000000 10 @@ -1330,7 +1342,7 @@ 6 6 - + True False @@ -1485,7 +1497,7 @@ - 2 + 3 1 @@ -1496,7 +1508,7 @@ Displacement in pixels - 2 + 3 0 @@ -1508,6 +1520,45 @@ True + + 3 + 2 + + + + + True + False + Dimensions in pixels + + + 2 + 0 + + + + + True + True + window_vertical_dimension_adjustment + True + if-valid + + + + 2 + 1 + + + + + True + True + window_horizontal_dimension_adjustment + True + if-valid + + 2 2 diff --git a/guake/gsettings.py b/guake/gsettings.py index fe0e2b0f9..0799595be 100644 --- a/guake/gsettings.py +++ b/guake/gsettings.py @@ -58,6 +58,8 @@ def __init__(self, guake_inst): ) settings.general.onChangedValue("window-height", self.size_changed) settings.general.onChangedValue("window-width", self.size_changed) + settings.general.onChangedValue("window-pixel-height", self.size_changed) + settings.general.onChangedValue("window-pixel-width", self.size_changed) settings.general.onChangedValue("window-valignment", self.alignment_changed) settings.general.onChangedValue("window-halignment", self.alignment_changed) settings.general.onChangedValue("window-vertical-displacement", self.alignment_changed) diff --git a/guake/prefs.py b/guake/prefs.py index 9452c64c7..e65d25345 100644 --- a/guake/prefs.py +++ b/guake/prefs.py @@ -632,6 +632,15 @@ def on_window_horizontal_displacement_value_changed(self, spin): """Changes the value of window-horizontal-displacement""" self.settings.general.set_int("window-horizontal-displacement", int(spin.get_value())) + def on_window_vertical_dimension_value_changed(self, spin): + """Changes the value of window-vertical-displacement""" + self.settings.general.set_int("window-pixel-height", int(spin.get_value())) + + def on_window_horizontal_dimension_value_changed(self, spin): + """Changes the value of window-horizontal-displacement""" + print("CHANGING WIDTH TO ", int(spin.get_value())) + self.settings.general.set_int("window-pixel-width", int(spin.get_value())) + def reload_erase_combos(self, btn=None): self.prefDlg.reload_erase_combos(btn) diff --git a/guake/utils.py b/guake/utils.py index dc07c80e6..7783feaa3 100644 --- a/guake/utils.py +++ b/guake/utils.py @@ -257,6 +257,8 @@ def set_final_window_rect(cls, settings, window): # fetch settings height_percents = settings.general.get_int("window-height") width_percents = settings.general.get_int("window-width") + height_pixel = settings.general.get_int("window-pixel-height") + width_pixel = settings.general.get_int("window-pixel-width") halignment = settings.general.get_int("window-halignment") valignment = settings.general.get_int("window-valignment") vdisplacement = settings.general.get_int("window-vertical-displacement") @@ -265,6 +267,8 @@ def set_final_window_rect(cls, settings, window): log.debug("set_final_window_rect") log.debug(" height_percents = %s", height_percents) log.debug(" width_percents = %s", width_percents) + log.debug(" height_pixel = %s", height_pixel) + log.debug(" width_pixel = %s", width_pixel) log.debug(" halignment = %s", halignment) log.debug(" valignment = %s", valignment) log.debug(" hdisplacement = %s", hdisplacement) @@ -299,7 +303,9 @@ def set_final_window_rect(cls, settings, window): ) window_rect.x += total_width - window_rect.width - hdisplacement - window_rect.height = int(float(total_height) * float(height_percents) / 100.0) + #window_rect.height = int(float(total_height) * float(height_percents) / 100.0) + window_rect.width = width_pixel + window_rect.height = height_pixel if valignment == ALIGN_TOP: window_rect.y += vdisplacement elif valignment == ALIGN_BOTTOM: From 052b04c7c4b28107b12c7281420312b6e7ea427e Mon Sep 17 00:00:00 2001 From: Adam Montano Date: Wed, 16 Oct 2024 09:38:26 -0700 Subject: [PATCH 2/5] spin box values will preserve window dimension settings --- guake/prefs.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/guake/prefs.py b/guake/prefs.py index e65d25345..f706ddc9d 100644 --- a/guake/prefs.py +++ b/guake/prefs.py @@ -749,6 +749,7 @@ class fake_guake: self.load_configs() self.get_widget("config-window").hide() + def spawn_sync_pid(self, directory=None, terminal=None): argv = [] user_shell = self.settings.general.get_string("default-shell") @@ -1311,6 +1312,8 @@ def load_configs(self): # it's a separated method, to be reused. self.reload_erase_combos() + value = self.settings.general.get_int("window-pixel-height") + self.get_widget("window_vertical_dimension").set_value(value) # custom command context-menu configuration file custom_command_file = self.settings.general.get_string("custom-command-file") From 4d5ecd05d7bea0822be49b16a9c8dd74aca3d7b1 Mon Sep 17 00:00:00 2001 From: Adam Montano Date: Thu, 17 Oct 2024 14:20:21 -0700 Subject: [PATCH 3/5] Added new setting in schema that keeps track of if the dimensions were changed via the text box or scale slider. Text box values are then converted to percentages for size update. --- guake/data/org.guake.gschema.xml | 5 +++++ guake/prefs.py | 29 +++++++++++++++++++---------- guake/utils.py | 16 +++++++++++++--- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/guake/data/org.guake.gschema.xml b/guake/data/org.guake.gschema.xml index 55980311b..60a79d8b6 100644 --- a/guake/data/org.guake.gschema.xml +++ b/guake/data/org.guake.gschema.xml @@ -171,6 +171,11 @@ Audible bell If true, the system alert sound will be played on a bell character. + + false + Update window size by sliding scale or text box + If true, window size is determined by scale widget. Otherwise, by spin button in preferences. + 100 Window width. diff --git a/guake/prefs.py b/guake/prefs.py index f706ddc9d..1ef3b2513 100644 --- a/guake/prefs.py +++ b/guake/prefs.py @@ -454,14 +454,26 @@ def on_display_n_changed(self, combo): def on_window_height_value_changed(self, hscale): """Changes the value of window_height in dconf""" + self.settings.general.set_boolean("window-pixel-or-scale-update", True) val = hscale.get_value() self.settings.general.set_int("window-height", int(val)) def on_window_width_value_changed(self, wscale): """Changes the value of window_width in dconf""" + self.settings.general.set_boolean("window-pixel-or-scale-update", True) val = wscale.get_value() self.settings.general.set_int("window-width", int(val)) + def on_window_vertical_dimension_value_changed(self, spin): + """Changes the value of window-vertical-displacement""" + self.settings.general.set_boolean("window-pixel-or-scale-update", False) + self.settings.general.set_int("window-pixel-height", int(spin.get_value())) + + def on_window_horizontal_dimension_value_changed(self, spin): + """Changes the value of window-horizontal-displacement""" + self.settings.general.set_boolean("window-pixel-or-scale-update", False) + self.settings.general.set_int("window-pixel-width", int(spin.get_value())) + def on_window_halign_value_changed(self, halign_button): """Changes the value of window_halignment in dconf""" which_align = { @@ -632,14 +644,6 @@ def on_window_horizontal_displacement_value_changed(self, spin): """Changes the value of window-horizontal-displacement""" self.settings.general.set_int("window-horizontal-displacement", int(spin.get_value())) - def on_window_vertical_dimension_value_changed(self, spin): - """Changes the value of window-vertical-displacement""" - self.settings.general.set_int("window-pixel-height", int(spin.get_value())) - - def on_window_horizontal_dimension_value_changed(self, spin): - """Changes the value of window-horizontal-displacement""" - print("CHANGING WIDTH TO ", int(spin.get_value())) - self.settings.general.set_int("window-pixel-width", int(spin.get_value())) def reload_erase_combos(self, btn=None): self.prefDlg.reload_erase_combos(btn) @@ -1158,6 +1162,12 @@ def load_configs(self): value = self.settings.general.get_int("window-width") self.get_widget("window_width").set_value(value) + value = self.settings.general.get_int("window-pixel-height") + self.get_widget("window_vertical_dimension").set_value(value) + + value = self.settings.general.get_int("window-pixel-width") + self.get_widget("window_horizontal_dimension").set_value(value) + # window displacements value = self.settings.general.get_int("window-vertical-displacement") self.get_widget("window_vertical_displacement").set_value(value) @@ -1312,8 +1322,7 @@ def load_configs(self): # it's a separated method, to be reused. self.reload_erase_combos() - value = self.settings.general.get_int("window-pixel-height") - self.get_widget("window_vertical_dimension").set_value(value) + # custom command context-menu configuration file custom_command_file = self.settings.general.get_string("custom-command-file") diff --git a/guake/utils.py b/guake/utils.py index 7783feaa3..bcbb895aa 100644 --- a/guake/utils.py +++ b/guake/utils.py @@ -255,6 +255,7 @@ def set_final_window_rect(cls, settings, window): horizontal alignment is given by window_alignment. """ # fetch settings + update_by_scale = settings.general.get_boolean("window-pixel-or-scale-update") height_percents = settings.general.get_int("window-height") width_percents = settings.general.get_int("window-width") height_pixel = settings.general.get_int("window-pixel-height") @@ -286,6 +287,12 @@ def set_final_window_rect(cls, settings, window): total_height = window_rect.height total_width = window_rect.width + if not update_by_scale: + height_percents = int((height_pixel/total_height)*100) + log.debug("UPDATING BY SPIN BOX!") + log.debug(" calculated new percent: %s", height_percents) + width_percents = int((width_pixel/total_width)*100) + if halignment == ALIGN_CENTER: log.debug("aligning to center!") window_rect.width = int(float(total_width) * float(width_percents) / 100.0) @@ -303,9 +310,12 @@ def set_final_window_rect(cls, settings, window): ) window_rect.x += total_width - window_rect.width - hdisplacement - #window_rect.height = int(float(total_height) * float(height_percents) / 100.0) - window_rect.width = width_pixel - window_rect.height = height_pixel + window_rect.height = int(float(total_height) * float(height_percents) / 100.0) + if update_by_scale: + settings.general.set_int("window-pixel-height",window_rect.height) + settings.general.set_int("window-pixel-width",window_rect.width) + #window_rect.width = width_pixel + #window_rect.height = height_pixel if valignment == ALIGN_TOP: window_rect.y += vdisplacement elif valignment == ALIGN_BOTTOM: From a908e2a73cac0f29f4362d38bc45efa61b24252d Mon Sep 17 00:00:00 2001 From: Adam Montano Date: Mon, 21 Oct 2024 18:08:40 -0700 Subject: [PATCH 4/5] widgets reflect changes dynamically and also spin box value can't exceed 100% window size --- guake/data/org.guake.gschema.xml | 10 ++++++++++ guake/prefs.py | 23 +++++++++++++++++++++-- guake/utils.py | 9 +++++---- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/guake/data/org.guake.gschema.xml b/guake/data/org.guake.gschema.xml index 60a79d8b6..278828b48 100644 --- a/guake/data/org.guake.gschema.xml +++ b/guake/data/org.guake.gschema.xml @@ -196,6 +196,16 @@ Window pixel height. Resolution of the screen that will be used by guake terminal vertically. + + 1920 + Max window pixel width. + Maximum resolution of the screen that will be used by guake terminal horizontally. + + + 1080 + Max window pixel height. + Maximum resolution of the screen that will be used by guake terminal vertically. + 0 Horizontal window displacement. diff --git a/guake/prefs.py b/guake/prefs.py index 1ef3b2513..e351d58f1 100644 --- a/guake/prefs.py +++ b/guake/prefs.py @@ -458,21 +458,40 @@ def on_window_height_value_changed(self, hscale): val = hscale.get_value() self.settings.general.set_int("window-height", int(val)) + value = self.settings.general.get_int("window-pixel-height") + self.prefDlg.get_widget("window_vertical_dimension").set_value(value) + def on_window_width_value_changed(self, wscale): """Changes the value of window_width in dconf""" self.settings.general.set_boolean("window-pixel-or-scale-update", True) val = wscale.get_value() self.settings.general.set_int("window-width", int(val)) + value = self.settings.general.get_int("window-pixel-width") + self.prefDlg.get_widget("window_horizontal_dimension").set_value(value) + def on_window_vertical_dimension_value_changed(self, spin): """Changes the value of window-vertical-displacement""" self.settings.general.set_boolean("window-pixel-or-scale-update", False) - self.settings.general.set_int("window-pixel-height", int(spin.get_value())) + max_value = self.settings.general.get_int("max-window-pixel-height") + val = int(spin.get_value()) + if val <= max_value: + self.settings.general.set_int("window-pixel-height", val) + + value = self.settings.general.get_int("window-height") + self.prefDlg.get_widget("window_height").set_value(value) def on_window_horizontal_dimension_value_changed(self, spin): """Changes the value of window-horizontal-displacement""" self.settings.general.set_boolean("window-pixel-or-scale-update", False) - self.settings.general.set_int("window-pixel-width", int(spin.get_value())) + max_value = int(self.settings.general.get_int("max-window-pixel-width")) + val = int(spin.get_value()) + + if val <= max_value: + self.settings.general.set_int("window-pixel-width", val) + + value = self.settings.general.get_int("window-width") + self.prefDlg.get_widget("window_width").set_value(value) def on_window_halign_value_changed(self, halign_button): """Changes the value of window_halignment in dconf""" diff --git a/guake/utils.py b/guake/utils.py index bcbb895aa..010081b53 100644 --- a/guake/utils.py +++ b/guake/utils.py @@ -286,12 +286,14 @@ def set_final_window_rect(cls, settings, window): total_height = window_rect.height total_width = window_rect.width + settings.general.set_int("max-window-pixel-height",total_height) + settings.general.set_int("max-window-pixel-width",total_width) if not update_by_scale: height_percents = int((height_pixel/total_height)*100) - log.debug("UPDATING BY SPIN BOX!") - log.debug(" calculated new percent: %s", height_percents) width_percents = int((width_pixel/total_width)*100) + settings.general.set_int("window-height",height_percents) + settings.general.set_int("window-width",width_percents) if halignment == ALIGN_CENTER: log.debug("aligning to center!") @@ -314,8 +316,7 @@ def set_final_window_rect(cls, settings, window): if update_by_scale: settings.general.set_int("window-pixel-height",window_rect.height) settings.general.set_int("window-pixel-width",window_rect.width) - #window_rect.width = width_pixel - #window_rect.height = height_pixel + if valignment == ALIGN_TOP: window_rect.y += vdisplacement elif valignment == ALIGN_BOTTOM: From 9c4101c12a6fa7a25a5cdbdec9e81cef0a980601 Mon Sep 17 00:00:00 2001 From: Adam Montano Date: Tue, 22 Oct 2024 09:03:23 -0700 Subject: [PATCH 5/5] added release notes and readying for PR --- guake/prefs.py | 2 ++ .../notes/pixel-defined-window-8062a170d105512a.yaml | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 releasenotes/notes/pixel-defined-window-8062a170d105512a.yaml diff --git a/guake/prefs.py b/guake/prefs.py index e351d58f1..f412ba220 100644 --- a/guake/prefs.py +++ b/guake/prefs.py @@ -1182,7 +1182,9 @@ def load_configs(self): self.get_widget("window_width").set_value(value) value = self.settings.general.get_int("window-pixel-height") + max_value = self.settings.general.get_int("max-window-pixel-height") self.get_widget("window_vertical_dimension").set_value(value) + self.get_widget("window_vertical_dimension").set value = self.settings.general.get_int("window-pixel-width") self.get_widget("window_horizontal_dimension").set_value(value) diff --git a/releasenotes/notes/pixel-defined-window-8062a170d105512a.yaml b/releasenotes/notes/pixel-defined-window-8062a170d105512a.yaml new file mode 100644 index 000000000..9ba4188c8 --- /dev/null +++ b/releasenotes/notes/pixel-defined-window-8062a170d105512a.yaml @@ -0,0 +1,7 @@ +release_summary: > + Terminal window size is set by pixel rather than solely by the sliding scale in the preferences window. + +features: + - | + - Terminal window size can be configured in the preferences window by explicit pixel dimensions +