Re: Application.activate not emitted when opening files.
- From: Stefan Salewski <mail ssalewski de>
- To: Victor Aurélio Santos <victoraur santos gmail com>
- Cc: gtk-app-devel-list list <gtk-app-devel-list gnome org>
- Subject: Re: Application.activate not emitted when opening files.
- Date: Thu, 16 Jun 2016 21:11:24 +0200
On Thu, 2016-06-16 at 20:12 +0200, Stefan Salewski wrote:
I will see if I can find some C code for testing...
Well, looking at the C code of example10 is already enough:
gtk+-3.20.1/examples/application10
exampleapp.c
static void
example_app_activate (GApplication *app)
{
ExampleAppWindow *win;
win = example_app_window_new (EXAMPLE_APP (app));
gtk_window_present (GTK_WINDOW (win));
}
static void
example_app_open (GApplication *app,
GFile **files,
gint n_files,
const gchar *hint)
{
GList *windows;
ExampleAppWindow *win;
int i;
windows = gtk_application_get_windows (GTK_APPLICATION (app));
if (windows)
win = EXAMPLE_APP_WINDOW (windows->data);
else
win = example_app_window_new (EXAMPLE_APP (app));
for (i = 0; i < n_files; i++)
example_app_window_open (win, files[i]);
gtk_window_present (GTK_WINDOW (win));
}
static void
example_app_class_init (ExampleAppClass *class)
{
G_APPLICATION_CLASS (class)->startup = example_app_startup;
G_APPLICATION_CLASS (class)->activate = example_app_activate;
G_APPLICATION_CLASS (class)->open = example_app_open;
}
So your observed behaviour seems to be intended. When application is
started with arguments, example_app_open() is called, which includes
the code of example_app_activate(). This indicates that
example_app_activate() is not executed when application is started with
arguments, so we can assume that "activate" signal is not emitted for
that case. (That was not clear for me from the docs)
For testing, you may download gtk+ tar file, which includes
application10. Building only this one works with these commands
cd application10
glib-compile-schemas .
glib-compile-resources exampleapp.gresource.xml --target=resources.c --generate-source
gcc -o main main.c resources.c exampleapp.c exampleappwin.c exampleappprefs.c `pkg-config --libs --cflags
gtk+-3.0`
A Nim version is also available, see
https://github.com/ngtk3/nim-app
http://forum.nim-lang.org/t/2198#13675
Unfortunately there seems to exist no Vala version yet.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]