Przeglądaj źródła

Add beginnings of columns preference.

Signed-off-by: Bradley Smith <[email protected]>
Bradley Smith 15 lat temu
rodzic
commit
fa46c5541b
6 zmienionych plików z 49 dodań i 6 usunięć
  1. 11 0
      mssh.gconf.xml
  2. 22 0
      src/mssh-gconf.c
  3. 3 0
      src/mssh-gconf.h
  4. 1 1
      src/mssh-pref.c
  5. 10 5
      src/mssh-window.c
  6. 2 0
      src/mssh-window.h

+ 11 - 0
mssh.gconf.xml

@@ -33,5 +33,16 @@
                 <long>Background colour to use for all MSSH terminals</long>
             </locale>
         </schema>
+        <schema>
+            <key>/schemas/apps/mssh/coloums</key>
+            <applyto>/apps/mssh/columns</applyto>
+            <owner>mssh</owner>
+            <type>int</type>
+            <default>2</default>
+            <locale name="C">
+                <short>Terminal columns</short>
+                <long>Number of columns of tiled terminals</long>
+            </locale>
+        </schema>
     </schemalist>
 </gconfschemafile>

+ 22 - 0
src/mssh-gconf.c

@@ -74,3 +74,25 @@ void mssh_gconf_notify_bg_colour(GConfClient *client, guint cnxn_id,
 			window->terminals, MSSHTerminal*, i)), &colour);
 	}
 }
+
+void mssh_gconf_notify_columns(GConfClient *client, guint cnxn_id,
+	GConfEntry *entry, gpointer data)
+{
+	GConfValue *value;
+	int columns;
+
+	MSSHWindow *window = MSSH_WINDOW(data);
+
+	value = gconf_entry_get_value(entry);
+	columns = gconf_value_get_int(value);
+
+	if(columns <= 0)
+	{
+		columns = 1;
+		gconf_client_set_int(client, MSSH_GCONF_KEY_COLUMNS, columns,
+			NULL);
+	}
+
+	window->columns = columns;
+	mssh_window_relayout(window);
+}

+ 3 - 0
src/mssh-gconf.h

@@ -7,6 +7,7 @@
 #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"
 
 void mssh_gconf_notify_font(GConfClient *client, guint cnxn_id,
 	GConfEntry *entry, gpointer data);
@@ -14,5 +15,7 @@ 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_columns(GConfClient *client, guint cnxn_id,
+	GConfEntry *entry, gpointer data);
 
 #endif

+ 1 - 1
src/mssh-pref.c

@@ -88,7 +88,7 @@ static void mssh_pref_init(MSSHPref* pref)
 	GtkWidget *fg_colour_select = gtk_color_button_new();
 
 	GtkWidget *exit_check = gtk_check_button_new_with_label(
-		"Enable Ctrl+W quit shortcut");
+		"Quit after all sessions have ended");
 	GtkWidget *close_check = gtk_check_button_new_with_label(
 		"Close ended sessions");
 

+ 10 - 5
src/mssh-window.c

@@ -25,7 +25,6 @@ static void mssh_window_session_focused(MSSHTerminal *terminal,
 	gpointer data);
 static void mssh_window_insert(GtkWidget *widget, gchar *new_text,
 	gint new_text_length, gint *position, gpointer data);
-static void mssh_window_relayout(MSSHWindow *window);
 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);
@@ -212,11 +211,11 @@ static void mssh_window_session_focused(MSSHTerminal *terminal,
 	free(title);
 }
 
-static void mssh_window_relayout(MSSHWindow *window)
+void mssh_window_relayout(MSSHWindow *window)
 {
 	GConfClient *client;
 	GConfEntry *entry;
-	int i, len = window->terminals->len;
+	int i, len = window->terminals->len, cols = window->columns;
 
 	for(i = 0; i < len; i++)
 	{
@@ -231,7 +230,8 @@ static void mssh_window_relayout(MSSHWindow *window)
 		}
 
 		gtk_table_attach(GTK_TABLE(window->table), GTK_WIDGET(terminal),
-			(i % 2), (i == len - 1) ? 2 : (i % 2) + 1, i / 2, (i / 2) + 1,
+			(i % cols), (i == len - 1) ? cols : (i % cols) + 1, i / cols,
+			(i / cols) + 1,
 			GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 1, 1);
 		g_object_unref(terminal);
 
@@ -244,7 +244,8 @@ static void mssh_window_relayout(MSSHWindow *window)
 
 	if(len > 0)
 	{
-		gtk_table_resize(GTK_TABLE(window->table), ((len + 1) / 2), 2);
+		gtk_table_resize(GTK_TABLE(window->table), ((len + 1) / cols),
+			cols);
 	}
 
 	client = gconf_client_get_default();
@@ -361,6 +362,10 @@ 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_COLUMNS,
+		mssh_gconf_notify_columns, window, NULL, NULL);
+
+	gconf_client_notify(client, MSSH_GCONF_KEY_COLUMNS);
 }
 
 void mssh_window_start_session(MSSHWindow* window, char **env, int nhosts,

+ 2 - 0
src/mssh-window.h

@@ -23,6 +23,7 @@ typedef struct
 	GtkWidget *server_menu;
 	GArray *terminals;
 	char **env;
+	int columns;
 } MSSHWindow;
 
 typedef struct
@@ -35,6 +36,7 @@ GType mssh_window_get_type(void) G_GNUC_CONST;
 GtkWidget* mssh_window_new(void);
 void mssh_window_start_session(MSSHWindow* window, char **env, int nhosts,
 	char **servers);
+void mssh_window_relayout(MSSHWindow *window);
 
 G_END_DECLS