瀏覽代碼

Add the option to change colors to the focused terminal

Héctor García 10 年之前
父節點
當前提交
82564e94c9
共有 7 個文件被更改,包括 318 次插入0 次删除
  1. 4 0
      ChangeLog
  2. 33 0
      mssh.schemas
  3. 89 0
      src/mssh-gconf.c
  4. 9 0
      src/mssh-gconf.h
  5. 88 0
      src/mssh-pref.c
  6. 94 0
      src/mssh-window.c
  7. 1 0
      src/mssh-window.h

+ 4 - 0
ChangeLog

@@ -1,13 +1,17 @@
 2014-03-14  Héctor García  <[email protected]>
 
 	Added support to defined backscroll lines for terminals. Patch from Balint Deak.
+
 	Added support to maximize a terminal (ctrl + shift + x). Patch from Balint Deak.
 
+    Added support to change bg y fg colors on selected terminal. Patch from Balint Deak.
+
 2014-01-15  Héctor García  <[email protected]>
 
 	Bumped version to 2.0 gtk3 support
 
 	Changed from gdk_color_ to gdk_rgba_ functions
+
 	Changed from gtk_color_button to gtk_color_chooser
 
 	Change from gtk_vbox and gtk_hbox to gtk_box

+ 33 - 0
mssh.schemas

@@ -33,6 +33,39 @@
                 <long>Background colour to use for all MSSH terminals</long>
             </locale>
         </schema>
+        <schema>
+            <key>/schemas/apps/mssh/recolor_focused</key>
+            <applyto>/apps/mssh/recolor_focused</applyto>
+            <owner>mssh</owner>
+            <type>bool</type>
+            <default>true</default>
+            <locale name="C">
+                <short>Recolor focused window</short>
+                <long>Use different Back- and Foreground color for focused window</long>
+            </locale>
+        </schema>
+        <schema>
+            <key>/schemas/apps/mssh/fg_colour_focus</key>
+            <applyto>/apps/mssh/fg_colour_focus</applyto>
+            <owner>mssh</owner>
+            <type>string</type>
+            <default>#ffffffffffff</default>
+            <locale name="C">
+                <short>Terminal foreground colour for the focused window</short>
+                <long>Foreground colour to use for the currently focused MSSH terminal</long>
+            </locale>
+        </schema>
+        <schema>
+            <key>/schemas/apps/mssh/bg_colour_focus</key>
+            <applyto>/apps/mssh/bg_colour_focus</applyto>
+            <owner>mssh</owner>
+            <type>string</type>
+            <default>#000000000000</default>
+            <locale name="C">
+                <short>Terminal background colour for the focused window</short>
+                <long>Background colour to use for the currently focused MSSH terminal</long>
+            </locale>
+        </schema>
         <schema>
             <key>/schemas/apps/mssh/coloums</key>
             <applyto>/apps/mssh/columns</applyto>

+ 89 - 0
src/mssh-gconf.c

@@ -66,6 +66,80 @@ void mssh_gconf_notify_bg_colour(GConfClient *client, guint cnxn_id,
     }
 }
 
+void mssh_gconf_notify_fg_colour_focus(GConfClient *client, guint cnxn_id,
+    GConfEntry *entry, gpointer data)
+{
+    GConfValue *value;
+    const gchar *colour_s;
+    GdkRGBA colour;
+    int i;
+    int idx = -1;
+    GtkWidget *focus;
+
+    MSSHWindow *window = MSSH_WINDOW(data);
+
+    value = gconf_entry_get_value(entry);
+    colour_s = gconf_value_get_string(value);
+    gdk_rgba_parse(&colour, colour_s);
+
+    /* get the currently focused window */
+	focus = gtk_window_get_focus(GTK_WINDOW(window));
+
+    /* find the focused window in the terminal list */
+    for(i = 0; i < window->terminals->len; i++)
+    {
+        if(focus == GTK_WIDGET(g_array_index(window->terminals,
+            MSSHTerminal*, i)))
+        {
+            idx = i;
+            break;
+        }
+    }
+
+    if (idx != -1) {
+        /* found the currently focused terminal, update the color */
+        vte_terminal_set_color_foreground_rgba(VTE_TERMINAL(g_array_index(
+            window->terminals, MSSHTerminal*, idx)), &colour);
+    }
+}
+
+void mssh_gconf_notify_bg_colour_focus(GConfClient *client, guint cnxn_id,
+    GConfEntry *entry, gpointer data)
+{
+    GConfValue *value;
+    const gchar *colour_s;
+    GdkRGBA colour;
+    int i;
+    int idx = -1;
+	GtkWidget *focus;
+
+    MSSHWindow *window = MSSH_WINDOW(data);
+
+    value = gconf_entry_get_value(entry);
+    colour_s = gconf_value_get_string(value);
+    gdk_rgba_parse(&colour, colour_s);
+
+    /* get the currently focused window */
+    focus = gtk_window_get_focus(GTK_WINDOW(window));
+
+    /* find the focused window in the terminal list */
+    for(i = 0; i < window->terminals->len; i++)
+    {
+        if(focus == GTK_WIDGET(g_array_index(window->terminals,
+            MSSHTerminal*, i)))
+        {
+            idx = i;
+            break;
+        }
+    }
+
+    if (idx != -1) {
+        /* found the currently focused terminal, update the color */
+        vte_terminal_set_color_background_rgba(VTE_TERMINAL(g_array_index(
+            window->terminals, MSSHTerminal*, idx)), &colour);
+    }
+
+}
 void mssh_gconf_notify_columns(GConfClient *client, guint cnxn_id,
     GConfEntry *entry, gpointer data)
 {
@@ -139,6 +213,21 @@ void mssh_gconf_notify_close_ended(GConfClient *client, guint cnxn_id,
     }
 }
 
+void mssh_gconf_notify_recolor_focused(GConfClient *client, guint cnxn_id,
+    GConfEntry *entry, gpointer data)
+{
+    GConfValue *value;
+    gboolean recolor_focused;
+
+    MSSHWindow *window = MSSH_WINDOW(data);
+
+    value = gconf_entry_get_value(entry);
+    recolor_focused = gconf_value_get_bool(value);
+
+    window->recolor_focused = recolor_focused;
+
+}
+
 void mssh_gconf_notify_quit_all_ended(GConfClient *client, guint cnxn_id,
     GConfEntry *entry, gpointer data)
 {

+ 9 - 0
src/mssh-gconf.h

@@ -7,9 +7,12 @@
 #define MSSH_GCONF_KEY_FONT             		MSSH_GCONF_PATH"/font"
 #define MSSH_GCONF_KEY_FG_COLOUR        		MSSH_GCONF_PATH"/fg_colour"
 #define MSSH_GCONF_KEY_BG_COLOUR        		MSSH_GCONF_PATH"/bg_colour"
+#define MSSH_GCONF_KEY_FG_COLOUR_FOCUS          MSSH_GCONF_PATH"/fg_colour_focus"
+#define MSSH_GCONF_KEY_BG_COLOUR_FOCUS          MSSH_GCONF_PATH"/bg_colour_focus"
 #define MSSH_GCONF_KEY_COLUMNS          		MSSH_GCONF_PATH"/columns"
 #define MSSH_GCONF_KEY_TIMEOUT          		MSSH_GCONF_PATH"/timeout"
 #define MSSH_GCONF_KEY_CLOSE_ENDED      		MSSH_GCONF_PATH"/close_ended"
+#define MSSH_GCONF_KEY_RECOLOR_FOCUSED          MSSH_GCONF_PATH"/recolor_focused"
 #define MSSH_GCONF_KEY_QUIT_ALL_ENDED   		MSSH_GCONF_PATH"/quit_all_ended"
 #define MSSH_GCONF_KEY_MODIFIER         		MSSH_GCONF_PATH"/modifier"
 #define MSSH_GCONF_KEY_DIR_FOCUS        		MSSH_GCONF_PATH"/dir_focus"
@@ -21,6 +24,10 @@ void mssh_gconf_notify_fg_colour(GConfClient *client, guint cnxn_id,
     GConfEntry *entry, gpointer data);
 void mssh_gconf_notify_bg_colour(GConfClient *client, guint cnxn_id,
     GConfEntry *entry, gpointer data);
+void mssh_gconf_notify_fg_colour_focus(GConfClient *client, guint cnxn_id,
+    GConfEntry *entry, gpointer data);
+void mssh_gconf_notify_bg_colour_focus(GConfClient *client, guint cnxn_id,
+    GConfEntry *entry, gpointer data);
 void mssh_gconf_notify_columns(GConfClient *client, guint cnxn_id,
     GConfEntry *entry, gpointer data);
 void mssh_gconf_notify_timeout(GConfClient *client, guint cnxn_id,
@@ -35,5 +42,7 @@ void mssh_gconf_notify_dir_focus(GConfClient *client, guint cnxn_id,
     GConfEntry *entry, gpointer data);
 void mssh_gconf_backscroll_buffer_size(GConfClient *client, guint cnxn_id,
     GConfEntry *entry, gpointer data);
+void mssh_gconf_notify_recolor_focused(GConfClient *client, guint cnxn_id,
+    GConfEntry *entry, gpointer data);
 
 #endif

+ 88 - 0
src/mssh-pref.c

@@ -63,6 +63,36 @@ static void mssh_pref_bg_colour_select(GtkWidget *widget, gpointer data)
         NULL);
 }
 
+static void mssh_pref_fg_colour_select_focus(GtkWidget *widget, gpointer data)
+{
+    GConfClient *client;
+    GdkRGBA colour;
+    const gchar *colour_s;
+
+    client = gconf_client_get_default();
+
+    gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(widget), &colour);
+    colour_s = gdk_rgba_to_string(&colour);
+
+
+    gconf_client_set_string(client, MSSH_GCONF_KEY_FG_COLOUR_FOCUS, colour_s,
+        NULL);
+}
+
+static void mssh_pref_bg_colour_select_focus(GtkWidget *widget, gpointer data)
+{
+    GConfClient *client;
+    GdkRGBA colour;
+    const gchar *colour_s;
+
+    client = gconf_client_get_default();
+
+    gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(widget), &colour);
+    colour_s = gdk_rgba_to_string(&colour);
+
+    gconf_client_set_string(client, MSSH_GCONF_KEY_BG_COLOUR_FOCUS, colour_s,
+        NULL);
+}
 static void mssh_pref_columns_select(GtkWidget *widget, gpointer data)
 {
     GConfClient *client;
@@ -110,6 +140,17 @@ static void mssh_pref_close_check(GtkWidget *widget, gpointer data)
     gconf_client_set_bool(client, MSSH_GCONF_KEY_CLOSE_ENDED, close, NULL);
 }
 
+static void mssh_pref_recolor_focused_check(GtkWidget *widget, gpointer data)
+{
+    GConfClient *client;
+    gboolean recolor_focused;
+
+    client = gconf_client_get_default();
+
+    recolor_focused = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+
+    gconf_client_set_bool(client, MSSH_GCONF_KEY_RECOLOR_FOCUSED, recolor_focused, NULL);
+}
 static void mssh_pref_exit_check(GtkWidget *widget, gpointer data)
 {
     GConfClient *client;
@@ -177,6 +218,14 @@ static void mssh_pref_init(MSSHPref* pref)
     GtkWidget *fg_colour_label = gtk_label_new("Foreground:");
     GtkWidget *fg_colour_select = gtk_color_button_new();
 
+    GtkWidget *recolor_focused_check = gtk_check_button_new_with_label(
+        "Use different color for focused window");
+
+    GtkWidget *colour_table_focus = gtk_grid_new();
+    GtkWidget *bg_colour_label_focus = gtk_label_new("Background for focused window:");
+    GtkWidget *bg_colour_select_focus = gtk_color_button_new();
+    GtkWidget *fg_colour_label_focus = gtk_label_new("Foreground for focused window:");
+    GtkWidget *fg_colour_select_focus = gtk_color_button_new();
     GtkWidget *exit_check = gtk_check_button_new_with_label(
         "Quit after all sessions have ended");
     GtkWidget *close_check = gtk_check_button_new_with_label(
@@ -236,6 +285,17 @@ static void mssh_pref_init(MSSHPref* pref)
         1, 1, 1, 1);
     gtk_box_pack_start(GTK_BOX(content), colour_table, FALSE, TRUE, 0);
 
+    gtk_box_pack_start(GTK_BOX(content), recolor_focused_check, FALSE, TRUE, 0);
+
+    gtk_grid_attach(GTK_GRID(colour_table_focus), bg_colour_label_focus,
+        0, 0, 1, 1);
+    gtk_grid_attach(GTK_GRID(colour_table_focus), bg_colour_select_focus,
+        1, 0, 1, 1);
+    gtk_grid_attach(GTK_GRID(colour_table_focus), fg_colour_label_focus,
+        0, 1, 1, 1);
+    gtk_grid_attach(GTK_GRID(colour_table_focus), fg_colour_select_focus,
+        1, 1, 1, 1);
+    gtk_box_pack_start(GTK_BOX(content), colour_table_focus, FALSE, TRUE, 0);
     gtk_box_pack_start(GTK_BOX(content), exit_check, FALSE, TRUE, 0);
     gtk_box_pack_start(GTK_BOX(content), close_check, FALSE, TRUE, 0);
     gtk_box_pack_start(GTK_BOX(content), dir_focus_check, FALSE, TRUE, 0);
@@ -288,6 +348,10 @@ static void mssh_pref_init(MSSHPref* pref)
         G_CALLBACK(mssh_pref_fg_colour_select), NULL);
     g_signal_connect(G_OBJECT(bg_colour_select), "color-set",
         G_CALLBACK(mssh_pref_bg_colour_select), NULL);
+    g_signal_connect(G_OBJECT(fg_colour_select_focus), "color-set",
+        G_CALLBACK(mssh_pref_fg_colour_select_focus), NULL);
+    g_signal_connect(G_OBJECT(bg_colour_select_focus), "color-set",
+        G_CALLBACK(mssh_pref_bg_colour_select_focus), NULL);
     g_signal_connect(G_OBJECT(columns_select), "value-changed",
         G_CALLBACK(mssh_pref_columns_select), NULL);
     g_signal_connect(G_OBJECT(backscroll_buffer_size_select), "value-changed",
@@ -296,6 +360,8 @@ static void mssh_pref_init(MSSHPref* pref)
         G_CALLBACK(mssh_pref_timeout_select), NULL);
     g_signal_connect(G_OBJECT(close_check), "toggled",
         G_CALLBACK(mssh_pref_close_check), NULL);
+    g_signal_connect(G_OBJECT(recolor_focused_check), "toggled",
+        G_CALLBACK(mssh_pref_recolor_focused_check), NULL);
     g_signal_connect(G_OBJECT(exit_check), "toggled",
         G_CALLBACK(mssh_pref_exit_check), NULL);
      g_signal_connect(G_OBJECT(dir_focus_check), "toggled",
@@ -333,6 +399,22 @@ static void mssh_pref_init(MSSHPref* pref)
     gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(bg_colour_select),
         &colour);
 
+    entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_FG_COLOUR_FOCUS, NULL,
+        TRUE, NULL);
+    value = gconf_entry_get_value(entry);
+    colour_s = gconf_value_get_string(value);
+    gdk_rgba_parse(&colour, colour_s);
+    gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(fg_colour_select_focus),
+        &colour);
+
+    entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_BG_COLOUR_FOCUS, NULL,
+        TRUE, NULL);
+    value = gconf_entry_get_value(entry);
+    colour_s = gconf_value_get_string(value);
+    gdk_rgba_parse(&colour, colour_s);
+    gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(bg_colour_select_focus),
+        &colour);
+
     entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_COLUMNS, NULL,
         TRUE, NULL);
     value = gconf_entry_get_value(entry);
@@ -357,6 +439,12 @@ static void mssh_pref_init(MSSHPref* pref)
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(close_check),
         gconf_value_get_bool(value));
 
+    entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_RECOLOR_FOCUSED,
+        NULL, TRUE, NULL);
+    value = gconf_entry_get_value(entry);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(recolor_focused_check),
+        gconf_value_get_bool(value));
+
     entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_QUIT_ALL_ENDED,
             NULL, TRUE, NULL);
     value = gconf_entry_get_value(entry);

+ 94 - 0
src/mssh-window.c

@@ -109,11 +109,22 @@ static gboolean mssh_window_key_press(GtkWidget *widget,
 static gboolean mssh_window_entry_focused(GtkWidget *widget,
     GtkDirectionType dir, gpointer data)
 {
+    GConfClient *client;
+    GConfEntry *entry;
     MSSHWindow *window = MSSH_WINDOW(data);
 
     gtk_window_set_title(GTK_WINDOW(window), PACKAGE_NAME" - All");
     window->last_focus = NULL;
 
+    /* clear the coloring for the focused window */
+    client = gconf_client_get_default();
+
+    entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_FG_COLOUR, NULL,
+        TRUE, NULL);
+    mssh_gconf_notify_fg_colour(client, 0, entry, window);
+    entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_BG_COLOUR, NULL,
+        TRUE, NULL);
+    mssh_gconf_notify_bg_colour(client, 0, entry, window);
     return FALSE;
 }
 
@@ -122,6 +133,8 @@ gboolean mssh_window_focus(GtkWidget *widget, GObject *acceleratable,
 {
     MSSHWindow *window = MSSH_WINDOW(data);
     GtkWidget *focus;
+    GConfClient *client;
+    GConfEntry *entry;
 
     int i, idx = -1, len = window->terminals->len;
     int wcols = window->columns_override ? window->columns_override :
@@ -140,6 +153,17 @@ gboolean mssh_window_focus(GtkWidget *widget, GObject *acceleratable,
         }
     }
 
+    client = gconf_client_get_default();
+
+    /* recolor the windows */
+    if (window->recolor_focused) {
+        entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_FG_COLOUR, NULL,
+            TRUE, NULL);
+        mssh_gconf_notify_fg_colour(client, 0, entry, window);
+        entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_BG_COLOUR, NULL,
+            TRUE, NULL);
+        mssh_gconf_notify_bg_colour(client, 0, entry, window);
+    }
     if(focus == window->global_entry && keyval == GDK_KEY_Down &&
         window->dir_focus)
         idx = 0;
@@ -261,6 +285,8 @@ static void mssh_window_session_focused(MSSHTerminal *terminal,
     char *title;
     size_t len;
 
+    GConfClient *client;
+    GConfEntry *entry;
     MSSHWindow *window = MSSH_WINDOW(data);
 
     len = strlen(PACKAGE_NAME" - ") + strlen(terminal->hostname) + 1;
@@ -271,6 +297,25 @@ static void mssh_window_session_focused(MSSHTerminal *terminal,
     gtk_window_set_title(GTK_WINDOW(window), title);
 
     free(title);
+    client = gconf_client_get_default();
+
+    /* recolor all windows */
+    entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_FG_COLOUR, NULL,
+        TRUE, NULL);
+    mssh_gconf_notify_fg_colour(client, 0, entry, window);
+    entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_BG_COLOUR, NULL,
+        TRUE, NULL);
+    mssh_gconf_notify_bg_colour(client, 0, entry, window);
+
+    /* recolor the focused window - if needed */
+    if (window->recolor_focused && window->is_maximized == 0) {
+        entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_FG_COLOUR_FOCUS, NULL,
+            TRUE, NULL);
+        mssh_gconf_notify_fg_colour_focus(client, 0, entry, window);
+        entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_BG_COLOUR_FOCUS, NULL,
+            TRUE, NULL);
+        mssh_gconf_notify_bg_colour_focus(client, 0, entry, window);
+    }
 }
 
 void mssh_window_relayout(MSSHWindow *window)
@@ -418,6 +463,8 @@ static void mssh_window_init(MSSHWindow* window)
 
     window->is_maximized = 0;
 
+   window->recolor_focused = FALSE;
+
     gtk_menu_item_set_submenu(GTK_MENU_ITEM(file_item), file_menu);
     gtk_menu_item_set_submenu(GTK_MENU_ITEM(edit_item), edit_menu);
     gtk_menu_item_set_submenu(GTK_MENU_ITEM(server_item),
@@ -469,12 +516,18 @@ static void mssh_window_init(MSSHWindow* window)
         mssh_gconf_notify_fg_colour, window, NULL, NULL);
     gconf_client_notify_add(client, MSSH_GCONF_KEY_BG_COLOUR,
         mssh_gconf_notify_bg_colour, window, NULL, NULL);
+    gconf_client_notify_add(client, MSSH_GCONF_KEY_FG_COLOUR_FOCUS,
+        mssh_gconf_notify_fg_colour_focus, window, NULL, NULL);
+    gconf_client_notify_add(client, MSSH_GCONF_KEY_BG_COLOUR_FOCUS,
+        mssh_gconf_notify_bg_colour_focus, window, NULL, NULL);
     gconf_client_notify_add(client, MSSH_GCONF_KEY_COLUMNS,
         mssh_gconf_notify_columns, window, NULL, NULL);
     gconf_client_notify_add(client, MSSH_GCONF_KEY_TIMEOUT,
         mssh_gconf_notify_timeout, window, NULL, NULL);
     gconf_client_notify_add(client, MSSH_GCONF_KEY_CLOSE_ENDED,
         mssh_gconf_notify_close_ended, window, NULL, NULL);
+    gconf_client_notify_add(client, MSSH_GCONF_KEY_RECOLOR_FOCUSED,
+        mssh_gconf_notify_recolor_focused, window, NULL, NULL);
     gconf_client_notify_add(client, MSSH_GCONF_KEY_QUIT_ALL_ENDED,
         mssh_gconf_notify_quit_all_ended, window, NULL, NULL);
     gconf_client_notify_add(client, MSSH_GCONF_KEY_DIR_FOCUS,
@@ -487,6 +540,7 @@ static void mssh_window_init(MSSHWindow* window)
     gconf_client_notify(client, MSSH_GCONF_KEY_COLUMNS);
     gconf_client_notify(client, MSSH_GCONF_KEY_TIMEOUT);
     gconf_client_notify(client, MSSH_GCONF_KEY_CLOSE_ENDED);
+    gconf_client_notify(client, MSSH_GCONF_KEY_RECOLOR_FOCUSED);
     gconf_client_notify(client, MSSH_GCONF_KEY_QUIT_ALL_ENDED);
     gconf_client_notify(client, MSSH_GCONF_KEY_DIR_FOCUS);
     gconf_client_notify(client, MSSH_GCONF_KEY_MODIFIER);
@@ -548,6 +602,8 @@ static void mssh_window_class_init(MSSHWindowClass *klass)
 void mssh_window_relayout_for_one(MSSHWindow *window, GtkWidget *t)
 {
 
+    GConfClient *client;
+    GConfEntry *entry;
     int len = window->terminals->len;
     int wcols = window->columns_override ? window->columns_override :
         window->columns;
@@ -568,6 +624,19 @@ void mssh_window_relayout_for_one(MSSHWindow *window, GtkWidget *t)
     /* make the terminal focused */
     gtk_window_set_focus(GTK_WINDOW(window), GTK_WIDGET(terminal));
 
+    /* remove the coloring */
+    if (window->recolor_focused) {
+
+        client = gconf_client_get_default();
+
+        entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_FG_COLOUR, NULL,
+            TRUE, NULL);
+        mssh_gconf_notify_fg_colour(client, 0, entry, window);
+        entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_BG_COLOUR, NULL,
+            TRUE, NULL);
+        mssh_gconf_notify_bg_colour(client, 0, entry, window);
+    }
+
     g_object_unref(terminal);
 
 }
@@ -597,6 +666,8 @@ static void mssh_window_maximize(GtkWidget *widget, gpointer data)
     int i;
     int idx = -1;
     int len = window->terminals->len;
+    GConfClient *client;
+    GConfEntry *entry;
 
     /* get the currently focused window */
     GtkWidget *focus = gtk_window_get_focus(GTK_WINDOW(window));
@@ -614,6 +685,17 @@ static void mssh_window_maximize(GtkWidget *widget, gpointer data)
         }
     }
 
+    /* recolor the window with the normal color */
+    if (window->recolor_focused) {
+        client = gconf_client_get_default();
+
+        entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_FG_COLOUR, NULL,
+            TRUE, NULL);
+        mssh_gconf_notify_fg_colour(client, 0, entry, window);
+        entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_BG_COLOUR, NULL,
+            TRUE, NULL);
+        mssh_gconf_notify_bg_colour(client, 0, entry, window);
+    }
     if (idx == -1) {
         /* there's no window focused, do nothing */
     } else {
@@ -627,6 +709,8 @@ static void mssh_window_maximize(GtkWidget *widget, gpointer data)
 static void mssh_window_restore_layout(GtkWidget *widget, gpointer data)
 {
 
+    GConfClient *client;
+    GConfEntry *entry;
     /* get the window */
     MSSHWindow *window = MSSH_WINDOW(data);
 
@@ -639,4 +723,14 @@ static void mssh_window_restore_layout(GtkWidget *widget, gpointer data)
         gtk_window_set_focus(GTK_WINDOW(window), window->last_focus);
     }
 
+    /* recolor the focused window - if needed */
+    client = gconf_client_get_default();
+    if (window->recolor_focused && window->is_maximized == 0) {
+        entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_FG_COLOUR_FOCUS, NULL,
+            TRUE, NULL);
+        mssh_gconf_notify_fg_colour_focus(client, 0, entry, window);
+        entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_BG_COLOUR_FOCUS, NULL,
+            TRUE, NULL);
+        mssh_gconf_notify_bg_colour_focus(client, 0, entry, window);
+	}
 }

+ 1 - 0
src/mssh-window.h

@@ -38,6 +38,7 @@ typedef struct
     gint backscroll_buffer_size;
     GtkWidget *last_focus;
     int is_maximized;
+    gboolean recolor_focused;
 } MSSHWindow;
 
 typedef struct