From d4535c61648d2702fedc24d21bbb98b9ab5f8db2 Mon Sep 17 00:00:00 2001 From: Robert Zwerus Date: Sat, 19 Sep 2015 16:52:49 +0200 Subject: [PATCH] [GTKUI] Store width and height of 'Edit trackers' dialog in config --- deluge/ui/gtkui/edittrackersdialog.py | 21 ++++++++++++++++++++- deluge/ui/gtkui/glade/edit_trackers.ui | 1 + deluge/ui/gtkui/gtkui.py | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/deluge/ui/gtkui/edittrackersdialog.py b/deluge/ui/gtkui/edittrackersdialog.py index f00bfec9d..b3f746b2f 100644 --- a/deluge/ui/gtkui/edittrackersdialog.py +++ b/deluge/ui/gtkui/edittrackersdialog.py @@ -15,6 +15,7 @@ from twisted.internet import defer import deluge.component as component from deluge.common import is_url, resource_filename +from deluge.configmanager import ConfigManager from deluge.ui.client import client from deluge.ui.gtkui.common import get_deluge_icon @@ -25,6 +26,8 @@ class EditTrackersDialog: def __init__(self, torrent_id, parent=None): self.torrent_id = torrent_id self.builder = gtk.Builder() + self.gtkui_config = ConfigManager("gtkui.conf") + # Main dialog self.builder.add_from_file(resource_filename( "deluge.ui.gtkui", os.path.join("glade", "edit_trackers.ui") @@ -46,6 +49,8 @@ class EditTrackersDialog: self.edit_tracker_entry.set_transient_for(self.dialog) self.dialog.set_icon(get_deluge_icon()) + self.load_edit_trackers_dialog_state() + if parent is not None: self.dialog.set_transient_for(parent) @@ -59,7 +64,8 @@ class EditTrackersDialog: "on_button_remove_clicked": self.on_button_remove_clicked, "on_button_down_clicked": self.on_button_down_clicked, "on_button_add_ok_clicked": self.on_button_add_ok_clicked, - "on_button_add_cancel_clicked": self.on_button_add_cancel_clicked + "on_button_add_cancel_clicked": self.on_button_add_cancel_clicked, + "on_edit_trackers_dialog_configure_event": self.on_edit_trackers_dialog_configure_event }) # Create a liststore for tier, url @@ -92,6 +98,19 @@ class EditTrackersDialog: self.deferred = defer.Deferred() return self.deferred + def __del__(self): + del self.gtkui_config + + def load_edit_trackers_dialog_state(self): + w = self.gtkui_config["edit_trackers_dialog_width"] + h = self.gtkui_config["edit_trackers_dialog_height"] + if w is not None and h is not None: + self.dialog.resize(w, h) + + def on_edit_trackers_dialog_configure_event(self, widget, event): + self.gtkui_config["edit_trackers_dialog_width"] = event.width + self.gtkui_config["edit_trackers_dialog_height"] = event.height + def _on_delete_event(self, widget, event): self.deferred.callback(gtk.RESPONSE_DELETE_EVENT) self.dialog.destroy() diff --git a/deluge/ui/gtkui/glade/edit_trackers.ui b/deluge/ui/gtkui/glade/edit_trackers.ui index f79958122..06fc2b386 100644 --- a/deluge/ui/gtkui/glade/edit_trackers.ui +++ b/deluge/ui/gtkui/glade/edit_trackers.ui @@ -11,6 +11,7 @@ 400 True dialog + True diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index 41432face..85f08e971 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -97,6 +97,8 @@ DEFAULT_PREFS = { "window_height": 480, "pref_dialog_width": None, "pref_dialog_height": None, + "edit_trackers_dialog_width": None, + "edit_trackers_dialog_height": None, "window_pane_position": 235, "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],