X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fcanvasview.cpp;h=deb956746fa56d6d8d736c3db6d800843f6de8af;hb=3b61f1786f7c6dcb4038af31af709bddddd312b7;hp=f1b6b1ea6f39d82725d804b36e46fc680e79b327;hpb=cf12beaa12f85928c13bf9d5f7db7e710fff7f0a;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/canvasview.cpp b/synfig-studio/trunk/src/gtkmm/canvasview.cpp index f1b6b1e..deb9567 100644 --- a/synfig-studio/trunk/src/gtkmm/canvasview.cpp +++ b/synfig-studio/trunk/src/gtkmm/canvasview.cpp @@ -1221,8 +1221,11 @@ CanvasView::init_menus() 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")), @@ -1460,7 +1463,12 @@ CanvasView::init_menus() 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))); @@ -1940,18 +1948,40 @@ CanvasView::refresh_rend_desc() bool -CanvasView::close() +CanvasView::close_view() +{ + if(get_instance()->get_visible_canvases()==1) + close_instance(); + else + hide(); + return false; +} + +static bool _close_instance(etl::handle instance) +{ + etl::handle 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_when_safe) ,250); - return false; + Glib::signal_timeout().connect( + sigc::mem_fun(*this, &CanvasView::close_instance), + 250); } - - close_instance_when_safe(); + else + Glib::signal_timeout().connect( + sigc::bind(sigc::ptr_fun(_close_instance), + (etl::handle)get_instance()), + 250); return false; } @@ -2166,6 +2196,8 @@ CanvasView::on_layer_user_click(int button, Gtk::TreeRow /*row*/, LayerTree::Col parammenu.items().clear(); Gtk::Menu *newlayers(manage(new Gtk::Menu())); + // do we need this? the code is all #ifdef'ed out anyway + // newlayers->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), newlayers)); build_new_layer_menu(*newlayers); parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem("New Layer",*newlayers)); @@ -2574,7 +2606,7 @@ CanvasView::rebuild_ducks_layer_(synfig::TransformStack& transform_stack, Canvas // do the bounding box thing bbox|=transform_stack.perform(layer->get_bounding_rect()); - // Grab the layer's list pf parameters + // Grab the layer's list of parameters Layer::ParamList paramlist(layer->get_param_list()); // Grab the layer vocabulary @@ -2960,6 +2992,7 @@ CanvasView::on_waypoint_clicked(synfigapp::ValueDesc value_desc,synfig::Waypoint case 2: { Gtk::Menu* waypoint_menu(manage(new Gtk::Menu())); + waypoint_menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), waypoint_menu)); waypoint_menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-jump-to"), sigc::bind( @@ -3107,8 +3140,8 @@ CanvasView::on_drop_drag_data_received(const Glib::RefPtr& con // 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") @@ -3525,37 +3558,10 @@ CanvasView::set_ext_widget(const synfig::String& x, Gtk::Widget* y) keyframe_tree=dynamic_cast(y); } -static bool _close_instance(etl::handle instance) -{ - etl::handle argh(instance); - instance->safe_close(); - synfig::info("closed"); - return false; -} - -bool -CanvasView::close_instance_when_safe() -{ - if (get_work_area()->get_updating()) - return true; - - 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)get_instance() - ) - ,250 - ); - - return false; -} - bool CanvasView::on_delete_event(GdkEventAny* event) { - close(); + 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?