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;
208 -- ** -- S I G N A L S -------------------------------------------------------
213 etl::loose_handle<CanvasView>
214 > signal_canvas_view_focus_;
217 etl::handle<Instance>
218 > signal_instance_selected_;
221 etl::handle<Instance>
222 > signal_instance_created_;
225 etl::handle<Instance>
226 > signal_instance_deleted_;
227 static sigc::signal<void> signal_recent_files_changed_;
228 static sigc::signal<void> signal_present_all_;
232 static sigc::signal<void> &signal_present_all();
234 static sigc::signal<void> &signal_recent_files_changed();
238 etl::loose_handle<CanvasView>
239 >& signal_canvas_view_focus();
243 etl::handle<Instance>
244 > &signal_instance_selected();
248 etl::handle<Instance>
249 > &signal_instance_created();
253 etl::handle<Instance>
254 > &signal_instance_deleted();
257 -- ** -- P R I V A T E M E T H O D S ---------------------------------------
261 static void add_recent_file(const std::string &filename, const std::string &window_size = std::string());
264 -- ** -- P U B L I C M E T H O D S -----------------------------------------
269 App(int *argc, char ***argv);
273 -- ** -- S T A T I C P U B L I C M E T H O D S ---------------------------
278 static StateManager* get_state_manager();
280 static Glib::RefPtr<UIManager>& ui_manager() { return ui_manager_; }
282 static void set_recent_file_window_size(etl::handle<Instance> instance);
283 static void add_recent_file(const etl::handle<Instance> instance);
285 static synfig::String get_base_path();
286 static void save_settings();
287 static void load_settings();
288 static void reset_initial_window_configuration();
290 static const std::list<std::string>& get_recent_files();
292 static const etl::handle<synfigapp::UIInterface>& get_ui_interface();
295 static void set_selected_instance(etl::loose_handle<Instance> instance);
296 static void set_selected_canvas_view(etl::loose_handle<CanvasView>);
298 static etl::loose_handle<Instance> get_instance(etl::handle<synfig::Canvas> canvas);
300 static etl::loose_handle<Instance> get_selected_instance() { return selected_instance; }
301 static etl::loose_handle<CanvasView> get_selected_canvas_view() { return selected_canvas_view; }
303 static bool open(std::string filename);
305 static bool open_as(std::string filename,std::string as);
307 static void new_instance();
309 static void dialog_open(std::string filename = "");
311 static void dialog_about();
315 static void show_setup();
320 static int get_max_recent_files();
321 static void set_max_recent_files(int x);
324 static synfig::Time::Format get_time_format();
325 static void set_time_format(synfig::Time::Format x);
327 static bool shutdown_request(GdkEventAny*bleh=NULL);
329 // static bool dialog_file(const std::string &title, std::string &filename);
331 static bool dialog_open_file(const std::string &title, std::string &filename, std::string preference);
332 static bool dialog_save_file(const std::string &title, std::string &filename, std::string preference);
334 static void dialog_error_blocking(const std::string &title, const std::string &message);
336 static void dialog_warning_blocking(const std::string &title, const std::string &message);
338 static bool dialog_entry(const std::string &title, const std::string &message,std::string &text);
339 static bool dialog_paragraph(const std::string &title, const std::string &message,std::string &text);
341 static bool dialog_yes_no(const std::string &title, const std::string &message);
343 static int dialog_yes_no_cancel(const std::string &title, const std::string &message);
345 static void dialog_not_implemented();
347 static void dialog_help();
349 static void open_url(const std::string &url);
351 static synfig::String get_user_app_directory();
352 static synfig::String get_config_file(const synfig::String& file);
353 }; // END of class App
355 void delete_widget(Gtk::Widget *widget);
357 }; // END namespace studio
359 /* === E N D =============================================================== */