RE: Combo Box Problem



The following is the code used to create the problem combo box. The combo box is part of a rather involved dialog box that gets initialization data for a war game I'm developing. The combo represents the start time of the battle.

void game_dialog (mData *map)
{
 GtkWidget *dialog = gtk_dialog_new ();
 GtkWidget *vbox   = get_dialog_work_area (GTK_DIALOG (dialog));
 ........
 GtkWidget *combo1 = gtk_combo_box_new_text ();
 GtkWidget *stbox  = gtk_fixed_new ();

 gtk_fixed_put (GTK_FIXED (stbox), stlab, 5, 5);
 gtk_fixed_put (GTK_FIXED (stbox), combo1, 150, 1);
 set_start_times (combo1);
 gtk_combo_box_set_active (GTK_COMBO_BOX (combo1), stime);
.........
 gtk_box_pack_start (GTK_BOX (vbox), stbox, FALSE, FALSE, 5);
........
}


void set_start_times (GtkWidget *combo)
{
 int  k = 0;
 char *text = get_text ("hours");
 char time[20];
 char temp[20];

 for (k = 100; k <= 2400; k += 100)
 {
   itoa (k, time, 10);
   if (k < 1000)
   {
     strcpy (temp, "0");
     strcat (temp, time);
     strcpy (time, temp);
} strcat (time, " ");
   strcat (time, text);
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), time); } }


Thanks for the held,

Bill


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]