Show the 'select all child layers' icon in the layers panel all the time, rather...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Tue, 19 Feb 2008 10:31:20 +0000 (10:31 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Tue, 19 Feb 2008 10:31:20 +0000 (10:31 +0000)
git-svn-id: http://svn.voria.com/code@1755 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/gtkmm/dock_layers.cpp
synfig-studio/trunk/src/gtkmm/layeractionmanager.cpp
synfig-studio/trunk/src/gtkmm/layeractionmanager.h

index 12bbe0f..74b8d5f 100644 (file)
@@ -140,19 +140,23 @@ Dock_Layers::Dock_Layers():
                }
        }
 
+       if(layer_action_manager)
+               action_group_layer_ops->add(layer_action_manager->get_action_select_all_child_layers());
 
        action_group_layer_ops->add( Gtk::Action::create("toolbar-layer", _("Layer Ops")) );
        App::ui_manager()->insert_action_group(action_group_layer_ops);
 
-
     Glib::ustring ui_info =
        "<ui>"
        "       <toolbar action='toolbar-layer'>"
        "       <toolitem action='action-layer_raise' />"
        "       <toolitem action='action-layer_lower' />"
+       "       <separator />"
        "       <toolitem action='action-layer_duplicate' />"
        "       <toolitem action='action-layer_encapsulate' />"
+       "       <toolitem action='select-all-child-layers' />"
        "       <toolitem action='action-layer_remove' />"
+       "       <separator />"
        "       <toolitem action='cut' />"
        "       <toolitem action='copy' />"
        "       <toolitem action='paste' />"
index 34d7f20..3191970 100644 (file)
@@ -128,7 +128,12 @@ LayerActionManager::LayerActionManager():
                _("Amount"),_("Amount")
        );
 
-
+       action_select_all_child_layers_=Gtk::Action::create(
+               "select-all-child-layers",
+               Gtk::StockID("synfig-select_all_child_layers"),
+               _("Select All Child Layers"),_("Select All Child Layers")
+       );
+       action_select_all_child_layers_->set_sensitive(false);
 }
 
 LayerActionManager::~LayerActionManager()
@@ -231,8 +236,7 @@ LayerActionManager::refresh()
                return;
        }
 
-
-       String ui_info, ui_toolbar_info;
+       String ui_info;
 
        action_paste_->set_sensitive(!clipboard_.empty());
        action_group_->add(action_paste_);
@@ -286,17 +290,22 @@ LayerActionManager::refresh()
 
                        if(!multiple_selected && layer->get_name()=="PasteCanvas")
                        {
-                               action_group_->add(Gtk::Action::create(
-                                       "select-all-child-layers",
-                                       Gtk::StockID("synfig-select_all_child_layers"),
-                                       _("Select All Child Layers"),
-                                       _("Select All Child Layers")),
+                               if (select_all_child_layers_connection)
+                                       select_all_child_layers_connection.disconnect();
+
+                               select_all_child_layers_connection = action_select_all_child_layers_->signal_activate().connect(
                                        sigc::bind(sigc::mem_fun(*layer_tree_,
                                                                                         &studio::LayerTree::select_all_children_layers),
                                                           Layer::LooseHandle(layer)));
+
+                               action_select_all_child_layers_->set_sensitive(true);
+
                                ui_info+="<menuitem action='select-all-child-layers'/>";
-                               ui_toolbar_info+="<toolbar action='toolbar-layer'><toolitem action='select-all-child-layers'/></toolbar>";
                        }
+                       else
+                               action_select_all_child_layers_->set_sensitive(false);
+                       action_group_->add(action_select_all_child_layers_);
+
                        handle<studio::Instance>::cast_static(get_canvas_interface()->get_instance())->
                                add_actions_to_group(action_group_, ui_info,   param_list, synfigapp::Action::CATEGORY_LAYER);
                }
@@ -313,7 +322,6 @@ LayerActionManager::refresh()
                                   "<separator/>"
                             "</menu>"
                           "</popup>" +
-                        ui_toolbar_info +
                         "</ui>");
        popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
 #ifdef ONE_ACTION_GROUP
index 0e9305a..91c400f 100644 (file)
@@ -62,10 +62,11 @@ class LayerActionManager
        Glib::RefPtr<Gtk::Action>       action_amount_dec_;
        Glib::RefPtr<Gtk::Action>       action_amount_;
 
+       Glib::RefPtr<Gtk::Action>       action_select_all_child_layers_;
+       sigc::connection                        select_all_child_layers_connection;
 
        std::list<synfig::Layer::Handle> clipboard_;
 
-
        sigc::connection selection_changed_connection;
 
        bool queued;
@@ -100,6 +101,8 @@ public:
 
        void refresh();
        void clear();
+
+       Glib::RefPtr<Gtk::Action> get_action_select_all_child_layers() { return action_select_all_child_layers_; }
 }; // END of LayerActionManager
 
 }; // END of namespace studio