Re: [Vala] regarding Gtk.Application managing a single instance app
- From: Erick Pérez Castellanos <erickpc gnome org>
- To: vala-list gnome org
- Subject: Re: [Vala] regarding Gtk.Application managing a single instance app
- Date: Mon, 4 Feb 2013 09:11:16 -0500
/* I guess the issues is the way you handle the app invocation, you're
trying to parse the
command-line arguments yourself, and that could be causing the errors. I
recommend to look into
the vala application inside gnome that use Gtk.Application. Gnome Contacts,
Gnome Boxes does that
and I think Baobab does as well. */
/* Check the code below which is mainly what I use. */
public class App: Gtk.Application {
private ApplicationWindow window;
public App () {
/* Here, you should check the flags, since those flags define how your app
will be invoked */
Object (application_id: "nova.ncopier", flags:
ApplicationFlags.HANDLES_COMMAND_LINE);
}
/* For instance the HANDLES_COMMAND_LINE flags wil give you access to this
method that
will be called everytime some call your application from the command line.
*/
public override int command_line (ApplicationCommandLine command_line) {
var args = command_line.get_arguments ();
/* blah, blah, blah */
activate ();
return 0;
}
public override void activate () {
if (window == null)
create_window ();
else
add_new_copy_to_window ();
window.present ();
}
}
/* And your application is launched like this */
public static int
main (string[] args) {
var app = new App ();
app.run (args);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]