synfig-studio  1.0.3
app.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
24 /* ========================================================================= */
25 
26 /* === S T A R T =========================================================== */
27 
28 #ifndef __SYNFIG_STUDIO_APP_H
29 #define __SYNFIG_STUDIO_APP_H
30 
31 /* === H E A D E R S ======================================================= */
32 
33 #include <sigc++/bind.h>
34 
35 #include <gtkmm/main.h>
36 #include <string>
37 #include <list>
38 
39 #include <ETL/smart_ptr>
40 
41 #include <synfig/distance.h>
42 #include <synfig/string.h>
43 #include <synfig/time.h>
44 
45 #include <synfig/filecontainerzip.h>
46 
47 #include <gtkmm/uimanager.h>
48 
49 #include <synfigapp/instance.h>
51 #include "iconcontroller.h"
52 
53 /* === M A C R O S ========================================================= */
54 
55 #define MISC_DIR_PREFERENCE "misc_dir"
56 #define ANIMATION_DIR_PREFERENCE "animation_dir"
57 #define IMAGE_DIR_PREFERENCE "image_dir"
58 #define SKETCH_DIR_PREFERENCE "sketch_dir"
59 #define RENDER_DIR_PREFERENCE "render_dir"
60 
61 // uncomment define SINGLE_THREADED to use a single thread, and hopefully get more stability (dooglus) - changed to be default if using windows (Nov 2009 pixelgeek)
62 #ifdef WIN32
63 #define SINGLE_THREADED
64 #endif
65 
66 /* === T Y P E D E F S ===================================================== */
67 
68 /* === C L A S S E S & S T R U C T S ======================================= */
69 
70 namespace Gtk
71 {
72  class UIManager;
73  class ActionGroup;
74 };
75 
76 namespace synfigapp
77 {
78  class UIInterface;
79  class Main;
80 };
81 
82 class Preferences;
83 
84 namespace studio {
85 
87 
88 class About;
89 class MainWindow;
90 class Instance;
91 class CanvasView;
92 class Dialog_Setup;
93 class Dialog_Gradient;
94 class Dialog_Input;
95 class Dialog_Color;
96 class Dialog_ToolOptions;
97 class DeviceTracker;
98 class AutoRecover;
99 
100 class DockManager;
101 
102 class Dock_Toolbox;
103 class Dock_History;
104 class Dock_Canvases;
105 
106 class Dock_Keyframes;
107 class Dock_Params;
108 class Dock_Layers;
109 class Dock_MetaData;
110 class Dock_Children;
111 class Dock_Info;
112 class Dock_Navigator;
113 class Dock_LayerGroups;
114 class IPC;
115 
116 class Module;
117 
118 class StateManager;
119 class IconController;
120 
121 class App : public Gtk::Main, private IconController
122 {
123  friend class Preferences;
124  friend class Dialog_Setup;
125 
126  /*
127  -- ** -- P U B L I C T Y P E S ---------------------------------------------
128  */
129 
130 public:
131 
132  struct Busy
133  {
134  static int count;
135  Busy(){count++;}
136  ~Busy(){count--;}
137  };
138 
139  enum Response
140  {
142  };
143 
144 
145  /*
146  -- ** -- P R I V A T E D A T A ---------------------------------------------
147  */
148 
149 private:
150  //static etl::handle<synfigapp::UIInterface> ui_interface_;
151  //static int max_recent_files;
152 
153 /* //declated as globals in app.cpp
154  static Dock_Keyframes *dock_keyframes;
155  static Dock_Layers *dock_layers;
156  static Dock_Params *dock_params;
157  static Dock_MetaData *dock_meta_data;
158  static Dock_Children *dock_children;
159  static Dock_Info *dock_info;
160  static Dock_Navigator *dock_navigator;
161  static Dock_History *dock_history;
162  static Dock_Canvases *dock_canvases;
163  static Dock_LayerGroups *dock_layer_groups;
164 
165  static IPC *ipc;
166 */
167 
168  etl::smart_ptr<synfigapp::Main> synfigapp_main;
169 
170 
171  static etl::handle<Instance> selected_instance;
172  static etl::handle<CanvasView> selected_canvas_view;
173 
174  static Glib::RefPtr<UIManager> ui_manager_;
175 
176  static int jack_locks_;
177 
178 // static std::list< etl::handle< Module > > module_list_;
179 
180  /*
181  -- ** -- P U B L I C D A T A -----------------------------------------------
182  */
183 
184 public:
186 
190 
192 
196 // static Dialog_Palette* dialog_palette;
198 
199  static synfig::Distance::System distance_system;
200 
201  static synfig::Gamma gamma;
202 
203  static About *about;
206 
207  static std::list<etl::handle<Instance> > instance_list;
208 
209  static bool shutdown_in_progress;
210 
211  static bool use_colorspace_gamma;
212 
213 #ifdef SINGLE_THREADED
214  static bool single_threaded;
215 #endif
216 
220  static bool use_dark_theme;
221 
223 
224  static synfig::String browser_command;
225  static synfig::String brushes_path;
226  static synfig::String custom_filename_prefix;
227  static int preferred_x_size;
228  static int preferred_y_size;
229  static synfig::String predefined_size;
230  static synfig::String predefined_fps;
231  static float preferred_fps;
232  static synfig::String sequence_separator;
233  static bool navigator_uses_cairo;
234  static bool workarea_uses_cairo;
236  static synfig::String ui_language;
237 
238  /*
239  -- ** -- S I G N A L S -------------------------------------------------------
240  */
241 /* //declated as globals in app.cpp
242  static sigc::signal<
243  void,
244  etl::loose_handle<CanvasView>
245  > signal_canvas_view_focus_;
246  static sigc::signal<
247  void,
248  etl::handle<Instance>
249  > signal_instance_selected_;
250  static sigc::signal<
251  void,
252  etl::handle<Instance>
253  > signal_instance_created_;
254  static sigc::signal<
255  void,
256  etl::handle<Instance>
257  > signal_instance_deleted_;
258  static sigc::signal<void> signal_recent_files_changed_;
259  static sigc::signal<void> signal_present_all_;
260 */
261 public:
262 
263  static sigc::signal<void> &signal_present_all();
264 
265  static sigc::signal<void> &signal_recent_files_changed();
266 
267  static sigc::signal<
268  void,
269  etl::loose_handle<CanvasView>
271 
272  static sigc::signal<
273  void,
274  etl::handle<Instance>
276 
277  static sigc::signal<
278  void,
279  etl::handle<Instance>
281 
282  static sigc::signal<
283  void,
284  etl::handle<Instance>
286 
287  /*
288  -- ** -- P R I V A T E M E T H O D S ---------------------------------------
289  */
290 
291 private:
292  static void add_recent_file(const std::string &filename);
293 
294  /*
295  -- ** -- P U B L I C M E T H O D S -----------------------------------------
296  */
297 
298 public:
299 
300  App(const synfig::String& basepath, int *argc, char ***argv);
301  virtual ~App();
302 
303  /*
304  -- ** -- S T A T I C P U B L I C M E T H O D S ---------------------------
305  */
306 
307 public:
308 
310 
311  static Glib::RefPtr<UIManager>& ui_manager() { return ui_manager_; }
312 
313  static void add_recent_file(const etl::handle<Instance> instance);
314 
315  static synfig::String get_base_path();
316  static void save_settings();
317  static bool load_settings(const synfig::String& key_filter = "");
318  static void load_accel_map();
319  static void load_file_window_size();
320  static void load_language_settings();
321  static void set_workspace_default();
322  static void set_workspace_compositing();
323  static void set_workspace_animating();
324  static void restore_default_settings();
325  static void apply_gtk_settings(bool);
326 
327  static const std::list<std::string>& get_recent_files();
328 
329  static const etl::handle<synfigapp::UIInterface>& get_ui_interface();
330 
331 
332  static void set_selected_instance(etl::loose_handle<Instance> instance);
333  static void set_selected_canvas_view(etl::loose_handle<CanvasView>);
334 
335  static etl::loose_handle<Instance> get_instance(etl::handle<synfig::Canvas> canvas);
336 
337  static etl::loose_handle<Instance> get_selected_instance() { return selected_instance; }
338  static etl::loose_handle<CanvasView> get_selected_canvas_view() { return selected_canvas_view; }
339 
340  static bool open(std::string filename);
341 
342  static bool open_as(std::string filename,std::string as,synfig::FileContainerZip::file_size_t truncate_storage_size = 0);
343 
344  static bool open_from_temporary_container_as(std::string container_filename_base,std::string as);
345 
346  static void new_instance();
347 
348  static void dialog_open(std::string filename = "");
349 
350  static void dialog_about();
351 
352  static void quit();
353 
354  static void show_setup();
355 
356  static void undo();
357  static void redo();
358 
359  static int get_max_recent_files();
360  static void set_max_recent_files(int x);
361 
362  static bool jack_is_locked();
363  static void jack_lock();
364  static void jack_unlock();
365 
366  static synfig::Time::Format get_time_format();
367  static void set_time_format(synfig::Time::Format x);
368 
369  static bool shutdown_request(GdkEventAny*bleh=NULL);
370 
371 // static bool dialog_file(const std::string &title, std::string &filename);
372 
373  static bool dialog_open_file(const std::string &title, std::string &filename, std::string preference);
374  static bool dialog_open_file_spal(const std::string &title, std::string &filename, std::string preference);
375  static bool dialog_open_file_sketch(const std::string &title, std::string &filename, std::string preference);
376  static bool dialog_open_file_image(const std::string &title, std::string &filename, std::string preference);
377  static bool dialog_open_file_audio(const std::string &title, std::string &filename, std::string preference);
378  static bool dialog_open_file_with_history_button(const std::string &title, std::string &filename, bool &show_history, std::string preference);
379  static bool dialog_save_file(const std::string &title, std::string &filename, std::string preference);
380  static bool dialog_save_file_spal(const std::string &title, std::string &filename, std::string preference);
381  static bool dialog_save_file_sketch(const std::string &title, std::string &filename, std::string preference);
382  static bool dialog_save_file_render(const std::string &title, std::string &filename, std::string preference);
383 
384  static bool dialog_select_list_item(const std::string &title, const std::string &message, const std::list<std::string> &list, int &item_index);
385 
386  static bool dialog_entry(const std::string &action, const std::string &content, std::string &text, const std::string &button1, const std::string &button2);
387 
388  static bool dialog_paragraph(const std::string &title, const std::string &message,std::string &text);
389 
390  static void dialog_not_implemented();
391 
392  static void dialog_help();
393 
394  static void dialog_message_1b(
395  const std::string &type,
396  const std::string &message,
397  const std::string &detials,
398  const std::string &button1,
399  const std::string &long_details = "long_details");
400 
401  static bool dialog_message_2b(const std::string &message,
402  const std::string &details,
403  const Gtk::MessageType &type,
404  const std::string &button1,
405  const std::string &button2);
406 
407  static int dialog_message_3b(const std::string &message,
408  const std::string &details,
409  const Gtk::MessageType &type,
410  const std::string &button1,
411  const std::string &button2,
412  const std::string &button3);
413 
414  static void open_url(const std::string &url);
415 
416  static synfig::String get_config_file(const synfig::String& file);
417  // This will spread the changes made in preferences.
418  // (By now it updates the System Units or Time Format for all the canvases).
419  // This fixes bug 1890020
420  static void setup_changed();
421 }; // END of class App
422 
423  void delete_widget(Gtk::Widget *widget);
424 
425 }; // END namespace studio
426 
427 /* === E N D =============================================================== */
428 
429 #endif