1 /* === S Y N F I G ========================================================= */
2 /*! \file statemanager.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "statemanager.h"
33 #include <gtkmm/actiongroup.h>
34 #include <gtkmm/action.h>
35 #include <synfig/string.h>
41 /* === U S I N G =========================================================== */
45 using namespace synfig;
46 using namespace studio;
48 /* === M A C R O S ========================================================= */
50 /* === G L O B A L S ======================================================= */
52 /* === P R O C E D U R E S ================================================= */
54 /* === M E T H O D S ======================================================= */
56 StateManager::StateManager():
57 state_group(Gtk::ActionGroup::create()),
58 merge_id(App::ui_manager()->new_merge_id())
60 App::ui_manager()->insert_action_group(get_action_group());
63 StateManager::~StateManager()
65 App::ui_manager()->remove_ui(merge_id);
67 for(;!merge_id_list.empty();merge_id_list.pop_back())
68 App::ui_manager()->remove_ui(merge_id_list.back());
72 StateManager::change_state_(const Smach::state_base *state)
74 App::toolbox->change_state_(state);
78 StateManager::add_state(const Smach::state_base *state)
80 String name(state->get_name());
82 Glib::RefPtr<Gtk::Action> action(
85 Gtk::StockID("synfig-"+name),
90 /*action->set_sensitive(false);*/
91 state_group->add(action);
93 action->signal_activate().connect(
95 sigc::mem_fun(*this,&studio::StateManager::change_state_),
100 App::ui_manager()->ensure_update();
102 /*App::ui_manager()->add_ui(
104 "/main-menu/menu-state",
110 String uid_def("<ui><popup action='menu-main'><menu action='menu-state'><menuitem action='state-"+name+"' /></menu></popup></ui>");
111 merge_id_list.push_back(App::ui_manager()->add_ui_from_string(uid_def));
113 App::ui_manager()->ensure_update();
115 App::toolbox->add_state(state);
118 Glib::RefPtr<Gtk::ActionGroup>
119 StateManager::get_action_group()