Commit fcba75c2 authored by Matthias Clasen's avatar Matthias Clasen

example: Modernize the prefs dialog

We should show the current best practice for this kind of
dialog, and use a headerbar with a window close button.
parent b718b95a
......@@ -25,12 +25,6 @@ struct _ExampleAppPrefsPrivate
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
preferences_closed (GtkWidget *button)
{
gtk_widget_destroy (gtk_widget_get_toplevel (button));
}
static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
......@@ -68,12 +62,10 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), preferences_closed);
}
ExampleAppPrefs *
example_app_prefs_new (ExampleAppWindow *win)
{
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, "use-header-bar", TRUE, NULL);
}
......@@ -64,19 +64,6 @@
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="action_area">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="close">
<signal name="clicked" handler="preferences_closed"/>
<property name="visible">True</property>
<property name="label">_Close</property>
<property name="use-underline">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
......
......@@ -25,12 +25,6 @@ struct _ExampleAppPrefsPrivate
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
preferences_closed (GtkWidget *button)
{
gtk_widget_destroy (gtk_widget_get_toplevel (button));
}
static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
......@@ -68,12 +62,10 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), preferences_closed);
}
ExampleAppPrefs *
example_app_prefs_new (ExampleAppWindow *win)
{
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, "use-header-bar", TRUE, NULL);
}
......@@ -64,19 +64,6 @@
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="action_area">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="close">
<signal name="clicked" handler="preferences_closed"/>
<property name="visible">True</property>
<property name="label">_Close</property>
<property name="use-underline">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
......
......@@ -25,12 +25,6 @@ struct _ExampleAppPrefsPrivate
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
preferences_closed (GtkWidget *button)
{
gtk_widget_destroy (gtk_widget_get_toplevel (button));
}
static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
......@@ -68,12 +62,10 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), preferences_closed);
}
ExampleAppPrefs *
example_app_prefs_new (ExampleAppWindow *win)
{
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, "use-header-bar", TRUE, NULL);
}
......@@ -64,19 +64,6 @@
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="action_area">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="close">
<signal name="clicked" handler="preferences_closed"/>
<property name="visible">True</property>
<property name="label">_Close</property>
<property name="use-underline">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
......
......@@ -25,12 +25,6 @@ struct _ExampleAppPrefsPrivate
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
preferences_closed (GtkWidget *button)
{
gtk_widget_destroy (gtk_widget_get_toplevel (button));
}
static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
......@@ -68,12 +62,10 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), preferences_closed);
}
ExampleAppPrefs *
example_app_prefs_new (ExampleAppWindow *win)
{
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, "use-header-bar", TRUE, NULL);
}
......@@ -64,19 +64,6 @@
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="action_area">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="close">
<signal name="clicked" handler="preferences_closed"/>
<property name="visible">True</property>
<property name="label">_Close</property>
<property name="use-underline">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
......
......@@ -25,12 +25,6 @@ struct _ExampleAppPrefsPrivate
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
preferences_closed (GtkWidget *button)
{
gtk_widget_destroy (gtk_widget_get_toplevel (button));
}
static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
......@@ -68,12 +62,10 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), preferences_closed);
}
ExampleAppPrefs *
example_app_prefs_new (ExampleAppWindow *win)
{
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, "use-header-bar", TRUE, NULL);
}
......@@ -64,19 +64,6 @@
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="action_area">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="close">
<signal name="clicked" handler="preferences_closed"/>
<property name="visible">True</property>
<property name="label">_Close</property>
<property name="use-underline">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment