mssh-gconf.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. #include <vte/vte.h>
  2. #include <gdk/gdkkeysyms.h>
  3. #include "mssh-gconf.h"
  4. #include "mssh-window.h"
  5. #include "mssh-terminal.h"
  6. void mssh_gconf_notify_font(GConfClient *client, guint cnxn_id,
  7. GConfEntry *entry, gpointer data)
  8. {
  9. PangoFontDescription *font_desc;
  10. GConfValue *value;
  11. int i;
  12. MSSHWindow *window = MSSH_WINDOW(data);
  13. value = gconf_entry_get_value(entry);
  14. font_desc = pango_font_description_from_string(gconf_value_get_string(value));
  15. for(i = 0; i < window->terminals->len; i++)
  16. {
  17. vte_terminal_set_font(VTE_TERMINAL(g_array_index(
  18. window->terminals, MSSHTerminal*, i)), font_desc);
  19. }
  20. pango_font_description_free(font_desc);
  21. }
  22. void mssh_gconf_notify_fg_colour(GConfClient *client, guint cnxn_id,
  23. GConfEntry *entry, gpointer data)
  24. {
  25. GConfValue *value;
  26. const gchar *colour_s;
  27. GdkRGBA colour;
  28. int i;
  29. MSSHWindow *window = MSSH_WINDOW(data);
  30. value = gconf_entry_get_value(entry);
  31. colour_s = gconf_value_get_string(value);
  32. gdk_rgba_parse(&colour, colour_s);
  33. for(i = 0; i < window->terminals->len; i++)
  34. {
  35. vte_terminal_set_color_foreground(VTE_TERMINAL(g_array_index(
  36. window->terminals, MSSHTerminal*, i)), &colour);
  37. }
  38. }
  39. void mssh_gconf_notify_bg_colour(GConfClient *client, guint cnxn_id,
  40. GConfEntry *entry, gpointer data)
  41. {
  42. GConfValue *value;
  43. const gchar *colour_s;
  44. GdkRGBA colour;
  45. int i;
  46. MSSHWindow *window = MSSH_WINDOW(data);
  47. value = gconf_entry_get_value(entry);
  48. colour_s = gconf_value_get_string(value);
  49. gdk_rgba_parse(&colour, colour_s);
  50. for(i = 0; i < window->terminals->len; i++)
  51. {
  52. vte_terminal_set_color_background(VTE_TERMINAL(g_array_index(
  53. window->terminals, MSSHTerminal*, i)), &colour);
  54. }
  55. }
  56. void mssh_gconf_notify_fg_colour_focus(GConfClient *client, guint cnxn_id,
  57. GConfEntry *entry, gpointer data)
  58. {
  59. GConfValue *value;
  60. const gchar *colour_s;
  61. GdkRGBA colour;
  62. int i;
  63. int idx = -1;
  64. GtkWidget *focus;
  65. MSSHWindow *window = MSSH_WINDOW(data);
  66. value = gconf_entry_get_value(entry);
  67. colour_s = gconf_value_get_string(value);
  68. gdk_rgba_parse(&colour, colour_s);
  69. /* get the currently focused window */
  70. focus = gtk_window_get_focus(GTK_WINDOW(window));
  71. /* find the focused window in the terminal list */
  72. for(i = 0; i < window->terminals->len; i++)
  73. {
  74. if(focus == GTK_WIDGET(g_array_index(window->terminals,
  75. MSSHTerminal*, i)))
  76. {
  77. idx = i;
  78. break;
  79. }
  80. }
  81. if (idx != -1) {
  82. /* found the currently focused terminal, update the color */
  83. vte_terminal_set_color_foreground(VTE_TERMINAL(g_array_index(
  84. window->terminals, MSSHTerminal*, idx)), &colour);
  85. }
  86. }
  87. void mssh_gconf_notify_bg_colour_focus(GConfClient *client, guint cnxn_id,
  88. GConfEntry *entry, gpointer data)
  89. {
  90. GConfValue *value;
  91. const gchar *colour_s;
  92. GdkRGBA colour;
  93. int i;
  94. int idx = -1;
  95. GtkWidget *focus;
  96. MSSHWindow *window = MSSH_WINDOW(data);
  97. value = gconf_entry_get_value(entry);
  98. colour_s = gconf_value_get_string(value);
  99. gdk_rgba_parse(&colour, colour_s);
  100. /* get the currently focused window */
  101. focus = gtk_window_get_focus(GTK_WINDOW(window));
  102. /* find the focused window in the terminal list */
  103. for(i = 0; i < window->terminals->len; i++)
  104. {
  105. if(focus == GTK_WIDGET(g_array_index(window->terminals,
  106. MSSHTerminal*, i)))
  107. {
  108. idx = i;
  109. break;
  110. }
  111. }
  112. if (idx != -1) {
  113. /* found the currently focused terminal, update the color */
  114. vte_terminal_set_color_background(VTE_TERMINAL(g_array_index(
  115. window->terminals, MSSHTerminal*, idx)), &colour);
  116. }
  117. }
  118. void mssh_gconf_notify_columns(GConfClient *client, guint cnxn_id,
  119. GConfEntry *entry, gpointer data)
  120. {
  121. GConfValue *value;
  122. int columns;
  123. MSSHWindow *window = MSSH_WINDOW(data);
  124. value = gconf_entry_get_value(entry);
  125. columns = gconf_value_get_int(value);
  126. if(columns <= 0)
  127. {
  128. columns = 1;
  129. gconf_client_set_int(client, MSSH_GCONF_KEY_COLUMNS, columns,
  130. NULL);
  131. }
  132. window->columns = columns;
  133. mssh_window_relayout(window);
  134. }
  135. void mssh_gconf_notify_timeout(GConfClient *client, guint cnxn_id,
  136. GConfEntry *entry, gpointer data)
  137. {
  138. GConfValue *value;
  139. int timeout;
  140. MSSHWindow *window = MSSH_WINDOW(data);
  141. value = gconf_entry_get_value(entry);
  142. timeout = gconf_value_get_int(value);
  143. if(timeout < 0)
  144. {
  145. timeout = 0;
  146. gconf_client_set_int(client, MSSH_GCONF_KEY_TIMEOUT, timeout,
  147. NULL);
  148. }
  149. window->timeout = timeout;
  150. mssh_window_relayout(window);
  151. }
  152. void mssh_gconf_notify_close_ended(GConfClient *client, guint cnxn_id,
  153. GConfEntry *entry, gpointer data)
  154. {
  155. GConfValue *value;
  156. gboolean close_ended;
  157. int i;
  158. MSSHWindow *window = MSSH_WINDOW(data);
  159. value = gconf_entry_get_value(entry);
  160. close_ended = gconf_value_get_bool(value);
  161. window->close_ended_sessions = close_ended;
  162. if(close_ended)
  163. {
  164. for(i = 0; i < window->terminals->len; i++)
  165. {
  166. MSSHTerminal *terminal = g_array_index(window->terminals,
  167. MSSHTerminal*, i);
  168. if(terminal->ended)
  169. {
  170. mssh_window_session_closed(terminal, window);
  171. }
  172. }
  173. }
  174. }
  175. void mssh_gconf_notify_recolor_focused(GConfClient *client, guint cnxn_id,
  176. GConfEntry *entry, gpointer data)
  177. {
  178. GConfValue *value;
  179. gboolean recolor_focused;
  180. MSSHWindow *window = MSSH_WINDOW(data);
  181. value = gconf_entry_get_value(entry);
  182. recolor_focused = gconf_value_get_bool(value);
  183. window->recolor_focused = recolor_focused;
  184. }
  185. void mssh_gconf_notify_quit_all_ended(GConfClient *client, guint cnxn_id,
  186. GConfEntry *entry, gpointer data)
  187. {
  188. GConfValue *value;
  189. MSSHWindow *window = MSSH_WINDOW(data);
  190. value = gconf_entry_get_value(entry);
  191. window->exit_on_all_closed = gconf_value_get_bool(value);
  192. }
  193. void mssh_gconf_notify_dir_focus(GConfClient *client, guint cnxn_id,
  194. GConfEntry *entry, gpointer data)
  195. {
  196. GConfValue *value;
  197. MSSHWindow *window = MSSH_WINDOW(data);
  198. value = gconf_entry_get_value(entry);
  199. window->dir_focus = gconf_value_get_bool(value);
  200. }
  201. void mssh_gconf_notify_modifier(GConfClient *client, guint cnxn_id,
  202. GConfEntry *entry, gpointer data)
  203. {
  204. GConfValue *value;
  205. MSSHWindow *window = MSSH_WINDOW(data);
  206. value = gconf_entry_get_value(entry);
  207. if(window->accel)
  208. {
  209. gtk_accel_group_disconnect_key(window->accel, GDK_KEY_Up,
  210. window->modifier);
  211. gtk_accel_group_disconnect_key(window->accel, GDK_KEY_Down,
  212. window->modifier);
  213. gtk_accel_group_disconnect_key(window->accel, GDK_KEY_Left,
  214. window->modifier);
  215. gtk_accel_group_disconnect_key(window->accel, GDK_KEY_Right,
  216. window->modifier);
  217. }
  218. window->modifier = gconf_value_get_int(value);
  219. if(window->accel)
  220. {
  221. gtk_accel_group_connect(window->accel, GDK_KEY_Up, window->modifier,
  222. GTK_ACCEL_VISIBLE, g_cclosure_new(
  223. G_CALLBACK(mssh_window_focus), window, NULL));
  224. gtk_accel_group_connect(window->accel, GDK_KEY_Down, window->modifier,
  225. GTK_ACCEL_VISIBLE, g_cclosure_new(
  226. G_CALLBACK(mssh_window_focus), window, NULL));
  227. gtk_accel_group_connect(window->accel, GDK_KEY_Left, window->modifier,
  228. GTK_ACCEL_VISIBLE, g_cclosure_new(
  229. G_CALLBACK(mssh_window_focus), window, NULL));
  230. gtk_accel_group_connect(window->accel, GDK_KEY_Right, window->modifier,
  231. GTK_ACCEL_VISIBLE, g_cclosure_new(
  232. G_CALLBACK(mssh_window_focus), window, NULL));
  233. }
  234. }
  235. void mssh_gconf_backscroll_buffer_size(GConfClient *client, guint cnxn_id,
  236. GConfEntry *entry, gpointer data)
  237. {
  238. GConfValue *value;
  239. gint backscroll_buffer_size;
  240. MSSHWindow *window = MSSH_WINDOW(data);
  241. int i;
  242. int len = window->terminals->len;
  243. value = gconf_entry_get_value(entry);
  244. backscroll_buffer_size = gconf_value_get_int(value);
  245. if (backscroll_buffer_size < -1)
  246. {
  247. backscroll_buffer_size = 5000;
  248. gconf_client_set_int(client, MSSH_GCONF_KEY_BACKSCROLL_BUFFER_SIZE, backscroll_buffer_size,
  249. NULL);
  250. }
  251. window->backscroll_buffer_size = backscroll_buffer_size;
  252. /* reconfigure all terminals with the new size*/
  253. for(i = 0; i < len; i++)
  254. {
  255. mssh_terminal_set_backscroll_size(g_array_index(window->terminals,
  256. MSSHTerminal*, i), &backscroll_buffer_size);
  257. }
  258. }