X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fui%2Fdialog%2Ffiledialogimpl-win32.cpp;h=ed257a49a68f23ee7143ee23d4712afcbc5376a4;hb=238893a45781289c11985fe83f5ce18d4af3ec5b;hp=354d673bc3964106800deea73be3d3a2264e1c13;hpb=78a4fd75621ab829ed0005b043f7262ebec13f69;p=inkscape.git diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 354d673bc..ed257a49a 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -40,7 +40,7 @@ #include #include #include "sp-item.h" -#include "canvas-arena.h" +#include "display/canvas-arena.h" #include "filedialog.h" #include "filedialogimpl-win32.h" @@ -110,6 +110,7 @@ FileDialogBaseWin32::FileDialogBaseWin32(Gtk::Window &parent, _filter_count = 0; _title = (wchar_t*)g_utf8_to_utf16(title, -1, NULL, NULL, NULL); + g_assert(_title != NULL); Glib::RefPtr parentWindow = parent.get_window(); g_assert(parentWindow->gobj() != NULL); @@ -164,6 +165,8 @@ FileOpenDialogImplWin32::FileOpenDialogImplWin32(Gtk::Window &parent, _preview_document_height = 0; _preview_image_width = 0; _preview_image_height = 0; + + _mutex = NULL; createFilterMenu(); } @@ -208,7 +211,7 @@ void FileOpenDialogImplWin32::createFilterMenu() if (imod->deactivated()) continue; // Type - filter.name = g_utf8_to_utf16(imod->get_filetypename(), + filter.name = g_utf8_to_utf16(_(imod->get_filetypename()), -1, NULL, &filter.name_length, NULL); // Extension @@ -241,28 +244,28 @@ void FileOpenDialogImplWin32::createFilterMenu() _extension_map = new Inkscape::Extension::Extension*[filter_count]; // Filter Image Files - all_image_files.name = g_utf8_to_utf16(_(all_image_files_filter_name), + all_image_files.name = g_utf8_to_utf16(all_image_files_filter_name, -1, NULL, &all_image_files.name_length, NULL); all_image_files.filter = g_utf8_to_utf16(all_image_files_filter.data(), -1, NULL, &all_image_files.filter_length, NULL); + all_image_files.mod = NULL; filter_list.push_front(all_image_files); - _extension_map[extension_index++] = NULL; // Filter Inkscape Files - all_inkscape_files.name = g_utf8_to_utf16(_(all_inkscape_files_filter_name), + all_inkscape_files.name = g_utf8_to_utf16(all_inkscape_files_filter_name, -1, NULL, &all_inkscape_files.name_length, NULL); all_inkscape_files.filter = g_utf8_to_utf16(all_inkscape_files_filter.data(), -1, NULL, &all_inkscape_files.filter_length, NULL); + all_inkscape_files.mod = NULL; filter_list.push_front(all_inkscape_files); - _extension_map[extension_index++] = NULL; // Filter All Files - all_files.name = g_utf8_to_utf16(_(all_files_filter_name), + all_files.name = g_utf8_to_utf16(all_files_filter_name, -1, NULL, &all_files.name_length, NULL); all_files.filter = NULL; all_files.filter_length = 0; + all_files.mod = NULL; filter_list.push_front(all_files); - _extension_map[extension_index++] = NULL; filter_length += all_files.name_length + 3 + all_inkscape_files.filter_length + @@ -270,17 +273,16 @@ void FileOpenDialogImplWin32::createFilterMenu() all_image_files.filter_length + all_image_files.name_length + 3 + 1; // Add 3 for 2*2 \0s and a *, and 1 for a trailing \0 - - - _filter = new wchar_t[filter_length]; + + _filter = new wchar_t[filter_length]; wchar_t *filterptr = _filter; - + for(list::iterator filter_iterator = filter_list.begin(); filter_iterator != filter_list.end(); filter_iterator++) { const Filter &filter = *filter_iterator; - memcpy(filterptr, filter.name, filter.name_length * 2); + wcsncpy(filterptr, (wchar_t*)filter.name, filter.name_length); filterptr += filter.name_length; g_free(filter.name); @@ -289,7 +291,7 @@ void FileOpenDialogImplWin32::createFilterMenu() if(filter.filter != NULL) { - memcpy(filterptr, filter.filter, filter.filter_length * 2); + wcsncpy(filterptr, (wchar_t*)filter.filter, filter.filter_length); filterptr += filter.filter_length; g_free(filter.filter); } @@ -300,9 +302,9 @@ void FileOpenDialogImplWin32::createFilterMenu() _extension_map[extension_index++] = filter.mod; } *(filterptr++) = L'\0'; - + _filter_count = extension_index; - _filter_index = 2; // Select the 2nd filter in the list - NOT the 3rd + _filter_index = 2; // Select the 2nd filter in the list - 2 is NOT the 3rd } void FileOpenDialogImplWin32::GetOpenFileName_thread() @@ -310,9 +312,11 @@ void FileOpenDialogImplWin32::GetOpenFileName_thread() OPENFILENAMEEXW ofn; g_assert(this != NULL); + g_assert(_mutex != NULL); WCHAR* current_directory_string = (WCHAR*)g_utf8_to_utf16( - _current_directory.data(), -1, NULL, NULL, NULL); + _current_directory.data(), _current_directory.length(), + NULL, NULL, NULL); memset(&ofn, 0, sizeof(ofn)); @@ -343,8 +347,6 @@ void FileOpenDialogImplWin32::GetOpenFileName_thread() _filter_index = ofn.nFilterIndex; _extension = _extension_map[ofn.nFilterIndex - 1]; - myFilename = utf16_to_ustring(_path_string, _MAX_PATH); - // Copy the selected file name, converting from UTF-16 to UTF-8 myFilename = utf16_to_ustring(_path_string, _MAX_PATH); @@ -434,7 +436,7 @@ UINT_PTR CALLBACK FileOpenDialogImplWin32::GetOpenFileName_hookproc( pImpl->_file_dialog_wnd = hParentWnd; pImpl->_preview_wnd = - CreateWindow(PreviewWindowClassName, "", + CreateWindowA(PreviewWindowClassName, "", WS_CHILD | WS_VISIBLE, 0, 0, 100, 100, hParentWnd, NULL, hInstance, NULL); SetWindowLongPtr(pImpl->_preview_wnd, GWLP_USERDATA, ofn->lCustData); @@ -465,8 +467,6 @@ UINT_PTR CALLBACK FileOpenDialogImplWin32::GetOpenFileName_hookproc( pImpl->_file_selected = true; pImpl->_mutex->unlock(); - - //pImpl->file_selected(); } } break; @@ -558,7 +558,6 @@ LRESULT CALLBACK FileOpenDialogImplWin32::preview_wnd_proc(HWND hwnd, UINT uMsg, pImpl->_mutex->lock(); - //FillRect(dc, &client_rect, (HBRUSH)(COLOR_HOTLIGHT+1)); if(pImpl->_path_string[0] == 0) { FillRect(dc, &rcClient, (HBRUSH)(COLOR_3DFACE + 1)); @@ -874,7 +873,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() arena, key, SP_ITEM_SHOW_DISPLAY); NRGC gc(NULL); - nr_matrix_set_scale(&gc.transform, scaleFactor, scaleFactor); + gc.transform = NR::Matrix(NR::scale(scaleFactor, scaleFactor)); nr_arena_item_invoke_update (root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); @@ -1276,7 +1275,7 @@ void FileSaveDialogImplWin32::createFilterMenu() Inkscape::Extension::db.get_output_list(extension_list); int filter_count = 0; - int filter_length = 0; + int filter_length = 1; for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin(); current_item != extension_list.end(); current_item++) @@ -1296,7 +1295,7 @@ void FileSaveDialogImplWin32::createFilterMenu() // Type filter.name = g_utf8_to_utf16( - omod->get_filetypename(), -1, NULL, &filter.name_length, NULL); + _(omod->get_filetypename()), -1, NULL, &filter.name_length, NULL); filter.mod = omod; @@ -1317,14 +1316,14 @@ void FileSaveDialogImplWin32::createFilterMenu() { const Filter &filter = *filter_iterator; - memcpy(filterptr, filter.name, filter.name_length * 2); + wcsncpy(filterptr, (wchar_t*)filter.name, filter.name_length); filterptr += filter.name_length; g_free(filter.name); *(filterptr++) = L'\0'; *(filterptr++) = L'*'; - memcpy(filterptr, filter.filter, filter.filter_length * 2); + wcsncpy(filterptr, (wchar_t*)filter.filter, filter.filter_length); filterptr += filter.filter_length; g_free(filter.filter); @@ -1346,8 +1345,9 @@ void FileSaveDialogImplWin32::GetSaveFileName_thread() g_assert(this != NULL); g_assert(_main_loop != NULL); - gunichar2* current_directory_string = g_utf8_to_utf16( - _current_directory.data(), -1, NULL, NULL, NULL); + WCHAR* current_directory_string = (WCHAR*)g_utf8_to_utf16( + _current_directory.data(), _current_directory.length(), + NULL, NULL, NULL); // Copy the selected file name, converting from UTF-8 to UTF-16 memset(_path_string, 0, sizeof(_path_string)); @@ -1364,7 +1364,7 @@ void FileSaveDialogImplWin32::GetSaveFileName_thread() ofn.nFilterIndex = _filter_index; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; - ofn.lpstrInitialDir = (wchar_t*)current_directory_string; + ofn.lpstrInitialDir = current_directory_string; ofn.lpstrTitle = _title; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; ofn.lpstrFilter = _filter; @@ -1396,13 +1396,16 @@ FileSaveDialogImplWin32::show() _result = false; _main_loop = g_main_loop_new(g_main_context_default(), FALSE); - - if(Glib::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread), true)) - g_main_loop_run(_main_loop); - - if(_result) - appendExtension(myFilename, (Inkscape::Extension::Output*)_extension); - + + if(_main_loop != NULL) + { + if(Glib::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread), true)) + g_main_loop_run(_main_loop); + + if(_result) + appendExtension(myFilename, (Inkscape::Extension::Output*)_extension); + } + return _result; }