Re: How to identify a particular checkbutton ?
- From: Flavio Alberto Lopes Soares <flavio maqplas com br>
- To: Steve Ramsay <steve ramsay spatialcomponents com>
- Cc: gtk-list gnome org
- Subject: Re: How to identify a particular checkbutton ?
- Date: Thu, 12 Dec 2002 09:39:28 -0200
Hi all,
In file interface.c (generated by Glade) :
gtk_signal_connect (GTK_OBJECT (checkbutton_ponto09_20), "toggled",
GTK_SIGNAL_FUNC (on_checkbutton_ponto_toggled),
&ponto_data);
and the callback function :
void
on_checkbutton_ponto_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
const gchar *nm;
nm = gtk_widget_get_name(GTK_WIDGET(togglebutton));
printf("NAME = %s\n", nm);
}
But when I run the program and I click on some checkbutton it prints :
NAME = GtkCheckButton
NAME = GtkCheckButton
NAME = GtkCheckButton
NAME = GtkCheckButton
NAME = GtkCheckButton
NAME = GtkCheckButton
.
.
.
I thought that would print :
NAME = checkbutton_ponto09_20
NAME = checkbutton_ponto09_23
NAME = checkbutton_ponto09_22
NAME = checkbutton_ponto10_20
NAME = checkbutton_ponto11_29
.
.
.
as you said that your program does.
What's wrong ???
If work I will manipulate this string to know what checkbutton was clicked.
PS: Excuse-me for horrible english.
Thanks for all help
--
Flavio Alberto Lopes Soares
flavio maqplas com br
Linux User n. 257636
MAQPLAS INDÚSTRIA E COMÉRCIO DE MÁQUINAS LTDA.
www.maqplas.com.br
maqplas maqplas com br
On 11 Dec 2002 11:26:10 -0400
Steve Ramsay <steve ramsay spatialcomponents com> wrote:
> Hi,
>
> Funny I just implemented something just like that. I have a GtkTable of
> 8x8 toggle buttons. I used glade to create the interface. Here is what
> I did, I named each toggle button in glade to be "pix0_0", "pix0_1",
> etc....
>
> Make sure the glade option Set Widget Names" is set.
>
> I set signal for each toggle:
>
> gtk_signal_connect (GTK_OBJECT (lookup_widget(fillWidget,"pix0_0")),
> "clicked",
> GTK_SIGNAL_FUNC (pixelChange),
> NULL);
> gtk_signal_connect (GTK_OBJECT (lookup_widget(fillWidget,"pix0_1")),
> "clicked",
> GTK_SIGNAL_FUNC (pixelChange),
> NULL);
> etc....
>
>
> my signal function looks like:
>
> extern void pixelChange(
> GtkToggleButton *widget,
> gpointer user_data
> )
> {
> const gchar *nm = gtk_widget_get_name(GTK_WIDGET(widget));
> // nm is in form of pixX_Y
> // copy name to manipulate it.
> //
> //we are going to strip first 3 bytes ("pix")
> char *temp = new char[strlen(test)+1-3];
> strcpy(temp,nm+3);
>
> // we should now have X_Y
> char *save = strtok(test2,"_");
> int x = atoi(save);
>
> save = strtok(NULL,"\n");
> int y = atoi(save);
>
> // now we know the x and y
>
> ....
> delete [] temp;
> }
>
> Hope this helps.
> Steve
>
>
> On Tue, 2002-12-10 at 21:20, Flavio Alberto wrote:
> > Hello all,
> >
> > I create one GtkWindow using GTK 1.2 in C with a matrix formed by 20 rows x 32 columns = 640 checkbuttons to user to mark to create a "picture" to send to a device attached by serial line,
> > to make the interface I used glade,
> > I attached the signal "toggled" to same function (I believe that if I put 640 functions for each check button I will overload my program), and I pass the struct that keep these "bitmap" information, but I don't know how to identify each checkbutton to change the struct to send information to device, I attempt to use gtk_object_get_data but without success;
> >
> > If someone can help I will been thankful
> >
> >
> > Best reguards
> >
> >
> > Flavio Alberto
> > flavio maqplas com br
> > www.maqplas.com.br
> >
> > flaviothunder yahoo com
> >
> > _______________________________________________
> > gtk-list mailing list
> > gtk-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gtk-list
> >
> --
> ========================================================================
> Steve Ramsay CARIS
> Development Manager 264 Rookwood Ave
> Spatial Components Division Fredericton,NB E3B-2M2
> http://www.spatialcomponents.com Phone: 506-458-8533
> mailto:steve ramsay spatialcomponents com Fax: 506 459 3849
> ========================================================================
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]