From 76a2b0b1ac94478c26b5fc0a5835327f8ccffac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Fri, 7 Nov 2014 13:29:44 -0600 Subject: [PATCH] Show total characters used in the title bar for tweets and messages --- src/gui/buffers/base.py | 6 ++--- src/gui/dialogs/message.py | 7 +++--- src/gui/dialogs/trending.py | 48 +++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 src/gui/dialogs/trending.py diff --git a/src/gui/buffers/base.py b/src/gui/buffers/base.py index e21ab242..2a14ed45 100644 --- a/src/gui/buffers/base.py +++ b/src/gui/buffers/base.py @@ -217,7 +217,7 @@ class basePanel(wx.Panel): self.onResponse(ev) else: user = self.db.settings[self.name_buffer][self.list.get_selected()]["user"]["screen_name"] - dlg = gui.dialogs.message.dm(_("Direct message to %s") % (user,), "", "", self) + dlg = gui.dialogs.message.dm(_("Direct message to %s") % (user,), _(u"New direct message"), "", self) if dlg.ShowModal() == wx.ID_OK: call_threaded(self.twitter.api_call, call_name="send_direct_message", _sound="dm_sent.ogg", text=dlg.text.GetValue(), screen_name=dlg.cb.GetValue()) # dlg.Destroy() @@ -240,7 +240,7 @@ class basePanel(wx.Panel): ask = wx.MessageDialog(self.parent, _(u"Would you like to add a comment to this tweet?"), _("Retweet"), wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION) response = ask.ShowModal() if response == wx.ID_YES: - dlg = gui.dialogs.message.retweet(_(u"Add your comment to the tweet"), "", u"“@%s: %s ”" % (self.db.settings[self.name_buffer][self.list.get_selected()]["user"]["screen_name"], self.db.settings[self.name_buffer][self.list.get_selected()]["text"]), self) + dlg = gui.dialogs.message.retweet(_(u"Add your comment to the tweet"), _(u"Retweet"), u"“@%s: %s ”" % (self.db.settings[self.name_buffer][self.list.get_selected()]["user"]["screen_name"], self.db.settings[self.name_buffer][self.list.get_selected()]["text"]), self) if dlg.ShowModal() == wx.ID_OK: if dlg.image == None: call_threaded(self.twitter.api_call, call_name="update_status", _sound="retweet_send.ogg", status=dlg.text.GetValue(), in_reply_to_status_id=dlg.in_reply_to) @@ -256,7 +256,7 @@ class basePanel(wx.Panel): def onResponse(self, ev): if self.name_buffer == "sent": return - dlg = gui.dialogs.message.reply(_(u"Reply to %s") % (self.db.settings[self.name_buffer][self.list.get_selected()]["user"]["screen_name"]), "", u"@%s " % (self.db.settings[self.name_buffer][self.list.get_selected()]["user"]["screen_name"]), self) + dlg = gui.dialogs.message.reply(_(u"Reply to %s") % (self.db.settings[self.name_buffer][self.list.get_selected()]["user"]["screen_name"]), _(u"Reply"), u"@%s " % (self.db.settings[self.name_buffer][self.list.get_selected()]["user"]["screen_name"]), self) if dlg.ShowModal() == wx.ID_OK: if dlg.image == None: call_threaded(self.twitter.api_call, call_name="update_status", _sound="reply_send.ogg", in_reply_to_status_id=dlg.in_reply_to, status=dlg.text.GetValue()) diff --git a/src/gui/dialogs/message.py b/src/gui/dialogs/message.py index 0820d37e..4c10b5ab 100644 --- a/src/gui/dialogs/message.py +++ b/src/gui/dialogs/message.py @@ -39,11 +39,12 @@ class textLimited(wx.Dialog): wx.Dialog.__init__(self, parent) self.twitter = parent.twitter self.parent = parent - self.SetTitle(_(u"New tweet")) + self.title = title + self.SetTitle(_(u"%s - %s of 140 characters") % (self.title, str(len(text)))) self.panel = wx.Panel(self) def createTextArea(self, message, text): - self.label = wx.StaticText(self.panel, -1, str(len(text))) + self.label = wx.StaticText(self.panel, -1, message) self.text = wx.TextCtrl(self.panel, -1, text) font = self.text.GetFont() dc = wx.WindowDC(self.text) @@ -139,7 +140,7 @@ class textLimited(wx.Dialog): self.text.SetFocus() def onTimer(self, ev): - self.label.SetLabel(str(len(self.text.GetValue()))) + self.SetTitle(_(u"%s - %s of 140 characters") % (self.title, str(len(self.text.GetValue())))) if len(self.text.GetValue()) > 1: self.shortenButton.Enable() self.unshortenButton.Enable() diff --git a/src/gui/dialogs/trending.py b/src/gui/dialogs/trending.py new file mode 100644 index 00000000..157ac85d --- /dev/null +++ b/src/gui/dialogs/trending.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +############################################################ +# Copyright (c) 2014 Manuel Eduardo Cortéz Vallejo +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################ +import wx + +class trendingTopicsDialog(wx.Dialog): + def __init__(self): + super(searchDialog, self).__init__(None, -1) + panel = wx.Panel(self) + sizer = wx.BoxSizer(wx.VERTICAL) + self.SetTitle(_(u"Search on Twitter")) + label = wx.StaticText(panel, -1, _(u"Search")) + self.term = wx.TextCtrl(panel, -1,) + dc = wx.WindowDC(self.term) + dc.SetFont(self.term.GetFont()) + self.term.SetSize(dc.GetTextExtent("0"*40)) + sizer.Add(label, 0, wx.ALL, 5) + sizer.Add(self.term, 0, wx.ALL, 5) + self.tweets = wx.RadioButton(panel, -1, _(u"Tweets"), style=wx.RB_GROUP) + self.users = wx.RadioButton(panel, -1, _(u"Users")) + radioSizer = wx.BoxSizer(wx.HORIZONTAL) + radioSizer.Add(self.tweets, 0, wx.ALL, 5) + radioSizer.Add(self.users, 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())