Prechádzať zdrojové kódy

Merge tag 'tags/1.4' into gtk2

Héctor García 10 rokov pred
rodič
commit
b2963477ce
12 zmenil súbory, kde vykonal 786 pridanie a 26 odobranie
  1. 2 1
      AUTHORS
  2. 28 10
      ChangeLog
  3. 1 1
      configure.ac
  4. 55 0
      mssh.schemas
  5. 130 0
      src/mssh-gconf.c
  6. 22 10
      src/mssh-gconf.h
  7. 124 0
      src/mssh-pref.c
  8. 7 0
      src/mssh-terminal.c
  9. 2 0
      src/mssh-terminal.h
  10. 338 3
      src/mssh-window.c
  11. 9 0
      src/mssh-window.h
  12. 68 1
      src/mssh.c

+ 2 - 1
AUTHORS

@@ -8,6 +8,7 @@ Founder and Lead Developer:
 
 Contributors
 ----------------------------------------------------------------------------
+    Balint Deak  <[email protected]>
     Francisco Licerán <[email protected]>
     Mario J. Barchéin <[email protected]>
-    Oscar Fernandez <[email protected]>
+    Oscar Fernandez <[email protected]>

+ 28 - 10
ChangeLog

@@ -1,28 +1,46 @@
+2014-03-17  Héctor García  <[email protected]>
+
+	Bumped version to 1.4 gtk2 parallel release
+
+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.
+
+	Added support to create a new session. Patch from Balint Deak.
+
+2014-03-13  Héctor García  <[email protected]>
+
+	Added a new feature to the aliases file. Now you can define aliases for command line text to send using {}
+
 2014-01-20  Héctor García  <[email protected]>
 
-    Make paste with mouse middle button focus on terminal
+	Make paste with mouse middle button focus on terminal
 
 2014-01-15  Héctor García  <[email protected]>
 
-    Added patch from Oscar Fernandez to support comments on configuration archive
+	Added patch from Oscar Fernandez to support comments on configuration archive
 
-    Added patch from Mario J. Barchéin and Francisco Licerán to support port numbers on host
+	Added patch from Mario J. Barchéin and Francisco Licerán to support port numbers on host
 
-    Copy Debian's mssh man page to upstream and added Karl Goetz <[email protected]> patch
+	Copy Debian's mssh man page to upstream and added Karl Goetz <[email protected]> patch
 
-    Allow window to be smaller than 1024x768. Patch from Lorenzo Masini <[email protected]>
+	Allow window to be smaller than 1024x768. Patch from Lorenzo Masini <[email protected]>
 
 2014-01-15  Héctor García  <[email protected]>
 
-    Bumped version to 1.3 gtk2 deprecated symbols free
+	Bumped version to 1.3 gtk2 deprecated symbols free
 
-    Replaced GDK_<keyname> with GDK_KEY_<keyname>
+	Replaced GDK_<keyname> with GDK_KEY_<keyname>
 
-    Changed direct access to use accessor for terminal->parent
+	Changed direct access to use accessor for terminal->parent
 
-    Changed deprecated gtk_menu_bar_append with gtk_menu_shell_append
+	Changed deprecated gtk_menu_bar_append with gtk_menu_shell_append
 
-    Migrate from vte_terminal_fork_command to vte_terminal_fork_command_full to make compile against GTK 2.24
+	Migrate from vte_terminal_fork_command to vte_terminal_fork_command_full to make compile against GTK 2.24
 
 2010-01-15  Bradley Smith  <[email protected]>
 

+ 1 - 1
configure.ac

@@ -1,4 +1,4 @@
-AC_INIT([MultiSSH], [1.3], [[email protected]], [mssh])
+AC_INIT([MultiSSH], [1.4], [[email protected]], [mssh])
 AM_CONFIG_HEADER([config.h])
 AM_INIT_AUTOMAKE
 

+ 55 - 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>
@@ -88,6 +121,17 @@
                 <long>Uses directional focus rather than linear focus</long>
             </locale>
         </schema>
+        <schema>
+            <key>/schemas/apps/mssh/use_pattern_expansion</key>
+            <applyto>/apps/mssh/use_pattern_expansion</applyto>
+            <owner>mssh</owner>
+            <type>bool</type>
+            <default>true</default>
+            <locale name="C">
+                <short>Allow expansion of curly braces when adding new sessions</short>
+                <long>Use curly bracket expansion when adding new sessions</long>
+            </locale>
+        </schema>              
         <schema>
             <key>/schemas/apps/mssh/modifier</key>
             <applyto>/apps/mssh/modifier</applyto>
@@ -99,5 +143,16 @@
                 <long>Modifier used in focus shortcuts</long>
             </locale>
         </schema>
+        <schema>
+            <key>/schemas/apps/mssh/backscroll_buffer_size</key>
+            <applyto>/apps/mssh/backscroll_buffer_size</applyto>
+            <owner>mssh</owner>
+            <type>int</type>
+            <default>5000</default>
+            <locale name="C">
+                <short>Backscroll buffer size</short>
+                <long>Number of lines to keep for every window as a backscroll buffer. Set to -1 to make it infinite</long>
+            </locale>
+        </schema>        
     </schemalist>
 </gconfschemafile>

+ 130 - 0
src/mssh-gconf.c

@@ -76,6 +76,89 @@ 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;
+    GdkVisual *visual = gdk_visual_get_system();
+    GdkColormap *colour_map;
+    GdkColor 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);
+    colour_map = gdk_colormap_new(visual, TRUE);
+    gdk_colormap_alloc_color(colour_map, &colour, TRUE, TRUE);
+
+    gdk_color_parse(colour_s, &colour);
+
+    /* 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(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;
+    GdkVisual *visual = gdk_visual_get_system();
+    GdkColormap *colour_map;
+    GdkColor 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);
+    colour_map = gdk_colormap_new(visual, TRUE);
+    gdk_colormap_alloc_color(colour_map, &colour, TRUE, TRUE);
+    gdk_color_parse(colour_s, &colour);
+
+    /* 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(VTE_TERMINAL(g_array_index(
+            window->terminals, MSSHTerminal*, idx)), &colour);
+    }
+
+}
 void mssh_gconf_notify_columns(GConfClient *client, guint cnxn_id,
     GConfEntry *entry, gpointer data)
 {
@@ -149,6 +232,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)
 {
@@ -212,3 +310,35 @@ void mssh_gconf_notify_modifier(GConfClient *client, guint cnxn_id,
             G_CALLBACK(mssh_window_focus), window, NULL));
     }
 }
+
+
+void mssh_gconf_backscroll_buffer_size(GConfClient *client, guint cnxn_id,
+    GConfEntry *entry, gpointer data)
+{
+    GConfValue *value;
+    gint backscroll_buffer_size;
+
+    MSSHWindow *window = MSSH_WINDOW(data);
+
+    int i;
+    int len = window->terminals->len;
+
+    value = gconf_entry_get_value(entry);
+    backscroll_buffer_size = gconf_value_get_int(value);
+
+
+    if (backscroll_buffer_size < -1)
+    {
+        backscroll_buffer_size = 5000;
+        gconf_client_set_int(client, MSSH_GCONF_KEY_BACKSCROLL_BUFFER_SIZE, backscroll_buffer_size,
+            NULL);
+    }
+
+    window->backscroll_buffer_size = backscroll_buffer_size;
+    /* reconfigure all terminals with the new size*/
+    for(i = 0; i < len; i++)
+    {
+        mssh_terminal_set_backscroll_size(g_array_index(window->terminals,
+            MSSHTerminal*, i), &backscroll_buffer_size);
+    }
+}

+ 22 - 10
src/mssh-gconf.h

@@ -3,16 +3,20 @@
 
 #include <gconf/gconf-client.h>
 
-#define MSSH_GCONF_PATH                 "/apps/mssh"
-#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_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_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"
+#define MSSH_GCONF_PATH                 		"/apps/mssh"
+#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"
+#define MSSH_GCONF_KEY_BACKSCROLL_BUFFER_SIZE 	MSSH_GCONF_PATH"/backscroll_buffer_size"
 
 void mssh_gconf_notify_font(GConfClient *client, guint cnxn_id,
     GConfEntry *entry, gpointer data);
@@ -20,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,
@@ -32,5 +40,9 @@ void mssh_gconf_notify_modifier(GConfClient *client, guint cnxn_id,
     GConfEntry *entry, gpointer data);
 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

+ 124 - 0
src/mssh-pref.c

@@ -63,6 +63,37 @@ 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;
+    GdkColor colour;
+    const gchar *colour_s;
+
+    client = gconf_client_get_default();
+
+    gtk_color_button_get_color(GTK_COLOR_BUTTON(widget), &colour);
+    colour_s = gdk_color_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;
+    GdkColor colour;
+    const gchar *colour_s;
+
+    client = gconf_client_get_default();
+
+    gtk_color_button_get_color(GTK_COLOR_BUTTON(widget), &colour);
+    colour_s = gdk_color_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;
@@ -75,6 +106,17 @@ static void mssh_pref_columns_select(GtkWidget *widget, gpointer data)
     gconf_client_set_int(client, MSSH_GCONF_KEY_COLUMNS, columns, NULL);
 }
 
+static void mssh_pref_backscroll_buffer_size_select(GtkWidget *widget, gpointer data)
+{
+    GConfClient *client;
+    gint backscroll_buffer_size;
+
+    client = gconf_client_get_default();
+
+    backscroll_buffer_size = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
+
+    gconf_client_set_int(client, MSSH_GCONF_KEY_BACKSCROLL_BUFFER_SIZE, backscroll_buffer_size, NULL);
+}
 static void mssh_pref_timeout_select(GtkWidget *widget, gpointer data)
 {
     GConfClient *client;
@@ -99,6 +141,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;
@@ -168,6 +221,15 @@ 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_table_new(2, 2, FALSE);
+    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(
@@ -187,6 +249,12 @@ static void mssh_pref_init(MSSHPref* pref)
     GtkWidget *columns_select = gtk_spin_button_new(
         GTK_ADJUSTMENT(columns_adj), 1, 0);
 
+    GtkWidget *backscroll_buffer_size_hbox = gtk_hbox_new(FALSE, 10);
+    GtkWidget *backscroll_buffer_size_label = gtk_label_new("Scrollback Lines:");
+    GtkObject *backscroll_buffer_size_adj = gtk_adjustment_new(5000, -1, 65535, 1, 100, 0);
+    GtkWidget *backscroll_buffer_size_select = gtk_spin_button_new(
+        GTK_ADJUSTMENT(backscroll_buffer_size_adj), 1, 0);  
+
     GtkWidget *mod_hbox = gtk_hbox_new(FALSE, 10);
     GtkWidget *mod_label = gtk_label_new("Modifier:");
     GtkWidget *mod_ctrl_check = gtk_check_button_new_with_label("Ctrl");
@@ -222,6 +290,18 @@ static void mssh_pref_init(MSSHPref* pref)
         1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
     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_table_attach(GTK_TABLE(colour_table_focus), bg_colour_label_focus,
+        0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
+    gtk_table_attach(GTK_TABLE(colour_table_focus), bg_colour_select_focus,
+        1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
+    gtk_table_attach(GTK_TABLE(colour_table_focus), fg_colour_label_focus,
+        0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
+    gtk_table_attach(GTK_TABLE(colour_table_focus), fg_colour_select_focus,
+        1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
+
+    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);
@@ -240,6 +320,12 @@ static void mssh_pref_init(MSSHPref* pref)
         TRUE, 0);
     gtk_box_pack_start(GTK_BOX(content), columns_hbox, FALSE, TRUE, 0);
 
+    gtk_box_pack_start(GTK_BOX(backscroll_buffer_size_hbox), backscroll_buffer_size_label, FALSE,
+        TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(backscroll_buffer_size_hbox), backscroll_buffer_size_select, FALSE,
+        TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(content), backscroll_buffer_size_hbox, FALSE, TRUE, 0);
+
     gtk_box_pack_start(GTK_BOX(mod_hbox), mod_label, FALSE, TRUE, 0);
     gtk_box_pack_start(GTK_BOX(mod_hbox), mod_ctrl_check, FALSE, TRUE, 0);
     gtk_box_pack_start(GTK_BOX(mod_hbox), mod_alt_check, FALSE, TRUE, 0);
@@ -268,12 +354,20 @@ 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",
+        G_CALLBACK(mssh_pref_backscroll_buffer_size_select), NULL);    
     g_signal_connect(G_OBJECT(timeout_select), "value-changed",
         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",
@@ -313,12 +407,36 @@ static void mssh_pref_init(MSSHPref* pref)
     gtk_color_button_set_color(GTK_COLOR_BUTTON(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_colormap_alloc_color(colour_map, &colour, TRUE, TRUE);
+    gdk_color_parse(colour_s, &colour);
+    gtk_color_button_set_color(GTK_COLOR_BUTTON(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_colormap_alloc_color(colour_map, &colour, TRUE, TRUE);
+    gdk_color_parse(colour_s, &colour);
+    gtk_color_button_set_color(GTK_COLOR_BUTTON(bg_colour_select_focus),
+        &colour);
+
     entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_COLUMNS, NULL,
         TRUE, NULL);
     value = gconf_entry_get_value(entry);
     gtk_spin_button_set_value(GTK_SPIN_BUTTON(columns_select),
         gconf_value_get_int(value));
 
+    entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_BACKSCROLL_BUFFER_SIZE, NULL,
+        TRUE, NULL);
+    value = gconf_entry_get_value(entry);
+    gtk_spin_button_set_value(GTK_SPIN_BUTTON(backscroll_buffer_size_select),
+        gconf_value_get_int(value));
+
     entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_TIMEOUT, NULL,
         TRUE, NULL);
     value = gconf_entry_get_value(entry);
@@ -331,6 +449,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);

+ 7 - 0
src/mssh-terminal.c

@@ -27,9 +27,16 @@ gboolean mssh_terminal_isactive(MSSHTerminal *terminal)
         GTK_CHECK_MENU_ITEM(terminal->menu_item));
 }
 
+void mssh_terminal_set_backscroll_size(MSSHTerminal *terminal, gint *backscroll_buffer_size)
+{
+    /* use scrollback buffer from gconf*/
+    vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), *backscroll_buffer_size);
+}
 void mssh_terminal_init_session(MSSHTerminal *terminal, char *hostname)
 {
     terminal->hostname = hostname;
+    /* use scrollback buffer from gconf*/
+    mssh_terminal_set_backscroll_size(terminal, &terminal->backscroll_buffer_size);
 
     terminal->menu_item = gtk_check_menu_item_new_with_label(
         terminal->hostname);

+ 2 - 0
src/mssh-terminal.h

@@ -23,6 +23,7 @@ typedef struct
     char *hostname;
     int started;
     int ended;
+    gint backscroll_buffer_size;
 } MSSHTerminal;
 
 typedef struct
@@ -42,6 +43,7 @@ GtkWidget* mssh_terminal_new(void);
 void mssh_terminal_destroy(MSSHTerminal *terminal);
 gboolean mssh_terminal_isactive(MSSHTerminal *terminal);
 void mssh_terminal_init_session(MSSHTerminal *terminal, char *hostname);
+void mssh_terminal_set_backscroll_size(MSSHTerminal *terminal, gint *backscroll_buffer_size);
 void mssh_terminal_start_session(MSSHTerminal *terminal, char **env);
 void mssh_terminal_send_host(MSSHTerminal *terminal);
 void mssh_terminal_send_string(MSSHTerminal *terminal, gchar *string);

+ 338 - 3
src/mssh-window.c

@@ -1,8 +1,10 @@
 #include <string.h>
 #include <stdlib.h>
+#include <stdio.h>
 
 #include <gconf/gconf-client.h>
 #include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
 
 #include "mssh-terminal.h"
 #include "mssh-pref.h"
@@ -11,6 +13,8 @@
 
 #include "config.h"
 
+#include <regex.h>  
+
 static void mssh_window_sendhost(GtkWidget *widget, gpointer data);
 static void mssh_window_destroy(GtkWidget *widget, gpointer data);
 static void mssh_window_pref(GtkWidget *widget, gpointer data);
@@ -28,6 +32,12 @@ static void mssh_window_insert(GtkWidget *widget, gchar *new_text,
 static void mssh_window_add_session(MSSHWindow *window, char *hostname);
 static void mssh_window_init(MSSHWindow* window);
 static void mssh_window_class_init(MSSHWindowClass *klass);
+static void mssh_window_add(GtkWidget *widget, gpointer data);
+gboolean mssh_window_dialog_emit_response(GtkWidget *widget, GObject *acceleratable,
+    guint keyval, GdkModifierType modifier, gpointer data);
+static void mssh_window_maximize(GtkWidget *widget, gpointer data);
+static void mssh_window_restore_layout(GtkWidget *widget, gpointer data);
+void mssh_window_relayout_for_one(MSSHWindow *window, GtkWidget *t);
 
 G_DEFINE_TYPE(MSSHWindow, mssh_window, GTK_TYPE_WINDOW)
 
@@ -55,6 +65,24 @@ static void mssh_window_sendhost(GtkWidget *widget, gpointer data)
     }
 }
 
+static void mssh_window_sendcommand(GtkWidget *widget, gpointer data)
+{
+    int i;
+    char *command;
+
+    MSSHWindow *window = MSSH_WINDOW(data);
+    GtkMenuItem *item = (GtkMenuItem *)widget;
+
+    command = g_datalist_get_data(MSSH_WINDOW(data)->commands, gtk_menu_item_get_label (item));
+
+    for(i = 0; i < window->terminals->len; i++)
+    {
+        mssh_terminal_send_string(g_array_index(window->terminals,
+            MSSHTerminal*, i), command);
+    }
+
+}
+
 static void mssh_window_destroy(GtkWidget *widget, gpointer data)
 {
     gtk_main_quit();
@@ -108,10 +136,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;
 }
 
@@ -120,6 +160,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 :
@@ -138,6 +180,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;
@@ -224,6 +277,9 @@ static gboolean mssh_window_session_close(gpointer data)
         g_array_remove_index(data_pair->window->terminals, idx);
 
         mssh_window_relayout(data_pair->window);
+
+        /* set the focus on the entry */
+        gtk_window_set_focus(GTK_WINDOW(data_pair->window), GTK_WIDGET(data_pair->window->global_entry));
     }
 
     if(data_pair->window->terminals->len == 0 &&
@@ -264,6 +320,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;
@@ -274,6 +332,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)
@@ -359,6 +436,7 @@ static void mssh_window_add_session(MSSHWindow *window, char *hostname)
 {
     MSSHTerminal *terminal = MSSH_TERMINAL(mssh_terminal_new());
 
+    terminal->backscroll_buffer_size = window->backscroll_buffer_size;
     g_array_append_val(window->terminals, terminal);
 
     g_signal_connect(G_OBJECT(terminal), "session-closed",
@@ -388,13 +466,14 @@ static void mssh_window_init(MSSHWindow* window)
     GtkWidget *file_item = gtk_menu_item_new_with_label("File");
     GtkWidget *edit_item = gtk_menu_item_new_with_label("Edit");
     GtkWidget *server_item = gtk_menu_item_new_with_label("Servers");
+    GtkWidget *command_item = gtk_menu_item_new_with_label("Commands");
 
     GtkWidget *file_quit = gtk_image_menu_item_new_from_stock(
         GTK_STOCK_QUIT, NULL);
     GtkWidget *file_sendhost = gtk_image_menu_item_new_with_label(
         "Send hostname");
-/*  GtkWidget *file_add = gtk_image_menu_item_new_with_label(
-        "Add session");*/
+    GtkWidget *file_add = gtk_menu_item_new_with_label(
+        "Add session");
 
     GtkWidget *edit_pref = gtk_image_menu_item_new_from_stock(
         GTK_STOCK_PREFERENCES, NULL);
@@ -405,23 +484,35 @@ static void mssh_window_init(MSSHWindow* window)
 
     window->server_menu = gtk_menu_new();
 
+    window->command_menu = gtk_menu_new();
+
     window->global_entry = entry;
 
     window->last_closed = -1;
 
     window->terminals = g_array_new(FALSE, TRUE, sizeof(MSSHTerminal*));
 
+    window->backscroll_buffer_size = 5000;
+
+    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),
         window->server_menu);
+    gtk_menu_item_set_submenu(GTK_MENU_ITEM(command_item),
+        window->command_menu);
 
-/*  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_add);*/
+    gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_add);
     gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_sendhost);
     gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_quit);
     gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_pref);
     g_signal_connect(G_OBJECT(file_sendhost), "activate",
         G_CALLBACK(mssh_window_sendhost), window);
+    g_signal_connect(G_OBJECT(file_add), "activate",
+        G_CALLBACK(mssh_window_add), window);
     g_signal_connect(G_OBJECT(file_quit), "activate",
         G_CALLBACK(mssh_window_destroy), window);
     g_signal_connect(G_OBJECT(edit_pref), "activate",
@@ -430,6 +521,7 @@ static void mssh_window_init(MSSHWindow* window)
     gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file_item);
     gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), edit_item);
     gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), server_item);
+    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), command_item);
 
     g_signal_connect(G_OBJECT(entry), "key-press-event",
         G_CALLBACK(mssh_window_key_press), window);
@@ -461,25 +553,35 @@ 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,
         mssh_gconf_notify_dir_focus, window, NULL, NULL);
     gconf_client_notify_add(client, MSSH_GCONF_KEY_MODIFIER,
         mssh_gconf_notify_modifier, window, NULL, NULL);
+    gconf_client_notify_add(client, MSSH_GCONF_KEY_BACKSCROLL_BUFFER_SIZE,
+        mssh_gconf_backscroll_buffer_size, window, NULL, NULL);
 
     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);
+    gconf_client_notify(client, MSSH_GCONF_KEY_BACKSCROLL_BUFFER_SIZE);
 
     gtk_accel_group_connect(accel, GDK_KEY_Up, window->modifier,
         GTK_ACCEL_VISIBLE, g_cclosure_new(
@@ -494,6 +596,16 @@ static void mssh_window_init(MSSHWindow* window)
         GTK_ACCEL_VISIBLE, g_cclosure_new(
         G_CALLBACK(mssh_window_focus), window, NULL));
 
+    /* bind Ctrl + Shift + x to toggling maximize terminal */
+    gtk_accel_group_connect(accel, GDK_KEY_x, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
+        GTK_ACCEL_VISIBLE, g_cclosure_new(
+        G_CALLBACK(mssh_window_toggle_maximize), window, NULL));
+
+    /* bind Ctrl + Shift + N to show the dialog for adding new sessions */
+    gtk_accel_group_connect(accel, GDK_KEY_n, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
+        GTK_ACCEL_VISIBLE, g_cclosure_new(
+        G_CALLBACK(mssh_window_add), window, NULL));
+
     window->accel = accel;
 
     gtk_window_add_accel_group(GTK_WINDOW(window), accel);
@@ -525,6 +637,229 @@ void mssh_window_start_session(MSSHWindow* window, char **env,
     mssh_window_relayout(window);
 }
 
+void mssh_window_add_command(GQuark key_id, gpointer data, gpointer user_data)
+{
+    GtkWidget *menu_item;
+    GtkWidget* window = (GtkWidget *)user_data;
+
+    menu_item = gtk_menu_item_new_with_label(g_quark_to_string (key_id));
+
+    gtk_menu_shell_append(GTK_MENU_SHELL(MSSH_WINDOW(window)->command_menu), menu_item);
+    g_signal_connect(G_OBJECT(menu_item), "activate",
+        G_CALLBACK(mssh_window_sendcommand), window);
+}
+
 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;
+    int cols = (len < wcols) ? len : wcols;
+    int rows = (len + 1) / cols;
+
+    /* get the terminal widget */
+    GtkWidget *terminal = GTK_WIDGET(t);
+
+    g_object_ref(terminal);
+
+    /* remove the widget from the container temporarily */
+    gtk_container_remove(GTK_CONTAINER(window->table), GTK_WIDGET(terminal));
+
+    /* add it back again, now resized */
+    gtk_table_attach(GTK_TABLE(window->table), GTK_WIDGET(terminal), 0, cols, 0, rows,
+            GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 1, 1);
+
+    /* 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);
+
+}
+
+gboolean mssh_window_toggle_maximize(GtkWidget *widget, GObject *acceleratable,
+    guint keyval, GdkModifierType modifier, gpointer data)
+{
+
+    MSSHWindow *window = MSSH_WINDOW(data);
+
+    if (window->is_maximized) {
+        /* toggle restore */
+        mssh_window_restore_layout(widget, data);
+    } else {
+        /* toggle maximize */
+        mssh_window_maximize(widget, data);
+    }
+    return TRUE;
+}
+
+static void mssh_window_maximize(GtkWidget *widget, gpointer data)
+{
+
+    /* find the id of the currently focused window (if any) */
+    MSSHWindow *window = MSSH_WINDOW(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));
+    /* save the currently focused window so we can restore it later */
+    window->last_focus = focus;
+
+    /* find the focused window in the terminal list */
+    for(i = 0; i < len; i++)
+    {
+        if(focus == GTK_WIDGET(g_array_index(window->terminals,
+            MSSHTerminal*, i)))
+        {
+            idx = i;
+            break;
+        }
+    }
+
+    /* 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 {
+        /* call relayout, it will reposition the widget to occupy the whole table */
+        mssh_window_relayout_for_one(window, GTK_WIDGET(g_array_index(window->terminals,
+                    MSSHTerminal*, idx)));
+        window->is_maximized = 1;
+    }
+}
+
+static void mssh_window_restore_layout(GtkWidget *widget, gpointer data)
+{
+
+    GConfClient *client;
+    GConfEntry *entry;
+    /* get the window */
+    MSSHWindow *window = MSSH_WINDOW(data);
+
+    /* just call relayout */
+    mssh_window_relayout(window);
+    window->is_maximized = 0;
+
+    /* restore the focus */
+    if (window->last_focus != NULL) {
+        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);
+	}
+}
+
+/* show a popup window for adding new sessions  */
+static void mssh_window_add(GtkWidget *widget, gpointer data)
+{
+
+    MSSHWindow *window = MSSH_WINDOW(data);
+    GtkWidget *dialog, *label, *content_area, *button_add;
+	GtkWidget *new_session_entry;
+	gint result;
+    
+    /* create new dialog */
+    dialog = gtk_dialog_new();
+    /* get the content area that will be packed */
+    content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+    /* label for text */
+    label = gtk_label_new ("Add new session with hostname: ");
+
+    /* Add the label and entry, and show everything we've added to the dialog */
+    new_session_entry = gtk_entry_new();
+    gtk_entry_set_max_length (GTK_ENTRY(new_session_entry), 255);
+
+    /* pack the widgets */
+    gtk_container_add (GTK_CONTAINER (content_area), label);
+    gtk_container_add (GTK_CONTAINER (content_area), new_session_entry);
+    /* add two buttons */
+    button_add = gtk_dialog_add_button(GTK_DIALOG(dialog), "Add", GTK_RESPONSE_ACCEPT);
+    gtk_dialog_add_button(GTK_DIALOG(dialog), "Cancel", GTK_RESPONSE_CANCEL);
+    /* make the add button the default */
+    gtk_widget_grab_default(button_add);
+    /* set dialog properties (modal, etc) */
+    gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(window));
+    /* set it's title */
+    gtk_window_set_title(GTK_WINDOW(dialog), "Add new session");
+
+    /* catch the activate signal (hitting enter) */
+    g_signal_connect(G_OBJECT(new_session_entry), "activate",
+        G_CALLBACK(mssh_window_dialog_emit_response), window);
+
+    /* show the dialog and it's widgets */
+    gtk_widget_show_all (dialog);
+
+    /* wait for input */
+    result = gtk_dialog_run (GTK_DIALOG (dialog));
+    switch (result)
+      {
+        case GTK_RESPONSE_ACCEPT:
+           mssh_window_add_session(window, (gchar*) gtk_entry_get_text(GTK_ENTRY(new_session_entry)));
+           /* relayout */
+           mssh_window_relayout(window);
+           break;
+        default:
+           /* do nothing */
+           break;
+      }
+    gtk_widget_destroy (dialog);
+}
+
+/* catch the 'activate' signal of the entry (return has been pushed)  */
+/* emit the response for accept, simulating a mouse click on the add button  */
+gboolean mssh_window_dialog_emit_response(GtkWidget *widget, GObject *acceleratable,
+    guint keyval, GdkModifierType modifier, gpointer data)
+{
+
+    /* get the dialog by getting the parent of the parent for the emitting (entry) widget */
+    GtkWidget *vbox = gtk_widget_get_parent(widget);
+    GtkWidget *dialog = gtk_widget_get_parent(vbox);
+    /* emit the response signal simulating the clicking of 'ok'  */
+    gtk_dialog_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
+
+    return TRUE;
+}

+ 9 - 0
src/mssh-window.h

@@ -23,6 +23,7 @@ typedef struct
     GtkWindow widget;
     GtkWidget *table;
     GtkWidget *server_menu;
+    GtkWidget *command_menu;
     GtkWidget *global_entry;
     GtkAccelGroup *accel;
     GArray *terminals;
@@ -35,6 +36,11 @@ typedef struct
     gint modifier;
     gint dir_focus;
     gint last_closed;
+    GData **commands;
+    gint backscroll_buffer_size;
+    GtkWidget *last_focus;
+    int is_maximized;
+    gboolean recolor_focused;
 } MSSHWindow;
 
 typedef struct
@@ -47,10 +53,13 @@ GType mssh_window_get_type(void) G_GNUC_CONST;
 GtkWidget* mssh_window_new(void);
 void mssh_window_start_session(MSSHWindow* window, char **env,
     GArray *hosts, long cols);
+void mssh_window_add_command(GQuark key_id, gpointer data, gpointer user_data);
 void mssh_window_relayout(MSSHWindow *window);
 void mssh_window_session_closed(MSSHTerminal *terminal, gpointer data);
 gboolean mssh_window_focus(GtkWidget *widget, GObject *acceleratable,
     guint keyval, GdkModifierType modifier, gpointer data);
+gboolean mssh_window_toggle_maximize(GtkWidget *widget, GObject *acceleratable,
+    guint keyval, GdkModifierType modifier, gpointer data);
 
 G_END_DECLS
 

+ 68 - 1
src/mssh.c

@@ -121,7 +121,10 @@ GData **parse_aliases(char *conffile)
         if(strcmp(line, "") == 0)
             continue;
 
-        if( *line == '#')
+        if(*line == '#')
+            continue;
+
+        if(*line == '{')
             continue;
 
         if((sep = strchr(line, ':')) == NULL)
@@ -162,6 +165,65 @@ GData **parse_aliases(char *conffile)
     return aliases;
 }
 
+GData **parse_commands(char *conffile)
+{
+    FILE *file;
+    char *line;
+    int lineno = 0;
+
+    GData **commands = malloc(sizeof(GData*));
+    g_datalist_init(commands);
+
+    if((file = fopen(conffile, "r")) == NULL)
+        return commands;
+
+    while((line = fgetline(file)) != NULL)
+    {
+        char *sep, *command, *commandline;
+
+        lineno++;
+
+        if(strcmp(line, "") == 0)
+            continue;
+
+        if(*line == '#')
+            continue;
+
+        if(*line != '{')
+            continue;
+
+        if((sep = strchr(line, '}')) == NULL)
+        {
+            printf("Line %d: Failed to parse line '%s'\n", lineno, line);
+            exit(EXIT_FAILURE);
+        }
+
+        *sep = '\0';
+        command = line + 1;
+
+        if((commandline = index(sep + 1, ' ')) == NULL)
+        {
+            printf("Line %d: Command Alias '%s' specifies no command\n", lineno,
+                command);
+            exit(EXIT_FAILURE);
+        }
+        while ( *commandline == ' ' ) { commandline++; }
+
+        sep = commandline;
+        while ( ( sep = index(sep, '\\') ) != NULL ) {
+            if ( *(sep+1) == 'n' ) {
+                *sep = ' ';
+                *(sep+1) = '\n';
+            }
+            sep++;
+        }
+
+        g_datalist_set_data(commands, command, commandline);
+    }
+
+    return commands;
+}
+
 int main(int argc, char* argv[], char* env[])
 {
     GtkWidget* window;
@@ -169,6 +231,7 @@ int main(int argc, char* argv[], char* env[])
     char *home, *conffile;
     long cols = 0;
     GData **aliases = NULL;
+    GData **commands = NULL;
     GArray *hosts = NULL;
 
     static struct option long_options[] =
@@ -188,6 +251,7 @@ int main(int argc, char* argv[], char* env[])
         snprintf(conffile, len, "%s/%s", home, CONFFILE);
 
         aliases = parse_aliases(conffile);
+        commands = parse_commands(conffile);
         free(conffile);
     }
     else
@@ -289,7 +353,10 @@ int main(int argc, char* argv[], char* env[])
     g_signal_connect(G_OBJECT(window), "destroy",
         G_CALLBACK(on_mssh_destroy), NULL);
 
+    MSSH_WINDOW(window)->commands = commands;
+
     mssh_window_start_session(MSSH_WINDOW(window), env, hosts, cols);
+    g_datalist_foreach(commands, mssh_window_add_command, window);
 
     gtk_widget_show_all(window);
     gtk_main();