tests: Fix teststackedheader

Connect to signals programmatically.
This commit is contained in:
Alexander Mikhaylenko 2020-05-11 19:32:52 +05:00
parent 1d2af907fc
commit 2940b17a8e
2 changed files with 9 additions and 6 deletions

View File

@ -4,7 +4,6 @@
static GtkWidget *header_stack; static GtkWidget *header_stack;
static GtkWidget *page_stack; static GtkWidget *page_stack;
#if 0
static void static void
back_to_main (GtkButton *button) back_to_main (GtkButton *button)
{ {
@ -18,13 +17,14 @@ go_to_secondary (GtkButton *button)
gtk_stack_set_visible_child_name (GTK_STACK (header_stack), "secondary"); gtk_stack_set_visible_child_name (GTK_STACK (header_stack), "secondary");
gtk_stack_set_visible_child_name (GTK_STACK (page_stack), "secondary"); gtk_stack_set_visible_child_name (GTK_STACK (page_stack), "secondary");
} }
#endif
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
GtkBuilder *builder; GtkBuilder *builder;
GtkWidget *win; GtkWidget *win;
GtkWidget *new_btn;
GtkWidget *back_btn;
#ifdef GTK_SRCDIR #ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR); g_chdir (GTK_SRCDIR);
@ -38,6 +38,11 @@ main (int argc, char *argv[])
win = (GtkWidget *)gtk_builder_get_object (builder, "window"); win = (GtkWidget *)gtk_builder_get_object (builder, "window");
header_stack = (GtkWidget *)gtk_builder_get_object (builder, "header_stack"); header_stack = (GtkWidget *)gtk_builder_get_object (builder, "header_stack");
page_stack = (GtkWidget *)gtk_builder_get_object (builder, "page_stack"); page_stack = (GtkWidget *)gtk_builder_get_object (builder, "page_stack");
new_btn = (GtkWidget *)gtk_builder_get_object (builder, "new_btn");
back_btn = (GtkWidget *)gtk_builder_get_object (builder, "back_btn");
g_signal_connect (new_btn, "clicked", G_CALLBACK (go_to_secondary), NULL);
g_signal_connect (back_btn, "clicked", G_CALLBACK (back_to_main), NULL);
g_assert (header_stack); g_assert (header_stack);

View File

@ -11,10 +11,9 @@
<property name="child"> <property name="child">
<object class="GtkHeaderBar"> <object class="GtkHeaderBar">
<child type="start"> <child type="start">
<object class="GtkButton"> <object class="GtkButton" id="new_btn">
<property name="label">New</property> <property name="label">New</property>
<property name="valign">center</property> <property name="valign">center</property>
<signal name="clicked" handler="go_to_secondary"/>
</object> </object>
</child> </child>
<child type="title"> <child type="title">
@ -32,10 +31,9 @@
<property name="child"> <property name="child">
<object class="GtkHeaderBar"> <object class="GtkHeaderBar">
<child type="start"> <child type="start">
<object class="GtkButton"> <object class="GtkButton" id="back_btn">
<property name="label">&lt;</property> <property name="label">&lt;</property>
<property name="valign">center</property> <property name="valign">center</property>
<signal name="clicked" handler="back_to_main"/>
</object> </object>
</child> </child>
</object> </object>