Skip to content

Commit

Permalink
Add window displacement options to move guake away from the screen edges
Browse files Browse the repository at this point in the history
  • Loading branch information
aichingm authored and gsemet committed Jan 25, 2018
1 parent 7fb3945 commit e5b0190
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 5 deletions.
Binary file removed .Makefile.swp
Binary file not shown.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

# kde
.directory
.kdev4/
guake.kdev4

# vim
*~
Expand Down Expand Up @@ -72,4 +74,4 @@ ChangeLog
.venv
.vscode/

guake/data/gschemas.compiled
guake/data/gschemas.compiled
10 changes: 10 additions & 0 deletions guake/data/org.guake.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@
<summary>Window height.</summary>
<description>Percent 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>
<description>Displace the window horizontally by a given amount of pixels.</description>
</key>
<key name="window-vertical-displacement" type="i">
<default>0</default>
<summary>Vertical window displacement.</summary>
<description>Displace the window vertically by a given amount of pixels.</description>
</key>
<key name="window-halignment" type="i">
<default>0</default>
<summary>Window horizontal alignment.</summary>
Expand Down
49 changes: 48 additions & 1 deletion guake/data/prefs.glade
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.20.2 -->
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkAdjustment" id="max_tab_name_length_adj">
Expand All @@ -23,6 +23,16 @@
<property name="step_increment">1</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_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_width_adjustment">
<property name="upper">100</property>
<property name="step_increment">1</property>
Expand Down Expand Up @@ -897,6 +907,43 @@
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="window_vertical_displacement">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">window_vertical_displacement_adjustment</property>
<property name="numeric">True</property>
<signal name="value-changed" handler="on_window_vertical_displacement_value_changed" swapped="no"/>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Displacement 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_horizontal_displacement">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">window_horizontal_displacement_adjustment</property>
<property name="numeric">True</property>
<signal name="value-changed" handler="on_window_horizontal_displacement_value_changed" swapped="no"/>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">2</property>
</packing>
</child>
</object>
</child>
</object>
Expand Down
2 changes: 2 additions & 0 deletions guake/gsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def __init__(self, guake_inst):
settings.general.onChangedValue('window-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)
settings.general.onChangedValue('window-horizontal-displacement', self.alignment_changed)
settings.style.onChangedValue('cursor-blink-mode', self.cursor_blink_mode_changed)
settings.style.onChangedValue('cursor-shape', self.cursor_shape_changed)

Expand Down
15 changes: 13 additions & 2 deletions guake/guake_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
from guake.globals import ALIGN_CENTER
from guake.globals import ALIGN_LEFT
from guake.globals import ALIGN_RIGHT
from guake.globals import ALIGN_TOP
from guake.globals import ALWAYS_ON_PRIMARY
from guake.globals import LOCALE_DIR
from guake.globals import NAME
Expand Down Expand Up @@ -1015,11 +1016,16 @@ def set_final_window_rect(self):
halignment = self.settings.general.get_int('window-halignment')
valignment = self.settings.general.get_int('window-valignment')

vdisplacement = self.settings.general.get_int('window-vertical-displacement')
hdisplacement = self.settings.general.get_int('window-horizontal-displacement')

log.debug("set_final_window_rect")
log.debug(" height_percents = %s", height_percents)
log.debug(" width_percents = %s", width_percents)
log.debug(" halignment = %s", halignment)
log.debug(" valignment = %s", valignment)
log.debug(" vdisplacement = %s", vdisplacement)
log.debug(" hdisplacement = %s", hdisplacement)

# get the rectangle just from the destination monitor
screen = self.window.get_screen()
Expand Down Expand Up @@ -1105,14 +1111,19 @@ def set_final_window_rect(self):
window_rect.x += (total_width - window_rect.width) / 2
elif halignment == ALIGN_LEFT:
# log.debug("aligning to left!")
window_rect.x += 0
window_rect.x += 0 + hdisplacement
elif halignment == ALIGN_RIGHT:
# log.debug("aligning to right!")
window_rect.x += total_width - window_rect.width
window_rect.x += total_width - window_rect.width - hdisplacement
if window_rect.height < total_height:
if valignment == ALIGN_BOTTOM:
window_rect.y += (total_height - window_rect.height)

if valignment == ALIGN_TOP:
window_rect.y += vdisplacement
elif valignment == ALIGN_BOTTOM:
window_rect.y -= vdisplacement

if width_percents == 100 and height_percents == 100:
log.debug("MAXIMIZING MAIN WINDOW")
self.window.maximize()
Expand Down
25 changes: 24 additions & 1 deletion guake/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@
from guake.common import gladefile
from guake.common import hexify_color
from guake.common import pixmapfile
from guake.globals import ALIGN_BOTTOM
from guake.globals import ALIGN_CENTER
from guake.globals import ALIGN_LEFT
from guake.globals import ALIGN_RIGHT
from guake.globals import ALIGN_TOP
from guake.globals import ALWAYS_ON_PRIMARY
from guake.globals import LOCALE_DIR
from guake.globals import NAME
Expand Down Expand Up @@ -402,7 +404,7 @@ def on_bottom_align_toggled(self, chk):
"""set the vertical alignment setting.
"""
v = chk.get_active()
self.settings.general.set_int('window-valignment', 1 if v else 0)
self.settings.general.set_int('window-valignment', ALIGN_BOTTOM if v else ALIGN_TOP)

def on_display_n_changed(self, combo):
"""Set the destination display in gconf.
Expand Down Expand Up @@ -446,6 +448,9 @@ def on_window_halign_value_changed(self, halign_button):
self.settings.general.set_int(
'window-halignment', which_align[halign_button.get_name()]
)
self.prefDlg.get_widget("window_horizontal_displacement").set_sensitive(
which_align[halign_button.get_name()] != ALIGN_CENTER
)

def on_use_audible_bell_toggled(self, chk):
"""Changes the value of use_audible_bell in gconf
Expand Down Expand Up @@ -561,6 +566,16 @@ def on_blink_cursor_toggled(self, chk):
def on_palette_color_set(self, btn):
self.prefDlg.on_palette_color_set(btn)

def on_window_vertical_displacement_value_changed(self, spin):
"""Changes the value of window-vertical-displacement
"""
self.settings.general.set_int('window-vertical-displacement', int(spin.get_value()))

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 @@ -966,13 +981,21 @@ def load_configs(self):
value = self.settings.general.get_int('window-width')
self.get_widget('window_width').set_value(value)

# window displacements
value = self.settings.general.get_int('window-vertical-displacement')
self.get_widget('window_vertical_displacement').set_value(value)

value = self.settings.general.get_int('window-horizontal-displacement')
self.get_widget('window_horizontal_displacement').set_value(value)

value = self.settings.general.get_int('window-halignment')
which_button = {
ALIGN_RIGHT: 'radiobutton_align_right',
ALIGN_LEFT: 'radiobutton_align_left',
ALIGN_CENTER: 'radiobutton_align_center'
}
self.get_widget(which_button[value]).set_active(True)
self.get_widget("window_horizontal_displacement").set_sensitive(value != ALIGN_CENTER)

value = self.settings.general.get_boolean('open-tab-cwd')
self.get_widget('open_tab_cwd').set_active(value)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
features:
- |
Add window displacement options to move guake away from the screen edges
fixes:
- |
fixes #1162

0 comments on commit e5b0190

Please sign in to comment.