[libwnck/wip/muktupavels/icons: 17/21] application: load icons only in getters




commit c242140aba27bfdb96bf3d6720ba46cae4841000
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Mar 14 19:48:19 2022 +0200

    application: load icons only in getters
    
    libwnck users might not use icons at all or might use only normal
    or mini icon. Redo code to get icons only when getters are used.

 libwnck/application.c | 44 ++------------------------------------------
 1 file changed, 2 insertions(+), 42 deletions(-)
---
diff --git a/libwnck/application.c b/libwnck/application.c
index f92901c7..b570d9fb 100644
--- a/libwnck/application.c
+++ b/libwnck/application.c
@@ -300,42 +300,10 @@ icon_cache_invalidated_cb (WnckIconCache   *icon_cache,
   emit_icon_changed (self);
 }
 
-static void
-get_icons (WnckApplication *app)
-{
-  GdkPixbuf *icon;
-  GdkPixbuf *mini_icon;
-
-  icon = NULL;
-  mini_icon = NULL;
-
-  _wnck_read_icons (app->priv->icon_cache, &icon, &mini_icon);
-
-  /* FIXME we should really fall back to using the icon
-   * for one of the windows. But then we need to be more
-   * complicated about icon_changed and when the icon
-   * needs updating and all that.
-   */
-
-  g_assert ((icon && mini_icon) || !(icon || mini_icon));
-
-  g_clear_object (&icon);
-  g_clear_object (&mini_icon);
-}
-
-static void
-_wnck_application_load_icons (WnckApplication *app)
-{
-  g_return_if_fail (WNCK_IS_APPLICATION (app));
-
-  get_icons (app);
-}
-
 void
 _wnck_application_invalidate_icons (WnckApplication *self)
 {
   _wnck_icon_cache_invalidate (self->priv->icon_cache);
-  _wnck_application_load_icons (self);
 }
 
 /* Prefer to get group icon from a window of type "normal" */
@@ -380,8 +348,6 @@ wnck_application_get_icon (WnckApplication *app)
 
   g_return_val_if_fail (WNCK_IS_APPLICATION (app), NULL);
 
-  _wnck_application_load_icons (app);
-
   icon = _wnck_icon_cache_get_icon (app->priv->icon_cache);
 
   if (icon != NULL)
@@ -415,8 +381,6 @@ wnck_application_get_mini_icon (WnckApplication *app)
 
   g_return_val_if_fail (WNCK_IS_APPLICATION (app), NULL);
 
-  _wnck_application_load_icons (app);
-
   mini_icon = _wnck_icon_cache_get_mini_icon (app->priv->icon_cache);
 
   if (mini_icon != NULL)
@@ -583,9 +547,7 @@ _wnck_application_add_window (WnckApplication *app,
   update_name (app);
 
   /* see if we're using icon from a window */
-  if (_wnck_icon_cache_get_icon (app->priv->icon_cache) == NULL ||
-      _wnck_icon_cache_get_mini_icon (app->priv->icon_cache) == NULL)
-    emit_icon_changed (app);
+  emit_icon_changed (app);
 }
 
 void
@@ -607,9 +569,7 @@ _wnck_application_remove_window (WnckApplication *app,
   update_name (app);
 
   /* see if we're using icon from a window */
-  if (_wnck_icon_cache_get_icon (app->priv->icon_cache) == NULL ||
-      _wnck_icon_cache_get_mini_icon (app->priv->icon_cache) == NULL)
-    emit_icon_changed (app);
+  emit_icon_changed (app);
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]