[gnome-shell/gnome-3-22] Properly detect changes in .desktop files



commit 722bef3d0cc659aa30b62c6df8d775f5fbd8664f
Author: Adrian Perez de Castro <aperez igalia com>
Date:   Mon Nov 7 20:59:03 2016 +0200

    Properly detect changes in .desktop files
    
    This fixes the shell not picking updates to the contents of the underlying
    .desktop files for application launchers, or when a .desktop file is
    overriden by a user-installed one under ~/.local/share/applications
    
    https://bugzilla.gnome.org/show_bug.cgi?id=773636

 src/shell-app-system.c |   37 +++++++++++++++++++++++++++++--------
 1 files changed, 29 insertions(+), 8 deletions(-)
---
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index c41b4da..8edf757 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -112,19 +112,40 @@ scan_startup_wm_class_to_id (ShellAppSystem *self)
 static gboolean
 app_is_stale (ShellApp *app)
 {
-  GDesktopAppInfo *info;
-  gboolean is_stale;
+  GDesktopAppInfo *info, *old;
+  GAppInfo *old_info, *new_info;
+  gboolean is_unchanged;
 
   if (shell_app_is_window_backed (app))
     return FALSE;
 
   info = g_desktop_app_info_new (shell_app_get_id (app));
-  is_stale = (info == NULL);
-
-  if (info)
-    g_object_unref (info);
+  if (!info)
+    return TRUE;
+
+  old = shell_app_get_app_info (app);
+  old_info = G_APP_INFO (old);
+  new_info = G_APP_INFO (info);
+
+  is_unchanged =
+    g_app_info_should_show (old_info) == g_app_info_should_show (new_info) &&
+    strcmp (g_desktop_app_info_get_filename (old),
+            g_desktop_app_info_get_filename (info)) == 0 &&
+    g_strcmp0 (g_app_info_get_executable (old_info),
+               g_app_info_get_executable (new_info)) == 0 &&
+    g_strcmp0 (g_app_info_get_commandline (old_info),
+               g_app_info_get_commandline (new_info)) == 0 &&
+    strcmp (g_app_info_get_name (old_info),
+            g_app_info_get_name (new_info)) == 0 &&
+    g_strcmp0 (g_app_info_get_description (old_info),
+               g_app_info_get_description (new_info)) == 0 &&
+    strcmp (g_app_info_get_display_name (old_info),
+            g_app_info_get_display_name (new_info)) == 0 &&
+    g_icon_equal (g_app_info_get_icon (old_info),
+                  g_app_info_get_icon (new_info));
 
-  return is_stale;
+  g_object_unref (info);
+  return !is_unchanged;
 }
 
 static gboolean


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