Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal window configured by pixel size #2267

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 25 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 All @@ -181,6 +186,26 @@
<summary>Window height.</summary>
<description>Percent of the screen that will be used by guake terminal vertically.</description>
</key>
<key name="window-pixel-width" type="i">
<default>100</default>
<summary>Window pixel width.</summary>
<description>Resolution of the screen that will be used by guake terminal horizontally.</description>
</key>
<key name="window-pixel-height" type="i">
<default>100</default>
<summary>Window pixel height.</summary>
<description>Resolution of the screen that will be used by guake terminal vertically.</description>
</key>
<key name="max-window-pixel-width" type="i">
<default>1920</default>
<summary>Max window pixel width.</summary>
<description>Maximum resolution of the screen that will be used by guake terminal horizontally.</description>
</key>
<key name="max-window-pixel-height" type="i">
<default>1080</default>
<summary>Max window pixel height.</summary>
<description>Maximum resolution of the screen that will be used by guake terminal vertically.</description>
</key>
<key name="window-horizontal-displacement" type="i">
<default>0</default>
<summary>Horizontal window displacement.</summary>
Expand Down
57 changes: 54 additions & 3 deletions guake/data/prefs.glade
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,23 @@
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="window_horizontal_dimension_adjustment">
<property name="lower">100</property>
<property name="upper">5000</property>
<property name="step-increment">100</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="window_horizontal_displacement_adjustment">
<property name="upper">10000000</property>
<property name="step-increment">10</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="window_vertical_dimension_adjustment">
<property name="lower">100</property>
<property name="upper">5000</property>
<property name="step-increment">100</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="window_vertical_displacement_adjustment">
<property name="upper">10000000</property>
<property name="step-increment">10</property>
Expand Down Expand Up @@ -1330,7 +1342,7 @@
<property name="top-padding">6</property>
<property name="left-padding">6</property>
<child>
<!-- n-columns=3 n-rows=3 -->
<!-- n-columns=4 n-rows=3 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
Expand Down Expand Up @@ -1485,7 +1497,7 @@
<signal name="value-changed" handler="on_window_vertical_displacement_value_changed" swapped="no"/>
</object>
<packing>
<property name="left-attach">2</property>
<property name="left-attach">3</property>
<property name="top-attach">1</property>
</packing>
</child>
Expand All @@ -1496,7 +1508,7 @@
<property name="label" translatable="yes">Displacement in pixels</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="left-attach">3</property>
<property name="top-attach">0</property>
</packing>
</child>
Expand All @@ -1508,6 +1520,45 @@
<property name="numeric">True</property>
<signal name="value-changed" handler="on_window_horizontal_displacement_value_changed" swapped="no"/>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Dimensions in pixels</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="window_vertical_dimension">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="adjustment">window_vertical_dimension_adjustment</property>
<property name="numeric">True</property>
<property name="update-policy">if-valid</property>
<signal name="value-changed" handler="on_window_vertical_dimension_value_changed" swapped="no"/>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="window_horizontal_dimension">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="adjustment">window_horizontal_dimension_adjustment</property>
<property name="numeric">True</property>
<property name="update-policy">if-valid</property>
<signal name="value-changed" handler="on_window_horizontal_dimension_value_changed" swapped="no"/>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">2</property>
Expand Down
2 changes: 2 additions & 0 deletions guake/gsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
42 changes: 42 additions & 0 deletions guake/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,14 +454,45 @@ 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))

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)
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)
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"""
which_align = {
Expand Down Expand Up @@ -632,6 +663,7 @@ 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 reload_erase_combos(self, btn=None):
self.prefDlg.reload_erase_combos(btn)

Expand Down Expand Up @@ -740,6 +772,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")
Expand Down Expand Up @@ -1148,6 +1181,14 @@ 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")
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)

# window displacements
value = self.settings.general.get_int("window-vertical-displacement")
self.get_widget("window_vertical_displacement").set_value(value)
Expand Down Expand Up @@ -1303,6 +1344,7 @@ def load_configs(self):
# it's a separated method, to be reused.
self.reload_erase_combos()


# custom command context-menu configuration file
custom_command_file = self.settings.general.get_string("custom-command-file")
if custom_command_file:
Expand Down
17 changes: 17 additions & 0 deletions guake/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,11 @@ 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")
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")
Expand All @@ -265,6 +268,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)
Expand All @@ -281,6 +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)
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!")
Expand All @@ -300,6 +313,10 @@ 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)
if update_by_scale:
settings.general.set_int("window-pixel-height",window_rect.height)
settings.general.set_int("window-pixel-width",window_rect.width)

if valignment == ALIGN_TOP:
window_rect.y += vdisplacement
elif valignment == ALIGN_BOTTOM:
Expand Down
7 changes: 7 additions & 0 deletions releasenotes/notes/pixel-defined-window-8062a170d105512a.yaml
Original file line number Diff line number Diff line change
@@ -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