From 75207e168070482f7714d1e06229f463e9941a75 Mon Sep 17 00:00:00 2001
From: Stefano Tortarolo <stefano.tortarolo@gmail.com>
Date: Mon, 20 Jul 2009 12:27:39 +0200
Subject: [PATCH 2/3] Allow window width to be customized
---
data/guake.schemas | 15 ++++++++++++++-
data/prefs.glade | 41 ++++++++++++++++++++++++++++++++++++++++-
src/guake.py | 13 ++++++++-----
src/prefs.py | 12 +++++++++++-
4 files changed, 73 insertions(+), 8 deletions(-)
diff --git a/data/guake.schemas b/data/guake.schemas
index fb25663..6273c7c 100644
|
a
|
b
|
|
| 92 | 92 | </locale> |
| 93 | 93 | </schema> |
| 94 | 94 | |
| 95 | | <schema> |
| | 95 | <schema> |
| | 96 | <key>/schemas/apps/guake/general/window_width</key> |
| | 97 | <applyto>/apps/guake/general/window_width</applyto> |
| | 98 | <owner>guake</owner> |
| | 99 | <type>int</type> |
| | 100 | <default>100</default> |
| | 101 | <locale name="C"> |
| | 102 | <short>Window height.</short> |
| | 103 | <long>Percent of the screen that will be used by guake |
| | 104 | terminal horizontally.</long> |
| | 105 | </locale> |
| | 106 | </schema> |
| | 107 | |
| | 108 | <schema> |
| 96 | 109 | <key>/schemas/apps/guake/general/window_height</key> |
| 97 | 110 | <applyto>/apps/guake/general/window_height</applyto> |
| 98 | 111 | <owner>guake</owner> |
diff --git a/data/prefs.glade b/data/prefs.glade
index 31f348d..798585f 100644
|
a
|
b
|
|
| 336 | 336 | <widget class="GtkLabel" id="label24"> |
| 337 | 337 | <property name="visible">True</property> |
| 338 | 338 | <property name="ypad">6</property> |
| 339 | | <property name="label" translatable="yes"><b>Main Window size</b></property> |
| | 339 | <property name="label" translatable="yes"><b>Main Window height</b></property> |
| 340 | 340 | <property name="use_markup">True</property> |
| 341 | 341 | </widget> |
| 342 | 342 | <packing> |
| … |
… |
|
| 348 | 348 | <property name="position">3</property> |
| 349 | 349 | </packing> |
| 350 | 350 | </child> |
| | 351 | <child> |
| | 352 | <widget class="GtkFrame" id="frame12"> |
| | 353 | <property name="visible">True</property> |
| | 354 | <property name="label_xalign">0</property> |
| | 355 | <property name="shadow_type">GTK_SHADOW_NONE</property> |
| | 356 | <child> |
| | 357 | <widget class="GtkAlignment" id="alignment12"> |
| | 358 | <property name="visible">True</property> |
| | 359 | <property name="left_padding">12</property> |
| | 360 | <child> |
| | 361 | <widget class="GtkHScale" id="window_width"> |
| | 362 | <property name="visible">True</property> |
| | 363 | <property name="can_focus">True</property> |
| | 364 | <property name="update_policy">GTK_UPDATE_DISCONTINUOUS</property> |
| | 365 | <property name="adjustment">50 10 110 10 10 10</property> |
| | 366 | <property name="digits">0</property> |
| | 367 | <property name="draw_value">False</property> |
| | 368 | <property name="value_pos">GTK_POS_RIGHT</property> |
| | 369 | <signal name="value_changed" handler="on_window_width_value_changed"/> |
| | 370 | </widget> |
| | 371 | </child> |
| | 372 | </widget> |
| | 373 | </child> |
| | 374 | <child> |
| | 375 | <widget class="GtkLabel" id="label25"> |
| | 376 | <property name="visible">True</property> |
| | 377 | <property name="ypad">6</property> |
| | 378 | <property name="label" translatable="yes"><b>Main Window width</b></property> |
| | 379 | <property name="use_markup">True</property> |
| | 380 | </widget> |
| | 381 | <packing> |
| | 382 | <property name="type">label_item</property> |
| | 383 | </packing> |
| | 384 | </child> |
| | 385 | </widget> |
| | 386 | <packing> |
| | 387 | <property name="position">4</property> |
| | 388 | </packing> |
| | 389 | </child> |
| 351 | 390 | </widget> |
| 352 | 391 | </child> |
| 353 | 392 | <child> |
diff --git a/src/guake.py b/src/guake.py
index e9917fd..270ad48 100644
|
a
|
b
|
|
| 95 | 95 | notify_add(KEY('/general/use_trayicon'), self.trayicon_toggled) |
| 96 | 96 | notify_add(KEY('/general/window_ontop'), self.ontop_toggled) |
| 97 | 97 | notify_add(KEY('/general/window_tabbar'), self.tabbar_toggled) |
| | 98 | notify_add(KEY('/general/window_width'), self.size_changed) |
| 98 | 99 | notify_add(KEY('/general/window_height'), self.size_changed) |
| 99 | 100 | |
| 100 | 101 | notify_add(KEY('/general/use_scrollbar'), self.scrollbar_toggled) |
| … |
… |
|
| 145 | 146 | self.guake.toolbar.hide() |
| 146 | 147 | |
| 147 | 148 | def size_changed(self, client, connection_id, entry, data): |
| 148 | | """If the gconf var window_height be changed, this method will |
| 149 | | be called and will call the resize function in guake. |
| | 149 | """If the gconf var window_height or window_width are changed, |
| | 150 | this method will be called and will call the resize function |
| | 151 | in guake. |
| 150 | 152 | """ |
| 151 | 153 | window_rect = self.guake.get_final_window_rect() |
| 152 | 154 | self.guake.window.resize(window_rect.width, window_rect.height) |
| … |
… |
|
| 738 | 740 | |
| 739 | 741 | def get_final_window_rect(self): |
| 740 | 742 | """Gets the final size of the main window of guake. The height |
| 741 | | is just the window_height property. But width is calculated as |
| 742 | | 100% of the screen and tested against the monitor geometry |
| 743 | | width. |
| | 743 | is the window_height property, while width is window_width. |
| 744 | 744 | """ |
| 745 | 745 | screen = self.window.get_screen() |
| 746 | 746 | height = self.client.get_int(KEY('/general/window_height')) |
| | 747 | width = self.client.get_int(KEY('/general/window_width')) |
| 747 | 748 | |
| 748 | 749 | # get the rectangle just from the first/default monitor in the |
| 749 | 750 | # future we might create a field to select which monitor you |
| … |
… |
|
| 751 | 752 | window_rect = screen.get_monitor_geometry(0) |
| 752 | 753 | |
| 753 | 754 | window_rect.height = window_rect.height * height / 100 |
| | 755 | window_rect.width = window_rect.width * width / 100 |
| 754 | 756 | return window_rect |
| 755 | 757 | |
| 756 | 758 | # -- configuration -- |
| … |
… |
|
| 761 | 763 | self.client.notify(KEY('/general/use_trayicon')) |
| 762 | 764 | self.client.notify(KEY('/general/window_tabbar')) |
| 763 | 765 | self.client.notify(KEY('/general/window_ontop')) |
| | 766 | self.client.notify(KEY('/general/window_width')) |
| 764 | 767 | self.client.notify(KEY('/general/window_height')) |
| 765 | 768 | self.client.notify(KEY('/general/use_scrollbar')) |
| 766 | 769 | self.client.notify(KEY('/general/history_size')) |
diff --git a/src/prefs.py b/src/prefs.py
index 552fb6c..88daed2 100644
|
a
|
b
|
|
| 138 | 138 | """ |
| 139 | 139 | self.client.set_bool(KEY('/general/window_tabbar'), chk.get_active()) |
| 140 | 140 | |
| | 141 | def on_window_width_value_changed(self, wscale): |
| | 142 | """Changes the value of window_width in gconf |
| | 143 | """ |
| | 144 | val = wscale.get_value() |
| | 145 | self.client.set_int(KEY('/general/window_width'), int(val)) |
| | 146 | |
| 141 | 147 | def on_window_height_value_changed(self, hscale): |
| 142 | 148 | """Changes the value of window_height in gconf |
| 143 | 149 | """ |
| … |
… |
|
| 397 | 403 | value = self.client.get_bool(KEY('/general/window_tabbar')) |
| 398 | 404 | self.get_widget('window_tabbar').set_active(value) |
| 399 | 405 | |
| 400 | | # size |
| | 406 | # width |
| | 407 | value = float(self.client.get_int(KEY('/general/window_width'))) |
| | 408 | self.get_widget('window_width').set_value(value) |
| | 409 | |
| | 410 | # height |
| 401 | 411 | value = float(self.client.get_int(KEY('/general/window_height'))) |
| 402 | 412 | self.get_widget('window_height').set_value(value) |
| 403 | 413 | |