Commit 3499b41a authored by Francois Techene's avatar Francois Techene

Replace dice GtkSpinButton by simple GtkButton

parent 7c2ac4ef
......@@ -28,12 +28,16 @@ struct _RandomizerWindow
/* Template widgets */
GtkStack *stack;
HdyViewSwitcherTitle *switcher_title;
GtkLabel *answer_label;
RandomizerAnimation *fade_answer_animation;
gboolean answer_is_displayed;
guint number_of_dices;
GtkImage *dice_image_1;
GtkImage *dice_image_2;
RandomizerAnimation *fade_answer_animation;
gboolean answer_is_displayed;
};
......@@ -183,16 +187,19 @@ dice_randomize_clicked_cb (GtkButton *btn,
static void
dice_number_changed_cb (GtkSpinButton *spinbutton,
RandomizerWindow *self)
dice_number_toggle_cb (GtkButton *btn,
RandomizerWindow *self)
{
int nb_dices = gtk_spin_button_get_value_as_int (spinbutton);
if (nb_dices > 1) {
if (self->number_of_dices < 2) {
gtk_widget_show( GTK_WIDGET(self->dice_image_2) );
gtk_button_set_label(btn, "One Dice");
self->number_of_dices = 2;
}
else {
gtk_widget_hide( GTK_WIDGET(self->dice_image_2) );
gtk_button_set_label(btn, "Two Dices");
self->number_of_dices = 1;
}
}
......@@ -250,7 +257,7 @@ randomizer_window_class_init (RandomizerWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, RandomizerWindow, dice_image_2);
gtk_widget_class_bind_template_callback (widget_class, answer_randomize_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, dice_randomize_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, dice_number_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, dice_number_toggle_cb);
gtk_widget_class_bind_template_callback (widget_class, switched_tab_cb);
}
......@@ -267,7 +274,9 @@ randomizer_window_init (RandomizerWindow *self)
OPACITY_ANIMATED_PROPERTY);
init_answer_tab(self);
gtk_widget_hide( GTK_WIDGET(self->dice_image_2) );
self->number_of_dices = 1;
}
......
......@@ -162,25 +162,27 @@
<property name="vexpand">True</property>
<property name="hexpand">True</property>
<property name="spacing">24</property>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Roll</property>
<property name="label" translatable="yes">Two Dices</property>
<property name="use-underline">True</property>
<signal name="clicked" handler="dice_randomize_clicked_cb" swapped="no"/>
<style>
<class name="suggested-action"/>
</style>
<signal name="clicked" handler="dice_number_toggle_cb" swapped="no"/>
</object>
</child>
<child>
<object class="GtkSpinButton">
<property name="adjustment">dice_number_adjustment</property>
<property name="valign">center</property>
<object class="GtkButton">
<property name="visible">True</property>
<signal name="value-changed" handler="dice_number_changed_cb" swapped="no"/>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Roll</property>
<property name="use-underline">True</property>
<signal name="clicked" handler="dice_randomize_clicked_cb" swapped="no"/>
<style>
<class name="suggested-action"/>
</style>
</object>
</child>
......
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