config-gtk.c 5.9 KB

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