GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Sep 03, 2014 7:02 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: clear the text of a combo box with entry
PostPosted: Thu Jun 06, 2013 9:58 pm 
Offline

Joined: Thu Jun 06, 2013 9:09 pm
Posts: 1
Hello, I am a new GTK programmer. I'm enjoying learning GTK and I am glad to have found this forum where so many others (appairently) enjoy it too!

Here is my first of (probably many) questions

Using Ubuntu 13.04 x64, GTK+3.6.4

I have a combo box with entry that I created with:
Code:
combo_box = gtk_combo_box_text_new_with_entry();

appended a few items....
Now I want to clear the entry. According to the documentation, I can pass -1 to gtk_combo_box_set_active to have no active item:
Code:
gtk_combo_box_set_active(combo_box, -1);

appairently that doesn't clear the entry as well (note passing a valid positive integer does change the entry to match the corresponding combo box item)
On a whim I also tried:
Code:
gtk_entry_set_text(GTK_ENTRY(new_data->workout_type_entry), "");

but of course the cast failed :P

The combo box with entry is such a great widget... but how can I clear the entry?


Top
 Profile  
 
 Post subject: Re: clear the text of a combo box with entry
PostPosted: Wed Jun 12, 2013 6:18 am 
Offline
Familiar Face

Joined: Tue Jun 11, 2013 7:08 am
Posts: 8
Hi,

What is the real type of the combo_box variable in your example ?

Is it a GtkComboBoxEntry or a simple GtkComboBox ?

In the 2nd case, did you try the gtk_combo_box_remove_text() function ?


Top
 Profile  
 
 Post subject: Re: clear the text of a combo box with entry
PostPosted: Wed Jun 12, 2013 6:51 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 745
Location: UK
Hello,

You need to gain access to the GtkEntry. To do this use :
Code:
GtkWidget *         gtk_bin_get_child                   (GtkBin *bin);
on your GtkComboBoxText.

So you may do some thing along the lines of
Code:
    GtkWidget *entry;
/* ... */
    entry = gtk_bin_get_child (combo_box);
    gtk_entry_set_text (GTK_ENTRY (entry), "");


The documentation at https://developer.gnome.org/gtk3/stable/GtkComboBoxText.html has more information on GtkComboBoxText and on how to get the GtkEntry of the GtkComboBoxText.

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group