diff options
-rw-r--r-- | icons/pyload.ico | bin | 0 -> 7206 bytes | |||
-rw-r--r-- | module/file_list.py | 15 | ||||
-rw-r--r-- | pyLoadCore.py | 14 | ||||
-rwxr-xr-x | pyLoadGui.py | 52 |
4 files changed, 78 insertions, 3 deletions
diff --git a/icons/pyload.ico b/icons/pyload.ico Binary files differnew file mode 100644 index 000000000..58b1f4b89 --- /dev/null +++ b/icons/pyload.ico diff --git a/module/file_list.py b/module/file_list.py index e9a836dbc..a25e954a5 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -90,7 +90,22 @@ class File_List(object): id += 1 return id + + def move(self, id, offset=-1): + for pyfile in self.files: + if pyfile.id == id: + index = self.files.index(pyfile) + pyfile = self.files.pop(index) + self.files.insert(index + offset, pyfile) + break + + + index = self.data['order'].index(id) + pyfile = self.data['order'].pop(index) + self.data['order'].insert(index + offset, pyfile) + + def save(self): self.lock.acquire() diff --git a/pyLoadCore.py b/pyLoadCore.py index 3f45ca332..b250d3f55 100644 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -269,6 +269,20 @@ class Core(object): def get_links(self): return self.file_list.data + def move_links_up(self, ids): + + for id in ids: + self.file_list.move(id) + + self.file_list.save() + + def move_links_down(self, ids): + + for id in ids: + self.file_list.move(id, 1) + + self.file_list.save() + def toggle_pause(self): if self.thread_list.pause: self.thread_list.pause = False diff --git a/pyLoadGui.py b/pyLoadGui.py index 58e0006d2..d508db540 100755 --- a/pyLoadGui.py +++ b/pyLoadGui.py @@ -126,16 +126,34 @@ class _Upper_Panel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) sizer = wx.BoxSizer(wx.HORIZONTAL) - + self.parent = parent + self.list = Download_Liste(self) sizer.Add(self.list, 1, wx.EXPAND) self.SetSizer(sizer) - def refresh(self, links, data): - + def refresh(self, links, data): self.list.reload(links, data) + def get_selected_ids(self, deselect=False): + """return ids and deselect items""" + item = self.list.GetFirstSelected() + if deselect: self.list.Select(item, on=0) + + if item == -1: + return False + + links = [] + links.append(self.parent.data['order'][item]) + + while self.list.GetNextSelected(item) != -1: + item = self.list.GetNextSelected(item) + if deselect: self.list.Select(item, on=0) + links.append(self.parent.data['order'][item]) + + return links + class _Lower_Panel(wx.Panel): def __init__(self, parent): @@ -195,6 +213,10 @@ class Pyload_Main_Gui(wx.Frame): # Statusbar self.CreateStatusBar() + # icon + icon1 = wx.Icon(app_path + '/icons/pyload.ico', wx.BITMAP_TYPE_ICO) + self.SetIcon(icon1) + # Toolbar toolbar = self.CreateToolBar() toolbar.SetToolBitmapSize((32, 32)) @@ -218,6 +240,9 @@ class Pyload_Main_Gui(wx.Frame): self.Bind(wx.EVT_MENU, self.connect, self.submenu_pyload_connect) self.Bind(wx.EVT_MENU, self.disconnect, self.submenu_pyload_disconnect) self.Bind(wx.EVT_TOOL, self.add_button_clicked, add) + self.Bind(wx.EVT_TOOL, self.delete_button_clicked, delete) + self.Bind(wx.EVT_TOOL, self.up_button_clicked, up) + self.Bind(wx.EVT_TOOL, self.down_button_clicked, down) self.Bind(EVT_DATA_ARRIVED, self.onUpdate) self.Centre() @@ -265,6 +290,27 @@ class Pyload_Main_Gui(wx.Frame): downloads = add_download.links.GetValue().split() self.thread.push_exec('add_links', [downloads]) + def delete_button_clicked(self, event): + + links = self.panel_up.get_selected_ids(True) + + self.thread.push_exec('remove_links', [links]) + + + def up_button_clicked(self, event): + + links = self.panel_up.get_selected_ids() + self.thread.push_exec('move_links_up', [links]) + + + def down_button_clicked(self, event): + + links = self.panel_up.get_selected_ids() + + self.thread.push_exec('move_links_down', [links]) + + + def show_links(self, links): for link in links: #wx.MessageDialog(self, str(link), 'info', style=wx.OK).ShowModal() |