1 /* === S Y N F I G ========================================================= */
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007, 2008 Chris Moore
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.
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.
22 /* ========================================================================= */
24 /* === S T A R T =========================================================== */
26 #ifndef __SYNFIG_STUDIO_APP_H
27 #define __SYNFIG_STUDIO_APP_H
29 /* === H E A D E R S ======================================================= */
31 #include <sigc++/bind.h>
33 #include <gtkmm/main.h>
37 #include <ETL/smart_ptr>
39 #include <synfig/distance.h>
40 #include <synfig/string.h>
41 #include <synfig/time.h>
43 #include <gtkmm/uimanager.h>
45 #include <synfigapp/instance.h>
46 #include "iconcontroller.h"
48 /* === M A C R O S ========================================================= */
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"
56 /* === T Y P E D E F S ===================================================== */
58 /* === C L A S S E S & S T R U C T S ======================================= */
77 typedef Gtk::UIManager UIManager;
84 class Dialog_Gradient;
86 class Dialog_ToolOptions;
101 class Dock_Navigator;
102 class Dock_LayerGroups;
108 class IconController;
110 class App : public Gtk::Main, private IconController
112 friend class Preferences;
113 friend class Dialog_Setup;
116 -- ** -- P U B L I C T Y P E S ---------------------------------------------
130 -- ** -- P R I V A T E D A T A ---------------------------------------------
134 //static etl::handle<synfigapp::UIInterface> ui_interface_;
135 //static int max_recent_files;
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;
152 etl::smart_ptr<synfigapp::Main> synfigapp_main;
155 static etl::handle<Instance> selected_instance;
156 static etl::handle<CanvasView> selected_canvas_view;
158 static Glib::RefPtr<UIManager> ui_manager_;
160 // static std::list< etl::handle< Module > > module_list_;
163 -- ** -- P U B L I C D A T A -----------------------------------------------
167 static Gtk::InputDialog* dialog_input;
169 static DeviceTracker* device_tracker;
170 static AutoRecover* auto_recover;
171 static DockManager* dock_manager;
173 static DockManager* get_dock_manager() { return dock_manager; }
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;
181 static synfig::Distance::System distance_system;
183 static synfig::Gamma gamma;
186 static Toolbox *toolbox;
188 static std::list<etl::handle<Instance> > instance_list;
190 static bool shutdown_in_progress;
192 static bool use_colorspace_gamma;
194 #ifdef SINGLE_THREADED
195 static bool single_threaded;
198 static bool restrict_radius_ducks;
200 static synfig::String browser_command;
203 -- ** -- S I G N A L S -------------------------------------------------------
208 etl::loose_handle<CanvasView>
209 > signal_canvas_view_focus_;
212 etl::handle<Instance>
213 > signal_instance_selected_;
216 etl::handle<Instance>
217 > signal_instance_created_;
220 etl::handle<Instance>
221 > signal_instance_deleted_;
222 static sigc::signal<void> signal_recent_files_changed_;
223 static sigc::signal<void> signal_present_all_;
227 static sigc::signal<void> &signal_present_all();
229 static sigc::signal<void> &signal_recent_files_changed();
233 etl::loose_handle<CanvasView>
234 >& signal_canvas_view_focus();
238 etl::handle<Instance>
239 > &signal_instance_selected();
243 etl::handle<Instance>
244 > &signal_instance_created();
248 etl::handle<Instance>
249 > &signal_instance_deleted();
252 -- ** -- P R I V A T E M E T H O D S ---------------------------------------
256 static void add_recent_file(const std::string &filename, const std::string &window_size = std::string());
259 -- ** -- P U B L I C M E T H O D S -----------------------------------------
264 App(int *argc, char ***argv);
268 -- ** -- S T A T I C P U B L I C M E T H O D S ---------------------------
273 static StateManager* get_state_manager();
275 static Glib::RefPtr<UIManager>& ui_manager() { return ui_manager_; }
277 static void set_recent_file_window_size(etl::handle<Instance> instance);
278 static void add_recent_file(const etl::handle<Instance> instance);
280 static synfig::String get_base_path();
281 static void save_settings();
282 static void load_settings();
283 static void reset_initial_window_configuration();
285 static const std::list<std::string>& get_recent_files();
287 static const etl::handle<synfigapp::UIInterface>& get_ui_interface();
290 static void set_selected_instance(etl::loose_handle<Instance> instance);
291 static void set_selected_canvas_view(etl::loose_handle<CanvasView>);
293 static etl::loose_handle<Instance> get_instance(etl::handle<synfig::Canvas> canvas);
295 static etl::loose_handle<Instance> get_selected_instance() { return selected_instance; }
296 static etl::loose_handle<CanvasView> get_selected_canvas_view() { return selected_canvas_view; }
298 static bool open(std::string filename);
300 static bool open_as(std::string filename,std::string as);
302 static void new_instance();
304 static void dialog_open(std::string filename = "");
306 static void dialog_about();
310 static void show_setup();
315 static int get_max_recent_files();
316 static void set_max_recent_files(int x);
319 static synfig::Time::Format get_time_format();
320 static void set_time_format(synfig::Time::Format x);
322 static bool shutdown_request(GdkEventAny*bleh=NULL);
324 // static bool dialog_file(const std::string &title, std::string &filename);
326 static bool dialog_open_file(const std::string &title, std::string &filename, std::string preference);
327 static bool dialog_save_file(const std::string &title, std::string &filename, std::string preference);
329 static void dialog_error_blocking(const std::string &title, const std::string &message);
331 static void dialog_warning_blocking(const std::string &title, const std::string &message);
333 static bool dialog_entry(const std::string &title, const std::string &message,std::string &text);
334 static bool dialog_paragraph(const std::string &title, const std::string &message,std::string &text);
336 static bool dialog_yes_no(const std::string &title, const std::string &message);
338 static int dialog_yes_no_cancel(const std::string &title, const std::string &message);
340 static void dialog_not_implemented();
342 static void dialog_help();
344 static void open_url(const std::string &url);
346 static synfig::String get_user_app_directory();
347 static synfig::String get_config_file(const synfig::String& file);
348 }; // END of class App
350 void delete_widget(Gtk::Widget *widget);
352 }; // END namespace studio
354 /* === E N D =============================================================== */