Use a Menu instead of CtxPopup for torrent actions, add queue actions.

This commit is contained in:
Kai Huuhko 2013-08-08 02:16:20 +03:00
parent 500f3bc529
commit 9264a23cd7
1 changed files with 23 additions and 13 deletions

View File

@ -32,7 +32,7 @@ try:
Box, Label, Button, ELM_GENLIST_ITEM_FIELD_TEXT, \
ELM_GENLIST_ITEM_FIELD_CONTENT, InnerWindow, Ctxpopup, Frame, \
Fileselector, Entry, Panel, ELM_PANEL_ORIENT_BOTTOM, \
ELM_OBJECT_SELECT_MODE_NONE, Table, Separator
ELM_OBJECT_SELECT_MODE_NONE, Table, Separator, Menu
except ImportError:
from efl.evas import EVAS_ASPECT_CONTROL_VERTICAL, Rectangle
from efl.ecore import Timer
@ -53,6 +53,7 @@ except ImportError:
from efl.elementary.panel import Panel, ELM_PANEL_ORIENT_BOTTOM
from efl.elementary.table import Table
from efl.elementary.separator import Separator
from efl.elementary.menu import Menu
from TorrentInfo import TorrentInfo
from Preferences import Preferences
@ -164,47 +165,56 @@ class MainInterface(object):
def item_activated_cb(self, gl, item):
h = item.data
cp = Ctxpopup(self.win)
cp.item_append(
cp = Menu(self.win)
cp.item_add(
None,
"Resume" if h.is_paused() else "Pause",
None,
self.resume_torrent_cb if h.is_paused() else self.pause_torrent_cb,
h
)
cp.item_append("Remove torrent", None,
q = cp.item_add(None, "Queue", None, None)
cp.item_add(q, "Up", None, lambda x, y: h.queue_position_up())
cp.item_add(q, "Down", None, lambda x, y: h.queue_position_down())
cp.item_add(q, "Top", None, lambda x, y: h.queue_position_top())
cp.item_add(q, "Bottom", None, lambda x, y: h.queue_position_bottom())
cp.item_add(None, "Remove torrent", None,
self.remove_torrent_cb, item, h, False)
cp.item_append("Remove torrent and files", None,
cp.item_add(None, "Remove torrent and files", None,
self.remove_torrent_cb, item, h, True)
cp.item_append("Force re-check", None,
cp.item_add(None, "Force re-check", None,
self.force_recheck, h)
cp.item_append("Torrent preferences", None,
cp.item_separator_add(None)
cp.item_add(None, "Torrent preferences", None,
self.torrent_preferences_cb, h)
cp.pos = self.win.evas.pointer_canvas_xy_get()
cp.move(*self.win.evas.pointer_canvas_xy_get())
cp.show()
def resume_torrent_cb(self, l, item, h):
item.widget_get().dismiss()
#item.widget_get().dismiss()
h.resume()
h.auto_managed(True)
def pause_torrent_cb(self, l, item, h):
item.widget_get().dismiss()
#item.widget_get().dismiss()
h.auto_managed(False)
h.pause()
def force_recheck(self, l, item, h):
item.widget_get().dismiss()
#item.widget_get().dismiss()
h.force_recheck()
def remove_torrent_cb(self, l, item, glitem, h, with_data=False):
item.widget_get().dismiss()
#item.widget_get().dismiss()
ihash = self.parent.session.remove_torrent(h, with_data)
glitem.delete()
del self.torrentitems[ihash]
del glitem
def torrent_preferences_cb(self, cp, item, h):
item.widget_get().dismiss()
#item.widget_get().dismiss()
self.i = TorrentInfo(self, h)
def show_error(self, title, text):