Re: [Re: how to get text from combo box]



alprach wrote:
hi,

i tried ..... but don't know why it is not working.

this is a gist of my program

GtkWidget *combo;
GList *list=NULL;

//list-- has a list of items

gtk_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->list),"select-child",
GTK_SIGNAL_FUNC(my_callback),NULL);

//my_callback function is like this

void my_callback(GtkWidget *combo)
{
char *string;
string=gtk_editable_get_chars(GTK_EDITABLE(GTK_COMBO(combo)->entry),0,-1);
g_print("%s\n",string);
free(string);
}

its also giving me warning such as

warning : invalid cast from GtkList to GtkCombo
and many more such warnings

can somebody help me..



Jeff Shipman <shippy nmt edu> wrote:
The entry widget of a combo box can be accessed via
GTK_ENTRY(GT K_COMBO(my_combo_box)->entry). Then, you
can set activate signals on that and you can use
gtk_editable_get_chars() to get the text. If you want
to get the text each time something is selected in
the list, then hook the "select-child" signal up to
GTK_ENTRY(GTK_COMBO(my_combo_box)->list) and then
use gtk_editable_get_chars() as before.

Hope this helps. :)

Jeff "Shippy" Shipman E-Mail: shippy nmt edu
Computer Science Major ICQ: 1786493
New Mexico Institute of Mining and Technology
Homepage: http://www.nmt.edu/~shippy

On 20 Feb 2001, alprach wrote:

hi,.

i am using a combo box ..from which i need to get the text within it..
how do i connect signal to it(i tried using "activate" but didn't work).
i am using gtk_get_text_entry in the callback function ...


can somebody help me ...

bye,


____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1

_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list



_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list


____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1

_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list



Hi,

Your warning appears because you give a GtkList to your callback (the "list" member of a GtkCombo is a widget GtkList...)
So your callback must be like this :

void my_callback(GtkList *list, GtkWidget *element, gpointer my_data)
{
...
}

where element is the newly selected child.

regards, JFB



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