Re: GtkApplication and argc/arv

On 2011-02-21 at 21:57, Murray Cumming wrote:

I'll leave the other points, as they've received a reply already.

> 2.
> How should we use GOptionContext to parse command line arguments from
> argc/argv when using GtkApplication. Is this the ideal way, using the
> command-line signal?
> It seems a little long-winded.

Totem's usage is not entirely trivial: it requires argument parsing in
the local (i.e. the just executed) and remote (i.e. the currently
running) instances.

simpler cases are:

  • you can just parse all arguments in the local instance, which means
    using g_option_context_parse() prior to creating the G(tk)Application
    instance; in this case, the command line arguments can be used to
    parametrize the Application instance, e.g via GObject properties,
    direct access to instance members, or even GApplication actions (as
    soon as they get more functionality).

  • you can defer all command line parsing to the remote instance, by
    passing the G_APPLICATION_HANDLES_COMMAND_LINE flag to the
    constructor and by connecting to the ::command-line signal; and
    example is in the Dictionary:

probably the latter case is a more direct map of what you'd have done
with libunique or the Bacon copy-and-paste API.

in general, and if at all possible, I'd strongly advise to use the first
approach (local parsing), and keep an eye out as soon as the GAction API
gets more love and functionality.



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