OSDN Git Service

Add support for MLSD responses from some broken hosts.
[ffftp/ffftp.git] / putty / UNIX / GTKCFG.C
1 /*\r
2  * gtkcfg.c - the GTK-specific parts of the PuTTY configuration\r
3  * box.\r
4  */\r
5 \r
6 #include <assert.h>\r
7 #include <stdlib.h>\r
8 \r
9 #include "putty.h"\r
10 #include "dialog.h"\r
11 #include "storage.h"\r
12 \r
13 static void about_handler(union control *ctrl, void *dlg,\r
14                           void *data, int event)\r
15 {\r
16     if (event == EVENT_ACTION) {\r
17         about_box(ctrl->generic.context.p);\r
18     }\r
19 }\r
20 \r
21 void gtk_setup_config_box(struct controlbox *b, int midsession, void *win)\r
22 {\r
23     struct controlset *s, *s2;\r
24     union control *c;\r
25     int i;\r
26 \r
27     if (!midsession) {\r
28         /*\r
29          * Add the About button to the standard panel.\r
30          */\r
31         s = ctrl_getset(b, "", "", "");\r
32         c = ctrl_pushbutton(s, "About", 'a', HELPCTX(no_help),\r
33                             about_handler, P(win));\r
34         c->generic.column = 0;\r
35     }\r
36 \r
37     /*\r
38      * GTK makes it rather easier to put the scrollbar on the left\r
39      * than Windows does!\r
40      */\r
41     s = ctrl_getset(b, "Window", "scrollback",\r
42                     "Control the scrollback in the window");\r
43     ctrl_checkbox(s, "Scrollbar on left", 'l',\r
44                   HELPCTX(no_help),\r
45                   dlg_stdcheckbox_handler,\r
46                   I(offsetof(Config,scrollbar_on_left)));\r
47     /*\r
48      * Really this wants to go just after `Display scrollbar'. See\r
49      * if we can find that control, and do some shuffling.\r
50      */\r
51     for (i = 0; i < s->ncontrols; i++) {\r
52         c = s->ctrls[i];\r
53         if (c->generic.type == CTRL_CHECKBOX &&\r
54             c->generic.context.i == offsetof(Config,scrollbar)) {\r
55             /*\r
56              * Control i is the scrollbar checkbox.\r
57              * Control s->ncontrols-1 is the scrollbar-on-left one.\r
58              */\r
59             if (i < s->ncontrols-2) {\r
60                 c = s->ctrls[s->ncontrols-1];\r
61                 memmove(s->ctrls+i+2, s->ctrls+i+1,\r
62                         (s->ncontrols-i-2)*sizeof(union control *));\r
63                 s->ctrls[i+1] = c;\r
64             }\r
65             break;\r
66         }\r
67     }\r
68 \r
69     /*\r
70      * X requires three more fonts: bold, wide, and wide-bold; also\r
71      * we need the fiddly shadow-bold-offset control. This would\r
72      * make the Window/Appearance panel rather unwieldy and large,\r
73      * so I think the sensible thing here is to _move_ this\r
74      * controlset into a separate Window/Fonts panel!\r
75      */\r
76     s2 = ctrl_getset(b, "Window/Appearance", "font",\r
77                      "Font settings");\r
78     /* Remove this controlset from b. */\r
79     for (i = 0; i < b->nctrlsets; i++) {\r
80         if (b->ctrlsets[i] == s2) {\r
81             memmove(b->ctrlsets+i, b->ctrlsets+i+1,\r
82                     (b->nctrlsets-i-1) * sizeof(*b->ctrlsets));\r
83             b->nctrlsets--;\r
84             break;\r
85         }\r
86     }\r
87     ctrl_settitle(b, "Window/Fonts", "Options controlling font usage");\r
88     s = ctrl_getset(b, "Window/Fonts", "font",\r
89                     "Fonts for displaying non-bold text");\r
90     ctrl_fontsel(s, "Font used for ordinary text", 'f',\r
91                  HELPCTX(no_help),\r
92                  dlg_stdfontsel_handler, I(offsetof(Config,font)));\r
93     ctrl_fontsel(s, "Font used for wide (CJK) text", 'w',\r
94                  HELPCTX(no_help),\r
95                  dlg_stdfontsel_handler, I(offsetof(Config,widefont)));\r
96     s = ctrl_getset(b, "Window/Fonts", "fontbold",\r
97                     "Fonts for displaying bolded text");\r
98     ctrl_fontsel(s, "Font used for bolded text", 'b',\r
99                  HELPCTX(no_help),\r
100                  dlg_stdfontsel_handler, I(offsetof(Config,boldfont)));\r
101     ctrl_fontsel(s, "Font used for bold wide text", 'i',\r
102                  HELPCTX(no_help),\r
103                  dlg_stdfontsel_handler, I(offsetof(Config,wideboldfont)));\r
104     ctrl_checkbox(s, "Use shadow bold instead of bold fonts", 'u',\r
105                   HELPCTX(no_help),\r
106                   dlg_stdcheckbox_handler,\r
107                   I(offsetof(Config,shadowbold)));\r
108     ctrl_text(s, "(Note that bold fonts or shadow bolding are only"\r
109               " used if you have not requested bolding to be done by"\r
110               " changing the text colour.)",\r
111               HELPCTX(no_help));\r
112     ctrl_editbox(s, "Horizontal offset for shadow bold:", 'z', 20,\r
113                  HELPCTX(no_help), dlg_stdeditbox_handler,\r
114                  I(offsetof(Config,shadowboldoffset)), I(-1));\r
115 \r
116     /*\r
117      * Markus Kuhn feels, not totally unreasonably, that it's good\r
118      * for all applications to shift into UTF-8 mode if they notice\r
119      * that they've been started with a LANG setting dictating it,\r
120      * so that people don't have to keep remembering a separate\r
121      * UTF-8 option for every application they use. Therefore,\r
122      * here's an override option in the Translation panel.\r
123      */\r
124     s = ctrl_getset(b, "Window/Translation", "trans",\r
125                     "Character set translation on received data");\r
126     ctrl_checkbox(s, "Override with UTF-8 if locale says so", 'l',\r
127                   HELPCTX(translation_utf8_override),\r
128                   dlg_stdcheckbox_handler,\r
129                   I(offsetof(Config,utf8_override)));\r
130 \r
131     if (!midsession) {\r
132         /*\r
133          * Allow the user to specify the window class as part of the saved\r
134          * configuration, so that they can have their window manager treat\r
135          * different kinds of PuTTY and pterm differently if they want to.\r
136          */\r
137         s = ctrl_getset(b, "Window/Behaviour", "x11",\r
138                         "X Window System settings");\r
139         ctrl_editbox(s, "Window class name:", 'z', 50,\r
140                      HELPCTX(no_help), dlg_stdeditbox_handler,\r
141                      I(offsetof(Config,winclass)),\r
142                      I(sizeof(((Config *)0)->winclass)));\r
143     }\r
144 }\r