1 | #include <gtk/gtk.h> |
2 | |
3 | #include "exampleapp.h" |
4 | #include "exampleappwin.h" |
5 | |
6 | struct _ExampleApp |
7 | { |
8 | GtkApplication parent; |
9 | }; |
10 | |
11 | G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION); |
12 | |
13 | static void |
14 | example_app_init (ExampleApp *app) |
15 | { |
16 | } |
17 | |
18 | static void |
19 | example_app_activate (GApplication *app) |
20 | { |
21 | ExampleAppWindow *win; |
22 | |
23 | win = example_app_window_new (app: EXAMPLE_APP (ptr: app)); |
24 | gtk_window_present (GTK_WINDOW (win)); |
25 | } |
26 | |
27 | static void |
28 | example_app_open (GApplication *app, |
29 | GFile **files, |
30 | int n_files, |
31 | const char *hint) |
32 | { |
33 | GList *windows; |
34 | ExampleAppWindow *win; |
35 | int i; |
36 | |
37 | windows = gtk_application_get_windows (GTK_APPLICATION (app)); |
38 | if (windows) |
39 | win = EXAMPLE_APP_WINDOW (ptr: windows->data); |
40 | else |
41 | win = example_app_window_new (app: EXAMPLE_APP (ptr: app)); |
42 | |
43 | for (i = 0; i < n_files; i++) |
44 | example_app_window_open (win, file: files[i]); |
45 | |
46 | gtk_window_present (GTK_WINDOW (win)); |
47 | } |
48 | |
49 | static void |
50 | example_app_class_init (ExampleAppClass *class) |
51 | { |
52 | G_APPLICATION_CLASS (class)->activate = example_app_activate; |
53 | G_APPLICATION_CLASS (class)->open = example_app_open; |
54 | } |
55 | |
56 | ExampleApp * |
57 | example_app_new (void) |
58 | { |
59 | return g_object_new (EXAMPLE_APP_TYPE, |
60 | first_property_name: "application-id" , "org.gtk.exampleapp" , |
61 | "flags" , G_APPLICATION_HANDLES_OPEN, |
62 | NULL); |
63 | } |
64 | |