1
# This is a part of the Cairo-Dock plug-ins.
2
# Copyright : (C) 2010-2011 by Fabounet
3
# E-mail : fabounet@glx-dock.org
5
# This program is free software; you can redistribute it and/or
6
# modify it under the terms of the GNU General Public License
7
# as published by the Free Software Foundation; either version 2
8
# of the License, or (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
# http://www.gnu.org/licenses/licenses.html#GPL
16
# Base class for Cairo-Dock's main interface.
25
USER_CONFIG_DIR = os.path.abspath("~/.config")
53
CATEGORY_APPLET_FILES = 2
54
CATEGORY_APPLET_INTERNET = 3
55
CATEGORY_APPLET_DESKTOP = 4
56
CATEGORY_APPLET_ACCESSORY = 5
57
CATEGORY_APPLET_SYSTEM = 6
58
CATEGORY_APPLET_FUN = 7
63
TYPE_LAUNCHER = "Launcher"
64
TYPE_APPLICATION = "Application"
65
TYPE_APPLET = "Applet"
66
TYPE_SEPARATOR = "Separator"
67
TYPE_CONTAINER = "Container"
68
TYPE_CLASS_CONTAINER = "Class-Container"
70
# toggle dock visibility
79
def __init__(self, app_name="cairo-dock"):
80
""" Initialize the interface.
81
It defines the following:
83
- cCurrentThemeDir: current theme dir
84
- cConfFile : path to the global config file
87
self.cAppName = app_name
88
self.cDataDir = USER_CONFIG_DIR + '/' + app_name
89
self.cCurrentThemeDir = self.cDataDir + '/current_theme'
90
self.cLaunchersDir = self.cCurrentThemeDir + '/launchers'
91
self.cPluginsDir = self.cCurrentThemeDir + '/plug-ins'
92
self.cConfFile = self.cCurrentThemeDir + '/' + app_name + '.conf'
97
# get gldi on the bus.
98
bus = dbus.SessionBus()
100
name1 = self.cAppName.replace('-','') # -> cairodock
101
name2 = re.sub('-[a-z]', lambda x: x.group(0).upper(), self.cAppName)
102
name2 = re.sub('^[a-z]', lambda x: x.group(0).upper(), name2) # -> CairoDock
103
name2 = name2.replace('-','') # -> CairoDock
104
cBusPath = '/org/'+name1+'/'+name2
106
dbus_object = bus.get_object("org.cairodock.CairoDock", cBusPath)
108
print ">>> object '"+cBusPath+"' can't be found on the bus, exit.\nMake sure that Cairo-Dock is running"
110
self.iface = dbus.Interface(dbus_object, "org.cairodock.CairoDock") # this object represents gldi.