Commit 39c4d7c7 authored by Zander Brown's avatar Zander Brown 🔄 Committed by Guido Gunther

example: Add to example application

Silly simple demo of HdyDialog.
parent f6efb428
......@@ -229,6 +229,57 @@ adj_arrows_duration_value_changed_cb (GtkAdjustment *adj,
hdy_arrows_animate (HDY_ARROWS (self->arrows));
}
static void
dialog_close_cb (GtkDialog *self)
{
gtk_widget_destroy (GTK_WIDGET (self));
}
static void
dialog_clicked_cb (GtkButton *btn,
ExampleWindow *self)
{
GtkWidget *dlg;
GtkWidget *lbl;
dlg = hdy_dialog_new (GTK_WINDOW (self));
gtk_window_set_title (GTK_WINDOW (dlg), "HdyDialog");
lbl = gtk_label_new ("Hello, World!");
gtk_widget_set_vexpand (lbl, TRUE);
gtk_widget_set_valign (lbl, GTK_ALIGN_CENTER);
gtk_widget_set_halign (lbl, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
lbl);
gtk_widget_show (lbl);
gtk_widget_show (dlg);
}
static void
dialog_action_clicked_cb (GtkButton *btn,
ExampleWindow *self)
{
GtkWidget *dlg;
GtkWidget *lbl;
dlg = hdy_dialog_new (GTK_WINDOW (self));
gtk_window_set_title (GTK_WINDOW (dlg), "HdyDialog");
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
"Done", GTK_RESPONSE_ACCEPT,
"Cancel", GTK_RESPONSE_CANCEL,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_ACCEPT);
g_signal_connect (G_OBJECT (dlg), "response", G_CALLBACK (dialog_close_cb), NULL);
lbl = gtk_label_new ("Hello, World!");
gtk_widget_set_vexpand (lbl, TRUE);
gtk_widget_set_valign (lbl, GTK_ALIGN_CENTER);
gtk_widget_set_halign (lbl, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
lbl);
gtk_widget_show (lbl);
gtk_widget_show (dlg);
}
ExampleWindow *
example_window_new (GtkApplication *application)
......@@ -304,6 +355,8 @@ example_window_class_init (ExampleWindowClass *klass)
gtk_widget_class_bind_template_callback_full (widget_class, "btn_arrows_right_toggled_cb", G_CALLBACK(btn_arrows_right_toggled_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "adj_arrows_count_value_changed_cb", G_CALLBACK(adj_arrows_count_value_changed_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "adj_arrows_duration_value_changed_cb", G_CALLBACK(adj_arrows_duration_value_changed_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "dialog_clicked_cb", G_CALLBACK(dialog_clicked_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "dialog_action_clicked_cb", G_CALLBACK(dialog_action_clicked_cb));
}
static gchar *
......
......@@ -1006,6 +1006,66 @@
<property name="title">Search bar</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<property name="valign">center</property>
<property name="halign">center</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="opacity">0.5</property>
<property name="halign">center</property>
<property name="margin_bottom">12</property>
<property name="label" translatable="yes">Dialog</property>
<property name="justify">center</property>
<property name="wrap">True</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="2"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="label" translatable="yes">Presentation Dialog</property>
<signal name="clicked" handler="dialog_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="label" translatable="yes">Action Dialog</property>
<signal name="clicked" handler="dialog_action_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="name">dialog</property>
<property name="title">Dialog</property>
</packing>
</child>
</object>
</child>
</object>
......
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