[gtk/wip/otte/symbolic-paintable] enums: Add a GtkSymbolicColor enum
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/symbolic-paintable] enums: Add a GtkSymbolicColor enum
- Date: Mon, 30 Aug 2021 03:02:21 +0000 (UTC)
commit 6c87d362c5d52ad26cff03e7cab87496a4d51ae4
Author: Benjamin Otte <otte redhat com>
Date: Mon Aug 30 04:32:22 2021 +0200
enums: Add a GtkSymbolicColor enum
That way we don't nedmagic numbres to index the colors array.
Use it in the symbolic paintable demo.
demos/gtk-demo/paintable_symbolic.c | 6 +++---
gtk/gtkenums.h | 19 +++++++++++++++++++
2 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/demos/gtk-demo/paintable_symbolic.c b/demos/gtk-demo/paintable_symbolic.c
index 6be093f6e6..8f31ca31ef 100644
--- a/demos/gtk-demo/paintable_symbolic.c
+++ b/demos/gtk-demo/paintable_symbolic.c
@@ -61,10 +61,10 @@ gtk_nuclear_symbolic_snapshot_symbolic (GtkSymbolicPaintable *paintable,
bg_color = &transparent;
break;
case WARNING_ALERT:
- bg_color = &colors[2]; /* warning color */
+ bg_color = &colors[GTK_SYMBOLIC_COLOR_WARNING];
break;
case WARNING_EMERGENCY:
- bg_color = &colors[1]; /* error color */
+ bg_color = &colors[GTK_SYMBOLIC_COLOR_ERROR];
break;
default:
/* This should never happen, but we better do defensive coding
@@ -76,7 +76,7 @@ gtk_nuclear_symbolic_snapshot_symbolic (GtkSymbolicPaintable *paintable,
/* Draw the icon with the selected warning color */
gtk_nuclear_snapshot (snapshot,
- &colors[0], /* foreground color */
+ &colors[GTK_SYMBOLIC_COLOR_FOREGROUND],
bg_color,
width, height,
0);
diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h
index 31b0c8fb46..0dbae71726 100644
--- a/gtk/gtkenums.h
+++ b/gtk/gtkenums.h
@@ -1131,6 +1131,25 @@ typedef enum {
GTK_SYSTEM_SETTING_ICON_THEME
} GtkSystemSetting;
+/**
+ * GtkSymbolicColor:
+ * @GTK_SYMBOLIC_COLOR_FOREGROUND: The default foreground color
+ * @GTK_SYMBOLIC_COLOR_ERROR: Indication color for errors
+ * @GTK_SYMBOLIC_COLOR_WARNING: Indication color for warnings
+ * @GTK_SYMBOLIC_COLOR_SUCCESS: Indication color for success
+ *
+ * The indexes of colors passed to symbolic color rendering, such as
+ * [vfunc.GtkSymbolicPaintable.snapshot_symbolic].
+ *
+ * More values may be added over time.
+ */
+typedef enum {
+ GTK_SYMBOLIC_COLOR_FOREGROUND = 0,
+ GTK_SYMBOLIC_COLOR_ERROR = 1,
+ GTK_SYMBOLIC_COLOR_WARNING = 2,
+ GTK_SYMBOLIC_COLOR_SUCCESS = 3
+} GtkSymbolicColor;
+
/**
* GtkAccessibleRole:
* @GTK_ACCESSIBLE_ROLE_ALERT: An element with important, and usually
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]