1 | #include <gtk/gtk.h> |
2 | |
3 | #include "exampleapp.h" |
4 | #include "exampleappwin.h" |
5 | #include "exampleappprefs.h" |
6 | |
7 | struct _ExampleAppPrefs |
8 | { |
9 | GtkDialog parent; |
10 | |
11 | GSettings *settings; |
12 | GtkWidget *font; |
13 | GtkWidget *transition; |
14 | }; |
15 | |
16 | G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG) |
17 | |
18 | static void |
19 | example_app_prefs_init (ExampleAppPrefs *prefs) |
20 | { |
21 | gtk_widget_init_template (GTK_WIDGET (prefs)); |
22 | prefs->settings = g_settings_new (schema_id: "org.gtk.exampleapp" ); |
23 | |
24 | g_settings_bind (settings: prefs->settings, key: "font" , |
25 | object: prefs->font, property: "font" , |
26 | flags: G_SETTINGS_BIND_DEFAULT); |
27 | g_settings_bind (settings: prefs->settings, key: "transition" , |
28 | object: prefs->transition, property: "active-id" , |
29 | flags: G_SETTINGS_BIND_DEFAULT); |
30 | } |
31 | |
32 | static void |
33 | example_app_prefs_dispose (GObject *object) |
34 | { |
35 | ExampleAppPrefs *prefs; |
36 | |
37 | prefs = EXAMPLE_APP_PREFS (ptr: object); |
38 | |
39 | g_clear_object (&prefs->settings); |
40 | |
41 | G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object); |
42 | } |
43 | |
44 | static void |
45 | example_app_prefs_class_init (ExampleAppPrefsClass *class) |
46 | { |
47 | G_OBJECT_CLASS (class)->dispose = example_app_prefs_dispose; |
48 | |
49 | gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class), |
50 | resource_name: "/org/gtk/exampleapp/prefs.ui" ); |
51 | gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font); |
52 | gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition); |
53 | } |
54 | |
55 | ExampleAppPrefs * |
56 | example_app_prefs_new (ExampleAppWindow *win) |
57 | { |
58 | return g_object_new (EXAMPLE_APP_PREFS_TYPE, first_property_name: "transient-for" , win, "use-header-bar" , TRUE, NULL); |
59 | } |
60 | |