Save and restore Preferences dialog size from config

This commit is contained in:
Calum Lind 2011-06-19 23:11:04 +01:00
parent 6a873c524e
commit 4f3c753fc1
3 changed files with 19 additions and 4 deletions

View File

@ -7,11 +7,12 @@
<property name="border_width">5</property>
<property name="title" translatable="yes">Preferences</property>
<property name="window_position">center-on-parent</property>
<property name="default_width">510</property>
<property name="default_height">530</property>
<property name="default_width">500</property>
<property name="default_height">560</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<signal name="configure_event" handler="on_pref_dialog_configure_event"/>
<signal name="delete_event" handler="on_pref_dialog_delete_event"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">

View File

@ -125,6 +125,8 @@ DEFAULT_PREFS = {
"window_y_pos": 0,
"window_width": 640,
"window_height": 480,
"pref_dialog_width": None,
"pref_dialog_height": None,
"window_pane_position": -1,
"tray_download_speed_list" : [5.0, 10.0, 30.0, 80.0, 300.0],
"tray_upload_speed_list" : [5.0, 10.0, 30.0, 80.0, 300.0],

View File

@ -51,7 +51,6 @@ import deluge.configmanager
class Preferences(component.Component):
def __init__(self):
component.Component.__init__(self, "Preferences")
self.window = component.get("MainWindow")
self.glade = gtk.glade.XML(
pkg_resources.resource_filename("deluge.ui.gtkui",
"glade/preferences_dialog.glade"))
@ -61,6 +60,8 @@ class Preferences(component.Component):
self.notebook = self.glade.get_widget("notebook")
self.gtkui_config = ConfigManager("gtkui.conf")
self.load_pref_dialog_state()
self.glade.get_widget("image_magnet").set_from_file(
deluge.common.get_pixmap("magnet.png"))
@ -111,7 +112,8 @@ class Preferences(component.Component):
"on_button_find_plugins_clicked": self._on_button_find_plugins_clicked,
"on_button_cache_refresh_clicked": self._on_button_cache_refresh_clicked,
"on_combo_proxy_type_changed": self._on_combo_proxy_type_changed,
"on_button_associate_magnet_clicked": self._on_button_associate_magnet_clicked
"on_button_associate_magnet_clicked": self._on_button_associate_magnet_clicked,
"on_pref_dialog_configure_event": self.on_pref_dialog_configure_event,
})
# These get updated by requests done to the core
@ -768,6 +770,16 @@ class Preferences(component.Component):
self.hide()
return True
def load_pref_dialog_state(self):
w = self.gtkui_config["pref_dialog_width"]
h = self.gtkui_config["pref_dialog_height"]
if w != None and h != None:
self.pref_dialog.resize(w, h)
def on_pref_dialog_configure_event(self, widget, event):
self.gtkui_config["pref_dialog_width"] = event.width
self.gtkui_config["pref_dialog_height"] = event.height
def on_toggle(self, widget):
"""Handles widget sensitivity based on radio/check button values."""
try: