Use text column value in GtkComboBoxText

This commit is contained in:
Christian Dywan 2010-10-15 15:26:00 +02:00 committed by Matthias Clasen
parent 7a5a5e9c5d
commit a16722fc3a

View File

@ -78,6 +78,7 @@ gtk_combo_box_text_append_text (GtkComboBoxText *combo_box,
{
GtkListStore *store;
GtkTreeIter iter;
gint text_column;
gint column_type;
g_return_if_fail (GTK_IS_COMBO_BOX_TEXT (combo_box));
@ -85,11 +86,12 @@ gtk_combo_box_text_append_text (GtkComboBoxText *combo_box,
store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)));
g_return_if_fail (GTK_IS_LIST_STORE (store));
column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), 0);
text_column = gtk_combo_box_get_entry_text_column (GTK_COMBO_BOX (combo_box));
column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), text_column);
g_return_if_fail (column_type == G_TYPE_STRING);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, text, -1);
gtk_list_store_set (store, &iter, text_column, text, -1);
}
/**
@ -109,6 +111,7 @@ gtk_combo_box_text_insert_text (GtkComboBoxText *combo_box,
{
GtkListStore *store;
GtkTreeIter iter;
gint text_column;
gint column_type;
g_return_if_fail (GTK_IS_COMBO_BOX_TEXT (combo_box));
@ -117,11 +120,12 @@ gtk_combo_box_text_insert_text (GtkComboBoxText *combo_box,
store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)));
g_return_if_fail (GTK_IS_LIST_STORE (store));
column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), 0);
text_column = gtk_combo_box_get_entry_text_column (GTK_COMBO_BOX (combo_box));
column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), text_column);
g_return_if_fail (column_type == G_TYPE_STRING);
gtk_list_store_insert (store, &iter, position);
gtk_list_store_set (store, &iter, 0, text, -1);
gtk_list_store_set (store, &iter, text_column, text, -1);
}
/**
@ -139,6 +143,7 @@ gtk_combo_box_text_prepend_text (GtkComboBoxText *combo_box,
{
GtkListStore *store;
GtkTreeIter iter;
gint text_column;
gint column_type;
g_return_if_fail (GTK_IS_COMBO_BOX_TEXT (combo_box));
@ -146,11 +151,12 @@ gtk_combo_box_text_prepend_text (GtkComboBoxText *combo_box,
store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)));
g_return_if_fail (GTK_IS_LIST_STORE (store));
column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), 0);
text_column = gtk_combo_box_get_entry_text_column (GTK_COMBO_BOX (combo_box));
column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), text_column);
g_return_if_fail (column_type == G_TYPE_STRING);
gtk_list_store_prepend (store, &iter);
gtk_list_store_set (store, &iter, 0, text, -1);
gtk_list_store_set (store, &iter, text_column, text, -1);
}
/**
@ -169,6 +175,7 @@ gtk_combo_box_text_remove (GtkComboBoxText *combo_box,
GtkTreeModel *model;
GtkListStore *store;
GtkTreeIter iter;
gint text_column;
gint column_type;
g_return_if_fail (GTK_IS_COMBO_BOX_TEXT (combo_box));
@ -177,7 +184,8 @@ gtk_combo_box_text_remove (GtkComboBoxText *combo_box,
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
store = GTK_LIST_STORE (model);
g_return_if_fail (GTK_IS_LIST_STORE (store));
column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), 0);
text_column = gtk_combo_box_get_entry_text_column (GTK_COMBO_BOX (combo_box));
column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), text_column);
g_return_if_fail (column_type == G_TYPE_STRING);
if (gtk_tree_model_iter_nth_child (model, &iter, NULL, position))
@ -207,13 +215,15 @@ gtk_combo_box_text_get_active_text (GtkComboBoxText *combo_box)
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter))
{
GtkTreeModel *model;
gint text_column;
gint column_type;
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
g_return_val_if_fail (GTK_IS_LIST_STORE (model), NULL);
column_type = gtk_tree_model_get_column_type (model, 0);
text_column = gtk_combo_box_get_entry_text_column (GTK_COMBO_BOX (combo_box));
column_type = gtk_tree_model_get_column_type (model, text_column);
g_return_val_if_fail (column_type == G_TYPE_STRING, NULL);
gtk_tree_model_get (model, &iter, 0, &text, -1);
gtk_tree_model_get (model, &iter, text_column, &text, -1);
}
return text;