3 * Copyright (C) 2001-2009 Jim Evins <evins@snaught.com>.
5 * This file is part of gLabels.
7 * gLabels is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * gLabels is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
23 #include "combo-util.h"
27 #include <libglabels.h>
30 /****************************************************************************/
31 /* Convienience function to set strings in a text combo_box from a GList */
32 /****************************************************************************/
34 gl_combo_util_set_strings (GtkComboBoxText *combo,
39 g_return_if_fail (list);
41 gtk_combo_box_text_remove_all (combo);
43 for (p=list; p!=NULL; p=p->next) {
45 gtk_combo_box_text_append_text (combo, p->data);
51 /*---------------------------------------------------------------------------*/
52 /* PRIVATE. gl_combo_util_set_active_text support. */
53 /*---------------------------------------------------------------------------*/
62 search_text_func (GtkTreeModel *model,
67 TextSearchData *search_data = (TextSearchData *)data;
70 gtk_tree_model_get (model, iter, 0, &text, -1);
72 if (strcmp (text,search_data->text) == 0) {
73 search_data->found = TRUE;
74 search_data->iter = *iter;
83 /****************************************************************************/
84 /* Convienience function to set active text in a text combo_box from text */
85 /****************************************************************************/
87 gl_combo_util_set_active_text (GtkComboBox *combo,
90 GtkTreeModel *model = gtk_combo_box_get_model(combo);
92 g_return_if_fail (GTK_IS_LIST_STORE (model));
96 gtk_combo_box_set_active (combo, -1);
99 TextSearchData search_data;
101 search_data.text = text;
102 search_data.found = FALSE;
104 gtk_tree_model_foreach (model, search_text_func, &search_data);
105 if (search_data.found) {
106 gtk_combo_box_set_active_iter (combo,
109 gtk_combo_box_set_active (combo, -1);
119 * Local Variables: -- emacs
121 * c-basic-offset: 8 -- emacs
122 * tab-width: 8 -- emacs
123 * indent-tabs-mode: nil -- emacs