From b8c487050e04975cb81bd9404f4f4281b6ed6f86 Mon Sep 17 00:00:00 2001
From: wangxiaoqing <wangxiaoqing@kylinsec.com.cn>
Date: Wed, 27 Jul 2022 14:14:11 +0800
Subject: [PATCH] Support change desktop background image in kiran desktop
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- 修复在Kiran桌面中桌面右键更改桌面背景菜单无法使用的问题
  Related #I5I1HE

Signed-off-by: wangxiaoqing <wangxiaoqing@kylinsec.com.cn>
---
 libcaja-private/caja-program-choosing.c |  5 ++++
 src/file-manager/fm-desktop-icon-view.c | 32 +++++++++++++++++++++----
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/libcaja-private/caja-program-choosing.c b/libcaja-private/caja-program-choosing.c
index 5e3d22b..033142d 100644
--- a/libcaja-private/caja-program-choosing.c
+++ b/libcaja-private/caja-program-choosing.c
@@ -358,6 +358,11 @@ caja_launch_application_from_command (GdkScreen  *screen,
             display = gdk_screen_get_display (screen);
             launch_context = gdk_display_get_app_launch_context (display);
             gdk_app_launch_context_set_screen (launch_context, screen);
+            /**
+             * Remove GIO_LAUNCHED_DESKTOP_FILE Environment variables to allow
+             * the KIRAN taskbar to find the corresponding window icon.
+             */
+            g_app_launch_context_unsetenv (G_APP_LAUNCH_CONTEXT (launch_context), "GIO_LAUNCHED_DESKTOP_FILE");
             g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (launch_context), NULL);
             g_object_unref (launch_context);
             g_object_unref (app_info);
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index aa40b2d..22dfa3f 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -656,17 +656,39 @@ action_new_launcher_callback (GtkAction *action, gpointer data)
 
 }
 
+static gboolean
+running_in_kiran (void)
+{
+    return (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "KIRAN") == 0)
+        || (g_strcmp0 (g_getenv ("XDG_SESSION_DESKTOP"), "KIRAN") == 0)
+        || (g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "KIRAN") == 0);
+}
+
 static void
 action_change_background_callback (GtkAction *action,
                                    gpointer data)
 {
     g_assert (FM_DIRECTORY_VIEW (data));
 
-    caja_launch_application_from_command (gtk_widget_get_screen (GTK_WIDGET (data)),
-                                          _("Background"),
-                                          "mate-appearance-properties",
-                                          FALSE,
-                                          "--show-page=background", NULL);
+    if (running_in_kiran())
+    {
+        caja_launch_application_from_command (gtk_widget_get_screen (GTK_WIDGET (data)),
+                                              _("Background"),
+                                              "kiran-control-panel",
+                                              FALSE,
+					      "-c",
+					      "individuation",
+                                              "-s",
+					      "Wallpaper", NULL);
+    }
+    else
+    {
+        caja_launch_application_from_command (gtk_widget_get_screen (GTK_WIDGET (data)),
+                                              _("Background"),
+                                              "mate-appearance-properties",
+                                              FALSE,
+                                              "--show-page=background", NULL);
+    }
 }
 
 static void
-- 
2.36.1

