From 75dfaec727a621a4c2a1f9aebf8276adda4404a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Wed, 18 Mar 2015 11:45:39 -0600 Subject: [PATCH] Basic conversation support, a jaws fix --- src/accessible_output2/outputs/jaws.py | 2 +- src/app-configuration.defaults | 1 + src/controller/buffersController.py | 30 +++++++++++++++++++++++++- src/controller/mainController.py | 12 +++++++++++ src/keystrokeEditor/constants.py | 1 + src/multiplatform_widgets/widgets.py | 4 +++- src/wxUI/buffers/base.py | 3 ++- src/wxUI/view.py | 2 ++ 8 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/accessible_output2/outputs/jaws.py b/src/accessible_output2/outputs/jaws.py index 90f34fbc..14e9d834 100644 --- a/src/accessible_output2/outputs/jaws.py +++ b/src/accessible_output2/outputs/jaws.py @@ -22,7 +22,7 @@ class Jaws (Output): self.object.RunFunction("BrailleString(\"%s\")" % text) def speak(self, text, interrupt=False): - self.object.SayString(' %s' % text, interrupt) + self.object.SayString(' %s' % text, True) def is_active(self): try: diff --git a/src/app-configuration.defaults b/src/app-configuration.defaults index b276ef64..07fbe10e 100644 --- a/src/app-configuration.defaults +++ b/src/app-configuration.defaults @@ -18,6 +18,7 @@ left = string(default="control+win+left") right = string(default="control+win+right") next_account = string(default="control+win+shift+right") previous_account = string(default="control+win+shift+left") +open_conversation = string(default="control+win+c") conversation_up = string(default="control+win+shift+up") conversation_down = string(default="control+win+shift+down") show_hide = string(default="control+win+m") diff --git a/src/controller/buffersController.py b/src/controller/buffersController.py index f64e1ba2..f86dfeef 100644 --- a/src/controller/buffersController.py +++ b/src/controller/buffersController.py @@ -691,4 +691,32 @@ class trendsBufferController(bufferController): return False def url(self, *args, **kwargs): - self.searchfunction(value=self.get_message()) \ No newline at end of file + self.searchfunction(value=self.get_message()) + +class conversationBufferController(searchBufferController): + + def start_stream(self, start=False): + if start == True: + self.statuses = [] + self.ids = [] + self.statuses.append(self.tweet) + self.ids.append(self.tweet["id"]) + tweet = self.tweet + while tweet["in_reply_to_status_id"] != None: + tweet = self.session.twitter.twitter.show_status(id=tweet["in_reply_to_status_id"]) + self.statuses.insert(0, tweet) + self.ids.append(tweet["id"]) + if tweet["in_reply_to_status_id"] == None: + self.kwargs["since_id"] = tweet["id"] + self.ids.append(tweet["id"]) + val2 = getattr(self.session.twitter.twitter, self.function)(*self.args, **self.kwargs) + for i in val2["statuses"]: + if i["in_reply_to_status_id"] in self.ids: + self.statuses.append(i) + self.ids.append(i["id"]) + tweet = i + number_of_items = self.session.order_buffer(self.name, self.statuses) + log.debug("Number of items retrieved: %d" % (number_of_items,)) + self.put_items_on_list(number_of_items) + if number_of_items > 0: + self.session.sound.play("search_updated.ogg") diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 878b6e59..7ffa13c8 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -649,6 +649,18 @@ class Controller(object): else: commonMessageDialogs.user_not_exist() + def open_conversation(self, *args, **kwargs): + buffer = self.get_current_buffer() + id = buffer.get_right_tweet()["id_str"] + user = buffer.get_right_tweet()["user"]["screen_name"] + search = buffersController.conversationBufferController(self.view.nb, "search", "%s-searchterm" % (id,), buffer.session, buffer.session.db["user_name"], bufferType="searchPanel", since_id=id, q="@{0}".format(user,), count=100) + search.tweet = buffer.get_right_tweet() + search.start_stream(start=True) + self.buffers.append(search) + self.view.insert_buffer(search.buffer, name=_(u"Conversation with {0}".format(user)), pos=self.view.search("searches", buffer.session.db["user_name"])) + search.timer = RepeatingTimer(300, search.start_stream) + search.timer.start() + def show_hide(self, *args, **kwargs): km = self.create_invisible_keyboard_shorcuts() if self.showing == True: diff --git a/src/keystrokeEditor/constants.py b/src/keystrokeEditor/constants.py index 6373c4da..b07e7571 100644 --- a/src/keystrokeEditor/constants.py +++ b/src/keystrokeEditor/constants.py @@ -47,4 +47,5 @@ actions = { "reverse_geocode": _(u"Get location of any tweet"), "view_reverse_geocode": _(u"Displays the tweet's location in a dialog"), "get_trending_topics": _(u"Creates a buffer for displaying trends for a desired place"), +"open_conversation": _(u"Opens up a conversation buffer"), } \ No newline at end of file diff --git a/src/multiplatform_widgets/widgets.py b/src/multiplatform_widgets/widgets.py index 97dd71c2..8cc01fc2 100644 --- a/src/multiplatform_widgets/widgets.py +++ b/src/multiplatform_widgets/widgets.py @@ -21,7 +21,9 @@ class list(object): self.list.SetColumnWidth(column, x) def set_size(self): - self.list.SetSize(self.list.GetBestSize()) +# self.list.SetSize(self.list.GetBestSize()) +# print self.list.GetBestSize() + self.list.SetSize((1439, 1000)) def create_list(self, parent): if self.system == "Windows": diff --git a/src/wxUI/buffers/base.py b/src/wxUI/buffers/base.py index f87319be..19d3e0ef 100644 --- a/src/wxUI/buffers/base.py +++ b/src/wxUI/buffers/base.py @@ -28,8 +28,9 @@ class basePanel(wx.Panel): btnSizer.Add(self.reply, 0, wx.ALL, 5) btnSizer.Add(self.dm, 0, wx.ALL, 5) self.sizer.Add(btnSizer, 0, wx.ALL, 5) - self.sizer.Add(self.list.list, 0, wx.ALL, 5) + self.sizer.Add(self.list.list, 0, wx.ALL|wx.EXPAND, 5) self.SetSizer(self.sizer) + self.SetClientSize(self.sizer.CalcMin()) def set_position(self, reversed=False): if reversed == False: diff --git a/src/wxUI/view.py b/src/wxUI/view.py index e4db5bef..5599e1a0 100644 --- a/src/wxUI/view.py +++ b/src/wxUI/view.py @@ -132,6 +132,8 @@ class mainFrame(wx.Frame): def prepare(self): self.sizer.Add(self.nb, 0, wx.ALL, 5) self.panel.SetSizer(self.sizer) +# self.Maximize() + self.sizer.Layout() self.SetClientSize(self.sizer.CalcMin()) def search(self, name_, account):