ComboBox.h

Go to the documentation of this file.
00001 #ifndef _GTKUTIL_COMBOBOX_H_
00002 #define _GTKUTIL_COMBOBOX_H_
00003 
00004 #include <string>
00005 #include <gtk/gtkcombobox.h>
00006 
00007 namespace gtkutil
00008 {
00009 
00010     class ComboBox
00011     {
00012         public:
00013 
00014             // Utility method to retrieve the currently selected text from a combo box
00015             // GTK requires the returned string to be freed to prevent memory leaks
00016             static std::string getActiveText (GtkComboBox* comboBox)
00017             {
00018                 gchar* text = gtk_combo_box_get_active_text(comboBox);
00019 
00020                 if (text != NULL) {
00021                     std::string returnValue(text);
00022                     g_free(text);
00023                     return returnValue;
00024                 } else {
00025                     return "";
00026                 }
00027             }
00028     };
00029 
00030 } // namespace gtkutil
00031 
00032 #endif /* _GTKUTIL_COMBOBOX_H_ */

Generated by  doxygen 1.6.2