[gtk+/wip/checked: 3/6] gtk: Use new :checked state
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/checked: 3/6] gtk: Use new :checked state
- Date: Thu, 14 Aug 2014 03:34:41 +0000 (UTC)
commit 83f0244a5279c23d599eb173281af484dfca8866
Author: Benjamin Otte <otte redhat com>
Date: Thu Aug 14 04:34:30 2014 +0200
gtk: Use new :checked state
on:
- GtkToggleButton
- GtkCheckButton
- GtkRadioButton
- GtkCellRendererToggle
also update themes:
- Adwaita
- Raleigh
but not the win32 theme.
The new :checked state replaces :active for the actual checkedness of
the widgets and :active is now used exclusively while the button is being
pressed.
https://bugzilla.gnome.org/show_bug.cgi?id=733967
gtk/gtkcellrenderertoggle.c | 4 +-
gtk/gtkcheckbutton.c | 9 +++---
gtk/gtkcheckmenuitem.c | 2 +-
gtk/gtkradiobutton.c | 6 ++--
gtk/gtktogglebutton.c | 15 ++++++----
gtk/resources/theme/Adwaita/_common.scss | 14 +++++-----
gtk/resources/theme/Adwaita/gtk-contained-dark.css | 28 ++++++++++----------
gtk/resources/theme/Adwaita/gtk-contained.css | 28 ++++++++++----------
gtk/resources/theme/Raleigh/gtk-default.css | 8 +++---
9 files changed, 58 insertions(+), 56 deletions(-)
---
diff --git a/gtk/gtkcellrenderertoggle.c b/gtk/gtkcellrenderertoggle.c
index dfb24c1..64c01f2 100644
--- a/gtk/gtkcellrenderertoggle.c
+++ b/gtk/gtkcellrenderertoggle.c
@@ -386,12 +386,12 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
if (!priv->activatable)
state |= GTK_STATE_FLAG_INSENSITIVE;
- state &= ~(GTK_STATE_FLAG_INCONSISTENT | GTK_STATE_FLAG_ACTIVE);
+ state &= ~(GTK_STATE_FLAG_INCONSISTENT | GTK_STATE_FLAG_CHECKED);
if (priv->inconsistent)
state |= GTK_STATE_FLAG_INCONSISTENT;
else if (priv->active)
- state |= GTK_STATE_FLAG_ACTIVE;
+ state |= GTK_STATE_FLAG_CHECKED;
cairo_save (cr);
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 0c6ddbd..f395dcc 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -561,17 +561,16 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
state &= ~(GTK_STATE_FLAG_INCONSISTENT |
GTK_STATE_FLAG_ACTIVE |
- GTK_STATE_FLAG_SELECTED |
+ GTK_STATE_FLAG_CHECKED |
GTK_STATE_FLAG_PRELIGHT);
if (gtk_toggle_button_get_inconsistent (toggle_button))
state |= GTK_STATE_FLAG_INCONSISTENT;
- else if (gtk_toggle_button_get_active (toggle_button) ||
- (button->priv->button_down && button->priv->in_button))
- state |= GTK_STATE_FLAG_ACTIVE;
+ else if (gtk_toggle_button_get_active (toggle_button))
+ state |= GTK_STATE_FLAG_CHECKED;
if (button->priv->activate_timeout || (button->priv->button_down && button->priv->in_button))
- state |= GTK_STATE_FLAG_SELECTED;
+ state |= GTK_STATE_FLAG_ACTIVE;
if (button->priv->in_button)
state |= GTK_STATE_FLAG_PRELIGHT;
diff --git a/gtk/gtkcheckmenuitem.c b/gtk/gtkcheckmenuitem.c
index 2be79ef..a326515 100644
--- a/gtk/gtkcheckmenuitem.c
+++ b/gtk/gtkcheckmenuitem.c
@@ -576,7 +576,7 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
if (priv->inconsistent)
state |= GTK_STATE_FLAG_INCONSISTENT;
else if (priv->active)
- state |= GTK_STATE_FLAG_ACTIVE;
+ state |= GTK_STATE_FLAG_CHECKED;
gtk_style_context_set_state (context, state);
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index e1bd0d5..58b4f5d 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -897,17 +897,17 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
state &= ~(GTK_STATE_FLAG_INCONSISTENT |
GTK_STATE_FLAG_ACTIVE |
- GTK_STATE_FLAG_SELECTED |
+ GTK_STATE_FLAG_CHECKED |
GTK_STATE_FLAG_PRELIGHT);
if (gtk_toggle_button_get_inconsistent (toggle_button))
state |= GTK_STATE_FLAG_INCONSISTENT;
else if (gtk_toggle_button_get_active (toggle_button))
- state |= GTK_STATE_FLAG_ACTIVE;
+ state |= GTK_STATE_FLAG_CHECKED;
if (button->priv->activate_timeout ||
(button->priv->button_down && button->priv->in_button))
- state |= GTK_STATE_FLAG_SELECTED;
+ state |= GTK_STATE_FLAG_ACTIVE;
if (button->priv->in_button && !(state & GTK_STATE_FLAG_INSENSITIVE))
state |= GTK_STATE_FLAG_PRELIGHT;
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index c73ab85..a40c087 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -657,10 +657,19 @@ gtk_toggle_button_update_state (GtkButton *button)
new_state = gtk_widget_get_state_flags (GTK_WIDGET (button)) &
~(GTK_STATE_FLAG_INCONSISTENT |
GTK_STATE_FLAG_PRELIGHT |
+ GTK_STATE_FLAG_CHECKED |
GTK_STATE_FLAG_ACTIVE);
if (priv->inconsistent)
new_state |= GTK_STATE_FLAG_INCONSISTENT;
+ else if (priv->active)
+ new_state |= GTK_STATE_FLAG_CHECKED;
+
+ if (button->priv->in_button && button->priv->button_down)
+ new_state |= GTK_STATE_FLAG_ACTIVE;
+
+ if (button->priv->in_button)
+ new_state |= GTK_STATE_FLAG_PRELIGHT;
if (priv->inconsistent)
depressed = FALSE;
@@ -669,12 +678,6 @@ gtk_toggle_button_update_state (GtkButton *button)
else
depressed = priv->active;
- if (button->priv->in_button)
- new_state |= GTK_STATE_FLAG_PRELIGHT;
-
- if (depressed)
- new_state |= GTK_STATE_FLAG_ACTIVE;
-
_gtk_button_set_depressed (button, depressed);
gtk_widget_set_state_flags (GTK_WIDGET (toggle_button), new_state, TRUE);
}
diff --git a/gtk/resources/theme/Adwaita/_common.scss b/gtk/resources/theme/Adwaita/_common.scss
index 6533b50..ffcb4da 100644
--- a/gtk/resources/theme/Adwaita/_common.scss
+++ b/gtk/resources/theme/Adwaita/_common.scss
@@ -1625,7 +1625,7 @@ $asset_suffix: if($variant=='dark', '-dark', '');
//standard checks and radios
@each $s,$as in ('','-unchecked'),
(':hover', '-unchecked-hover'),
- (':selected', '-unchecked-active'),
+ (':active', '-unchecked-active'),
(':insensitive','-unchecked-insensitive'),
(':backdrop', '-unchecked-backdrop'),
(':backdrop:insensitive', '-unchecked-backdrop-insensitive'),
@@ -1635,12 +1635,12 @@ $asset_suffix: if($variant=='dark', '-dark', '');
(':inconsistent:backdrop', '-mixed-backdrop'),
(':inconsistent:insensitive', '-mixed-insensitive'),
(':inconsistent:insensitive:backdrop', '-mixed-backdrop-insensitive'),
- (':active', '-checked'),
- (':active:insensitive','-checked-insensitive'),
- (':hover:active', '-checked-hover'),
- (':active:selected', '-checked-active'),
- (':backdrop:active', '-checked-backdrop'),
- (':backdrop:active:insensitive', '-checked-backdrop-insensitive') {
+ (':checked', '-checked'),
+ (':checked:insensitive','-checked-insensitive'),
+ (':checked:hover', '-checked-hover'),
+ (':checked:active', '-checked-active'),
+ (':backdrop:checked', '-checked-backdrop'),
+ (':backdrop:checked:insensitive', '-checked-backdrop-insensitive') {
.#{$w}#{$s} {
-gtk-icon-source: -gtk-scaled(url("assets/#{$a}#{$as}#{$asset_suffix}.png"),
url("assets/#{$a}#{$as}#{$asset_suffix} 2 png"));
diff --git a/gtk/resources/theme/Adwaita/gtk-contained-dark.css
b/gtk/resources/theme/Adwaita/gtk-contained-dark.css
index 32983f2..b02f688 100644
--- a/gtk/resources/theme/Adwaita/gtk-contained-dark.css
+++ b/gtk/resources/theme/Adwaita/gtk-contained-dark.css
@@ -1705,7 +1705,7 @@ GtkSwitch {
.check:hover {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-unchecked-hover-dark.png"),
url("assets/checkbox-unchecked-hover-dark 2 png")); }
-.check:selected {
+.check:active {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-unchecked-active-dark.png"),
url("assets/checkbox-unchecked-active-dark 2 png")); }
.check:insensitive {
@@ -1735,22 +1735,22 @@ GtkSwitch {
.check:inconsistent:insensitive:backdrop {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-mixed-backdrop-insensitive-dark.png"),
url("assets/checkbox-mixed-backdrop-insensitive-dark 2 png")); }
-.check:active {
+.check:checked {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-checked-dark.png"), url("assets/checkbox-checked-dark 2
png")); }
-.check:active:insensitive {
+.check:checked:insensitive {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-checked-insensitive-dark.png"),
url("assets/checkbox-checked-insensitive-dark 2 png")); }
-.check:hover:active {
+.check:checked:hover {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-checked-hover-dark.png"),
url("assets/checkbox-checked-hover-dark 2 png")); }
-.check:active:selected {
+.check:checked:active {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-checked-active-dark.png"),
url("assets/checkbox-checked-active-dark 2 png")); }
-.check:backdrop:active {
+.check:backdrop:checked {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-checked-backdrop-dark.png"),
url("assets/checkbox-checked-backdrop-dark 2 png")); }
-.check:backdrop:active:insensitive {
+.check:backdrop:checked:insensitive {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-checked-backdrop-insensitive-dark.png"),
url("assets/checkbox-checked-backdrop-insensitive-dark 2 png")); }
.menuitem.check {
@@ -1823,7 +1823,7 @@ GtkSwitch {
.radio:hover {
-gtk-icon-source: -gtk-scaled(url("assets/radio-unchecked-hover-dark.png"),
url("assets/radio-unchecked-hover-dark 2 png")); }
-.radio:selected {
+.radio:active {
-gtk-icon-source: -gtk-scaled(url("assets/radio-unchecked-active-dark.png"),
url("assets/radio-unchecked-active-dark 2 png")); }
.radio:insensitive {
@@ -1853,22 +1853,22 @@ GtkSwitch {
.radio:inconsistent:insensitive:backdrop {
-gtk-icon-source: -gtk-scaled(url("assets/radio-mixed-backdrop-insensitive-dark.png"),
url("assets/radio-mixed-backdrop-insensitive-dark 2 png")); }
-.radio:active {
+.radio:checked {
-gtk-icon-source: -gtk-scaled(url("assets/radio-checked-dark.png"), url("assets/radio-checked-dark 2
png")); }
-.radio:active:insensitive {
+.radio:checked:insensitive {
-gtk-icon-source: -gtk-scaled(url("assets/radio-checked-insensitive-dark.png"),
url("assets/radio-checked-insensitive-dark 2 png")); }
-.radio:hover:active {
+.radio:checked:hover {
-gtk-icon-source: -gtk-scaled(url("assets/radio-checked-hover-dark.png"),
url("assets/radio-checked-hover-dark 2 png")); }
-.radio:active:selected {
+.radio:checked:active {
-gtk-icon-source: -gtk-scaled(url("assets/radio-checked-active-dark.png"),
url("assets/radio-checked-active-dark 2 png")); }
-.radio:backdrop:active {
+.radio:backdrop:checked {
-gtk-icon-source: -gtk-scaled(url("assets/radio-checked-backdrop-dark.png"),
url("assets/radio-checked-backdrop-dark 2 png")); }
-.radio:backdrop:active:insensitive {
+.radio:backdrop:checked:insensitive {
-gtk-icon-source: -gtk-scaled(url("assets/radio-checked-backdrop-insensitive-dark.png"),
url("assets/radio-checked-backdrop-insensitive-dark 2 png")); }
.menuitem.radio {
diff --git a/gtk/resources/theme/Adwaita/gtk-contained.css b/gtk/resources/theme/Adwaita/gtk-contained.css
index 3561a8e..6f683e9 100644
--- a/gtk/resources/theme/Adwaita/gtk-contained.css
+++ b/gtk/resources/theme/Adwaita/gtk-contained.css
@@ -1700,7 +1700,7 @@ GtkSwitch {
.check:hover {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-unchecked-hover.png"),
url("assets/checkbox-unchecked-hover 2 png")); }
-.check:selected {
+.check:active {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-unchecked-active.png"),
url("assets/checkbox-unchecked-active 2 png")); }
.check:insensitive {
@@ -1730,22 +1730,22 @@ GtkSwitch {
.check:inconsistent:insensitive:backdrop {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-mixed-backdrop-insensitive.png"),
url("assets/checkbox-mixed-backdrop-insensitive 2 png")); }
-.check:active {
+.check:checked {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-checked.png"), url("assets/checkbox-checked 2 png")); }
-.check:active:insensitive {
+.check:checked:insensitive {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-checked-insensitive.png"),
url("assets/checkbox-checked-insensitive 2 png")); }
-.check:hover:active {
+.check:checked:hover {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-checked-hover.png"), url("assets/checkbox-checked-hover
2 png")); }
-.check:active:selected {
+.check:checked:active {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-checked-active.png"),
url("assets/checkbox-checked-active 2 png")); }
-.check:backdrop:active {
+.check:backdrop:checked {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-checked-backdrop.png"),
url("assets/checkbox-checked-backdrop 2 png")); }
-.check:backdrop:active:insensitive {
+.check:backdrop:checked:insensitive {
-gtk-icon-source: -gtk-scaled(url("assets/checkbox-checked-backdrop-insensitive.png"),
url("assets/checkbox-checked-backdrop-insensitive 2 png")); }
.menuitem.check {
@@ -1818,7 +1818,7 @@ GtkSwitch {
.radio:hover {
-gtk-icon-source: -gtk-scaled(url("assets/radio-unchecked-hover.png"), url("assets/radio-unchecked-hover 2
png")); }
-.radio:selected {
+.radio:active {
-gtk-icon-source: -gtk-scaled(url("assets/radio-unchecked-active.png"), url("assets/radio-unchecked-active
2 png")); }
.radio:insensitive {
@@ -1848,22 +1848,22 @@ GtkSwitch {
.radio:inconsistent:insensitive:backdrop {
-gtk-icon-source: -gtk-scaled(url("assets/radio-mixed-backdrop-insensitive.png"),
url("assets/radio-mixed-backdrop-insensitive 2 png")); }
-.radio:active {
+.radio:checked {
-gtk-icon-source: -gtk-scaled(url("assets/radio-checked.png"), url("assets/radio-checked 2 png")); }
-.radio:active:insensitive {
+.radio:checked:insensitive {
-gtk-icon-source: -gtk-scaled(url("assets/radio-checked-insensitive.png"),
url("assets/radio-checked-insensitive 2 png")); }
-.radio:hover:active {
+.radio:checked:hover {
-gtk-icon-source: -gtk-scaled(url("assets/radio-checked-hover.png"), url("assets/radio-checked-hover 2
png")); }
-.radio:active:selected {
+.radio:checked:active {
-gtk-icon-source: -gtk-scaled(url("assets/radio-checked-active.png"), url("assets/radio-checked-active 2
png")); }
-.radio:backdrop:active {
+.radio:backdrop:checked {
-gtk-icon-source: -gtk-scaled(url("assets/radio-checked-backdrop.png"), url("assets/radio-checked-backdrop
2 png")); }
-.radio:backdrop:active:insensitive {
+.radio:backdrop:checked:insensitive {
-gtk-icon-source: -gtk-scaled(url("assets/radio-checked-backdrop-insensitive.png"),
url("assets/radio-checked-backdrop-insensitive 2 png")); }
.menuitem.radio {
diff --git a/gtk/resources/theme/Raleigh/gtk-default.css b/gtk/resources/theme/Raleigh/gtk-default.css
index e699785..e739214 100644
--- a/gtk/resources/theme/Raleigh/gtk-default.css
+++ b/gtk/resources/theme/Raleigh/gtk-default.css
@@ -157,7 +157,7 @@ GtkTreeView.dnd {
border-width: 2px;
}
-.button:active {
+.button:active, .button:checked {
background-color: shade (@bg_color, 0.7);
border-style: inset;
}
@@ -239,20 +239,20 @@ GtkRadioButton:selected {
border-color: @fg_color;
}
-.check:active, .radio:active,
+.check:checked, .radio:checked,
.check:hover, .radio:hover {
background-color: @base_color;
border-color: @fg_color;
color: @text_color;
}
-.check:selected, .radio:selected {
+.check:active, .radio:active {
background-color: darker (@bg_color);
color: @selected_fg_color;
border-color: @selected_fg_color;
}
-.check:selected:focused, .radio:selected:focused {
+.check:active:focused, .radio:active:focused {
background-color: @selected_bg_color;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]