1
# -*- coding: utf-8 -*-
3
# Authors: Roberto Alsina <roberto.alsina@canonical.com>
5
# Copyright 2011 Canonical Ltd.
7
# This program is free software: you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License version 3, as published
9
# by the Free Software Foundation.
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranties of
13
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
# PURPOSE. See the GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License along
17
# with this program. If not, see <http://www.gnu.org/licenses/>.
18
"""System notification area icon."""
20
from PyQt4 import QtGui
23
class TrayIcon(QtGui.QSystemTrayIcon):
25
"""System notification icon."""
27
def __init__(self, window=None):
28
super(TrayIcon, self).__init__(None)
29
self.setIcon(QtGui.QIcon(":/u1icon.png"))
32
self.activated.connect(self.on_activated)
33
self.context_menu = QtGui.QMenu()
34
self.restore = QtGui.QAction("Restore", self,
35
triggered=self.restore_window)
36
self.quit = QtGui.QAction("Quit Ubuntu One", self,
38
self.context_menu.addAction(self.restore)
39
self.context_menu.addSeparator()
40
self.context_menu.addAction(self.quit)
41
self.setContextMenu(self.context_menu)
43
def on_activated(self, reason):
44
"""The user activated the icon."""
45
if reason == self.Trigger: # Left-click
48
def restore_window(self):
49
"""Show the main window."""
50
if self.window is None:
51
# pylint: disable=W0404
52
from ubuntuone.controlpanel.gui.qt.gui import MainWindow
53
# pylint: enable=W0404
54
self.window = MainWindow(close_callback=self.delete_window)
57
def delete_window(self):
58
"""Close and remove the main window."""
59
if self.window is not None:
64
"""Stop the application."""
65
# pylint: disable=W0404
66
from twisted.internet import reactor
67
# pylint: enable=W0404