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