1
0
Преглед на файлове

Hook up colour preferences.

Signed-off-by: Bradley Smith <[email protected]>
Bradley Smith преди 15 години
родител
ревизия
4076c54eb6
променени са 6 файла, в които са добавени 158 реда и са изтрити 9 реда
  1. 6 6
      bootstrap.sh
  2. 22 0
      mssh.gconf.xml
  3. 53 0
      src/mssh-gconf.c
  4. 8 2
      src/mssh-gconf.h
  5. 57 1
      src/mssh-pref.c
  6. 12 0
      src/mssh-window.c

+ 6 - 6
bootstrap.sh

@@ -104,18 +104,18 @@ aclocal || {
   echo "aclocal failed - check that all needed development files are present on system"
   exit 1
 }
-echo "+ running autoheader ... "
-autoheader || {
-  echo
-  echo "autoheader failed"
-  exit 1
-}
 echo "+ running autoconf ... "
 autoconf || {
   echo
   echo "autoconf failed"
   exit 1
 }
+echo "+ running autoheader ... "
+autoheader || {
+  echo
+  echo "autoheader failed"
+  exit 1
+}
 echo "+ running automake ... "
 automake -a -c || {
   echo

+ 22 - 0
mssh.gconf.xml

@@ -11,5 +11,27 @@
                 <long>Font to use for all MSSH terminals</long>
             </locale>
         </schema>
+        <schema>
+            <key>/schemas/apps/mssh/fg_colour</key>
+            <applyto>/apps/mssh/fg_colour</applyto>
+            <owner>mssh</owner>
+            <type>string</type>
+            <default>#ffffffffffff</default>
+            <locale name="C">
+                <short>Terminal foreground colour</short>
+                <long>Foreground colour to use for all MSSH terminals</long>
+            </locale>
+        </schema>
+        <schema>
+            <key>/schemas/apps/mssh/bg_colour</key>
+            <applyto>/apps/mssh/bg_colour</applyto>
+            <owner>mssh</owner>
+            <type>string</type>
+            <default>#000000000000</default>
+            <locale name="C">
+                <short>Terminal background colour</short>
+                <long>Background colour to use for all MSSH terminals</long>
+            </locale>
+        </schema>
     </schemalist>
 </gconfschemafile>

+ 53 - 0
src/mssh-gconf.c

@@ -10,6 +10,7 @@ void mssh_gconf_notify_font(GConfClient *client, guint cnxn_id,
 	GConfValue *value;
 	const gchar *font;
 	int i;
+
 	MSSHWindow *window = MSSH_WINDOW(data);
 
 	value = gconf_entry_get_value(entry);
@@ -21,3 +22,55 @@ void mssh_gconf_notify_font(GConfClient *client, guint cnxn_id,
 			window->terminals, MSSHTerminal*, i)), font);
 	}
 }
+
+void mssh_gconf_notify_fg_colour(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;
+
+	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);
+
+	for(i = 0; i < window->terminals->len; i++)
+	{
+		vte_terminal_set_color_foreground(VTE_TERMINAL(g_array_index(
+			window->terminals, MSSHTerminal*, i)), &colour);
+	}
+}
+
+void mssh_gconf_notify_bg_colour(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;
+
+	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);
+
+	for(i = 0; i < window->terminals->len; i++)
+	{
+		vte_terminal_set_color_background(VTE_TERMINAL(g_array_index(
+			window->terminals, MSSHTerminal*, i)), &colour);
+	}
+}

+ 8 - 2
src/mssh-gconf.h

@@ -3,10 +3,16 @@
 
 #include <gconf/gconf-client.h>
 
-#define MSSH_GCONF_PATH			"/apps/mssh"
-#define MSSH_GCONF_KEY_FONT		MSSH_GCONF_PATH"/font"
+#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"
 
 void mssh_gconf_notify_font(GConfClient *client, guint cnxn_id,
 	GConfEntry *entry, gpointer data);
+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);
 
 #endif

+ 57 - 1
src/mssh-pref.c

@@ -33,11 +33,45 @@ static void mssh_pref_font_select(GtkWidget *widget, gpointer data)
 	gconf_client_set_string(client, MSSH_GCONF_KEY_FONT, font, NULL);
 }
 
+static void mssh_pref_fg_colour_select(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, colour_s,
+		NULL);
+}
+
+static void mssh_pref_bg_colour_select(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, colour_s,
+		NULL);
+}
+
 static void mssh_pref_init(MSSHPref* pref)
 {
 	GConfClient *client;
 	GConfEntry *entry;
 	GConfValue *value;
+	GdkVisual *visual = gdk_visual_get_system();
+	GdkColormap *colour_map = gdk_colormap_new(visual, TRUE);
+	GdkColor colour;
+	const gchar *colour_s;
 
 	GtkWidget *frame = gtk_vbox_new(FALSE, 5);
 	GtkWidget *notebook = gtk_notebook_new();
@@ -50,7 +84,7 @@ static void mssh_pref_init(MSSHPref* pref)
 	GtkWidget *colour_table = gtk_table_new(2, 2, FALSE);
 	GtkWidget *bg_colour_label = gtk_label_new("Background:");
 	GtkWidget *bg_colour_select = gtk_color_button_new();
-	GtkWidget *fg_colour_label = gtk_label_new("Forground:");
+	GtkWidget *fg_colour_label = gtk_label_new("Foreground:");
 	GtkWidget *fg_colour_select = gtk_color_button_new();
 
 	GtkWidget *exit_check = gtk_check_button_new_with_label(
@@ -126,6 +160,10 @@ static void mssh_pref_init(MSSHPref* pref)
 
 	g_signal_connect(G_OBJECT(font_select), "font-set",
 		G_CALLBACK(mssh_pref_font_select), NULL);
+	g_signal_connect(G_OBJECT(fg_colour_select), "color-set",
+		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);
 
 	client = gconf_client_get_default();
 
@@ -134,6 +172,24 @@ static void mssh_pref_init(MSSHPref* pref)
 	value = gconf_entry_get_value(entry);
 	gtk_font_button_set_font_name(GTK_FONT_BUTTON(font_select),
 		gconf_value_get_string(value));
+
+	entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_FG_COLOUR, 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),
+		&colour);
+
+	entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_BG_COLOUR, 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),
+		&colour);
 }
 
 static void mssh_pref_class_init(MSSHPrefClass *klass)

+ 12 - 0
src/mssh-window.c

@@ -249,9 +249,17 @@ static void mssh_window_relayout(MSSHWindow *window)
 
 	client = gconf_client_get_default();
 
+	gtk_widget_show_all(GTK_WIDGET(window));
+
 	entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_FONT, NULL,
 		TRUE, NULL);
 	mssh_gconf_notify_font(client, 0, entry, window);
+	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);
 }
 
 static void mssh_window_add_session(MSSHWindow *window, char *hostname)
@@ -349,6 +357,10 @@ static void mssh_window_init(MSSHWindow* window)
 
 	gconf_client_notify_add(client, MSSH_GCONF_KEY_FONT,
 		mssh_gconf_notify_font, window, NULL, NULL);
+	gconf_client_notify_add(client, MSSH_GCONF_KEY_FG_COLOUR,
+		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);
 }
 
 void mssh_window_start_session(MSSHWindow* window, char **env, int nhosts,