forked from AuroraMiddleware/gtk
8087bb7a22
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.
67 lines
1.5 KiB
C
67 lines
1.5 KiB
C
#include <gtk/gtk.h>
|
|
|
|
#include "exampleapp.h"
|
|
#include "exampleappwin.h"
|
|
|
|
struct ExampleApp {
|
|
GtkApplication parent;
|
|
};
|
|
|
|
struct ExampleAppClass {
|
|
GtkApplicationClass parent_class;
|
|
};
|
|
|
|
G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION);
|
|
|
|
static void
|
|
example_app_init (ExampleApp *app)
|
|
{
|
|
}
|
|
|
|
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)->activate = example_app_activate;
|
|
G_APPLICATION_CLASS (class)->open = example_app_open;
|
|
}
|
|
|
|
ExampleApp *
|
|
example_app_new (void)
|
|
{
|
|
return g_object_new (EXAMPLE_APP_TYPE,
|
|
"application-id", "org.gtk.exampleapp",
|
|
"flags", G_APPLICATION_HANDLES_OPEN,
|
|
NULL);
|
|
}
|