File: im-client.py

package info (click to toggle)
libindicate 0.6.92-2%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 3,232 kB
  • ctags: 1,076
  • sloc: sh: 11,407; ansic: 5,175; xml: 1,491; makefile: 902; python: 96; cs: 35
file content (73 lines) | stat: -rw-r--r-- 2,170 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/env python
#
#Copyright 2009 Canonical Ltd.
#
#Authors:
#    Eitan Isaacson <eitan@ascender.com>
#
#This program is free software: you can redistribute it and/or modify it 
#under the terms of either or both of the following licenses:
#
#1) the GNU Lesser General Public License version 3, as published by the 
#Free Software Foundation; and/or
#2) the GNU Lesser General Public License version 2.1, as published by 
#the Free Software Foundation.
#
#This program is distributed in the hope that it will be useful, but 
#WITHOUT ANY WARRANTY; without even the implied warranties of 
#MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 
#PURPOSE.  See the applicable version of the GNU Lesser General Public 
#License for more details.
#
#You should have received a copy of both the GNU Lesser General Public 
#License version 3 and version 2.1 along with this program.  If not, see 
#<http://www.gnu.org/licenses/>
#

import indicate
import gobject
import gtk
from time import time

PATHA = "/usr/share/icons/hicolor/16x16/apps/empathy.png"
PATHB = "/usr/share/icons/hicolor/22x22/apps/empathy.png"
lastpath = None

def timeout_cb(indicator):
    print "Modifying properties"
    global lastpath
    indicator.set_property_time("time", time())
    if lastpath == PATHA:
        lastpath = PATHB
    else:
        lastpath = PATHA

    pixbuf = gtk.gdk.pixbuf_new_from_file(lastpath)

    indicator.set_property_icon("icon", pixbuf)

    return True

def display(indicator, timestamp):
    print "Ah, my indicator has been displayed"

def server_display(server, timestamp):
    print "Ah, my server has been displayed"


if __name__ == "__main__":
    server = indicate.indicate_server_ref_default()
    server.set_type("message.im")
    server.set_desktop_file("/usr/share/applications/empathy.desktop")
    server.connect("server-display", server_display)
    
    indicator = indicate.Indicator()
    indicator.set_property("name", "IM Client Test")
    indicator.set_property_time("time", time())
    indicator.show()

    indicator.connect("user-display", display)

    gobject.timeout_add_seconds(5, timeout_cb, indicator)

    gtk.main()