Project Homepage | Sourceforge Page | CVS Repository | Freshmeat.net Page | Download project | Author's Homepage |
00001 /*!\file comboBox.c 00002 \brief Provide comboBox functionality 00003 */ 00004 00005 /* NOTICE: 00006 Copyright (C) 2004 Karl N. Redman (SleepingStill.com) 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 00022 For further information contact: parasyte@sleepingstill.com 00023 */ 00024 00025 #include <gtk/gtk.h> 00026 #include "comboBox.h" 00027 #include "comboHandlers.h" 00028 #include "interface.h" 00029 #include "main.h" 00030 00031 00032 /** 00033 \brief Initialize the combo box. 00034 00035 \author Karl N. Redman 00036 00037 \param mode The mode we want to initialize to. 00038 00039 \par Purpose: 00040 This function is a bit misleading right now. What we want 00041 to accomplish is the setting of the values of the combo box list 00042 based on various predefined modes of operation. 00043 */ 00044 int combo_init(unsigned int mode) 00045 { 00046 /** 00047 \note We use GLists because we can easily use the convenience function, 00048 gtk_combo_set_popdown_strings(GTK_COMBO(combo), (GList *)aGList) 00049 for this kind of data (text only). 00050 */ 00051 00052 /** \warning 00053 The stuff in this function is a workaround for lack of gtk+1.2 00054 combobox functionality. The next version of gtk+ looks to have 00055 solved some of the problems we're working around here. 00056 */ 00057 00058 ///the persistant history list 00059 //static GList *hist_list = NULL; 00060 //static GList *exec_list = NULL; 00061 //static GList *file_list = NULL; 00062 00063 if((unsigned int)mode == RF_EXAMPLE_MODE) 00064 { 00065 /* we're going to change the contents of the combo box list so 00066 we need to delete the old contents and populate it with 00067 something else. 00068 */ 00069 00070 /** 00071 \note 00072 Note: This is a gtk+1.2 method and, I'm told, doesn't work 00073 for gtk+2+ (I'll find out I guess) 00074 */ 00075 00076 GtkList *oldList = NULL; 00077 00078 //get the current list 00079 //we could save this if we wanted to. 00080 oldList = (GtkList *)GTK_COMBO(combo1)->list; 00081 00082 //remove each item in the GTK_LIST 00083 if (GTK_LIST(oldList)->children != NULL) 00084 gtk_list_remove_items (oldList, (GList *)oldList->children); 00085 00086 //repopulate the list 00087 GList *list = NULL; 00088 list = g_list_append(list, ""); 00089 list = g_list_append(list, "1"); 00090 list = g_list_append(list, "2"); 00091 list = g_list_append(list, "3"); 00092 list = g_list_append(list, "4"); 00093 00094 //save a pointer to the list ? 00095 cbitems = list; 00096 00097 //populate the combo box list widget 00098 gtk_combo_set_popdown_strings(GTK_COMBO(combo1), (GList *)cbitems); 00099 00100 //a settingthat doesn't really go here 00101 gtk_combo_set_use_arrows_always(GTK_COMBO(combo1), 1); 00102 } 00103 00104 00105 if((unsigned int)mode == RF_HISTORY_MODE) 00106 { 00107 GtkList *oldList = NULL; 00108 00109 oldList = (GtkList *)GTK_COMBO(combo1)->list; 00110 00111 if (GTK_LIST(oldList)->children != NULL) 00112 gtk_list_remove_items (oldList, (GList *)oldList->children); 00113 00114 cbitems = NULL; 00115 //cbitems = g_list_append(cbitems, ""); 00116 //cbitems = g_list_append(cbitems, "a"); 00117 //cbitems = g_list_append(cbitems, "b"); 00118 //cbitems = g_list_append(cbitems, "c"); 00119 //cbitems = g_list_append(cbitems, "d"); 00120 //cbitems = g_list_append(cbitems, "e"); 00121 //cbitems = g_list_append(cbitems, "f"); 00122 00123 cbitems = readHistory(cbitems, history_file); 00124 gtk_combo_set_popdown_strings(GTK_COMBO(combo1), (GList *)cbitems); 00125 gtk_combo_set_use_arrows_always(GTK_COMBO(combo1), 1); 00126 } 00127 00128 return 0; 00129 }