Save and restore Preferences dialog size from config

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

View File

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

View File

@ -105,6 +105,8 @@ DEFAULT_PREFS = {
"window_y_pos": 0, "window_y_pos": 0,
"window_width": 640, "window_width": 640,
"window_height": 480, "window_height": 480,
"pref_dialog_width": None,
"pref_dialog_height": None,
"window_pane_position": -1, "window_pane_position": -1,
"tray_download_speed_list" : [5.0, 10.0, 30.0, 80.0, 300.0], "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], "tray_upload_speed_list" : [5.0, 10.0, 30.0, 80.0, 300.0],

View File

@ -64,7 +64,6 @@ COLOR_STATES = {
class Preferences(component.Component): class Preferences(component.Component):
def __init__(self): def __init__(self):
component.Component.__init__(self, "Preferences") component.Component.__init__(self, "Preferences")
self.window = component.get("MainWindow")
self.glade = gtk.glade.XML(deluge.common.resource_filename( self.glade = gtk.glade.XML(deluge.common.resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "preferences_dialog.glade") "deluge.ui.gtkui", os.path.join("glade", "preferences_dialog.glade")
)) ))
@ -74,6 +73,8 @@ class Preferences(component.Component):
self.notebook = self.glade.get_widget("notebook") self.notebook = self.glade.get_widget("notebook")
self.gtkui_config = ConfigManager("gtkui.conf") self.gtkui_config = ConfigManager("gtkui.conf")
self.load_pref_dialog_state()
self.glade.get_widget("image_magnet").set_from_file( self.glade.get_widget("image_magnet").set_from_file(
deluge.common.get_pixmap("magnet.png")) deluge.common.get_pixmap("magnet.png"))
@ -168,7 +169,8 @@ class Preferences(component.Component):
"on_waiting_color_set": self._on_waiting_color_set, "on_waiting_color_set": self._on_waiting_color_set,
"on_revert_color_waiting_clicked": self._on_revert_color_waiting_clicked, "on_revert_color_waiting_clicked": self._on_revert_color_waiting_clicked,
"on_missing_color_set": self._on_missing_color_set, "on_missing_color_set": self._on_missing_color_set,
"on_revert_color_missing_clicked": self._on_revert_color_missing_clicked "on_revert_color_missing_clicked": self._on_revert_color_missing_clicked,
"on_pref_dialog_configure_event": self.on_pref_dialog_configure_event,
}) })
from deluge.ui.gtkui.gtkui import DEFAULT_PREFS from deluge.ui.gtkui.gtkui import DEFAULT_PREFS
@ -877,6 +879,16 @@ class Preferences(component.Component):
self.hide() self.hide()
return True 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): def on_toggle(self, widget):
"""Handles widget sensitivity based on radio/check button values.""" """Handles widget sensitivity based on radio/check button values."""
try: try: