Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / synfigstudio_0_61_06 / src / gtkmm / app.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file app.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_STUDIO_APP_H
26 #define __SYNFIG_STUDIO_APP_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include <sigc++/compatibility.h>
31 #include <sigc++/bind.h>
32
33 #include <gtkmm/main.h>
34 #include <string>
35 #include <list>
36
37 #include <ETL/smart_ptr>
38
39 #include <synfig/distance.h>
40 #include <synfig/string.h>
41 #include <synfig/time.h>
42
43 #include <gtkmm/uimanager.h>
44
45 #include <synfigapp/instance.h>
46 #include "iconcontroler.h"
47
48 /* === M A C R O S ========================================================= */
49
50 /* === T Y P E D E F S ===================================================== */
51
52 /* === C L A S S E S & S T R U C T S ======================================= */
53
54 namespace Gtk
55 {
56         class InputDialog;
57         class UIManager;
58         class ActionGroup;
59 };
60
61 namespace synfigapp
62 {
63         class UIInterface;
64         class Main;
65 };
66
67 class Preferences;
68
69 namespace studio {
70
71 typedef Gtk::UIManager UIManager;
72
73 class Toolbox;
74 class Instance;
75 class CanvasView;
76 class Dialog_Setup;
77 class Dialog_Gradient;
78 class Dialog_Color;
79 class Dialog_ToolOptions;
80 class DeviceTracker;
81 class AutoRecover;
82
83 class DockManager;
84
85 class Dock_History;
86 class Dock_Canvases;
87
88 class Dock_Keyframes;
89 class Dock_Params;
90 class Dock_Layers;
91 class Dock_MetaData;
92 class Dock_Children;
93 class Dock_Info;
94 class Dock_Navigator;
95 class Dock_LayerGroups;
96 class IPC;
97
98 class Module;
99
100 class StateManager;
101 class IconControler;
102
103 class App : public Gtk::Main, private IconControler
104 {
105         friend class Preferences;
106         friend class Dialog_Setup;
107
108         /*
109  -- ** -- P U B L I C   T Y P E S ---------------------------------------------
110         */
111
112 public:
113
114         struct Busy
115         {
116                 static int count;
117                 Busy(){count++;}
118                 ~Busy(){count--;}
119         };
120
121
122         /*
123  -- ** -- P R I V A T E   D A T A ---------------------------------------------
124         */
125
126 private:
127         //static etl::handle<synfigapp::UIInterface> ui_interface_;
128         //static int max_recent_files;
129
130 /*
131         static Dock_Keyframes *dock_keyframes;
132         static Dock_Layers *dock_layers;
133         static Dock_Params *dock_params;
134         static Dock_MetaData *dock_meta_data;
135         static Dock_Children *dock_children;
136         static Dock_Info *dock_info;
137         static Dock_Navigator *dock_navigator;
138         static Dock_History *dock_history;
139         static Dock_Canvases *dock_canvases;
140         static Dock_LayerGroups *dock_layer_groups;
141
142         static IPC *ipc;
143 */
144
145         etl::smart_ptr<synfigapp::Main> synfigapp_main;
146
147
148         static etl::handle<Instance> selected_instance;
149         static etl::handle<CanvasView> selected_canvas_view;
150
151         static Glib::RefPtr<UIManager>  ui_manager_;
152
153 //      static std::list< etl::handle< Module > > module_list_;
154
155         /*
156  -- ** -- P U B L I C   D A T A -----------------------------------------------
157         */
158
159 public:
160         static Gtk::InputDialog* dialog_input;
161
162         static DeviceTracker*   device_tracker;
163         static AutoRecover*     auto_recover;
164         static DockManager* dock_manager;
165
166         static DockManager* get_dock_manager() { return dock_manager; }
167
168         static Dialog_Setup* dialog_setup;
169         static Dialog_Gradient* dialog_gradient;
170         static Dialog_Color* dialog_color;
171 //      static Dialog_Palette* dialog_palette;
172         static Dialog_ToolOptions *dialog_tool_options;
173
174         static synfig::Distance::System distance_system;
175
176         static synfig::Gamma gamma;
177
178         static Toolbox *toolbox;
179
180         static std::list<etl::handle<Instance> > instance_list;
181
182         static bool shutdown_in_progress;
183
184         static bool use_colorspace_gamma;
185
186         /*
187  -- ** -- S I G N A L S -------------------------------------------------------
188         */
189 /*
190         static sigc::signal<
191                 void,
192                 etl::loose_handle<CanvasView>
193         > signal_canvas_view_focus_;
194         static sigc::signal<
195                 void,
196                 etl::handle<Instance>
197         > signal_instance_selected_;
198         static sigc::signal<
199                 void,
200                 etl::handle<Instance>
201         > signal_instance_created_;
202         static sigc::signal<
203                 void,
204                 etl::handle<Instance>
205         > signal_instance_deleted_;
206         static sigc::signal<void> signal_recent_files_changed_;
207         static sigc::signal<void> signal_present_all_;
208 */
209 public:
210
211         static sigc::signal<void> &signal_present_all();
212
213         static sigc::signal<void> &signal_recent_files_changed();
214
215         static sigc::signal<
216                 void,
217                 etl::loose_handle<CanvasView>
218         >& signal_canvas_view_focus();
219
220         static sigc::signal<
221                 void,
222                 etl::handle<Instance>
223         > &signal_instance_selected();
224
225         static sigc::signal<
226                 void,
227                 etl::handle<Instance>
228         > &signal_instance_created();
229
230         static sigc::signal<
231                 void,
232                 etl::handle<Instance>
233         > &signal_instance_deleted();
234
235         /*
236  -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
237         */
238
239 private:
240
241         /*
242  -- ** -- P U B L I C   M E T H O D S -----------------------------------------
243         */
244
245 public:
246
247         App(int *argc, char ***argv);
248         virtual ~App();
249
250         /*
251  -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
252         */
253
254 public:
255
256         static StateManager* get_state_manager();
257
258         static Glib::RefPtr<UIManager>& ui_manager() { return ui_manager_; }
259
260         static void add_recent_file(const std::string &filename);
261
262         static synfig::String get_base_path();
263         static void save_settings();
264         static void load_settings();
265
266         static const std::list<std::string>& get_recent_files();
267
268         static const etl::handle<synfigapp::UIInterface>& get_ui_interface();
269
270
271         static void set_selected_instance(etl::loose_handle<Instance> instance);
272         static void set_selected_canvas_view(etl::loose_handle<CanvasView>);
273
274         static etl::loose_handle<Instance> get_instance(etl::handle<synfig::Canvas> canvas);
275
276         static etl::loose_handle<Instance> get_selected_instance() { return selected_instance; }
277         static etl::loose_handle<CanvasView> get_selected_canvas_view() { return selected_canvas_view; }
278
279         static bool open(std::string filename);
280
281         static bool open_as(std::string filename,std::string as);
282
283         static void new_instance();
284
285         static void dialog_open();
286
287         static void dialog_about();
288
289         static void quit();
290
291         static void show_setup();
292
293         static void undo();
294         static void redo();
295
296         static int get_max_recent_files();
297         static void set_max_recent_files(int x);
298
299
300         static synfig::Time::Format get_time_format();
301         static void set_time_format(synfig::Time::Format x);
302
303         static bool shutdown_request(GdkEventAny*bleh=NULL);
304
305 //      static bool dialog_file(const std::string &title, std::string &filename);
306
307         static bool dialog_open_file(const std::string &title, std::string &filename);
308         static bool dialog_save_file(const std::string &title, std::string &filename);
309         static bool dialog_saveas_file(const std::string &title, std::string &filename);
310
311         static void dialog_error_blocking(const std::string &title, const std::string &message);
312
313         static void dialog_warning_blocking(const std::string &title, const std::string &message);
314
315         static bool dialog_entry(const std::string &title, const std::string &message,std::string &text);
316
317         static bool dialog_yes_no(const std::string &title, const std::string &message);
318
319         static int dialog_yes_no_cancel(const std::string &title, const std::string &message);
320
321         static void dialog_not_implemented();
322
323         static synfig::String get_user_app_directory();
324         static synfig::String get_config_file(const synfig::String& file);
325 }; // END of class App
326
327 }; // END namespace studio
328
329 /* === E N D =============================================================== */
330
331 #endif