talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

combobox.h (2184B)


      1 /*
      2  * Claws Mail -- a GTK based, lightweight, and fast e-mail client
      3  * Copyright (C) 1999-2012 Andrej Kacian and the Claws Mail team
      4  *
      5  * This program is free software; you can redistribute it and/or modify
      6  * it under the terms of the GNU General Public License as published by
      7  * the Free Software Foundation; either version 3 of the License, or
      8  * (at your option) any later version.
      9  *
     10  * This program is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  * GNU General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU General Public License
     16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
     17  *
     18  */
     19 
     20 #ifndef __COMBOBOX_H__
     21 #define __COMBOBOX_H__
     22 
     23 #include <glib.h>
     24 #include <gtk/gtk.h>
     25 
     26 enum {
     27 	COMBOBOX_TEXT,
     28 	COMBOBOX_DATA,
     29 	COMBOBOX_SENS
     30 };
     31 
     32 
     33 #define COMBOBOX_ADD(menu, label, data) 		 \
     34 { 								 \
     35 	gtk_list_store_append(menu, &iter); \
     36 	gtk_list_store_set(menu, &iter, \
     37 			COMBOBOX_TEXT, label, \
     38 			COMBOBOX_DATA, data, \
     39 			COMBOBOX_SENS, TRUE, \
     40 			-1); \
     41 }
     42 
     43 #define COMBOBOX_ADD_ESCAPED(menu, label, data) 		 \
     44 { 								 \
     45 	gchar *tmp_esc = g_markup_printf_escaped("%s", label);	 \
     46 	gtk_list_store_append(menu, &iter); 			 \
     47 	gtk_list_store_set(menu, &iter, 			 \
     48 			COMBOBOX_TEXT, (tmp_esc ? tmp_esc : ""), 		 \
     49 			COMBOBOX_DATA, data, 				 \
     50 			COMBOBOX_SENS, TRUE,				 \
     51 			-1); 					 \
     52 	g_free(tmp_esc);					 \
     53 }
     54 
     55 GtkWidget *combobox_text_new(const gboolean with_entry, const gchar *text, ...);
     56 
     57 void combobox_select_by_data	(GtkComboBox 		*combobox,
     58 				 gint			 data);
     59 void combobox_select_by_text	(GtkComboBox 		*combobox,
     60 				 const gchar		*data);
     61 
     62 gint combobox_get_active_data	(GtkComboBox 		*combobox);
     63 
     64 /* these two functions require a GtkComboBoxText, so let the compiler warn */
     65 void combobox_unset_popdown_strings(GtkComboBoxText	*combobox);
     66 void combobox_set_popdown_strings(GtkComboBoxText	*combobox,
     67 				 GList       *list);
     68 
     69 void combobox_set_sensitive	(GtkComboBox *combobox,
     70 				 const guint index,
     71 				 const gboolean sensitive);
     72 
     73 #endif /* __COMBOBOX_H__ */