[network-manager-applet/NMA_0_8] editor: fix widget color functions for GTK+ 3.0 and later



commit dc48225c59a7dcb7d309dc7a13ece2e408bfaae3
Author: Dan Williams <dcbw redhat com>
Date:   Mon May 2 19:27:01 2011 -0500

    editor: fix widget color functions for GTK+ 3.0 and  later
    
    Turns out the gtk_widget_modify_* functions got deprecated in
    Gtk+ 3.0 and later, so use the replacement functions instead.

 src/connection-editor/ip4-routes-dialog.c |   21 ++++++++++++++-------
 src/connection-editor/ip6-routes-dialog.c |   21 ++++++++++++++-------
 src/connection-editor/page-ip4.c          |   21 ++++++++++++++-------
 src/connection-editor/page-ip6.c          |   21 ++++++++++++++-------
 4 files changed, 56 insertions(+), 28 deletions(-)
---
diff --git a/src/connection-editor/ip4-routes-dialog.c b/src/connection-editor/ip4-routes-dialog.c
index 7583a71..7b36897 100644
--- a/src/connection-editor/ip4-routes-dialog.c
+++ b/src/connection-editor/ip4-routes-dialog.c
@@ -413,8 +413,13 @@ cell_changed_cb (GtkEditable *editable,
 {
 	char *cell_text;
 	guint column;
+#if GTK_CHECK_VERSION(3,0,0)
+	GdkRGBA rgba;
+#else
 	GdkColor color;
+#endif
 	gboolean value_valid = FALSE;
+	const char *colorname = NULL;
 
 	cell_text = gtk_editable_get_chars (editable, 0, -1);
 
@@ -456,13 +461,15 @@ cell_changed_cb (GtkEditable *editable,
 	}
 
 	/* Change cell's background color while editing */
-	if (value_valid)
-		gdk_color_parse ("lightgreen", &color);
-	else
-		gdk_color_parse ("red", &color);
-
-	gtk_widget_modify_base (GTK_WIDGET (editable), GTK_STATE_NORMAL, &color); /* works for GTK2 */
-	gtk_widget_modify_bg (GTK_WIDGET (editable), GTK_STATE_NORMAL, &color);   /* works for GTK3 */
+	colorname = value_valid ? "lightgreen" : "red";
+
+#if GTK_CHECK_VERSION(3,0,0)
+	gdk_rgba_parse (&rgba, colorname);
+	gtk_widget_override_background_color (GTK_WIDGET (editable), GTK_STATE_NORMAL, &rgba);
+#else
+	gdk_color_parse (colorname, &color);
+	gtk_widget_modify_base (GTK_WIDGET (editable), GTK_STATE_NORMAL, &color);
+#endif
 
 	g_free (cell_text);
 	return FALSE;
diff --git a/src/connection-editor/ip6-routes-dialog.c b/src/connection-editor/ip6-routes-dialog.c
index 53da84c..2de59c3 100644
--- a/src/connection-editor/ip6-routes-dialog.c
+++ b/src/connection-editor/ip6-routes-dialog.c
@@ -370,8 +370,13 @@ cell_changed_cb (GtkEditable *editable,
 {
 	char *cell_text;
 	guint column;
+#if GTK_CHECK_VERSION(3,0,0)
+	GdkRGBA rgba;
+#else
 	GdkColor color;
+#endif
 	gboolean value_valid = FALSE;
+	const char *colorname = NULL;
 
 	cell_text = gtk_editable_get_chars (editable, 0, -1);
 
@@ -403,13 +408,15 @@ cell_changed_cb (GtkEditable *editable,
 	}
 
 	/* Change cell's background color while editing */
-	if (value_valid)
-		gdk_color_parse ("lightgreen", &color);
-	else
-		gdk_color_parse ("red", &color);
-
-	gtk_widget_modify_base (GTK_WIDGET (editable), GTK_STATE_NORMAL, &color); /* works for GTK2 */
-	gtk_widget_modify_bg (GTK_WIDGET (editable), GTK_STATE_NORMAL, &color);   /* works for GTK3 */
+	colorname = value_valid ? "lightgreen" : "red";
+
+#if GTK_CHECK_VERSION(3,0,0)
+	gdk_rgba_parse (&rgba, colorname);
+	gtk_widget_override_background_color (GTK_WIDGET (editable), GTK_STATE_NORMAL, &rgba);
+#else
+	gdk_color_parse (colorname, &color);
+	gtk_widget_modify_base (GTK_WIDGET (editable), GTK_STATE_NORMAL, &color);
+#endif
 
 	g_free (cell_text);
 	return FALSE;
diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c
index 81a9d7b..f777a60 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -685,8 +685,13 @@ cell_changed_cb (GtkEditable *editable,
 {
 	char *cell_text;
 	guint column;
+#if GTK_CHECK_VERSION(3,0,0)
+	GdkRGBA rgba;
+#else
 	GdkColor color;
+#endif
 	gboolean value_valid = FALSE;
+	const char *colorname = NULL;
 
 	cell_text = gtk_editable_get_chars (editable, 0, -1);
 
@@ -704,13 +709,15 @@ cell_changed_cb (GtkEditable *editable,
 	}
 
 	/* Change cell's background color while editing */
-	if (value_valid)
-		gdk_color_parse ("lightgreen", &color);
-	else
-		gdk_color_parse ("red", &color);
-
-	gtk_widget_modify_base (GTK_WIDGET (editable), GTK_STATE_NORMAL, &color); /* works for GTK2 */
-	gtk_widget_modify_bg (GTK_WIDGET (editable), GTK_STATE_NORMAL, &color);   /* works for GTK3 */
+	colorname = value_valid ? "lightgreen" : "red";
+
+#if GTK_CHECK_VERSION(3,0,0)
+	gdk_rgba_parse (&rgba, colorname);
+	gtk_widget_override_background_color (GTK_WIDGET (editable), GTK_STATE_NORMAL, &rgba);
+#else
+	gdk_color_parse (colorname, &color);
+	gtk_widget_modify_base (GTK_WIDGET (editable), GTK_STATE_NORMAL, &color);
+#endif
 
 	g_free (cell_text);
 	return FALSE;
diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c
index 5cc01d5..5ec6562 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -639,8 +639,13 @@ cell_changed_cb (GtkEditable *editable,
 {
 	char *cell_text;
 	guint column;
+#if GTK_CHECK_VERSION(3,0,0)
+	GdkRGBA rgba;
+#else
 	GdkColor color;
+#endif
 	gboolean value_valid = FALSE;
+	const char *colorname = NULL;
 
 	cell_text = gtk_editable_get_chars (editable, 0, -1);
 
@@ -663,13 +668,15 @@ cell_changed_cb (GtkEditable *editable,
 	}
 
 	/* Change cell's background color while editing */
-	if (value_valid)
-		gdk_color_parse ("lightgreen", &color);
-	else
-		gdk_color_parse ("red", &color);
-
-	gtk_widget_modify_base (GTK_WIDGET (editable), GTK_STATE_NORMAL, &color); /* works for GTK2 */
-	gtk_widget_modify_bg (GTK_WIDGET (editable), GTK_STATE_NORMAL, &color);   /* works for GTK3 */
+	colorname = value_valid ? "lightgreen" : "red";
+
+#if GTK_CHECK_VERSION(3,0,0)
+	gdk_rgba_parse (&rgba, colorname);
+	gtk_widget_override_background_color (GTK_WIDGET (editable), GTK_STATE_NORMAL, &rgba);
+#else
+	gdk_color_parse (colorname, &color);
+	gtk_widget_modify_base (GTK_WIDGET (editable), GTK_STATE_NORMAL, &color);
+#endif
 
 	g_free (cell_text);
 	return FALSE;



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