← Back to team overview

elementaryart team mailing list archive

[Merge] lp:~krzysztof-lochwinowicz/granite/trunk into lp:granite

 

darklin has proposed merging lp:~krzysztof-lochwinowicz/granite/trunk into lp:granite.

Requested reviews:
  Cody Garver (codygarver)

For more details, see:
https://code.launchpad.net/~krzysztof-lochwinowicz/granite/trunk/+merge/123253
-- 
https://code.launchpad.net/~krzysztof-lochwinowicz/granite/trunk/+merge/123253
Your team elementaryart (old) is subscribed to branch lp:granite.
=== modified file 'demo/main.vala'
--- demo/main.vala	2012-08-16 00:38:28 +0000
+++ demo/main.vala	2012-09-07 11:05:29 +0000
@@ -290,7 +290,8 @@
 
     public static int main(string[] args)
     {
-        new Granite.Demo().run(args);
+        OptionContext context = new OptionContext("Demo");
+        new Granite.Demo().run(ref context, args);
 
         Gtk.main();
 

=== modified file 'lib/Application.vala'
--- lib/Application.vala	2012-06-17 18:44:59 +0000
+++ lib/Application.vala	2012-09-07 11:05:29 +0000
@@ -77,37 +77,52 @@
 
             // Deprecated
             Granite.app = this;
-
         }
 
         [CCode (cheader_filename = "sys/prctl.h", cname = "prctl")]
             protected extern static int prctl (int option, string arg2, ulong arg3, ulong arg4, ulong arg5);
-
-        public new int run (string[] args) {
-
-            // parse commandline options
-            var context = new OptionContext ("");
-
-            context.add_main_entries (options, null);
-            context.add_group (Gtk.get_option_group (false));
-
+        
+        protected virtual void add_custom_cmd_options_group(ref OptionContext context) {
+        }
+
+        protected bool handle_common_cmd_options(ref OptionContext context, string[] args) {
+            
+            add_custom_cmd_options_group (ref context);
+            context.add_main_entries (options, program_name);
+            context.add_group (Gtk.get_option_group (true));
+           
+            
             try {
                 context.parse (ref args);
-            } catch { }
-
-            set_options ();
-
+            } catch (Error e) {
+                warning (e.message);
+            }
+            if (PRINT_VERSION) {
+                stdout.printf("%s %s\n", program_name, build_version);
+                stdout.printf("Copyright %s %s Developers.\n", app_years, program_name);
+                return false;
+            }
+            set_log_options ();
+            return true;
+        }
+        
+        public new int run (ref OptionContext context, string[] args) {
+            
+            if(!handle_common_cmd_options (ref context, args))
+                return 0;
             return base.run (args);
         }
 
         protected static bool DEBUG = false;
+        protected static bool PRINT_VERSION = false;
 
         protected const OptionEntry[] options = {
             { "debug", 'd', 0, OptionArg.NONE, out DEBUG, "Enable debug logging", null },
+            { "version", 'v', 0, OptionArg.NONE, out PRINT_VERSION, "Print version info and exit", null },
             { null }
         };
 
-        protected virtual void set_options () {
+        protected virtual void set_log_options () {
 
             if (DEBUG)
                 Logger.DisplayLevel = LogLevel.DEBUG;


Follow ups