active ok button in edit trackers list
This commit is contained in:
parent
078af4148f
commit
2c4978b9ef
|
@ -803,3 +803,6 @@ class Manager:
|
||||||
def get_trackers(self, unique_ID):
|
def get_trackers(self, unique_ID):
|
||||||
return deluge_core.get_trackers(unique_ID)
|
return deluge_core.get_trackers(unique_ID)
|
||||||
|
|
||||||
|
def replace_trackers(self, unique_ID, trackers):
|
||||||
|
return deluge_core.replace_trackers(unique_ID, trackers)
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
#include "libtorrent/natpmp.hpp"
|
#include "libtorrent/natpmp.hpp"
|
||||||
#include "libtorrent/extensions/metadata_transfer.hpp"
|
#include "libtorrent/extensions/metadata_transfer.hpp"
|
||||||
#include "libtorrent/extensions/ut_pex.hpp"
|
#include "libtorrent/extensions/ut_pex.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
using namespace std;
|
||||||
using namespace boost::filesystem;
|
using namespace boost::filesystem;
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
|
@ -1359,6 +1361,34 @@ static PyObject *torrent_get_trackers(PyObject *self, PyObject *args)
|
||||||
return Py_BuildValue("s",trackerslist.c_str());
|
return Py_BuildValue("s",trackerslist.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *torrent_replace_trackers(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
python_long unique_ID;
|
||||||
|
std::string tracker;
|
||||||
|
if (!PyArg_ParseTuple(args, "is", &unique_ID, &tracker))
|
||||||
|
return NULL;
|
||||||
|
long index = get_index_from_unique_ID(unique_ID);
|
||||||
|
if (PyErr_Occurred())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
torrent_handle& h = M_torrents->at(index).handle;
|
||||||
|
|
||||||
|
std::vector<libtorrent::announce_entry> trackerlist;
|
||||||
|
|
||||||
|
std::string line;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
istringstream in(tracker);
|
||||||
|
while(getline(in, line)){
|
||||||
|
trackerlist.push_back(line);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
h.replace_trackers(trackerlist);
|
||||||
|
h.force_reannounce();
|
||||||
|
|
||||||
|
return Py_None;
|
||||||
|
}
|
||||||
//====================
|
//====================
|
||||||
// Python Module data
|
// Python Module data
|
||||||
//====================
|
//====================
|
||||||
|
@ -1403,6 +1433,7 @@ static PyMethodDef deluge_core_methods[] =
|
||||||
{"set_ratio", torrent_set_ratio, METH_VARARGS, "."},
|
{"set_ratio", torrent_set_ratio, METH_VARARGS, "."},
|
||||||
{"proxy_settings", torrent_proxy_settings, METH_VARARGS, "."},
|
{"proxy_settings", torrent_proxy_settings, METH_VARARGS, "."},
|
||||||
{"get_trackers", torrent_get_trackers, METH_VARARGS, "."},
|
{"get_trackers", torrent_get_trackers, METH_VARARGS, "."},
|
||||||
|
{"replace_trackers", torrent_replace_trackers, METH_VARARGS, "."},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -317,28 +317,32 @@ class DelugeGTK:
|
||||||
trackerslist = self.manager.get_trackers(torrent)
|
trackerslist = self.manager.get_trackers(torrent)
|
||||||
self.show_edit_tracker_dialog(trackerslist)
|
self.show_edit_tracker_dialog(trackerslist)
|
||||||
|
|
||||||
|
def cancel_edit_window(self,arg=None):
|
||||||
|
self.edit_window.destroy()
|
||||||
|
|
||||||
|
def accept_edit_window(self,arg=None):
|
||||||
|
torrent = self.get_selected_torrent()
|
||||||
|
self.newlist = self.edit_list.get_buffer()
|
||||||
|
self.start = self.textbuffer.get_start_iter()
|
||||||
|
self.end = self.textbuffer.get_end_iter()
|
||||||
|
self.textlist = self.textbuffer.get_text(self.start,self.end,include_hidden_chars=False)
|
||||||
|
self.manager.replace_trackers(torrent, self.textlist)
|
||||||
|
self.edit_window.destroy()
|
||||||
|
|
||||||
def show_edit_tracker_dialog(self,list):
|
def show_edit_tracker_dialog(self,list):
|
||||||
textbuffer = gtk.TextBuffer(table=None)
|
self.textbuffer = gtk.TextBuffer(table=None)
|
||||||
textbuffer.set_text(list)
|
self.textbuffer.set_text(list)
|
||||||
edit_glade = gtk.glade.XML(common.get_glade_file("edit_trackers.glade"))
|
self.edit_glade = gtk.glade.XML(common.get_glade_file("edit_trackers.glade"))
|
||||||
edit_list = edit_glade.get_widget("txt_tracker_list")
|
self.edit_list = self.edit_glade.get_widget("txt_tracker_list")
|
||||||
edit_list.set_buffer(textbuffer)
|
self.edit_list.set_buffer(self.textbuffer)
|
||||||
edit_window = edit_glade.get_widget("edittrackers")
|
self.edit_window = self.edit_glade.get_widget("edittrackers")
|
||||||
edit_window.set_position(gtk.WIN_POS_CENTER_ALWAYS)
|
self.edit_window.set_position(gtk.WIN_POS_CENTER_ALWAYS)
|
||||||
edit_window.set_size_request(400, 200)
|
self.edit_window.set_size_request(400, 200)
|
||||||
def cancel_edit_window(self,arg=None):
|
self.edit_glade.signal_autoconnect({"cancel_button_clicked": self.cancel_edit_window,
|
||||||
edit_window.destroy()
|
"ok_button_clicked": self.accept_edit_window
|
||||||
def accept_edit_window(self,arg=None):
|
|
||||||
newlist = edit_list.get_buffer()
|
|
||||||
start = textbuffer.get_start_iter()
|
|
||||||
end = textbuffer.get_end_iter()
|
|
||||||
textlist = textbuffer.get_text(start,end,include_hidden_chars=False)
|
|
||||||
edit_window.destroy()
|
|
||||||
edit_glade.signal_autoconnect({"cancel_button_clicked": cancel_edit_window,
|
|
||||||
"ok_button_clicked": accept_edit_window
|
|
||||||
})
|
})
|
||||||
|
|
||||||
edit_window.show_all()
|
self.edit_window.show_all()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue