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