source: synfigstudio/trunk/fuentes/src/gui/app.h @ 481

Last change on this file since 481 was 481, checked in by jrpelegrina, 4 years ago

First release to xenial

File size: 11.7 KB
Line 
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, 2013 Carlos López
11**      Copyright (c) 2012 Konstantin Dmitriev
12**
13**      This package is free software; you can redistribute it and/or
14**      modify it under the terms of the GNU General Public License as
15**      published by the Free Software Foundation; either version 2 of
16**      the License, or (at your option) any later version.
17**
18**      This package is distributed in the hope that it will be useful,
19**      but WITHOUT ANY WARRANTY; without even the implied warranty of
20**      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21**      General Public License for more details.
22**      \endlegal
23*/
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>
50#include <synfigapp/pluginmanager.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
70namespace Gtk
71{
72        class UIManager;
73        class ActionGroup;
74};
75
76namespace synfigapp
77{
78        class UIInterface;
79        class Main;
80};
81
82class Preferences;
83
84namespace studio {
85
86typedef Gtk::UIManager UIManager;
87
88class About;
89class MainWindow;
90class Instance;
91class CanvasView;
92class Dialog_Setup;
93class Dialog_Gradient;
94class Dialog_Input;
95class Dialog_Color;
96class Dialog_ToolOptions;
97class DeviceTracker;
98class AutoRecover;
99
100class DockManager;
101
102class Dock_Toolbox;
103class Dock_History;
104class Dock_Canvases;
105
106class Dock_Keyframes;
107class Dock_Params;
108class Dock_Layers;
109class Dock_MetaData;
110class Dock_Children;
111class Dock_Info;
112class Dock_Navigator;
113class Dock_LayerGroups;
114class IPC;
115
116class Module;
117
118class StateManager;
119class IconController;
120
121class 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
130public:
131
132        struct Busy
133        {
134                static int count;
135                Busy(){count++;}
136                ~Busy(){count--;}
137        };
138
139        enum Response
140        {
141                RESPONSE_ACCEPT_WITH_HISTORY = 1
142        };
143
144
145        /*
146 -- ** -- P R I V A T E   D A T A ---------------------------------------------
147        */
148
149private:
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
184public:
185        static Dialog_Input* dialog_input;
186
187        static DeviceTracker*   device_tracker;
188        static AutoRecover*     auto_recover;
189        static DockManager* dock_manager;
190
191        static DockManager* get_dock_manager() { return dock_manager; }
192
193        static Dialog_Setup* dialog_setup;
194        static Dialog_Gradient* dialog_gradient;
195        static Dialog_Color* dialog_color;
196//      static Dialog_Palette* dialog_palette;
197        static Dialog_ToolOptions *dialog_tool_options;
198
199        static synfig::Distance::System distance_system;
200
201        static synfig::Gamma gamma;
202
203        static About *about;
204        static MainWindow *main_window;
205        static Dock_Toolbox *dock_toolbox;
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
217        static bool restrict_radius_ducks;
218        static bool resize_imported_images;
219        static bool enable_experimental_features;
220        static bool use_dark_theme;
221
222        static synfigapp::PluginManager plugin_manager;
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;
235        static bool enable_mainwin_menubar;
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*/
261public:
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>
270        >& signal_canvas_view_focus();
271
272        static sigc::signal<
273                void,
274                etl::handle<Instance>
275        > &signal_instance_selected();
276
277        static sigc::signal<
278                void,
279                etl::handle<Instance>
280        > &signal_instance_created();
281
282        static sigc::signal<
283                void,
284                etl::handle<Instance>
285        > &signal_instance_deleted();
286
287        /*
288 -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
289        */
290
291private:
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
298public:
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
307public:
308
309        static StateManager* get_state_manager();
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
Note: See TracBrowser for help on using the repository browser.