Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / synfigstudio_0_61_07 / src / synfigapp / instance.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file synfigapp/instance.h
3 **      \brief writeme
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
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.
14 **
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.
19 **      \endlegal
20 */
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 <list>
35 #include <sigc++/signal.h>
36 #include <sigc++/object.h>
37 #include "action_system.h"
38 #include "selectionmanager.h"
39 #include "cvs.h"
40
41 /* === M A C R O S ========================================================= */
42
43 /* === T Y P E D E F S ===================================================== */
44
45 /* === C L A S S E S & S T R U C T S ======================================= */
46
47 namespace synfigapp {
48
49 class CanvasInterface;
50
51
52 class Instance : public Action::System , public CVSInfo
53 {
54         friend class PassiveGrouper;
55         /*
56  -- ** -- P U B L I C   T Y P E S ---------------------------------------------
57         */
58
59 public:
60
61         typedef std::list< etl::handle<CanvasInterface> > CanvasInterfaceList;
62
63         using etl::shared_object::ref;
64         using etl::shared_object::unref;
65
66         /*
67  -- ** -- P U B L I C  D A T A ------------------------------------------------
68         */
69
70 public:
71
72         /*
73  -- ** -- P R I V A T E   D A T A ---------------------------------------------
74         */
75
76 private:
77         //! Handle for root canvas
78         synfig::Canvas::Handle canvas_;
79
80
81         CanvasInterfaceList canvas_interface_list_;
82
83         sigc::signal<void> signal_filename_changed_;
84         sigc::signal<void> signal_saved_;
85         etl::handle<SelectionManager> selection_manager_;
86
87 protected:
88         Instance(etl::handle<synfig::Canvas>);
89
90         /*
91  -- ** -- P U B L I C   M E T H O D S -----------------------------------------
92         */
93
94 public:
95
96         ~Instance();
97
98         void set_selection_manager(const etl::handle<SelectionManager> &sm) { assert(sm); selection_manager_=sm; }
99         void unset_selection_manager() { selection_manager_=new NullSelectionManager(); }
100         const etl::handle<SelectionManager> &get_selection_manager() { return selection_manager_; }
101
102
103
104         etl::handle<CanvasInterface> find_canvas_interface(synfig::Canvas::Handle canvas);
105
106         synfig::Canvas::Handle get_canvas()const { return canvas_; }
107
108         //! Saves the instance to filename_
109         bool save()const;
110
111         bool save_as(const synfig::String &filename);
112
113 public: // Interfaces to internal information
114         sigc::signal<void>& signal_filename_changed() { return signal_filename_changed_; }
115         sigc::signal<void>& signal_saved() { return signal_saved_; }
116
117         CanvasInterfaceList & canvas_interface_list() { return canvas_interface_list_; }
118         const CanvasInterfaceList & canvas_interface_list()const { return canvas_interface_list_; }
119
120         synfig::String get_file_name()const;
121
122         void set_file_name(const synfig::String &name);
123
124 public:
125
126
127 public: // Constructor interfaces
128         static etl::handle<Instance> create(etl::handle<synfig::Canvas> canvas);
129 }; // END class Instance
130
131 etl::handle<Instance> find_instance(etl::handle<synfig::Canvas> canvas);
132
133 bool is_editable(synfig::ValueNode::Handle value_node);
134
135 }; // END namespace studio
136
137 /* === E N D =============================================================== */
138
139 #endif