diff options
author | Matthias Clasen <mclasen@redhat.com> | 2012-01-18 00:56:37 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2012-01-18 00:58:38 -0500 |
commit | d6f9eb1ff87e9cb0c7e7ced41a4e2b9e7dcc2bdd (patch) | |
tree | b0061b930d84157e8dd573c03d4573ee7766de6c /tests/testscale.c | |
parent | 27f3c3c03120facdfc94a02c6c00cfa70531e131 (diff) | |
download | gtk+-d6f9eb1ff87e9cb0c7e7ced41a4e2b9e7dcc2bdd.tar.gz |
Add more GtkScale mark tests
This code tests adding scale marks 'late', and how this interact
with inversion.
Diffstat (limited to 'tests/testscale.c')
-rwxr-xr-x | tests/testscale.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/tests/testscale.c b/tests/testscale.c index ee5c1dfa06..b60bbfb0ed 100755 --- a/tests/testscale.c +++ b/tests/testscale.c @@ -23,6 +23,7 @@ GSList *scales; GtkWidget *flipbox; +GtkWidget *extra_scale; static void invert (GtkButton *button) @@ -65,6 +66,30 @@ trough (GtkToggleButton *button) } } +gdouble marks[3] = { 0.0, 50.0, 100.0 }; +gdouble extra_marks[2] = { 20.0, 40.0 }; + +static void +extra (GtkToggleButton *button) +{ + gboolean value; + + value = gtk_toggle_button_get_active (button); + + if (value) + { + gtk_scale_add_mark (GTK_SCALE (extra_scale), extra_marks[0], GTK_POS_TOP, NULL); + gtk_scale_add_mark (GTK_SCALE (extra_scale), extra_marks[1], GTK_POS_TOP, NULL); + } + else + { + gtk_scale_clear_marks (GTK_SCALE (extra_scale)); + gtk_scale_add_mark (GTK_SCALE (extra_scale), marks[0], GTK_POS_BOTTOM, NULL); + gtk_scale_add_mark (GTK_SCALE (extra_scale), marks[1], GTK_POS_BOTTOM, NULL); + gtk_scale_add_mark (GTK_SCALE (extra_scale), marks[2], GTK_POS_BOTTOM, NULL); + } +} + int main (int argc, char *argv[]) { GtkWidget *window; @@ -74,7 +99,6 @@ int main (int argc, char *argv[]) GtkWidget *button; GtkWidget *frame; GtkWidget *scale; - gdouble marks[3] = { 0.0, 50.0, 100.0 }; const gchar *labels[3] = { "<small>Left</small>", "<small>Middle</small>", @@ -111,11 +135,10 @@ int main (int argc, char *argv[]) gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0); frame = gtk_frame_new ("Simple marks"); - scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1); + extra_scale = scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1); scales = g_slist_prepend (scales, scale); gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE); gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_BOTTOM, NULL); - gtk_scale_add_mark (GTK_SCALE (scale), 25.0, GTK_POS_BOTTOM, NULL); gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_BOTTOM, NULL); gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_BOTTOM, NULL); gtk_container_add (GTK_CONTAINER (frame), scale); @@ -181,6 +204,12 @@ int main (int argc, char *argv[]) gtk_container_add (GTK_CONTAINER (box2), button); gtk_widget_show_all (window); + button = gtk_toggle_button_new_with_label ("Extra"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE); + g_signal_connect (button, "toggled", G_CALLBACK (extra), NULL); + gtk_container_add (GTK_CONTAINER (box2), button); + gtk_widget_show_all (window); + gtk_main (); return 0; |