Quellcode durchsuchen

Added patch to define back scroll lines for terminals

Héctor García vor 10 Jahren
Ursprung
Commit
487e0a449a
10 geänderte Dateien mit 121 neuen und 21 gelöschten Zeilen
  1. 4 0
      AUTHORS
  2. 15 11
      ChangeLog
  3. 11 0
      mssh.schemas
  4. 32 0
      src/mssh-gconf.c
  5. 13 10
      src/mssh-gconf.h
  6. 30 0
      src/mssh-pref.c
  7. 7 0
      src/mssh-terminal.c
  8. 2 0
      src/mssh-terminal.h
  9. 6 0
      src/mssh-window.c
  10. 1 0
      src/mssh-window.h

+ 4 - 0
AUTHORS

@@ -5,3 +5,7 @@ Current Developer:
 Founder and Lead Developer:
 ----------------------------------------------------------------------------
     Bradley Smith  <[email protected]> (United Kingdom)
+
+Contributors
+----------------------------------------------------------------------------
+    Balint Deak  <[email protected]>

+ 15 - 11
ChangeLog

@@ -1,27 +1,31 @@
+2014-03-14  Héctor García  <[email protected]>
+
+	Added support to defined backscroll lines for terminals. Patch from Balint Deak.
+
 2014-01-15  Héctor García  <[email protected]>
 
-    Bumped version to 2.0 gtk3 support
+	Bumped version to 2.0 gtk3 support
 
-    Changed from gdk_color_ to gdk_rgba_ functions
-    Changed from gtk_color_button to gtk_color_chooser
+	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
+	Change from gtk_vbox and gtk_hbox to gtk_box
 
-    Change colour_table from GTK_TABLE to GTK_GRID
+	Change colour_table from GTK_TABLE to GTK_GRID
 
-    Change table where to place terminals to grid
+	Change table where to place terminals to grid
 
 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]>
 

+ 11 - 0
mssh.schemas

@@ -99,5 +99,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>

+ 32 - 0
src/mssh-gconf.c

@@ -202,3 +202,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);
+    }
+}

+ 13 - 10
src/mssh-gconf.h

@@ -3,16 +3,17 @@
 
 #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_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_KEY_BACKSCROLL_BUFFER_SIZE 	MSSH_GCONF_PATH"/backscroll_buffer_size"
 
 void mssh_gconf_notify_font(GConfClient *client, guint cnxn_id,
     GConfEntry *entry, gpointer data);
@@ -32,5 +33,7 @@ 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);
 
 #endif

+ 30 - 0
src/mssh-pref.c

@@ -75,6 +75,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;
@@ -185,6 +196,11 @@ 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_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
+    GtkWidget *backscroll_buffer_size_label = gtk_label_new("Scrollback Lines:");
+    GtkAdjustment *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_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
     GtkWidget *mod_label = gtk_label_new("Modifier:");
     GtkWidget *mod_ctrl_check = gtk_check_button_new_with_label("Ctrl");
@@ -238,6 +254,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,6 +290,8 @@ static void mssh_pref_init(MSSHPref* pref)
         G_CALLBACK(mssh_pref_bg_colour_select), 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",
@@ -315,6 +339,12 @@ static void mssh_pref_init(MSSHPref* pref)
     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);

+ 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);

+ 6 - 0
src/mssh-window.c

@@ -356,6 +356,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",
@@ -406,6 +407,8 @@ static void mssh_window_init(MSSHWindow* window)
 
     window->terminals = g_array_new(FALSE, TRUE, sizeof(MSSHTerminal*));
 
+    window->backscroll_buffer_size = 5000;
+
     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,6 +472,8 @@ static void mssh_window_init(MSSHWindow* window)
         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);
@@ -476,6 +481,7 @@ static void mssh_window_init(MSSHWindow* window)
     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(

+ 1 - 0
src/mssh-window.h

@@ -35,6 +35,7 @@ typedef struct
     gint modifier;
     gint dir_focus;
     gint last_closed;
+    gint backscroll_buffer_size;
 } MSSHWindow;
 
 typedef struct