mssh-gconf.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. GdkVisual *visual = gdk_visual_get_system();
  27. GdkColormap *colour_map;
  28. GdkColor colour;
  29. int i;
  30. MSSHWindow *window = MSSH_WINDOW(data);
  31. value = gconf_entry_get_value(entry);
  32. colour_s = gconf_value_get_string(value);
  33. colour_map = gdk_colormap_new(visual, TRUE);
  34. gdk_colormap_alloc_color(colour_map, &colour, TRUE, TRUE);
  35. gdk_color_parse(colour_s, &colour);
  36. for(i = 0; i < window->terminals->len; i++)
  37. {
  38. vte_terminal_set_color_foreground(VTE_TERMINAL(g_array_index(
  39. window->terminals, MSSHTerminal*, i)), &colour);
  40. }
  41. }
  42. void mssh_gconf_notify_bg_colour(GConfClient *client, guint cnxn_id,
  43. GConfEntry *entry, gpointer data)
  44. {
  45. GConfValue *value;
  46. const gchar *colour_s;
  47. GdkVisual *visual = gdk_visual_get_system();
  48. GdkColormap *colour_map;
  49. GdkColor colour;
  50. int i;
  51. MSSHWindow *window = MSSH_WINDOW(data);
  52. value = gconf_entry_get_value(entry);
  53. colour_s = gconf_value_get_string(value);
  54. colour_map = gdk_colormap_new(visual, TRUE);
  55. gdk_colormap_alloc_color(colour_map, &colour, TRUE, TRUE);
  56. gdk_color_parse(colour_s, &colour);
  57. for(i = 0; i < window->terminals->len; i++)
  58. {
  59. vte_terminal_set_color_background(VTE_TERMINAL(g_array_index(
  60. window->terminals, MSSHTerminal*, i)), &colour);
  61. }
  62. }
  63. void mssh_gconf_notify_columns(GConfClient *client, guint cnxn_id,
  64. GConfEntry *entry, gpointer data)
  65. {
  66. GConfValue *value;
  67. int columns;
  68. MSSHWindow *window = MSSH_WINDOW(data);
  69. value = gconf_entry_get_value(entry);
  70. columns = gconf_value_get_int(value);
  71. if(columns <= 0)
  72. {
  73. columns = 1;
  74. gconf_client_set_int(client, MSSH_GCONF_KEY_COLUMNS, columns,
  75. NULL);
  76. }
  77. window->columns = columns;
  78. mssh_window_relayout(window);
  79. }
  80. void mssh_gconf_notify_timeout(GConfClient *client, guint cnxn_id,
  81. GConfEntry *entry, gpointer data)
  82. {
  83. GConfValue *value;
  84. int timeout;
  85. MSSHWindow *window = MSSH_WINDOW(data);
  86. value = gconf_entry_get_value(entry);
  87. timeout = gconf_value_get_int(value);
  88. if(timeout < 0)
  89. {
  90. timeout = 0;
  91. gconf_client_set_int(client, MSSH_GCONF_KEY_TIMEOUT, timeout,
  92. NULL);
  93. }
  94. window->timeout = timeout;
  95. mssh_window_relayout(window);
  96. }
  97. void mssh_gconf_notify_close_ended(GConfClient *client, guint cnxn_id,
  98. GConfEntry *entry, gpointer data)
  99. {
  100. GConfValue *value;
  101. gboolean close_ended;
  102. int i;
  103. MSSHWindow *window = MSSH_WINDOW(data);
  104. value = gconf_entry_get_value(entry);
  105. close_ended = gconf_value_get_bool(value);
  106. window->close_ended_sessions = close_ended;
  107. if(close_ended)
  108. {
  109. for(i = 0; i < window->terminals->len; i++)
  110. {
  111. MSSHTerminal *terminal = g_array_index(window->terminals,
  112. MSSHTerminal*, i);
  113. if(terminal->ended)
  114. {
  115. mssh_window_session_closed(terminal, window);
  116. }
  117. }
  118. }
  119. }
  120. void mssh_gconf_notify_quit_all_ended(GConfClient *client, guint cnxn_id,
  121. GConfEntry *entry, gpointer data)
  122. {
  123. GConfValue *value;
  124. MSSHWindow *window = MSSH_WINDOW(data);
  125. value = gconf_entry_get_value(entry);
  126. window->exit_on_all_closed = gconf_value_get_bool(value);
  127. }
  128. void mssh_gconf_notify_dir_focus(GConfClient *client, guint cnxn_id,
  129. GConfEntry *entry, gpointer data)
  130. {
  131. GConfValue *value;
  132. MSSHWindow *window = MSSH_WINDOW(data);
  133. value = gconf_entry_get_value(entry);
  134. window->dir_focus = gconf_value_get_bool(value);
  135. }
  136. void mssh_gconf_notify_modifier(GConfClient *client, guint cnxn_id,
  137. GConfEntry *entry, gpointer data)
  138. {
  139. GConfValue *value;
  140. MSSHWindow *window = MSSH_WINDOW(data);
  141. value = gconf_entry_get_value(entry);
  142. if(window->accel)
  143. {
  144. gtk_accel_group_disconnect_key(window->accel, GDK_KEY_Up,
  145. window->modifier);
  146. gtk_accel_group_disconnect_key(window->accel, GDK_KEY_Down,
  147. window->modifier);
  148. gtk_accel_group_disconnect_key(window->accel, GDK_KEY_Left,
  149. window->modifier);
  150. gtk_accel_group_disconnect_key(window->accel, GDK_KEY_Right,
  151. window->modifier);
  152. }
  153. window->modifier = gconf_value_get_int(value);
  154. if(window->accel)
  155. {
  156. gtk_accel_group_connect(window->accel, GDK_KEY_Up, window->modifier,
  157. GTK_ACCEL_VISIBLE, g_cclosure_new(
  158. G_CALLBACK(mssh_window_focus), window, NULL));
  159. gtk_accel_group_connect(window->accel, GDK_KEY_Down, window->modifier,
  160. GTK_ACCEL_VISIBLE, g_cclosure_new(
  161. G_CALLBACK(mssh_window_focus), window, NULL));
  162. gtk_accel_group_connect(window->accel, GDK_KEY_Left, window->modifier,
  163. GTK_ACCEL_VISIBLE, g_cclosure_new(
  164. G_CALLBACK(mssh_window_focus), window, NULL));
  165. gtk_accel_group_connect(window->accel, GDK_KEY_Right, window->modifier,
  166. GTK_ACCEL_VISIBLE, g_cclosure_new(
  167. G_CALLBACK(mssh_window_focus), window, NULL));
  168. }
  169. }