diff --git a/glade/plugin_dialog.glade b/glade/plugin_dialog.glade index 67427d5e4..e4dd17aef 100644 --- a/glade/plugin_dialog.glade +++ b/glade/plugin_dialog.glade @@ -9,7 +9,7 @@ 583 431 True - GDK_WINDOW_TYPE_HINT_DIALOG + GDK_WINDOW_TYPE_HINT_NORMAL True True @@ -127,6 +127,7 @@ gtk-close True 0 + diff --git a/glade/preferences_dialog.glade b/glade/preferences_dialog.glade index a09b316c2..89fa02187 100644 --- a/glade/preferences_dialog.glade +++ b/glade/preferences_dialog.glade @@ -10,7 +10,7 @@ GTK_WIN_POS_CENTER_ON_PARENT 550 True - GDK_WINDOW_TYPE_HINT_DIALOG + GDK_WINDOW_TYPE_HINT_NORMAL True True False @@ -2289,7 +2289,7 @@ HTTP W/ Auth True GTK_BUTTONBOX_END - + True gtk-cancel True @@ -2297,7 +2297,7 @@ HTTP W/ Auth - + True gtk-ok True diff --git a/plugins/EventLogging/__init__.py b/plugins/EventLogging/__init__.py index b9b09f91f..2413538d5 100644 --- a/plugins/EventLogging/__init__.py +++ b/plugins/EventLogging/__init__.py @@ -71,8 +71,11 @@ class EventLogging: self.dialog_initialize = True self.glade = gtk.glade.XML(path + "/event_logging_preferences.glade") self.dialog = self.glade.get_widget("dialog") + self.dialog.set_position(gtk.WIN_POS_CENTER) self.glade.signal_autoconnect({ - 'toggle_ui': self.toggle_ui + 'toggle_ui': self.toggle_ui, + 'on_button_cancel_pressed': self.cancel_pressed, + 'on_button_ok_pressed': self.ok_pressed }) self.viewport = gtk.Viewport() self.scrolledWindow = gtk.ScrolledWindow() @@ -341,24 +344,27 @@ class EventLogging: self.glade.get_widget("chk_log_files").set_active(False) self.dialog_initialize = False self.dialog.show() - response = self.dialog.run() + + def ok_pressed(self, src): + self.dialog.hide() + self.config.set("enable_finished", self.glade.get_widget("chk_finished").get_active()) + self.config.set("enable_peer_error", self.glade.get_widget("chk_peer_error").get_active()) + self.config.set("enable_invalid_request", self.glade.get_widget("chk_invalid_request").get_active()) + self.config.set("enable_file_error", self.glade.get_widget("chk_file_error").get_active()) + self.config.set("enable_hash_failed_error", self.glade.get_widget("chk_hash_failed_error").get_active()) + self.config.set("enable_peer_ban_error", self.glade.get_widget("chk_peer_ban_error").get_active()) + self.config.set("enable_fastresume_rejected_error", self.glade.get_widget("chk_fastresume_rejected_error").get_active()) + self.config.set("enable_tracker_announce", self.glade.get_widget("chk_tracker_announce").get_active()) + self.config.set("enable_tracker_reply", self.glade.get_widget("chk_tracker_reply").get_active()) + self.config.set("enable_tracker_alert", self.glade.get_widget("chk_tracker_alert").get_active()) + self.config.set("enable_tracker_warning", self.glade.get_widget("chk_tracker_warning").get_active()) + self.config.set("enable_storage_moved", self.glade.get_widget("chk_storage_moved").get_active()) + self.config.set("enable_piece_finished", self.glade.get_widget("chk_piece_finished").get_active()) + self.config.set("enable_block_downloading", self.glade.get_widget("chk_block_downloading").get_active()) + self.config.set("enable_block_finished", self.glade.get_widget("chk_block_finished").get_active()) + self.config.set("enable_peer_blocked", self.glade.get_widget("chk_peer_blocked").get_active()) + self.config.set("enable_other", self.glade.get_widget("chk_other").get_active()) + self.config.set("enable_log_files", self.glade.get_widget("chk_log_files").get_active()) + + def cancel_pressed(self, src): self.dialog.hide() - if response: - self.config.set("enable_finished", self.glade.get_widget("chk_finished").get_active()) - self.config.set("enable_peer_error", self.glade.get_widget("chk_peer_error").get_active()) - self.config.set("enable_invalid_request", self.glade.get_widget("chk_invalid_request").get_active()) - self.config.set("enable_file_error", self.glade.get_widget("chk_file_error").get_active()) - self.config.set("enable_hash_failed_error", self.glade.get_widget("chk_hash_failed_error").get_active()) - self.config.set("enable_peer_ban_error", self.glade.get_widget("chk_peer_ban_error").get_active()) - self.config.set("enable_fastresume_rejected_error", self.glade.get_widget("chk_fastresume_rejected_error").get_active()) - self.config.set("enable_tracker_announce", self.glade.get_widget("chk_tracker_announce").get_active()) - self.config.set("enable_tracker_reply", self.glade.get_widget("chk_tracker_reply").get_active()) - self.config.set("enable_tracker_alert", self.glade.get_widget("chk_tracker_alert").get_active()) - self.config.set("enable_tracker_warning", self.glade.get_widget("chk_tracker_warning").get_active()) - self.config.set("enable_storage_moved", self.glade.get_widget("chk_storage_moved").get_active()) - self.config.set("enable_piece_finished", self.glade.get_widget("chk_piece_finished").get_active()) - self.config.set("enable_block_downloading", self.glade.get_widget("chk_block_downloading").get_active()) - self.config.set("enable_block_finished", self.glade.get_widget("chk_block_finished").get_active()) - self.config.set("enable_peer_blocked", self.glade.get_widget("chk_peer_blocked").get_active()) - self.config.set("enable_other", self.glade.get_widget("chk_other").get_active()) - self.config.set("enable_log_files", self.glade.get_widget("chk_log_files").get_active()) diff --git a/plugins/EventLogging/event_logging_preferences.glade b/plugins/EventLogging/event_logging_preferences.glade index b7977fe4a..4720b6b86 100644 --- a/plugins/EventLogging/event_logging_preferences.glade +++ b/plugins/EventLogging/event_logging_preferences.glade @@ -7,6 +7,7 @@ Event Logging Preferences 400 150 + GDK_WINDOW_TYPE_HINT_NORMAL False @@ -18,249 +19,28 @@ True 20 - - True - Select events to log - - - - + True True - Torrent finished + Enable log files True 0 True - 1 - 2 + 19 + 20 - + True - True - Peer messages - True - 0 - True - + Log files - 2 - 3 - - - - - True - True - Invalid request - True - 0 - True - - - - 3 - 4 - - - - - True - True - File error - True - 0 - True - - - - 4 - 5 - - - - - True - True - Hash failed error - True - 0 - True - - - - 5 - 6 - - - - - True - True - Peer ban error - True - 0 - True - - - - 6 - 7 - - - - - True - True - Fastresume rejected error - True - 0 - True - - - - 7 - 8 - - - - - True - True - Tracker announce - True - 0 - True - - - - 8 - 9 - - - - - True - True - Tracker reply - True - 0 - True - - - - 9 - 10 - - - - - True - True - Tracker alert - True - 0 - True - - - - 10 - 11 - - - - - True - True - Tracker warning - True - 0 - True - - - - 11 - 12 - - - - - True - True - Storage moved - True - 0 - True - - - - 12 - 13 - - - - - True - True - Piece finished - True - 0 - True - - - - 13 - 14 - - - - - True - True - Block downloading - True - 0 - True - - - - 14 - 15 - - - - - True - True - Block finished - True - 0 - True - - - - 15 - 16 - - - - - True - True - Peer blocked - True - 0 - True - - - - 16 - 17 + 18 + 19 @@ -279,34 +59,256 @@ - - True - Log files - - - 18 - 19 - - - - + True True - Enable log files + Peer blocked True 0 True - 19 - 20 + 16 + 17 + + + True + True + Block finished + True + 0 + True + + + + 15 + 16 + + + + + True + True + Block downloading + True + 0 + True + + + + 14 + 15 + + + + + True + True + Piece finished + True + 0 + True + + + + 13 + 14 + + + + + True + True + Storage moved + True + 0 + True + + + + 12 + 13 + + + + + True + True + Tracker warning + True + 0 + True + + + + 11 + 12 + + + + + True + True + Tracker alert + True + 0 + True + + + + 10 + 11 + + + + + True + True + Tracker reply + True + 0 + True + + + + 9 + 10 + + + + + True + True + Tracker announce + True + 0 + True + + + + 8 + 9 + + + + + True + True + Fastresume rejected error + True + 0 + True + + + + 7 + 8 + + + + + True + True + Peer ban error + True + 0 + True + + + + 6 + 7 + + + + + True + True + Hash failed error + True + 0 + True + + + + 5 + 6 + + + + + True + True + File error + True + 0 + True + + + + 4 + 5 + + + + + True + True + Invalid request + True + 0 + True + + + + 3 + 4 + + + + + True + True + Peer messages + True + 0 + True + + + + 2 + 3 + + + + + True + True + Torrent finished + True + 0 + True + + + + 1 + 2 + + + + + True + Select events to log + + - False False + False + 1 @@ -320,6 +322,7 @@ gtk-cancel True 0 + @@ -328,6 +331,7 @@ gtk-ok True 1 + 1 @@ -343,4 +347,3 @@ - diff --git a/plugins/RSS/plugin.py b/plugins/RSS/plugin.py index 55b69b510..3adc91fb7 100644 --- a/plugins/RSS/plugin.py +++ b/plugins/RSS/plugin.py @@ -1,437 +1,444 @@ class plugin_RSS: - def __init__(self, path, deluge_core, deluge_interface): - #set up system thingies - import gtk, gtk.glade, os, ConfigParser, feedparser - import deluge.common, deluge.dgtk, deluge.pref - from time import asctime - self.path = path - self.core = deluge_core - self.interface = deluge_interface - #set up feeds file - self.feeds_config = ConfigParser.ConfigParser() - self.feeds_file = deluge.common.CONFIG_DIR + "/feeds.conf" - if not os.path.isfile(self.feeds_file): - f = open(self.feeds_file, mode='w') - f.flush() - f.close() - self.feeds_config.read(self.feeds_file) - #set up filters file - self.filters_config = ConfigParser.ConfigParser() - self.filters_file = deluge.common.CONFIG_DIR + "/filters.conf" - if not os.path.isfile(self.filters_file): - f = open(self.filters_file, mode='w') - f.flush() - f.close() - self.filters_config.read(self.filters_file) - #set up the preferences dialog - glade = gtk.glade.XML(path + "/rss.glade") - self.dlg = glade.get_widget("dialog") - self.dlg.set_icon_from_file(self.path + "/rss.png") - #set up the feeds list viewer - self.feeds_view = glade.get_widget("feeds_view") - model = gtk.ListStore(str, str, str) - self.feeds_view.set_model(model) - deluge.dgtk.add_text_column(self.feeds_view, _("Name"), 0) - deluge.dgtk.add_text_column(self.feeds_view, _("URL"), 1) - deluge.dgtk.add_text_column(self.feeds_view, _("Last Entry Date"), 2) - #set up the torrents list viewer - self.torrents_view = glade.get_widget("torrents_view") - model = gtk.ListStore(str, str, str, str) - self.torrents_view.set_model(model) - deluge.dgtk.add_text_column(self.torrents_view, _("Feed"), 0) - deluge.dgtk.add_text_column(self.torrents_view, _("Name"), 1) - deluge.dgtk.add_text_column(self.torrents_view, _("URL"), 2) - deluge.dgtk.add_text_column(self.torrents_view, _("Date"), 3) - # Setup the filters list viewer - self.filters_view = glade.get_widget("filters_view") - model = gtk.ListStore(str) - self.filters_view.set_model(model) - deluge.dgtk.add_text_column(self.filters_view, _("Name"), 0) - # set up the feed choice combobox - self.feedchoice_combo = glade.get_widget("feedchoice_combo") - model = gtk.ListStore(str) - self.feedchoice_combo.set_model(model) - cell = gtk.CellRendererText() - self.feedchoice_combo.pack_start(cell, True) - self.feedchoice_combo.add_attribute(cell, 'text', 0) - # set up the torrents feed choice combobox - self.torrents_fcc = glade.get_widget("torrents_fcc") - model = gtk.ListStore(str) - self.torrents_fcc.set_model(model) - cell = gtk.CellRendererText() - self.torrents_fcc.pack_start(cell, True) - self.torrents_fcc.add_attribute(cell, 'text', 0) - #set up the rest of the GUI elements - self.name_entry = glade.get_widget("name_entry") - self.url_entry = glade.get_widget("url_entry") - self.button_addfeed = glade.get_widget("button_addfeed") - self.button_delfeed = glade.get_widget("button_delfeed") - self.chkfeeds = glade.get_widget("chkfeeds") - self.filtername_entry = glade.get_widget("filtername_entry") - self.filterexp_entry = glade.get_widget("filterexp_entry") - self.button_delfilter = glade.get_widget("button_delfilter") - self.checkonstart_button = glade.get_widget("checkonstart_button") - self.update_entry = glade.get_widget("update_entry") - #Connect event signals - self.filters_view.connect("cursor-changed", self.filter_row_clicked) - dic = { "addfeed_clicked" : self.addfeed_clicked, - "delfeed_clicked" : self.delfeed_clicked, - "addfilter_clicked" : self.addfilter_clicked, - "delfilter_clicked" : self.delfilter_clicked, - "row_clicked" : self.row_clicked, - "feedtext_changed" : self.feedtext_changed, - "filtername_lostfocus" : self.filtername_lostfocus, - "filterexp_lostfocus" : self.filterexp_lostfocus, - "feedchoice_combo_changed" : self.feedchoice_combo_changed, - "torrents_fcc_changed" : self.torrents_fcc_changed, - "torrents_view_row_activated" : self.torrents_view_row_activated, - "chkfeeds_clicked" : self.chkfeeds_clicked } - glade.signal_autoconnect(dic) - self.feeds_view.get_selection().set_select_function(self.row_clicked) - self.timer = 0 - self.torrents_list = [] - #self.checkfeeds() - # Access the interface's toolbar - self.toolbar = self.interface.toolbar - # Make a toolbar button - icon = gtk.Image() - icon.set_from_file(self.path + "/rss.png") # Toolbar items should be 22x22 pixel images - self.button = gtk.ToolButton(icon_widget=icon, label=_("RSS")) - self.ttips = gtk.Tooltips() - self.button.set_tooltip(self.ttips, _("RSS Broadcatcher")) - self.button.connect("clicked", self.rss_clicked) # Connect the signal handler for the button - self.toolbar.add(self.button) # Add button to toolbar - self.button.show_all() # Show the button - self.checkonstart = False - #load options - if self.feeds_config.has_option("DEFAULT", "interval"): - self.interval = self.feeds_config.getint("DEFAULT", "interval") - self.update_entry.set_text(self.feeds_config.get("DEFAULT", "interval")) - else: - self.interval = 900 - self.feeds_config.set("DEFAULT", "interval", 900) - if self.feeds_config.has_option("DEFAULT", "checkonstart"): - self.checkonstart = self.feeds_config.getboolean("DEFAULT", "checkonstart") - self.checkonstart_button.set_active(self.checkonstart) - else: - self.checkonstart = False - self.feeds_config.set("DEFAULT", "checkonstart", False) - if self.checkonstart_button.get_active(): - self.timer = self.interval - 5 + def __init__(self, path, deluge_core, deluge_interface): + #set up system thingies + import gtk, gtk.glade, os, ConfigParser, feedparser + import deluge.common, deluge.dgtk, deluge.pref + from time import asctime + self.path = path + self.core = deluge_core + self.interface = deluge_interface + #set up feeds file + self.feeds_config = ConfigParser.ConfigParser() + self.feeds_file = deluge.common.CONFIG_DIR + "/feeds.conf" + if not os.path.isfile(self.feeds_file): + f = open(self.feeds_file, mode='w') + f.flush() + f.close() + self.feeds_config.read(self.feeds_file) + #set up filters file + self.filters_config = ConfigParser.ConfigParser() + self.filters_file = deluge.common.CONFIG_DIR + "/filters.conf" + if not os.path.isfile(self.filters_file): + f = open(self.filters_file, mode='w') + f.flush() + f.close() + self.filters_config.read(self.filters_file) + #set up the preferences dialog + glade = gtk.glade.XML(path + "/rss.glade") + self.dlg = glade.get_widget("dialog") + self.dlg.set_position(gtk.WIN_POS_CENTER) + self.dlg.set_icon_from_file(self.path + "/rss.png") + #set up the feeds list viewer + self.feeds_view = glade.get_widget("feeds_view") + model = gtk.ListStore(str, str, str) + self.feeds_view.set_model(model) + deluge.dgtk.add_text_column(self.feeds_view, _("Name"), 0) + deluge.dgtk.add_text_column(self.feeds_view, _("URL"), 1) + deluge.dgtk.add_text_column(self.feeds_view, _("Last Entry Date"), 2) + #set up the torrents list viewer + self.torrents_view = glade.get_widget("torrents_view") + model = gtk.ListStore(str, str, str, str) + self.torrents_view.set_model(model) + deluge.dgtk.add_text_column(self.torrents_view, _("Feed"), 0) + deluge.dgtk.add_text_column(self.torrents_view, _("Name"), 1) + deluge.dgtk.add_text_column(self.torrents_view, _("URL"), 2) + deluge.dgtk.add_text_column(self.torrents_view, _("Date"), 3) + # Setup the filters list viewer + self.filters_view = glade.get_widget("filters_view") + model = gtk.ListStore(str) + self.filters_view.set_model(model) + deluge.dgtk.add_text_column(self.filters_view, _("Name"), 0) + # set up the feed choice combobox + self.feedchoice_combo = glade.get_widget("feedchoice_combo") + model = gtk.ListStore(str) + self.feedchoice_combo.set_model(model) + cell = gtk.CellRendererText() + self.feedchoice_combo.pack_start(cell, True) + self.feedchoice_combo.add_attribute(cell, 'text', 0) + # set up the torrents feed choice combobox + self.torrents_fcc = glade.get_widget("torrents_fcc") + model = gtk.ListStore(str) + self.torrents_fcc.set_model(model) + cell = gtk.CellRendererText() + self.torrents_fcc.pack_start(cell, True) + self.torrents_fcc.add_attribute(cell, 'text', 0) + #set up the rest of the GUI elements + self.name_entry = glade.get_widget("name_entry") + self.url_entry = glade.get_widget("url_entry") + self.button_addfeed = glade.get_widget("button_addfeed") + self.button_delfeed = glade.get_widget("button_delfeed") + self.chkfeeds = glade.get_widget("chkfeeds") + self.filtername_entry = glade.get_widget("filtername_entry") + self.filterexp_entry = glade.get_widget("filterexp_entry") + self.button_delfilter = glade.get_widget("button_delfilter") + self.checkonstart_button = glade.get_widget("checkonstart_button") + self.update_entry = glade.get_widget("update_entry") + #Connect event signals + self.filters_view.connect("cursor-changed", self.filter_row_clicked) + dic = { "addfeed_clicked" : self.addfeed_clicked, + "delfeed_clicked" : self.delfeed_clicked, + "addfilter_clicked" : self.addfilter_clicked, + "delfilter_clicked" : self.delfilter_clicked, + "row_clicked" : self.row_clicked, + "feedtext_changed" : self.feedtext_changed, + "filtername_lostfocus" : self.filtername_lostfocus, + "filterexp_lostfocus" : self.filterexp_lostfocus, + "feedchoice_combo_changed" : self.feedchoice_combo_changed, + "torrents_fcc_changed" : self.torrents_fcc_changed, + "torrents_view_row_activated" : self.torrents_view_row_activated, + "chkfeeds_clicked" : self.chkfeeds_clicked, + "cancel_pressed" : self.dialog_cancel, + "ok_pressed" : self.dialog_ok } + glade.signal_autoconnect(dic) + self.feeds_view.get_selection().set_select_function(self.row_clicked) + self.timer = 0 + self.torrents_list = [] + #self.checkfeeds() + # Access the interface's toolbar + self.toolbar = self.interface.toolbar + # Make a toolbar button + icon = gtk.Image() + icon.set_from_file(self.path + "/rss.png") # Toolbar items should be 22x22 pixel images + self.button = gtk.ToolButton(icon_widget=icon, label=_("RSS")) + self.ttips = gtk.Tooltips() + self.button.set_tooltip(self.ttips, _("RSS Broadcatcher")) + self.button.connect("clicked", self.rss_clicked) # Connect the signal handler for the button + self.toolbar.add(self.button) # Add button to toolbar + self.button.show_all() # Show the button + self.checkonstart = False + #load options + if self.feeds_config.has_option("DEFAULT", "interval"): + self.interval = self.feeds_config.getint("DEFAULT", "interval") + self.update_entry.set_text(self.feeds_config.get("DEFAULT", "interval")) + else: + self.interval = 900 + self.feeds_config.set("DEFAULT", "interval", 900) + if self.feeds_config.has_option("DEFAULT", "checkonstart"): + self.checkonstart = self.feeds_config.getboolean("DEFAULT", "checkonstart") + self.checkonstart_button.set_active(self.checkonstart) + else: + self.checkonstart = False + self.feeds_config.set("DEFAULT", "checkonstart", False) + if self.checkonstart_button.get_active(): + self.timer = self.interval - 5 - def rss_clicked(self, button): - self.configure(self) - - def unload(self): - self.toolbar.remove(self.button) # Remove the button from the toolbar - f = open(self.feeds_file, "w") - self.feeds_config.write(f) - f.close() - - def feedtext_changed(self, args): - a = (self.name_entry.get_text() != "") - b = (self.url_entry.get_text() != "") - if(a and b): - self.button_addfeed.set_sensitive(1) - else: - self.button_addfeed.set_sensitive(0) + def rss_clicked(self, button): + self.configure(self) + + def unload(self): + self.toolbar.remove(self.button) # Remove the button from the toolbar + f = open(self.feeds_file, "w") + self.feeds_config.write(f) + f.close() + + def feedtext_changed(self, args): + a = (self.name_entry.get_text() != "") + b = (self.url_entry.get_text() != "") + if(a and b): + self.button_addfeed.set_sensitive(1) + else: + self.button_addfeed.set_sensitive(0) - def addfeed_clicked(self, args): - self.feeds_view.get_model().append([self.name_entry.get_text(), - self.url_entry.get_text(), ""]) - self.feedchoice_combo.append_text(self.name_entry.get_text()) - self.torrents_fcc.append_text(self.name_entry.get_text()) - self.feeds_config.add_section(self.name_entry.get_text()) - self.feeds_config.set(self.name_entry.get_text(), "url", self.url_entry.get_text()) - self.feeds_config.set(self.name_entry.get_text(), "lastchecked", "") - self.name_entry.set_text("") - self.url_entry.set_text("") + def addfeed_clicked(self, args): + self.feeds_view.get_model().append([self.name_entry.get_text(), + self.url_entry.get_text(), ""]) + self.feedchoice_combo.append_text(self.name_entry.get_text()) + self.torrents_fcc.append_text(self.name_entry.get_text()) + self.feeds_config.add_section(self.name_entry.get_text()) + self.feeds_config.set(self.name_entry.get_text(), "url", self.url_entry.get_text()) + self.feeds_config.set(self.name_entry.get_text(), "lastchecked", "") + self.name_entry.set_text("") + self.url_entry.set_text("") - def delfeed_clicked(self, args): - (model, selection) = self.feeds_view.get_selection().get_selected() - text = self.feeds_view.get_model().get_value(selection, 0) - model2 = self.feedchoice_combo.get_model() - model3 = self.torrents_fcc.get_model() - the_iter = model2.get_iter_first() - print text - while the_iter is not None: - print model2.get_value(the_iter, 0) - if (model2.get_value(the_iter, 0) == text): - remove_iter = the_iter - the_iter = model2.iter_next(the_iter) - model2.remove(remove_iter) - the_iter = model3.get_iter_first() - while the_iter is not None: - print model3.get_value(the_iter, 0) - if (model3.get_value(the_iter, 0) == text): - remove_iter = the_iter - the_iter = model3.iter_next(the_iter) - model3.remove(remove_iter) - model.remove(selection) - for filt in self.filters_config.sections(): - if self.filters_config.get(filt, "feed") == text: - self.filters_config.set(filt, "feed", "All") - self.feeds_config.remove_section(text) - self.button_delfeed.set_sensitive(0) - - def row_clicked(self, args): - self.button_delfeed.set_sensitive(1) - return True + def delfeed_clicked(self, args): + (model, selection) = self.feeds_view.get_selection().get_selected() + text = self.feeds_view.get_model().get_value(selection, 0) + model2 = self.feedchoice_combo.get_model() + model3 = self.torrents_fcc.get_model() + the_iter = model2.get_iter_first() + print text + while the_iter is not None: + print model2.get_value(the_iter, 0) + if (model2.get_value(the_iter, 0) == text): + remove_iter = the_iter + the_iter = model2.iter_next(the_iter) + model2.remove(remove_iter) + the_iter = model3.get_iter_first() + while the_iter is not None: + print model3.get_value(the_iter, 0) + if (model3.get_value(the_iter, 0) == text): + remove_iter = the_iter + the_iter = model3.iter_next(the_iter) + model3.remove(remove_iter) + model.remove(selection) + for filt in self.filters_config.sections(): + if self.filters_config.get(filt, "feed") == text: + self.filters_config.set(filt, "feed", "All") + self.feeds_config.remove_section(text) + self.button_delfeed.set_sensitive(0) + + def row_clicked(self, args): + self.button_delfeed.set_sensitive(1) + return True - def addfilter_clicked(self, args): - unique = True - for filt in self.filters_config.sections(): - if filt == _("New Filter"): - unique = False + def addfilter_clicked(self, args): + unique = True + for filt in self.filters_config.sections(): + if filt == _("New Filter"): + unique = False - if unique: - self.current_filter = _("New Filter") - self.filters_config.add_section(_("New Filter")) - new_iter = self.filters_view.get_model().append([_("New Filter")]) - self.filters_view.get_selection().select_iter(new_iter) - self.filters_config.set(_("New Filter"), "filterexp", "") - self.filters_config.set(_("New Filter"), "feed", "All") - self.filtername_entry.set_text(_("New Filter")) - self.feedchoice_combo.set_active(0) + if unique: + self.current_filter = _("New Filter") + self.filters_config.add_section(_("New Filter")) + new_iter = self.filters_view.get_model().append([_("New Filter")]) + self.filters_view.get_selection().select_iter(new_iter) + self.filters_config.set(_("New Filter"), "filterexp", "") + self.filters_config.set(_("New Filter"), "feed", "All") + self.filtername_entry.set_text(_("New Filter")) + self.feedchoice_combo.set_active(0) - self.filtername_entry.set_sensitive(1) - self.filterexp_entry.set_sensitive(1) - self.feedchoice_combo.set_sensitive(1) - self.filterexp_entry.set_text("") - self.filtername_entry.grab_focus() - self.button_delfilter.set_sensitive(1) + self.filtername_entry.set_sensitive(1) + self.filterexp_entry.set_sensitive(1) + self.feedchoice_combo.set_sensitive(1) + self.filterexp_entry.set_text("") + self.filtername_entry.grab_focus() + self.button_delfilter.set_sensitive(1) - def delfilter_clicked(self, args): - model, selection = self.filters_view.get_selection().get_selected() - self.filters_config.remove_section(self.current_filter) - model.remove(selection) - self.current_filter = None + def delfilter_clicked(self, args): + model, selection = self.filters_view.get_selection().get_selected() + self.filters_config.remove_section(self.current_filter) + model.remove(selection) + self.current_filter = None - self.filtername_entry.set_text("") - self.filterexp_entry.set_text("") - self.feedchoice_combo.set_active(-1) - self.filtername_entry.set_sensitive(0) - self.filterexp_entry.set_sensitive(0) - self.feedchoice_combo.set_sensitive(0) - self.button_delfilter.set_sensitive(0) + self.filtername_entry.set_text("") + self.filterexp_entry.set_text("") + self.feedchoice_combo.set_active(-1) + self.filtername_entry.set_sensitive(0) + self.filterexp_entry.set_sensitive(0) + self.feedchoice_combo.set_sensitive(0) + self.button_delfilter.set_sensitive(0) - def filter_row_clicked(self, widget): - selection = self.filters_view.get_selection() - model, selection_iter = selection.get_selected() - print model - print selection_iter - self.current_filter = self.filters_view.get_model().get_value(selection_iter, 0) - self.filtername_entry.set_text(self.current_filter) - self.filterexp_entry.set_text(self.filters_config.get(self.current_filter, "filterexp")) - feed = self.filters_config.get(self.current_filter, "feed") - model2 = self.feedchoice_combo.get_model() - the_iter = model2.get_iter_first() - while the_iter is not None: - #print model2.get_value(the_iter, 0) - if (model2.get_value(the_iter, 0) == feed): - set_iter = the_iter - the_iter = model2.iter_next(the_iter) - self.feedchoice_combo.set_active_iter(set_iter) + def filter_row_clicked(self, widget): + selection = self.filters_view.get_selection() + model, selection_iter = selection.get_selected() + print model + print selection_iter + self.current_filter = self.filters_view.get_model().get_value(selection_iter, 0) + self.filtername_entry.set_text(self.current_filter) + self.filterexp_entry.set_text(self.filters_config.get(self.current_filter, "filterexp")) + feed = self.filters_config.get(self.current_filter, "feed") + model2 = self.feedchoice_combo.get_model() + the_iter = model2.get_iter_first() + while the_iter is not None: + #print model2.get_value(the_iter, 0) + if (model2.get_value(the_iter, 0) == feed): + set_iter = the_iter + the_iter = model2.iter_next(the_iter) + self.feedchoice_combo.set_active_iter(set_iter) - self.filtername_entry.set_sensitive(1) - self.filterexp_entry.set_sensitive(1) - self.feedchoice_combo.set_sensitive(1) - self.button_delfilter.set_sensitive(1) + self.filtername_entry.set_sensitive(1) + self.filterexp_entry.set_sensitive(1) + self.feedchoice_combo.set_sensitive(1) + self.button_delfilter.set_sensitive(1) - def filtername_lostfocus(self, args, spare): - (model, selection) = self.filters_view.get_selection().get_selected() - old_filtername = self.filters_view.get_model().get_value(selection, 0) - self.filters_config.remove_section(old_filtername) - model.remove(selection) + def filtername_lostfocus(self, args, spare): + (model, selection) = self.filters_view.get_selection().get_selected() + old_filtername = self.filters_view.get_model().get_value(selection, 0) + self.filters_config.remove_section(old_filtername) + model.remove(selection) - self.current_filter = self.filtername_entry.get_text() - new_iter = self.filters_view.get_model().append([self.current_filter]) - self.filters_view.get_selection().select_iter(new_iter) - self.filters_config.add_section(self.current_filter) - self.filters_config.set(self.current_filter, "filterexp", self.filterexp_entry.get_text()) - self.filters_config.set(self.current_filter, "feed", self.feedchoice_combo.get_active_text()) + self.current_filter = self.filtername_entry.get_text() + new_iter = self.filters_view.get_model().append([self.current_filter]) + self.filters_view.get_selection().select_iter(new_iter) + self.filters_config.add_section(self.current_filter) + self.filters_config.set(self.current_filter, "filterexp", self.filterexp_entry.get_text()) + self.filters_config.set(self.current_filter, "feed", self.feedchoice_combo.get_active_text()) - def filterexp_lostfocus(self, args, spare): - self.filters_config.set(self.current_filter, "filterexp", self.filterexp_entry.get_text()) + def filterexp_lostfocus(self, args, spare): + self.filters_config.set(self.current_filter, "filterexp", self.filterexp_entry.get_text()) - def feedchoice_combo_changed(self, args): - self.filters_config.set(self.current_filter, "feed", self.feedchoice_combo.get_active_text()) + def feedchoice_combo_changed(self, args): + self.filters_config.set(self.current_filter, "feed", self.feedchoice_combo.get_active_text()) - def torrents_fcc_changed(self, args): - model = self.torrents_view.get_model() - model.clear() - if self.torrents_fcc.get_active_text() == _("All"): - for (date, feed, title, link) in self.torrents_list: - self.torrents_view.get_model().append((feed, title, link, date)) - else: - for (date, feed, title, link) in self.torrents_list: - if feed == self.torrents_fcc.get_active_text(): - self.torrents_view.get_model().append((feed, title, link, date)) + def torrents_fcc_changed(self, args): + model = self.torrents_view.get_model() + model.clear() + if self.torrents_fcc.get_active_text() == _("All"): + for (date, feed, title, link) in self.torrents_list: + self.torrents_view.get_model().append((feed, title, link, date)) + else: + for (date, feed, title, link) in self.torrents_list: + if feed == self.torrents_fcc.get_active_text(): + self.torrents_view.get_model().append((feed, title, link, date)) - def torrents_view_row_activated(self, widget, spare1, spare2): - selection = widget.get_selection() - model, selection_iter = selection.get_selected() - self.interface.interactive_add_torrent_url(widget.get_model().get_value(selection_iter, 2)) - + def torrents_view_row_activated(self, widget, spare1, spare2): + selection = widget.get_selection() + model, selection_iter = selection.get_selected() + self.interface.interactive_add_torrent_url(widget.get_model().get_value(selection_iter, 2)) + - def chkfeeds_clicked(self, args): - self.checkfeeds() + def chkfeeds_clicked(self, args): + self.checkfeeds() - def checkfeeds(self): - import feedparser, datetime - from time import asctime, strptime + def checkfeeds(self): + import feedparser, datetime + from time import asctime, strptime - avail = {} - sorted = {} - self.torrents_list = [] - for name in self.feeds_config.sections(): - print "Attempting to parse " + name - tmp = feedparser.parse(self.feeds_config.get(name, "url")) - try: - print "Parsed " + tmp['feed']['title'] - avail[name] = True - except: - print "Failed to download/parse " + name - avail[name] = False - if avail[name]: - entries = [] - entries.extend( tmp[ "items" ] ) - decorated = [(entry["date_parsed"], entry) for entry in entries] - tmplist = [(entry["date_parsed"], name, entry["title"], entry.enclosures[0].href) for entry in entries] - decorated.sort() - self.torrents_list.extend(tmplist) - #decorated.reverse() # for most recent entries first - sorted[name] = [entry for (date,entry) in decorated] + avail = {} + sorted = {} + self.torrents_list = [] + for name in self.feeds_config.sections(): + print "Attempting to parse " + name + tmp = feedparser.parse(self.feeds_config.get(name, "url")) + try: + print "Parsed " + tmp['feed']['title'] + avail[name] = True + except: + print "Failed to download/parse " + name + avail[name] = False + if avail[name]: + entries = [] + entries.extend( tmp[ "items" ] ) + decorated = [(entry["date_parsed"], entry) for entry in entries] + tmplist = [(entry["date_parsed"], name, entry["title"], entry.enclosures[0].href) for entry in entries] + decorated.sort() + self.torrents_list.extend(tmplist) + #decorated.reverse() # for most recent entries first + sorted[name] = [entry for (date,entry) in decorated] - model = self.torrents_view.get_model() - model.clear() - self.torrents_list.sort() - self.torrents_list.reverse() - #self.torrents_view.get_model().append([entry for entry in self.torrents_list]) - for (date,feed,title,link) in self.torrents_list: - self.torrents_view.get_model().append((feed, title, link, date)) - #for key in sorted.keys(): - # print "listing entries in " + key - # - # for entry in sorted[key]: - # print entry.title - # for enclosure in entry.enclosures: - # self.torrents_view.get_model().append( (key, entry.title, enclosure.href, entry.date_parsed) ) + model = self.torrents_view.get_model() + model.clear() + self.torrents_list.sort() + self.torrents_list.reverse() + #self.torrents_view.get_model().append([entry for entry in self.torrents_list]) + for (date,feed,title,link) in self.torrents_list: + self.torrents_view.get_model().append((feed, title, link, date)) + #for key in sorted.keys(): + # print "listing entries in " + key + # + # for entry in sorted[key]: + # print entry.title + # for enclosure in entry.enclosures: + # self.torrents_view.get_model().append( (key, entry.title, enclosure.href, entry.date_parsed) ) - checked = {} - for name in self.filters_config.sections(): - checkfiltername = name - checkfilterexp = self.filters_config.get(name, "filterexp") - checkfilterfeed = self.filters_config.get(name, "feed") - print "filter: " + checkfiltername - print "search: " + checkfilterexp - print "feed: " + checkfilterfeed - if checkfilterfeed == "All": - #print "made it to 'All'" - for feedname in sorted.keys(): - if avail[feedname]: - print feedname + " last checked: " + self.feeds_config.get(feedname, "lastchecked") - if self.feeds_config.get(feedname, "lastchecked") != "": - lastchecked = strptime(self.feeds_config.get(feedname, "lastchecked")) - else: - lastchecked = strptime(asctime(sorted[feedname][0].date_parsed)) - #print "searching feed: " + feedname - for entry in sorted[feedname]: - #print entry.title + ": " + asctime(entry.date_parsed) - if (strptime(asctime(entry.date_parsed)) > lastchecked): - #print entry.date_parsed - #print " > " - #print lastchecked - if entry.title.find(checkfilterexp) != -1: - #print "contains" + checkfilterexp - for enclosure in entry.enclosures: - print enclosure.href - self.interface.interactive_add_torrent_url(enclosure.href) - #self.feeds_config.set(feedname, "lastchecked", asctime(entry.date_parsed)) - else: - if avail[checkfilterfeed]: - print "searching feed: " + checkfilterfeed - if self.feeds_config.get(checkfilterfeed, "lastchecked") != "": - lastchecked = strptime(self.feeds_config.get(checkfilterfeed, "lastchecked")) - else: - #print sorted[checkfilterfeed][1].date_parsed - lastchecked = strptime(asctime(sorted[checkfilterfeed][0].date_parsed)) - print "lastchecked: " + asctime(lastchecked) - for entry in sorted[checkfilterfeed]: - #print entry.title + ": " + asctime(entry.date_parsed) - if (strptime(asctime(entry.date_parsed)) > lastchecked): - #print entry.date_parsed - #print " > " - #print lastchecked - if (entry.title.find(checkfilterexp) != -1): - #print "contains" + checkfilterexp - for enclosure in entry.enclosures: - print enclosure.href - self.interface.interactive_add_torrent_url(enclosure.href) - #self.feeds_config.set(checkfilterfeed, "lastchecked", asctime(entry.date_parsed)) + checked = {} + for name in self.filters_config.sections(): + checkfiltername = name + checkfilterexp = self.filters_config.get(name, "filterexp") + checkfilterfeed = self.filters_config.get(name, "feed") + print "filter: " + checkfiltername + print "search: " + checkfilterexp + print "feed: " + checkfilterfeed + if checkfilterfeed == "All": + #print "made it to 'All'" + for feedname in sorted.keys(): + if avail[feedname]: + print feedname + " last checked: " + self.feeds_config.get(feedname, "lastchecked") + if self.feeds_config.get(feedname, "lastchecked") != "": + lastchecked = strptime(self.feeds_config.get(feedname, "lastchecked")) + else: + lastchecked = strptime(asctime(sorted[feedname][0].date_parsed)) + #print "searching feed: " + feedname + for entry in sorted[feedname]: + #print entry.title + ": " + asctime(entry.date_parsed) + if (strptime(asctime(entry.date_parsed)) > lastchecked): + #print entry.date_parsed + #print " > " + #print lastchecked + if entry.title.find(checkfilterexp) != -1: + #print "contains" + checkfilterexp + for enclosure in entry.enclosures: + print enclosure.href + self.interface.interactive_add_torrent_url(enclosure.href) + #self.feeds_config.set(feedname, "lastchecked", asctime(entry.date_parsed)) + else: + if avail[checkfilterfeed]: + print "searching feed: " + checkfilterfeed + if self.feeds_config.get(checkfilterfeed, "lastchecked") != "": + lastchecked = strptime(self.feeds_config.get(checkfilterfeed, "lastchecked")) + else: + #print sorted[checkfilterfeed][1].date_parsed + lastchecked = strptime(asctime(sorted[checkfilterfeed][0].date_parsed)) + print "lastchecked: " + asctime(lastchecked) + for entry in sorted[checkfilterfeed]: + #print entry.title + ": " + asctime(entry.date_parsed) + if (strptime(asctime(entry.date_parsed)) > lastchecked): + #print entry.date_parsed + #print " > " + #print lastchecked + if (entry.title.find(checkfilterexp) != -1): + #print "contains" + checkfilterexp + for enclosure in entry.enclosures: + print enclosure.href + self.interface.interactive_add_torrent_url(enclosure.href) + #self.feeds_config.set(checkfilterfeed, "lastchecked", asctime(entry.date_parsed)) - for name in avail.keys(): - if avail[name]: - self.feeds_config.set(name, "lastchecked", asctime(sorted[name][len(sorted[name])-1].date_parsed)) + for name in avail.keys(): + if avail[name]: + self.feeds_config.set(name, "lastchecked", asctime(sorted[name][len(sorted[name])-1].date_parsed)) - self.timer = 0 + self.timer = 0 - def configure(self, widget=None): - import gtk, gtk.glade - from deluge import common - self.dlg.show_all() - model = self.feeds_view.get_model() - model.clear() - model2 = self.feedchoice_combo.get_model() - model2.clear() - model3 = self.filters_view.get_model() - model3.clear() - model4 = self.torrents_fcc.get_model() - model4.clear() - self.filtername_entry.set_text("") - self.filterexp_entry.set_text("") - self.name_entry.set_text("") - self.url_entry.set_text("") - self.feedchoice_combo.append_text(_("All")) - self.torrents_fcc.append_text(_("All")) - self.torrents_fcc.set_active(0) - for name in self.feeds_config.sections(): - self.feeds_view.get_model().append( (name, self.feeds_config.get(name, "url"), self.feeds_config.get(name, "lastchecked") ) ) - self.feedchoice_combo.append_text(name) - self.torrents_fcc.append_text(name) - for filters in self.filters_config.sections(): - self.filters_view.get_model().append( ([filters]) ) - #self.checkfeeds() - self.button_addfeed.set_sensitive(0) - self.button_delfeed.set_sensitive(0) - self.filtername_entry.set_sensitive(0) - self.filterexp_entry.set_sensitive(0) - self.feedchoice_combo.set_sensitive(0) - self.button_delfilter.set_sensitive(0) - self.update_entry.set_text(str(self.interval)) - self.checkonstart_button.set_active(self.checkonstart) - result = self.dlg.run() - self.dlg.hide_all() - if result == 1: - self.interval = int(self.update_entry.get_text()) - self.feeds_config.set("DEFAULT", "interval", self.update_entry.get_text()) - self.feeds_config.set("DEFAULT", "checkonstart", self.checkonstart_button.get_active()) - f = open(self.filters_file, "w") - self.filters_config.write(f) - f.close() - f = open(self.feeds_file, "w") - self.feeds_config.write(f) - f.close() - + def configure(self, widget=None): + import gtk, gtk.glade + from deluge import common + self.dlg.show_all() + model = self.feeds_view.get_model() + model.clear() + model2 = self.feedchoice_combo.get_model() + model2.clear() + model3 = self.filters_view.get_model() + model3.clear() + model4 = self.torrents_fcc.get_model() + model4.clear() + self.filtername_entry.set_text("") + self.filterexp_entry.set_text("") + self.name_entry.set_text("") + self.url_entry.set_text("") + self.feedchoice_combo.append_text(_("All")) + self.torrents_fcc.append_text(_("All")) + self.torrents_fcc.set_active(0) + for name in self.feeds_config.sections(): + self.feeds_view.get_model().append( (name, self.feeds_config.get(name, "url"), self.feeds_config.get(name, "lastchecked") ) ) + self.feedchoice_combo.append_text(name) + self.torrents_fcc.append_text(name) + for filters in self.filters_config.sections(): + self.filters_view.get_model().append( ([filters]) ) + #self.checkfeeds() + self.button_addfeed.set_sensitive(0) + self.button_delfeed.set_sensitive(0) + self.filtername_entry.set_sensitive(0) + self.filterexp_entry.set_sensitive(0) + self.feedchoice_combo.set_sensitive(0) + self.button_delfilter.set_sensitive(0) + self.update_entry.set_text(str(self.interval)) + self.checkonstart_button.set_active(self.checkonstart) - def update(self): - self.timer += 1 - if self.timer >= self.interval: - print "BONG!" - self.checkfeeds() - self.timer = 0 + def dialog_ok(self, source): + self.dlg.hide_all() + self.interval = int(self.update_entry.get_text()) + self.feeds_config.set("DEFAULT", "interval", self.update_entry.get_text()) + self.feeds_config.set("DEFAULT", "checkonstart", self.checkonstart_button.get_active()) + f = open(self.filters_file, "w") + self.filters_config.write(f) + f.close() + f = open(self.feeds_file, "w") + self.feeds_config.write(f) + f.close() + + def dialog_cancel(self, source): + self.dlg.hide_all() + + def update(self): + self.timer += 1 + if self.timer >= self.interval: + import threading + + print "BONG!" + threading.Thread(target=self.checkfeeds).start + self.timer = 0 diff --git a/plugins/RSS/rss.glade b/plugins/RSS/rss.glade index 45bc939a1..49cdfc03c 100644 --- a/plugins/RSS/rss.glade +++ b/plugins/RSS/rss.glade @@ -1,12 +1,13 @@ - + 5 RSS Broadcatcher Settings 512 384 + GDK_WINDOW_TYPE_HINT_NORMAL False @@ -857,6 +858,7 @@ gtk-cancel True 0 + @@ -865,6 +867,7 @@ gtk-ok True 1 + 1 diff --git a/plugins/TorrentNotification/__init__.py b/plugins/TorrentNotification/__init__.py index e7cdc590d..68ee00597 100644 --- a/plugins/TorrentNotification/__init__.py +++ b/plugins/TorrentNotification/__init__.py @@ -55,8 +55,11 @@ class TorrentNotification: self.glade = gtk.glade.XML(path + "/notification_preferences.glade") self.dialog = self.glade.get_widget("dialog") + self.dialog.set_position(gtk.WIN_POS_CENTER) self.glade.signal_autoconnect({ - 'toggle_ui': self.toggle_ui + 'toggle_ui': self.toggle_ui, + 'dialog_ok': self.dialog_ok, + 'dialog_cancel': self.dialog_cancel }) def handle_event(self, event): @@ -111,13 +114,16 @@ class TorrentNotification: self.glade.get_widget("sound_path_button").set_filename(os.path.expanduser("~/")) self.glade.get_widget("sound_path_button").set_sensitive(False) self.dialog.show() - response = self.dialog.run() + + def dialog_ok(self, source): + self.dialog.hide() + self.config.set("enable_tray_blink", self.glade.get_widget("chk_tray_blink").get_active()) + self.config.set("enable_notification", self.glade.get_widget("chk_notification").get_active()) + self.config.set("enable_sound", self.glade.get_widget("chk_sound").get_active()) + self.config.set("sound_path", self.glade.get_widget("sound_path_button").get_filename()) + + def dialog_cancel(self, source): self.dialog.hide() - if response: - self.config.set("enable_tray_blink", self.glade.get_widget("chk_tray_blink").get_active()) - self.config.set("enable_notification", self.glade.get_widget("chk_notification").get_active()) - self.config.set("enable_sound", self.glade.get_widget("chk_sound").get_active()) - self.config.set("sound_path", self.glade.get_widget("sound_path_button").get_filename()) def toggle_ui(self, widget): value = widget.get_active() diff --git a/plugins/TorrentNotification/notification_preferences.glade b/plugins/TorrentNotification/notification_preferences.glade index 1b97cd6f4..7e9070282 100644 --- a/plugins/TorrentNotification/notification_preferences.glade +++ b/plugins/TorrentNotification/notification_preferences.glade @@ -7,6 +7,7 @@ Torrent Notification Preferences 400 150 + GDK_WINDOW_TYPE_HINT_NORMAL False @@ -33,8 +34,6 @@ True False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - GTK_FILE_CHOOSER_ACTION_SELECT_FILE - Select A File 1 @@ -42,24 +41,15 @@ - False False + False + 1 True 2 - - - True - True - Enable blinking tray icon - True - 0 - True - - True @@ -74,10 +64,21 @@ 2 + + + True + True + Enable blinking tray icon + True + 0 + True + + - False False + False + 2 @@ -91,6 +92,7 @@ gtk-cancel True 0 + @@ -99,6 +101,7 @@ gtk-ok True 1 + 1 @@ -114,4 +117,3 @@ - diff --git a/src/dialogs.py b/src/dialogs.py index 756e068b6..a7fdac8b8 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -43,6 +43,7 @@ class PreferencesDlg: def __init__(self, preferences, active_port): self.glade = gtk.glade.XML(common.get_glade_file("preferences_dialog.glade"), domain='deluge') self.dialog = self.glade.get_widget("pref_dialog") + self.dialog.set_position(gtk.WIN_POS_CENTER) self.dialog.set_icon_from_file(common.get_pixmap("deluge32.png")) self.glade.signal_autoconnect({ 'toggle_ui': self.toggle_ui, @@ -52,7 +53,7 @@ class PreferencesDlg: self.preferences = preferences self.active_port = str(active_port) - def show(self): + def show(self, interface): # Load settings into dialog try: self.glade.get_widget("combo_encin").set_active(self.preferences.get("encin_state")) @@ -138,74 +139,80 @@ class PreferencesDlg: else: self.glade.get_widget('spin_port_min').set_sensitive(True) self.glade.get_widget('spin_port_max').set_sensitive(True) + + self.glade.get_widget("ok_button").connect("pressed", self.ok_pressed, interface) + self.glade.get_widget("cancel_button").connect("pressed", self.cancel_pressed) except KeyError: pass # Now, show the dialog self.dialog.show() - r = self.dialog.run() - self.dialog.hide() - # Now, get the settings from the dialog - if r == 1: - self.preferences.set("encin_state", self.glade.get_widget("combo_encin").get_active()) - self.preferences.set("encout_state", self.glade.get_widget("combo_encout").get_active()) - self.preferences.set("enclevel_type", self.glade.get_widget("combo_enclevel").get_active()) - self.preferences.set("peer_proxy_type", self.glade.get_widget("combo_peer_proxy_type").get_active()) - self.preferences.set("pref_rc4", self.glade.get_widget("chk_pref_rc4").get_active()) - self.preferences.set("peer_proxy", self.glade.get_widget("chk_peer_proxy").get_active()) - self.preferences.set("tracker_proxy", self.glade.get_widget("chk_tracker_proxy").get_active()) - self.preferences.set("dht_proxy", self.glade.get_widget("chk_dht_proxy").get_active()) - self.preferences.set("web_proxy", self.glade.get_widget("chk_web_proxy").get_active()) - self.preferences.set("use_upnp", self.glade.get_widget("chk_upnp").get_active()) - self.preferences.set("tracker_proxy_type", self.glade.get_widget("combo_tracker_proxy_type").get_active()) - self.preferences.set("dht_proxy_type", self.glade.get_widget("combo_dht_proxy_type").get_active()) - self.preferences.set("web_proxy_type", self.glade.get_widget("combo_web_proxy_type").get_active()) - self.preferences.set("new_releases", self.glade.get_widget("chk_new_releases").get_active()) - self.preferences.set("random_port", self.glade.get_widget("chk_random_port").get_active()) - self.preferences.set("use_natpmp", self.glade.get_widget("chk_natpmp").get_active()) - self.preferences.set("use_utpex", self.glade.get_widget("chk_utpex").get_active()) - self.preferences.set("enable_system_tray", self.glade.get_widget("chk_use_tray").get_active()) - self.preferences.set("close_to_tray", self.glade.get_widget("chk_min_on_close").get_active()) - self.preferences.set("lock_tray", self.glade.get_widget("chk_lock_tray").get_active()) - self.preferences.set("tray_passwd", self.glade.get_widget("txt_tray_passwd").get_text()) - self.preferences.set("tracker_proxy_username", self.glade.get_widget("txt_tracker_proxy_username").get_text()) - self.preferences.set("tracker_proxy_password", self.glade.get_widget("txt_tracker_proxy_password").get_text()) - self.preferences.set("tracker_proxy_hostname", self.glade.get_widget("txt_tracker_proxy_hostname").get_text()) - self.preferences.set("web_proxy_username", self.glade.get_widget("txt_web_proxy_username").get_text()) - self.preferences.set("web_proxy_password", self.glade.get_widget("txt_web_proxy_password").get_text()) - self.preferences.set("web_proxy_hostname", self.glade.get_widget("txt_web_proxy_hostname").get_text()) - self.preferences.set("dht_proxy_username", self.glade.get_widget("txt_dht_proxy_username").get_text()) - self.preferences.set("dht_proxy_password", self.glade.get_widget("txt_dht_proxy_password").get_text()) - self.preferences.set("dht_proxy_hostname", self.glade.get_widget("txt_dht_proxy_hostname").get_text()) - self.preferences.set("peer_proxy_username", self.glade.get_widget("txt_peer_proxy_username").get_text()) - self.preferences.set("peer_proxy_password", self.glade.get_widget("txt_peer_proxy_password").get_text()) - self.preferences.set("peer_proxy_hostname", self.glade.get_widget("txt_peer_proxy_hostname").get_text()) - self.preferences.set("use_default_dir", self.glade.get_widget("radio_save_all_to").get_active()) - self.preferences.set("default_download_path", self.glade.get_widget("download_path_button").get_filename()) - self.preferences.set("enable_move_completed", self.glade.get_widget("chk_move_completed").get_active()) - self.preferences.set("default_finished_path", self.glade.get_widget("finished_path_button").get_filename()) - self.preferences.set("enable_files_dialog", self.glade.get_widget("chk_enable_files_dialog").get_active()) - self.preferences.set("prioritize_first_last_pieces", self.glade.get_widget("chk_prioritize_first_last_pieces").get_active()) - self.preferences.set("auto_end_seeding", self.glade.get_widget("chk_autoseed").get_active()) - self.preferences.set("auto_seed_ratio", self.glade.get_widget("ratio_spinner").get_value()) - self.preferences.set("use_compact_storage", self.glade.get_widget("chk_compact").get_active()) - self.preferences.set("listen_on", [self.glade.get_widget("spin_port_min").get_value(), self.glade.get_widget("spin_port_max").get_value()]) - self.preferences.set("max_upload_speed", self.glade.get_widget("spin_max_upload").get_value()) - self.preferences.set("max_number_uploads", int(self.glade.get_widget("spin_num_upload").get_value())) - self.preferences.set("max_download_speed", self.glade.get_widget("spin_max_download").get_value()) - self.preferences.set("peer_proxy_port", self.glade.get_widget("spin_peer_proxy_port").get_value()) - self.preferences.set("dht_proxy_port", self.glade.get_widget("spin_dht_proxy_port").get_value()) - self.preferences.set("web_proxy_port", self.glade.get_widget("spin_web_proxy_port").get_value()) - self.preferences.set("tracker_proxy_port", self.glade.get_widget("spin_tracker_proxy_port").get_value()) - self.preferences.set("max_connections", int(self.glade.get_widget("spin_max_connections").get_value())) - self.preferences.set("max_active_torrents", int(self.glade.get_widget("spin_torrents").get_value())) - self.preferences.set("queue_seeds_to_bottom", self.glade.get_widget("chk_seedbottom").get_active()) - self.preferences.set("enable_dht", self.glade.get_widget("chk_dht").get_active()) - self.preferences.set("gui_update_interval", self.glade.get_widget("spin_gui").get_value()) - self.preferences.set("clear_max_ratio_torrents", self.glade.get_widget("chk_clear_max_ratio_torrents").get_active()) - self.preferences.set("queue_above_completed", self.glade.get_widget("chk_queue_above_completed").get_active()) - return r + def ok_pressed(self, source, interface): + self.dialog.hide() + self.preferences.set("encin_state", self.glade.get_widget("combo_encin").get_active()) + self.preferences.set("encout_state", self.glade.get_widget("combo_encout").get_active()) + self.preferences.set("enclevel_type", self.glade.get_widget("combo_enclevel").get_active()) + self.preferences.set("peer_proxy_type", self.glade.get_widget("combo_peer_proxy_type").get_active()) + self.preferences.set("pref_rc4", self.glade.get_widget("chk_pref_rc4").get_active()) + self.preferences.set("peer_proxy", self.glade.get_widget("chk_peer_proxy").get_active()) + self.preferences.set("tracker_proxy", self.glade.get_widget("chk_tracker_proxy").get_active()) + self.preferences.set("dht_proxy", self.glade.get_widget("chk_dht_proxy").get_active()) + self.preferences.set("web_proxy", self.glade.get_widget("chk_web_proxy").get_active()) + self.preferences.set("use_upnp", self.glade.get_widget("chk_upnp").get_active()) + self.preferences.set("tracker_proxy_type", self.glade.get_widget("combo_tracker_proxy_type").get_active()) + self.preferences.set("dht_proxy_type", self.glade.get_widget("combo_dht_proxy_type").get_active()) + self.preferences.set("web_proxy_type", self.glade.get_widget("combo_web_proxy_type").get_active()) + self.preferences.set("new_releases", self.glade.get_widget("chk_new_releases").get_active()) + self.preferences.set("random_port", self.glade.get_widget("chk_random_port").get_active()) + self.preferences.set("use_natpmp", self.glade.get_widget("chk_natpmp").get_active()) + self.preferences.set("use_utpex", self.glade.get_widget("chk_utpex").get_active()) + self.preferences.set("enable_system_tray", self.glade.get_widget("chk_use_tray").get_active()) + self.preferences.set("close_to_tray", self.glade.get_widget("chk_min_on_close").get_active()) + self.preferences.set("lock_tray", self.glade.get_widget("chk_lock_tray").get_active()) + self.preferences.set("tray_passwd", self.glade.get_widget("txt_tray_passwd").get_text()) + self.preferences.set("tracker_proxy_username", self.glade.get_widget("txt_tracker_proxy_username").get_text()) + self.preferences.set("tracker_proxy_password", self.glade.get_widget("txt_tracker_proxy_password").get_text()) + self.preferences.set("tracker_proxy_hostname", self.glade.get_widget("txt_tracker_proxy_hostname").get_text()) + self.preferences.set("web_proxy_username", self.glade.get_widget("txt_web_proxy_username").get_text()) + self.preferences.set("web_proxy_password", self.glade.get_widget("txt_web_proxy_password").get_text()) + self.preferences.set("web_proxy_hostname", self.glade.get_widget("txt_web_proxy_hostname").get_text()) + self.preferences.set("dht_proxy_username", self.glade.get_widget("txt_dht_proxy_username").get_text()) + self.preferences.set("dht_proxy_password", self.glade.get_widget("txt_dht_proxy_password").get_text()) + self.preferences.set("dht_proxy_hostname", self.glade.get_widget("txt_dht_proxy_hostname").get_text()) + self.preferences.set("peer_proxy_username", self.glade.get_widget("txt_peer_proxy_username").get_text()) + self.preferences.set("peer_proxy_password", self.glade.get_widget("txt_peer_proxy_password").get_text()) + self.preferences.set("peer_proxy_hostname", self.glade.get_widget("txt_peer_proxy_hostname").get_text()) + self.preferences.set("use_default_dir", self.glade.get_widget("radio_save_all_to").get_active()) + self.preferences.set("default_download_path", self.glade.get_widget("download_path_button").get_filename()) + self.preferences.set("enable_move_completed", self.glade.get_widget("chk_move_completed").get_active()) + self.preferences.set("default_finished_path", self.glade.get_widget("finished_path_button").get_filename()) + self.preferences.set("enable_files_dialog", self.glade.get_widget("chk_enable_files_dialog").get_active()) + self.preferences.set("prioritize_first_last_pieces", self.glade.get_widget("chk_prioritize_first_last_pieces").get_active()) + self.preferences.set("auto_end_seeding", self.glade.get_widget("chk_autoseed").get_active()) + self.preferences.set("auto_seed_ratio", self.glade.get_widget("ratio_spinner").get_value()) + self.preferences.set("use_compact_storage", self.glade.get_widget("chk_compact").get_active()) + self.preferences.set("listen_on", [self.glade.get_widget("spin_port_min").get_value(), self.glade.get_widget("spin_port_max").get_value()]) + self.preferences.set("max_upload_speed", self.glade.get_widget("spin_max_upload").get_value()) + self.preferences.set("max_number_uploads", int(self.glade.get_widget("spin_num_upload").get_value())) + self.preferences.set("max_download_speed", self.glade.get_widget("spin_max_download").get_value()) + self.preferences.set("peer_proxy_port", self.glade.get_widget("spin_peer_proxy_port").get_value()) + self.preferences.set("dht_proxy_port", self.glade.get_widget("spin_dht_proxy_port").get_value()) + self.preferences.set("web_proxy_port", self.glade.get_widget("spin_web_proxy_port").get_value()) + self.preferences.set("tracker_proxy_port", self.glade.get_widget("spin_tracker_proxy_port").get_value()) + self.preferences.set("max_connections", int(self.glade.get_widget("spin_max_connections").get_value())) + self.preferences.set("max_active_torrents", int(self.glade.get_widget("spin_torrents").get_value())) + self.preferences.set("queue_seeds_to_bottom", self.glade.get_widget("chk_seedbottom").get_active()) + self.preferences.set("enable_dht", self.glade.get_widget("chk_dht").get_active()) + self.preferences.set("gui_update_interval", self.glade.get_widget("spin_gui").get_value()) + self.preferences.set("clear_max_ratio_torrents", self.glade.get_widget("chk_clear_max_ratio_torrents").get_active()) + self.preferences.set("queue_above_completed", self.glade.get_widget("chk_queue_above_completed").get_active()) + + interface.apply_prefs() + interface.config.save() + + def cancel_pressed(self, source): + self.dialog.hide() def TestPort(self, widget): common.open_url_in_browser('http://www.deluge-torrent.org/test-port.php?port=%s' % self.active_port) @@ -268,6 +275,7 @@ class MergeDlg: self.glade = gtk.glade.XML(common.get_glade_file("merge_dialog.glade"), domain='deluge') self.dialog = self.glade.get_widget("merge_dialog") + self.dialog.set_position(gtk.WIN_POS_CENTER) self.dialog.set_icon_from_file(common.get_pixmap("deluge32.png")) def show(self): @@ -282,6 +290,7 @@ class FilesDlg: self.glade = gtk.glade.XML(common.get_glade_file("files_dialog.glade"), domain='deluge') self.dialog = self.glade.get_widget("file_dialog") + self.dialog.set_position(gtk.WIN_POS_CENTER) self.dialog.set_icon_from_file(common.get_pixmap("deluge32.png")) self.files_manager = files.FilesDialogManager( @@ -310,6 +319,7 @@ class PluginDlg: def __init__(self, plugins): self.glade = gtk.glade.XML(common.get_glade_file("plugin_dialog.glade"), domain='deluge') self.dialog = self.glade.get_widget("plugin_dialog") + self.dialog.set_position(gtk.WIN_POS_CENTER) self.dialog.set_icon_from_file(common.get_pixmap("deluge32.png")) self.view = self.glade.get_widget("plugin_view") self.store = gtk.ListStore(str, bool) @@ -322,7 +332,9 @@ class PluginDlg: name_col = dgtk.add_text_column(self.view, _("Plugin"), 0) name_col.set_expand(True) dgtk.add_toggle_column(self.view, _("Enabled"), 1, toggled_signal=self.plugin_toggled) - self.glade.signal_autoconnect({'plugin_pref': self.plugin_pref}) + signals = {'plugin_pref': self.plugin_pref, + 'on_close_pressed': self.close_pressed} + self.glade.signal_autoconnect(signals) self.plugins = plugins def show(self): @@ -336,7 +348,8 @@ class PluginDlg: self.glade.get_widget("plugin_text").get_buffer().set_text("") self.glade.get_widget("plugin_conf").set_sensitive(False) self.dialog.show() - self.dialog.run() + + def close_pressed(self, source): self.dialog.hide() def old_clicked(self, path): @@ -385,6 +398,7 @@ def show_about_dialog(parent=None): gtk.about_dialog_set_url_hook(url_hook) abt = gtk.glade.XML(common.get_glade_file("aboutdialog.glade")).get_widget("aboutdialog") + abt.set_position(gtk.WIN_POS_CENTER) abt.set_name(common.PROGRAM_NAME) abt.set_version(common.PROGRAM_VERSION) abt.set_authors(["Zach Tibbitts", "Alon Zakai", "Marcos Pinto", "Andrew Resch", "Alex Dedul"]) diff --git a/src/interface.py b/src/interface.py index 2eb3b75cd..daf7bbb6d 100644 --- a/src/interface.py +++ b/src/interface.py @@ -639,9 +639,7 @@ class DelugeGTK: active_port = self.manager.get_state()['port'] preferences_dialog = dialogs.PreferencesDlg(self.config, active_port) # Only apply the prefs if the user pressed OK in the prefs dialog - if preferences_dialog.show() == 1: - self.apply_prefs() - self.config.save() + preferences_dialog.show(self) def show_preferences_dialog_clicked(self, arg=None): if self.config.get("lock_tray") == True: diff --git a/src/update.py b/src/update.py index c0776aaa8..ffcbae70f 100644 --- a/src/update.py +++ b/src/update.py @@ -11,7 +11,7 @@ if new_release > sys.argv[1]: dialog = gtk.MessageDialog(parent = None, flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, buttons = gtk.BUTTONS_YES_NO, - message_format="There is a newer version of Deluge. Would you like to be taken to our download site?", + message_format=_("There is a newer version of Deluge. Would you like to be taken to our download site?"), type=gtk.MESSAGE_QUESTION) dialog.set_title('New Release!') import time