From 50d7282fcb3586df89cd6677bf9469057be1f440 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Sun, 24 Jun 2007 05:14:00 +0000 Subject: [PATCH] beginnings of gui interface for editing trackers --- glade/edit_trackers.glade | 110 ++++++++++++++++++++++++++++++++++++++ glade/torrent_menu.glade | 58 ++++++++++++++------ src/core.py | 3 ++ src/deluge_core.cpp | 25 ++++++++- src/interface.py | 40 ++++++++++++-- 5 files changed, 215 insertions(+), 21 deletions(-) create mode 100644 glade/edit_trackers.glade diff --git a/glade/edit_trackers.glade b/glade/edit_trackers.glade new file mode 100644 index 000000000..232eb9ade --- /dev/null +++ b/glade/edit_trackers.glade @@ -0,0 +1,110 @@ + + + + + + 300 + 200 + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 45 + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Edit Trackers + + + False + False + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + GTK_SHADOW_NONE + 1 + + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-cancel + True + 0 + + + + False + False + 1 + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-ok + True + 0 + + + + False + False + 2 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + GTK_SHADOW_NONE + 1 + + + + + + 3 + + + + + False + False + 2 + + + + + + diff --git a/glade/torrent_menu.glade b/glade/torrent_menu.glade index 2f1566ea1..4bbc5b8eb 100644 --- a/glade/torrent_menu.glade +++ b/glade/torrent_menu.glade @@ -4,22 +4,6 @@ True - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Remove Torrent - True - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-remove - - - - True @@ -46,6 +30,48 @@ + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Edit Trackers + True + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-edit + + + + + + + True + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Remove Torrent + True + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-remove + + + + + + + True + + True diff --git a/src/core.py b/src/core.py index da4924453..27f156dce 100644 --- a/src/core.py +++ b/src/core.py @@ -807,3 +807,6 @@ class Manager: def pe_settings(self, out_enc_policy, in_enc_policy, allowed_enc_level, prefer_rc4): return deluge_core.pe_settings(out_enc_policy, in_enc_policy, allowed_enc_level, prefer_rc4) + def get_trackers(self, unique_ID): + return deluge_core.get_trackers(unique_ID) + diff --git a/src/deluge_core.cpp b/src/deluge_core.cpp index 0543644c4..a7920e622 100644 --- a/src/deluge_core.cpp +++ b/src/deluge_core.cpp @@ -1333,9 +1333,31 @@ static PyObject *torrent_proxy_settings(PyObject *self, PyObject *args) M_ses->set_dht_proxy(*M_proxy_settings); } - Py_INCREF(Py_None); return Py_None; + return Py_None; } +static PyObject *torrent_get_trackers(PyObject *self, PyObject *args) +{ + python_long unique_ID; + if (!PyArg_ParseTuple(args, "i", &unique_ID)) + 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::string trackerslist; + if (h.is_valid() && h.has_metadata()) + { + for (std::vector::const_iterator i = h.trackers().begin(); + i != h.trackers().end(); ++i) + { + trackerslist = trackerslist + i->url +"\r\n"; + } + } + return Py_BuildValue("s",trackerslist.c_str()); +} //==================== // Python Module data @@ -1380,6 +1402,7 @@ static PyMethodDef deluge_core_methods[] = {"use_utpex", torrent_use_utpex, METH_VARARGS, "."}, {"set_ratio", torrent_set_ratio, METH_VARARGS, "."}, {"proxy_settings", torrent_proxy_settings, METH_VARARGS, "."}, + {"get_trackers", torrent_get_trackers, METH_VARARGS, "."}, {NULL} }; diff --git a/src/interface.py b/src/interface.py index 7dd03768d..6c2df9e8e 100644 --- a/src/interface.py +++ b/src/interface.py @@ -152,9 +152,7 @@ class DelugeGTK: "update_tracker": self.update_tracker, "clear_finished": self.clear_finished, "queue_up": self.q_torrent_up, - "queue_down": self.q_torrent_down, - "queue_bottom": self.q_to_bottom, - "queue_top": self.q_to_top, + "queue_down": self.q_torrent_down }) def build_tray_icon(self): @@ -313,6 +311,38 @@ class DelugeGTK: tray_lock.destroy() return True + def list_of_trackers(self,obj=None): + torrent = self.get_selected_torrent() + if torrent is not None: + trackerslist = self.manager.get_trackers(torrent) + self.show_edit_tracker_dialog(trackerslist) + + def show_edit_tracker_dialog(self,list): + textbuffer = gtk.TextBuffer(table=None) + textbuffer.set_text(list) + edit_glade = gtk.glade.XML(common.get_glade_file("edit_trackers.glade")) + edit_list = edit_glade.get_widget("txt_tracker_list") + edit_list.set_buffer(textbuffer) + edit_window = edit_glade.get_widget("edittrackers") + edit_window.set_position(gtk.WIN_POS_CENTER_ALWAYS) + edit_window.set_size_request(400, 200) + def cancel_edit_window(self,arg=None): + edit_window.destroy() + 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) + print textlist + edit_window.destroy() + edit_glade.signal_autoconnect({"cancel_button_clicked": cancel_edit_window, + "ok_button_clicked": accept_edit_window + }) + + edit_window.show_all() + + return True + def tray_clicked(self, status_icon): if self.window.get_property("visible"): @@ -342,6 +372,7 @@ class DelugeGTK: self.torrent_glade = gtk.glade.XML(common.get_glade_file("torrent_menu.glade"), domain='deluge') self.torrent_menu = self.torrent_glade.get_widget("torrent_menu") self.torrent_glade.signal_autoconnect({ "remove_torrent": self.remove_torrent_clicked, + "edit_trackers": self.list_of_trackers, "start_pause": self.start_pause, "update_tracker": self.update_tracker, "clear_finished": self.clear_finished, @@ -671,7 +702,7 @@ class DelugeGTK: def show_about_dialog(self, arg=None): dialogs.show_about_dialog() - + def show_pref_dialog(self, arg=None): if self.window.get_property("visible"): # Only apply the prefs if the user pressed OK in the prefs dialog @@ -1313,6 +1344,7 @@ class DelugeGTK: self.config.set("window_maximized", False) return False + def load_window_geometry(self): x = self.config.get('window_x_pos') y = self.config.get('window_y_pos')