~nochka85/cairo-dock-plug-ins/quick_rss_reader

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/python

# This is the STANDARD python script for Cairo-Dock external applets
# using bash scripts,  perl scripts, ...
# (based on the demo.py applet from Fabounet)
#
# Usage : Just rename this script as your applet name and modify the extension variables in the "env variables" section
#
# Copyright : (C) 2009 by Yann Dulieu (Nochka85)
# E-mail : nochka85@cairo-dock.org
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# http://www.gnu.org/licenses/licenses.html#GPL
#
#
# Rev : 0.0.7
#
# Changelog :
# 09/10/02 : Little fix with the last modification (by Ours_en_pluche)
# 09/10/02 : auto-detect the extension
# 09/10/01 : Add the "extension" variable (by Ours_en_pluche)
# 09/09/29 : Modification of notifications name
# 09/09/20 : Fix due to modifications in Dbus applet
# 09/09/16 : Remove the .py extension of this script
# 09/09/07 : First release


### import ###
import sys
import gobject
import glib
import gtk
import dbus
import os.path
from dbus.mainloop.glib import DBusGMainLoop


### env variables ###
app_folder = os.path.dirname(sys.argv[0])	# name of the script folder
app_name = os.popen("TEMP=`basename " + sys.argv[0] +"` && echo $TEMP | cut -f1 -d '.' ").read().rstrip()	# name of the script without th '.py' extension AND without the './' if running as a script
if app_folder == "":
	app_folder = os.getcwd()
extension =os.popen("GLOBAL_NAME=`ls " + app_name + ".* |grep -v .conf` && FORMAT=${GLOBAL_NAME##*.} && echo $FORMAT ").read().rstrip()



### let's connect to the dock.###
DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
try:
	dock_object = bus.get_object("org.cairodock.CairoDock",
			"/org/cairodock/CairoDock")
except dbus.DBusException:
	print app_name + " applet : Cairo-Dock not found on bus (did you activate its 'DBus' plug-in ?)"
	sys.exit(1)
dock_iface = dbus.Interface(dock_object, "org.cairodock.CairoDock")


### let's register our applet !###
return_from_bash = os.popen("cd " + app_folder + " && ./" + app_name + "." + extension + " register_the_applet").read().rstrip()
try:
	applet_object = bus.get_object("org.cairodock.CairoDock",
			"/org/cairodock/CairoDock/" + app_name)
except dbus.DBusException:
	print app_name + " applet : the module has not been registered"
	sys.exit(2)
applet_iface = dbus.Interface(applet_object, "org.cairodock.CairoDock.applet")
	

### init ###
def init():	
	# register to the notifications on our applet
	applet_iface.connect_to_signal("on_click", action_on_click)
	applet_iface.connect_to_signal("on_middle_click", action_on_middle_click)
	applet_iface.connect_to_signal("on_scroll", action_on_scroll_icon)
	applet_iface.connect_to_signal("on_drop_data", action_on_drop_data)
	applet_iface.connect_to_signal("on_init_module", action_on_init)
	applet_iface.connect_to_signal("on_stop_module", action_on_stop)
	applet_iface.connect_to_signal("on_reload_module", action_on_reload)
	applet_iface.connect_to_signal("on_build_menu", action_on_build_menu)
	applet_iface.connect_to_signal("on_menu_select", action_on_menu_select)


### callbacks ###
def action_on_click(iState):
	return_from_bash = os.popen("cd " + app_folder + " && ./" + app_name + "." + extension + " action_on_click").read().rstrip()
	print return_from_bash
	
def action_on_middle_click():
	return_from_bash = os.popen("cd " + app_folder + " && ./" + app_name + "." + extension + " action_on_middle_click").read().rstrip()
	print return_from_bash

def action_on_scroll_icon(bUpOrDown):
	if bUpOrDown:
		return_from_bash = os.popen("cd " + app_folder + " && ./" + app_name + "." + extension + " action_on_scroll_icon 0").read().rstrip()
		print return_from_bash		
	else:
		return_from_bash = os.popen("cd " + app_folder + " && ./" + app_name + "." + extension + " action_on_scroll_icon 1").read().rstrip()
		print return_from_bash
		
def action_on_drop_data(sDataName):
	return_from_bash = os.popen("cd " + app_folder + " && ./" + app_name + "." + extension + " action_on_drop_data" + sDataName).read().rstrip()
	print return_from_bash

def action_on_init():
	return_from_bash = os.popen("cd " + app_folder + " && ./" + app_name + "." + extension + " action_on_init").read().rstrip()
	print return_from_bash
	
def action_on_stop():
	return_from_bash = os.popen("cd " + app_folder + " && ./" + app_name + "." + extension + " action_on_stop").read().rstrip()
	print return_from_bash
	
def action_on_reload(bConfigHasChanged):
	if bConfigHasChanged:
		return_from_bash = os.popen("cd " + app_folder + " && ./" + app_name + "." + extension + " action_on_reload").read().rstrip()
		print return_from_bash

def action_on_build_menu():
	return_from_bash = os.popen("cd " + app_folder + " && ./" + app_name + "." + extension + " action_on_build_menu").read().rstrip()
	print return_from_bash
	
def action_on_menu_select(iNumEntry):
	return_from_bash = os.popen("cd " + app_folder + " && ./" + app_name + "." + extension + " action_on_menu_select " + str(iNumEntry)).read().rstrip()
	print return_from_bash


### main ###
if __name__ == '__main__':
	init()
	gtk.main()
	stop()
	sys.exit(0)