Skip to content

Commit

Permalink
Support for GTG 0.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
izidormatusov committed Mar 15, 2012
1 parent ae1bab4 commit 825de74
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
41 changes: 36 additions & 5 deletions chrome/newtask.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@
import dbus
import sys

class GTG:
""" Unified interface to different versions of GTG D-Bus """

def __init__(self):
try:
self.version = "0.2.9"
bus = dbus.SessionBus()
gtg_obj = bus.get_object('org.gnome.GTG', '/org/gnome/GTG')
self.gtg = dbus.Interface(gtg_obj, 'org.gnome.GTG')
except dbus.exceptions.DBusException, e:
# Use older version
self.version = "0.2.4"
bus = dbus.SessionBus()
gtg_obj = bus.get_object('org.GTG', '/org/GTG')
self.gtg = dbus.Interface(gtg_obj, 'org.GTG')

def new_task(self, title, message):
if self.version == "0.2.9":
return self.gtg.NewTask('Active', title, '', '', '', [], message, [])
else:
return self.gtg.new_task('Active', title, '', '', '', [], message, [])

def open_task(self, task_id):
if self.version == "0.2.9":
return self.gtg.OpenTaskEditor(task_id)
else:
return self.gtg.open_task_editor(task_id)

def show_notification(title, message):
try:
import pynotify
Expand All @@ -45,11 +73,14 @@ def show_notification(title, message):
title = sys.argv[1]
message = "\n".join(sys.argv[2:])

bus = dbus.SessionBus()
gtg_obj = bus.get_object('org.gnome.GTG', '/org/gnome/GTG')
gtg = dbus.Interface(gtg_obj, 'org.gnome.GTG')
try:
gtg = GTG()
except dbus.exceptions.DBusException, e:
show_notification("Failed to find GTG", "There is no D-Bus interface for GTG")
print "D-Bus exception:", e
sys.exit(1)

task = gtg.NewTask('Active', title, '', '', '', [], message, [])
task = gtg.new_task(title, message)
# if notification fails, open the task
if force_editor or not show_notification("New GTG task added", title):
gtg.OpenTaskEditor(task['id'])
gtg.open_task(task['id'])
4 changes: 2 additions & 2 deletions install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
about="urn:mozilla:install-manifest"

em:name="GTG Task Button"
em:description="Easily transform a page into a GTG task with one click"
em:description="Easily transform a page into a task for Getting Things GNOME! with a single click."
em:creator="Izidor Matušov"

em:id="gtg@fritalk.com"
em:version="1.0"
em:version="1.1"
em:homepageURL="http://gtg.fritalk.com"

em:iconURL="chrome://gtgtask/content/icon.png" >
Expand Down
1 change: 1 addition & 0 deletions package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
#
# Created by Izidor Matušov <izidor.matusov@gmail.com>

rm -f ../gtgtask.xpi
zip -r9 ../gtgtask.xpi chrome/ chrome.manifest defaults/ install.rdf

0 comments on commit 825de74

Please sign in to comment.