Created
February 9, 2009 07:11
-
-
Save 13k/60696 to your computer and use it in GitHub Desktop.
Patches Guake (9a41f1f8b7ce073302e864cd71901c0628d818be) to have horizontal size and alignment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 9a41f1f8b7ce073302e864cd71901c0628d818be Mon Sep 17 00:00:00 2001 | |
From: Kiyoshi de Brito Murata <13k@kside.net> | |
Date: Mon, 9 Feb 2009 05:03:32 -0200 | |
Subject: [PATCH] Horizontal size and alignment | |
--- | |
data/guake.schemas | 32 +++++- | |
data/prefs.glade | 274 ++++++++++++++++++++++++++++++++-------------- | |
src/guake.py | 92 +++++++++++----- | |
src/guake_globals.py.in | 3 + | |
src/prefs.py | 51 ++++++++-- | |
5 files changed, 332 insertions(+), 120 deletions(-) | |
diff --git a/data/guake.schemas b/data/guake.schemas | |
index db976b3..834366f 100644 | |
--- a/data/guake.schemas | |
+++ b/data/guake.schemas | |
@@ -92,19 +92,45 @@ | |
</schema> | |
<schema> | |
- <key>/schemas/apps/guake/general/window_size</key> | |
- <applyto>/apps/guake/general/window_size</applyto> | |
+ <key>/schemas/apps/guake/general/window_height</key> | |
+ <applyto>/apps/guake/general/window_height</applyto> | |
<owner>guake</owner> | |
<type>int</type> | |
<default>50</default> | |
<locale name="C"> | |
- <short>Window size.</short> | |
+ <short>Window height.</short> | |
<long>Percent of the screen that will be used by guake | |
terminal vertically.</long> | |
</locale> | |
</schema> | |
<schema> | |
+ <key>/schemas/apps/guake/general/window_width</key> | |
+ <applyto>/apps/guake/general/window_width</applyto> | |
+ <owner>guake</owner> | |
+ <type>int</type> | |
+ <default>100</default> | |
+ <locale name="C"> | |
+ <short>Window width.</short> | |
+ <long>Percent of the screen that will be used by guake | |
+ terminal horizontally.</long> | |
+ </locale> | |
+ </schema> | |
+ | |
+ <schema> | |
+ <key>/schemas/apps/guake/general/window_halignment</key> | |
+ <applyto>/apps/guake/general/window_halignment</applyto> | |
+ <owner>guake</owner> | |
+ <type>int</type> | |
+ <default>0</default> | |
+ <locale name="C"> | |
+ <short>Window horizontal alignment.</short> | |
+ <long>Place Guake at: | |
+ 0: center, 1: left, 2: right</long> | |
+ </locale> | |
+ </schema> | |
+ | |
+ <schema> | |
<key>/schemas/apps/guake/general/use_scrollbar</key> | |
<applyto>/apps/guake/general/use_scrollbar</applyto> | |
<owner>guake</owner> | |
diff --git a/data/prefs.glade b/data/prefs.glade | |
index c3a8745..56466e9 100644 | |
--- a/data/prefs.glade | |
+++ b/data/prefs.glade | |
@@ -234,61 +234,128 @@ | |
<property name="label_xalign">0</property> | |
<property name="shadow_type">GTK_SHADOW_NONE</property> | |
<child> | |
- <widget class="GtkAlignment" id="alignment4"> | |
+ <widget class="GtkHBox" id="hbox33"> | |
<property name="visible">True</property> | |
- <property name="left_padding">12</property> | |
+ <property name="border_width">12</property> | |
+ <property name="spacing">1</property> | |
<child> | |
- <widget class="GtkVBox" id="vbox11"> | |
+ <widget class="GtkAlignment" id="alignment4"> | |
<property name="visible">True</property> | |
- <property name="spacing">6</property> | |
- <property name="homogeneous">True</property> | |
- <child> | |
- <widget class="GtkCheckButton" id="window_ontop"> | |
- <property name="visible">True</property> | |
- <property name="label" translatable="yes">Stay on top</property> | |
- <property name="use_underline">True</property> | |
- <property name="focus_on_click">False</property> | |
- <property name="response_id">0</property> | |
- <property name="active">True</property> | |
- <property name="draw_indicator">True</property> | |
- <signal name="toggled" handler="on_window_ontop_toggled"/> | |
- </widget> | |
- <packing> | |
- <property name="expand">False</property> | |
- </packing> | |
- </child> | |
+ <property name="left_padding">12</property> | |
<child> | |
- <widget class="GtkCheckButton" id="window_losefocus"> | |
+ <widget class="GtkVBox" id="vbox11"> | |
<property name="visible">True</property> | |
- <property name="can_focus">True</property> | |
- <property name="label" translatable="yes">Hide on lose focus</property> | |
- <property name="use_underline">True</property> | |
- <property name="response_id">0</property> | |
- <property name="active">True</property> | |
- <property name="draw_indicator">True</property> | |
- <signal name="toggled" handler="on_window_losefocus_toggled"/> | |
+ <property name="spacing">6</property> | |
+ <property name="homogeneous">True</property> | |
+ <child> | |
+ <widget class="GtkCheckButton" id="window_ontop"> | |
+ <property name="visible">True</property> | |
+ <property name="label" translatable="yes">Stay on top</property> | |
+ <property name="use_underline">True</property> | |
+ <property name="focus_on_click">False</property> | |
+ <property name="response_id">0</property> | |
+ <property name="active">True</property> | |
+ <property name="draw_indicator">True</property> | |
+ <signal name="toggled" handler="on_window_ontop_toggled"/> | |
+ </widget> | |
+ <packing> | |
+ <property name="expand">False</property> | |
+ </packing> | |
+ </child> | |
+ <child> | |
+ <widget class="GtkCheckButton" id="window_losefocus"> | |
+ <property name="visible">True</property> | |
+ <property name="can_focus">True</property> | |
+ <property name="label" translatable="yes">Hide on lose focus</property> | |
+ <property name="use_underline">True</property> | |
+ <property name="response_id">0</property> | |
+ <property name="active">True</property> | |
+ <property name="draw_indicator">True</property> | |
+ <signal name="toggled" handler="on_window_losefocus_toggled"/> | |
+ </widget> | |
+ <packing> | |
+ <property name="expand">False</property> | |
+ <property name="fill">False</property> | |
+ <property name="position">1</property> | |
+ </packing> | |
+ </child> | |
+ <child> | |
+ <widget class="GtkCheckButton" id="window_tabbar"> | |
+ <property name="visible">True</property> | |
+ <property name="can_focus">True</property> | |
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
+ <property name="label" translatable="yes">Show tab bar</property> | |
+ <property name="response_id">0</property> | |
+ <property name="draw_indicator">True</property> | |
+ <signal name="toggled" handler="on_window_tabbar_toggled"/> | |
+ </widget> | |
+ <packing> | |
+ <property name="position">2</property> | |
+ </packing> | |
+ </child> | |
</widget> | |
- <packing> | |
- <property name="expand">False</property> | |
- <property name="fill">False</property> | |
- <property name="position">1</property> | |
- </packing> | |
</child> | |
+ </widget> | |
+ </child> | |
+ <child> | |
+ <widget class="GtkVSeparator" id="vseparator1"> | |
+ <property name="visible">True</property> | |
+ </widget> | |
+ <packing> | |
+ <property name="expand">False</property> | |
+ <property name="position">1</property> | |
+ </packing> | |
+ </child> | |
+ <child> | |
+ <widget class="GtkAlignment" id="alignment1"> | |
+ <property name="visible">True</property> | |
+ <property name="left_padding">12</property> | |
<child> | |
- <widget class="GtkCheckButton" id="window_tabbar"> | |
+ <widget class="GtkVBox" id="vbox20"> | |
<property name="visible">True</property> | |
- <property name="can_focus">True</property> | |
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
- <property name="label" translatable="yes">Show tab bar</property> | |
- <property name="response_id">0</property> | |
- <property name="draw_indicator">True</property> | |
- <signal name="toggled" handler="on_window_tabbar_toggled"/> | |
+ <property name="spacing">6</property> | |
+ <child> | |
+ <widget class="GtkHBox" id="hbox39"> | |
+ <property name="visible">True</property> | |
+ <child> | |
+ <widget class="GtkLabel" id="lblWindowHAlignment"> | |
+ <property name="visible">True</property> | |
+ <property name="xalign">1</property> | |
+ <property name="label" translatable="yes">Horizontal alignment:</property> | |
+ <property name="use_markup">True</property> | |
+ <property name="justify">GTK_JUSTIFY_RIGHT</property> | |
+ <property name="single_line_mode">True</property> | |
+ </widget> | |
+ <packing> | |
+ <property name="expand">False</property> | |
+ <property name="fill">False</property> | |
+ </packing> | |
+ </child> | |
+ <child> | |
+ <widget class="GtkComboBox" id="window_halignment"> | |
+ <property name="visible">True</property> | |
+ <property name="items" translatable="yes"></property> | |
+ <signal name="changed" handler="on_window_halignment_changed"/> | |
+ </widget> | |
+ <packing> | |
+ <property name="position">1</property> | |
+ </packing> | |
+ </child> | |
+ </widget> | |
+ <packing> | |
+ <property name="expand">False</property> | |
+ </packing> | |
+ </child> | |
+ <child> | |
+ <placeholder/> | |
+ </child> | |
</widget> | |
- <packing> | |
- <property name="position">2</property> | |
- </packing> | |
</child> | |
</widget> | |
+ <packing> | |
+ <property name="expand">False</property> | |
+ <property name="position">2</property> | |
+ </packing> | |
</child> | |
</widget> | |
</child> | |
@@ -309,6 +376,45 @@ | |
</packing> | |
</child> | |
<child> | |
+ <widget class="GtkFrame" id="frame12"> | |
+ <property name="visible">True</property> | |
+ <property name="label_xalign">0</property> | |
+ <property name="shadow_type">GTK_SHADOW_NONE</property> | |
+ <child> | |
+ <widget class="GtkAlignment" id="alignment12"> | |
+ <property name="visible">True</property> | |
+ <property name="left_padding">12</property> | |
+ <child> | |
+ <widget class="GtkHScale" id="window_width"> | |
+ <property name="visible">True</property> | |
+ <property name="can_focus">True</property> | |
+ <property name="update_policy">GTK_UPDATE_DISCONTINUOUS</property> | |
+ <property name="adjustment">100 10 110 10 10 10</property> | |
+ <property name="digits">0</property> | |
+ <property name="draw_value">False</property> | |
+ <property name="value_pos">GTK_POS_RIGHT</property> | |
+ <signal name="value_changed" handler="on_window_width_value_changed"/> | |
+ </widget> | |
+ </child> | |
+ </widget> | |
+ </child> | |
+ <child> | |
+ <widget class="GtkLabel" id="label25"> | |
+ <property name="visible">True</property> | |
+ <property name="ypad">6</property> | |
+ <property name="label" translatable="yes"><b>Main Window width</b></property> | |
+ <property name="use_markup">True</property> | |
+ </widget> | |
+ <packing> | |
+ <property name="type">label_item</property> | |
+ </packing> | |
+ </child> | |
+ </widget> | |
+ <packing> | |
+ <property name="position">3</property> | |
+ </packing> | |
+ </child> | |
+ <child> | |
<widget class="GtkFrame" id="frame11"> | |
<property name="visible">True</property> | |
<property name="label_xalign">0</property> | |
@@ -318,7 +424,7 @@ | |
<property name="visible">True</property> | |
<property name="left_padding">12</property> | |
<child> | |
- <widget class="GtkHScale" id="window_size"> | |
+ <widget class="GtkHScale" id="window_height"> | |
<property name="visible">True</property> | |
<property name="can_focus">True</property> | |
<property name="update_policy">GTK_UPDATE_DISCONTINUOUS</property> | |
@@ -326,7 +432,7 @@ | |
<property name="digits">0</property> | |
<property name="draw_value">False</property> | |
<property name="value_pos">GTK_POS_RIGHT</property> | |
- <signal name="value_changed" handler="on_window_size_value_changed"/> | |
+ <signal name="value_changed" handler="on_window_height_value_changed"/> | |
</widget> | |
</child> | |
</widget> | |
@@ -335,7 +441,7 @@ | |
<widget class="GtkLabel" id="label24"> | |
<property name="visible">True</property> | |
<property name="ypad">6</property> | |
- <property name="label" translatable="yes"><b>Main Window size</b></property> | |
+ <property name="label" translatable="yes"><b>Main Window height</b></property> | |
<property name="use_markup">True</property> | |
</widget> | |
<packing> | |
@@ -356,8 +462,8 @@ | |
<property name="use_markup">True</property> | |
</widget> | |
<packing> | |
- <property name="tab_fill">False</property> | |
<property name="type">tab</property> | |
+ <property name="tab_fill">False</property> | |
</packing> | |
</child> | |
<child> | |
@@ -515,9 +621,9 @@ | |
<property name="label" translatable="yes">Scrolling</property> | |
</widget> | |
<packing> | |
+ <property name="type">tab</property> | |
<property name="position">4</property> | |
<property name="tab_fill">False</property> | |
- <property name="type">tab</property> | |
</packing> | |
</child> | |
<child> | |
@@ -531,7 +637,7 @@ | |
<property name="label_xalign">0</property> | |
<property name="shadow_type">GTK_SHADOW_NONE</property> | |
<child> | |
- <widget class="GtkAlignment" id="alignment1"> | |
+ <widget class="GtkAlignment" id="alignment2"> | |
<property name="visible">True</property> | |
<property name="left_padding">12</property> | |
<child> | |
@@ -640,7 +746,7 @@ | |
<property name="label_xalign">0</property> | |
<property name="shadow_type">GTK_SHADOW_NONE</property> | |
<child> | |
- <widget class="GtkAlignment" id="alignment2"> | |
+ <widget class="GtkAlignment" id="alignment3"> | |
<property name="visible">True</property> | |
<property name="left_padding">12</property> | |
<child> | |
@@ -806,9 +912,9 @@ | |
<property name="use_markup">True</property> | |
</widget> | |
<packing> | |
+ <property name="type">tab</property> | |
<property name="position">2</property> | |
<property name="tab_fill">False</property> | |
- <property name="type">tab</property> | |
</packing> | |
</child> | |
<child> | |
@@ -842,9 +948,9 @@ | |
<property name="label" translatable="yes">Keyboard shortcuts</property> | |
</widget> | |
<packing> | |
+ <property name="type">tab</property> | |
<property name="position">3</property> | |
<property name="tab_fill">False</property> | |
- <property name="type">tab</property> | |
</packing> | |
</child> | |
<child> | |
@@ -854,7 +960,7 @@ | |
<property name="label_xalign">0</property> | |
<property name="shadow_type">GTK_SHADOW_NONE</property> | |
<child> | |
- <widget class="GtkAlignment" id="alignment3"> | |
+ <widget class="GtkAlignment" id="alignment9"> | |
<property name="visible">True</property> | |
<property name="left_padding">12</property> | |
<child> | |
@@ -882,33 +988,19 @@ | |
<property name="column_spacing">12</property> | |
<property name="row_spacing">6</property> | |
<child> | |
- <widget class="GtkComboBox" id="delete-binding-combobox"> | |
+ <widget class="GtkLabel" id="delete-binding-combobox-label"> | |
<property name="visible">True</property> | |
- <property name="items" translatable="yes">ASCII DEL | |
-Escape sequence | |
-Control-H</property> | |
- <signal name="changed" handler="on_delete_binding_changed"/> | |
+ <property name="xalign">0</property> | |
+ <property name="label" translatable="yes">_Delete key generates:</property> | |
+ <property name="use_underline">True</property> | |
+ <property name="justify">GTK_JUSTIFY_CENTER</property> | |
+ <property name="mnemonic_widget">delete-binding-combobox</property> | |
</widget> | |
<packing> | |
- <property name="left_attach">1</property> | |
- <property name="right_attach">3</property> | |
<property name="top_attach">1</property> | |
<property name="bottom_attach">2</property> | |
- <property name="y_options">GTK_FILL</property> | |
- </packing> | |
- </child> | |
- <child> | |
- <widget class="GtkComboBox" id="backspace-binding-combobox"> | |
- <property name="visible">True</property> | |
- <property name="items" translatable="yes">ASCII DEL | |
-Escape sequence | |
-Control-H</property> | |
- <signal name="changed" handler="on_backspace_binding_changed"/> | |
- </widget> | |
- <packing> | |
- <property name="left_attach">1</property> | |
- <property name="right_attach">3</property> | |
- <property name="y_options">GTK_FILL</property> | |
+ <property name="x_options">GTK_FILL</property> | |
+ <property name="y_options"></property> | |
</packing> | |
</child> | |
<child> | |
@@ -926,19 +1018,33 @@ Control-H</property> | |
</packing> | |
</child> | |
<child> | |
- <widget class="GtkLabel" id="delete-binding-combobox-label"> | |
+ <widget class="GtkComboBox" id="backspace-binding-combobox"> | |
<property name="visible">True</property> | |
- <property name="xalign">0</property> | |
- <property name="label" translatable="yes">_Delete key generates:</property> | |
- <property name="use_underline">True</property> | |
- <property name="justify">GTK_JUSTIFY_CENTER</property> | |
- <property name="mnemonic_widget">delete-binding-combobox</property> | |
+ <property name="items" translatable="yes">ASCII DEL | |
+Escape sequence | |
+Control-H</property> | |
+ <signal name="changed" handler="on_backspace_binding_changed"/> | |
</widget> | |
<packing> | |
+ <property name="left_attach">1</property> | |
+ <property name="right_attach">3</property> | |
+ <property name="y_options">GTK_FILL</property> | |
+ </packing> | |
+ </child> | |
+ <child> | |
+ <widget class="GtkComboBox" id="delete-binding-combobox"> | |
+ <property name="visible">True</property> | |
+ <property name="items" translatable="yes">ASCII DEL | |
+Escape sequence | |
+Control-H</property> | |
+ <signal name="changed" handler="on_delete_binding_changed"/> | |
+ </widget> | |
+ <packing> | |
+ <property name="left_attach">1</property> | |
+ <property name="right_attach">3</property> | |
<property name="top_attach">1</property> | |
<property name="bottom_attach">2</property> | |
- <property name="x_options">GTK_FILL</property> | |
- <property name="y_options"></property> | |
+ <property name="y_options">GTK_FILL</property> | |
</packing> | |
</child> | |
</widget> | |
@@ -997,9 +1103,9 @@ Control-H</property> | |
<property name="label" translatable="yes">Compatibility</property> | |
</widget> | |
<packing> | |
+ <property name="type">tab</property> | |
<property name="position">4</property> | |
<property name="tab_fill">False</property> | |
- <property name="type">tab</property> | |
</packing> | |
</child> | |
</widget> | |
diff --git a/src/guake.py b/src/guake.py | |
index 5afcb5e..3156340 100644 | |
--- a/src/guake.py | |
+++ b/src/guake.py | |
@@ -97,7 +97,9 @@ class GConfHandler(object): | |
notify_add(KEY('/general/use_trayicon'), self.trayicon_toggled) | |
notify_add(KEY('/general/window_ontop'), self.ontop_toggled) | |
notify_add(KEY('/general/window_tabbar'), self.tabbar_toggled) | |
- notify_add(KEY('/general/window_size'), self.size_changed) | |
+ notify_add(KEY('/general/window_halignment'), self.alignment_changed) | |
+ notify_add(KEY('/general/window_height'), self.size_changed) | |
+ notify_add(KEY('/general/window_width'), self.size_changed) | |
notify_add(KEY('/general/use_scrollbar'), self.scrollbar_toggled) | |
notify_add(KEY('/general/history_size'), self.history_size_changed) | |
@@ -145,8 +147,16 @@ class GConfHandler(object): | |
else: | |
self.guake.toolbar.hide() | |
+ def alignment_changed(self, client, connection_id, entry, data): | |
+ """If the gconf var window_halignment be changed, this method will | |
+ be called and will call the move function in guake. | |
+ """ | |
+ width, height = self.guake.get_final_window_size() | |
+ x, y = self.guake.get_final_window_pos(width, height) | |
+ self.guake.window.move(x, y) | |
+ | |
def size_changed(self, client, connection_id, entry, data): | |
- """If the gconf var window_size be changed, this method will | |
+ """If the gconf var window_height or window_width be changed, this method will | |
be called and will call the resize function in guake. | |
""" | |
width, height = self.guake.get_final_window_size() | |
@@ -548,7 +558,7 @@ class Guake(SimpleGladeApp): | |
notification.show() | |
def on_resizer_drag(self, widget, event): | |
- """Method that handles the resize drag. It does not actuall | |
+ """Method that handles the resize drag. It does not actually | |
moves the main window. It just set the new window size in | |
gconf. | |
""" | |
@@ -557,12 +567,19 @@ class Guake(SimpleGladeApp): | |
return | |
max_height = self.window.get_screen().get_height() | |
- percent = y / (max_height / 100) | |
+ h_percent = y / (max_height / 100) | |
- if percent < 1: | |
- percent = 1 | |
+ if h_percent < 1: | |
+ h_percent = 1 | |
- self.client.set_int(KEY('/general/window_size'), int(percent)) | |
+ max_width = self.window.get_screen().get_width() | |
+ w_percent = x / (max_width / 100) | |
+ | |
+ if w_percent < 1: | |
+ w_percent = 1 | |
+ | |
+ self.client.set_int(KEY('/general/window_height'), int(h_percent)) | |
+ self.client.set_int(KEY('/general/window_width'), int(w_percent)) | |
def on_window_losefocus(self, window, event): | |
"""Hides terminal main window when it loses the focus and if | |
@@ -641,7 +658,7 @@ class Guake(SimpleGladeApp): | |
self.set_terminal_focus() | |
else: | |
self.hide() | |
- | |
+ | |
def show(self): | |
"""Shows the main window and grabs the focus on it. | |
""" | |
@@ -654,9 +671,10 @@ class Guake(SimpleGladeApp): | |
self.add_tab() | |
width, height = self.get_final_window_size() | |
+ x, y = self.get_final_window_pos(width, height) | |
self.window.resize(width, height) | |
self.window.show_all() | |
- self.window.move(0, 0) | |
+ self.window.move(x, y) | |
try: | |
# does it work in other gtk backends | |
@@ -678,37 +696,59 @@ class Guake(SimpleGladeApp): | |
self.window.hide() # Don't use hide_all here! | |
def get_final_window_size(self): | |
- """Gets the final size of the main window of guake. The height | |
- is just the window_size property. But width is calculated as | |
- 100% of the screen and tested against the monitor geometry | |
- width. | |
+ """Gets the final size of the main window of guake. | |
""" | |
+ width = self.client.get_int(KEY('/general/window_width')) | |
+ height = self.client.get_int(KEY('/general/window_height')) | |
+ | |
screen = self.window.get_screen() | |
- height = self.client.get_int(KEY('/general/window_size')) | |
+ screen_width = screen.get_width() | |
+ screen_height = screen.get_height() | |
+ | |
+ final_height = screen_height * height / 100 | |
+ final_width = screen_width * width / 100 | |
# avoiding X Window system error | |
- max_height = screen.get_height() | |
- if height > max_height: | |
- height = max_height | |
+ if final_width > screen_width: | |
+ final_width = screen_width | |
+ if final_height > screen_height: | |
+ final_height = screen_height | |
+ | |
+ return final_width, final_height | |
+ | |
+ def get_final_window_pos(self, width, height): | |
+ """Gets the final position of the main window of guake based | |
+ on alignment user setting. | |
+ TODO: support vertical alignment (y is currently always 0) | |
+ """ | |
+ alignment = self.client.get_int(KEY('/general/window_halignment')) | |
+ screen = self.window.get_screen() | |
+ screen_width = screen.get_width() | |
+ screen_height = screen.get_height() | |
+ x, y = 0, 0 | |
- # get the width just from the first/default monitor in the | |
- # future we might create a field to select which monitor you | |
- # wanna use | |
- width = screen.get_monitor_geometry(0).width | |
+ # if width == screen_width, there's no point in aligning the window | |
+ if width < screen_width: | |
+ if alignment == ALIGN_CENTER: | |
+ x = (screen_width / 2) - (width / 2) | |
+ elif alignment == ALIGN_LEFT: | |
+ x = 0 | |
+ elif alignment == ALIGN_RIGHT: | |
+ x = screen_width - width | |
- total_height = self.window.get_screen().get_height() | |
- final_height = total_height * height / 100 | |
- return width, final_height | |
+ return x, y | |
# -- configuration -- | |
def load_config(self): | |
- """"Just a proxy for all the configuration stuff. | |
+ """Just a proxy for all the configuration stuff. | |
""" | |
self.client.notify(KEY('/general/use_trayicon')) | |
self.client.notify(KEY('/general/window_tabbar')) | |
self.client.notify(KEY('/general/window_ontop')) | |
- self.client.notify(KEY('/general/window_size')) | |
+ self.client.notify(KEY('/general/window_halignment')) | |
+ self.client.notify(KEY('/general/window_height')) | |
+ self.client.notify(KEY('/general/window_width')) | |
self.client.notify(KEY('/general/use_scrollbar')) | |
self.client.notify(KEY('/general/history_size')) | |
self.client.notify(KEY('/general/show_resizer')) | |
diff --git a/src/guake_globals.py.in b/src/guake_globals.py.in | |
index ec86c55..e64a880 100644 | |
--- a/src/guake_globals.py.in | |
+++ b/src/guake_globals.py.in | |
@@ -22,6 +22,7 @@ Boston, MA 02111-1307, USA. | |
__all__ = [ | |
'name', 'version', 'image_dir', 'glade_dir', 'locale_dir', | |
'GCONF_PATH', 'KEY', 'TERMINAL_MATCH_EXPRS', 'TERMINAL_MATCH_TAGS', | |
+ 'ALIGN_CENTER', 'ALIGN_RIGHT', 'ALIGN_LEFT', | |
] | |
name = 'guake' | |
@@ -54,3 +55,5 @@ TERMINAL_MATCH_EXPRS = [ | |
] | |
TERMINAL_MATCH_TAGS = 'schema', 'http', 'email' | |
+ | |
+ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT = range(3) | |
diff --git a/src/prefs.py b/src/prefs.py | |
index cc0e90e..50ff53e 100644 | |
--- a/src/prefs.py | |
+++ b/src/prefs.py | |
@@ -25,7 +25,7 @@ import gobject | |
import gconf | |
from simplegladeapp import SimpleGladeApp | |
-from guake_globals import GCONF_PATH, KEY | |
+from guake_globals import GCONF_PATH, KEY, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER | |
from common import * | |
import globalhotkeys | |
@@ -128,11 +128,26 @@ class PrefsCallbacks(object): | |
""" | |
self.client.set_bool(KEY('/general/window_tabbar'), chk.get_active()) | |
- def on_window_size_value_changed(self, hscale): | |
- """Changes the value of window_size in gconf | |
+ def on_window_halignment_changed(self, combo): | |
+ """Changes the activity of window_alignment in gconf | |
+ """ | |
+ citer = combo.get_active_iter() | |
+ if not citer: | |
+ return | |
+ alignment = combo.get_model().get_value(citer, 1) | |
+ self.client.set_int(KEY('/general/window_halignment'), alignment) | |
+ | |
+ def on_window_height_value_changed(self, hscale): | |
+ """Changes the value of window_height in gconf | |
+ """ | |
+ val = hscale.get_value() | |
+ self.client.set_int(KEY('/general/window_height'), int(val)) | |
+ | |
+ def on_window_width_value_changed(self, hscale): | |
+ """Changes the value of window_width in gconf | |
""" | |
val = hscale.get_value() | |
- self.client.set_int(KEY('/general/window_size'), int(val)) | |
+ self.client.set_int(KEY('/general/window_width'), int(val)) | |
# scrolling tab | |
@@ -263,6 +278,7 @@ class PrefsDialog(SimpleGladeApp): | |
treeview.append_column(column) | |
self.populate_shell_combo() | |
+ self.populate_halignment_combo() | |
self.populate_keys_tree() | |
self.load_configs() | |
self.get_widget('config-window').hide() | |
@@ -384,9 +400,19 @@ class PrefsDialog(SimpleGladeApp): | |
value = self.client.get_bool(KEY('/general/window_tabbar')) | |
self.get_widget('window_tabbar').set_active(value) | |
- # size | |
- value = float(self.client.get_int(KEY('/general/window_size'))) | |
- self.get_widget('window_size').set_value(value) | |
+ # horizontal alignment | |
+ combo = self.get_widget('window_halignment') | |
+ for i in combo.get_model(): | |
+ if i[1] == self.client.get_int(KEY('/general/window_halignment')): | |
+ combo.set_active_iter(i.iter) | |
+ | |
+ # width | |
+ value = float(self.client.get_int(KEY('/general/window_width'))) | |
+ self.get_widget('window_width').set_value(value) | |
+ | |
+ # height | |
+ value = float(self.client.get_int(KEY('/general/window_height'))) | |
+ self.get_widget('window_height').set_value(value) | |
# scrollbar | |
value = self.client.get_bool(KEY('/general/use_scrollbar')) | |
@@ -458,6 +484,17 @@ class PrefsDialog(SimpleGladeApp): | |
for i in get_binaries_from_path(PYTHONS): | |
cb.append_text(i) | |
+ def populate_halignment_combo(self): | |
+ """Fill combo model with alignment possible values. | |
+ """ | |
+ model = self.get_widget('window_halignment').get_model() | |
+ model.set_column_types(gobject.TYPE_STRING, gobject.TYPE_INT) | |
+ for row in ( | |
+ ("Center", ALIGN_CENTER), | |
+ ("Left", ALIGN_LEFT), | |
+ ("Right", ALIGN_RIGHT)): | |
+ model.append(row) | |
+ | |
def populate_keys_tree(self): | |
"""Reads the HOTKEYS global variable and insert all data in | |
the TreeStore used by the preferences window treeview. | |
-- | |
1.5.6.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment