mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
Add more GtkScale mark tests
This code tests adding scale marks 'late', and how this interact with inversion.
This commit is contained in:
parent
27f3c3c031
commit
d6f9eb1ff8
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user