Back to index

libindicate  12.10.0
im-client.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 #Copyright 2009 Canonical Ltd.
00004 #
00005 #Authors:
00006 #    Eitan Isaacson <eitan@ascender.com>
00007 #
00008 #This program is free software: you can redistribute it and/or modify it 
00009 #under the terms of either or both of the following licenses:
00010 #
00011 #1) the GNU Lesser General Public License version 3, as published by the 
00012 #Free Software Foundation; and/or
00013 #2) the GNU Lesser General Public License version 2.1, as published by 
00014 #the Free Software Foundation.
00015 #
00016 #This program is distributed in the hope that it will be useful, but 
00017 #WITHOUT ANY WARRANTY; without even the implied warranties of 
00018 #MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 
00019 #PURPOSE.  See the applicable version of the GNU Lesser General Public 
00020 #License for more details.
00021 #
00022 #You should have received a copy of both the GNU Lesser General Public 
00023 #License version 3 and version 2.1 along with this program.  If not, see 
00024 #<http://www.gnu.org/licenses/>
00025 #
00026 
00027 import indicate
00028 import gobject
00029 import gtk
00030 from time import time
00031 
00032 PATHA = "/usr/share/icons/hicolor/16x16/apps/empathy.png"
00033 PATHB = "/usr/share/icons/hicolor/22x22/apps/empathy.png"
00034 lastpath = None
00035 
00036 def timeout_cb(indicator):
00037     print "Modifying properties"
00038     global lastpath
00039     indicator.set_property_time("time", time())
00040     if lastpath == PATHA:
00041         lastpath = PATHB
00042     else:
00043         lastpath = PATHA
00044 
00045     pixbuf = gtk.gdk.pixbuf_new_from_file(lastpath)
00046 
00047     indicator.set_property_icon("icon", pixbuf)
00048 
00049     return True
00050 
00051 def display(indicator, timestamp):
00052     print "Ah, my indicator has been displayed"
00053 
00054 def server_display(server, timestamp):
00055     print "Ah, my server has been displayed"
00056 
00057 
00058 if __name__ == "__main__":
00059     server = indicate.indicate_server_ref_default()
00060     server.set_type("message.im")
00061     server.set_desktop_file("/usr/share/applications/empathy.desktop")
00062     server.connect("server-display", server_display)
00063     
00064     indicator = indicate.Indicator()
00065     indicator.set_property("name", "IM Client Test")
00066     indicator.set_property_time("time", time())
00067     indicator.show()
00068 
00069     indicator.connect("user-display", display)
00070 
00071     gobject.timeout_add_seconds(5, timeout_cb, indicator)
00072 
00073     gtk.main()