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