[gtk: 25/40] icon-theme: Preload default icon themes in thread
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 25/40] icon-theme: Preload default icon themes in thread
- Date: Thu, 30 Jan 2020 17:33:14 +0000 (UTC)
commit 6a8001fe7d2818d50fbf133b27c823726c28d97d
Author: Alexander Larsson <alexl redhat com>
Date: Wed Jan 29 11:38:05 2020 +0100
icon-theme: Preload default icon themes in thread
This happens when we first get the theme for a display, or then the
icon theme setting changes.
This means we don't have to do this scan in the first snapshot
and can do the i/o it in parallel with other stuff. This moves
a 10msec block from the first snapshot cycle to early setup.
gtk/gtkicontheme.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index e354f8c4fd..317a36a2f8 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -733,6 +733,30 @@ gtk_icon_theme_get_default (void)
return gtk_icon_theme_get_for_display (gdk_display_get_default ());
}
+static void
+load_theme_thread (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable)
+{
+ GtkIconTheme *self = GTK_ICON_THEME (source_object);
+
+ gtk_icon_theme_lock (self);
+ ensure_valid_themes (self, FALSE);
+ gtk_icon_theme_unlock (self);
+ g_task_return_pointer (task, NULL, NULL);
+}
+
+static void
+gtk_icon_theme_load_in_thread (GtkIconTheme *self)
+{
+ GTask *task;
+
+ task = g_task_new (self, NULL, NULL, NULL);
+ g_task_set_task_data (task, g_object_ref (self), g_object_unref);
+ g_task_run_in_thread (task, load_theme_thread);
+}
+
/**
* gtk_icon_theme_get_for_display:
* @display: a #GdkDisplay
@@ -767,6 +791,9 @@ gtk_icon_theme_get_for_display (GdkDisplay *display)
self->is_display_singleton = TRUE;
g_object_set_data (G_OBJECT (display), I_("gtk-icon-theme"), self);
+
+ /* Queue early read of the default themes, we read the icon theme name in _set_display(). */
+ gtk_icon_theme_load_in_thread (self);
}
return self;
@@ -873,7 +900,12 @@ theme_changed__mainthread_unlocked (GtkSettings *settings,
GtkIconTheme *self = gtk_icon_theme_ref_aquire (ref);
if (self)
- update_current_theme__mainthread (self);
+ {
+ update_current_theme__mainthread (self);
+
+ /* Queue early read of the new theme */
+ gtk_icon_theme_load_in_thread (self);
+ }
gtk_icon_theme_ref_release (ref);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]