[hamster-applet] launch dialogs from commandline



commit 62c605641f3bc1f139089bb25421e1377ae942cf
Author: Toms Bauģis <toms baugis gmail com>
Date:   Fri Jul 16 15:30:21 2010 +0100

    launch dialogs from commandline

 src/hamster-client |   74 +++++++++++++++++++++++++++++++++-------------------
 1 files changed, 47 insertions(+), 27 deletions(-)
---
diff --git a/src/hamster-client b/src/hamster-client
index 0c9f368..955e3d3 100755
--- a/src/hamster-client
+++ b/src/hamster-client
@@ -250,43 +250,63 @@ Time formats:
 
     command, args = sys.argv[1], sys.argv[2:]
 
-    if command not in ['toggle', 'start', 'stop', 'list', 'list-activities', 'list-categories']:
-        # unknown command - print usage, go home
-        sys.exit(usage % {'prog': sys.argv[0]})
+    if command in ("toggle", "start", "stop", "list", "list-activities", "list-categories"):
+        hamster_client = HamsterClient()
+
+        if command == 'toggle':
+            hamster_client.toggle()
+
+        elif command == 'start':
+            if not args: # mandatory is only the activity name
+                sys.exit(usage % {'prog': sys.argv[0]})
+
+            activity = args[0]
 
+            start_time, end_time = None, None
+            if len(args) > 1:
+                start_time, end_time = parse_datetime_range(args[1])
 
-    hamster_client = HamsterClient()
+                if start_time > dt.datetime.now() or (end_time and end_time > dt.datetime.now()):
+                    sys.exit("Activity must start and finish before current time")
 
-    if command == 'toggle':
-        hamster_client.toggle()
+            hamster_client.start_tracking(activity, start_time, end_time)
 
-    elif command == 'start':
-        if not args: # mandatory is only the activity name
-            sys.exit(usage % {'prog': sys.argv[0]})
+        elif command == 'stop':
+            hamster_client.stop_tracking()
 
-        activity = args[0]
+        elif command == 'list':
+            start_time, end_time = None, None
+            if args:
+                start_time, end_time = parse_datetime_range(args[0])
 
-        start_time, end_time = None, None
-        if len(args) > 1:
-            start_time, end_time = parse_datetime_range(args[1])
+            hamster_client.list(start_time, end_time)
 
-            if start_time > dt.datetime.now() or (end_time and end_time > dt.datetime.now()):
-                sys.exit("Activity must start and finish before current time")
+        elif command == 'list-activities':
+            hamster_client.list_activities()
 
-        hamster_client.start_tracking(activity, start_time, end_time)
+        elif command == 'list-categories':
+            hamster_client.list_categories()
 
-    elif command == 'stop':
-        hamster_client.stop_tracking()
+    elif command in ("overview", "statistics", "edit", "preferences"): # windows
+        import gtk
+        from hamster import i18n
+        i18n.setup_i18n()
 
-    elif command == 'list':
-        start_time, end_time = None, None
-        if args:
-            start_time, end_time = parse_datetime_range(args[0])
+        gtk.window_set_default_icon_name("hamster-applet")
+        from hamster.configuration import dialogs
 
-        hamster_client.list(start_time, end_time)
 
-    elif command == 'list-activities':
-        hamster_client.list_activities()
+        if command == "overview":
+            dialogs.overview.show()
+        elif command == "statistics":
+            dialogs.stats.show()
+        elif command == "edit":
+            dialogs.edit.show()
+        elif command == "preferences":
+            dialogs.prefs.show()
 
-    elif command == 'list-categories':
-        hamster_client.list_categories()
+        gtk.main()
+
+    else:
+        # unknown command - print usage, go home
+        sys.exit(usage % {'prog': sys.argv[0]})



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]