filedialog-win32.cpp revision f4f507228b30d55fd7e39386ba513f3a0a54bd5d
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "filedialog.h"
#include <windows.h>
#include <glib.h>
#include <extension/extension.h>
#define UNSAFE_SCRATCH_BUFFER_SIZE 4096
namespace Inkscape
{
namespace UI
{
namespace Dialogs
{
/*#################################
# U T I L I T Y
#################################*/
static gboolean
{
static OSVERSIONINFOA osver;
if ( !initialized )
{
initialized = TRUE;
if (result)
{
}
// If we can't even call to get the version, fall back to ANSI API
}
return is_wide;
}
/*#################################
# F I L E O P E N
#################################*/
struct FileOpenNativeData_def {
char *dir;
char *title;
};
nativeData = (FileOpenNativeData *)
g_malloc(sizeof (FileOpenNativeData));
if ( !nativeData ) {
// do we want exceptions?
return;
}
if ( !dir )
dir = "";
}
FileOpenDialog::~FileOpenDialog() {
//do any cleanup here
if ( nativeData ) {
}
}
bool
FileOpenDialog::show() {
if ( !nativeData ) {
//error
return FALSE;
}
//Jon's UNICODE patch
if ( win32_is_os_wide() ) {
L"SVG files\0*.svg\0"
L"All files\0*\0";
OPENFILENAMEW ofn = {
sizeof (OPENFILENAMEW),
NULL, // hwndOwner
NULL, // hInstance
NULL, // lpstrCustomFilter
0, // nMaxCustFilter
1, // nFilterIndex
NULL, // lpstrFileTitle
0, // nMaxFileTitle
0, // nFileOffset
0, // nFileExtension
NULL, // lpstrDefExt
0, // lCustData
NULL, // lpfnHook
NULL // lpTemplateName
};
if (retval)
} else {
filter = "SVG files\0*.svg;*.svgz\0All files\0*\0";
filter = "Image files\0*.svg;*.png;*.jpg;*.jpeg;*.bmp;*.gif;*.tiff;*.xpm\0"
"SVG files\0*.svg\0"
"All files\0*\0";
OPENFILENAMEA ofn = {
sizeof (OPENFILENAMEA),
NULL, // hwndOwner
NULL, // hInstance
NULL, // lpstrCustomFilter
0, // nMaxCustFilter
1, // nFilterIndex
fnbuf, // lpstrFile
sizeof (fnbuf), // nMaxFile
NULL, // lpstrFileTitle
0, // nMaxFileTitle
0, // nFileOffset
0, // nFileExtension
NULL, // lpstrDefExt
0, // lCustData
NULL, // lpfnHook
NULL // lpTemplateName
};
if ( retval ) {
/* ### We need to try something like this instead:
GError *err = NULL;
filename = g_filename_to_utf8(fnbuf, -1, NULL, NULL, &err);
if ( !filename && err ) {
g_warning("Charset conversion in show()[%d]%s\n",
err->code, err->message);
}
*/
}
}
if ( !retval ) {
//int errcode = CommDlgExtendedError();
return FALSE;
}
return TRUE;
}
/*#################################
# F I L E S A V E
#################################*/
struct FileSaveNativeData_def {
};
nativeData = (FileSaveNativeData *)
g_malloc(sizeof (FileSaveNativeData));
if ( !nativeData ) {
//do we want exceptions?
return;
}
int default_item = 0;
/* Make up the filter string for the save dialogue using the list
** of available output types.
*/
int N = UNSAFE_SCRATCH_BUFFER_SIZE;
int n = 1;
if (!d->sensitive)
continue;
N -= w + 1;
p += w + 1;
w = snprintf (p, N, "*");
N -= w + 1;
p += w + 1;
g_assert (N >= 0);
/* Look to see if this extension is the default */
if (default_key &&
default_item = n;
}
n++;
}
*p = '\0';
if (dir) {
/* We must check that dir is not something like
** c:\foo\ (ie with a trailing \). If it is,
** GetSaveFileName will give an error.
*/
}
}
OPENFILENAME ofn = {
sizeof (OPENFILENAME),
NULL, // hwndOwner
NULL, // hInstance
NULL, // lpstrCustomFilter
0, // nMaxCustFilter
default_item, // nFilterIndex
NULL, // lpstrFileTitle
0, // nMaxFileTitle
0, // nFileOffset
0, // nFileExtension
NULL, // lpstrDefExt
0, // lCustData
NULL, // lpfnHook
NULL // lpTemplateName
};
}
FileSaveDialog::~FileSaveDialog() {
//do any cleanup here
}
bool
FileSaveDialog::show() {
if (!nativeData)
return FALSE;
if (!retval) {
//int errcode = CommDlgExtendedError();
return FALSE;
}
/* Work out which extension corresponds to the user's choice of
** file type.
*/
while (n > 0 && i) {
n--;
i = g_slist_next(i);
}
return TRUE;
}
} //namespace Dialogs
} //namespace UI
} //namespace Inkscape