From 8b5ee9aa8123945b29d23ae0fcfdc22d299e1ba3 Mon Sep 17 00:00:00 2001 From: jacob Date: Sun, 15 Jun 2008 12:39:09 +0000 Subject: [PATCH] Exorcise beeps from the Colours pane in Gtk. The colour list box beeped at the user whenever it found that something other than exactly one colour was selected. This seems to happen implicitly in Gtk when the pane is changed. In Gtk1, this gave you a beep whenever you left the Colours dialog after having selected a colour from the list; in Gtk2, you additionally got a beep _every_ time you subsequently re-entered the Colours dialog (for reasons I haven't investigated). Windows was unaffected. Also, in Gtk (unlike Windows), it's possible for the user to go back to the state where no items in the list box are selected at all. For these reasons, stop beeping at the user, and instead blank the RGB edit boxes as a hint that edits to them would be futile. (Really we should be disabling them entirely, but the cross-platform edit controls aren't up to that yet.) git-svn-id: svn://svn.tartarus.org/sgt/putty@8074 cda61777-01e9-0310-a592-d414129be87e --- config.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/config.c b/config.c index 4f01c160..8be448e8 100644 --- a/config.c +++ b/config.c @@ -623,7 +623,7 @@ static void colour_handler(union control *ctrl, void *dlg, Config *cfg = (Config *)data; struct colour_data *cd = (struct colour_data *)ctrl->generic.context.p; - int update = FALSE, r, g, b; + int update = FALSE, clear, r, g, b; if (event == EVENT_REFRESH) { if (ctrl == cd->listbox) { @@ -633,21 +633,21 @@ static void colour_handler(union control *ctrl, void *dlg, for (i = 0; i < lenof(colours); i++) dlg_listbox_add(ctrl, dlg, colours[i]); dlg_update_done(ctrl, dlg); - dlg_editbox_set(cd->redit, dlg, ""); - dlg_editbox_set(cd->gedit, dlg, ""); - dlg_editbox_set(cd->bedit, dlg, ""); + clear = TRUE; + update = TRUE; } } else if (event == EVENT_SELCHANGE) { if (ctrl == cd->listbox) { /* The user has selected a colour. Update the RGB text. */ int i = dlg_listbox_index(ctrl, dlg); if (i < 0) { - dlg_beep(dlg); - return; + clear = TRUE; + } else { + clear = FALSE; + r = cfg->colours[i][0]; + g = cfg->colours[i][1]; + b = cfg->colours[i][2]; } - r = cfg->colours[i][0]; - g = cfg->colours[i][1]; - b = cfg->colours[i][2]; update = TRUE; } } else if (event == EVENT_VALCHANGE) { @@ -700,16 +700,23 @@ static void colour_handler(union control *ctrl, void *dlg, cfg->colours[i][0] = r; cfg->colours[i][1] = g; cfg->colours[i][2] = b; + clear = FALSE; update = TRUE; } } } if (update) { - char buf[40]; - sprintf(buf, "%d", r); dlg_editbox_set(cd->redit, dlg, buf); - sprintf(buf, "%d", g); dlg_editbox_set(cd->gedit, dlg, buf); - sprintf(buf, "%d", b); dlg_editbox_set(cd->bedit, dlg, buf); + if (clear) { + dlg_editbox_set(cd->redit, dlg, ""); + dlg_editbox_set(cd->gedit, dlg, ""); + dlg_editbox_set(cd->bedit, dlg, ""); + } else { + char buf[40]; + sprintf(buf, "%d", r); dlg_editbox_set(cd->redit, dlg, buf); + sprintf(buf, "%d", g); dlg_editbox_set(cd->gedit, dlg, buf); + sprintf(buf, "%d", b); dlg_editbox_set(cd->bedit, dlg, buf); + } } } -- 2.11.0