~ubuntu-branches/ubuntu/saucy/cairo-dock-plug-ins/saucy

« back to all changes in this revision

Viewing changes to Dbus/interfaces/python/CairoDock.py.in

  • Committer: Package Import Robot
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2012-08-19 00:37:51 UTC
  • mfrom: (1.1.23)
  • Revision ID: package-import@ubuntu.com-20120819003751-rcy2836qb5jfj31i
Tags: 3.0.99.beta1-0ubuntu1
* New upstream beta release.
* Upstream ChangeLog (main changes):
 - Better integration of Unity: support of the Launcher API and better
    support of indicators
 - All configuration windows have been merged into a single one.
 - Added progress bars in several applets and in the Dbus API
 - The Music Player applet can control players in the systray.
 - Icons of the taskbar can be separated from launchers or not
 - And as always ... various bug fixes and improvements :-)
* Fixed one bug reported on Launchpad:
 - Bookmark name in thunar wrong when shortcut added on plugin (LP: #995634)
* debian: Used 'wrap-and-sort' tool
* debian/control:
 - Bump Cairo-Dock version
 - Updated my email address
* debian/rules:
 - Added Disks, Global-Menu and Doncky applets.
* debian/cairo-dock-plug-ins.install:
 - Added 'appmenu-registrar' ('Global-Menu' applet)
    and 'cairo-dock-unity-bridge' ('Dbus' applet)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import os.path
24
24
import dbus
25
25
import re
26
 
 
27
 
USER_CONFIG_DIR = os.path.abspath("~/.config")
28
 
 
 
26
from dbus.mainloop.glib import DBusGMainLoop
 
27
 
 
28
USER_CONFIG_DIR = os.path.expanduser("~/.config")
 
29
BUS_NAME = "org.cairodock.CairoDock"
29
30
 
30
31
##################
31
32
### Main class ###
89
90
                """ Initialize the interface.
90
91
                It defines the following:
91
92
                 - cDataDir: main dir
92
 
                 - cCurrentThemeDir: current theme dir
93
 
                 - cConfFile : path to the global config file
 
93
                 - cCurrentThemeDir: path to the current theme folder
 
94
                 - cConfFile: path to the global config file
 
95
                 - cLaunchersDir: path to the launchers folder
 
96
                 - cPluginsDir: path to the plug-ins folders
 
97
                 - iface: the interface to control the dock
94
98
                 """
95
 
                self.dock = None
 
99
                
 
100
                DBusGMainLoop(set_as_default=True)  # set a main loop for the 'watch_name_owner' signal.
 
101
                
 
102
                ## initialize the class properties
 
103
                self.iface = None
96
104
                self.cAppName = app_name
97
105
                self.cDataDir = USER_CONFIG_DIR + '/' + app_name
98
106
                self.cCurrentThemeDir = self.cDataDir + '/current_theme'
100
108
                self.cPluginsDir = self.cCurrentThemeDir + '/plug-ins'
101
109
                self.cConfFile = self.cCurrentThemeDir + '/' + app_name + '.conf'
102
110
                
103
 
                self._connect()
104
 
        
105
 
        def _connect(self):
106
 
                # get gldi on the bus.
107
 
                bus = dbus.SessionBus()
108
 
                
109
111
                name1 = self.cAppName.replace('-','')  # -> cairodock
110
112
                name2 = re.sub('-[a-z]', lambda x: x.group(0).upper(), self.cAppName)
111
113
                name2 = re.sub('^[a-z]', lambda x: x.group(0).upper(), name2)  # -> CairoDock
112
114
                name2 = name2.replace('-','')  # -> CairoDock
113
 
                cBusPath = '/org/'+name1+'/'+name2
 
115
                self.cObjectPath = '/org/'+name1+'/'+name2
 
116
                
 
117
                ## connect to the dock
 
118
                self.bus = dbus.SessionBus()
 
119
                self._connect()
 
120
                
 
121
                ## if the watch for de/re-connections
 
122
                self.bus.watch_name_owner(BUS_NAME, self.on_name_owner_changed)
 
123
        
 
124
        def on_name_owner_changed(self,connection_name):
 
125
                print("new owner:",connection_name)
 
126
                if len(connection_name) == 0:
 
127
                        if self.iface != None:
 
128
                                self.iface = None
 
129
                                print("-> no more connection to "+self.cAppName)
 
130
                elif self.iface == None:
 
131
                        self._connect()
 
132
        
 
133
        def _connect(self):
 
134
                # get gldi on the bus.
 
135
                print("connect...")
114
136
                try:
115
 
                        dbus_object = bus.get_object("org.cairodock.CairoDock", cBusPath)
 
137
                        dbus_object = self.bus.get_object(BUS_NAME, self.cObjectPath)
116
138
                except:
117
 
                        print ">>> object '"+cBusPath+"' can't be found on the bus, exit.\nMake sure that Cairo-Dock is running"
 
139
                        print(">>> object '"+self.cObjectPath+"' can't be found on the bus, exit.\nMake sure that Cairo-Dock is running.")
118
140
                        return
119
141
                self.iface = dbus.Interface(dbus_object, "org.cairodock.CairoDock")  # this object represents gldi.
120
 
                
 
142
                print("-> connected to "+self.cAppName)
 
143