mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-23 03:38:08 -06:00
There is a context menu on buffers. When the applications key or the right mouse button is pressed that menu is displayed. It only works for the GUI
This commit is contained in:
parent
855cefeb8d
commit
2f7eb12104
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,12 +1,8 @@
|
|||||||
*.pyc
|
*.pyc
|
||||||
*~
|
*~
|
||||||
#windows-dependencies/*
|
|
||||||
src/build/
|
src/build/
|
||||||
src/dist/
|
src/dist/
|
||||||
src/config/
|
src/config/
|
||||||
src/config1/
|
|
||||||
src/config2/
|
|
||||||
src/config3/
|
|
||||||
src/dropbox/
|
src/dropbox/
|
||||||
src/logs/
|
src/logs/
|
||||||
src/documentation/
|
src/documentation/
|
||||||
|
@ -27,6 +27,7 @@ import logging as original_logger
|
|||||||
import output
|
import output
|
||||||
import platform
|
import platform
|
||||||
import datetime
|
import datetime
|
||||||
|
import menus
|
||||||
from twitter import prettydate
|
from twitter import prettydate
|
||||||
from multiplatform_widgets import widgets
|
from multiplatform_widgets import widgets
|
||||||
from mysc import event
|
from mysc import event
|
||||||
@ -39,6 +40,8 @@ class basePanel(wx.Panel):
|
|||||||
def bind_events(self):
|
def bind_events(self):
|
||||||
self.Bind(event.MyEVT_OBJECT, self.update)
|
self.Bind(event.MyEVT_OBJECT, self.update)
|
||||||
self.Bind(event.MyEVT_DELETED, self.Remove)
|
self.Bind(event.MyEVT_DELETED, self.Remove)
|
||||||
|
self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.showMenu, self.list.list)
|
||||||
|
self.Bind(wx.EVT_LIST_KEY_DOWN, self.showMenuByKey, self.list.list)
|
||||||
self.list.list.Bind(wx.EVT_CHAR_HOOK, self.interact)
|
self.list.list.Bind(wx.EVT_CHAR_HOOK, self.interact)
|
||||||
if self.system == "Windows":
|
if self.system == "Windows":
|
||||||
self.list.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.onFocus)
|
self.list.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.onFocus)
|
||||||
@ -369,3 +372,18 @@ class basePanel(wx.Panel):
|
|||||||
self.list.select_item(len(self.db.settings[self.name_buffer])-1)
|
self.list.select_item(len(self.db.settings[self.name_buffer])-1)
|
||||||
else:
|
else:
|
||||||
self.list.select_item(0)
|
self.list.select_item(0)
|
||||||
|
|
||||||
|
def showMenu(self, ev):
|
||||||
|
if self.list.get_count() == 0: return
|
||||||
|
if self.name_buffer == "sent":
|
||||||
|
self.PopupMenu(menus.sentPanelMenu(self), ev.GetPosition())
|
||||||
|
else:
|
||||||
|
self.PopupMenu(menus.basePanelMenu(self), ev.GetPosition())
|
||||||
|
|
||||||
|
def showMenuByKey(self, ev):
|
||||||
|
if self.list.get_count() == 0: return
|
||||||
|
if ev.GetKeyCode() == wx.WXK_WINDOWS_MENU:
|
||||||
|
if self.name_buffer == "sent":
|
||||||
|
self.PopupMenu(menus.sentPanelMenu(self), self.list.list.GetPosition())
|
||||||
|
else:
|
||||||
|
self.PopupMenu(menus.basePanelMenu(self), self.list.list.GetPosition())
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
import wx
|
import wx
|
||||||
import sound
|
import sound
|
||||||
import gui.dialogs
|
import gui.dialogs
|
||||||
|
import menus
|
||||||
import logging as original_logger
|
import logging as original_logger
|
||||||
from base import basePanel
|
from base import basePanel
|
||||||
from mysc.thread_utils import call_threaded
|
from mysc.thread_utils import call_threaded
|
||||||
@ -46,4 +47,13 @@ class dmPanel(basePanel):
|
|||||||
if dlg.ShowModal() == wx.ID_OK:
|
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())
|
call_threaded(self.twitter.api_call, call_name="send_direct_message", _sound="dm_sent.ogg", text=dlg.text.GetValue(), screen_name=dlg.cb.GetValue())
|
||||||
if ev != None:
|
if ev != None:
|
||||||
self.list.list.SetFocus()
|
self.list.list.SetFocus()
|
||||||
|
|
||||||
|
def showMenu(self, ev):
|
||||||
|
if self.list.get_count() == 0: return
|
||||||
|
self.PopupMenu(menus.dmPanelMenu(self), ev.GetPosition())
|
||||||
|
|
||||||
|
def showMenuByKey(self, ev):
|
||||||
|
if self.list.get_count() == 0: return
|
||||||
|
if ev.GetKeyCode() == wx.WXK_WINDOWS_MENU:
|
||||||
|
self.PopupMenu(menus.dmPanelMenu(self), self.list.list.GetPosition())
|
||||||
|
@ -21,6 +21,7 @@ import sound
|
|||||||
import config
|
import config
|
||||||
import platform
|
import platform
|
||||||
import gui.dialogs
|
import gui.dialogs
|
||||||
|
import menus
|
||||||
import output
|
import output
|
||||||
import logging as original_logger
|
import logging as original_logger
|
||||||
from multiplatform_widgets import widgets
|
from multiplatform_widgets import widgets
|
||||||
@ -36,6 +37,8 @@ class eventsPanel(wx.Panel):
|
|||||||
|
|
||||||
def bind_events(self):
|
def bind_events(self):
|
||||||
self.Bind(event.MyEVT_OBJECT, self.update)
|
self.Bind(event.MyEVT_OBJECT, self.update)
|
||||||
|
self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.showMenu, self.list.list)
|
||||||
|
self.Bind(wx.EVT_LIST_KEY_DOWN, self.showMenuByKey, self.list.list)
|
||||||
|
|
||||||
def put_items(self, items):
|
def put_items(self, items):
|
||||||
pass
|
pass
|
||||||
@ -131,4 +134,13 @@ class eventsPanel(wx.Panel):
|
|||||||
try:
|
try:
|
||||||
ev.Skip()
|
ev.Skip()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def showMenu(self, ev):
|
||||||
|
if self.list.get_count() == 0: return
|
||||||
|
self.PopupMenu(menus.eventsPanelMenu(self), ev.GetPosition())
|
||||||
|
|
||||||
|
def showMenuByKey(self, ev):
|
||||||
|
if self.list.get_count() == 0: return
|
||||||
|
if ev.GetKeyCode() == wx.WXK_WINDOWS_MENU:
|
||||||
|
self.PopupMenu(menus.eventsPanelMenu(self), self.list.list.GetPosition())
|
||||||
|
120
src/gui/buffers/menus.py
Normal file
120
src/gui/buffers/menus.py
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import wx
|
||||||
|
|
||||||
|
class basePanelMenu(wx.Menu):
|
||||||
|
def __init__(self, parent):
|
||||||
|
super(basePanelMenu, self).__init__()
|
||||||
|
self.window = parent
|
||||||
|
retweet = wx.MenuItem(self, wx.NewId(), _(u"&Retweet"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.onRetweet, retweet)
|
||||||
|
self.AppendItem(retweet)
|
||||||
|
reply = wx.MenuItem(self, wx.NewId(), _(u"Re&ply"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.onResponse, reply)
|
||||||
|
self.AppendItem(reply)
|
||||||
|
fav = wx.MenuItem(self, wx.NewId(), _(u"Add to &favourites"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.fav, fav)
|
||||||
|
self.AppendItem(fav)
|
||||||
|
unfav = wx.MenuItem(self, wx.NewId(), _(u"Remove from favo&urites"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.unfav, unfav)
|
||||||
|
self.AppendItem(unfav)
|
||||||
|
openUrl = wx.MenuItem(self, wx.NewId(), _(u"&Open URL"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.url, openUrl)
|
||||||
|
self.AppendItem(openUrl)
|
||||||
|
play = wx.MenuItem(self, wx.NewId(), _(u"&Play audio"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.audio, play)
|
||||||
|
self.AppendItem(play)
|
||||||
|
view = wx.MenuItem(self, wx.NewId(), _(u"&Show tweet"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.view, view)
|
||||||
|
self.AppendItem(view)
|
||||||
|
copy = wx.MenuItem(self, wx.NewId(), _(u"&Copy to clipboard"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.copy_to_clipboard, copy)
|
||||||
|
self.AppendItem(copy)
|
||||||
|
remove = wx.MenuItem(self, wx.NewId(), _(u"&Delete"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.delete, remove)
|
||||||
|
self.AppendItem(remove)
|
||||||
|
userActions = wx.MenuItem(self, wx.NewId(), _(u"&User actions..."))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.onFollow, userActions)
|
||||||
|
self.AppendItem(userActions)
|
||||||
|
|
||||||
|
class dmPanelMenu(wx.Menu):
|
||||||
|
def __init__(self, parent):
|
||||||
|
super(dmPanelMenu, self).__init__()
|
||||||
|
self.window = parent
|
||||||
|
reply = wx.MenuItem(self, wx.NewId(), _(u"Re&ply"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.onResponse, reply)
|
||||||
|
self.AppendItem(reply)
|
||||||
|
openUrl = wx.MenuItem(self, wx.NewId(), _(u"&Open URL"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.url, openUrl)
|
||||||
|
self.AppendItem(openUrl)
|
||||||
|
play = wx.MenuItem(self, wx.NewId(), _(u"&Play audio"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.audio, play)
|
||||||
|
self.AppendItem(play)
|
||||||
|
view = wx.MenuItem(self, wx.NewId(), _(u"&Show direct message"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.view, view)
|
||||||
|
self.AppendItem(view)
|
||||||
|
copy = wx.MenuItem(self, wx.NewId(), _(u"&Copy to clipboard"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.copy_to_clipboard, copy)
|
||||||
|
self.AppendItem(copy)
|
||||||
|
remove = wx.MenuItem(self, wx.NewId(), _(u"&Delete"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.delete, remove)
|
||||||
|
self.AppendItem(remove)
|
||||||
|
userActions = wx.MenuItem(self, wx.NewId(), _(u"&User actions..."))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.onFollow, userActions)
|
||||||
|
self.AppendItem(userActions)
|
||||||
|
|
||||||
|
class sentPanelMenu(wx.Menu):
|
||||||
|
def __init__(self, parent):
|
||||||
|
super(sentPanelMenu, self).__init__()
|
||||||
|
self.window = parent
|
||||||
|
openUrl = wx.MenuItem(self, wx.NewId(), _(u"&Open URL"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.url, openUrl)
|
||||||
|
self.AppendItem(openUrl)
|
||||||
|
play = wx.MenuItem(self, wx.NewId(), _(u"&Play audio"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.audio, play)
|
||||||
|
self.AppendItem(play)
|
||||||
|
view = wx.MenuItem(self, wx.NewId(), _(u"&Show tweet"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.view, view)
|
||||||
|
self.AppendItem(view)
|
||||||
|
copy = wx.MenuItem(self, wx.NewId(), _(u"&Copy to clipboard"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.copy_to_clipboard, copy)
|
||||||
|
self.AppendItem(copy)
|
||||||
|
remove = wx.MenuItem(self, wx.NewId(), _(u"&Delete"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.delete, remove)
|
||||||
|
self.AppendItem(remove)
|
||||||
|
|
||||||
|
class eventsPanelMenu(wx.Menu):
|
||||||
|
def __init__(self, parent):
|
||||||
|
super(eventsPanelMenu, self).__init__()
|
||||||
|
self.window = parent
|
||||||
|
view = wx.MenuItem(self, wx.NewId(), _(u"&Show event"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.view, view)
|
||||||
|
self.AppendItem(view)
|
||||||
|
copy = wx.MenuItem(self, wx.NewId(), _(u"&Copy to clipboard"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.copy_to_clipboard, copy)
|
||||||
|
self.AppendItem(copy)
|
||||||
|
remove = wx.MenuItem(self, wx.NewId(), _(u"&Delete"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.delete, remove)
|
||||||
|
self.AppendItem(remove)
|
||||||
|
|
||||||
|
class peoplePanelMenu(wx.Menu):
|
||||||
|
def __init__(self, parent):
|
||||||
|
super(peoplePanelMenu, self).__init__()
|
||||||
|
self.window = parent
|
||||||
|
reply = wx.MenuItem(self, wx.NewId(), _(u"&Mention"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.onResponse, reply)
|
||||||
|
self.AppendItem(reply)
|
||||||
|
lists = wx.MenuItem(self, wx.NewId(), _(u"&View lists"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.view_user_lists, lists)
|
||||||
|
self.AppendItem(lists)
|
||||||
|
details = wx.MenuItem(self, wx.NewId(), _(u"Show user &profile"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.details, details)
|
||||||
|
self.AppendItem(details)
|
||||||
|
view = wx.MenuItem(self, wx.NewId(), _(u"&Show user"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.view, view)
|
||||||
|
self.AppendItem(view)
|
||||||
|
copy = wx.MenuItem(self, wx.NewId(), _(u"&Copy to clipboard"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.copy_to_clipboard, copy)
|
||||||
|
self.AppendItem(copy)
|
||||||
|
userActions = wx.MenuItem(self, wx.NewId(), _(u"&User actions..."))
|
||||||
|
self.Bind(wx.EVT_MENU, self.window.parent.onFollow, userActions)
|
||||||
|
self.AppendItem(userActions)
|
@ -21,6 +21,7 @@ import sound
|
|||||||
import config
|
import config
|
||||||
import twitter
|
import twitter
|
||||||
import gui.dialogs
|
import gui.dialogs
|
||||||
|
import menus
|
||||||
import logging as original_logger
|
import logging as original_logger
|
||||||
import output
|
import output
|
||||||
from multiplatform_widgets import widgets
|
from multiplatform_widgets import widgets
|
||||||
@ -36,6 +37,8 @@ class peoplePanel(basePanel):
|
|||||||
self.Bind(event.MyEVT_OBJECT, self.update)
|
self.Bind(event.MyEVT_OBJECT, self.update)
|
||||||
self.Bind(event.MyEVT_DELETED, self.Remove)
|
self.Bind(event.MyEVT_DELETED, self.Remove)
|
||||||
self.list.list.Bind(wx.EVT_CHAR_HOOK, self.interact)
|
self.list.list.Bind(wx.EVT_CHAR_HOOK, self.interact)
|
||||||
|
self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.showMenu, self.list.list)
|
||||||
|
self.Bind(wx.EVT_LIST_KEY_DOWN, self.showMenuByKey, self.list.list)
|
||||||
|
|
||||||
def create_list(self):
|
def create_list(self):
|
||||||
self.list = widgets.list(self, _(u"User"), style=wx.LC_REPORT|wx.LC_SINGLE_SEL, size=(800, 800))
|
self.list = widgets.list(self, _(u"User"), style=wx.LC_REPORT|wx.LC_SINGLE_SEL, size=(800, 800))
|
||||||
@ -146,3 +149,12 @@ class peoplePanel(basePanel):
|
|||||||
else:
|
else:
|
||||||
list = self.compose_function(self.db.settings[self.name_buffer][self.list.get_selected()], self.db)
|
list = self.compose_function(self.db.settings[self.name_buffer][self.list.get_selected()], self.db)
|
||||||
return " ".join(list)
|
return " ".join(list)
|
||||||
|
|
||||||
|
def showMenu(self, ev):
|
||||||
|
if self.list.get_count() == 0: return
|
||||||
|
self.PopupMenu(menus.peoplePanelMenu(self), ev.GetPosition())
|
||||||
|
|
||||||
|
def showMenuByKey(self, ev):
|
||||||
|
if self.list.get_count() == 0: return
|
||||||
|
if ev.GetKeyCode() == wx.WXK_WINDOWS_MENU:
|
||||||
|
self.PopupMenu(menus.peoplePanelMenu(self), self.list.list.GetPosition())
|
||||||
|
Loading…
Reference in New Issue
Block a user