~ubuntu-branches/debian/sid/libindicate/sid

« back to all changes in this revision

Viewing changes to examples/im-client.py

  • Committer: Bazaar Package Importer
  • Author(s): Evgeni Golov
  • Date: 2010-06-20 14:01:00 UTC
  • mfrom: (4.1.14 maverick)
  • Revision ID: james.westby@ubuntu.com-20100620140100-59y3fqqmp9nfp8gr
Tags: 0.4.1-1
* Merge from Ubuntu.
  Closes: #560122
* debian/control:
  - Set Maintainer to pkg-ayatana.
  - Add myself as Uploader.
  - Update Vcs-* fields.
  - Standards-Version: 3.8.4
  - Update package descriptions.
  - -doc package is Arch:all
  - -doc package does not need to depend on the lib.
* debian/copyright:
  - Convert to DEP5 format.
  - Add Ken and Sebastien, according to changelog.
  - Add bindings/ and examples/ copyrights.
* debian/{control,rules}:
  - Force python2.6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
#Copyright 2009 Canonical Ltd.
 
4
#
 
5
#Authors:
 
6
#    Eitan Isaacson <eitan@ascender.com>
 
7
#
 
8
#This program is free software: you can redistribute it and/or modify it 
 
9
#under the terms of either or both of the following licenses:
 
10
#
 
11
#1) the GNU Lesser General Public License version 3, as published by the 
 
12
#Free Software Foundation; and/or
 
13
#2) the GNU Lesser General Public License version 2.1, as published by 
 
14
#the Free Software Foundation.
 
15
#
 
16
#This program is distributed in the hope that it will be useful, but 
 
17
#WITHOUT ANY WARRANTY; without even the implied warranties of 
 
18
#MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 
 
19
#PURPOSE.  See the applicable version of the GNU Lesser General Public 
 
20
#License for more details.
 
21
#
 
22
#You should have received a copy of both the GNU Lesser General Public 
 
23
#License version 3 and version 2.1 along with this program.  If not, see 
 
24
#<http://www.gnu.org/licenses/>
 
25
#
 
26
 
 
27
import indicate
 
28
import gobject
 
29
import gtk
 
30
from time import time
 
31
 
 
32
PATHA = "/usr/share/icons/hicolor/16x16/apps/empathy.png"
 
33
PATHB = "/usr/share/icons/hicolor/22x22/apps/empathy.png"
 
34
lastpath = None
 
35
 
 
36
def timeout_cb(indicator):
 
37
    print "Modifying properties"
 
38
    global lastpath
 
39
    indicator.set_property_time("time", time())
 
40
    if lastpath == PATHA:
 
41
        lastpath = PATHB
 
42
    else:
 
43
        lastpath = PATHA
 
44
 
 
45
    pixbuf = gtk.gdk.pixbuf_new_from_file(lastpath)
 
46
 
 
47
    indicator.set_property_icon("icon", pixbuf)
 
48
 
 
49
    return True
 
50
 
 
51
def display(indicator, timestamp):
 
52
    print "Ah, my indicator has been displayed"
 
53
 
 
54
def server_display(server, timestamp):
 
55
    print "Ah, my server has been displayed"
 
56
 
 
57
 
 
58
if __name__ == "__main__":
 
59
    server = indicate.indicate_server_ref_default()
 
60
    server.set_type("message.im")
 
61
    server.set_desktop_file("/usr/share/applications/empathy.desktop")
 
62
    server.connect("server-display", server_display)
 
63
    
 
64
    indicator = indicate.Indicator()
 
65
    indicator.set_property("name", "IM Client Test")
 
66
    indicator.set_property_time("time", time())
 
67
    indicator.show()
 
68
 
 
69
    indicator.connect("user-display", display)
 
70
 
 
71
    gobject.timeout_add_seconds(5, timeout_cb, indicator)
 
72
 
 
73
    gtk.main()