beginnings of gui interface for editing trackers

This commit is contained in:
Marcos Pinto 2007-06-24 05:14:00 +00:00
parent bc76d648ba
commit 50d7282fcb
5 changed files with 215 additions and 21 deletions

110
glade/edit_trackers.glade Normal file
View File

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.2.2 on Sat Jun 23 23:04:31 2007 by root@peg-->
<glade-interface>
<widget class="GtkWindow" id="edittrackers">
<property name="width_request">300</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>
<child>
<widget class="GtkVBox" id="vbox1">
<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>
<child>
<widget class="GtkLabel" id="label1">
<property name="height_request">45</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="label" translatable="yes">Edit Trackers</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkTextView" id="txt_tracker_list">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox1">
<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>
<child>
<widget class="GtkAspectFrame" id="aspectframe1">
<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="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="ratio">1</property>
<child>
<placeholder/>
</child>
</widget>
</child>
<child>
<widget class="GtkButton" id="cancel_button">
<property name="visible">True</property>
<property name="can_focus">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="label" translatable="yes">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="cancel_button_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="ok_button">
<property name="visible">True</property>
<property name="can_focus">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="label" translatable="yes">gtk-ok</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="ok_button_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkAspectFrame" id="aspectframe2">
<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="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="ratio">1</property>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="position">3</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -4,22 +4,6 @@
<glade-interface>
<widget class="GtkMenu" id="torrent_menu">
<property name="visible">True</property>
<child>
<widget class="GtkImageMenuItem" id="menuitem12">
<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="label" translatable="yes">Remove Torrent</property>
<property name="use_underline">True</property>
<signal name="activate" handler="remove_torrent"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image9">
<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="stock">gtk-remove</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menu_pause">
<property name="visible">True</property>
@ -46,6 +30,48 @@
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem13">
<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="label" translatable="yes">Edit Trackers</property>
<property name="use_underline">True</property>
<signal name="activate" handler="edit_trackers"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image12">
<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="stock">gtk-edit</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem12">
<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="label" translatable="yes">Remove Torrent</property>
<property name="use_underline">True</property>
<signal name="activate" handler="remove_torrent"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image9">
<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="stock">gtk-remove</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menuitem2">
<property name="visible">True</property>

View File

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

View File

@ -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<announce_entry>::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}
};

View File

@ -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,
@ -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')