Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
R
randomizer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Francois Techene
randomizer
Commits
3499b41a
Commit
3499b41a
authored
Jan 13, 2021
by
Francois Techene
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace dice GtkSpinButton by simple GtkButton
parent
7c2ac4ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
16 deletions
+27
-16
src/randomizer-window.c
src/randomizer-window.c
+16
-7
src/randomizer-window.ui
src/randomizer-window.ui
+11
-9
No files found.
src/randomizer-window.c
View file @
3499b41a
...
...
@@ -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
*
spinbutto
n
,
RandomizerWindow
*
self
)
dice_number_
toggle_cb
(
GtkButton
*
bt
n
,
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
;
}
...
...
src/randomizer-window.ui
View file @
3499b41a
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment