]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - unix/uxcfg.c
Display panel titles and grouping box titles.
[PuTTY.git] / unix / uxcfg.c
1 /*
2  * uxcfg.c - the Unix-specific parts of the PuTTY configuration
3  * box.
4  */
5
6 #include <assert.h>
7 #include <stdlib.h>
8
9 #include "putty.h"
10 #include "dialog.h"
11 #include "storage.h"
12
13 static void about_handler(union control *ctrl, void *dlg,
14                           void *data, int event)
15 {
16     if (event == EVENT_ACTION) {
17         about_box(ctrl->generic.context.p);
18     }
19 }
20
21 void unix_setup_config_box(struct controlbox *b, int midsession, void *win)
22 {
23     struct controlset *s, *s2;
24     union control *c;
25     int i;
26
27     if (!midsession) {
28         /*
29          * Add the About button to the standard panel.
30          */
31         s = ctrl_getset(b, "", "", "");
32         c = ctrl_pushbutton(s, "About", 'a', HELPCTX(no_help),
33                             about_handler, P(win));
34         c->generic.column = 0;
35     }
36
37     /*
38      * The Config structure contains two Unix-specific elements
39      * which are not configured in here: stamp_utmp and
40      * login_shell. This is because pterm does not put up a
41      * configuration box right at the start, which is the only time
42      * when these elements would be useful to configure.
43      */
44
45     /*
46      * On Unix, we don't have a drop-down list for the printer
47      * control.
48      */
49     s = ctrl_getset(b, "Terminal", "printing", "Remote-controlled printing");
50     assert(s->ncontrols == 1 && s->ctrls[0]->generic.type == CTRL_EDITBOX);
51     s->ctrls[0]->editbox.has_list = 0;
52
53     /*
54      * GTK makes it rather easier to put the scrollbar on the left
55      * than Windows does!
56      */
57     s = ctrl_getset(b, "Window", "scrollback",
58                     "Control the scrollback in the window");
59     ctrl_checkbox(s, "Scrollbar on left", 'l',
60                   HELPCTX(no_help),
61                   dlg_stdcheckbox_handler,
62                   I(offsetof(Config,scrollbar_on_left)));
63     /*
64      * Really this wants to go just after `Display scrollbar'. See
65      * if we can find that control, and do some shuffling.
66      */
67     for (i = 0; i < s->ncontrols; i++) {
68         c = s->ctrls[i];
69         if (c->generic.type == CTRL_CHECKBOX &&
70             c->generic.context.i == offsetof(Config,scrollbar)) {
71             /*
72              * Control i is the scrollbar checkbox.
73              * Control s->ncontrols-1 is the scrollbar-on-left one.
74              */
75             if (i < s->ncontrols-2) {
76                 c = s->ctrls[s->ncontrols-1];
77                 memmove(s->ctrls+i+2, s->ctrls+i+1,
78                         (s->ncontrols-i-2)*sizeof(union control *));
79                 s->ctrls[i+1] = c;
80             }
81             break;
82         }
83     }
84
85     /*
86      * X requires three more fonts: bold, wide, and wide-bold; also
87      * we need the fiddly shadow-bold-offset control. This would
88      * make the Window/Appearance panel rather unwieldy and large,
89      * so I think the sensible thing here is to _move_ this
90      * controlset into a separate Window/Fonts panel!
91      */
92     s2 = ctrl_getset(b, "Window/Appearance", "font",
93                      "Font settings");
94     /* Remove this controlset from b. */
95     for (i = 0; i < b->nctrlsets; i++) {
96         if (b->ctrlsets[i] == s2) {
97             memmove(b->ctrlsets+i, b->ctrlsets+i+1,
98                     (b->nctrlsets-i-1) * sizeof(*b->ctrlsets));
99             b->nctrlsets--;
100             break;
101         }
102     }
103     ctrl_settitle(b, "Window/Fonts", "Options controlling font usage");
104     s = ctrl_getset(b, "Window/Fonts", "font",
105                     "Fonts for displaying non-bold text");
106     ctrl_fontsel(s, "Font used for ordinary text", 'f',
107                  HELPCTX(no_help),
108                  dlg_stdfontsel_handler, I(offsetof(Config,font)));
109     ctrl_fontsel(s, "Font used for wide (CJK) text", 'w',
110                  HELPCTX(no_help),
111                  dlg_stdfontsel_handler, I(offsetof(Config,widefont)));
112     s = ctrl_getset(b, "Window/Fonts", "fontbold",
113                     "Fonts for displaying bolded text");
114     ctrl_fontsel(s, "Font used for bolded text", 'b',
115                  HELPCTX(no_help),
116                  dlg_stdfontsel_handler, I(offsetof(Config,boldfont)));
117     ctrl_fontsel(s, "Font used for bold wide text", 'i',
118                  HELPCTX(no_help),
119                  dlg_stdfontsel_handler, I(offsetof(Config,wideboldfont)));
120     ctrl_checkbox(s, "Use shadow bold instead of bold fonts", 'u',
121                   HELPCTX(no_help),
122                   dlg_stdcheckbox_handler,
123                   I(offsetof(Config,shadowbold)));
124     ctrl_text(s, "(Note that bold fonts or shadow bolding are only"
125               " used if you have not requested bolding to be done by"
126               " changing the text colour.)",
127               HELPCTX(no_help));
128     ctrl_editbox(s, "Horizontal offset for shadow bold:", 'z', 20,
129                  HELPCTX(no_help), dlg_stdeditbox_handler,
130                  I(offsetof(Config,shadowboldoffset)), I(-1));
131
132     /*
133      * Markus Kuhn feels, not totally unreasonably, that it's good
134      * for all applications to shift into UTF-8 mode if they notice
135      * that they've been started with a LANG setting dictating it,
136      * so that people don't have to keep remembering a separate
137      * UTF-8 option for every application they use. Therefore,
138      * here's an override option in the Translation panel.
139      */
140     s = ctrl_getset(b, "Window/Translation", "trans",
141                     "Character set translation on received data");
142     ctrl_checkbox(s, "Override with UTF-8 if locale says so", 'l',
143                   HELPCTX(translation_utf8_override),
144                   dlg_stdcheckbox_handler,
145                   I(offsetof(Config,utf8_override)));
146
147     /*
148      * Unix supports a local-command proxy. This also means we must
149      * adjust the text on the `Telnet command' control.
150      */
151     if (!midsession) {
152         int i;
153         s = ctrl_getset(b, "Connection/Proxy", "basics", NULL);
154         for (i = 0; i < s->ncontrols; i++) {
155             c = s->ctrls[i];
156             if (c->generic.type == CTRL_RADIO &&
157                 c->generic.context.i == offsetof(Config, proxy_type)) {
158                 assert(c->generic.handler == dlg_stdradiobutton_handler);
159                 c->radio.nbuttons++;
160                 c->radio.buttons =
161                     sresize(c->radio.buttons, c->radio.nbuttons, char *);
162                 c->radio.buttons[c->radio.nbuttons-1] =
163                     dupstr("Local");
164                 c->radio.buttondata =
165                     sresize(c->radio.buttondata, c->radio.nbuttons, intorptr);
166                 c->radio.buttondata[c->radio.nbuttons-1] = I(PROXY_CMD);
167                 break;
168             }
169         }
170
171         for (i = 0; i < s->ncontrols; i++) {
172             c = s->ctrls[i];
173             if (c->generic.type == CTRL_EDITBOX &&
174                 c->generic.context.i ==
175                 offsetof(Config, proxy_telnet_command)) {
176                 assert(c->generic.handler == dlg_stdeditbox_handler);
177                 sfree(c->generic.label);
178                 c->generic.label = dupstr("Telnet command, or local"
179                                           " proxy command");
180                 break;
181             }
182         }
183     }
184
185 }