icon-theme: Add i/o priority to choose_icon_async()
authorAlexander Larsson <alexl@redhat.com>
Thu, 30 Jan 2020 14:15:08 +0000 (15:15 +0100)
committerAlexander Larsson <alexl@redhat.com>
Thu, 30 Jan 2020 14:15:08 +0000 (15:15 +0100)
This is set on the GTask and lower priority will be loaded before,
this can be used to prioritize some icons for preloading.

gtk/gtkiconhelper.c
gtk/gtkicontheme.c
gtk/gtkicontheme.h
tests/testicontheme.c
testsuite/gtk/icontheme.c

index 4091722cc4ee54cfe333a6fc2cc281282d411a2c..e266887c566904e9ea31cabee697431dfbaea16c 100644 (file)
@@ -215,7 +215,7 @@ _gtk_icon_helper_preload (GtkIconHelper *self)
       gtk_icon_theme_choose_icon_async (icon_theme,
                                         (const gchar **)g_themed_icon_get_names (G_THEMED_ICON (gicon)),
                                         size, scale,
-                                        flags, NULL, NULL, NULL);
+                                        flags, 0, NULL, NULL, NULL);
     }
 
   if (free_gicon)
index 104a95e3329f6c3d1e1404d6cdb0b34589c6c3c0..f04b019b1beee1da834ddbc7c2794c1ea284814f 100644 (file)
@@ -2458,6 +2458,7 @@ load_icon_thread  (GTask        *task,
  * @size: desired icon size.
  * @scale: the window scale this will be displayed on
  * @flags: flags modifying the behavior of the icon lookup
+ * @io_priority: the [I/O priority][io-priority] of the request.
  * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore
  * @callback: (scope async): a #GAsyncReadyCallback to call when the
  *     request is satisfied
@@ -2474,9 +2475,10 @@ gtk_icon_theme_choose_icon_async (GtkIconTheme       *self,
                                   gint                size,
                                   gint                scale,
                                   GtkIconLookupFlags  flags,
-                                  GCancellable        *cancellable,
-                                  GAsyncReadyCallback  callback,
-                                  gpointer             user_data)
+                                  int                 priority,
+                                  GCancellable       *cancellable,
+                                  GAsyncReadyCallback callback,
+                                  gpointer            user_data)
 {
   GTask *task;
   GtkIcon *icon = NULL;
@@ -2489,6 +2491,7 @@ gtk_icon_theme_choose_icon_async (GtkIconTheme       *self,
   g_warn_if_fail ((flags & GTK_ICON_LOOKUP_GENERIC_FALLBACK) == 0);
 
   task = g_task_new (self, cancellable, callback, user_data);
+  g_task_set_priority (task, priority);
 
   if (gtk_icon_theme_trylock (self))
     {
index 45ca6093633077165c1a814a4075e51d3d25f1d7..a11959a61b700afb6c8192f25a7bf038d8be31f7 100644 (file)
@@ -163,6 +163,7 @@ void         gtk_icon_theme_choose_icon_async      (GtkIconTheme
                                                     gint                         size,
                                                     gint                         scale,
                                                     GtkIconLookupFlags           flags,
+                                                    int                          priority,
                                                     GCancellable                *cancellable,
                                                     GAsyncReadyCallback          callback,
                                                     gpointer                     user_data);
index c988f10ce577574d7807dba3d7273642bae2e5f9..4271e6df46e8cce4f10f226b2f3798003fd543c5 100644 (file)
@@ -149,7 +149,7 @@ main (int argc, char *argv[])
       gtk_widget_show (window);
 
       icons[0] = argv[3];
-      gtk_icon_theme_choose_icon_async (icon_theme, icons, size, scale, flags, NULL, icon_loaded_cb, image);
+      gtk_icon_theme_choose_icon_async (icon_theme, icons, size, scale, flags, 0, NULL, icon_loaded_cb, image);
 
       gtk_main ();
     }
index 2d1ea6902c73976e10be4865ef3ee106ce17c98b..9563ad290829abe6cf41de85748f194f3ed9fe50 100644 (file)
@@ -622,8 +622,8 @@ test_async (void)
 
   g_printerr ("test_async\n");
   theme = get_test_icontheme (TRUE);
-  gtk_icon_theme_choose_icon_async (theme, icons, 32, 1, 0, NULL, load_icon, loop);
-  gtk_icon_theme_choose_icon_async (theme, icons, 48, 1, 0, NULL, load_icon, loop);
+  gtk_icon_theme_choose_icon_async (theme, icons, 32, 1, 0, 0, NULL, load_icon, loop);
+  gtk_icon_theme_choose_icon_async (theme, icons, 48, 1, 0, 0, NULL, load_icon, loop);
 
   g_main_loop_run (loop);
   g_main_loop_unref (loop);