Fixed 1799250: Add a function to update the render filename from the document filenam...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Fri, 21 Sep 2007 00:27:07 +0000 (00:27 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Fri, 21 Sep 2007 00:27:07 +0000 (00:27 +0000)
git-svn-id: http://svn.voria.com/code@729 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/gtkmm/render.cpp

index 1e098b7..4a5a4b6 100644 (file)
@@ -177,22 +177,44 @@ RenderSettings::RenderSettings(Gtk::Window& parent,handle<synfigapp::CanvasInter
        toggle_single_frame.set_active(true);
        widget_rend_desc.disable_time_section();
 
+       set_entry_filename();
+
+       get_vbox()->show_all();
+}
+
+RenderSettings::~RenderSettings()
+{
+}
+
+void
+RenderSettings::set_entry_filename()
+{
+       String filename(canvas_interface_->get_canvas()->get_file_name());
+
+       // if the basename of the filename has an extension, remove it
+       String base = basename(filename);
+       if(find(base.begin(),base.end(),'.')!=base.end())
+               filename = String(filename.begin(), filename.begin()+filename.find_last_of('.'));
+
+       // if this isn't the root canvas, append (<canvasname>) to the filename
+       etl::handle<synfig::Canvas> canvas = canvas_interface_->get_canvas();
+       if (!canvas->is_root())
+               if(canvas->get_name().empty())
+                       filename+=" ("+canvas->get_id()+')';
+               else
+                       filename+=" ("+canvas->get_name()+')';
+
+       filename += ".png";
 
        try
        {
-               entry_filename.set_text(Glib::build_filename(Glib::get_home_dir(),Glib::ustring("Desktop")+ETL_DIRECTORY_SEPARATOR+Glib::ustring("output.png")));
+               entry_filename.set_text((filename));
        }
        catch(...)
        {
                synfig::warning("Averted crash!");
                entry_filename.set_text("output.png");
        }
-
-       get_vbox()->show_all();
-}
-
-RenderSettings::~RenderSettings()
-{
 }
 
 void