summaryrefslogtreecommitdiff
path: root/gtk/gtkswitch.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2019-01-18 14:43:42 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2019-01-18 14:43:42 +0000
commit58d9c3d5bdab3600809f3bc8dd51e328e9755d08 (patch)
tree2956a5733a330e3051ee091af4d7bb1c8a9840f7 /gtk/gtkswitch.c
parent5c50e48156c6edbc2923bb3702f60349d8184057 (diff)
downloadgtk+-58d9c3d5bdab3600809f3bc8dd51e328e9755d08.tar.gz
switch: Update state labels when needed
If the text style changes, or the display settings do, we need to update the state labels to ensure that the glyphs are available in the font we're using.
Diffstat (limited to 'gtk/gtkswitch.c')
-rw-r--r--gtk/gtkswitch.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c
index cb361c1292..8ade76acdb 100644
--- a/gtk/gtkswitch.c
+++ b/gtk/gtkswitch.c
@@ -65,6 +65,7 @@
#include "gtkprivate.h"
#include "gtkprogresstrackerprivate.h"
#include "gtksettingsprivate.h"
+#include "gtkstylecontextprivate.h"
#include "gtkwidgetprivate.h"
#include "a11y/gtkswitchaccessible.h"
@@ -400,6 +401,31 @@ gtk_switch_size_allocate (GtkWidget *widget,
}
static void
+gtk_switch_style_updated (GtkWidget *widget)
+{
+ GtkSwitch *self = GTK_SWITCH (widget);
+ GtkCssStyleChange *change;
+ GtkStyleContext *context;
+
+ GTK_WIDGET_CLASS (gtk_switch_parent_class)->style_updated (widget);
+
+ context = gtk_widget_get_style_context (widget);
+ change = gtk_style_context_get_change (context);
+
+ if (change == NULL || gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT))
+ gtk_switch_update_state_labels (self);
+}
+
+static void
+gtk_switch_display_changed (GtkWidget *widget,
+ GdkDisplay *previous_display)
+{
+ GtkSwitch *self = GTK_SWITCH (widget);
+
+ gtk_switch_update_state_labels (self);
+}
+
+static void
gtk_switch_set_action_name (GtkActionable *actionable,
const gchar *action_name)
{
@@ -591,6 +617,8 @@ gtk_switch_class_init (GtkSwitchClass *klass)
widget_class->measure = gtk_switch_measure;
widget_class->size_allocate = gtk_switch_size_allocate;
+ widget_class->style_updated = gtk_switch_style_updated;
+ widget_class->display_changed = gtk_switch_display_changed;
klass->activate = gtk_switch_activate;
klass->state_set = state_set;