summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2004-12-19 21:00:58 +0000
committerTor Lillqvist <tml@src.gnome.org>2004-12-19 21:00:58 +0000
commit78e869fe97c6f759dcbaabae6d7a3124f3019222 (patch)
tree60f235e908e00841156b07e7fd95bcb5848223a7
parenta5b531c1b078c35454e3cc6015695614d7ae050d (diff)
downloadgdk-pixbuf-78e869fe97c6f759dcbaabae6d7a3124f3019222.tar.gz
Use wide character API when available. Use UTF-8 for filenames.
2004-12-19 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (resolve_link, gdk_dropfiles_filter): Use wide character API when available. Use UTF-8 for filenames. * gdk/win32/gdkselection-win32.c (_gdk_dropfiles_store): Include the string's trailing zero byte in the property's length, just for safety.
-rw-r--r--ChangeLog9
-rw-r--r--ChangeLog.pre-2-109
-rw-r--r--ChangeLog.pre-2-69
-rw-r--r--ChangeLog.pre-2-89
-rw-r--r--gdk/win32/gdkdnd-win32.c166
-rw-r--r--gdk/win32/gdkselection-win32.c2
6 files changed, 133 insertions, 71 deletions
diff --git a/ChangeLog b/ChangeLog
index 0cce19d02..bc31f0a8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-12-19 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkdnd-win32.c (resolve_link, gdk_dropfiles_filter):
+ Use wide character API when available. Use UTF-8 for filenames.
+
+ * gdk/win32/gdkselection-win32.c (_gdk_dropfiles_store): Include
+ the string's trailing zero byte in the property's length, just for
+ safety.
+
2004-12-18 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserentry.c (check_completion_callback)
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 0cce19d02..bc31f0a8c 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,12 @@
+2004-12-19 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkdnd-win32.c (resolve_link, gdk_dropfiles_filter):
+ Use wide character API when available. Use UTF-8 for filenames.
+
+ * gdk/win32/gdkselection-win32.c (_gdk_dropfiles_store): Include
+ the string's trailing zero byte in the property's length, just for
+ safety.
+
2004-12-18 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserentry.c (check_completion_callback)
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 0cce19d02..bc31f0a8c 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,12 @@
+2004-12-19 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkdnd-win32.c (resolve_link, gdk_dropfiles_filter):
+ Use wide character API when available. Use UTF-8 for filenames.
+
+ * gdk/win32/gdkselection-win32.c (_gdk_dropfiles_store): Include
+ the string's trailing zero byte in the property's length, just for
+ safety.
+
2004-12-18 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserentry.c (check_completion_callback)
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 0cce19d02..bc31f0a8c 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,12 @@
+2004-12-19 Tor Lillqvist <tml@iki.fi>
+
+ * gdk/win32/gdkdnd-win32.c (resolve_link, gdk_dropfiles_filter):
+ Use wide character API when available. Use UTF-8 for filenames.
+
+ * gdk/win32/gdkselection-win32.c (_gdk_dropfiles_store): Include
+ the string's trailing zero byte in the property's length, just for
+ safety.
+
2004-12-18 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserentry.c (check_completion_callback)
diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c
index 7b8a86c46..a646e5490 100644
--- a/gdk/win32/gdkdnd-win32.c
+++ b/gdk/win32/gdkdnd-win32.c
@@ -851,90 +851,101 @@ enum_formats_new (void)
/* From MS Knowledge Base article Q130698 */
-/* resolve_link() fills the filename and path buffer
- * with relevant information
- * hWnd - calling app's window handle.
- *
- * lpszLinkName - name of the link file passed into the function.
- *
- * lpszPath - the buffer that will receive the file pathname.
- */
-
static HRESULT
-resolve_link(HWND hWnd,
- LPCTSTR lpszLinkName,
- LPSTR lpszPath,
- LPSTR lpszDescription)
+resolve_link (HWND hWnd,
+ guchar *lpszLinkName,
+ guchar **lpszPath)
{
HRESULT hres;
- IShellLink *psl;
- WIN32_FIND_DATA wfd;
+ IShellLinkA *pslA = NULL;
+ IShellLinkW *pslW = NULL;
+ IPersistFile *ppf = NULL;
- /* Assume Failure to start with: */
+ /* Assume failure to start with: */
*lpszPath = 0;
- if (lpszDescription)
- *lpszDescription = 0;
/* Call CoCreateInstance to obtain the IShellLink interface
* pointer. This call fails if CoInitialize is not called, so it is
* assumed that CoInitialize has been called.
*/
- hres = CoCreateInstance (&CLSID_ShellLink,
- NULL,
- CLSCTX_INPROC_SERVER,
- &IID_IShellLink,
- (LPVOID *)&psl);
+ if (G_WIN32_HAVE_WIDECHAR_API ())
+ hres = CoCreateInstance (&CLSID_ShellLink,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ &IID_IShellLinkW,
+ (LPVOID *)&pslW);
+ else
+ hres = CoCreateInstance (&CLSID_ShellLink,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ &IID_IShellLinkA,
+ (LPVOID *)&pslA);
+
if (SUCCEEDED (hres))
{
- IPersistFile *ppf;
/* The IShellLink interface supports the IPersistFile
* interface. Get an interface pointer to it.
*/
- hres = psl->lpVtbl->QueryInterface (psl,
- &IID_IPersistFile,
- (LPVOID *) &ppf);
- if (SUCCEEDED (hres))
- {
- WORD wsz[MAX_PATH];
-
- /* Convert the given link name string to wide character string. */
- MultiByteToWideChar (CP_ACP, 0,
- lpszLinkName,
- -1, wsz, MAX_PATH);
- /* Load the file. */
- hres = ppf->lpVtbl->Load (ppf, wsz, STGM_READ);
- if (SUCCEEDED (hres))
- {
- /* Resolve the link by calling the Resolve()
- * interface function.
- */
- hres = psl->lpVtbl->Resolve(psl, hWnd,
- SLR_ANY_MATCH |
- SLR_NO_UI);
- if (SUCCEEDED (hres))
- {
- hres = psl->lpVtbl->GetPath (psl, lpszPath,
- MAX_PATH,
- (WIN32_FIND_DATA*)&wfd,
- 0);
-
- if (SUCCEEDED (hres) && lpszDescription != NULL)
- {
- hres = psl->lpVtbl->GetDescription (psl,
- lpszDescription,
- MAX_PATH );
-
- if (!SUCCEEDED (hres))
- return FALSE;
- }
- }
- }
- ppf->lpVtbl->Release (ppf);
- }
- psl->lpVtbl->Release (psl);
- }
+ if (G_WIN32_HAVE_WIDECHAR_API ())
+ hres = pslW->lpVtbl->QueryInterface (pslW,
+ &IID_IPersistFile,
+ (LPVOID *) &ppf);
+ else
+ hres = pslA->lpVtbl->QueryInterface (pslA,
+ &IID_IPersistFile,
+ (LPVOID *) &ppf);
+ }
+
+ if (SUCCEEDED (hres))
+ {
+ /* Convert the given link name string to wide character string. */
+ wchar_t *wsz = g_utf8_to_utf16 (lpszLinkName, -1, NULL, NULL, NULL);
+
+ /* Load the file. */
+ hres = ppf->lpVtbl->Load (ppf, wsz, STGM_READ);
+ g_free (wsz);
+ }
+
+ if (SUCCEEDED (hres))
+ {
+ /* Resolve the link by calling the Resolve()
+ * interface function.
+ */
+ if (G_WIN32_HAVE_WIDECHAR_API ())
+ hres = pslW->lpVtbl->Resolve (pslW, hWnd, SLR_ANY_MATCH | SLR_NO_UI);
+ else
+ hres = pslA->lpVtbl->Resolve (pslA, hWnd, SLR_ANY_MATCH | SLR_NO_UI);
+ }
+
+ if (SUCCEEDED (hres))
+ {
+ if (G_WIN32_HAVE_WIDECHAR_API ())
+ {
+ wchar_t wtarget[MAX_PATH];
+
+ hres = pslW->lpVtbl->GetPath (pslW, wtarget, MAX_PATH, NULL, 0);
+ if (SUCCEEDED (hres))
+ *lpszPath = g_utf16_to_utf8 (wtarget, -1, NULL, NULL, NULL);
+ }
+ else
+ {
+ guchar cptarget[MAX_PATH];
+
+ hres = pslA->lpVtbl->GetPath (pslA, cptarget, MAX_PATH, NULL, 0);
+ if (SUCCEEDED (hres))
+ *lpszPath = g_locale_to_utf8 (cptarget, -1, NULL, NULL, NULL);
+ }
+ }
+
+ if (ppf)
+ ppf->lpVtbl->Release (ppf);
+ if (pslW)
+ pslW->lpVtbl->Release (pslW);
+ if (pslA)
+ pslA->lpVtbl->Release (pslA);
+
return SUCCEEDED (hres);
}
@@ -950,7 +961,7 @@ gdk_dropfiles_filter (GdkXEvent *xev,
HANDLE hdrop;
POINT pt;
gint nfiles, i;
- guchar fileName[MAX_PATH], linkedFile[MAX_PATH];
+ guchar *fileName, *linkedFile;
if (msg->message == WM_DROPFILES)
{
@@ -987,12 +998,26 @@ gdk_dropfiles_filter (GdkXEvent *xev,
{
gchar *uri;
- DragQueryFile (hdrop, i, fileName, MAX_PATH);
+ if (G_WIN32_HAVE_WIDECHAR_API ())
+ {
+ wchar_t wfn[MAX_PATH];
+
+ DragQueryFileW (hdrop, i, wfn, MAX_PATH);
+ fileName = g_utf16_to_utf8 (wfn, -1, NULL, NULL, NULL);
+ }
+ else
+ {
+ char cpfn[MAX_PATH];
+
+ DragQueryFileA (hdrop, i, cpfn, MAX_PATH);
+ fileName = g_locale_to_utf8 (cpfn, -1, NULL, NULL, NULL);
+ }
/* Resolve shortcuts */
- if (resolve_link (msg->hwnd, fileName, linkedFile, NULL))
+ if (resolve_link (msg->hwnd, fileName, &linkedFile))
{
uri = g_filename_to_uri (linkedFile, NULL, NULL);
+ g_free (linkedFile);
if (uri != NULL)
{
g_string_append (result, uri);
@@ -1011,6 +1036,7 @@ gdk_dropfiles_filter (GdkXEvent *xev,
g_free (uri);
}
}
+ g_free (fileName);
g_string_append (result, "\015\012");
}
_gdk_dropfiles_store (result->str);
diff --git a/gdk/win32/gdkselection-win32.c b/gdk/win32/gdkselection-win32.c
index 1e22293da..924bc6da2 100644
--- a/gdk/win32/gdkselection-win32.c
+++ b/gdk/win32/gdkselection-win32.c
@@ -179,7 +179,7 @@ _gdk_dropfiles_store (gchar *data)
dropfiles_prop = g_new (GdkSelProp, 1);
dropfiles_prop->data = data;
- dropfiles_prop->length = strlen (data);
+ dropfiles_prop->length = strlen (data) + 1;
dropfiles_prop->format = 8;
dropfiles_prop->type = _text_uri_list;
}