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