Gtk Utilities


Detailed Description

The API in this file is designed to provide support functions that wrap the base gtk functions and make them easier to use.


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)


Function Documentation

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.

Parameters:
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.

00043 {
00044   GtkTreeModel *model;
00045   GtkTreeIter iter;
00046   gchar *tree_string;
00047   gint column, index, id;
00048   gboolean match;
00049 
00050   model = gtk_combo_box_get_model(GTK_COMBO_BOX(cbe));
00051   if (!gtk_tree_model_get_iter_first(model, &iter)) {
00052     /* empty tree */
00053     gtk_combo_box_set_active(GTK_COMBO_BOX(cbe), -1);
00054     return;
00055   }
00056 
00057   column = gtk_combo_box_entry_get_text_column(cbe);
00058   do {
00059     gtk_tree_model_get(model, &iter, column, &tree_string, -1);
00060     match = g_utf8_collate(text, tree_string) == 0;
00061     g_free(tree_string);
00062     if (!match)
00063       continue;
00064 
00065     /* Found a matching string */
00066     id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cbe), CHANGED_ID));
00067     g_signal_handler_block(cbe, id);
00068     gtk_combo_box_set_active_iter(GTK_COMBO_BOX(cbe), &iter);
00069     g_signal_handler_unblock(cbe, id);
00070 
00071     index = gtk_combo_box_get_active(GTK_COMBO_BOX(cbe));
00072     g_object_set_data(G_OBJECT(cbe), LAST_INDEX, GINT_TO_POINTER(index));
00073     return;
00074   } while (gtk_tree_model_iter_next(model, &iter));
00075 }


Generated on Sun Oct 12 05:07:54 2008 for GnuCash by  doxygen 1.5.2