8d68f26a |
1 | /* |
2 | * gtkcfg.c - the GTK-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 gtk_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 | * GTK makes it rather easier to put the scrollbar on the left |
39 | * than Windows does! |
40 | */ |
41 | s = ctrl_getset(b, "Window", "scrollback", |
42 | "Control the scrollback in the window"); |
43 | ctrl_checkbox(s, "Scrollbar on left", 'l', |
44 | HELPCTX(no_help), |
4a693cfc |
45 | conf_checkbox_handler, |
46 | I(CONF_scrollbar_on_left)); |
8d68f26a |
47 | /* |
48 | * Really this wants to go just after `Display scrollbar'. See |
49 | * if we can find that control, and do some shuffling. |
50 | */ |
51 | for (i = 0; i < s->ncontrols; i++) { |
52 | c = s->ctrls[i]; |
53 | if (c->generic.type == CTRL_CHECKBOX && |
4a693cfc |
54 | c->generic.context.i == CONF_scrollbar) { |
8d68f26a |
55 | /* |
56 | * Control i is the scrollbar checkbox. |
57 | * Control s->ncontrols-1 is the scrollbar-on-left one. |
58 | */ |
59 | if (i < s->ncontrols-2) { |
60 | c = s->ctrls[s->ncontrols-1]; |
61 | memmove(s->ctrls+i+2, s->ctrls+i+1, |
62 | (s->ncontrols-i-2)*sizeof(union control *)); |
63 | s->ctrls[i+1] = c; |
64 | } |
65 | break; |
66 | } |
67 | } |
68 | |
69 | /* |
70 | * X requires three more fonts: bold, wide, and wide-bold; also |
71 | * we need the fiddly shadow-bold-offset control. This would |
72 | * make the Window/Appearance panel rather unwieldy and large, |
73 | * so I think the sensible thing here is to _move_ this |
74 | * controlset into a separate Window/Fonts panel! |
75 | */ |
76 | s2 = ctrl_getset(b, "Window/Appearance", "font", |
77 | "Font settings"); |
78 | /* Remove this controlset from b. */ |
79 | for (i = 0; i < b->nctrlsets; i++) { |
80 | if (b->ctrlsets[i] == s2) { |
81 | memmove(b->ctrlsets+i, b->ctrlsets+i+1, |
82 | (b->nctrlsets-i-1) * sizeof(*b->ctrlsets)); |
83 | b->nctrlsets--; |
84 | break; |
85 | } |
86 | } |
87 | ctrl_settitle(b, "Window/Fonts", "Options controlling font usage"); |
88 | s = ctrl_getset(b, "Window/Fonts", "font", |
89 | "Fonts for displaying non-bold text"); |
90 | ctrl_fontsel(s, "Font used for ordinary text", 'f', |
91 | HELPCTX(no_help), |
4a693cfc |
92 | conf_fontsel_handler, I(CONF_font)); |
8d68f26a |
93 | ctrl_fontsel(s, "Font used for wide (CJK) text", 'w', |
94 | HELPCTX(no_help), |
4a693cfc |
95 | conf_fontsel_handler, I(CONF_widefont)); |
8d68f26a |
96 | s = ctrl_getset(b, "Window/Fonts", "fontbold", |
97 | "Fonts for displaying bolded text"); |
98 | ctrl_fontsel(s, "Font used for bolded text", 'b', |
99 | HELPCTX(no_help), |
4a693cfc |
100 | conf_fontsel_handler, I(CONF_boldfont)); |
8d68f26a |
101 | ctrl_fontsel(s, "Font used for bold wide text", 'i', |
102 | HELPCTX(no_help), |
4a693cfc |
103 | conf_fontsel_handler, I(CONF_wideboldfont)); |
8d68f26a |
104 | ctrl_checkbox(s, "Use shadow bold instead of bold fonts", 'u', |
105 | HELPCTX(no_help), |
4a693cfc |
106 | conf_checkbox_handler, |
107 | I(CONF_shadowbold)); |
8d68f26a |
108 | ctrl_text(s, "(Note that bold fonts or shadow bolding are only" |
109 | " used if you have not requested bolding to be done by" |
110 | " changing the text colour.)", |
111 | HELPCTX(no_help)); |
112 | ctrl_editbox(s, "Horizontal offset for shadow bold:", 'z', 20, |
4a693cfc |
113 | HELPCTX(no_help), conf_editbox_handler, |
114 | I(CONF_shadowboldoffset), I(-1)); |
8d68f26a |
115 | |
116 | /* |
117 | * Markus Kuhn feels, not totally unreasonably, that it's good |
118 | * for all applications to shift into UTF-8 mode if they notice |
119 | * that they've been started with a LANG setting dictating it, |
120 | * so that people don't have to keep remembering a separate |
121 | * UTF-8 option for every application they use. Therefore, |
122 | * here's an override option in the Translation panel. |
123 | */ |
124 | s = ctrl_getset(b, "Window/Translation", "trans", |
125 | "Character set translation on received data"); |
126 | ctrl_checkbox(s, "Override with UTF-8 if locale says so", 'l', |
127 | HELPCTX(translation_utf8_override), |
4a693cfc |
128 | conf_checkbox_handler, |
129 | I(CONF_utf8_override)); |
3e4a1fd7 |
130 | |
131 | if (!midsession) { |
132 | /* |
133 | * Allow the user to specify the window class as part of the saved |
134 | * configuration, so that they can have their window manager treat |
135 | * different kinds of PuTTY and pterm differently if they want to. |
136 | */ |
137 | s = ctrl_getset(b, "Window/Behaviour", "x11", |
138 | "X Window System settings"); |
139 | ctrl_editbox(s, "Window class name:", 'z', 50, |
4a693cfc |
140 | HELPCTX(no_help), conf_editbox_handler, |
141 | I(CONF_winclass), I(1)); |
3e4a1fd7 |
142 | } |
8d68f26a |
143 | } |