Fixed list buffer creation

This commit is contained in:
Manuel Cortez 2022-11-15 13:31:11 -06:00
parent 2e8c8c6db4
commit f5328379e8
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
3 changed files with 9 additions and 5 deletions

View File

@ -300,6 +300,8 @@ class Controller(object):
def create_buffer(self, buffer_type="baseBuffer", session_type="twitter", buffer_title="", parent_tab=None, start=False, kwargs={}): def create_buffer(self, buffer_type="baseBuffer", session_type="twitter", buffer_title="", parent_tab=None, start=False, kwargs={}):
log.debug("Creating buffer of type {0} with parent_tab of {2} arguments {1}".format(buffer_type, kwargs, parent_tab)) log.debug("Creating buffer of type {0} with parent_tab of {2} arguments {1}".format(buffer_type, kwargs, parent_tab))
if kwargs.get("parent") == None:
kwargs["parent"] = self.view.nb
if not hasattr(buffers, session_type): if not hasattr(buffers, session_type):
raise AttributeError("Session type %s does not exist yet." % (session_type)) raise AttributeError("Session type %s does not exist yet." % (session_type))
available_buffers = getattr(buffers, session_type) available_buffers = getattr(buffers, session_type)
@ -458,7 +460,8 @@ class Controller(object):
buffer = self.get_best_buffer() buffer = self.get_best_buffer()
handler = self.get_handler(type=buffer.session.type) handler = self.get_handler(type=buffer.session.type)
if handler != None and hasattr(handler, "list_manager"): if handler != None and hasattr(handler, "list_manager"):
return handler.list_manager(session=buffer.session) lists_buffer_position = self.view.search("lists", buffer.session.get_name())
return handler.list_manager(session=buffer.session, lists_buffer_position=lists_buffer_position)
def configuration(self, *args, **kwargs): def configuration(self, *args, **kwargs):
""" Opens the global settings dialogue.""" """ Opens the global settings dialogue."""

View File

@ -155,8 +155,8 @@ class Handler(object):
output.speak("error %s" % (str(e))) output.speak("error %s" % (str(e)))
log.exception("error %s" % (str(e))) log.exception("error %s" % (str(e)))
def list_manager(self, session): def list_manager(self, session, lists_buffer_position):
return lists.listsController(session=session) return lists.listsController(session=session, lists_buffer_position=lists_buffer_position)
def account_settings(self, buffer, controller): def account_settings(self, buffer, controller):
d = settings.accountSettingsController(buffer, controller) d = settings.accountSettingsController(buffer, controller)

View File

@ -10,9 +10,10 @@ from pubsub import pub
log = logging.getLogger("controller.listsController") log = logging.getLogger("controller.listsController")
class listsController(object): class listsController(object):
def __init__(self, session, user=None): def __init__(self, session, user=None, lists_buffer_position=0):
super(listsController, self).__init__() super(listsController, self).__init__()
self.session = session self.session = session
self.lists_buffer_position = lists_buffer_position
if user == None: if user == None:
self.dialog = lists.listViewer() self.dialog = lists.listViewer()
self.dialog.populate_list(self.get_all_lists()) self.dialog.populate_list(self.get_all_lists())
@ -90,7 +91,7 @@ class listsController(object):
def open_list_as_buffer(self, *args, **kwargs): def open_list_as_buffer(self, *args, **kwargs):
if self.dialog.lista.get_count() == 0: return if self.dialog.lista.get_count() == 0: return
list = self.session.db["lists"][self.dialog.get_item()] list = self.session.db["lists"][self.dialog.get_item()]
pub.sendMessage("create-new-buffer", buffer="list", account=self.session.db["user_name"], create=list.name) pub.sendMessage("createBuffer", buffer_type="ListBuffer", session_type=self.session.type, buffer_title=_("List for {}").format(list.name), parent_tab=self.lists_buffer_position, start=True, kwargs=dict(function="list_timeline", name="%s-list" % (list.name,), sessionObject=self.session, account=self.session.get_name(), bufferType=None, sound="list_tweet.ogg", list_id=list.id, include_ext_alt_text=True, tweet_mode="extended"))
def subscribe(self, *args, **kwargs): def subscribe(self, *args, **kwargs):
if self.dialog.lista.get_count() == 0: return if self.dialog.lista.get_count() == 0: return