Re: Get active text from GtkComboBox



On Sun, 2004-12-12 at 16:36 -0200, cesarbs brturbo com wrote:
Hello,

My program has a GtkComboBox created with gtk_combo_box_new_text (),
and I would like to know how could I grab the active text on it. I
know there's a function called gtk_combo_box_get_active_text(), but
that only works with GTK+-2.6 that's still under development.

How could I do that in GTK+-2.4?

The following should work:

GtkTreeModel *model;
GtkTreeIter iter;

model = gtk_combo_box_get_model (combo_box);
if (gtk_combo_box_get_active_iter (combo_box, &iter)) {
        gchar *str = NULL;
        gtk_tree_model_get (model, &iter, 0, &str, -1);
        
        /* do something with str */

        g_free (str);
}

-- 
Regards,
Martyn



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