From aaa93ae0438cbcdbe73b69ff976155ce861dac09 Mon Sep 17 00:00:00 2001 From: dooglus Date: Tue, 18 Sep 2007 12:54:44 +0000 Subject: [PATCH] Implement feature request 1741236: Use 'Synfig Animation N' (N=1,2,3,...) rather than 'untitledN' (N=0,1,2,...) as the default file name. Put the default name in the file selector dialog when saving. git-svn-id: http://svn.voria.com/code@708 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-studio/trunk/src/gtkmm/app.cpp | 18 ++++++++++++++---- synfig-studio/trunk/src/gtkmm/instance.cpp | 5 ++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/synfig-studio/trunk/src/gtkmm/app.cpp b/synfig-studio/trunk/src/gtkmm/app.cpp index 238e339..5444784 100644 --- a/synfig-studio/trunk/src/gtkmm/app.cpp +++ b/synfig-studio/trunk/src/gtkmm/app.cpp @@ -1821,10 +1821,20 @@ App::dialog_save_file(const std::string &title, std::string &filename) dialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); dialog->add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); if(!filename.empty()) + { + std::string full_path; if (is_absolute_path(filename)) - dialog->set_filename(filename); + full_path = filename; else - dialog->set_filename(prev_path + ETL_DIRECTORY_SEPARATOR + filename); + full_path = prev_path + ETL_DIRECTORY_SEPARATOR + filename; + // select the file if it exists + dialog->set_filename(full_path); + + // if the file doesn't exist, put its name into the filename box + struct stat s; + if(stat(full_path.c_str(),&s) == -1 && errno == ENOENT) + dialog->set_current_name(basename(filename)); + } if(dialog->run()==GTK_RESPONSE_ACCEPT) { filename=dialog->get_filename(); delete dialog; @@ -1999,9 +2009,9 @@ void App::new_instance() { handle canvas=synfig::Canvas::create(); - canvas->set_name(strprintf("Untitled%d",Instance::get_count())); + canvas->set_name(strprintf("Synfig Animation %d",Instance::get_count()+1)); - String file_name(strprintf("untitled%d.sif",Instance::get_count())); + String file_name(strprintf("Synfig Animation %d.sifz",Instance::get_count()+1)); canvas->rend_desc().set_frame_rate(24.0); canvas->rend_desc().set_time_start(0.0); diff --git a/synfig-studio/trunk/src/gtkmm/instance.cpp b/synfig-studio/trunk/src/gtkmm/instance.cpp index a67d7f7..122e96b 100644 --- a/synfig-studio/trunk/src/gtkmm/instance.cpp +++ b/synfig-studio/trunk/src/gtkmm/instance.cpp @@ -198,7 +198,7 @@ studio::Instance::save_as(const synfig::String &file_name) bool studio::Instance::save() { - if(basename(get_file_name()).find("untitled")==0) + if(basename(get_file_name()).find("Synfig Animation")==0) { dialog_save_as(); return true; @@ -211,8 +211,7 @@ studio::Instance::save() void studio::Instance::dialog_save_as() { - string filename="*.sif"; - + string filename=basename(get_file_name()); Canvas::Handle canvas(get_canvas()); { -- 2.7.4