Move 'add_peer_dialog' to peers_tab.py where it should belong..
This commit is contained in:
parent
23944abc4c
commit
2ccebaca3b
|
@ -181,27 +181,3 @@ def show_other_dialog(header, type_str, image_stockid=None, image_filename=None,
|
|||
|
||||
dialog.destroy()
|
||||
return value
|
||||
|
||||
def add_peer_dialog():
|
||||
dialog_glade = gtk.glade.XML(
|
||||
pkg_resources.resource_filename("deluge.ui.gtkui",
|
||||
"glade/dgtkpopups.glade"))
|
||||
peer_dialog = dialog_glade.get_widget("connect_peer_dialog")
|
||||
txt_ip = dialog_glade.get_widget("txt_ip")
|
||||
response = peer_dialog.run()
|
||||
if response:
|
||||
value = txt_ip.get_text()
|
||||
if ']' in value:
|
||||
#ipv6
|
||||
ip = value.split("]")[0][1:]
|
||||
port = value.split("]")[1][1:]
|
||||
else:
|
||||
#ipv4
|
||||
ip = value.split(":")[0]
|
||||
port = value.split(":")[1]
|
||||
if deluge.common.is_ip(ip):
|
||||
id = component.get("TorrentView").get_selected_torrent()
|
||||
log.debug("adding peer %s to %s", value, id)
|
||||
client.core.connect_peer(id, ip, port)
|
||||
peer_dialog.destroy()
|
||||
return True
|
||||
|
|
|
@ -46,7 +46,6 @@ from deluge.configmanager import ConfigManager
|
|||
import deluge.configmanager
|
||||
import deluge.component as component
|
||||
import deluge.common
|
||||
import deluge.ui.gtkui.common as common
|
||||
from deluge.ui.gtkui.listview import cell_data_speed as cell_data_speed
|
||||
from deluge.ui.gtkui.torrentdetails import Tab
|
||||
from deluge.log import LOG as log
|
||||
|
@ -375,5 +374,24 @@ class PeersTab(Tab):
|
|||
def _on_menuitem_add_peer_activate(self, menuitem):
|
||||
"""This is a callback for manually adding a peer"""
|
||||
log.debug("on_menuitem_add_peer")
|
||||
common.add_peer_dialog()
|
||||
dialog_glade = gtk.glade.XML(
|
||||
pkg_resources.resource_filename("deluge.ui.gtkui",
|
||||
"glade/dgtkpopups.glade"))
|
||||
peer_dialog = dialog_glade.get_widget("connect_peer_dialog")
|
||||
txt_ip = dialog_glade.get_widget("txt_ip")
|
||||
response = peer_dialog.run()
|
||||
if response:
|
||||
value = txt_ip.get_text()
|
||||
if ']' in value:
|
||||
#ipv6
|
||||
ip = value.split("]")[0][1:]
|
||||
port = value.split("]")[1][1:]
|
||||
else:
|
||||
#ipv4
|
||||
ip = value.split(":")[0]
|
||||
port = value.split(":")[1]
|
||||
if deluge.common.is_ip(ip):
|
||||
log.debug("adding peer %s to %s", value, self.torrent_id)
|
||||
client.core.connect_peer(self.torrent_id, ip, port)
|
||||
peer_dialog.destroy()
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue