[libhandy/wip/exalm/animation] style-manager: Disable light/dark transtion without GtkSettings
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy/wip/exalm/animation] style-manager: Disable light/dark transtion without GtkSettings
- Date: Thu, 17 Feb 2022 15:01:19 +0000 (UTC)
commit c87af19d8463b278e433e1289b5628411a6777ab
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Thu Feb 17 20:01:56 2022 +0500
style-manager: Disable light/dark transtion without GtkSettings
That approach worked but wasn't exactly great. Hence replace it with
another approach that's not great either but is cleaner.
Now a spinning spinner will keep spinning when switching between light
and dark!
src/hdy-style-manager.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/src/hdy-style-manager.c b/src/hdy-style-manager.c
index 0d5a9555..34f79593 100644
--- a/src/hdy-style-manager.c
+++ b/src/hdy-style-manager.c
@@ -62,6 +62,7 @@ struct _HdyStyleManager
HdyColorScheme color_scheme;
gboolean dark;
+ GtkCssProvider *animations_provider;
guint animation_timeout_id;
};
@@ -264,8 +265,8 @@ enable_animations_cb (HdyStyleManager *self)
{
GdkScreen *screen = gdk_display_get_default_screen (self->display);
- gtk_settings_reset_property (gtk_settings_get_for_screen (screen),
- "gtk-enable-animations");
+ gtk_style_context_remove_provider_for_screen (screen,
+ GTK_STYLE_PROVIDER (self->animations_provider));
self->animation_timeout_id = 0;
@@ -295,7 +296,6 @@ update_stylesheet (HdyStyleManager *self)
{
GdkScreen *screen;
GtkSettings *gtk_settings;
- gboolean enable_animations;
if (!self->display)
return;
@@ -310,17 +310,12 @@ update_stylesheet (HdyStyleManager *self)
G_CALLBACK (update_stylesheet),
self);
- if (self->animation_timeout_id) {
+ if (self->animation_timeout_id)
g_clear_handle_id (&self->animation_timeout_id, g_source_remove);
- enable_animations = TRUE;
- } else {
- g_object_get (gtk_settings,
- "gtk-enable-animations", &enable_animations,
- NULL);
- }
- if (enable_animations)
- g_object_set (gtk_settings, "gtk-enable-animations", FALSE, NULL);
+ gtk_style_context_add_provider_for_screen (screen,
+ GTK_STYLE_PROVIDER (self->animations_provider),
+ 10000);
g_object_set (gtk_settings,
"gtk-application-prefer-dark-theme", self->dark,
@@ -340,12 +335,10 @@ update_stylesheet (HdyStyleManager *self)
G_CALLBACK (warn_prefer_dark_theme),
self);
- if (enable_animations) {
- self->animation_timeout_id =
- g_timeout_add (SWITCH_DURATION,
- G_SOURCE_FUNC (enable_animations_cb),
- self);
- }
+ self->animation_timeout_id =
+ g_timeout_add (SWITCH_DURATION,
+ G_SOURCE_FUNC (enable_animations_cb),
+ self);
g_idle_add (G_SOURCE_FUNC (unblock_theme_name_changed_cb), self);
}
@@ -425,6 +418,12 @@ hdy_style_manager_constructed (GObject *object)
G_CALLBACK (update_stylesheet),
self,
G_CONNECT_SWAPPED);
+
+ self->animations_provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (self->animations_provider,
+ "* { transition: none; }",
+ -1,
+ NULL);
}
self->settings = hdy_settings_get_default ();
@@ -450,6 +449,7 @@ hdy_style_manager_dispose (GObject *object)
HdyStyleManager *self = HDY_STYLE_MANAGER (object);
g_clear_handle_id (&self->animation_timeout_id, g_source_remove);
+ g_clear_object (&self->animations_provider);
G_OBJECT_CLASS (hdy_style_manager_parent_class)->dispose (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]