Build:
gcc `pkg-config --cflags --libs gtk+-2.0` -W -g -o gtkscaletest gtkscaletest.c

Run:
./gtkscaletest

Drag the slider to the far right.  The number says "90.0" (see
attached screenshot).

Since the GtkAdjustment used when creating the slider says "100.0" as
the range, I'd expect the slider to say "100.0" when I move it to the
far right.

I was unable to find any upstream bug report about this.  I don't know
if it's Debian specific.

  Regards //Johan
#include <gtk/gtk.h>

/*
 * Terminate the main loop.
 */
static void
on_destroy (GtkWidget * widget, gpointer data)
{
    gtk_main_quit ();
}

int
main (int argc, char *argv[])
{
    GtkWidget *window;
    GtkObject *adjustment;
    GtkWidget *scale;

    gtk_init (&argc, &argv);

    /* create the main, top level, window */
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size (GTK_WINDOW (window), 200, 50);
    
    /* Connect the destroy event of the window with our on_destroy function
     * When the window is about to be destroyed we get a notificaiton and
     * stop the main GTK loop
     */
    g_signal_connect (G_OBJECT (window), "destroy",
                      G_CALLBACK (on_destroy), NULL);

    /* Create the scale */
    adjustment = gtk_adjustment_new (50.0, 0.0, 100.0, 1.0, 10.0, 10.0);
    scale = gtk_hscale_new (GTK_ADJUSTMENT(adjustment));
    gtk_scale_set_draw_value (GTK_SCALE(scale), 1);
    
    /* and insert it into the main window  */
    gtk_container_add (GTK_CONTAINER (window), scale);

    /* make sure that everything, window and label, are visible */
    gtk_widget_show_all (window);

    /* start the main loop */
    gtk_main ();

    return 0;
}

<<attachment: gtkscaletest.png>>

Reply via email to