[gtk/switch-fallback] switch: Update state labels when needed
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/switch-fallback] switch: Update state labels when needed
- Date: Fri, 18 Jan 2019 14:45:27 +0000 (UTC)
commit 58d9c3d5bdab3600809f3bc8dd51e328e9755d08
Author: Emmanuele Bassi <ebassi gnome org>
Date: Fri Jan 18 14:43:42 2019 +0000
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.
gtk/gtkswitch.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
---
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"
@@ -399,6 +400,31 @@ gtk_switch_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (priv->off_label, &child_alloc, -1);
}
+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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]