summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6d08571)
raw | patch | inline | side by side (parent: 6d08571)
author | joelholdsworth <joelholdsworth@users.sourceforge.net> | |
Thu, 28 Feb 2008 16:37:08 +0000 (16:37 +0000) | ||
committer | joelholdsworth <joelholdsworth@users.sourceforge.net> | |
Thu, 28 Feb 2008 16:37:08 +0000 (16:37 +0000) |
src/ui/dialog/filedialogimpl-win32.cpp | patch | blob | history | |
src/ui/dialog/filedialogimpl-win32.h | patch | blob | history |
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);
index fd0d1c259a8c04175b8e6ecb6bd923ce1d73ef7f..9de49019346927a9dd2773853bef52f69581d63f 100644 (file)
protected:
/// The dialog type
FileDialogType dialogType;
-
- /// This mutex is used to ensure that the worker thread
- /// that calls GetOpenFileName cannot collide with the
- /// main Inkscape thread
- Glib::Mutex *_mutex;
-
- /// This flag is set true when the GetOpenFileName call
- /// has returned
- bool _finished;
-
- /// A pointer to the GTK main-loop context object. This
+
+ /// A pointer to the GTK main-loop context object. This
/// is used to keep the rest of the inkscape UI running
/// while the file dialog is displayed
GMainLoop *_main_loop;
/// The filter string for GetOpenFileName in UTF-16
wchar_t *_filter;
- /// The index of the currently selected filter
- int _filterIndex;
+ /// The index of the currently selected filter.
+ /// This value must be greater than or equal to 1,
+ /// and less than or equal to _filter_count.
+ int _filter_index;
+
+ /// The number of filters registered
+ int _filter_count;
/// An array of the extensions associated with the
/// file types of each filter. So the Nth entry of
/// filter in the list. NULL if no specific extension is
/// specified/
Inkscape::Extension::Extension **_extension_map;
-
- /// The currently selected extension. Valid after an [OK]
+
+ /// The currently selected extension. Valid after an [OK]
Inkscape::Extension::Extension *_extension;
};
/// This flag is set true if a file has been selected
bool _file_selected;
+
+ /// This flag is set true when the GetOpenFileName call
+ /// has returned
+ bool _finished;
+
+ /// This mutex is used to ensure that the worker thread
+ /// that calls GetOpenFileName cannot collide with the
+ /// main Inkscape thread
+ Glib::Mutex *_mutex;
/// The controller function for the thread which calls
private:
- /**
- * Create a filter menu for this type of dialog
- */
+ /// Create a filter menu for this type of dialog
void createFilterMenu();
+ /// The controller function for the thread which calls
+ /// GetSaveFileName
void GetSaveFileName_thread();
+
};