Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added new setting in schema that keeps track of if the dimensions wer…
…e changed via the text box or scale slider. Text box values are then converted to percentages for size update.
  • Loading branch information
adamm-xyz committed Oct 17, 2024
commit 4d5ecd05d7bea0822be49b16a9c8dd74aca3d7b1
5 changes: 5 additions & 0 deletions guake/data/org.guake.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@
<summary>Audible bell</summary>
<description>If true, the system alert sound will be played on a bell character.</description>
</key>
<key name="window-pixel-or-scale-update" type="b">
<default>false</default>
<summary>Update window size by sliding scale or text box</summary>
<description>If true, window size is determined by scale widget. Otherwise, by spin button in preferences.</description>
</key>
<key name="window-width" type="i">
<default>100</default>
<summary>Window width.</summary>
Expand Down
29 changes: 19 additions & 10 deletions guake/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
16 changes: 13 additions & 3 deletions guake/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want to update percentage and pixel dimensions in unison, not sure why we would want our recorded percentage and pixel dimensions to be different at any point.

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)
Expand All @@ -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:
Expand Down