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
10 ** Copyright (c) 2008 Carlos López
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.
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.
23 /* ========================================================================= */
25 /* === S T A R T =========================================================== */
27 #ifndef __SYNFIG_STUDIO_APP_H
28 #define __SYNFIG_STUDIO_APP_H
30 /* === H E A D E R S ======================================================= */
32 #include <sigc++/bind.h>
34 #include <gtkmm/main.h>
38 #include <ETL/smart_ptr>
40 #include <synfig/distance.h>
41 #include <synfig/string.h>
42 #include <synfig/time.h>
44 #include <gtkmm/uimanager.h>
46 #include <synfigapp/instance.h>
47 #include "iconcontroller.h"
49 /* === M A C R O S ========================================================= */
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"
57 /* === T Y P E D E F S ===================================================== */
59 /* === C L A S S E S & S T R U C T S ======================================= */
78 typedef Gtk::UIManager UIManager;
85 class Dialog_Gradient;
87 class Dialog_ToolOptions;
102 class Dock_Navigator;
103 class Dock_LayerGroups;
109 class IconController;
111 class App : public Gtk::Main, private IconController
113 friend class Preferences;
114 friend class Dialog_Setup;
117 -- ** -- P U B L I C T Y P E S ---------------------------------------------
131 -- ** -- P R I V A T E D A T A ---------------------------------------------
135 //static etl::handle<synfigapp::UIInterface> ui_interface_;
136 //static int max_recent_files;
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;
153 etl::smart_ptr<synfigapp::Main> synfigapp_main;
156 static etl::handle<Instance> selected_instance;
157 static etl::handle<CanvasView> selected_canvas_view;
159 static Glib::RefPtr<UIManager> ui_manager_;
161 // static std::list< etl::handle< Module > > module_list_;
164 -- ** -- P U B L I C D A T A -----------------------------------------------
168 static Gtk::InputDialog* dialog_input;
170 static DeviceTracker* device_tracker;
171 static AutoRecover* auto_recover;
172 static DockManager* dock_manager;
174 static DockManager* get_dock_manager() { return dock_manager; }
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;
182 static synfig::Distance::System distance_system;
184 static synfig::Gamma gamma;
187 static Toolbox *toolbox;
189 static std::list<etl::handle<Instance> > instance_list;
191 static bool shutdown_in_progress;
193 static bool use_colorspace_gamma;
195 #ifdef SINGLE_THREADED
196 static bool single_threaded;
199 static bool restrict_radius_ducks;
200 static bool resize_imported_images;
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 static synfig::String predefined_fps;
208 static float preferred_fps;
210 -- ** -- S I G N A L S -------------------------------------------------------
215 etl::loose_handle<CanvasView>
216 > signal_canvas_view_focus_;
219 etl::handle<Instance>
220 > signal_instance_selected_;
223 etl::handle<Instance>
224 > signal_instance_created_;
227 etl::handle<Instance>
228 > signal_instance_deleted_;
229 static sigc::signal<void> signal_recent_files_changed_;
230 static sigc::signal<void> signal_present_all_;
234 static sigc::signal<void> &signal_present_all();
236 static sigc::signal<void> &signal_recent_files_changed();
240 etl::loose_handle<CanvasView>
241 >& signal_canvas_view_focus();
245 etl::handle<Instance>
246 > &signal_instance_selected();
250 etl::handle<Instance>
251 > &signal_instance_created();
255 etl::handle<Instance>
256 > &signal_instance_deleted();
259 -- ** -- P R I V A T E M E T H O D S ---------------------------------------
263 static void add_recent_file(const std::string &filename, const std::string &window_size = std::string());
266 -- ** -- P U B L I C M E T H O D S -----------------------------------------
271 App(int *argc, char ***argv);
275 -- ** -- S T A T I C P U B L I C M E T H O D S ---------------------------
280 static StateManager* get_state_manager();
282 static Glib::RefPtr<UIManager>& ui_manager() { return ui_manager_; }
284 static void set_recent_file_window_size(etl::handle<Instance> instance);
285 static void add_recent_file(const etl::handle<Instance> instance);
287 static synfig::String get_base_path();
288 static void save_settings();
289 static void load_settings();
290 static void reset_initial_window_configuration();
292 static const std::list<std::string>& get_recent_files();
294 static const etl::handle<synfigapp::UIInterface>& get_ui_interface();
297 static void set_selected_instance(etl::loose_handle<Instance> instance);
298 static void set_selected_canvas_view(etl::loose_handle<CanvasView>);
300 static etl::loose_handle<Instance> get_instance(etl::handle<synfig::Canvas> canvas);
302 static etl::loose_handle<Instance> get_selected_instance() { return selected_instance; }
303 static etl::loose_handle<CanvasView> get_selected_canvas_view() { return selected_canvas_view; }
305 static bool open(std::string filename);
307 static bool open_as(std::string filename,std::string as);
309 static void new_instance();
311 static void dialog_open(std::string filename = "");
313 static void dialog_about();
317 static void show_setup();
322 static int get_max_recent_files();
323 static void set_max_recent_files(int x);
326 static synfig::Time::Format get_time_format();
327 static void set_time_format(synfig::Time::Format x);
329 static bool shutdown_request(GdkEventAny*bleh=NULL);
331 // static bool dialog_file(const std::string &title, std::string &filename);
333 static bool dialog_open_file(const std::string &title, std::string &filename, std::string preference);
334 static bool dialog_save_file(const std::string &title, std::string &filename, std::string preference);
336 static void dialog_error_blocking(const std::string &title, const std::string &message);
338 static void dialog_warning_blocking(const std::string &title, const std::string &message);
340 static bool dialog_entry(const std::string &title, const std::string &message,std::string &text);
341 static bool dialog_paragraph(const std::string &title, const std::string &message,std::string &text);
343 static bool dialog_yes_no(const std::string &title, const std::string &message);
345 static int dialog_yes_no_cancel(const std::string &title, const std::string &message);
347 static void dialog_not_implemented();
349 static void dialog_help();
351 static void open_url(const std::string &url);
353 static synfig::String get_user_app_directory();
354 static synfig::String get_config_file(const synfig::String& file);
355 }; // END of class App
357 void delete_widget(Gtk::Widget *widget);
359 }; // END namespace studio
361 /* === E N D =============================================================== */