]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - unix/uxcfg.c
Move MODULE files out of individual project directories into a
[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      * Unix supports a local-command proxy. This also means we must
134      * adjust the text on the `Telnet command' control.
135      */
136     if (!midsession) {
137         int i;
138         s = ctrl_getset(b, "Connection/Proxy", "basics", NULL);
139         for (i = 0; i < s->ncontrols; i++) {
140             c = s->ctrls[i];
141             if (c->generic.type == CTRL_RADIO &&
142                 c->generic.context.i == offsetof(Config, proxy_type)) {
143                 assert(c->generic.handler == dlg_stdradiobutton_handler);
144                 c->radio.nbuttons++;
145                 c->radio.buttons =
146                     sresize(c->radio.buttons, c->radio.nbuttons, char *);
147                 c->radio.buttons[c->radio.nbuttons-1] =
148                     dupstr("Local");
149                 c->radio.buttondata =
150                     sresize(c->radio.buttondata, c->radio.nbuttons, intorptr);
151                 c->radio.buttondata[c->radio.nbuttons-1] = I(PROXY_CMD);
152                 break;
153             }
154         }
155
156         for (i = 0; i < s->ncontrols; i++) {
157             c = s->ctrls[i];
158             if (c->generic.type == CTRL_EDITBOX &&
159                 c->generic.context.i ==
160                 offsetof(Config, proxy_telnet_command)) {
161                 assert(c->generic.handler == dlg_stdeditbox_handler);
162                 sfree(c->generic.label);
163                 c->generic.label = dupstr("Telnet command, or local"
164                                           " proxy command");
165                 break;
166             }
167         }
168     }
169
170 }