[network-manager-applet] editor: fix widget color functions for GTK+ 3.0 and later
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet] editor: fix widget color functions for GTK+ 3.0 and later
- Date: Tue, 3 May 2011 00:26:02 +0000 (UTC)
commit 5a355d4e7e83432b98a18d639019a33ee6764e48
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 53a3b7a..559653a 100644
--- a/src/connection-editor/ip4-routes-dialog.c
+++ b/src/connection-editor/ip4-routes-dialog.c
@@ -415,8 +415,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);
@@ -458,13 +463,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 2742b82..0b47861 100644
--- a/src/connection-editor/ip6-routes-dialog.c
+++ b/src/connection-editor/ip6-routes-dialog.c
@@ -372,8 +372,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);
@@ -405,13 +410,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 469a59a..f230c73 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -684,8 +684,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);
@@ -703,13 +708,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 64beaa1..70c6f09 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -638,8 +638,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);
@@ -662,13 +667,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]