index db49b4a8668521a28970cf3d1208874d926eb175..354d673bc3964106800deea73be3d3a2264e1c13 100644 (file)
parent(parent),
_current_directory(dir)
{
- //_mutex = NULL;
_main_loop = NULL;
+ _filter_index = 1;
+ _filter_count = 0;
+
_title = (wchar_t*)g_utf8_to_utf16(title, -1, NULL, NULL, NULL);
Glib::RefPtr<const Gdk::Window> parentWindow = parent.get_window();
}
*(filterptr++) = L'\0';
- _filterIndex = 2;
+ _filter_count = extension_index;
+ _filter_index = 2; // Select the 2nd filter in the list - NOT the 3rd
}
void FileOpenDialogImplWin32::GetOpenFileName_thread()
OPENFILENAMEEXW ofn;
g_assert(this != NULL);
- //g_assert(_mutex != NULL);
- g_assert(_main_loop != NULL);
-
+
WCHAR* current_directory_string = (WCHAR*)g_utf8_to_utf16(
_current_directory.data(), -1, NULL, NULL, NULL);
ofn.lpstrTitle = _title;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_HIDEREADONLY | OFN_ENABLESIZING;
ofn.lpstrFilter = _filter;
- ofn.nFilterIndex = _filterIndex;
+ ofn.nFilterIndex = _filter_index;
ofn.lpfnHook = GetOpenFileName_hookproc;
ofn.lCustData = (LPARAM)this;
_result = GetOpenFileNameW(&ofn) != 0;
- _filterIndex = ofn.nFilterIndex;
- _extension = _extension_map[ofn.nFilterIndex];
+ g_assert(ofn.nFilterIndex >= 1 && ofn.nFilterIndex <= _filter_count);
+ _filter_index = ofn.nFilterIndex;
+ _extension = _extension_map[ofn.nFilterIndex - 1];
myFilename = utf16_to_ustring(_path_string, _MAX_PATH);
_mutex->lock();
_finished = true;
_mutex->unlock();
- //g_main_loop_quit(_main_loop);
-
-
}
void FileOpenDialogImplWin32::register_preview_wnd_class()
context->stroke_preserve();
// Draw the image
-
if(_preview_bitmap_image) // Is the image a pixbuf?
{
// Set the transformation
FileOpenDialogImplWin32::show()
{
// We can only run one worker thread at a time
- //if(_mutex != NULL) return false;
+ if(_mutex != NULL) return false;
if(!Glib::thread_supported())
Glib::thread_init();
Sleep(10);
}
- //g_main_loop_run(_main_loop);
}
// Tidy up
const Glib::ustring &/*default_key*/) :
FileDialogBaseWin32(parent, dir, title, fileTypes, "dialogs.save_as")
{
- _main_loop = NULL;
-
createFilterMenu();
}
}
*(filterptr++) = 0;
- _filterIndex = 0;
+ _filter_count = extension_index;
+ _filter_index = 1; // A value of 1 selects the 1st filter - NOT the 2nd
}
void FileSaveDialogImplWin32::GetSaveFileName_thread()
OPENFILENAMEEXW ofn;
g_assert(this != NULL);
- //g_assert(_mutex != NULL);
g_assert(_main_loop != NULL);
gunichar2* current_directory_string = g_utf8_to_utf16(
ofn.hwndOwner = _ownerHwnd;
ofn.lpstrFile = _path_string;
ofn.nMaxFile = _MAX_PATH;
- ofn.nFilterIndex = _filterIndex;
+ ofn.nFilterIndex = _filter_index;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = (wchar_t*)current_directory_string;
ofn.lpstrTitle = _title;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
ofn.lpstrFilter = _filter;
- ofn.nFilterIndex = _filterIndex;
+ ofn.nFilterIndex = _filter_index;
_result = GetSaveFileNameW(&ofn) != 0;
- _filterIndex = ofn.nFilterIndex;
- _extension = _extension_map[ofn.nFilterIndex];
+ g_assert(ofn.nFilterIndex >= 1 && ofn.nFilterIndex <= _filter_count);
+ _filter_index = ofn.nFilterIndex;
+ _extension = _extension_map[ofn.nFilterIndex - 1];
// Copy the selected file name, converting from UTF-16 to UTF-8
myFilename = utf16_to_ustring(_path_string, _MAX_PATH);
- //_mutex->lock();
- //_finished = true;
- //_mutex->unlock();
-
-
// Tidy up
g_free(current_directory_string);
bool
FileSaveDialogImplWin32::show()
{
- // We can only run one worker thread at a time
- //if(_mutex != NULL) return false;
-
if(!Glib::thread_supported())
Glib::thread_init();
_result = false;
- //_finished = false;
- //_mutex = new Glib::Mutex();
_main_loop = g_main_loop_new(g_main_context_default(), FALSE);
if(Glib::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread), true))
- {
- /*while(1)
- {
- // While the dialog runs - keep the main UI alive
- g_main_context_iteration(g_main_context_default(), FALSE);
-
- if(_mutex->trylock())
- {
- if(_finished) break;
- _mutex->unlock();
- }
-
- Sleep(10);
- }*/
g_main_loop_run(_main_loop);
- }
- //delete _mutex;
- //_mutex = NULL;
if(_result)
appendExtension(myFilename, (Inkscape::Extension::Output*)_extension);