problems with gtk_toggle_button_set_active() and check buttons
- From: Ignacio Nodal <inodal teleline es>
- To: GTK-List <gtk-list gnome org>
- Subject: problems with gtk_toggle_button_set_active() and check buttons
- Date: Sun, 10 Jun 2001 21:32:55 +0200
Hi again,
I've create a check button but I've also added a callback which must be
called if the right button has been pressed. The calldata is a pointer
to my class.
When I create it I set the state to TRUE or FALSE according to the value
stored in *parameter.
[...]
_boolean_button = gtk_check_button_new();
_label_widget = gtk_label_new (_label);
gtk_container_add(GTK_CONTAINER(_boolean_button), _label_widget);
gtk_misc_set_alignment(GTK_MISC(_label_widget), 0.1f, 0.5f);
gtk_widget_show(_label_widget);
//"button_press_event" instead of "toggled" to know which button was
pressed
gtk_signal_connect (GTK_OBJECT(_boolean_button), "button_press_event",
GTK_SIGNAL_FUNC(CB_ChangedValue), (gpointer) this);
//set state as indicated in "*parameter"
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_boolean_button),
(*parameter));
[...]
In my callback I look which button has been pressed so I can use
differents callbacks for the left and the right button. I know the
button only toggles using the left button, that's ok for me.
The problem is when I ask in my CB_ChangedValue for "button->active" it
returns me FALSE when it's "pressed-in" and TRUE when it's "raised-out".
If I don't use gtk_toggle_button_set_active() in the code above all
works fine..
Here is the callback function (just testing)...
void CB_ChangedValue(GtkWidget* widget, GdkEventButton* event, gpointer
cd)
{
ParameterBoolean * pb = (ParameterBoolean *) cd;
switch (event->button) {
case 1:
*(pb->parameter) = !(*(pb->parameter));
if(pb->_type == BooleanCharCase || pb->_type == BooleanPixmap)
pb->Update();
if(pb->_callback != NULL) {
void (*pf) (gpointer) = (void (*) (gpointer)) pb->_callback;
pf(pb->_calldata);
}
if (GTK_TOGGLE_BUTTON(widget)->active) {
g_print("button activated w:%d
p:%d\n",GTK_TOGGLE_BUTTON(widget)->active,*(pb->parameter));
} else {
g_print("button desactivated w:%d
p:%d\n",GTK_TOGGLE_BUTTON(widget)->active,*(pb->parameter));
}
break;
case 3:
if(pb->_btn3callback != NULL) {
void (*pf) (gpointer) = (void (*) (gpointer)) pb->_btn3callback;
pf(pb->_btn3data);
}
break;
}
What's going wrong?
Thanks in advance,
Ignacio Nodal
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]