Putting all the code from the current master branch of TWBlue

This commit is contained in:
2014-10-27 16:29:04 -06:00
parent 58c82e5486
commit 1af4a8b291
284 changed files with 58760 additions and 0 deletions

View File

View File

@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
actions = {
"up": _(u"Go up up on the current list"),
"down": _(u"Go down up on the current list"),
"left": _(u"Go to the previous tab"),
"right": _(u"Go to the next tab"),
"conversation_up": _(u"Move up one tweet in the conversation"),
"conversation_down": _(u"Move down one tweet in the conversation"),
"show_hide": _(u"Show the graphical interface"),
"compose": _(u"New tweet"),
"reply": _(u"Reply to a tweet"),
"retweet": _(u"Retweet"),
"dm": _(u"Send direct message"),
"fav": _(u"Mark as favourite"),
"unfav": _(u"Remove from favourites"),
"action": _(u"Open the actions dialogue"),
"details": _(u"See user details"),
"view": _(u"Show tweet"),
"close": _(u"Quit"),
"open_timeline": _(u"Open user timeline"),
"delete_buffer": _(u"Remove buffer"),
"url": _(u"Open URL on the current tweet, or further information for a friend or follower"),
"audio": _(u"Attempt to play audio"),
"volume_up": _(u"Increase volume by 5%"),
"volume_down": _(u"Decrease volume by 5%"),
"go_home": _(u"Go to the first element on the list"),
"go_end": _(u"Go to the last element on the list"),
"go_page_up": _(u"Move 20 elements up on the current list"),
"go_page_down": _(u"Move 20 elements down on the current list"),
"update_profile": _(u"Edit profile"),
"delete": _(u"Remove a tweet or direct message"),
"clear_list": _(u"Empty the buffer removing all the elements"),
"repeat_item": _(u"Listen the current message"),
"copy_to_clipboard": _(u"Copy to clipboard"),
"add_to_list": _(u"Add to list"),
"remove_from_list": _(u"Remove from list"),
"toggle_mute": _(u"Mutes/unmutes the active buffer"),
"toggle_global_mute": _(u"Globally mute/unmute TW Blue"),
"toggle_autoread": _(u"toggles the automatic reading of incoming tweets in the active buffer"),
"search": _(u"Search on twitter"),
"edit_keystrokes": _(u"Shows the keystroke editor"),
"view_user_lists": _(u"Show lists for a specified user"),
}

119
src/keystrokeEditor/gui.py Normal file
View File

@@ -0,0 +1,119 @@
# -*- coding: utf-8 -*-
import config
import wx
import constants
from multiplatform_widgets import widgets
from constants import actions
class keystrokeEditor(wx.Dialog):
def __init__(self, parent=None, keyboard_handler=None):
super(keystrokeEditor, self).__init__(parent=parent, id=-1, title=_(u"Keystroke editor"))
panel = wx.Panel(self)
self.parent = parent
self.keyboard_handler = keyboard_handler or None
self.actions = []
sizer = wx.BoxSizer(wx.VERTICAL)
keysText = wx.StaticText(panel, -1, _(u"Select a keystroke to edit"))
self.keys = widgets.list(self, _(u"Action"), _(u"Keystroke"), style=wx.LC_REPORT|wx.LC_SINGLE_SEL, size=(400, 450))
self.keys.list.SetFocus()
firstSizer = wx.BoxSizer(wx.HORIZONTAL)
firstSizer.Add(keysText)
firstSizer.Add(self.keys.list)
edit = wx.Button(panel, -1, _(u"Edit"))
self.Bind(wx.EVT_BUTTON, self.edit, edit)
edit.SetDefault()
close = wx.Button(panel, wx.ID_CANCEL, _(u"Close"))
secondSizer = wx.BoxSizer(wx.HORIZONTAL)
secondSizer.Add(edit)
secondSizer.Add(close)
sizer.Add(firstSizer)
sizer.Add(secondSizer)
panel.SetSizerAndFit(sizer)
self.put_keystrokes()
def put_keystrokes(self):
for i in config.main["keymap"]:
action = actions[i]
self.actions.append(i)
keystroke = config.main["keymap"][i]
self.keys.insert_item(False, *[action, keystroke])
def edit(self, ev):
action = self.actions[self.keys.get_selected()]
dlg = editKeystroke(self.parent, action, config.main["keymap"][action], self.keyboard_handler)
if dlg.ShowModal() == wx.ID_OK:
pos = self.keys.get_selected()
self.keys.clear()
self.put_keystrokes()
self.keys.select_item(pos)
# dlg.Destroy()
class editKeystroke(wx.Dialog):
def __init__(self, parent, action, keystroke, keyboard_handler):
super(editKeystroke, self).__init__(parent=None, id=-1, title=_(u"Editing keystroke"))
self.parent = parent
self.keyboard_handler = keyboard_handler
self.action = action
self.keystroke = keystroke
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
self.control = wx.CheckBox(panel, -1, _(u"Control"))
self.alt = wx.CheckBox(panel, -1, _(u"Alt"))
self.shift = wx.CheckBox(panel, -1, _(u"Shift"))
self.win = wx.CheckBox(panel, -1, _(u"Windows"))
sizer1 = wx.BoxSizer(wx.HORIZONTAL)
sizer1.Add(self.control)
sizer1.Add(self.alt)
sizer1.Add(self.shift)
sizer1.Add(self.win)
charLabel = wx.StaticText(panel, -1, _(u"Key"))
self.key = wx.TextCtrl(panel, -1)
# self.key.SetMaxLength(1)
sizer2 = wx.BoxSizer(wx.HORIZONTAL)
sizer2.Add(charLabel)
sizer2.Add(self.key)
ok = wx.Button(panel, wx.ID_OK, _(u"OK"))
ok.SetDefault()
self.Bind(wx.EVT_BUTTON, self.ok, ok)
cancel = wx.Button(panel, wx.ID_CANCEL)
sizer3 = wx.BoxSizer(wx.HORIZONTAL)
sizer3.Add(ok)
sizer3.Add(cancel)
sizer.Add(sizer1)
sizer.Add(sizer2)
sizer.Add(sizer3)
panel.SetSizerAndFit(sizer)
self.set_default()
def set_default(self):
for i in self.keystroke.split("+"):
if hasattr(self, i):
key = getattr(self, i)
key.SetValue(True)
self.key.SetValue(self.keystroke.split("+")[-1])
def ok(self, ev):
keys = []
if self.win.GetValue() == False:
wx.MessageDialog(self, _(u"You need to use the Windows key"), _(u"Invalid keystroke"), wx.OK|wx.ICON_ERROR).ShowModal()
return
if self.control.GetValue() == True:
keys.append("control")
if self.win.GetValue() == True:
keys.append("win")
if self.alt.GetValue() == True:
keys.append("alt")
if self.shift.GetValue() == True:
keys.append("shift")
if self.key.GetValue() != "":
keys.append(self.key.GetValue())
else:
wx.MessageDialog(self, _(u"You must provide a character for the keystroke"), _(u"Invalid keystroke"), wx.ICON_ERROR).ShowModal()
return
config.main["keymap"][self.action] = "+".join(keys)
if self.keyboard_handler != None:
self.keyboard_handler.unregister_key(self.keystroke, getattr(self.parent, self.action))
self.keyboard_handler.register_key(config.main["keymap"][self.action], getattr(self.parent, self.action))
self.EndModal(wx.ID_OK)