synfig-studio  1.0.3
gui/instance.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
23 /* ========================================================================= */
24 
25 /* === S T A R T =========================================================== */
26 
27 #ifndef __SYNFIG_STUDIO_INSTANCE_H
28 #define __SYNFIG_STUDIO_INSTANCE_H
29 
30 /* === H E A D E R S ======================================================= */
31 
32 #include <ETL/handle>
33 #include <gtkmm/treeview.h>
34 #include <gtkmm/treestore.h>
35 #include <synfigapp/instance.h>
36 #include <sigc++/object.h>
37 #include <synfigapp/value_desc.h>
38 #include "trees/historytreestore.h"
39 #include <synfig/canvas.h>
40 
41 /* === M A C R O S ========================================================= */
42 #define DEFAULT_FILENAME_PREFIX _("Synfig Animation ") // will be followed by a different number for each document
43 
44 /* === T Y P E D E F S ===================================================== */
45 
46 /* === C L A S S E S & S T R U C T S ======================================= */
47 
48 namespace Gtk { class Menu; class ActionGroup; };
49 
50 namespace studio {
51 
52 class CanvasView;
53 
54 
56 {
57 public:
58  typedef std::list< etl::handle<CanvasView> > CanvasViewList;
59 
60  enum Status
61  {
65  };
66 
67  class CanvasTreeModel : public Gtk::TreeModel::ColumnRecord
68  {
69  public:
70  Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
71  Gtk::TreeModelColumn<Glib::ustring> label;
72  Gtk::TreeModelColumn<Glib::ustring> name;
73  Gtk::TreeModelColumn<Glib::ustring> id;
74 
75  Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
76  Gtk::TreeModelColumn<bool> is_canvas;
77 
78  Gtk::TreeModelColumn<synfig::ValueNode::Handle> value_node;
79  Gtk::TreeModelColumn<bool> is_value_node;
80  Gtk::TreeModelColumn<synfig::ValueBase> value;
81  Gtk::TreeModelColumn<Glib::ustring> type;
82  Gtk::TreeModelColumn<int> link_id;
83  Gtk::TreeModelColumn<int> link_count;
84 
85  Gtk::TreeModelColumn<bool> is_editable;
86 
87  Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
88 
90  {
91  add(value);
92  add(name);
93  add(label);
94  add(icon);
95  add(type);
96  add(id);
97  add(canvas);
98  add(value_node);
99  add(is_canvas);
100  add(is_value_node);
101 
102  add(is_editable);
103  add(value_desc);
104  add(link_count);
105  add(link_id);
106  }
108 
109 private:
110 
111  sigc::signal<void,CanvasView*> signal_canvas_view_created_;
112  sigc::signal<void,CanvasView*> signal_canvas_view_deleted_;
113 
114  sigc::signal<void> signal_undo_redo_status_changed_;
115 
117  Glib::RefPtr<Gtk::TreeStore> canvas_tree_store_;
118 
120  Glib::RefPtr<HistoryTreeStore> history_tree_store_;
121 
123  int id_;
124 
126  static int instance_count_;
127 
129  CanvasViewList canvas_view_list_;
130 
131  bool undo_status_;
132  bool redo_status_;
133 
134  void set_undo_status(bool x);
135  void set_redo_status(bool x);
136 
137 protected:
138 
139  Instance(synfig::Canvas::Handle, etl::handle< synfig::FileContainerTemporary >);
140 
141 public:
142 
143  sigc::signal<void>& signal_undo_redo_status_changed() { return signal_undo_redo_status_changed_; }
144 
145  ~Instance();
146 
147  sigc::signal<void,CanvasView*>& signal_canvas_view_created() { return signal_canvas_view_created_; }
148  sigc::signal<void,CanvasView*>& signal_canvas_view_deleted() { return signal_canvas_view_deleted_; }
149 
150  bool get_undo_status()const { return undo_status_; }
151 
152  bool get_redo_status()const { return redo_status_; }
153 
154  int get_visible_canvases()const;
155 
156  Glib::RefPtr<Gtk::TreeStore> canvas_tree_store() { return canvas_tree_store_; }
157 
158  Glib::RefPtr<const Gtk::TreeStore> canvas_tree_store()const { return canvas_tree_store_; }
159 
160  Glib::RefPtr<HistoryTreeStore> history_tree_store() { return history_tree_store_; }
161 
162  Glib::RefPtr<const HistoryTreeStore> history_tree_store()const { return history_tree_store_; }
163 
165  static int get_count() { return instance_count_; }
166 
167  //etl::handle<synfig::Canvas> get_canvas()const { return synfigapp::Instance::get_canvas(); }
168 
169  etl::handle<CanvasView> find_canvas_view(etl::handle<synfig::Canvas> canvas);
170 
172  void focus(etl::handle<synfig::Canvas> canvas);
173 
174  CanvasViewList & canvas_view_list() { return canvas_view_list_; }
175 
176  const CanvasViewList & canvas_view_list()const { return canvas_view_list_; }
177 
178  void run_plugin(std::string plugin_path);
179 
180  bool save_as(const synfig::String &filename);
181 
183  bool has_real_filename();
184 
187  bool dialog_save_as();
188 
189  void open();
190 
191  Status save();
192 
193  void dialog_cvs_commit();
194 
195  void dialog_cvs_add();
196 
197  void dialog_cvs_update();
198 
199  void dialog_cvs_revert();
200 
202  void close();
203 
204  void revert();
205 
206  void update_all_titles();
207 
208  void refresh_canvas_tree();
209 
210  bool safe_revert();
211  bool safe_close();
212 
215 
216  void add_actions_to_group(const Glib::RefPtr<Gtk::ActionGroup>& action_group, synfig::String& ui_info, const synfigapp::Action::ParamList &param_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
217 
218  void process_action(synfig::String name, synfigapp::Action::ParamList param_list);
219 
220  void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location=0.5f, bool bezier=false);
221 
222  void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas,const std::list<synfigapp::ValueDesc>& value_desc_list, const synfigapp::ValueDesc &value_desc = synfigapp::ValueDesc());
223 
224 
225  static void edit_waypoint(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint);
226 
227 private:
228  void insert_canvas(Gtk::TreeRow row,synfig::Canvas::Handle canvas);
229 
230 public:
231  static etl::handle<Instance> create(synfig::Canvas::Handle canvas, etl::handle< synfig::FileContainerTemporary > container);
232 }; // END class Instance
233 
234 }; // END namespace studio
235 
236 /* === E N D =============================================================== */
237 
238 #endif