From a9cf26f946b19982ae8f35df29fe94cf109c6a94 Mon Sep 17 00:00:00 2001 From: theAdib Date: Mon, 3 Aug 2009 21:16:32 +0000 Subject: FIX 2922232 win32 dialogue for browse file on export-bitmap dialogue, also solved the case where filename is emphty (bzr r8399) --- src/dialogs/export.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'src/dialogs/export.cpp') diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 4e235bbf5..0cde76657 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -60,6 +60,11 @@ #include "helper/png-write.h" +#ifdef WIN32 +#include +#include +#include +#endif #define SP_EXPORT_MIN_SIZE 1.0 @@ -167,7 +172,7 @@ sp_export_dialog_delete ( GtkObject */*object*/, GdkEvent */*event*/, gpointer / if (x<0) x=0; if (y<0) y=0; - + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setInt(prefs_path + "x", x); prefs->setInt(prefs_path + "y", y); @@ -1290,6 +1295,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) } // end of sp_export_export_clicked() /// Called when Browse button is clicked +/// @todo refactor this code to use ui/dialogs/filedialog.cpp static void sp_export_browse_clicked (GtkButton */*button*/, gpointer /*userdata*/) { @@ -1318,11 +1324,55 @@ sp_export_browse_clicked (GtkButton */*button*/, gpointer /*userdata*/) filename = gtk_entry_get_text (GTK_ENTRY (fe)); if (*filename == '\0') { - filename = homedir_path(NULL); + filename = create_filepath_from_id(NULL, NULL); } gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fs), filename); +#ifdef WIN32 + // code in this section is borrowed from ui/dialogs/filedialogimpl-win32.cpp + OPENFILENAMEW opf; + WCHAR* filter_string = (WCHAR*)g_utf8_to_utf16("PNG\0*.png\0\0", 12, NULL, NULL, NULL); + WCHAR* title_string = (WCHAR*)g_utf8_to_utf16(_("Select a filename for exporting"), -1, NULL, NULL, NULL); + WCHAR* extension_string = (WCHAR*)g_utf8_to_utf16("*.png", -1, NULL, NULL, NULL); + // Copy the selected file name, converting from UTF-8 to UTF-16 + WCHAR _filename[_MAX_PATH + 1]; + memset(_filename, 0, sizeof(_filename)); + gunichar2* utf16_path_string = g_utf8_to_utf16(filename, -1, NULL, NULL, NULL); + wcsncpy(_filename, (wchar_t*)utf16_path_string, _MAX_PATH); + g_free(utf16_path_string); + + opf.hwndOwner = (HWND)(GDK_WINDOW_HWND(GTK_WIDGET(dlg)->window)); + opf.lpstrFilter = filter_string; + opf.lpstrCustomFilter = 0; + opf.nMaxCustFilter = 0L; + opf.nFilterIndex = 1L; + opf.lpstrFile = _filename; + opf.nMaxFile = _MAX_PATH; + opf.lpstrFileTitle = NULL; + opf.nMaxFileTitle=0; + opf.lpstrInitialDir = 0; + opf.lpstrTitle = title_string; + opf.nFileOffset = 0; + opf.nFileExtension = 2; + opf.lpstrDefExt = extension_string; + opf.lpfnHook = NULL; + opf.lCustData = 0; + opf.Flags = OFN_PATHMUSTEXIST; + opf.lStructSize = sizeof(OPENFILENAMEW); + if (GetSaveFileNameW(&opf) != 0) + { + // Copy the selected file name, converting from UTF-16 to UTF-8 + gchar *utf8string = g_utf16_to_utf8((const gunichar2*)opf.lpstrFile, _MAX_PATH, NULL, NULL, NULL); + gtk_entry_set_text (GTK_ENTRY (fe), utf8string); + g_object_set_data (G_OBJECT (dlg), "filename", fe); + g_free(utf8string); + + } + g_free(extension_string); + g_free(title_string); + g_free(filter_string); +#else if (gtk_dialog_run (GTK_DIALOG (fs)) == GTK_RESPONSE_ACCEPT) { gchar *file; @@ -1337,6 +1387,7 @@ sp_export_browse_clicked (GtkButton */*button*/, gpointer /*userdata*/) g_free(utf8file); g_free(file); } +#endif gtk_widget_destroy (fs); -- cgit v1.2.3 From a6fa3b454bdcef9b23e0a3107b6de6b4c6a477a0 Mon Sep 17 00:00:00 2001 From: johnce Date: Wed, 5 Aug 2009 05:56:35 +0000 Subject: SPDocument->Document (bzr r8405) --- src/dialogs/export.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/dialogs/export.cpp') diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 0cde76657..56d50596c 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -538,7 +538,7 @@ sp_export_dialog (void) if (SP_ACTIVE_DOCUMENT && SP_DOCUMENT_URI (SP_ACTIVE_DOCUMENT)) { gchar *name; - SPDocument * doc = SP_ACTIVE_DOCUMENT; + Document * doc = SP_ACTIVE_DOCUMENT; const gchar *uri = SP_DOCUMENT_URI (doc); Inkscape::XML::Node * repr = sp_document_repr_root(doc); const gchar * text_extension = repr->attribute("inkscape:output_extension"); @@ -779,7 +779,7 @@ sp_export_selection_modified ( Inkscape::Application */*inkscape*/, switch (current_key) { case SELECTION_DRAWING: if ( SP_ACTIVE_DESKTOP ) { - SPDocument *doc; + Document *doc; doc = sp_desktop_document (SP_ACTIVE_DESKTOP); Geom::OptRect bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc))); if (bbox) { @@ -839,7 +839,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base) if ( SP_ACTIVE_DESKTOP ) { - SPDocument *doc; + Document *doc; Geom::OptRect bbox; doc = sp_desktop_document (SP_ACTIVE_DESKTOP); @@ -906,7 +906,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base) switch (key) { case SELECTION_PAGE: case SELECTION_DRAWING: { - SPDocument * doc = SP_ACTIVE_DOCUMENT; + Document * doc = SP_ACTIVE_DOCUMENT; sp_document_get_export_hints (doc, &filename, &xdpi, &ydpi); if (filename == NULL) { @@ -1213,7 +1213,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) switch ((selection_type)(GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(base), "selection-type")))) { case SELECTION_PAGE: case SELECTION_DRAWING: { - SPDocument * doc = SP_ACTIVE_DOCUMENT; + Document * doc = SP_ACTIVE_DOCUMENT; Inkscape::XML::Node * repr = sp_document_repr_root(doc); bool modified = false; const gchar * temp_string; @@ -1245,7 +1245,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) } case SELECTION_SELECTION: { const GSList * reprlst; - SPDocument * doc = SP_ACTIVE_DOCUMENT; + Document * doc = SP_ACTIVE_DOCUMENT; bool modified = false; bool saved = sp_document_get_undo_sensitive(doc); @@ -1466,7 +1466,7 @@ sp_export_detect_size(GtkObject * base) { } break; case SELECTION_DRAWING: { - SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP); + Document *doc = sp_desktop_document (SP_ACTIVE_DESKTOP); Geom::OptRect bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc))); @@ -1478,7 +1478,7 @@ sp_export_detect_size(GtkObject * base) { } case SELECTION_PAGE: { - SPDocument *doc; + Document *doc; doc = sp_desktop_document (SP_ACTIVE_DESKTOP); -- cgit v1.2.3 From 51c2905fd3e99955db2d823b79abb763d8097028 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Thu, 6 Aug 2009 14:17:17 +0000 Subject: Revert recent refactoring changes by johnce because they break the build, which cannot be fixed easily. (bzr r8422) --- src/dialogs/export.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/dialogs/export.cpp') diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 56d50596c..0cde76657 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -538,7 +538,7 @@ sp_export_dialog (void) if (SP_ACTIVE_DOCUMENT && SP_DOCUMENT_URI (SP_ACTIVE_DOCUMENT)) { gchar *name; - Document * doc = SP_ACTIVE_DOCUMENT; + SPDocument * doc = SP_ACTIVE_DOCUMENT; const gchar *uri = SP_DOCUMENT_URI (doc); Inkscape::XML::Node * repr = sp_document_repr_root(doc); const gchar * text_extension = repr->attribute("inkscape:output_extension"); @@ -779,7 +779,7 @@ sp_export_selection_modified ( Inkscape::Application */*inkscape*/, switch (current_key) { case SELECTION_DRAWING: if ( SP_ACTIVE_DESKTOP ) { - Document *doc; + SPDocument *doc; doc = sp_desktop_document (SP_ACTIVE_DESKTOP); Geom::OptRect bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc))); if (bbox) { @@ -839,7 +839,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base) if ( SP_ACTIVE_DESKTOP ) { - Document *doc; + SPDocument *doc; Geom::OptRect bbox; doc = sp_desktop_document (SP_ACTIVE_DESKTOP); @@ -906,7 +906,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base) switch (key) { case SELECTION_PAGE: case SELECTION_DRAWING: { - Document * doc = SP_ACTIVE_DOCUMENT; + SPDocument * doc = SP_ACTIVE_DOCUMENT; sp_document_get_export_hints (doc, &filename, &xdpi, &ydpi); if (filename == NULL) { @@ -1213,7 +1213,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) switch ((selection_type)(GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(base), "selection-type")))) { case SELECTION_PAGE: case SELECTION_DRAWING: { - Document * doc = SP_ACTIVE_DOCUMENT; + SPDocument * doc = SP_ACTIVE_DOCUMENT; Inkscape::XML::Node * repr = sp_document_repr_root(doc); bool modified = false; const gchar * temp_string; @@ -1245,7 +1245,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) } case SELECTION_SELECTION: { const GSList * reprlst; - Document * doc = SP_ACTIVE_DOCUMENT; + SPDocument * doc = SP_ACTIVE_DOCUMENT; bool modified = false; bool saved = sp_document_get_undo_sensitive(doc); @@ -1466,7 +1466,7 @@ sp_export_detect_size(GtkObject * base) { } break; case SELECTION_DRAWING: { - Document *doc = sp_desktop_document (SP_ACTIVE_DESKTOP); + SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP); Geom::OptRect bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc))); @@ -1478,7 +1478,7 @@ sp_export_detect_size(GtkObject * base) { } case SELECTION_PAGE: { - Document *doc; + SPDocument *doc; doc = sp_desktop_document (SP_ACTIVE_DESKTOP); -- cgit v1.2.3 From 606ebb35498c3d750bb2906954195baaa0fbcad6 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Sun, 9 Aug 2009 14:23:52 +0000 Subject: Fix remaining glitches in the behaviour of the Save dialogs (w.r.t. remembering the last file type and folder). As part of the cleanup inkscape:output_extension was removed, too. (bzr r8454) --- src/dialogs/export.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/dialogs/export.cpp') diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 0cde76657..835003e5e 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -540,8 +540,7 @@ sp_export_dialog (void) gchar *name; SPDocument * doc = SP_ACTIVE_DOCUMENT; const gchar *uri = SP_DOCUMENT_URI (doc); - Inkscape::XML::Node * repr = sp_document_repr_root(doc); - const gchar * text_extension = repr->attribute("inkscape:output_extension"); + const gchar *text_extension = Inkscape::Preferences::get()->getString("/dialogs/save_as/default").c_str(); Inkscape::Extension::Output * oextension = NULL; if (text_extension != NULL) { -- cgit v1.2.3 From 39559f543f4034819b2ccc3fccac1ef8c1b1b049 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Sun, 9 Aug 2009 16:43:14 +0000 Subject: Cleanup (remove unused variable; use generic function to determine the file extension) (bzr r8455) --- src/dialogs/export.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/dialogs/export.cpp') diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 835003e5e..ee7852924 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -540,7 +540,7 @@ sp_export_dialog (void) gchar *name; SPDocument * doc = SP_ACTIVE_DOCUMENT; const gchar *uri = SP_DOCUMENT_URI (doc); - const gchar *text_extension = Inkscape::Preferences::get()->getString("/dialogs/save_as/default").c_str(); + const gchar *text_extension = get_file_save_extension (Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS).c_str(); Inkscape::Extension::Output * oextension = NULL; if (text_extension != NULL) { -- cgit v1.2.3 From e6fc7252065fa1d48183d162a74013e533cf4240 Mon Sep 17 00:00:00 2001 From: bulia byak Date: Mon, 17 Aug 2009 23:09:16 +0000 Subject: fix 396851: move absolutizing relative path (added by Ted) out of sp_export_png_file and make sure it works only for rel filenames from hints (both on command line and on batch export), but not for filenames specified on command line or in export dialog; reenable export-id with export-use-hints; fix errors in string comparisons when choosing command line mode; fix crash when opening nonexistent file in command line mode (bzr r8500) --- src/dialogs/export.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/dialogs/export.cpp') diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index ee7852924..2e41850ed 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -1067,6 +1067,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) if (!SP_ACTIVE_DESKTOP) return; SPNamedView *nv = sp_desktop_namedview(SP_ACTIVE_DESKTOP); + SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP); GtkWidget *be = (GtkWidget *)gtk_object_get_data(base, "batch_checkbox"); GtkWidget *he = (GtkWidget *)gtk_object_get_data(base, "hide_checkbox"); @@ -1088,10 +1089,24 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) i != NULL; i = i->next) { SPItem *item = (SPItem *) i->data; + // retrieve export filename hint - const gchar *fn = SP_OBJECT_REPR(item)->attribute("inkscape:export-filename"); - if (!fn) { - fn = create_filepath_from_id (SP_OBJECT_ID(item), NULL); + const gchar *filename = SP_OBJECT_REPR(item)->attribute("inkscape:export-filename"); + gchar *path = 0; + if (!filename) { + path = create_filepath_from_id (SP_OBJECT_ID(item), NULL); + } else { + //Make relative paths go from the document location, if possible: + if (!g_path_is_absolute(filename) && doc->uri) { + gchar *dirname = g_path_get_dirname(doc->uri); + if (dirname) { + path = g_build_filename(dirname, filename, NULL); + g_free(dirname); + } + } + if (!path) { + path = g_strdup(filename); + } } // retrieve export dpi hints @@ -1112,14 +1127,14 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) if (width > 1 && height > 1) { /* Do export */ - if (!sp_export_png_file (sp_desktop_document (SP_ACTIVE_DESKTOP), fn, + if (!sp_export_png_file (doc, path, *area, width, height, dpi, dpi, nv->pagecolor, NULL, NULL, TRUE, // overwrite without asking hide ? (GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList() : NULL )) { gchar * error; - gchar * safeFile = Inkscape::IO::sanitizeString(fn); + gchar * safeFile = Inkscape::IO::sanitizeString(path); error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile); sp_ui_error_dialog(error); g_free(safeFile); @@ -1128,6 +1143,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) } } n++; + g_free(path); sp_export_progress_callback((float)n/num, base); } @@ -1178,9 +1194,9 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) gtk_entry_set_text(GTK_ENTRY(fe), filename_ext); gchar *fn = g_path_get_basename (filename_ext); - gchar *progress_text = g_strdup_printf (_("Exporting %s (%lu x %lu)"), fn, width, height); g_free (fn); + GtkWidget *prog_dlg = create_progress_dialog (base, progress_text); g_free (progress_text); -- cgit v1.2.3 From 77fcf0fd68cb88879c317a41c59b7ab3a2bbb751 Mon Sep 17 00:00:00 2001 From: bulia byak Date: Fri, 21 Aug 2009 15:26:16 +0000 Subject: absolutize user-entered path from doc location (bzr r8514) --- src/dialogs/export.cpp | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) (limited to 'src/dialogs/export.cpp') diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 2e41850ed..ce0786a01 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -1060,6 +1060,23 @@ filename_add_extension (const gchar *filename, const gchar *extension) } } +gchar *absolutize_path_from_document_location (SPDocument *doc, const gchar *filename) +{ + gchar *path = 0; + //Make relative paths go from the document location, if possible: + if (!g_path_is_absolute(filename) && doc->uri) { + gchar *dirname = g_path_get_dirname(doc->uri); + if (dirname) { + path = g_build_filename(dirname, filename, NULL); + g_free(dirname); + } + } + if (!path) { + path = g_strdup(filename); + } + return path; +} + /// Called when export button is clicked static void sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) @@ -1096,17 +1113,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) if (!filename) { path = create_filepath_from_id (SP_OBJECT_ID(item), NULL); } else { - //Make relative paths go from the document location, if possible: - if (!g_path_is_absolute(filename) && doc->uri) { - gchar *dirname = g_path_get_dirname(doc->uri); - if (dirname) { - path = g_build_filename(dirname, filename, NULL); - g_free(dirname); - } - } - if (!path) { - path = g_strdup(filename); - } + path = absolutize_path_from_document_location(doc, filename); } // retrieve export dpi hints @@ -1174,7 +1181,13 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) return; } - gchar *dirname = g_path_get_dirname(filename); + // make sure that .png is the extension of the file: + gchar * filename_ext = filename_add_extension(filename, "png"); + gtk_entry_set_text(GTK_ENTRY(fe), filename_ext); + + gchar *path = absolutize_path_from_document_location(doc, filename_ext); + + gchar *dirname = g_path_get_dirname(path); if ( dirname == NULL || !Inkscape::IO::file_test(dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) ) { @@ -1185,15 +1198,12 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) g_free(safeDir); g_free(error); g_free(dirname); + g_free(path); return; } g_free(dirname); - // make sure that .png is the extension of the file: - gchar * filename_ext = filename_add_extension(filename, "png"); - gtk_entry_set_text(GTK_ENTRY(fe), filename_ext); - - gchar *fn = g_path_get_basename (filename_ext); + gchar *fn = g_path_get_basename (path); gchar *progress_text = g_strdup_printf (_("Exporting %s (%lu x %lu)"), fn, width, height); g_free (fn); @@ -1201,14 +1211,14 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) g_free (progress_text); /* Do export */ - if (!sp_export_png_file (sp_desktop_document (SP_ACTIVE_DESKTOP), filename_ext, + if (!sp_export_png_file (sp_desktop_document (SP_ACTIVE_DESKTOP), path, Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi, nv->pagecolor, sp_export_progress_callback, base, FALSE, hide ? (GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList() : NULL )) { gchar * error; - gchar * safeFile = Inkscape::IO::sanitizeString(filename); + gchar * safeFile = Inkscape::IO::sanitizeString(path); error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile); sp_ui_error_dialog(error); g_free(safeFile); @@ -1304,6 +1314,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) } g_free (filename_ext); + g_free (path); } -- cgit v1.2.3 From 338d3664cbe9c56464338c45c420c9618229e731 Mon Sep 17 00:00:00 2001 From: Josh Andler Date: Tue, 22 Sep 2009 20:21:38 +0000 Subject: Patch by Adib for 431022. Appears safe, however, I am unable to test as it is/was a win32 issue only. (bzr r8631) --- src/dialogs/export.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/dialogs/export.cpp') diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index ce0786a01..adadcd2f6 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -1358,7 +1358,7 @@ sp_export_browse_clicked (GtkButton */*button*/, gpointer /*userdata*/) #ifdef WIN32 // code in this section is borrowed from ui/dialogs/filedialogimpl-win32.cpp OPENFILENAMEW opf; - WCHAR* filter_string = (WCHAR*)g_utf8_to_utf16("PNG\0*.png\0\0", 12, NULL, NULL, NULL); + WCHAR* filter_string = (WCHAR*)g_utf8_to_utf16("PNG\0*.png\0", 10, NULL, NULL, NULL); WCHAR* title_string = (WCHAR*)g_utf8_to_utf16(_("Select a filename for exporting"), -1, NULL, NULL, NULL); WCHAR* extension_string = (WCHAR*)g_utf8_to_utf16("*.png", -1, NULL, NULL, NULL); // Copy the selected file name, converting from UTF-8 to UTF-16 -- cgit v1.2.3 From e313aed76c3bc76bbdd3b99c1a2afbed58db7da7 Mon Sep 17 00:00:00 2001 From: Josh Andler Date: Wed, 23 Sep 2009 13:23:33 +0000 Subject: Better patch by Adib for 431022. Appears safe, however, I am unable to test as it is/was a win32 issue only. (bzr r8635) --- src/dialogs/export.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/dialogs/export.cpp') diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index adadcd2f6..2c04135bc 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -1358,7 +1358,11 @@ sp_export_browse_clicked (GtkButton */*button*/, gpointer /*userdata*/) #ifdef WIN32 // code in this section is borrowed from ui/dialogs/filedialogimpl-win32.cpp OPENFILENAMEW opf; - WCHAR* filter_string = (WCHAR*)g_utf8_to_utf16("PNG\0*.png\0", 10, NULL, NULL, NULL); + WCHAR filter_string[20]; + wcsncpy(filter_string, L"PNG#*.png##", 11); + filter_string[3] = L'\0'; + filter_string[9] = L'\0'; + filter_string[10] = L'\0'; WCHAR* title_string = (WCHAR*)g_utf8_to_utf16(_("Select a filename for exporting"), -1, NULL, NULL, NULL); WCHAR* extension_string = (WCHAR*)g_utf8_to_utf16("*.png", -1, NULL, NULL, NULL); // Copy the selected file name, converting from UTF-8 to UTF-16 @@ -1397,7 +1401,7 @@ sp_export_browse_clicked (GtkButton */*button*/, gpointer /*userdata*/) } g_free(extension_string); g_free(title_string); - g_free(filter_string); + #else if (gtk_dialog_run (GTK_DIALOG (fs)) == GTK_RESPONSE_ACCEPT) { -- cgit v1.2.3