Allow adding multiple trackers at once in the edit tracker dialog
This commit is contained in:
parent
42d239c91a
commit
31a157091a
|
@ -9,3 +9,4 @@ Deluge 1.1.0 - "" (In Development)
|
||||||
* Add peer progress to the peers tab
|
* Add peer progress to the peers tab
|
||||||
* Sorting # column will place downloaders above seeds
|
* Sorting # column will place downloaders above seeds
|
||||||
* Remove dependency on libtorrent for add torrent dialog
|
* Remove dependency on libtorrent for add torrent dialog
|
||||||
|
* Allow adding multiple trackers at once in the edit tracker dialog
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# edittrackersdialog.py
|
# edittrackersdialog.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
# Copyright (C) 2007, 2008 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
|
@ -125,7 +125,7 @@ class EditTrackersDialog:
|
||||||
log.debug("on_button_add_clicked")
|
log.debug("on_button_add_clicked")
|
||||||
# Show the add tracker dialog
|
# Show the add tracker dialog
|
||||||
self.add_tracker_dialog.show()
|
self.add_tracker_dialog.show()
|
||||||
self.glade.get_widget("entry_tracker").grab_focus()
|
self.glade.get_widget("textview_trackers").grab_focus()
|
||||||
|
|
||||||
def on_button_remove_clicked(self, widget):
|
def on_button_remove_clicked(self, widget):
|
||||||
log.debug("on_button_remove_clicked")
|
log.debug("on_button_remove_clicked")
|
||||||
|
@ -185,38 +185,43 @@ class EditTrackersDialog:
|
||||||
|
|
||||||
def on_button_add_ok_clicked(self, widget):
|
def on_button_add_ok_clicked(self, widget):
|
||||||
log.debug("on_button_add_ok_clicked")
|
log.debug("on_button_add_ok_clicked")
|
||||||
from re import search as re_search
|
|
||||||
tracker = self.glade.get_widget("entry_tracker").get_text()
|
|
||||||
if not re_search("[udp|http]s?://", tracker):
|
|
||||||
# Bad url.. lets prepend http://
|
|
||||||
tracker = "http://" + tracker
|
|
||||||
|
|
||||||
|
# Create a list of trackers from the textview widget
|
||||||
|
textview = self.glade.get_widget("textview_trackers")
|
||||||
|
trackers = []
|
||||||
|
b = textview.get_buffer()
|
||||||
|
lines = b.get_text(b.get_start_iter(), b.get_end_iter()).strip().split("\n")
|
||||||
|
for l in lines:
|
||||||
|
if deluge.common.is_url(l):
|
||||||
|
trackers.append(l)
|
||||||
|
|
||||||
|
for tracker in trackers:
|
||||||
# Figure out what tier number to use.. it's going to be the highest+1
|
# Figure out what tier number to use.. it's going to be the highest+1
|
||||||
# Also check for duplicates
|
# Also check for duplicates
|
||||||
self.highest_tier = 0
|
highest_tier = 0
|
||||||
self.duplicate = False
|
duplicate = False
|
||||||
def tier_count(model, path, iter, data):
|
def tier_count(model, path, iter, data):
|
||||||
tier = model.get_value(iter, 0)
|
tier = model.get_value(iter, 0)
|
||||||
if tier > self.highest_tier:
|
if tier > data[1]:
|
||||||
self.highest_tier = tier
|
data[1] = tier
|
||||||
tracker = model.get_value(iter, 1)
|
tracker = model.get_value(iter, 1)
|
||||||
if data == tracker:
|
if data[0] == tracker:
|
||||||
# We already have this tracker in the list
|
# We already have this tracker in the list
|
||||||
self.duplicate = True
|
data[2] = True
|
||||||
|
|
||||||
# Check if there are any entries
|
# Check if there are any entries
|
||||||
if self.liststore.iter_n_children(None) > 0:
|
if self.liststore.iter_n_children(None) > 0:
|
||||||
self.liststore.foreach(tier_count, tracker)
|
self.liststore.foreach(tier_count, [tracker, highest_tier, duplicate])
|
||||||
else:
|
else:
|
||||||
self.highest_tier = -1
|
highest_tier = -1
|
||||||
|
|
||||||
# If not a duplicate, then add it to the list
|
# If not a duplicate, then add it to the list
|
||||||
if not self.duplicate:
|
if not duplicate:
|
||||||
# Add the tracker to the list
|
# Add the tracker to the list
|
||||||
self.add_tracker(self.highest_tier + 1, tracker)
|
self.add_tracker(highest_tier + 1, tracker)
|
||||||
|
|
||||||
# Clear the entry widget and hide the dialog
|
# Clear the entry widget and hide the dialog
|
||||||
self.glade.get_widget("entry_tracker").set_text("")
|
textview.get_buffer().set_text("")
|
||||||
self.add_tracker_dialog.hide()
|
self.add_tracker_dialog.hide()
|
||||||
|
|
||||||
def on_button_add_cancel_clicked(self, widget):
|
def on_button_add_cancel_clicked(self, widget):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
||||||
<!--Generated with glade3 3.4.5 on Wed Aug 13 20:02:28 2008 -->
|
<!--Generated with glade3 3.4.5 on Fri Sep 19 18:55:00 2008 -->
|
||||||
<glade-interface>
|
<glade-interface>
|
||||||
<widget class="GtkDialog" id="edit_trackers_dialog">
|
<widget class="GtkDialog" id="edit_trackers_dialog">
|
||||||
<property name="width_request">400</property>
|
<property name="width_request">400</property>
|
||||||
|
@ -93,7 +93,7 @@
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
<property name="label" translatable="no">gtk-go-up</property>
|
<property name="label">gtk-go-up</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="response_id">0</property>
|
<property name="response_id">0</property>
|
||||||
<signal name="clicked" handler="on_button_up_clicked"/>
|
<signal name="clicked" handler="on_button_up_clicked"/>
|
||||||
|
@ -134,7 +134,7 @@
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
<property name="label" translatable="no">gtk-remove</property>
|
<property name="label">gtk-remove</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="response_id">0</property>
|
<property name="response_id">0</property>
|
||||||
<signal name="clicked" handler="on_button_remove_clicked"/>
|
<signal name="clicked" handler="on_button_remove_clicked"/>
|
||||||
|
@ -149,7 +149,7 @@
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
<property name="label" translatable="no">gtk-go-down</property>
|
<property name="label">gtk-go-down</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="response_id">0</property>
|
<property name="response_id">0</property>
|
||||||
<signal name="clicked" handler="on_button_down_clicked"/>
|
<signal name="clicked" handler="on_button_down_clicked"/>
|
||||||
|
@ -186,7 +186,7 @@
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
<property name="label" translatable="no">gtk-cancel</property>
|
<property name="label">gtk-cancel</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="response_id">0</property>
|
<property name="response_id">0</property>
|
||||||
<signal name="clicked" handler="on_button_cancel_clicked"/>
|
<signal name="clicked" handler="on_button_cancel_clicked"/>
|
||||||
|
@ -198,7 +198,7 @@
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
<property name="label" translatable="no">gtk-ok</property>
|
<property name="label">gtk-ok</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="response_id">0</property>
|
<property name="response_id">0</property>
|
||||||
<signal name="clicked" handler="on_button_ok_clicked"/>
|
<signal name="clicked" handler="on_button_ok_clicked"/>
|
||||||
|
@ -218,6 +218,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="GtkDialog" id="add_tracker_dialog">
|
<widget class="GtkDialog" id="add_tracker_dialog">
|
||||||
<property name="width_request">400</property>
|
<property name="width_request">400</property>
|
||||||
|
<property name="height_request">200</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
<property name="border_width">5</property>
|
<property name="border_width">5</property>
|
||||||
<property name="title" translatable="yes">Add Tracker</property>
|
<property name="title" translatable="yes">Add Tracker</property>
|
||||||
|
@ -256,7 +257,7 @@
|
||||||
<widget class="GtkLabel" id="label1">
|
<widget class="GtkLabel" id="label1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
<property name="label" translatable="yes"><b>Add Tracker</b></property>
|
<property name="label" translatable="yes"><b>Add Trackers</b></property>
|
||||||
<property name="use_markup">True</property>
|
<property name="use_markup">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
|
@ -290,21 +291,30 @@
|
||||||
<widget class="GtkLabel" id="label2">
|
<widget class="GtkLabel" id="label2">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
<property name="label" translatable="yes">Tracker:</property>
|
<property name="xalign">0</property>
|
||||||
|
<property name="yalign">0</property>
|
||||||
|
<property name="label" translatable="yes">Trackers:</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkEntry" id="entry_tracker">
|
<widget class="GtkScrolledWindow" id="scrolledwindow1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="has_focus">True</property>
|
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||||
<property name="is_focus">True</property>
|
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||||
<property name="activates_default">True</property>
|
<child>
|
||||||
|
<widget class="GtkTextView" id="textview_trackers">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="left_margin">1</property>
|
||||||
|
<property name="right_margin">1</property>
|
||||||
|
<property name="accepts_tab">False</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
|
@ -312,8 +322,6 @@
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">2</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
@ -333,7 +341,7 @@
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
<property name="label" translatable="no">gtk-cancel</property>
|
<property name="label">gtk-cancel</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="response_id">0</property>
|
<property name="response_id">0</property>
|
||||||
<signal name="clicked" handler="on_button_add_cancel_clicked"/>
|
<signal name="clicked" handler="on_button_add_cancel_clicked"/>
|
||||||
|
@ -347,7 +355,7 @@
|
||||||
<property name="has_default">True</property>
|
<property name="has_default">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
<property name="label" translatable="no">gtk-ok</property>
|
<property name="label">gtk-ok</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="response_id">0</property>
|
<property name="response_id">0</property>
|
||||||
<signal name="clicked" handler="on_button_add_ok_clicked"/>
|
<signal name="clicked" handler="on_button_add_ok_clicked"/>
|
||||||
|
@ -482,7 +490,7 @@
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
<property name="label" translatable="no">gtk-cancel</property>
|
<property name="label">gtk-cancel</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="response_id">0</property>
|
<property name="response_id">0</property>
|
||||||
<signal name="clicked" handler="on_button_edit_cancel_clicked"/>
|
<signal name="clicked" handler="on_button_edit_cancel_clicked"/>
|
||||||
|
@ -496,7 +504,7 @@
|
||||||
<property name="has_default">True</property>
|
<property name="has_default">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
<property name="label" translatable="no">gtk-ok</property>
|
<property name="label">gtk-ok</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="response_id">0</property>
|
<property name="response_id">0</property>
|
||||||
<signal name="clicked" handler="on_button_edit_ok_clicked"/>
|
<signal name="clicked" handler="on_button_edit_ok_clicked"/>
|
||||||
|
|
Loading…
Reference in New Issue