Fix the 'close' menu entry and close button when viewing multiple canvases of the...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sat, 13 Oct 2007 01:23:14 +0000 (01:23 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sat, 13 Oct 2007 01:23:14 +0000 (01:23 +0000)
git-svn-id: http://svn.voria.com/code@918 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/gtkmm/app.cpp
synfig-studio/trunk/src/gtkmm/canvasview.cpp
synfig-studio/trunk/src/gtkmm/canvasview.h

index b8e8200..bd35bc8 100644 (file)
@@ -741,7 +741,8 @@ init_ui_manager()
        DEFINE_ACTION("dialog-flipbook", _("Preview Dialog"));
        DEFINE_ACTION("sound", _("Sound File"));
        DEFINE_ACTION("options", _("Options"));
-       DEFINE_ACTION("close", _("Close"));
+       DEFINE_ACTION("close", _("Close View"));
+       DEFINE_ACTION("close-document", _("Close Document"));
 
 
        DEFINE_ACTION("undo", Gtk::StockID("gtk-undo"));
@@ -861,6 +862,7 @@ init_ui_manager()
 "              <separator name='bleh04'/>"
 "              <menuitem action='options' />"
 "              <menuitem action='close' />"
+"              <menuitem action='close-document' />"
 "      </menu>"
 "      <menu action='menu-edit'>"
 "              <menuitem action='undo'/>"
index f1b6b1e..b6e093e 100644 (file)
@@ -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> 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_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<Instance>)get_instance()),
+                       250);
        return false;
 }
 
@@ -3525,37 +3555,10 @@ CanvasView::set_ext_widget(const synfig::String& x, Gtk::Widget* y)
                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::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<Instance>)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?
index f1c1d78..17cedda 100644 (file)
@@ -505,8 +505,11 @@ public:
        //! Updates the title of the window
        void update_title();
 
+       //! Closes this document
+       bool close_instance();
+
        //! Closes this canvas view
-       bool close();
+       bool close_view();
 
        //!     Stops the currently executing action
        /*! \see get_cancel_status(), reset_cancel_status(), IsWorking */