synfig-studio  1.0.3
synfigapp/instance.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
21 /* ========================================================================= */
22 
23 /* === S T A R T =========================================================== */
24 
25 #ifndef __SYNFIG_APP_INSTANCE_H
26 #define __SYNFIG_APP_INSTANCE_H
27 
28 /* === H E A D E R S ======================================================= */
29 
30 #include "action.h"
31 #include <ETL/handle>
32 #include <synfig/canvas.h>
33 #include <synfig/string.h>
34 #include <synfig/filecontainertemporary.h>
35 #include <synfig/filesystemgroup.h>
36 #include <list>
37 #include <set>
38 #include <sigc++/signal.h>
39 #include <sigc++/object.h>
40 #include "action_system.h"
41 #include "selectionmanager.h"
42 #include "cvs.h"
43 
44 /* === M A C R O S ========================================================= */
45 
46 /* === T Y P E D E F S ===================================================== */
47 
48 /* === C L A S S E S & S T R U C T S ======================================= */
49 
50 namespace synfigapp {
51 
52 class CanvasInterface;
53 
54 
55 class Instance : public Action::System , public CVSInfo
56 {
57  friend class PassiveGrouper;
58  /*
59  -- ** -- P U B L I C T Y P E S ---------------------------------------------
60  */
61 
62 public:
63 
64  typedef std::list< etl::handle<CanvasInterface> > CanvasInterfaceList;
65 
67  {
68  synfig::Layer::ConstHandle layer;
69  std::string param_name;
70  std::string old_filename;
71  std::string new_filename;
72  };
73 
74  typedef std::list< FileReference > FileReferenceList;
75 
76  using etl::shared_object::ref;
77  using etl::shared_object::unref;
78 
79  /*
80  -- ** -- P U B L I C D A T A ------------------------------------------------
81  */
82 
83 public:
84 
85  /*
86  -- ** -- P R I V A T E D A T A ---------------------------------------------
87  */
88 
89 private:
90 
92  synfig::Canvas::Handle canvas_;
93 
94  etl::handle< synfig::FileSystemGroup > file_system_;
95  etl::handle< synfig::FileContainerTemporary > container_;
96 
97  CanvasInterfaceList canvas_interface_list_;
98 
99  sigc::signal<void> signal_filename_changed_;
100  sigc::signal<void> signal_saved_;
101  etl::handle<SelectionManager> selection_manager_;
102 
103  bool save_canvas_into_container_;
104  std::string save_canvas_reference_directory_;
105  std::string save_canvas_reference_local_directory_;
106  FileReferenceList save_canvas_references_;
107  std::list< synfig::Layer::Handle > layers_to_save;
108 
109  static bool save_canvas_callback(void *instance_ptr, synfig::Layer::ConstHandle layer, const std::string &param_name, std::string &filename);
110  void update_references_in_canvas(synfig::Canvas::Handle canvas);
111  bool import_external_canvas(synfig::Canvas::Handle canvas, std::map<synfig::Canvas*, synfig::Canvas::Handle> &imported);
112  void import_external_canvases();
113  void embed_all(synfig::Canvas::Handle canvas, bool &success, bool &restart);
114 
115 protected:
116  Instance(etl::handle<synfig::Canvas>, etl::handle< synfig::FileContainerTemporary > container);
117 
118  /*
119  -- ** -- P U B L I C M E T H O D S -----------------------------------------
120  */
121 
122 public:
123  ~Instance();
124 
126  for(std::list<synfig::Layer::Handle>::iterator i = layers_to_save.begin(); i != layers_to_save.end(); i++)
127  if (*i == layer) return true;
128  return false;
129  }
130  void register_layer_to_save(synfig::Layer::Handle layer) { layers_to_save.push_back(layer); }
132  {
133  for(std::list<synfig::Layer::Handle>::iterator i = layers_to_save.begin(); i != layers_to_save.end(); i++)
134  if (*i == layer) { layers_to_save.erase(i); break; }
135  }
136 
137  void set_selection_manager(const etl::handle<SelectionManager> &sm) { assert(sm); selection_manager_=sm; }
138  void unset_selection_manager() { selection_manager_=new NullSelectionManager(); }
139  const etl::handle<SelectionManager> &get_selection_manager() { return selection_manager_; }
140 
141  etl::handle< synfig::FileSystemGroup > get_file_system() const { return file_system_; };
142  etl::handle< synfig::FileContainerTemporary > get_container() const { return container_; };
143  void save_surface(const synfig::Surface &surface, const synfig::String &filename);
144 
145  etl::handle<CanvasInterface> find_canvas_interface(synfig::Canvas::Handle canvas);
146 
147  synfig::Canvas::Handle get_canvas()const { return canvas_; }
148 
149  bool embed_all();
150 
151  void convert_animated_filenames(const synfig::Canvas::Handle &canvas, const synfig::String &old_path, const synfig::String &new_path);
152 
154  bool save();
155 
156  bool save_as(const synfig::String &filename);
157 
159  bool generate_new_name(
160  synfig::Layer::Handle layer,
161  synfig::Canvas::Handle canvas,
162  synfig::FileSystem::Handle file_system,
163  synfig::String &out_description,
164  synfig::String &out_filename,
165  synfig::String &out_filename_param);
166 
167 public: // Interfaces to internal information
168  sigc::signal<void>& signal_filename_changed() { return signal_filename_changed_; }
169  sigc::signal<void>& signal_saved() { return signal_saved_; }
170 
171  CanvasInterfaceList & canvas_interface_list() { return canvas_interface_list_; }
172  const CanvasInterfaceList & canvas_interface_list()const { return canvas_interface_list_; }
173 
174  synfig::String get_file_name()const;
175 
176  void set_file_name(const synfig::String &name);
177 
178 public:
179 
180 
181 public: // Constructor interfaces
182  static etl::handle<Instance> create(etl::handle<synfig::Canvas> canvas, etl::handle< synfig::FileContainerTemporary > container);
183 }; // END class Instance
184 
185 etl::handle<Instance> find_instance(etl::handle<synfig::Canvas> canvas);
186 
187 bool is_editable(synfig::ValueNode::Handle value_node);
188 
189 }; // END namespace studio
190 
191 /* === E N D =============================================================== */
192 
193 #endif