Skip to content

Commit 5658c4e

Browse files
authored
Constants/CssClass: add colors and deprecate old ones (#753)
1 parent 138eab1 commit 5658c4e

File tree

3 files changed

+45
-10
lines changed

3 files changed

+45
-10
lines changed

demo/Views/CSSView.vala

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,26 +113,32 @@ public class CSSView : Gtk.Box {
113113
var accent_color_box = new Gtk.Box (HORIZONTAL, 6);
114114
accent_color_box.append (new Gtk.Image.from_icon_name ("emoji-body-symbolic"));
115115
accent_color_box.append (new Gtk.Image.from_icon_name ("face-tired-symbolic"));
116-
accent_color_box.append (new Gtk.Label (".accent"));
117-
accent_color_box.add_css_class (Granite.STYLE_CLASS_ACCENT);
116+
accent_color_box.append (new Gtk.Label ("Granite.CssClass.ACCENT"));
117+
accent_color_box.add_css_class (Granite.CssClass.ACCENT);
118118

119119
var success_color_box = new Gtk.Box (HORIZONTAL, 6);
120120
success_color_box.append (new Gtk.Image.from_icon_name ("process-completed-symbolic"));
121121
success_color_box.append (new Gtk.Image.from_icon_name ("face-sick-symbolic"));
122-
success_color_box.append (new Gtk.Label (".success"));
123-
success_color_box.add_css_class (Granite.STYLE_CLASS_SUCCESS);
122+
success_color_box.append (new Gtk.Label ("Granite.CssClass.SUCCESS"));
123+
success_color_box.add_css_class (Granite.CssClass.SUCCESS);
124124

125125
var warning_color_box = new Gtk.Box (HORIZONTAL, 6);
126126
warning_color_box.append (new Gtk.Image.from_icon_name ("dialog-warning-symbolic"));
127127
warning_color_box.append (new Gtk.Image.from_icon_name ("face-laugh-symbolic"));
128-
warning_color_box.append (new Gtk.Label (".warning"));
129-
warning_color_box.add_css_class (Granite.STYLE_CLASS_WARNING);
128+
warning_color_box.append (new Gtk.Label ("Granite.CssClass.WARNING"));
129+
warning_color_box.add_css_class (Granite.CssClass.WARNING);
130130

131131
var error_color_box = new Gtk.Box (HORIZONTAL, 6);
132132
error_color_box.append (new Gtk.Image.from_icon_name ("dialog-error-symbolic"));
133133
error_color_box.append (new Gtk.Image.from_icon_name ("face-angry-symbolic"));
134-
error_color_box.append (new Gtk.Label (".error"));
135-
error_color_box.add_css_class (Granite.STYLE_CLASS_ERROR);
134+
error_color_box.append (new Gtk.Label ("Granite.CssClass.ERROR"));
135+
error_color_box.add_css_class (Granite.CssClass.ERROR);
136+
137+
var dimmed_box = new Gtk.Box (HORIZONTAL, 6);
138+
dimmed_box.append (new Gtk.Image.from_icon_name ("adw-tab-icon-missing-symbolic"));
139+
dimmed_box.append (new Gtk.Image.from_icon_name ("face-plain-symbolic"));
140+
dimmed_box.append (new Gtk.Label ("Granite.CssClass.DIM"));
141+
dimmed_box.add_css_class (Granite.CssClass.DIM);
136142

137143
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12) {
138144
halign = Gtk.Align.CENTER,
@@ -160,6 +166,7 @@ public class CSSView : Gtk.Box {
160166
box.append (success_color_box);
161167
box.append (warning_color_box);
162168
box.append (error_color_box);
169+
box.append (dimmed_box);
163170

164171
var scrolled = new Gtk.ScrolledWindow () {
165172
child = box

demo/Views/WelcomeView.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class WelcomeView : Gtk.Box {
2525
description = "Maybe you can <b>do something</b> to hide it but <i>otherwise</i> it will stay here",
2626
icon = new ThemedIcon ("dialog-warning")
2727
};
28-
alert.add_css_class (Granite.STYLE_CLASS_WARNING);
28+
alert.add_css_class (Granite.CssClass.WARNING);
2929

3030
var alert_action = alert.append_button (
3131
new ThemedIcon ("edit-delete"),

lib/Constants.vala

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Granite {
77
/**
88
* Style class to give accent color to a {@link Gtk.Label} or symbolic icon
99
*/
10+
[Version (deprecated = true, deprecated_since = "7.7.0", replacement = "Granite.CssClass.ACCENT")]
1011
public const string STYLE_CLASS_ACCENT = "accent";
1112
/**
1213
* Style class for shaping a {@link Gtk.Button}
@@ -106,7 +107,7 @@ namespace Granite {
106107
/**
107108
* Style class for widgets in success state.
108109
*/
109-
[Version (since = "7.5.0")]
110+
[Version (since = "7.5.0", deprecated = true, deprecated_since = "7.7.0", replacement = "Granite.CssClass.SUCCESS")]
110111
public const string STYLE_CLASS_SUCCESS = "success";
111112

112113
/**
@@ -144,10 +145,12 @@ namespace Granite {
144145
/**
145146
* Style class for dimmed labels.
146147
*/
148+
[Version (deprecated = true, deprecated_since = "7.7.0", replacement = "Granite.CssClass.DIM")]
147149
public const string STYLE_CLASS_DIM_LABEL = "dim-label";
148150
/**
149151
* Style class for widgets in error state.
150152
*/
153+
[Version (deprecated = true, deprecated_since = "7.7.0", replacement = "Granite.CssClass.ERROR")]
151154
public const string STYLE_CLASS_ERROR = "error";
152155
/**
153156
* Style class for flattened widgets, such as buttons,
@@ -173,6 +176,7 @@ namespace Granite {
173176
/**
174177
* Style class for widgets in warning state.
175178
*/
179+
[Version (deprecated = true, deprecated_since = "7.7.0", replacement = "Granite.CssClass.WARNING")]
176180
public const string STYLE_CLASS_WARNING = "warning";
177181

178182
/**
@@ -195,11 +199,35 @@ namespace Granite {
195199
*/
196200
[Version (since = "7.7.0")]
197201
namespace CssClass {
202+
/**
203+
* Style class to give accent color to a {@link Gtk.Label} or symbolic icon
204+
*/
205+
public const string ACCENT = "accent";
206+
207+
/**
208+
* Style class for dimmed labels and icons
209+
*/
210+
public const string DIM = "dim-label";
211+
212+
/**
213+
* Style class for widgets in error state.
214+
*/
215+
public const string ERROR = "error";
198216

199217
/**
200218
* sets font features to use tabular numbers. Equivalent of Pango's tnum property
201219
*/
202220
public const string NUMERIC = "numeric";
221+
222+
/**
223+
* Style class for widgets in success state.
224+
*/
225+
public const string SUCCESS = "success";
226+
227+
/**
228+
* Style class for widgets in warning state.
229+
*/
230+
public const string WARNING = "warning";
203231
}
204232

205233
/**

0 commit comments

Comments
 (0)