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