1 /* === S Y N F I G ========================================================= */
2 /*! \file gtkmm/instance.h
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 /* === S T A R T =========================================================== */
25 #ifndef __SYNFIG_STUDIO_INSTANCE_H
26 #define __SYNFIG_STUDIO_INSTANCE_H
28 /* === H E A D E R S ======================================================= */
31 #include <gtkmm/treeview.h>
32 #include <gtkmm/treestore.h>
33 #include <synfigapp/instance.h>
34 #include <sigc++/object.h>
35 #include <synfigapp/value_desc.h>
36 #include "historytreestore.h"
37 #include <synfig/canvas.h>
39 /* === M A C R O S ========================================================= */
41 /* === T Y P E D E F S ===================================================== */
43 /* === C L A S S E S & S T R U C T S ======================================= */
45 namespace Gtk { class Menu; class ActionGroup; };
52 class Instance : public synfigapp::Instance
55 typedef std::list< etl::handle<CanvasView> > CanvasViewList;
57 class CanvasTreeModel : public Gtk::TreeModel::ColumnRecord
60 Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
61 Gtk::TreeModelColumn<Glib::ustring> label;
62 Gtk::TreeModelColumn<Glib::ustring> name;
63 Gtk::TreeModelColumn<Glib::ustring> id;
65 Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
66 Gtk::TreeModelColumn<bool> is_canvas;
68 Gtk::TreeModelColumn<synfig::ValueNode::Handle> value_node;
69 Gtk::TreeModelColumn<bool> is_value_node;
70 Gtk::TreeModelColumn<synfig::ValueBase> value;
71 Gtk::TreeModelColumn<Glib::ustring> type;
72 Gtk::TreeModelColumn<int> link_id;
73 Gtk::TreeModelColumn<int> link_count;
75 Gtk::TreeModelColumn<bool> is_editable;
77 Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
101 sigc::signal<void,CanvasView*> signal_canvas_view_created_;
102 sigc::signal<void,CanvasView*> signal_canvas_view_deleted_;
104 sigc::signal<void> signal_undo_redo_status_changed_;
106 //! Tree containing the canvases -- used for the "canvas browser"
107 Glib::RefPtr<Gtk::TreeStore> canvas_tree_store_;
109 //! Tree containing the actions -- used for the "canvas browser"
110 Glib::RefPtr<HistoryTreeStore> history_tree_store_;
115 //! Used to calculate instance ID
116 static int instance_count_;
118 //! List of canvas view windows
119 CanvasViewList canvas_view_list_;
124 void set_undo_status(bool x);
125 void set_redo_status(bool x);
127 static void _revert(Instance *);
131 Instance(synfig::Canvas::Handle);
135 sigc::signal<void>& signal_undo_redo_status_changed() { return signal_undo_redo_status_changed_; }
139 sigc::signal<void,CanvasView*>& signal_canvas_view_created() { return signal_canvas_view_created_; }
140 sigc::signal<void,CanvasView*>& signal_canvas_view_deleted() { return signal_canvas_view_deleted_; }
142 bool get_undo_status()const { return undo_status_; }
144 bool get_redo_status()const { return redo_status_; }
146 int get_visible_canvases()const;
148 Glib::RefPtr<Gtk::TreeStore> canvas_tree_store() { return canvas_tree_store_; }
150 Glib::RefPtr<const Gtk::TreeStore> canvas_tree_store()const { return canvas_tree_store_; }
152 Glib::RefPtr<HistoryTreeStore> history_tree_store() { return history_tree_store_; }
154 Glib::RefPtr<const HistoryTreeStore> history_tree_store()const { return history_tree_store_; }
156 //! Returns the number of instances that are currently open in the program
157 static int get_count() { return instance_count_; }
159 //etl::handle<synfig::Canvas> get_canvas()const { return synfigapp::Instance::get_canvas(); }
161 etl::handle<CanvasView> find_canvas_view(etl::handle<synfig::Canvas> canvas);
163 //! Sets the focus to a specific canvas
164 void focus(etl::handle<synfig::Canvas> canvas);
166 CanvasViewList & canvas_view_list() { return canvas_view_list_; }
168 const CanvasViewList & canvas_view_list()const { return canvas_view_list_; }
170 bool save_as(const synfig::String &filename)const;
172 bool save_as(const synfig::String &filename);
174 //! Opens a "Save As" dialog, and then saves the composition to that file
175 void dialog_save_as();
179 void dialog_cvs_commit();
181 void dialog_cvs_add();
183 void dialog_cvs_update();
185 void dialog_cvs_revert();
187 //! Closes the instance of this composition
192 void update_all_titles();
194 void refresh_canvas_tree();
199 void add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList ¶m_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
200 void add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList ¶m_list1,const synfigapp::Action::ParamList ¶m_list2, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
202 void add_actions_to_group(const Glib::RefPtr<Gtk::ActionGroup>& action_group, synfig::String& ui_info, const synfigapp::Action::ParamList ¶m_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
204 void process_action(synfig::String name, synfigapp::Action::ParamList param_list);
206 void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location=0.5f);
208 void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas,const std::list<synfigapp::ValueDesc>& value_desc_list);
211 static void edit_waypoint(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint);
214 void insert_canvas(Gtk::TreeRow row,synfig::Canvas::Handle canvas);
217 static etl::handle<Instance> create(synfig::Canvas::Handle canvas);
218 }; // END class Instance
220 }; // END namespace studio
222 /* === E N D =============================================================== */