gtg-user team mailing list archive
-
gtg-user team
-
Mailing list archive
-
Message #00222
Re: I made a docky plugin for GTG
Hey Sam, good to hear that!
Open a bug on the gtg launchapad page, so that we can discuss that
without bugging the other gtg-users.
Luca
On Tue, Feb 09, 2010 at 08:14:37PM -0800, Sam wrote:
> 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()
> _______________________________________________
> Mailing list: https://launchpad.net/~gtg-user
> Post to : gtg-user@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~gtg-user
> More help : https://help.launchpad.net/ListHelp
Attachment:
signature.asc
Description: Digital signature
Follow ups
References