Re: GtkButton GtkHScale
- From: "Brian J. Tarricone" <bjt23 cornell edu>
- To: gtk-app-devel-list gnome org
- Subject: Re: GtkButton GtkHScale
- Date: Mon, 19 Jul 2004 14:27:14 -0400 (EDT)
On Mon, 19 Jul 2004, Johannes Postma wrote:
Hello,
I have an application with a GtkButton and a GtkHScale.The button is
used to set the value of the GtkHScale. Unfortunately my code doesn't
work. I get the next error:
Gtk-CRITICAL **: file gtkrange.c: line 669 (gtk_range_set_value):
assertion `GTK_IS_RANGE (range)' failed
My code is:
void on_BUTTON_clicked (GtkButton *button, gpointer user_data)
{
GtkHScale *scale = (GtkHScale *)g_object_get_data(G_OBJECT(button),
"hscale1");
gtk_range_set_value(GTK_HSCALE(scale), 0);
}
Can someone help me?
you're probably looking for something like this:
{
GtkRange *range = GTK_RANGE(g_object_get_data(....));
gtk_range_set_value(range, 0);
}
gtk_range_set_value() expects a GtkRange as the first parameter
(GtkHScale is a subclass of GtkScale which is a subclass of GtkRange).
also, make sure you're using g_object_set_data() correctly to set
"hscale1" to the proper widget.
however, there's a better way of doing all this:
/* where the scale/button are created */
hscale1 = gtk_hscale_new(...);
/* some stuff */
button = gtk_button_new();
/* some more stuff */
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(on_BUTTON_clicked), hscale1);
/* note here: ^^^^^^^ */
then you don't need to worry about g_object_{set,get}_data():
void on_BUTTON_clicked(GtkButton *b, gpointer user_data)
{
GtkRange *hscale1 = user_data;
gtk_range_set_value(hscale1, 0);
}
hope this helps,
brian
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]