Re: [gtk-list] Glade / adjustments and hscale callbacks

Dean Skuldt wrote:
> Hello,
> With Glade I am trying to have multiple hscales connected to a single
> adjustment (just as is done in the GTK rangewidgets.c example).
> This way, when one hscale is changed, other hscales are also
> changed.  However, in Glade, a hscale widget is created by:
>   hscale = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (10, 0,
>                         100, 0, 0, 0)));
> Here the adjustment which is connected to the hscale is newly created.
> There is no option within Glade to create a new adjustment, and there is
> no option to create a new hscale and connect it to a particular
> adjustment.
> Is there any way, after an hscale is created in this way, to connect the
> hscale to my own adjustment?

This is a known problem in Glade. But you can get around it by setting
adjustments yourself, after creating the window/dialog, e.g.

  window1 = create_window1 ();
  hscale1 = lookup_widget (window1, "hscale1");
  hscale2 = lookup_widget (window1, "hscale2");
  gtk_range_set_adjustment (GTK_RANGE (hscale2), GTK_RANGE (hscale1)->adjustment);

> Also, I would like to connect the "changed" signal to the hscale created
> in Glade.  Is this possible?  I don't have this option with my version of
> Glade.

You can do this in a similar way. It's mentioned in the FAQ:

3.7 How do I connect to GtkAdjustment signals?

Glade doesn't support this at present, but you can set it up manually, in a
similar way to question 3.6.

When you create the window, get a pointer to the widget containing the
adjustment, and connect to the "changed" or "value_changed" signals:

  window1 = create_window1 ();
  hscale = lookup_widget (window1, "hscale1");
  gtk_signal_connect (GTK_OBJECT (GTK_RANGE (hscale)->adjustment),
                      "changed", GTK_SIGNAL_FUNC (on_adjustment_changed),


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