Added basics for timelines support
This commit is contained in:
parent
a4d4148a82
commit
69f4964158
@ -142,6 +142,13 @@ class baseBuffer(object):
|
||||
|
||||
def remove_buffer(self): return False
|
||||
|
||||
def get_users(self):
|
||||
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
|
||||
if post.has_key("type") == False:
|
||||
return post["from_id"]
|
||||
else:
|
||||
return [post["source_id"]]
|
||||
|
||||
class feedBuffer(baseBuffer):
|
||||
|
||||
def get_items(self, show_nextpage=False):
|
||||
|
@ -15,6 +15,7 @@ from mysc.thread_utils import call_threaded
|
||||
from sessionmanager import session
|
||||
from wxUI import (mainWindow, commonMessages)
|
||||
from wxUI.dialogs import search as searchDialogs
|
||||
from wxUI.dialogs import timeline
|
||||
from update import updater
|
||||
|
||||
class Controller(object):
|
||||
@ -85,6 +86,7 @@ class Controller(object):
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.get_more_items, menuitem=self.window.load_previous_items)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.changelog, menuitem=self.window.changelog)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.configuration, menuitem=self.window.settings_dialog)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.new_timeline, menuitem=self.window.timeline)
|
||||
|
||||
def disconnect_events(self):
|
||||
pub.unsubscribe(self.in_post, "posted")
|
||||
@ -186,3 +188,25 @@ class Controller(object):
|
||||
d = configuration.configuration(self.session)
|
||||
if d.response == widgetUtils.OK:
|
||||
d.save_configuration()
|
||||
|
||||
def new_timeline(self, *args, **kwargs):
|
||||
b = self.get_current_buffer()
|
||||
if not hasattr(b, "get_users"): return
|
||||
ids = b.get_users()
|
||||
d = []
|
||||
for i in ids:
|
||||
d.append((i, self.session.get_user_name(i)))
|
||||
for i in self.session.db["users"]:
|
||||
d.append((i, self.session.get_user_name(i)))
|
||||
for i in self.session.db["groups"]:
|
||||
d.append((i, self.session.get_user_name(i)))
|
||||
a = timeline.timelineDialog([i[1] for i in d])
|
||||
if a.get_response() == widgetUtils.OK:
|
||||
user = a.get_user()
|
||||
buffertype = a.get_buffer_type()
|
||||
user_id = ""
|
||||
print user
|
||||
for i in d:
|
||||
if i[1] == user:
|
||||
user_id = i[0]
|
||||
print user_id
|
37
src/wxUI/dialogs/timeline.py
Normal file
37
src/wxUI/dialogs/timeline.py
Normal file
@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import wx
|
||||
import widgetUtils
|
||||
|
||||
class timelineDialog(widgetUtils.BaseDialog):
|
||||
|
||||
def __init__(self, users=[]):
|
||||
super(timelineDialog, self).__init__(parent=None, title=_(u"New timeline for {0}").format(users[0],))
|
||||
panel = wx.Panel(self)
|
||||
sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
userLabel = wx.StaticText(panel, -1, _(u"User"))
|
||||
self.cb = wx.ComboBox(panel, -1, choices=users, value=users[0])
|
||||
self.cb.SetFocus()
|
||||
userSizer = wx.BoxSizer()
|
||||
userSizer.Add(userLabel, 0, wx.ALL, 5)
|
||||
userSizer.Add(self.cb, 0, wx.ALL, 5)
|
||||
actionsstatic = wx.StaticBox(panel, label=_(u"Buffer type"))
|
||||
self.audio = wx.RadioButton(panel, wx.NewId(), _(u"&Audios"), style=wx.RB_GROUP)
|
||||
radioSizer = wx.StaticBoxSizer(actionsstatic, wx.HORIZONTAL)
|
||||
radioSizer.Add(self.audio, 0, wx.ALL, 5)
|
||||
sizer.Add(radioSizer, 0, wx.ALL, 5)
|
||||
ok = wx.Button(panel, wx.ID_OK, _(u"&OK"))
|
||||
ok.SetDefault()
|
||||
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"&Close"))
|
||||
btnsizer = wx.BoxSizer()
|
||||
btnsizer.Add(ok, 0, wx.ALL, 5)
|
||||
btnsizer.Add(cancel, 0, wx.ALL, 5)
|
||||
sizer.Add(btnsizer, 0, wx.ALL, 5)
|
||||
panel.SetSizer(sizer)
|
||||
self.SetClientSize(sizer.CalcMin())
|
||||
|
||||
def get_user(self):
|
||||
return self.cb.GetValue()
|
||||
|
||||
def get_buffer_type(self):
|
||||
if self.audio.GetValue() == True:
|
||||
return "audio"
|
@ -10,7 +10,8 @@ class mainWindow(wx.Frame):
|
||||
buffer = wx.Menu()
|
||||
self.new_buffer = wx.Menu()
|
||||
self.search_audios = self.new_buffer.Append(wx.NewId(), _(u"Audio"))
|
||||
buffer.AppendMenu(wx.NewId(), _(u"New buffer"), self.new_buffer)
|
||||
buffer.AppendMenu(wx.NewId(), _(u"Search"), self.new_buffer)
|
||||
self.timeline = buffer.Append(wx.NewId(), _(u"&New timeline"))
|
||||
self.update_buffer = buffer.Append(wx.NewId(), _(u"Update current buffer"))
|
||||
self.load_previous_items = buffer.Append(wx.NewId(), _(u"Load previous items"))
|
||||
self.remove_buffer_ = buffer.Append(wx.NewId(), _(u"&Remove buffer"))
|
||||
|
Loading…
Reference in New Issue
Block a user