~cairo-dock-team/ubuntu/oneiric/cairo-dock-plug-ins/2.3.0-2.1

« back to all changes in this revision

Viewing changes to Dbus/demos/demo_bash/demo_bash

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2011-04-20 20:46:51 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20110420204651-ftnpzesj6uc7qeul
Tags: 2.3.0~1-0ubuntu1
* New Upstream Version (LP: #723995)
* Upstream short ChangeLog (since 2.3.0~0rc1):
 - Updated translations
 - Updated the integration of the new versions of kwin and compiz
    (Switcher, ShowDesktop, etc.)
 - Removed a lot of useless g_print
 - Updated a few plug-ins to fit with the new version of the API (gldit)
 - Fixed a few bugs
 - Updated MeMenu, MessagingMenu and Status-Notifier to works
    with the latest version of dbusmenu, etc.
* Switch to dpkg-source 3.0 (quilt) format
* debian/cairo-dock-plug-ins.install:
 - Added new files (interfaces for python, ruby, vala and mono)
* debian/control:
 - Added new dependences for new applets (sensors and zeitgeist)
    and new interfaces (python, valac, ruby and mono)
 - Updated the version of cairo-dock build-dependences
* debian/rules:
 - Added a new CMake flag to install python interface in debian/tmp
* Updated debian/watch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
 
3
3
# This is a part of the external demo applet for Cairo-Dock
4
 
#
5
 
# Copyright : (C) 2010 by Nochka85
6
 
#                      modified by matttbe for the new API
7
 
#                      (based on the demo.py by Fabounet)
8
 
# E-mail : nochka85@glx-dock.org
9
 
#
 
4
# Copyright : (C) 2010-2011 by Nochka85, Fabounet and atttbe
 
5
# E-mail : fabounet@glx-dock.org
10
6
#
11
7
# This program is free software; you can redistribute it and/or
12
8
# modify it under the terms of the GNU General Public License
15
11
#
16
12
# This program is distributed in the hope that it will be useful,
17
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
14
# ERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
15
# GNU General Public License for more details.
20
16
# http://www.gnu.org/licenses/licenses.html#GPL
21
17
 
22
 
### We assume the name of this applet is "demo_bash"
23
 
### This Python script (demo_bash) should be placed in a folder alongside with 3 files :
24
 
### demo_bash.conf (the default config file), "icon" (the default icon of the applet) , "preview" (a preview of this applet) and demo_bash.sh (the script in bash, where you will place your code)
25
 
 
26
 
### REV : 21/01/2010
27
 
 
28
 
### import ###
29
 
import sys
30
 
import gobject
31
 
import glib
32
 
import gtk
33
 
import dbus
34
 
import os.path
35
 
from dbus.mainloop.glib import DBusGMainLoop
36
 
 
37
 
# get our applet on the bus
38
 
app_folder = os.path.dirname(sys.argv[0])
39
 
applet_name = os.path.basename(os.path.abspath("."))
40
 
applet_path = "/org/cairodock/CairoDock/"+applet_name
41
 
DBusGMainLoop(set_as_default=True)
42
 
bus = dbus.SessionBus()
43
 
try:
44
 
        applet_object = bus.get_object("org.cairodock.CairoDock", applet_path)
45
 
except dbus.DBusException:
46
 
        print ">>> module '"+applet_name+"' can't be found on the bus, exit."
47
 
        sys.exit(2)
48
 
myIcon = dbus.Interface(applet_object, "org.cairodock.CairoDock.applet") 
49
 
 
50
 
### we'll have a sub-dock, so we also get the sub-icons object ###
51
 
#sub_icons_object = bus.get_object("org.cairodock.CairoDock", applet_path+"/sub_icons")
52
 
#mySubIcons = dbus.Interface(sub_icons_object, "org.cairodock.CairoDock.subapplet") 
53
 
 
54
 
### callbacks ###
55
 
def action_on_click(iState):
56
 
        return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_click").read().rstrip()
57
 
        print return_from_bash
58
 
        
59
 
def action_on_middle_click():
60
 
        return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_middle_click").read().rstrip()
61
 
        print return_from_bash
62
 
 
63
 
def action_on_scroll_icon(bUpOrDown):
64
 
        if bUpOrDown:
65
 
                return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_scroll_icon 0").read().rstrip()
66
 
                print return_from_bash
67
 
        else:
68
 
                return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_scroll_icon 1").read().rstrip()
69
 
                print return_from_bash
70
 
 
71
 
def action_on_drop_data(sDataName):
72
 
        return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_drop_data " + sDataName).read().rstrip()
73
 
        print return_from_bash
74
 
 
75
 
def action_on_init():
76
 
        return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_init").read().rstrip()
77
 
        print return_from_bash
78
 
        
79
 
def action_on_stop():
80
 
        return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_stop").read().rstrip()
81
 
        print return_from_bash
82
 
        
83
 
def action_on_reload(bConfigHasChanged):
84
 
        if bConfigHasChanged:
85
 
                return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_reload").read().rstrip()
86
 
                print return_from_bash
87
 
 
88
 
def action_on_build_menu():
89
 
        return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_build_menu").read().rstrip()
90
 
        print return_from_bash
91
 
        
92
 
def action_on_menu_select(iNumEntry):
93
 
        return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_menu_select " + str(iNumEntry)).read().rstrip()
94
 
        print return_from_bash
95
 
 
96
 
### init ###
97
 
def init():
98
 
        # register to the notifications on our applet
99
 
        myIcon.connect_to_signal("on_click", action_on_click)
100
 
        myIcon.connect_to_signal("on_middle_click", action_on_middle_click)
101
 
        myIcon.connect_to_signal("on_scroll", action_on_scroll_icon)
102
 
        myIcon.connect_to_signal("on_drop_data", action_on_drop_data)
103
 
        myIcon.connect_to_signal("on_init_module", action_on_init)
104
 
        myIcon.connect_to_signal("on_stop_module", action_on_stop)
105
 
        myIcon.connect_to_signal("on_reload_module", action_on_reload)
106
 
        myIcon.connect_to_signal("on_build_menu", action_on_build_menu)
107
 
        myIcon.connect_to_signal("on_menu_select", action_on_menu_select)
108
 
 
109
 
### main ###
 
18
# The name of this applet is "demo_bash"; it is placed in a folder named "demo_bash", with a file named "auto-load.conf" which describes it.
 
19
# Copy this folder into ~/.config/cairo-dock/third-party to let the dock register it automatically.
 
20
# In the folder we have :
 
21
# - "demo_bash"         : this python script, without extension
 
22
# - "demo_bash.sh"      : the script in bash, where you actually place your code
 
23
# - "demo_bash.conf"    : the config file of the applet
 
24
# - "auto-load.conf"    : the file describing the applet
 
25
# - "icon"              : the default icon of the applet (optionnal)
 
26
# - "preview"           : a preview of this applet (optionnal)
 
27
 
 
28
from CDBashApplet import CDBashApplet
 
29
 
110
30
if __name__ == '__main__':
111
 
        init()
112
 
        gtk.main()
113
 
        stop()
114
 
        sys.exit(0)
 
31
        CDBashApplet().run()