action_group->add( Gtk::Action::create("options", _("Options")),
sigc::mem_fun0(canvas_options,&studio::CanvasOptions::present)
);
- action_group->add( Gtk::Action::create("close", Gtk::StockID("gtk-close")),
- sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close))
+ action_group->add( Gtk::Action::create("close", Gtk::StockID("gtk-close"), _("Close Window")),
+ sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_view))
+ );
+ action_group->add( Gtk::Action::create("close-document", Gtk::StockID("gtk-close"), _("Close Document")),
+ sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_instance))
);
//action_group->add( Gtk::Action::create("undo", Gtk::StockID("gtk-undo")),
sigc::mem_fun(canvas_options,&studio::CanvasOptions::present)
));
filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
- filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-close"),sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close))));
+ filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Close View"),
+ sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_view))
+ ));
+ filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Close Document"),
+ sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_document))
+ ));
editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-undo"),Gtk::AccelKey('Z',Gdk::CONTROL_MASK),SLOT_EVENT(EVENT_UNDO)));
editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-redo"),Gtk::AccelKey('R',Gdk::CONTROL_MASK),SLOT_EVENT(EVENT_REDO)));
bool
-CanvasView::close()
+CanvasView::close_view()
{
- get_instance()->safe_close();
+ if(get_instance()->get_visible_canvases()==1)
+ close_instance();
+ else
+ hide();
+ return false;
+}
+
+static bool _close_instance(etl::handle<Instance> instance)
+{
+ etl::handle<Instance> argh(instance);
+ instance->safe_close();
+ synfig::info("closed");
+ return false;
+}
+
+bool
+CanvasView::close_instance()
+{
+ if (get_work_area()->get_updating())
+ {
+ get_work_area()->stop_updating(true); // stop and mark as cancelled
+
+ // give the workarea chances to stop updating
+ Glib::signal_timeout().connect(
+ sigc::mem_fun(*this, &CanvasView::close_instance),
+ 250);
+ }
+ else
+ Glib::signal_timeout().connect(
+ sigc::bind(sigc::ptr_fun(_close_instance),
+ (etl::handle<Instance>)get_instance()),
+ 250);
return false;
}
{
string title;
+ if(get_instance()->synfigapp::Instance::get_action_count())
+ title="*";
title+=etl::basename(get_instance()->get_file_name())
+" : ";
if(get_canvas()->get_name().empty())
else
title+='"'+get_canvas()->get_name()+'"';
- if(get_instance()->synfigapp::Instance::get_action_count())
- title+=_(" (Unsaved)");
-
if(get_instance()->synfigapp::Instance::in_repository())
{
title+=" (CVS";
// Strip the "file://" part from the filename
filename=synfig::String(filename.begin()+sizeof("file://")-1,filename.end());
- String ext;
- try{ext=(String(filename.begin()+filename.find_last_of('.')+1,filename.end()));}catch(...){continue;}
+ String ext(filename_extension(filename));
+ if (ext.size()) ext = ext.substr(1); // skip initial '.'
// If this is a SIF file, then we need to do things slightly differently
if(ext=="sketch")
keyframe_tree=dynamic_cast<KeyframeTree*>(y);
}
-static bool _close_instance(etl::handle<Instance> instance)
-{
- etl::handle<Instance> argh(instance);
- instance->safe_close();
- synfig::info("closed");
- return false;
-}
-
bool
CanvasView::on_delete_event(GdkEventAny* event)
{
- if(get_instance()->get_visible_canvases()==1)
- {
- // Schedule a close to occur in a few moments
- Glib::signal_timeout().connect(
- sigc::bind(
- sigc::ptr_fun(_close_instance),
- (etl::handle<Instance>)get_instance()
- )
- ,250
- );
- }
+ close_view();
//! \todo This causes the window to be deleted straight away - but what if we prompt 'save?' and the user cancels?
// Is there ever any need to pass on the delete event to the window here?