Remove ancient trunk folder from svn repository
[synfig.git] / synfig-studio / 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         static bool resize_imported_images;
201
202         static synfig::String browser_command;
203         static synfig::String custom_filename_prefix;
204         static int preferred_x_size;
205         static int preferred_y_size;
206         static synfig::String predefined_size;
207         static synfig::String predefined_fps;
208         static float preferred_fps;
209         /*
210  -- ** -- S I G N A L S -------------------------------------------------------
211         */
212 /*
213         static sigc::signal<
214                 void,
215                 etl::loose_handle<CanvasView>
216         > signal_canvas_view_focus_;
217         static sigc::signal<
218                 void,
219                 etl::handle<Instance>
220         > signal_instance_selected_;
221         static sigc::signal<
222                 void,
223                 etl::handle<Instance>
224         > signal_instance_created_;
225         static sigc::signal<
226                 void,
227                 etl::handle<Instance>
228         > signal_instance_deleted_;
229         static sigc::signal<void> signal_recent_files_changed_;
230         static sigc::signal<void> signal_present_all_;
231 */
232 public:
233
234         static sigc::signal<void> &signal_present_all();
235
236         static sigc::signal<void> &signal_recent_files_changed();
237
238         static sigc::signal<
239                 void,
240                 etl::loose_handle<CanvasView>
241         >& signal_canvas_view_focus();
242
243         static sigc::signal<
244                 void,
245                 etl::handle<Instance>
246         > &signal_instance_selected();
247
248         static sigc::signal<
249                 void,
250                 etl::handle<Instance>
251         > &signal_instance_created();
252
253         static sigc::signal<
254                 void,
255                 etl::handle<Instance>
256         > &signal_instance_deleted();
257
258         /*
259  -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
260         */
261
262 private:
263         static void add_recent_file(const std::string &filename, const std::string &window_size = std::string());
264
265         /*
266  -- ** -- P U B L I C   M E T H O D S -----------------------------------------
267         */
268
269 public:
270
271         App(int *argc, char ***argv);
272         virtual ~App();
273
274         /*
275  -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
276         */
277
278 public:
279
280         static StateManager* get_state_manager();
281
282         static Glib::RefPtr<UIManager>& ui_manager() { return ui_manager_; }
283
284         static void set_recent_file_window_size(etl::handle<Instance> instance);
285         static void add_recent_file(const etl::handle<Instance> instance);
286
287         static synfig::String get_base_path();
288         static void save_settings();
289         static void load_settings();
290         static void reset_initial_window_configuration();
291
292         static const std::list<std::string>& get_recent_files();
293
294         static const etl::handle<synfigapp::UIInterface>& get_ui_interface();
295
296
297         static void set_selected_instance(etl::loose_handle<Instance> instance);
298         static void set_selected_canvas_view(etl::loose_handle<CanvasView>);
299
300         static etl::loose_handle<Instance> get_instance(etl::handle<synfig::Canvas> canvas);
301
302         static etl::loose_handle<Instance> get_selected_instance() { return selected_instance; }
303         static etl::loose_handle<CanvasView> get_selected_canvas_view() { return selected_canvas_view; }
304
305         static bool open(std::string filename);
306
307         static bool open_as(std::string filename,std::string as);
308
309         static void new_instance();
310
311         static void dialog_open(std::string filename = "");
312
313         static void dialog_about();
314
315         static void quit();
316
317         static void show_setup();
318
319         static void undo();
320         static void redo();
321
322         static int get_max_recent_files();
323         static void set_max_recent_files(int x);
324
325
326         static synfig::Time::Format get_time_format();
327         static void set_time_format(synfig::Time::Format x);
328
329         static bool shutdown_request(GdkEventAny*bleh=NULL);
330
331 //      static bool dialog_file(const std::string &title, std::string &filename);
332
333         static bool dialog_open_file(const std::string &title, std::string &filename, std::string preference);
334         static bool dialog_save_file(const std::string &title, std::string &filename, std::string preference);
335
336         static void dialog_error_blocking(const std::string &title, const std::string &message);
337
338         static void dialog_warning_blocking(const std::string &title, const std::string &message);
339
340         static bool dialog_entry(const std::string &title, const std::string &message,std::string &text);
341         static bool dialog_paragraph(const std::string &title, const std::string &message,std::string &text);
342
343         static bool dialog_yes_no(const std::string &title, const std::string &message);
344
345         static int dialog_yes_no_cancel(const std::string &title, const std::string &message);
346
347         static void dialog_not_implemented();
348
349         static void dialog_help();
350
351         static void open_url(const std::string &url);
352
353         static synfig::String get_user_app_directory();
354         static synfig::String get_config_file(const synfig::String& file);
355 }; // END of class App
356
357         void delete_widget(Gtk::Widget *widget);
358
359 }; // END namespace studio
360
361 /* === E N D =============================================================== */
362
363 #endif