2
# -*- coding: utf-8 -*-
4
# Copyright (C) 2008 Nicolas Lécureuil <neoclust@mandriva.org>
5
# Copyright (C) 2008 Helio Chissini de Castro <helio@mandriva.com>
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2, or (at your option)
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
# TODO : Add a configuration windows to allow to change name or plugins before launching
22
# the server and save a configuration file in ~/.coherence
23
# Use the name and the plugin given as commandline arguments
33
from pkg_resources import resource_filename
34
icon = resource_filename(__name__, '../../misc/Desktop Applet/tango-system-file-manager.png')
35
# this ../.. is evil, I know :-(
36
# there must be a better way
37
if not os.path.exists(icon):
38
icon = "/usr/share/icons/coherence/tango-system-file-manager.png"
40
from PyQt4.QtGui import *
41
from PyQt4.QtCore import *
42
from PyQt4 import QtCore
57
host = socket.gethostname()
58
user = os.environ["USER"]
60
if os.path.isfile( confFile ):
61
proc = subprocess.Popen(["/usr/bin/coherence"])
63
proc = subprocess.Popen(["/usr/bin/coherence","--plugin=backend:FSStore,name:%s@%s" % ( user, host )])
64
startAction.setDisabled(1)
65
stopAction.setDisabled(0)
70
os.kill( proc.pid, signal.SIGTERM )
71
stopAction.setDisabled(1)
72
startAction.setDisabled(0)
79
if __name__ == "__main__":
80
app = QApplication(sys.argv)
84
startAction = menu.addAction('Start Coherence Server')
85
stopAction = menu.addAction('Stop Coherence Server')
86
quitAction = menu.addAction('Quit')
88
systrayIcon = QString(icon)
89
icon = QIcon(systrayIcon)
90
quitAction.connect( quitAction, SIGNAL("triggered()"), quitApplet)
91
quitAction.connect( quitAction, SIGNAL("triggered()"), app, QtCore.SLOT("quit()"))
92
startAction.connect( startAction, SIGNAL("triggered()"), startCoherence)
93
stopAction.connect( stopAction, SIGNAL("triggered()"), stopCoherence)
94
stopAction.setDisabled(1)
96
tray = QSystemTrayIcon(icon)
97
if (tray.isSystemTrayAvailable()):
98
tray.setContextMenu(menu)
100
tray.setToolTip("Coherence control Applet")
102
sys.exit(app.exec_())