The systray module has been added

This commit is contained in:
Manuel Cortez 2015-03-12 05:17:59 -06:00
parent d4fc809169
commit e63db7b150
4 changed files with 40 additions and 36 deletions

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
import application
from wxUI import (view, dialogs, commonMessageDialogs)
from wxUI import (view, dialogs, commonMessageDialogs, sysTrayIcon)
from twitter import utils
from sessionmanager import manager, sessionManager
@ -155,6 +155,27 @@ class Controller(object):
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.toggle_autoread, menuitem=self.view.autoread)
widgetUtils.connect_event(self.view.nb, widgetUtils.NOTEBOOK_PAGE_CHANGED, self.buffer_changed)
def set_systray_icon(self):
self.systrayIcon = sysTrayIcon.SysTrayIcon()
widgetUtils.connect_event(self.systrayIcon, widgetUtils.MENU, self.post_tweet, menuitem=self.systrayIcon.tweet)
widgetUtils.connect_event(self.systrayIcon, widgetUtils.MENU, self.configuration, menuitem=self.systrayIcon.global_settings)
widgetUtils.connect_event(self.systrayIcon, widgetUtils.MENU, self.accountConfiguration, menuitem=self.systrayIcon.account_settings)
widgetUtils.connect_event(self.systrayIcon, widgetUtils.MENU, self.update_profile, menuitem=self.systrayIcon.update_profile)
widgetUtils.connect_event(self.systrayIcon, widgetUtils.MENU, self.show_hide, menuitem=self.systrayIcon.show_hide)
widgetUtils.connect_event(self.systrayIcon, widgetUtils.MENU, self.check_for_updates, menuitem=self.systrayIcon.check_for_updates)
widgetUtils.connect_event(self.systrayIcon, widgetUtils.MENU, self.exit, menuitem=self.systrayIcon.exit)
widgetUtils.connect_event(self.systrayIcon, widgetUtils.TASKBAR_LEFT_CLICK, self.taskbar_left_click)
widgetUtils.connect_event(self.systrayIcon, widgetUtils.TASKBAR_RIGHT_CLICK, self.taskbar_right_click)
def taskbar_left_click(self, *args, **kwargs):
if self.showing == True:
self.view.set_focus()
else:
self.show_hide()
def taskbar_right_click(self, *args, **kwargs):
self.systrayIcon.show_menu()
def __init__(self):
super(Controller, self).__init__()
# Visibility state.
@ -172,6 +193,7 @@ class Controller(object):
self.view.prepare()
self.bind_stream_events()
self.bind_other_events()
self.set_systray_icon()
def check_invisible_at_startup(self):
# Visibility check
@ -407,12 +429,6 @@ class Controller(object):
buff.session.settings.write()
restart.restart_program()
def update_profile(self):
pass
def show_document(self, document):
pass
def report_error(self):
pass
@ -421,9 +437,6 @@ class Controller(object):
if update == False:
view.no_update_available()
def show_details_for_user(self, user):
pass
def delete(self, *args, **kwargs):
""" Deletes an item in the current buffer.
Users can only remove their tweets and direct messages, other users' tweets and people (followers, friends, blocked, etc) can not be removed using this method."""
@ -452,6 +465,7 @@ class Controller(object):
session_.sessions[item].main_stream.disconnect()
session_.sessions[item].timelinesStream.disconnect()
session_.sessions[item].sound.cleaner.cancel()
self.systrayIcon.Destroy()
widgetUtils.exit_application()
def follow(self, *args, **kwargs):

View File

@ -26,6 +26,8 @@ KEYPRESS = wx.EVT_CHAR_HOOK
KEYUP = wx.EVT_KEY_UP
NOTEBOOK_PAGE_CHANGED = wx.EVT_TREEBOOK_PAGE_CHANGED
RADIOBUTTON = wx.EVT_RADIOBUTTON
TASKBAR_RIGHT_CLICK = wx.EVT_TASKBAR_RIGHT_DOWN
TASKBAR_LEFT_CLICK = wx.EVT_TASKBAR_LEFT_DOWN
def exit_application():
""" Closes the current window cleanly. """
wx.GetApp().ExitMainLoop()

View File

@ -25,38 +25,24 @@ import os
class SysTrayIcon(wx.TaskBarIcon):
def __init__(self, frame):
def __init__(self):
super(SysTrayIcon, self).__init__()
self.frame=frame
icon=wx.Icon(os.path.join(paths.app_path(), "icon.ico"), wx.BITMAP_TYPE_ICO)
self.SetIcon(icon, application.name)
self.menu=wx.Menu()
item=self.menu.Append(wx.ID_ANY, _(u"Tweet"))
self.Bind(wx.EVT_MENU, frame.compose, item)
item=self.menu.Append(wx.ID_ANY, _(u"Preferences"))
self.Bind(wx.EVT_MENU, frame.preferences, item)
item=self.menu.Append(wx.ID_ANY, _(u"Update profile"))
self.Bind(wx.EVT_MENU, frame.update_profile, item)
item=self.menu.Append(wx.ID_ANY, _(u"Show / hide"))
self.Bind(wx.EVT_MENU, frame.show_hide, item)
item=self.menu.Append(wx.ID_ANY, _(u"Documentation"))
self.Bind(wx.EVT_MENU, frame.onManual, item)
item=self.menu.Append(wx.ID_ANY, _(u"Check for updates"))
self.Bind(wx.EVT_MENU, frame.onCheckForUpdates, item)
item=self.menu.Append(wx.ID_ANY, _(u"Exit"))
self.Bind(wx.EVT_MENU, frame.close, item)
self.Bind(wx.EVT_TASKBAR_RIGHT_DOWN, self.onRightClick)
self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.onLeftClick)
self.tweet = self.menu.Append(wx.ID_ANY, _(u"Tweet"))
self.global_settings = self.menu.Append(wx.ID_ANY, _(u"Global settings"))
self.account_settings = self.menu.Append(wx.ID_ANY, _(u"Account settings"))
self.update_profile = self.menu.Append(wx.ID_ANY, _(u"Update profile"))
self.show_hide = self.menu.Append(wx.ID_ANY, _(u"Show / hide"))
self.doc = self.menu.Append(wx.ID_ANY, _(u"Documentation"))
self.doc.Enable(False)
self.check_for_updates = self.menu.Append(wx.ID_ANY, _(u"Check for updates"))
self.exit = self.menu.Append(wx.ID_ANY, _(u"Exit"))
def onRightClick(self, evt):
def show_menu(self):
self.PopupMenu(self.menu)
def onLeftClick(self, evt):
if (self.frame.showing):
self.frame.SetFocus()
else:
self.frame.onShow_hide()
def Destroy(self):
self.menu.Destroy()
super(SysTrayIcon, self).Destroy()
super(SysTrayIcon, self).Destroy()

View File

@ -178,6 +178,8 @@ class mainFrame(wx.Frame):
# info.SetLicence(application.licence)
info.AddDeveloper(application.author)
wx.AboutBox(info)
def set_focus(self):
self.SetFocus()
def no_update_available():
wx.MessageDialog(None, _(u"Your TW Blue version is up to date"), _(u"Update"), style=wx.OK).ShowModal()