X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fcanvasview.cpp;h=87c58a5c854c525b80ab20abc14dc766d0774af6;hb=f26a17960daf8eca62ca03d3a3bdb61096e09c7b;hp=9e597d453e3128c6e5becdeab1f079ac25243be3;hpb=9872e3229a1877e8cdcdb2feb177e49e12e8ddf4;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/canvasview.cpp b/synfig-studio/trunk/src/gtkmm/canvasview.cpp index 9e597d4..87c58a5 100644 --- a/synfig-studio/trunk/src/gtkmm/canvasview.cpp +++ b/synfig-studio/trunk/src/gtkmm/canvasview.cpp @@ -6,6 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -446,7 +447,7 @@ public: { // assert(view->layer_tree); - if(!view->layer_tree) { DEBUGPOINT(); synfig::error("canvas_view.layer_tree not defined!?"); return LayerList(); } + if(!view->layer_tree) { DEBUGPOINT(); synfig::error("%s:%d canvas_view.layer_tree not defined!?", __FILE__, __LINE__); return LayerList(); } return view->layer_tree->get_selected_layers(); } @@ -455,7 +456,7 @@ public: { // assert(view->layer_tree); - if(!view->layer_tree) { DEBUGPOINT(); synfig::error("canvas_view.layer_tree not defined!?"); return 0; } + if(!view->layer_tree) { DEBUGPOINT(); synfig::error("%s:%d canvas_view.layer_tree not defined!?", __FILE__, __LINE__); return 0; } return view->layer_tree->get_selected_layer(); } @@ -464,7 +465,7 @@ public: { // assert(view->layer_tree); - if(!view->layer_tree) { DEBUGPOINT(); synfig::error("canvas_view.layer_tree not defined!?"); return; } + if(!view->layer_tree) { DEBUGPOINT(); synfig::error("%s:%d canvas_view.layer_tree not defined!?", __FILE__, __LINE__); return; } view->layer_tree->select_layers(layer_list); //view->get_smach().process_event(EVENT_REFRESH_DUCKS); @@ -1220,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")), @@ -1265,7 +1269,10 @@ CanvasView::init_menus() { Glib::RefPtr action(Gtk::RadioAction::create(quality_group,strprintf("quality-%02d",i), strprintf("Set Quality to %d",i))); if(i==10) - action->property_value()=10; + { + action->set_active(); + work_area->set_quality(i); + } action_group->add( action, sigc::bind( sigc::mem_fun(*work_area, &studio::WorkArea::set_quality), @@ -1275,7 +1282,7 @@ CanvasView::init_menus() } } - action_group->add( Gtk::Action::create("play", Gtk::StockID("synfig-play")), + action_group->add( Gtk::Action::create("play", Gtk::Stock::MEDIA_PLAY), sigc::mem_fun(*this, &studio::CanvasView::play) ); @@ -1456,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))); @@ -1583,7 +1595,7 @@ CanvasView::init_menus() viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Preview Quality"),qualitymenu)); } - viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-play"), + viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::MEDIA_PLAY, sigc::mem_fun(*this, &studio::CanvasView::play))); viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("Flipbook Dialog"), sigc::mem_fun(*preview_dialog, &studio::Dialog_Preview::present))); @@ -1936,9 +1948,40 @@ CanvasView::refresh_rend_desc() 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) +{ + 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), + 250); + } + else + Glib::signal_timeout().connect( + sigc::bind(sigc::ptr_fun(_close_instance), + (etl::handle)get_instance()), + 250); return false; } @@ -1956,6 +1999,8 @@ CanvasView::update_title() { 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()) @@ -1963,9 +2008,6 @@ CanvasView::update_title() 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"; @@ -3095,8 +3137,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") @@ -3415,7 +3457,7 @@ CanvasView::on_audio_offset_notify() sound_dialog->set_offset(t); disp_audio->queue_draw(); - synfig::info("CanvasView::on_audio_offset_notify(): offset time set to %s",t.get_string(get_canvas()->rend_desc().get_frame_rate()).c_str()); + // synfig::info("CanvasView::on_audio_offset_notify(): offset time set to %s",t.get_string(get_canvas()->rend_desc().get_frame_rate()).c_str()); } void @@ -3513,30 +3555,14 @@ 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::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)get_instance() - ) - ,250 - ); - } - if(event) - return Gtk::Window::on_delete_event(event); + 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? + // if(event) return Gtk::Window::on_delete_event(event); return true; }