[network-manager-applet/jk/editor-error-bg-color-bgo660915: 3/3] utils: add utils_set_cell_background() for GtkCellRenderer
- From: Jiří Klimeš <jklimes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/jk/editor-error-bg-color-bgo660915: 3/3] utils: add utils_set_cell_background() for GtkCellRenderer
- Date: Wed, 4 Mar 2015 14:05:01 +0000 (UTC)
commit bd6f661106f4df41e9112d25f34ab4ebca11ad6a
Author: Jiří Klimeš <jklimes redhat com>
Date: Wed Mar 4 14:20:09 2015 +0100
utils: add utils_set_cell_background() for GtkCellRenderer
src/connection-editor/ip4-routes-dialog.c | 20 ++++----------------
src/connection-editor/ip6-routes-dialog.c | 20 ++++----------------
src/connection-editor/page-ip4.c | 20 ++++----------------
src/connection-editor/page-ip6.c | 20 ++++----------------
src/utils/utils.c | 21 +++++++++++++++++++++
src/utils/utils.h | 3 +++
6 files changed, 40 insertions(+), 64 deletions(-)
---
diff --git a/src/connection-editor/ip4-routes-dialog.c b/src/connection-editor/ip4-routes-dialog.c
index 7e3ce33..1d1f271 100644
--- a/src/connection-editor/ip4-routes-dialog.c
+++ b/src/connection-editor/ip4-routes-dialog.c
@@ -672,23 +672,11 @@ cell_error_data_func (GtkTreeViewColumn *tree_column,
invalid = !get_one_int (tree_model, iter, COL_METRIC, G_MAXUINT32, FALSE, &metric, &value);
else
g_warn_if_reached ();
-
- if (invalid) {
- if (!value || !*value) {
- g_object_set (G_OBJECT (cell),
- "cell-background-set", TRUE,
- "cell-background", color,
- NULL);
- } else {
- char *markup;
- markup = g_strdup_printf ("<span background='%s'>%s</span>", color, value);
- g_object_set (G_OBJECT (cell), "markup", markup, NULL);
- g_free (markup);
- g_object_set (G_OBJECT (cell), "cell-background-set", FALSE, NULL);
- }
- } else
- g_object_set (G_OBJECT (cell), "cell-background-set", FALSE, NULL);
+ if (invalid)
+ utils_set_cell_background (cell, color, value);
+ else
+ utils_set_cell_background (cell, NULL, NULL);
g_free (value);
}
diff --git a/src/connection-editor/ip6-routes-dialog.c b/src/connection-editor/ip6-routes-dialog.c
index 5fde54c..e60502d 100644
--- a/src/connection-editor/ip6-routes-dialog.c
+++ b/src/connection-editor/ip6-routes-dialog.c
@@ -617,22 +617,10 @@ cell_error_data_func (GtkTreeViewColumn *tree_column,
else
g_warn_if_reached ();
- if (invalid) {
- if (!value || !*value) {
- g_object_set (G_OBJECT (cell),
- "cell-background-set", TRUE,
- "cell-background", color,
- NULL);
- } else {
- char *markup;
- markup = g_strdup_printf ("<span background='%s'>%s</span>", color, value);
- g_object_set (G_OBJECT (cell), "markup", markup, NULL);
- g_free (markup);
- g_object_set (G_OBJECT (cell), "cell-background-set", FALSE, NULL);
- }
- } else
- g_object_set (G_OBJECT (cell), "cell-background-set", FALSE, NULL);
-
+ if (invalid)
+ utils_set_cell_background (cell, color, value);
+ else
+ utils_set_cell_background (cell, NULL, NULL);
g_free (value);
}
diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c
index f5d0109..47d3da4 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -908,22 +908,10 @@ cell_error_data_func (GtkTreeViewColumn *tree_column,
else
g_warn_if_reached ();
- if (invalid) {
- if (!value || !*value) {
- g_object_set (G_OBJECT (cell),
- "cell-background-set", TRUE,
- "cell-background", color,
- NULL);
- } else {
- char *markup;
- markup = g_strdup_printf ("<span background='%s'>%s</span>", color, value);
- g_object_set (G_OBJECT (cell), "markup", markup, NULL);
- g_free (markup);
- g_object_set (G_OBJECT (cell), "cell-background-set", FALSE, NULL);
- }
- } else
- g_object_set (G_OBJECT (cell), "cell-background-set", FALSE, NULL);
-
+ if (invalid)
+ utils_set_cell_background (cell, color, value);
+ else
+ utils_set_cell_background (cell, NULL, NULL);
g_free (value);
}
diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c
index 915faf6..92f7654 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -908,22 +908,10 @@ cell_error_data_func (GtkTreeViewColumn *tree_column,
else
g_warn_if_reached ();
- if (invalid) {
- if (!value || !*value) {
- g_object_set (G_OBJECT (cell),
- "cell-background-set", TRUE,
- "cell-background", color,
- NULL);
- } else {
- char *markup;
- markup = g_strdup_printf ("<span background='%s'>%s</span>", color, value);
- g_object_set (G_OBJECT (cell), "markup", markup, NULL);
- g_free (markup);
- g_object_set (G_OBJECT (cell), "cell-background-set", FALSE, NULL);
- }
- } else
- g_object_set (G_OBJECT (cell), "cell-background-set", FALSE, NULL);
-
+ if (invalid)
+ utils_set_cell_background (cell, color, value);
+ else
+ utils_set_cell_background (cell, NULL, NULL);
g_free (value);
}
diff --git a/src/utils/utils.c b/src/utils/utils.c
index c9301fe..8691aa6 100644
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -517,3 +517,24 @@ utils_override_bg_color (GtkWidget *widget, GdkRGBA *rgba)
gtk_css_provider_load_from_data (provider, "", -1, NULL);
}
+void
+utils_set_cell_background (GtkCellRenderer *cell,
+ const char *color,
+ const char *value)
+{
+ if (color) {
+ if (!value || !*value) {
+ g_object_set (G_OBJECT (cell),
+ "cell-background-set", TRUE,
+ "cell-background", color,
+ NULL);
+ } else {
+ char *markup;
+ markup = g_strdup_printf ("<span background='%s'>%s</span>", color, value);
+ g_object_set (G_OBJECT (cell), "markup", markup, NULL);
+ g_free (markup);
+ g_object_set (G_OBJECT (cell), "cell-background-set", FALSE, NULL);
+ }
+ } else
+ g_object_set (G_OBJECT (cell), "cell-background-set", FALSE, NULL);
+}
diff --git a/src/utils/utils.h b/src/utils/utils.h
index 3e3d31b..6d4147f 100644
--- a/src/utils/utils.h
+++ b/src/utils/utils.h
@@ -101,6 +101,9 @@ void utils_update_password_storage (NMSetting *setting,
const char *password_flags_name);
void utils_override_bg_color (GtkWidget *widget, GdkRGBA *rgba);
+void utils_set_cell_background (GtkCellRenderer *cell,
+ const char *color,
+ const char *value);
#endif /* UTILS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]