Re: GtkRange??

Orlando Andico <> writes:

> On Mon, 6 Apr 1998, Jonathan Belson wrote:
> > 
> > Hi
> > 
> > Hope I'm not making myself sound stupid, but I can't figure out how
> > to extract a value from a Range widget...I can set up a callback for
> > when the slider is moved (using gtkmm), but I can't read what it's changed to
> > 8^/  Can anyone elucidate, or point me to a piece of example code?
> This is one of the things I hate about GTK+ !!!
> You DON'T extract values from a scale widget (what I assume you mean the
> range is) in fact you can't even attach a callback to a ^%^*$%@# scale..
> you attach the callback to the associated ADJUSTMENT widget, and extract
> values like so..
>  value = GTK_ADJUSTMENT(mywidget)->value;

If this is the biggest complaint you have about GTK. Then, well,
I'm happy. ;-)

  GtkWidget *range;
  GtkAdjustment *adj;

  adj = gtk_adjustment_new (value, upper, lower, step_increment,
                            page_increment, page_size);
  range = gtk_hscale_new (adj);

  gtk_signal_connect (adj, "value_changed", GTK_SIGNAL_FUNC
                      (callback), NULL);

callback (GtkAdjustment *adj, gpointer data)
  g_print ("New value is %f\n", adj->value);
That doesn't exactly seem very onerous to me. Note that you
can get the adjustment from the range with:

  gtk_range_get_adjustment (GTK_RANGE (range))

Note that an Adjustment is a a GtkObject, but not a GtkWidget.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]