dialogs/windows modality fix

This commit is contained in:
Marcos Pinto 2007-08-05 20:13:24 +00:00
parent 9024c5b620
commit ef1296cc36
11 changed files with 808 additions and 768 deletions

View File

@ -9,7 +9,7 @@
<property name="default_width">583</property>
<property name="default_height">431</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="skip_taskbar_hint">True</property>
<property name="skip_pager_hint">True</property>
<child internal-child="vbox">
@ -127,6 +127,7 @@
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="pressed" handler="on_close_pressed"/>
</widget>
</child>
</widget>

View File

@ -10,7 +10,7 @@
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="default_height">550</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="skip_taskbar_hint">True</property>
<property name="skip_pager_hint">True</property>
<property name="has_separator">False</property>
@ -2289,7 +2289,7 @@ HTTP W/ Auth</property>
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button2">
<widget class="GtkButton" id="cancel_button">
<property name="visible">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
@ -2297,7 +2297,7 @@ HTTP W/ Auth</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button1">
<widget class="GtkButton" id="ok_button">
<property name="visible">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>

View File

@ -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())

View File

@ -7,6 +7,7 @@
<property name="title" translatable="yes">Event Logging Preferences</property>
<property name="default_width">400</property>
<property name="default_height">150</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
@ -18,249 +19,28 @@
<property name="visible">True</property>
<property name="n_rows">20</property>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">Select events to log</property>
</widget>
</child>
<child>
<widget class="GtkCheckButton" id="chk_finished">
<widget class="GtkCheckButton" id="chk_log_files">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Torrent finished</property>
<property name="label" translatable="yes">Enable log files</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">19</property>
<property name="bottom_attach">20</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_peer_error">
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Peer messages</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
<property name="label" translatable="yes">Log files</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_invalid_request">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Invalid request</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_file_error">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">File error</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_hash_failed_error">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Hash failed error</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_peer_ban_error">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Peer ban error</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_fastresume_rejected_error">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Fastresume rejected error</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_tracker_announce">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Tracker announce</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_tracker_reply">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Tracker reply</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_tracker_alert">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Tracker alert</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">10</property>
<property name="bottom_attach">11</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_tracker_warning">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Tracker warning</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">11</property>
<property name="bottom_attach">12</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_storage_moved">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Storage moved</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">12</property>
<property name="bottom_attach">13</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_piece_finished">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Piece finished</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">13</property>
<property name="bottom_attach">14</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_block_downloading">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Block downloading</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">14</property>
<property name="bottom_attach">15</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_block_finished">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Block finished</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">15</property>
<property name="bottom_attach">16</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_peer_blocked">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Peer blocked</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">16</property>
<property name="bottom_attach">17</property>
<property name="top_attach">18</property>
<property name="bottom_attach">19</property>
</packing>
</child>
<child>
@ -279,34 +59,256 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">Log files</property>
</widget>
<packing>
<property name="top_attach">18</property>
<property name="bottom_attach">19</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_log_files">
<widget class="GtkCheckButton" id="chk_peer_blocked">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Enable log files</property>
<property name="label" translatable="yes">Peer blocked</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">19</property>
<property name="bottom_attach">20</property>
<property name="top_attach">16</property>
<property name="bottom_attach">17</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_block_finished">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Block finished</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">15</property>
<property name="bottom_attach">16</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_block_downloading">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Block downloading</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">14</property>
<property name="bottom_attach">15</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_piece_finished">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Piece finished</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">13</property>
<property name="bottom_attach">14</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_storage_moved">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Storage moved</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">12</property>
<property name="bottom_attach">13</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_tracker_warning">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Tracker warning</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">11</property>
<property name="bottom_attach">12</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_tracker_alert">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Tracker alert</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">10</property>
<property name="bottom_attach">11</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_tracker_reply">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Tracker reply</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_tracker_announce">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Tracker announce</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_fastresume_rejected_error">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Fastresume rejected error</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_peer_ban_error">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Peer ban error</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_hash_failed_error">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Hash failed error</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_file_error">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">File error</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_invalid_request">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Invalid request</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_peer_error">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Peer messages</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_finished">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Torrent finished</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle_ui"/>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">Select events to log</property>
</widget>
</child>
</widget>
<packing>
<property name="fill">False</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
@ -320,6 +322,7 @@
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="pressed" handler="on_button_cancel_pressed"/>
</widget>
</child>
<child>
@ -328,6 +331,7 @@
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="response_id">1</property>
<signal name="pressed" handler="on_button_ok_pressed"/>
</widget>
<packing>
<property name="position">1</property>
@ -343,4 +347,3 @@
</child>
</widget>
</glade-interface>

View File

@ -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

View File

@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.2.2 on Sun Jul 15 13:48:13 2007 by markybob@peg-->
<!--Generated with glade3 3.3.3 on Sun Aug 5 10:26:04 2007 -->
<glade-interface>
<widget class="GtkDialog" id="dialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">RSS Broadcatcher Settings</property>
<property name="default_width">512</property>
<property name="default_height">384</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
@ -857,6 +858,7 @@
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="pressed" handler="cancel_pressed"/>
</widget>
</child>
<child>
@ -865,6 +867,7 @@
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="response_id">1</property>
<signal name="pressed" handler="ok_pressed"/>
</widget>
<packing>
<property name="position">1</property>

View File

@ -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()

View File

@ -7,6 +7,7 @@
<property name="title" translatable="yes">Torrent Notification Preferences</property>
<property name="default_width">400</property>
<property name="default_height">150</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
@ -33,8 +34,6 @@
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FILE</property>
<property name="title" translatable="yes">Select A File</property>
</widget>
<packing>
<property name="position">1</property>
@ -42,24 +41,15 @@
</child>
</widget>
<packing>
<property name="fill">False</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<child>
<widget class="GtkCheckButton" id="chk_tray_blink">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Enable blinking tray icon</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
</child>
<child>
<widget class="GtkCheckButton" id="chk_notification">
<property name="visible">True</property>
@ -74,10 +64,21 @@
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_tray_blink">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Enable blinking tray icon</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
</child>
</widget>
<packing>
<property name="fill">False</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
@ -91,6 +92,7 @@
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="pressed" handler="dialog_cancel"/>
</widget>
</child>
<child>
@ -99,6 +101,7 @@
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="response_id">1</property>
<signal name="pressed" handler="dialog_ok"/>
</widget>
<packing>
<property name="position">1</property>
@ -114,4 +117,3 @@
</child>
</widget>
</glade-interface>

View File

@ -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"])

View File

@ -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:

View File

@ -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