[anjuta] sourceview: bgo#567029 - underline warnings/errors using user-selected message colors



commit 060a272b7bb00148ae13ae0276434499b7932e06
Author: Johannes Schmid <jhs gnome org>
Date:   Sun Mar 14 23:12:44 2010 +0100

    sourceview: bgo#567029 - underline warnings/errors using user-selected message colors

 plugins/sourceview/sourceview-prefs.c |   25 ++++++++++++++++++++++++-
 plugins/sourceview/sourceview.c       |   14 +++++++++++---
 2 files changed, 35 insertions(+), 4 deletions(-)
---
diff --git a/plugins/sourceview/sourceview-prefs.c b/plugins/sourceview/sourceview-prefs.c
index bd0c574..9ff10c4 100644
--- a/plugins/sourceview/sourceview-prefs.c
+++ b/plugins/sourceview/sourceview-prefs.c
@@ -46,6 +46,8 @@
 #define VIEW_LINE_WRAP             "view.line.wrap"
 #define RIGHTMARGIN_POSITION       "sourceview.rightmargin.position"
 
+#define COLOR_ERROR								 "messages.color.error"
+#define COLOR_WARNING							 "messages.color.warning"
 
 
 #define FONT_THEME "sourceview.font.use_theme"
@@ -312,6 +314,25 @@ on_notify_font_theme (AnjutaPreferences* prefs,
 	}
 }
 
+/* Preferences notifications */
+static void
+on_notify_indic_colors (AnjutaPreferences* prefs,
+                        const gchar *key,
+                        const gchar *color,
+                        gpointer user_data)
+{
+	char* error_color =
+		anjuta_preferences_get (anjuta_preferences_default(),
+		                        "messages.color.error");
+	char* warning_color =
+		anjuta_preferences_get (anjuta_preferences_default(),
+		                        "messages.color.warning");
+	Sourceview* sv = ANJUTA_SOURCEVIEW (user_data);
+
+	g_object_set (sv->priv->warning_indic, "foreground", warning_color, NULL);
+	g_object_set (sv->priv->critical_indic, "foreground", error_color, NULL);	
+}
+
 static void
 init_fonts(Sourceview* sv)
 {
@@ -410,7 +431,9 @@ sourceview_prefs_init(Sourceview* sv)
 	REGISTER_NOTIFY (VIEW_RIGHTMARGIN, on_notify_view_right_margin, bool);
 	REGISTER_NOTIFY (RIGHTMARGIN_POSITION, on_notify_right_margin_position, int);
 	REGISTER_NOTIFY (FONT_THEME, on_notify_font_theme, bool);
-	REGISTER_NOTIFY (FONT, on_notify_font, string);	
+	REGISTER_NOTIFY (FONT, on_notify_font, string);
+	REGISTER_NOTIFY (COLOR_ERROR, on_notify_indic_colors, string);
+	REGISTER_NOTIFY (COLOR_WARNING, on_notify_indic_colors, string);
 }
 
 void sourceview_prefs_destroy(Sourceview* sv)
diff --git a/plugins/sourceview/sourceview.c b/plugins/sourceview/sourceview.c
index d94fd75..2fd2003 100644
--- a/plugins/sourceview/sourceview.c
+++ b/plugins/sourceview/sourceview.c
@@ -186,7 +186,13 @@ static void sourceview_create_markers(Sourceview* sv)
 
 /* Create tags for highlighting */
 static void sourceview_create_highligth_indic(Sourceview* sv)
-{	
+{
+	char* error_color =
+		anjuta_preferences_get (anjuta_preferences_default(),
+		                        "messages.color.error");
+	char* warning_color =
+		anjuta_preferences_get (anjuta_preferences_default (),
+		                        "messages.color.warning");
 	sv->priv->important_indic = 
 		gtk_text_buffer_create_tag (GTK_TEXT_BUFFER(sv->priv->document),
 									IMPORTANT_INDIC,
@@ -194,14 +200,16 @@ static void sourceview_create_highligth_indic(Sourceview* sv)
 	sv->priv->warning_indic = 
 		gtk_text_buffer_create_tag (GTK_TEXT_BUFFER(sv->priv->document),
 									WARNING_INDIC,
-									"foreground", "#00FF00", 
+									"foreground", warning_color, 
 									"underline", PANGO_UNDERLINE_SINGLE,
 									NULL); 
 	sv->priv->critical_indic = 
 		gtk_text_buffer_create_tag (GTK_TEXT_BUFFER(sv->priv->document),
 									CRITICAL_INDIC,
-									"foreground", "#FF0000", "underline", 
+									"foreground", error_color, "underline", 
 									PANGO_UNDERLINE_ERROR, NULL);
+	g_free (error_color);
+	g_free (warning_color);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]