Opening lists as a buffer is now possible from the list manager

This commit is contained in:
Manuel Cortez 2015-06-05 05:21:49 -05:00
parent f09ff43672
commit 83575b14b9
2 changed files with 18 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import output
from wxUI.dialogs import lists
from twython import TwythonError
from twitter import compose, utils
from pubsub import pub
class listsController(object):
def __init__(self, session, user=None):
@ -14,6 +15,7 @@ class listsController(object):
self.dialog.populate_list(self.get_all_lists())
widgetUtils.connect_event(self.dialog.createBtn, widgetUtils.BUTTON_PRESSED, self.create_list)
widgetUtils.connect_event(self.dialog.editBtn, widgetUtils.BUTTON_PRESSED, self.edit_list)
widgetUtils.connect_event(self.dialog.view, widgetUtils.BUTTON_PRESSED, self.open_list_as_buffer)
self.dialog.get_response()
def get_all_lists(self):
@ -67,3 +69,8 @@ class listsController(object):
self.dialog.lista.remove_item(self.dialog.get_item())
except TwythonError as e:
output.speak("error %s: %s" % (e.error_code, e.msg))
def open_list_as_buffer(self, *args, **kwargs):
if self.dialog.lista.get_count() == 0: return
list = self.session.db["lists"][self.dialog.get_item()]
pub.sendMessage("create-new-buffer", buffer="list", account=self.session.db["user_name"], create=list["slug"])

View File

@ -1197,6 +1197,17 @@ class Controller(object):
self.view.insert_buffer(events.buffer, name=_(u"Events"), pos=self.view.search(buff.session.db["user_name"], buff.session.db["user_name"]))
elif create == False:
self.destroy_buffer(buffer, buff.session.db["user_name"])
elif buffer == "list":
if create in buff.session.settings["other_buffers"]["lists"]:
output.speak(_(u"This list is already opened"), True)
return
tl = buffersController.listBufferController(self.view.nb, "get_list_statuses", create+"-list", buff.session, buff.session.db["user_name"], bufferType=None, list_id=utils.find_list(create, buff.session.db["lists"]))
buff.session.lists.append(tl)
self.buffers.append(tl)
self.view.insert_buffer(tl.buffer, name=_(u"List for {}").format(create), pos=self.view.search("lists", buff.session.db["user_name"]))
tl.start_stream()
buff.session.settings["other_buffers"]["lists"].append(create)
pub.sendMessage("restart-streams", streams=["timelinesStream"], session=buff.session)
def restart_streams(self, streams=[], session=None):
for i in streams: