mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-02 03:52:49 -05:00
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an arbitrary length limit on every single one of those settings which is stored in string form. In place of it is 'Conf', an opaque data type everywhere outside the new file conf.c, which stores a list of (key, value) pairs in which every key contains an integer identifying a configuration setting, and for some of those integers the key also contains extra parts (so that, for instance, CONF_environmt is a string-to-string mapping). Everywhere that a Config was previously used, a Conf is now; everywhere there was a Config structure copy, conf_copy() is called; every lookup, adjustment, load and save operation on a Config has been rewritten; and there's a mechanism for serialising a Conf into a binary blob and back for use with Duplicate Session. User-visible effects of this change _should_ be minimal, though I don't doubt I've introduced one or two bugs here and there which will eventually be found. The _intended_ visible effects of this change are that all arbitrary limits on configuration strings and lists (e.g. limit on number of port forwardings) should now disappear; that list boxes in the configuration will now be displayed in a sorted order rather than the arbitrary order in which they were added to the list (since the underlying data structure is now a sorted tree234 rather than an ad-hoc comma-separated string); and one more specific change, which is that local and dynamic port forwardings on the same port number are now mutually exclusive in the configuration (putting 'D' in the key rather than the value was a mistake in the first place). One other reorganisation as a result of this is that I've moved all the dialog.c standard handlers (dlg_stdeditbox_handler and friends) out into config.c, because I can't really justify calling them generic any more. When they took a pointer to an arbitrary structure type and the offset of a field within that structure, they were independent of whether that structure was a Config or something completely different, but now they really do expect to talk to a Conf, which can _only_ be used for PuTTY configuration, so I've renamed them all things like conf_editbox_handler and moved them out of the nominally independent dialog-box management module into the PuTTY-specific config.c. [originally from svn r9214]
This commit is contained in:
@ -330,11 +330,10 @@ void dlg_editbox_set(union control *ctrl, void *dlg, char const *text)
|
||||
* The first call to "changed", if allowed to proceed normally,
|
||||
* will cause an EVENT_VALCHANGE event on the edit box, causing
|
||||
* a call to dlg_editbox_get() which will read the empty string
|
||||
* out of the GtkEntry - and promptly write it straight into
|
||||
* the Config structure, which is precisely where our `text'
|
||||
* pointer is probably pointing, so the second editing
|
||||
* operation will insert that instead of the string we
|
||||
* originally asked for.
|
||||
* out of the GtkEntry - and promptly write it straight into the
|
||||
* Conf structure, which is precisely where our `text' pointer
|
||||
* is probably pointing, so the second editing operation will
|
||||
* insert that instead of the string we originally asked for.
|
||||
*
|
||||
* Hence, we must take our own copy of the text before we do
|
||||
* this.
|
||||
@ -344,7 +343,7 @@ void dlg_editbox_set(union control *ctrl, void *dlg, char const *text)
|
||||
sfree(tmpstring);
|
||||
}
|
||||
|
||||
void dlg_editbox_get(union control *ctrl, void *dlg, char *buffer, int length)
|
||||
char *dlg_editbox_get(union control *ctrl, void *dlg)
|
||||
{
|
||||
struct dlgparam *dp = (struct dlgparam *)dlg;
|
||||
struct uctrl *uc = dlg_find_byctrl(dp, ctrl);
|
||||
@ -353,25 +352,16 @@ void dlg_editbox_get(union control *ctrl, void *dlg, char *buffer, int length)
|
||||
#if GTK_CHECK_VERSION(2,4,0)
|
||||
if (uc->combo) {
|
||||
#if GTK_CHECK_VERSION(2,6,0)
|
||||
strncpy(buffer,
|
||||
gtk_combo_box_get_active_text(GTK_COMBO_BOX(uc->combo)),
|
||||
length);
|
||||
return dupstr(gtk_combo_box_get_active_text(GTK_COMBO_BOX(uc->combo)));
|
||||
#else
|
||||
strncpy(buffer,
|
||||
gtk_entry_get_text
|
||||
(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(uc->combo)))),
|
||||
length);
|
||||
return dupstr(gtk_entry_get_text
|
||||
(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(uc->combo)))));
|
||||
#endif
|
||||
buffer[length-1] = '\0';
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (uc->entry) {
|
||||
strncpy(buffer, gtk_entry_get_text(GTK_ENTRY(uc->entry)),
|
||||
length);
|
||||
buffer[length-1] = '\0';
|
||||
return;
|
||||
return dupstr(gtk_entry_get_text(GTK_ENTRY(uc->entry)));
|
||||
}
|
||||
|
||||
assert(!"We shouldn't get here");
|
||||
@ -2826,12 +2816,12 @@ void set_dialog_action_area(GtkDialog *dlg, GtkWidget *w)
|
||||
#endif
|
||||
}
|
||||
|
||||
int do_config_box(const char *title, Config *cfg, int midsession,
|
||||
int do_config_box(const char *title, Conf *conf, int midsession,
|
||||
int protcfginfo)
|
||||
{
|
||||
GtkWidget *window, *hbox, *vbox, *cols, *label,
|
||||
*tree, *treescroll, *panels, *panelvbox;
|
||||
int index, level;
|
||||
int index, level, protocol;
|
||||
struct controlbox *ctrlbox;
|
||||
char *path;
|
||||
#if GTK_CHECK_VERSION(2,0,0)
|
||||
@ -2859,8 +2849,9 @@ int do_config_box(const char *title, Config *cfg, int midsession,
|
||||
window = gtk_dialog_new();
|
||||
|
||||
ctrlbox = ctrl_new_box();
|
||||
setup_config_box(ctrlbox, midsession, cfg->protocol, protcfginfo);
|
||||
unix_setup_config_box(ctrlbox, midsession, cfg->protocol);
|
||||
protocol = conf_get_int(conf, CONF_protocol);
|
||||
setup_config_box(ctrlbox, midsession, protocol, protcfginfo);
|
||||
unix_setup_config_box(ctrlbox, midsession, protocol);
|
||||
gtk_setup_config_box(ctrlbox, midsession, window);
|
||||
|
||||
gtk_window_set_title(GTK_WINDOW(window), title);
|
||||
@ -3095,7 +3086,7 @@ int do_config_box(const char *title, Config *cfg, int midsession,
|
||||
}
|
||||
#endif
|
||||
|
||||
dp.data = cfg;
|
||||
dp.data = conf;
|
||||
dlg_refresh(NULL, &dp);
|
||||
|
||||
dp.shortcuts = &selparams[0].shortcuts;
|
||||
|
Reference in New Issue
Block a user