|
GnuCash 2.4.99
|
Files | |
| file | gnc-gtk-utils.h |
gtk helper routines. | |
gtk Miscellaneous Functions | |
| void | gnc_cbe_set_by_string (GtkComboBoxEntry *cbe, const gchar *text) |
| void | gnc_cbe_add_completion (GtkComboBoxEntry *cbe) |
| void | gnc_cbe_require_list_item (GtkComboBoxEntry *cbe) |
The API in this file is designed to provide support functions that wrap the base gtk functions and make them easier to use.
| void gnc_cbe_set_by_string | ( | GtkComboBoxEntry * | cbe, |
| const gchar * | text | ||
| ) |
Find an entry in the GtkComboBoxEntry by its text value, and set the widget to that value. This function also records the index of that text value for use when the user leaves the widget.
| cbe | A pointer to a GtkComboBoxEntry widget. |
| text | The entry text to find in the model of the combo box entry. |
Definition at line 41 of file gnc-gtk-utils.c.
{
GtkTreeModel *model;
GtkTreeIter iter;
gchar *tree_string;
gint column, index, id;
gboolean match;
model = gtk_combo_box_get_model(GTK_COMBO_BOX(cbe));
if (!gtk_tree_model_get_iter_first(model, &iter))
{
/* empty tree */
gtk_combo_box_set_active(GTK_COMBO_BOX(cbe), -1);
return;
}
column = gtk_combo_box_entry_get_text_column(cbe);
do
{
gtk_tree_model_get(model, &iter, column, &tree_string, -1);
match = g_utf8_collate(text, tree_string) == 0;
g_free(tree_string);
if (!match)
continue;
/* Found a matching string */
id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cbe), CHANGED_ID));
g_signal_handler_block(cbe, id);
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(cbe), &iter);
g_signal_handler_unblock(cbe, id);
index = gtk_combo_box_get_active(GTK_COMBO_BOX(cbe));
g_object_set_data(G_OBJECT(cbe), LAST_INDEX, GINT_TO_POINTER(index));
return;
}
while (gtk_tree_model_iter_next(model, &iter));
}
1.7.4