Re: [gtk-list] entry box with drop down menu



Ladislav Kostal wrote:
> 
> Hello,
> 
> In my app I need to create %subj% like in screenshot:
> http://www.gtk.org/screenshots/entry2.gif
> 
> How can I do this ? I didn't found anything about it.

It's a GtkCombo...

GtkWidget *w = gtk_combo_new();

It's a composite widget, and the two children that you need to
deal with are a GtkEntry, and a GtkList.

You can set the strings in the popdown menu with this call :

gtk_combo_set_popdown_strings(GtkCombo *combo, GList *strings);

You can connect to the "changed" signal of the entry to find out
when the user has selected a new item.

gtk_signal_connect(GTK_OBJECT(GTK_COMBO(mycombo->entry)),
		   (GtkSignalFunc) myComboCallback, (gpointer) some_data);

You might also want to set the entry to not allow the user to type/edit
the text in it.

gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(mycombo)->entry),FALSE);

As long as you understand GLists, that should be all you need.

later,
Ben Boule



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