X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fstatemanager.cpp;fp=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fstatemanager.cpp;h=ae883909d89f0308108a59911293efbe18b87c1d;hb=3a3c4bca3a17137bec5d7960560934b91ef4146e;hp=0000000000000000000000000000000000000000;hpb=41257b650db1defb40ac20072ffeef70d5985f5e;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/statemanager.cpp b/synfig-studio/trunk/src/gtkmm/statemanager.cpp new file mode 100644 index 0000000..ae88390 --- /dev/null +++ b/synfig-studio/trunk/src/gtkmm/statemanager.cpp @@ -0,0 +1,121 @@ +/* === S I N F G =========================================================== */ +/*! \file template.cpp +** \brief Template File +** +** $Id: statemanager.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $ +** +** \legal +** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** +** This software and associated documentation +** are CONFIDENTIAL and PROPRIETARY property of +** the above-mentioned copyright holder. +** +** You may not copy, print, publish, or in any +** other way distribute this software without +** a prior written agreement with +** the copyright holder. +** \endlegal +*/ +/* ========================================================================= */ + +/* === H E A D E R S ======================================================= */ + +#ifdef USING_PCH +# include "pch.h" +#else +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "statemanager.h" +#include +#include +#include +#include "app.h" +#include "toolbox.h" + +#endif + +/* === U S I N G =========================================================== */ + +using namespace std; +using namespace etl; +using namespace sinfg; +using namespace studio; + +/* === M A C R O S ========================================================= */ + +/* === G L O B A L S ======================================================= */ + +/* === P R O C E D U R E S ================================================= */ + +/* === M E T H O D S ======================================================= */ + +StateManager::StateManager(): + state_group(Gtk::ActionGroup::create()), + merge_id(App::ui_manager()->new_merge_id()) +{ + App::ui_manager()->insert_action_group(get_action_group()); +} + +StateManager::~StateManager() +{ + App::ui_manager()->remove_ui(merge_id); + + for(;!merge_id_list.empty();merge_id_list.pop_back()) + App::ui_manager()->remove_ui(merge_id_list.back()); +} + +void +StateManager::change_state_(const Smach::state_base *state) +{ + App::toolbox->change_state_(state); +} + +void +StateManager::add_state(const Smach::state_base *state) +{ + String name(state->get_name()); + + Glib::RefPtr action( + Gtk::Action::create( + "state-"+name, + Gtk::StockID("sinfg-"+name), + name, + name + ) + ); + /*action->set_sensitive(false);*/ + state_group->add(action); + + action->signal_activate().connect( + sigc::bind( + sigc::mem_fun(*this,&studio::StateManager::change_state_), + state + ) + ); + + App::ui_manager()->ensure_update(); + + /*App::ui_manager()->add_ui( + merge_id, + "/main-menu/menu-state", + "state-"+name, + "state-"+name + ); + */ + + String uid_def(""); + merge_id_list.push_back(App::ui_manager()->add_ui_from_string(uid_def)); + + App::ui_manager()->ensure_update(); + + App::toolbox->add_state(state); +} + +Glib::RefPtr +StateManager::get_action_group() +{ + return state_group; +}