gtg-user team mailing list archive
-
gtg-user team
-
Mailing list archive
-
Message #00221
I made a docky plugin for GTG
I used the dbus api to make this, its almost perfect, but I would like a
dbus function to access the number of active tasks to have its dock icon
superimpose this.
--
Ubuntu FTW!
#!/usr/bin/python
import atexit
import gobject
import glib
import sys
import os
import dbus
try:
from docky.docky import DockyItem, DockySink
from signal import signal, SIGTERM
from sys import exit
except ImportError, e:
exit()
def newTask():
bus = dbus.SessionBus()
liste = bus.list_names()
busname = None
busgps = None
#We take the list of all buses actually available
for i in liste :
if i.startswith("org.GTG") :
busname = i
if busname :
remote_object = bus.get_object(busname,"/org/GTG")
timi = dbus.Interface(remote_object,dbus_interface="org.GTG")
#Calling the method
timi.open_new_task()
else:
print "GTG not found on DBus. Are you sure GTG is started?"
def newWindow():
bus = dbus.SessionBus()
liste = bus.list_names()
busname = None
busgps = None
#We take the list of all buses actually available
for i in liste :
if i.startswith("org.GTG") :
busname = i
if busname :
remote_object = bus.get_object(busname,"/org/GTG")
timi = dbus.Interface(remote_object,dbus_interface="org.GTG")
#Calling the method
timi.show_task_browser()
else:
print "GTG not found on DBus. Are you sure GTG is started?"
class DockyGTGItem(DockyItem):
def __init__(self, path):
DockyItem.__init__(self, path)
menu_id = self.iface.AddMenuItem ("New Task", "/usr/share/pixmaps/gnome-day.png", "Task Controls")
self.id_map[menu_id] = "NewTask"
menu_id = self.iface.AddMenuItem ("Open Tasks List", "gtg", "Task Controls")
self.id_map[menu_id] = "OpenWindow"
def menu_pressed(self, menu_id):
if self.id_map[menu_id] == "NewTask":
newTask()
elif self.id_map[menu_id] == "OpenWindow":
newWindow()
class DockyGTGSink(DockySink):
def item_path_found(self, pathtoitem, item):
if item.GetOwnsDesktopFile() and item.GetDesktopFile().endswith("gtg.desktop"):
self.items[pathtoitem] = DockyGTGItem(pathtoitem)
dockysink = DockyGTGSink()
def cleanup():
dockysink.dispose()
if __name__ == "__main__":
mainloop = gobject.MainLoop(is_running=True)
atexit.register (cleanup)
signal(SIGTERM, lambda signum, stack_frame: exit(1))
mainloop.run()
Follow ups