0

I needed to add some command option for an app I'm developing. I get the options working nicely after adding the following function

public const GLib.OptionEntry[] options = {
    // --version
    { "version", 0, 0, OptionArg.NONE, ref command_line_option_version, "Display version number", null },
    // --monitor
    { "monitor", 0, 0, OptionArg.STRING, ref command_line_option_monitor, "PATH", "Path to nutty config (i.e. /home/sid/.config/nutty)" },
    // --alert
    { "alert", 0, 0, OptionArg.NONE, ref command_line_option_alert, "Run Nutty in device alert mode", null },
    // list terminator
    { null }
};

But then when I right click the app icon the "About" option does not come. and the following warning also explains the reason:

nutty.vala:287.5-296.3: warning: Nutty.options hides inherited constant `Granite.Application.options'. Use the `new' keyword if hiding was intentional

How do I get around this - i.e. how can I add the command line options while still keeping the icon right click behavior intact ? Probably some way I can extend the Granite.Application.options ?

My source code is at the following Launchpad location.

1 Answer 1

2

take a look at this commit for a possible solution.

http://bazaar.launchpad.net/~elementary-apps/screenshot-tool/trunk/revision/147

2
  • Many thanks for the suggestion - I will check if that woks. Mar 19, 2016 at 10:24
  • Thanks for the tip...I got my code working with the command line parameters while still preserving the Granite "About" menu on right click of app icon....the following was the key to get both working: public static int main (string[] args) { Gtk.init (ref args); application = new Nutty(); //Workaround to get Granite's --about & Gtk's --help working together if ("--help" in args || "-h" in args) { return ((Gtk.Application)application).run(args); } else { print("direct call to run app \n"); return application.run(args); } } Mar 20, 2016 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.