16
16
class IndicatorApplet(Application):
18
Indicator Applet manages the new indicator messages applet
17
20
IA_TOPLEVEL = "embindicator-applet"
18
21
def __init__(self):
19
22
Application.__init__(self, 'indicator-applet')
26
29
def add_server(self, desktop_file):
31
Add a new server to the indicator applet.
33
@type desktop_file: string
34
@param desktop_file: The path to the file describing the server.
39
Name=Phony Internet Messenger
40
GenericName=Internet Messenger
41
Comment=Send instant messages over phony protocols
46
Categories=Network;InstantMessaging;
27
50
if not self.server:
29
52
self.server = indicate.indicate_server_ref_default()
56
85
def capture_applet_icon(self):
87
It captures a screenshot of the indicator applet icon
89
@return: The path of the file containing the screenshot
57
91
x, y, w, h = ldtp.getobjectsize(self.TOP_PANEL, self.IA_TOPLEVEL)
59
93
ldtp_one_six = version.StrictVersion('1.6.0')
73
107
def is_server_shown(self, sender, already_shown=True):
74
# We need a way to distinguish between the normal menu and the indicator-applet menu
75
# Workaround in the mean time:
76
# Set already_shown as True, if there is already a menu with the same name
77
# (in that case we will look for mnuServer1
78
# or to False, if there is no already a menu with the same name
109
It says if a server is being shown or not
112
@param sender: The name of the Indicator server to check
114
@type already_shown: boolean
115
@param already_shown: We need a way to distinguish between the normal menu and the indicator-applet menu
116
Workaround in the mean time:
117
Set already_shown as True, if there is already a menu with the same name
118
(in that case we will look for mnuServer1
119
or to False, if there is no already a menu with the same name
121
@return: True, if the server is being shown; False, otherwise.
80
124
return ldtp.objectexist(self.TOP_PANEL,
81
125
'mnu' + sender.replace(' ','') + '1')
84
128
'mnu' + sender.replace(' ',''))
86
130
def is_indicator_shown(self, sender):
132
It says if an indicator is being shown or not
135
@param sender: The name of the indicator to check
137
@return: True, if the indicator is being shown; False, otherwise
87
139
return ldtp.objectexist(self.TOP_PANEL,
88
140
'mnu' + sender.replace(' ',''))
90
142
def select_indicator(self, sender):
144
It selects the menu item of an indicator
147
@param sender: The name of the indicator to select
91
149
ldtp.selectmenuitem(self.TOP_PANEL, 'mnu' + sender.replace(' ',''))
93
151
def select_server(self, sender, already_shown=True):
94
# We need a way to distinguish between the normal menu and the indicator-applet menu
95
# Workaround in the mean time:
96
# Set already_shown as True, if there is already a menu with the same name
97
# (in that case we will look for mnuServer1
98
# or to False, if there is no already a menu with the same name
153
It selects the menu item of a server indicator
156
@param sender: The name of the Indicator server to select
158
@type already_shown: boolean
159
@param already_shown: We need a way to distinguish between the normal menu and the indicator-applet menu
160
Workaround in the mean time:
161
Set already_shown as True, if there is already a menu with the same name
162
(in that case we will look for mnuServer1
163
or to False, if there is no already a menu with the same name
100
167
ldtp.selectmenuitem(self.TOP_PANEL, 'mnu' + sender.replace(' ',''), + '1')
187
258
os.remove(screenshot)
189
260
def notify(self, summary, body="", icon=None):
190
n = pynotify.Notification (summary, body, icon)
262
Giving a summary, body and icon, it creates a notification bubble
264
@type summary: string
265
@param summary: The header of the notification
268
@param body: The text to show as body of the notification
271
@param icon: The name of the icon to show
273
n = pynotify.Notification (summary, body, icon)
193
276
def notify_synchronous(self, summary, body="", icon=None, value=-1):
194
n = pynotify.Notification (summary, body, icon)
278
Giving a summary, body, icon and value it creates a confirmation bubble
280
@type summary: string
281
@param summary: The header of the notification
284
@param body: The text to show as body of the notification
287
@param icon: The name of the icon to show
290
@param value: The value of the quantity of the confirmation bubble (i.e. volume)
292
n = pynotify.Notification (summary, body, icon)
195
293
n.set_hint("synchronous", "volume")
196
294
n.set_hint("value", value)
199
297
def grab_image_and_wait(self, summary, timeOut=30):
299
It waits for a notification to appear and grabs a screenshot
301
@type summary: string
302
@param summary: The summary of the notification to look for
305
@param timeOut: The number of seconds to wait for the notification to appear
307
@return: List with the time elapsed and the path to the screenshot
200
309
ldtp.waittillguiexist(summary, guiTimeOut=timeOut)
201
310
start_time = time()
208
317
if ldtp_current < ldtp_one_six:
210
ldtputils.imagecapture(outFile=tempfile.mktemp('.png', 'nosd_'),
319
ldtputils.imagecapture(out_file=tempfile.mktemp('.png', 'nosd_'),
216
ldtputils.imagecapture(outFile=tempfile.mktemp('.png', 'nosd_'),
325
ldtputils.imagecapture(out_file=tempfile.mktemp('.png', 'nosd_'),
224
333
return (end_time, screenshot)
226
335
def get_extents(self, summary, wait=False):
337
It gets the limits of the bubble
339
@type summary: string
340
@param summary: The summary of the bubble to get the size
342
@return: (x, y, width, height)
228
345
exists = ldtp.waittillguiexist(summary)