Debian Codegraph @

demos/icon-browser/iconbrowserapp.c

raw
1 #include <gtk/gtk.h>
2
3 #include "iconbrowserapp.h"
4 #include "iconbrowserwin.h"
5
6 struct _IconBrowserApp
7 {
8 GtkApplication parent;
9 };
10
11 struct _IconBrowserAppClass
12 {
13 GtkApplicationClass parent_class;
14 };
15
16 G_DEFINE_TYPE(IconBrowserApp, icon_browser_app, GTK_TYPE_APPLICATION);
17
18 static void
19 icon_browser_app_init (IconBrowserApp *app)
20 {
21 }
22
23 static void
24 quit_activated (GSimpleAction *action,
25 GVariant *parameter,
26 gpointer app)
27 {
28 g_application_quit (G_APPLICATION (app));
29 }
30
31 static GActionEntry app_entries[] =
32 {
33 { "quit", quit_activated, NULL, NULL, NULL }
34 };
35
36 static void
37 icon_browser_app_startup (GApplication *app)
38 {
39 const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
40
41 G_APPLICATION_CLASS (icon_browser_app_parent_class)->startup (app);
42
43 g_action_map_add_action_entries (G_ACTION_MAP (app),
44 app_entries, G_N_ELEMENTS (app_entries),
45 app);
46 gtk_application_set_accels_for_action (GTK_APPLICATION (app),
47 "app.quit",
48 quit_accels);
49 }
50
51 static void
52 icon_browser_app_activate (GApplication *app)
53 {
54 IconBrowserWindow *win;
55
56 win = icon_browser_window_new (ICON_BROWSER_APP (app));
57 gtk_window_present (GTK_WINDOW (win));
58 }
59
60 static void
61 icon_browser_app_class_init (IconBrowserAppClass *class)
62 {
63 G_APPLICATION_CLASS (class)->startup = icon_browser_app_startup;
64 G_APPLICATION_CLASS (class)->activate = icon_browser_app_activate;
65 }
66
67 IconBrowserApp *
68 icon_browser_app_new (void)
69 {
70 return g_object_new (ICON_BROWSER_APP_TYPE,
71 "application-id", "org.gtk.IconBrowser",
72 NULL);
73 }