1
# Copyright (c) 2007 Neil Jagdish Patel <njpatel@gmail.com>
2
# Copyright (c) 2008, 2009 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 -*-
22
from gettext import gettext as _
26
# load the required modules:
29
_version = getattr(gobject, 'pygobject_version', ())
30
if _version < (2, 11, 1):
31
raise ImportError("Awn requires PyGObject >= 2.11.1, but %s was found" %
37
import desktopagnostic.vfs
44
LOCALEDIR = '@LOCALEDIR@'
45
TEXTDOMAIN = '@GETTEXT_PACKAGE@'
46
locale.bindtextdomain(TEXTDOMAIN, LOCALEDIR)
53
desktopagnostic.vfs.init()
56
opts, args = getopt.getopt(argv, "u:w:i:",
57
["uid=", "window=", "panel-id="])
58
except getopt.GetoptError:
59
print("Unable to parse args")
63
if opt in ("-u", "--uid"):
65
elif opt in ("-w", "--window"):
66
# casting to long because of
67
# http://bugzilla.gnome.org/show_bug.cgi?id=539365
69
elif opt in ("-i", "--panel-id"):
73
def embed_applet(applet):
74
gtk.Plug.__init__(applet, globals()['window'])
75
# applet's embedded signal handler automatically calls show_all()
78
def check_dependencies(scope, *modules, **choice_modules):
80
Special flag: exit_on_failure=bool
81
Makes the applet exit if a dependency is not found.
83
exit_on_failure = True
84
if len(choice_modules) > 0 and 'exit_on_failure' in choice_modules:
85
exit_on_failure = bool(choice_modules['exit_on_failure'])
86
del choice_modules['exit_on_failure']
87
not_found_modules = []
89
def add_module(module, name=None):
92
mod_split = module.split('.')
93
submod = mod_split[-1]
101
scope[name] = __import__(module, scope, locals(), from_list)
105
for module in modules:
106
success = add_module(module)
108
not_found_modules.append(module)
109
for name, mods in choice_modules.iteritems():
112
success = add_module(module, name)
117
not_found_modules.append(' or '.join(mods))
118
if len(not_found_modules) > 0:
127
The following Python modules could not be found: %s. There are a few possible
128
explanations for this:
130
1. You do not have this Python module installed. In this case, you should
131
visit the AWN wiki's applets section to figure out the exact name of the
132
package for your distribution that provides this module.
134
2. The module is installed in a non-standard location. This is usually the
135
case when you manually install a package, that is, not via your distribution's
136
package manager. This situation is explained in the FAQ section of the wiki.
137
''') % ', '.join(not_found_modules)
139
dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
140
gtk.BUTTONS_NONE, msg)
141
dialog.add_button(_('Awn Wiki'), RESPONSE_WIKI).grab_default()
142
dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
143
dialog.set_alternative_button_order([gtk.RESPONSE_OK, RESPONSE_WIKI])
144
if dialog.run() == RESPONSE_WIKI:
145
url = 'http://wiki.awn-project.org/Applets:Dependencies'
147
if hasattr(webbrowser, 'open_new_tab'):
148
webbrowser.open_new_tab(url)
150
webbrowser.open_new(url)
155
sys.exit(RESPONSE_WIKI)