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
9 ** Copyright (c) 2007 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === H E A D E R S ======================================================= */
33 #include "statemanager.h"
34 #include <gtkmm/actiongroup.h>
35 #include <gtkmm/action.h>
36 #include <synfig/string.h>
42 /* === U S I N G =========================================================== */
46 using namespace synfig;
47 using namespace studio;
49 /* === M A C R O S ========================================================= */
51 /* === G L O B A L S ======================================================= */
53 /* === P R O C E D U R E S ================================================= */
55 /* === M E T H O D S ======================================================= */
57 StateManager::StateManager():
58 state_group(Gtk::ActionGroup::create()),
59 merge_id(App::ui_manager()->new_merge_id())
61 App::ui_manager()->insert_action_group(get_action_group());
64 StateManager::~StateManager()
66 App::ui_manager()->remove_ui(merge_id);
68 for(;!merge_id_list.empty();merge_id_list.pop_back())
69 App::ui_manager()->remove_ui(merge_id_list.back());
73 StateManager::change_state_(const Smach::state_base *state)
75 App::toolbox->change_state_(state);
79 StateManager::add_state(const Smach::state_base *state)
81 String name(state->get_name());
83 Gtk::StockItem stock_item;
84 Gtk::Stock::lookup(Gtk::StockID("synfig-"+name),stock_item);
86 Glib::RefPtr<Gtk::Action> action(
89 stock_item.get_stock_id(),
90 stock_item.get_label(),
91 stock_item.get_label()
94 /*action->set_sensitive(false);*/
95 state_group->add(action);
97 action->signal_activate().connect(
99 sigc::mem_fun(*this,&studio::StateManager::change_state_),
104 App::ui_manager()->ensure_update();
106 /*App::ui_manager()->add_ui(
108 "/main-menu/menu-state",
114 String uid_def("<ui><popup action='menu-main'><menu action='menu-state'><menuitem action='state-"+name+"' /></menu></popup></ui>");
115 merge_id_list.push_back(App::ui_manager()->add_ui_from_string(uid_def));
117 App::ui_manager()->ensure_update();
119 App::toolbox->add_state(state);
122 Glib::RefPtr<Gtk::ActionGroup>
123 StateManager::get_action_group()