diff --git a/glade/torrent_menu.glade b/glade/torrent_menu.glade index 68584024d..3a4697ed4 100644 --- a/glade/torrent_menu.glade +++ b/glade/torrent_menu.glade @@ -117,5 +117,55 @@ + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Desired Ratio + True + + + 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 + True + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 1 + True + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + True + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 3 + True + + + + + + + diff --git a/src/core.py b/src/core.py index f5d1deb5e..2075e6661 100644 --- a/src/core.py +++ b/src/core.py @@ -568,6 +568,10 @@ class Manager: self.unique_IDs[unique_ID].user_paused = new_value self.apply_queue() + def set_ratio(self, unique_ID, num): + print("setting the ratio core") + deluge_core.set_ratio(unique_ID, num) + def is_user_paused(self, unique_ID): return self.unique_IDs[unique_ID].user_paused diff --git a/src/deluge_core.cpp b/src/deluge_core.cpp index 096c99ffd..60f02b3eb 100644 --- a/src/deluge_core.cpp +++ b/src/deluge_core.cpp @@ -1290,6 +1290,22 @@ static PyObject *torrent_pe_settings(PyObject *self, PyObject *args) return Py_None; } +static PyObject *torrent_set_ratio(PyObject *self, PyObject *args) +{ + python_long unique_ID, num; + if (!PyArg_ParseTuple(args, "ii", &unique_ID, &num)) + return NULL; + + long index = get_index_from_unique_ID(unique_ID); + if (PyErr_Occurred()) + return NULL; + + M_torrents->at(index).handle.set_ratio(num); + + Py_INCREF(Py_None); return Py_None; +} + + //==================== // Python Module data //==================== @@ -1331,6 +1347,7 @@ static PyMethodDef deluge_core_methods[] = {"use_upnp", torrent_use_upnp, METH_VARARGS, "."}, {"use_natpmp", torrent_use_natpmp, METH_VARARGS, "."}, {"use_utpex", torrent_use_utpex, METH_VARARGS, "."}, + {"set_ratio", torrent_set_ratio, METH_VARARGS, "."}, {NULL} }; diff --git a/src/interface.py b/src/interface.py index a1aac6483..264451d07 100644 --- a/src/interface.py +++ b/src/interface.py @@ -263,6 +263,10 @@ class DelugeGTK: "queue_down": self.q_torrent_down, "queue_bottom": self.q_to_bottom, "queue_top": self.q_to_top, + "set_ratio0": self.set_ratio_0, + "set_ratio1": self.set_ratio_1, + "set_ratio2": self.set_ratio_2, + "set_ratio3": self.set_ratio_3, }) self.torrent_menu.connect("focus", self.torrent_menu_focus) # UID, Q#, Name, Size, Progress, Message, Seeders, Peers, DL, UL, ETA, Share @@ -414,7 +418,27 @@ class DelugeGTK: except KeyError: pass - + + def set_ratio_0(self, widget): + unique_ids = self.get_selected_torrent_rows() + for uid in unique_ids: + self.manager.set_ratio(uid, 0) + + def set_ratio_1(self, widget): + unique_ids = self.get_selected_torrent_rows() + for uid in unique_ids: + self.manager.set_ratio(uid, 1) + + def set_ratio_2(self, widget): + unique_ids = self.get_selected_torrent_rows() + for uid in unique_ids: + self.manager.set_ratio(uid, 2) + + def set_ratio_3(self, widget): + unique_ids = self.get_selected_torrent_rows() + for uid in unique_ids: + self.manager.set_ratio(uid, 3) + def torrent_menu_focus(self, widget, direction): menuitem = self.torrent_glade.get_widget("menu_pause") # Check if we are selecting multiple torrents