Implement feature request 1741236: Use 'Synfig Animation N' (N=1,2,3,...) rather...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Tue, 18 Sep 2007 12:54:44 +0000 (12:54 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Tue, 18 Sep 2007 12:54:44 +0000 (12:54 +0000)
git-svn-id: http://svn.voria.com/code@708 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/gtkmm/app.cpp
synfig-studio/trunk/src/gtkmm/instance.cpp

index 238e339..5444784 100644 (file)
@@ -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<synfig::Canvas> 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);
index a67d7f7..122e96b 100644 (file)
@@ -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());
 
        {