mssh-gconf.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #include <vte/vte.h>
  2. #include "mssh-gconf.h"
  3. #include "mssh-window.h"
  4. #include "mssh-terminal.h"
  5. void mssh_gconf_notify_font(GConfClient *client, guint cnxn_id,
  6. GConfEntry *entry, gpointer data)
  7. {
  8. GConfValue *value;
  9. const gchar *font;
  10. int i;
  11. MSSHWindow *window = MSSH_WINDOW(data);
  12. value = gconf_entry_get_value(entry);
  13. font = gconf_value_get_string(value);
  14. for(i = 0; i < window->terminals->len; i++)
  15. {
  16. vte_terminal_set_font_from_string(VTE_TERMINAL(g_array_index(
  17. window->terminals, MSSHTerminal*, i)), font);
  18. }
  19. }
  20. void mssh_gconf_notify_fg_colour(GConfClient *client, guint cnxn_id,
  21. GConfEntry *entry, gpointer data)
  22. {
  23. GConfValue *value;
  24. const gchar *colour_s;
  25. GdkVisual *visual = gdk_visual_get_system();
  26. GdkColormap *colour_map;
  27. GdkColor 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. colour_map = gdk_colormap_new(visual, TRUE);
  33. gdk_colormap_alloc_color(colour_map, &colour, TRUE, TRUE);
  34. gdk_color_parse(colour_s, &colour);
  35. for(i = 0; i < window->terminals->len; i++)
  36. {
  37. vte_terminal_set_color_foreground(VTE_TERMINAL(g_array_index(
  38. window->terminals, MSSHTerminal*, i)), &colour);
  39. }
  40. }
  41. void mssh_gconf_notify_bg_colour(GConfClient *client, guint cnxn_id,
  42. GConfEntry *entry, gpointer data)
  43. {
  44. GConfValue *value;
  45. const gchar *colour_s;
  46. GdkVisual *visual = gdk_visual_get_system();
  47. GdkColormap *colour_map;
  48. GdkColor colour;
  49. int i;
  50. MSSHWindow *window = MSSH_WINDOW(data);
  51. value = gconf_entry_get_value(entry);
  52. colour_s = gconf_value_get_string(value);
  53. colour_map = gdk_colormap_new(visual, TRUE);
  54. gdk_colormap_alloc_color(colour_map, &colour, TRUE, TRUE);
  55. gdk_color_parse(colour_s, &colour);
  56. for(i = 0; i < window->terminals->len; i++)
  57. {
  58. vte_terminal_set_color_background(VTE_TERMINAL(g_array_index(
  59. window->terminals, MSSHTerminal*, i)), &colour);
  60. }
  61. }
  62. void mssh_gconf_notify_columns(GConfClient *client, guint cnxn_id,
  63. GConfEntry *entry, gpointer data)
  64. {
  65. GConfValue *value;
  66. int columns;
  67. MSSHWindow *window = MSSH_WINDOW(data);
  68. value = gconf_entry_get_value(entry);
  69. columns = gconf_value_get_int(value);
  70. if(columns <= 0)
  71. {
  72. columns = 1;
  73. gconf_client_set_int(client, MSSH_GCONF_KEY_COLUMNS, columns,
  74. NULL);
  75. }
  76. window->columns = columns;
  77. mssh_window_relayout(window);
  78. }
  79. void mssh_gconf_notify_timeout(GConfClient *client, guint cnxn_id,
  80. GConfEntry *entry, gpointer data)
  81. {
  82. GConfValue *value;
  83. int timeout;
  84. MSSHWindow *window = MSSH_WINDOW(data);
  85. value = gconf_entry_get_value(entry);
  86. timeout = gconf_value_get_int(value);
  87. if(timeout < 0)
  88. {
  89. timeout = 0;
  90. gconf_client_set_int(client, MSSH_GCONF_KEY_TIMEOUT, timeout,
  91. NULL);
  92. }
  93. window->timeout = timeout;
  94. mssh_window_relayout(window);
  95. }
  96. void mssh_gconf_notify_close_ended(GConfClient *client, guint cnxn_id,
  97. GConfEntry *entry, gpointer data)
  98. {
  99. GConfValue *value;
  100. gboolean close_ended;
  101. int i;
  102. MSSHWindow *window = MSSH_WINDOW(data);
  103. value = gconf_entry_get_value(entry);
  104. close_ended = gconf_value_get_bool(value);
  105. window->close_ended_sessions = close_ended;
  106. if(close_ended)
  107. {
  108. for(i = 0; i < window->terminals->len; i++)
  109. {
  110. MSSHTerminal *terminal = g_array_index(window->terminals,
  111. MSSHTerminal*, i);
  112. if(terminal->ended)
  113. {
  114. mssh_window_session_closed(terminal, window);
  115. }
  116. }
  117. }
  118. }
  119. void mssh_gconf_notify_quit_all_ended(GConfClient *client, guint cnxn_id,
  120. GConfEntry *entry, gpointer data)
  121. {
  122. GConfValue *value;
  123. MSSHWindow *window = MSSH_WINDOW(data);
  124. value = gconf_entry_get_value(entry);
  125. window->exit_on_all_closed = gconf_value_get_bool(value);
  126. }