1
1
#!/usr/bin/env python
2
2
# -*- coding:utf-8 -*-
4
3
# -----------------------------------------------------------------------------
5
4
# Getting Things Gnome! - A personal organizer for the GNOME desktop
6
# Copyright (c) 2008,2009 Lionel Dricot & Bertrand Rousseau
5
# Copyright (c) 2008-2012 Lionel Dricot & Bertrand Rousseau
8
7
# This program is free software: you can redistribute it and/or modify it under
9
8
# the terms of the GNU General Public License as published by the Free Software
19
18
# this program. If not, see <http://www.gnu.org/licenses/>.
20
19
# -----------------------------------------------------------------------------
23
This script creates a new task and launches the editor to display it. GTG should be running
21
""" This script creates a new task and launches the editor to display it. """
28
from optparse import OptionParser
33
def get_task(title, body) :
34
#We will connect on the session bus
33
def new_task(title, body):
34
""" Open a new task in GTG with given title and body """
35
35
bus = dbus.SessionBus()
36
liste = bus.list_names()
37
busname = "org.gnome.GTG"
38
remote_object = bus.get_object(busname,"/org/gnome/GTG")
39
timi = dbus.Interface(remote_object,dbus_interface="org.gnome.GTG")
41
timi.OpenNewTask(title, body)
44
print _("Usage: %s [-i | --interactive] [-h | --help]") % sys.argv[0]
46
if __name__ == '__main__':
48
#Command line options handling
50
opts, args = getopt.getopt(sys.argv[1:], "hi", ["help", "interactive"])
51
except getopt.GetoptError, err:
52
# print help information and exit:
53
print str(err) # will print something like "option -a not recognized"
57
if o in ("-i", "--interactive"):
59
elif o in ("-h", "--help"):
63
assert False, "unhandled option"
36
proxy = bus.get_object("org.gnome.GTG", "/org/gnome/GTG")
37
gtg = dbus.Interface(proxy, "org.gnome.GTG")
38
gtg.OpenNewTask(title, body)
42
""" Parse arguments and create a new task """
43
parser = OptionParser()
44
parser.add_option('-i', '--interactive', action='store_true',
45
dest='interactive', help=_("Use input as the text of a new task"),
47
(options, args) = parser.parse_args()
65
49
title = " ".join(args)
67
optlist, args = getopt.getopt(args, 'i::')
50
if options.interactive:
68
51
body = sys.stdin.read()
69
52
subject_regex = re.compile("^Subject: (.*)$", re.M | re.I)
70
53
if subject_regex.search(body):