mssh-gconf.c 8.5 KB

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