Damjan Jovanovic : winemenubuilder: Use the user-dirs desktop directory instead of hardcoding ~/Desktop.
Alexandre Julliard
julliard at winehq.org
Tue Mar 31 12:19:22 CDT 2009
Module: wine
Branch: master
Commit: 612d47d3b573d19b3d8f195a8e70d8b718d2addf
URL: http://source.winehq.org/git/wine.git/?a=commit;h=612d47d3b573d19b3d8f195a8e70d8b718d2addf
Author: Damjan Jovanovic <damjan.jov at gmail.com>
Date: Mon Mar 30 20:06:31 2009 +0200
winemenubuilder: Use the user-dirs desktop directory instead of hardcoding ~/Desktop.
---
programs/winemenubuilder/winemenubuilder.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c
index 0c42b30..96d3c0f 100644
--- a/programs/winemenubuilder/winemenubuilder.c
+++ b/programs/winemenubuilder/winemenubuilder.c
@@ -146,6 +146,7 @@ typedef struct
static char *xdg_config_dir;
static char *xdg_data_dir;
+static char *xdg_desktop_dir;
/* Icon extraction routines
*
@@ -1382,7 +1383,7 @@ static BOOL InvokeShellLinker( IShellLinkW *sl, LPCWSTR link, BOOL bWait )
lastEntry = link_name;
else
++lastEntry;
- location = heap_printf("%s/Desktop/%s.desktop", getenv("HOME"), lastEntry);
+ location = heap_printf("%s/%s.desktop", xdg_desktop_dir, lastEntry);
if (location)
{
r = !write_desktop_entry(location, lastEntry, escaped_path, escaped_args, escaped_description, work_dir, icon_name);
@@ -1464,7 +1465,7 @@ static BOOL InvokeShellLinkerForURL( IUniformResourceLocatorW *url, LPCWSTR link
lastEntry = link_name;
else
++lastEntry;
- location = heap_printf("%s/Desktop/%s.desktop", getenv("HOME"), lastEntry);
+ location = heap_printf("%s/%s.desktop", xdg_desktop_dir, lastEntry);
if (location)
{
r = !write_desktop_entry(location, lastEntry, "winebrowser", escaped_urlPath, NULL, NULL, NULL);
@@ -1705,6 +1706,16 @@ static CHAR *next_token( LPSTR *p )
static BOOL init_xdg(void)
{
+ WCHAR shellDesktopPath[MAX_PATH];
+ HRESULT hr = SHGetFolderPathW(NULL, CSIDL_DESKTOP, NULL, SHGFP_TYPE_CURRENT, shellDesktopPath);
+ if (SUCCEEDED(hr))
+ xdg_desktop_dir = wine_get_unix_file_name(shellDesktopPath);
+ if (xdg_desktop_dir == NULL)
+ {
+ WINE_ERR("error looking up the desktop directory\n");
+ return FALSE;
+ }
+
if (getenv("XDG_CONFIG_HOME"))
xdg_config_dir = heap_printf("%s/menus/applications-merged", getenv("XDG_CONFIG_HOME"));
else
@@ -1730,6 +1741,7 @@ static BOOL init_xdg(void)
}
HeapFree(GetProcessHeap(), 0, xdg_config_dir);
}
+ WINE_ERR("out of memory\n");
return FALSE;
}
@@ -1744,7 +1756,8 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
BOOL bURL = FALSE;
int ret = 0;
- init_xdg();
+ if (!init_xdg())
+ return 1;
for( p = cmdline; p && *p; )
{
More information about the wine-cvs
mailing list