gtg team mailing list archive
-
gtg team
-
Mailing list archive
-
Message #02977
[Merge] lp:~gtg-user/gtg/uri-support into lp:gtg
Luca Invernizzi has proposed merging lp:~gtg-user/gtg/uri-support into lp:gtg.
Requested reviews:
Gtg developers (gtg)
GTG support for URIs of the format gtg://<gtg-task-id>
These URIs are useful for putting tasks links in other programs (e.g, in a tomboy note).
I'm currently using it in the Zeitgeist backend, to let the tasks registered in Zeitgeist and shown through the Activity Journal to be clickable.
On every start, GTG checks if GNOME knows about this kind of URI and, if not, puts itself as an application capable of handling those. Therefore, you can use
xdg-open gtg://<gtg-task-id>.
Tomboy has the same kind of feature through a note:// URI.
--
https://code.launchpad.net/~gtg-user/gtg/uri-support/+merge/32128
Your team Gtg developers is requested to review the proposed merge of lp:~gtg-user/gtg/uri-support into lp:gtg.
=== modified file 'GTG/__init__.py'
--- GTG/__init__.py 2010-03-12 11:16:15 +0000
+++ GTG/__init__.py 2010-08-09 17:27:45 +0000
@@ -92,3 +92,13 @@
if os.path.isdir(os.path.join(config_home, 'gtg/plugins')):
PLUGIN_DIR.append(os.path.join(config_home, 'gtg/plugins'))
+
+#Register GTG URI (temporary, it should be created by a schema upon installing)
+import gconf
+domain = "/desktop/gnome/url-handlers/gtg/"
+client = gconf.client_get_default()
+#this should work both in debugging mode and in deployed mode
+client.set_string(os.path.join(domain, "command"), "gtg %s")
+client.set_bool(os.path.join(domain, "enabled"), True)
+client.set_bool(os.path.join(domain, "needs_terminal"), False)
+
=== modified file 'GTG/gtg.py'
--- GTG/gtg.py 2010-08-03 17:07:31 +0000
+++ GTG/gtg.py 2010-08-09 17:27:45 +0000
@@ -46,8 +46,8 @@
#=== IMPORT ===================================================================
import os
+import sys
import logging
-
import dbus
#our own imports
@@ -55,7 +55,7 @@
from GTG import _
from GTG.core import CoreConfig
from GTG.core.datastore import DataStore
-#from GTG.gtk.crashhandler import signal_catcher
+from GTG.gtk.crashhandler import signal_catcher
from GTG.gtk.manager import Manager
from GTG.tools.logger import Log
@@ -66,8 +66,11 @@
#that's why we put the pid file in the data directory :
#we allow one instance of gtg by data directory.
-def check_instance(directory):
- """Check if gtg is already running."""
+def check_instance(directory, uri_list = []):
+ """
+ Check if gtg is already running.
+ If so, open the tasks whose ids are in the uri_list
+ """
pidfile = os.path.join(directory, "gtg.pid")
if not os.path.exists(pidfile):
open(pidfile, "w").close()
@@ -83,6 +86,10 @@
d=dbus.SessionBus().get_object(CoreConfig.BUSNAME,\
CoreConfig.BUSINTERFACE)
d.show_task_browser()
+ #if the user has specified a task to open, do that
+ for uri in uri_list:
+ if uri.startswith("gtg://"):
+ d.open_task_editor(uri[6:])
raise SystemExit
#write the pid file
@@ -102,10 +109,10 @@
#To be more user friendly and get the logs of crashes, we show an apport
# hooked window upon crashes
if options.no_crash_handler == False:
- #FIXME: Why is this disabled? Please comment when disabling functionality so we know. :-)
- #with signal_catcher(manager.close_browser):
- pass
- manager.main(once_thru=options.boot_test)
+ with signal_catcher(manager.close_browser):
+ manager.main(once_thru=options.boot_test, uri_list = args)
+ else:
+ manager.main(once_thru=options.boot_test, uri_list = args)
core_main_quit(config, ds)
def core_main_init(options = None, args = None):
@@ -116,10 +123,11 @@
if options.debug:
Log.setLevel(logging.DEBUG)
Log.debug("Debug output enabled.")
- Log.set_debugging_mode(True)
-
+ else:
+ Log.setLevel(logging.INFO)
+ Log.set_debugging_mode(options.debug)
config = CoreConfig()
- check_instance(config.get_data_dir())
+ check_instance(config.get_data_dir(), args)
backends_list = BackendFactory().get_saved_backends_list()
# Load data store
ds = DataStore()
@@ -145,6 +153,8 @@
# Ending the application: we save configuration
config.save()
ds.save(quit = True)
+ sys.exit(0)
+
#=== EXECUTION ================================================================
=== modified file 'GTG/gtk/manager.py'
--- GTG/gtk/manager.py 2010-08-03 17:07:31 +0000
+++ GTG/gtk/manager.py 2010-08-09 17:27:45 +0000
@@ -211,7 +211,11 @@
self.close_task(t)
### MAIN ###################################################################
- def main(self, once_thru=False):
+
+ def main(self, once_thru = False, uri_list = []):
+ for uri in uri_list:
+ if uri.startswith("gtg://"):
+ self.open_task(uri[6:])
gobject.threads_init()
if once_thru:
gtk.main_iteration()
Follow ups