Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "exampleapp.h"
|
|
|
|
#include "exampleappwin.h"
|
|
|
|
#include "exampleappprefs.h"
|
|
|
|
|
2016-09-06 17:56:22 +00:00
|
|
|
struct _ExampleApp
|
2014-04-17 18:27:11 +00:00
|
|
|
{
|
|
|
|
GtkApplication parent;
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION);
|
|
|
|
|
|
|
|
static void
|
|
|
|
example_app_init (ExampleApp *app)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
preferences_activated (GSimpleAction *action,
|
|
|
|
GVariant *parameter,
|
|
|
|
gpointer app)
|
|
|
|
{
|
2014-04-17 18:27:11 +00:00
|
|
|
ExampleAppPrefs *prefs;
|
|
|
|
GtkWindow *win;
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
|
2014-04-17 18:27:11 +00:00
|
|
|
win = gtk_application_get_active_window (GTK_APPLICATION (app));
|
|
|
|
prefs = example_app_prefs_new (EXAMPLE_APP_WINDOW (win));
|
|
|
|
gtk_window_present (GTK_WINDOW (prefs));
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
quit_activated (GSimpleAction *action,
|
|
|
|
GVariant *parameter,
|
|
|
|
gpointer app)
|
|
|
|
{
|
|
|
|
g_application_quit (G_APPLICATION (app));
|
|
|
|
}
|
|
|
|
|
2014-04-17 18:27:11 +00:00
|
|
|
static GActionEntry app_entries[] =
|
|
|
|
{
|
|
|
|
{ "preferences", preferences_activated, NULL, NULL, NULL },
|
|
|
|
{ "quit", quit_activated, NULL, NULL, NULL }
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
example_app_startup (GApplication *app)
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *quit_accels[2] = { "<Ctrl>Q", NULL };
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
|
2014-04-17 18:27:11 +00:00
|
|
|
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
|
2014-04-17 18:27:11 +00:00
|
|
|
g_action_map_add_action_entries (G_ACTION_MAP (app),
|
|
|
|
app_entries, G_N_ELEMENTS (app_entries),
|
|
|
|
app);
|
2014-04-17 18:36:33 +00:00
|
|
|
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
|
|
|
|
"app.quit",
|
|
|
|
quit_accels);
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
example_app_activate (GApplication *app)
|
|
|
|
{
|
2014-04-17 18:27:11 +00:00
|
|
|
ExampleAppWindow *win;
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
|
2014-04-17 18:27:11 +00:00
|
|
|
win = example_app_window_new (EXAMPLE_APP (app));
|
|
|
|
gtk_window_present (GTK_WINDOW (win));
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
example_app_open (GApplication *app,
|
|
|
|
GFile **files,
|
2020-07-24 13:54:49 +00:00
|
|
|
int n_files,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *hint)
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
{
|
2014-04-17 18:27:11 +00:00
|
|
|
GList *windows;
|
|
|
|
ExampleAppWindow *win;
|
|
|
|
int i;
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
|
2014-04-17 18:27:11 +00:00
|
|
|
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));
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
|
2014-04-17 18:27:11 +00:00
|
|
|
for (i = 0; i < n_files; i++)
|
|
|
|
example_app_window_open (win, files[i]);
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
|
2014-04-17 18:27:11 +00:00
|
|
|
gtk_window_present (GTK_WINDOW (win));
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
example_app_class_init (ExampleAppClass *class)
|
|
|
|
{
|
2014-04-17 18:27:11 +00:00
|
|
|
G_APPLICATION_CLASS (class)->startup = example_app_startup;
|
|
|
|
G_APPLICATION_CLASS (class)->activate = example_app_activate;
|
|
|
|
G_APPLICATION_CLASS (class)->open = example_app_open;
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ExampleApp *
|
|
|
|
example_app_new (void)
|
|
|
|
{
|
2014-04-17 18:27:11 +00:00
|
|
|
return g_object_new (EXAMPLE_APP_TYPE,
|
|
|
|
"application-id", "org.gtk.exampleapp",
|
|
|
|
"flags", G_APPLICATION_HANDLES_OPEN,
|
|
|
|
NULL);
|
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
2013-07-20 04:21:48 +00:00
|
|
|
}
|