[gtk+] Use text column value in GtkComboBoxText
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Use text column value in GtkComboBoxText
- Date: Fri, 15 Oct 2010 20:59:30 +0000 (UTC)
commit a16722fc3a68bdc44d5aeab1297b533a10001e46
Author: Christian Dywan <christian twotoasts de>
Date: Fri Oct 15 15:26:00 2010 +0200
Use text column value in GtkComboBoxText
gtk/gtkcomboboxtext.c | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkcomboboxtext.c b/gtk/gtkcomboboxtext.c
index ed352a3..f1ecb8a 100644
--- a/gtk/gtkcomboboxtext.c
+++ b/gtk/gtkcomboboxtext.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]