Re: clist & text entry



On 18 Jul 2001 11:56:14 +0200, Jan-Marek Glogowski wrote:
> Hi Castelo
> 
> > How I want to grab data from clist(when clicked on it)
> > and display it into gtkentry.. anyone.. any idea?
> 
> Do you want to display data, which is connected to the cell objects or the
> text of the item? Here comes the code for the text:
> 
> Somewhere where you construct your dialog
> 
> ....
> gtk_signal_connect(GTK_OBJECT(clist), "select_row",
> 	GTK_SIGNAL_FUNC(select_row_event), my_entry);
> ...
> 
> 
> void select_row_event(GtkWidget *clist, gint row, gint column,
> GdkEventButton *event, gpointer user_data)
> {
>    gchar* line;
>    gtk_clist_get_text(GTK_CLIST(clist), row, column, &line);
>    gtk_entry_set_text(GTK_ENTRY(my_entry), line);
> }
> 
> 
> I'm not shure if you have to free the line with g_free(line).
> Just try it.
> 

No you don't want to g_free (line); The pointer to the text in a clist 
is directly from the internal data structure of the clist so you
shouldn't mess with it, however the entry will make it's own copy of the
text so if you're just moving the text directly from the clist to the
entry you'll be ok.

Stephen





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