Skip to content
Snippets Groups Projects
Commit a1dfaddd authored by Bruce Cowan's avatar Bruce Cowan :airplane:
Browse files

Use GObject bind

parent b8c501b5
No related branches found
No related tags found
No related merge requests found
......@@ -64,12 +64,11 @@
</object>
</child>
<child>
<object class="GtkSpinButton">
<object class="GtkSpinButton" id="scorespin">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adjustment1</property>
<signal name="value-changed" handler="scorespin_value_changed_cb" swapped="no"/>
</object>
<packing>
<property name="position">1</property>
......
......@@ -16,19 +16,12 @@ struct _RugbyAppWindow
RugbyListStore *store;
GtkWidget *scorespin;
GtkWidget *listbox;
};
G_DEFINE_TYPE (RugbyAppWindow, rugby_app_window, GTK_TYPE_APPLICATION_WINDOW)
static void
scorespin_value_changed_cb (GtkSpinButton *spin,
RugbyAppWindow *self)
{
int score = gtk_spin_button_get_value_as_int (spin);
rugby_list_store_set_score (self->store, score);
}
static GtkWidget *
listbox_widget_func (gpointer item,
gpointer user_data)
......@@ -49,6 +42,10 @@ rugby_app_window_init (RugbyAppWindow *self)
listbox_widget_func,
NULL,
NULL);
g_object_bind_property (self->scorespin, "value",
self->store, "score",
G_BINDING_DEFAULT);
}
static void
......@@ -72,8 +69,8 @@ rugby_app_window_class_init (RugbyAppWindowClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/uk/me/bcowan/rugby/interface.ui");
gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, scorespin);
gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, listbox);
gtk_widget_class_bind_template_callback (widget_class, scorespin_value_changed_cb);
}
RugbyAppWindow *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment