forked from AuroraMiddleware/gtk
a8e84545d1
Using an offset from the struct means you can have children in both the public and private (via G_PRIVATE_OFFSET) parts of the instance. It also matches the new private macros nicer. https://bugzilla.gnome.org/show_bug.cgi?id=702563 Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
76 lines
2.1 KiB
C
76 lines
2.1 KiB
C
#include <gtk/gtk.h>
|
|
|
|
#include "exampleapp.h"
|
|
#include "exampleappwin.h"
|
|
#include "exampleappprefs.h"
|
|
|
|
struct _ExampleAppPrefs
|
|
{
|
|
GtkDialog parent;
|
|
};
|
|
|
|
struct _ExampleAppPrefsClass
|
|
{
|
|
GtkDialogClass parent_class;
|
|
};
|
|
|
|
typedef struct _ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
|
|
|
|
struct _ExampleAppPrefsPrivate
|
|
{
|
|
GSettings *settings;
|
|
GtkWidget *font;
|
|
GtkWidget *transition;
|
|
GtkWidget *close;
|
|
};
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
|
|
|
|
static void
|
|
example_app_prefs_init (ExampleAppPrefs *prefs)
|
|
{
|
|
ExampleAppPrefsPrivate *priv;
|
|
|
|
priv = example_app_prefs_get_instance_private (prefs);
|
|
gtk_widget_init_template (GTK_WIDGET (prefs));
|
|
priv->settings = g_settings_new ("org.gtk.exampleapp");
|
|
|
|
g_settings_bind (priv->settings, "font",
|
|
priv->font, "font",
|
|
G_SETTINGS_BIND_DEFAULT);
|
|
g_settings_bind (priv->settings, "transition",
|
|
priv->transition, "active-id",
|
|
G_SETTINGS_BIND_DEFAULT);
|
|
g_signal_connect_swapped (priv->close, "clicked",
|
|
G_CALLBACK (gtk_widget_destroy), prefs);
|
|
}
|
|
|
|
static void
|
|
example_app_prefs_dispose (GObject *object)
|
|
{
|
|
ExampleAppPrefsPrivate *priv;
|
|
|
|
priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
|
|
g_clear_object (&priv->settings);
|
|
|
|
G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
|
|
}
|
|
|
|
static void
|
|
example_app_prefs_class_init (ExampleAppPrefsClass *class)
|
|
{
|
|
G_OBJECT_CLASS (class)->dispose = example_app_prefs_dispose;
|
|
|
|
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
|
|
"/org/gtk/exampleapp/prefs.ui");
|
|
gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
|
|
gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
|
|
gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, close);
|
|
}
|
|
|
|
ExampleAppPrefs *
|
|
example_app_prefs_new (ExampleAppWindow *win)
|
|
{
|
|
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
|
|
}
|