1
# Copyright (c) 2007 Neil Jagdish Patel <njpatel@gmail.com>
2
# Copyright (c) 2008 Mark Lee <avant-wn@lazymalevolence.com>
4
# This library is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU Lesser General Public
6
# License as published by the Free Software Foundation; either
7
# version 2 of the License, or (at your option) any later version.
9
# This library is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
# Lesser General Public License for more details.
14
# You should have received a copy of the GNU Lesser General Public
15
# License along with this library; if not, write to the
16
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
# Boston, MA 02111-1307, USA.
19
# -*- Mode: Python; py-indent-offset: 4 -*-
24
# load the required modules:
25
import gobject as _gobject
27
ver = getattr(_gobject, 'pygobject_version', ())
29
raise ImportError("PyGTK requires PyGObject 2.11.1 or higher, but %s was found" % (ver,))
33
CONFIG_LIST_BOOL, CONFIG_LIST_FLOAT, CONFIG_LIST_INT, CONFIG_LIST_STRING = range(4)
34
CONFIG_DEFAULT_GROUP = 'DEFAULT'
48
opts, args = getopt.getopt (argv, "u:w:o:h:",
49
["uid=", "window=", "orient=", "height="])
50
except getopt.GetoptError:
51
print ("Unable to parse args")
55
if opt in ("-u", "--uid"):
57
#print "uid = " + arg + " " + str (type (uid))
58
elif opt in ("-w", "--window"):
60
#print "window = " + arg+ " " + str (type (window))
61
elif opt in ("-o", "--orient"):
63
#print "orient = " + arg + " " + str (type (orient))
64
elif opt in ("-h", "--height"):
66
#print "height = " + arg + " " + str (type (height))
68
def init_applet (applet):
73
plug = awn.Plug (applet)
76
plug.construct (window)
81
def check_dependencies(scope, *modules):
82
not_found_modules = []
83
for module in modules:
85
scope[module] = __import__(module, scope)
87
not_found_modules.append(module)
88
if len(not_found_modules) > 0:
96
msg = 'The following Python modules could not be found: %s. There are a few possible explanations for this:\n' % (', '.join(not_found_modules))
97
msg += '1. You do not have this Python module installed. In this case, you should visit the AWN wiki\'s applets section to figure out the exact name of the package for your distribution that provides this module.\n'
98
msg += '2. The module is installed in a non-standard location. This is usually the case when you manually install a package, that is, not via your distribution\'s package manager. This situation is explained in the FAQ section of the wiki.'
99
dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_NONE, msg)
100
dialog.add_button('AWN Wiki', RESPONSE_WIKI).grab_default()
101
dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
102
dialog.set_alternative_button_order([gtk.RESPONSE_OK, RESPONSE_WIKI])
103
if dialog.run() == RESPONSE_WIKI:
104
url = 'http://wiki.awn-project.org/'
106
if hasattr(webbrowser, 'open_new_tab'):
107
webbrowser.open_new_tab(url)
109
webbrowser.open_new(url)
113
sys.exit(RESPONSE_WIKI)
116
def __init__(self, group, key):
117
self.fd = config_key_lock_open(group, key)
119
def lock(self, operation):
120
config_key_lock(self.fd, operation)
123
config_key_lock_close(self.fd)