
Hello! --- bulia byak <buliabyak@...400...> wrote:
Thanks, I haven't tested it yet, but:
I found a bug due to g_free() of a const pointer, and fixed it with a g_strdup().
Can you please submit a second version with these problems fixed?
Here it is! I got the Inkscape code from CVS today, and its the latest version Ive patched.
Hope it helps, and makes to the CVS.
Thanks Muthu --------------------------------------------------------- Patch -------------- --- /sources/inkscape/src/file.cpp 2005-06-11 12:26:31.000000000 +0530 +++ ./inkscape/src/file.cpp 2005-06-20 10:53:34.000000000 +0530 @@ -333,6 +333,7 @@ static Inkscape::UI::Dialogs::FileOpenDi
/** * Display an file Open selector. Open a document if OK is pressed. + * Can also select open single or multiple files. */ void sp_file_open_dialog(gpointer object, gpointer data) @@ -367,6 +368,66 @@ sp_file_open_dialog(gpointer object, gpo g_free(open_path);
if (!success) return; + + // Code to check & open iff multiple files. + Glib::SListHandleGlib::ustring flist=openDialogInstance->getFilenames(); + GSList *list=flist.data(); + + if(g_slist_length(list)>1) + { + gchar *fileName=NULL; + + while(list!=NULL) + { + +#ifdef INK_DUMP_FILENAME_CONV + g_message(" FileName: %s",(const char *)list->data); +#endif + + fileName=(gchar *)g_strdup((gchar *)list->data); + + if (fileName && !g_file_test(fileName,G_FILE_TEST_IS_DIR)) { + gsize bytesRead = 0; + gsize bytesWritten = 0; + GError *error = NULL; +#ifdef INK_DUMP_FILENAME_CONV + dump_str( fileName, "A file pre is " ); +#endif + gchar *newFileName = g_filename_to_utf8(fileName, + -1, + &bytesRead, + &bytesWritten, + &error); + if ( newFileName != NULL ) { + g_free(fileName); + fileName = newFileName; +#ifdef INK_DUMP_FILENAME_CONV + dump_str( fileName, "A file post is " ); +#endif + } else { + // TODO: bulia, please look over + g_warning( "ERROR CONVERTING OPEN FILENAME TO UTF-8" ); + } + +#ifdef INK_DUMP_FILENAME_CONV + g_message("Opening File %s\n",fileName); +#endif + + sp_file_open(fileName, selection); + g_free(fileName); + } + else + { + g_message("Cannot Open Directory %s\n",fileName); + } + + list=list->next; + } + + return; + } + + if (fileName) { gsize bytesRead = 0; gsize bytesWritten = 0; --- /sources/inkscape/src/dialogs/filedialog.cpp 2005-04-03 02:54:51.000000000 +0530 +++ ./inkscape/src/dialogs/filedialog.cpp 2005-06-20 09:08:10.000000000 +0530 @@ -616,7 +616,7 @@ public:
gchar *getFilename();
- + Glib::SListHandleGlib::ustring getFilenames (); protected:
@@ -818,7 +818,8 @@ FileOpenDialogImpl::FileOpenDialogImpl(c
/* One file at a time */ - set_select_multiple(false); + /* And also Multiple Files */ + set_select_multiple(true);
/* Initalize to Autodetect */ extension = NULL; @@ -947,7 +948,13 @@ FileOpenDialogImpl::getFilename (void) }
- +/** + * To GetMultiple filenames selected at-once. + */ +Glib::SListHandleGlib::ustringFileOpenDialogImpl::getFilenames() +{ + return get_filenames(); +}
--- /sources/inkscape/src/dialogs/filedialog.h 2004-12-25 06:00:27.000000000 +0530 +++ ./inkscape/src/dialogs/filedialog.h 2005-06-20 09:04:16.000000000 +0530 @@ -89,6 +89,8 @@ public:
virtual gchar * getFilename () =0;
+ virtual Glib::SListHandleGlib::ustring getFilenames () = 0; + }; //FileOpenDialog
__________________________________ Yahoo! Mail Stay connected, organized, and protected. Take the tour: http://tour.mail.yahoo.com/mailtour.html