GtkApplication initialization tru command-line signal (vs activate or startup signals)




Hello

I don't understand how GtkApplication and GApplication should be used.

I actually am not sure to understand why is GtkApplication really
useful. I believe it is using DBus to communicate with the session
manager, possibly to permit that only one instance is running. But I
don't understand the details

In particular, I don't understand why GtkApplication don't offer the
simplicity of initializing itself with program argument processing
like gtk_init_with_args do.
Apparently, to initialize such an application, one have to call
gtk_application_new with  G_APPLICATION_HANDLES_COMMAND_LINE and define
a handler for the "command-line" signal. 

I am not sure to understand why both "activate" and "startup" signal
exist for GtkApplications. In fact, I don't understand why they are
both needed.

My code looks like


  my_appl =
    gtk_application_new ("my.program", 
                         G_APPLICATION_HANDLES_COMMAND_LINE);
  g_signal_connect (my_appl, "command-line",
                    G_CALLBACK (my_command_line), NULL);
  g_signal_connect (my_appl, "activate",
                             G_CALLBACK (my_activate),
                    NULL);
  g_signal_connect (my_appl, "startup", 
                             G_CALLBACK (my_startup), NULL);
  if (g_application_register (G_APPLICATION (my_appl), 
                                            NULL, &err))
    {
      g_debug ("application registered");
    }
  else
    g_error ("failed to register application %s", 
             err->message);
  g_debug ("before activation");
  g_application_activate (G_APPLICATION (my_appl));
  g_debug ("before run");
  status = g_application_run (G_APPLICATION (my_appl), 
                                            argc, argv); 



But I notice that my_startup is called before end of registration, but
my_command_line is called only from g_application_run. So my_activate &
my_startup routines cannot take into account any program arguments processed 
by my_command_line!


I am probably doing something wrong. But what?

I also find very few examples of GtkApplication code. Do you know some?

Regards.



-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***



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