ukblacknight
October 18th, 2009, 07:04 PM
Hi all,
I've been thinking about writing a plugin for emesene so that it integrates into the indicator-applet (https://wiki.ubuntu.com/MessagingMenu/), like pidgin, evolution, gwibber etc etc.
Since emesene is in python, I'd give it a go in python, although I have pretty much no experience in the language!
I followed this article (http://www.gnomejournal.org/article/67/an-introduction-to-the-message-indicator), however it won't run:
Traceback (most recent call last):
File "indicate.py", line 31, in <module>
server = indicate.indicate_server_ref_default()
AttributeError: 'module' object has no attribute 'indicate_server_ref_default'
tom@blacknight:~/Projects/Python$
So I thought I'd inspect the indicate library in python:
>>> import indicate
>>> dir(indicate)
['INTEREST_INDICATOR_COUNT', 'INTEREST_INDICATOR_DISPLAY', 'INTEREST_INDICATOR_SIGNAL', 'INTEREST_NONE', 'INTEREST_SERVER_DISPLAY', 'INTEREST_SERVER_SIGNAL', 'Indicator', 'IndicatorMessage', 'Listener', 'Server', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '_indicate', 'ctypes', 'indicate_listener_ref_default', 'indicate_server_ref_default', 'indicate_server_set_dbus_object', 'indicator_id', 'server_dbus_name']
So, the "indicate_server_ref_default" attribute (I'm sure it should be a method?) does exist. Any ideas why python would imply that it does not?
Below is the code that I have:
import gobject
import gtk
from time import time
import os
try:
import indicate
except:
indicate = None
curdir = os.getcwd()
desktop_file = os.path.join(curdir, "indicate.desktop")
def timeout_cb(indicator):
print "Modifying properties"
indicator.set_property_time("time", time())
return True
def display(indicator):
print "Ah, my indicator has been displayed"
indicator.hide()
def server_display(server):
print "Ah, my server has been displayed"
print __name__
if __name__ == "__main__":
# Setup the server
server = indicate.indicate_server_ref_default()
server.set_type("message.im")
server.set_desktop_file(desktop_file)
server.connect("server-display", server_display)
server.show()
# Setup the message
indicator = indicate.IndicatorMessage()
indicator.set_property("subtype", "im")
indicator.set_property("sender", "Test message")
indicator.set_property("body", "Test message body")
indicator.set_property_time("time", time())
indicator.show()
indicator.connect("user-display", display)
# Loop
gobject.timeout_add_seconds(5, timeout_cb, indicator)
gtk.main()
Note: The try: except: statement is something I noticed in the source code for gwibber - I tried that to see if it had any effect.
I've been thinking about writing a plugin for emesene so that it integrates into the indicator-applet (https://wiki.ubuntu.com/MessagingMenu/), like pidgin, evolution, gwibber etc etc.
Since emesene is in python, I'd give it a go in python, although I have pretty much no experience in the language!
I followed this article (http://www.gnomejournal.org/article/67/an-introduction-to-the-message-indicator), however it won't run:
Traceback (most recent call last):
File "indicate.py", line 31, in <module>
server = indicate.indicate_server_ref_default()
AttributeError: 'module' object has no attribute 'indicate_server_ref_default'
tom@blacknight:~/Projects/Python$
So I thought I'd inspect the indicate library in python:
>>> import indicate
>>> dir(indicate)
['INTEREST_INDICATOR_COUNT', 'INTEREST_INDICATOR_DISPLAY', 'INTEREST_INDICATOR_SIGNAL', 'INTEREST_NONE', 'INTEREST_SERVER_DISPLAY', 'INTEREST_SERVER_SIGNAL', 'Indicator', 'IndicatorMessage', 'Listener', 'Server', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '_indicate', 'ctypes', 'indicate_listener_ref_default', 'indicate_server_ref_default', 'indicate_server_set_dbus_object', 'indicator_id', 'server_dbus_name']
So, the "indicate_server_ref_default" attribute (I'm sure it should be a method?) does exist. Any ideas why python would imply that it does not?
Below is the code that I have:
import gobject
import gtk
from time import time
import os
try:
import indicate
except:
indicate = None
curdir = os.getcwd()
desktop_file = os.path.join(curdir, "indicate.desktop")
def timeout_cb(indicator):
print "Modifying properties"
indicator.set_property_time("time", time())
return True
def display(indicator):
print "Ah, my indicator has been displayed"
indicator.hide()
def server_display(server):
print "Ah, my server has been displayed"
print __name__
if __name__ == "__main__":
# Setup the server
server = indicate.indicate_server_ref_default()
server.set_type("message.im")
server.set_desktop_file(desktop_file)
server.connect("server-display", server_display)
server.show()
# Setup the message
indicator = indicate.IndicatorMessage()
indicator.set_property("subtype", "im")
indicator.set_property("sender", "Test message")
indicator.set_property("body", "Test message body")
indicator.set_property_time("time", time())
indicator.show()
indicator.connect("user-display", display)
# Loop
gobject.timeout_add_seconds(5, timeout_cb, indicator)
gtk.main()
Note: The try: except: statement is something I noticed in the source code for gwibber - I tried that to see if it had any effect.