[Wine-patches] (try 2) winemenubuilder: use xdg-user-dir for find desktop directory (eterbug #3640)

Konstantin Kondratyuk =?iso-8859-1?q?kondratyuk_=CE=C1_etersoft=2Eru?=
Вт Мар 17 17:01:27 MSK 2009


-- 
Best regards,
Konstantin Kondratyuk.
----------- следующая часть -----------
From 806fc2919895208e0a1390d091239dbe1dbd0681 Mon Sep 17 00:00:00 2001
From: Konstantin Kondratyuk <kondratyuk на etersoft.ru>
Date: Fri, 13 Mar 2009 18:51:37 +0300
Subject: [PATCH] winemenubuilder: use xdg-user-dir for find desktop directory (eterbug #3640)

---
 programs/winemenubuilder/winemenubuilder.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c
index f5f7ec0..4b73ca3 100644
--- a/programs/winemenubuilder/winemenubuilder.c
+++ b/programs/winemenubuilder/winemenubuilder.c
@@ -1375,6 +1375,8 @@ static BOOL InvokeShellLinker( IShellLinkW *sl, LPCWSTR link, BOOL bWait )
 
     if (in_desktop_dir(csidl))
     {
+        FILE *ptr;
+        char *desktop = NULL;
         char *location;
         const char *lastEntry;
         lastEntry = strrchr(link_name, '/');
@@ -1382,7 +1384,25 @@ static BOOL InvokeShellLinker( IShellLinkW *sl, LPCWSTR link, BOOL bWait )
             lastEntry = link_name;
         else
             ++lastEntry;
-        location = heap_printf("%s/Desktop/%s.desktop", getenv("HOME"), lastEntry);
+
+        if((ptr = popen("xdg-user-dir DESKTOP","r")))
+        {
+            char buf[256];
+            if(fgets(buf, sizeof(buf), ptr) && buf[0] == '/')
+            {
+                buf[strlen(buf)-1] = '\0';
+                desktop = heap_printf("%s", buf);
+            }
+            pclose(ptr);
+        }
+        if(!desktop)
+            desktop = heap_printf("%s/Desktop",getenv("HOME"));
+
+        location = heap_printf("%s/%s.desktop", desktop, lastEntry);
+        HeapFree(GetProcessHeap(), 0, desktop);
+
+        WINE_TRACE("Desktop entry is: %s\n",location);
+
         if (location)
         {
             r = !write_desktop_entry(location, lastEntry, escaped_path, escaped_args, escaped_description, work_dir, icon_name);
-- 
1.6.1.3.GIT



Подробная информация о списке рассылки Wine-patches