- entry = gtk_entry_new();
- gtk_entry_set_text(GTK_ENTRY(entry), dfl);
- gtk_table_attach(GTK_TABLE(box), entry,
- left, left + 1, 0, 1,
- GTK_EXPAND | GTK_FILL, GTK_EXPAND, 4, 2);
- if (f & f_invis)
- gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
- gtk_widget_show(entry);
+ if (list) {
+ FILE *fp = fopen(list, "r");
+ GtkWidget *combo;
+
+ /* --- Read the items in from the file --- *
+ *
+ * Inability to open the file is not a disaster.
+ */
+
+ hist = 0;
+ if (fp) {
+ dstr d;
+
+ dstr_create(&d);
+ while (dstr_putline(&d, fp) != EOF) {
+ hist = g_list_append(hist, xstrdup(d.buf));
+ dstr_destroy(&d);
+ }
+ fclose(fp);
+ }
+
+ /* --- Now create a combo box --- */
+
+ combo = gtk_combo_new();
+ entry = GTK_COMBO(combo)->entry;
+ if (hist)
+ gtk_combo_set_popdown_strings(GTK_COMBO(combo), hist);
+
+ /* --- Do other configuring --- */
+
+ if (f & f_nochoice) {
+ gtk_combo_set_value_in_list(GTK_COMBO(combo), 1, 0);
+ gtk_entry_set_editable(GTK_ENTRY(entry), 0);
+ }
+ gtk_combo_set_case_sensitive(GTK_COMBO(combo), 1);
+ gtk_combo_set_use_arrows_always(GTK_COMBO(combo), 1);
+ gtk_combo_disable_activate(GTK_COMBO(combo));
+ if (strcmp(dfl, "@") == 0)
+ gtk_entry_set_text(GTK_ENTRY(entry), hist ? (char *)hist->data : "");
+ else
+ gtk_entry_set_text(GTK_ENTRY(entry), dfl);
+
+ /* --- Set the widget in the right place and show it --- */
+
+ gtk_table_attach(GTK_TABLE(box), combo,
+ left, left + 1, 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND, 4, 2);
+ gtk_widget_show(combo);
+ } else {
+ entry = gtk_entry_new();
+ gtk_entry_set_text(GTK_ENTRY(entry), dfl);
+ if (f & f_invis)
+ gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
+ gtk_table_attach(GTK_TABLE(box), entry,
+ left, left + 1, 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_EXPAND, 4, 2);
+ gtk_widget_show(entry);
+ }