synfig-studio  1.0.3
dockmanager.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
21 /* ========================================================================= */
22 
23 /* === S T A R T =========================================================== */
24 
25 #ifndef __SYNFIG_DOCKMANAGER_H
26 #define __SYNFIG_DOCKMANAGER_H
27 
28 /* === H E A D E R S ======================================================= */
29 
30 #include <vector>
31 #include <list>
32 #include <map>
33 #include <synfig/string.h>
34 #include <sigc++/signal.h>
35 #include <sigc++/object.h>
36 #include <ETL/smart_ptr>
37 
38 #include <gtkmm/widget.h>
39 
40 /* === M A C R O S ========================================================= */
41 
42 /* === T Y P E D E F S ===================================================== */
43 
44 /* === C L A S S E S & S T R U C T S ======================================= */
45 
46 namespace studio {
47 
48 class Dockable;
49 class DockBook;
50 class DockDialog;
51 class DockSettings;
52 
53 class DockManager : public sigc::trackable
54 {
55  friend class Dockable;
56  friend class DockBook;
57  friend class DockDialog;
58  friend class DockSettings;
59 
60  std::list<Dockable*> dockable_list_;
61  std::list<DockDialog*> dock_dialog_list_;
62 
63  sigc::signal<void,Dockable*> signal_dockable_registered_;
64  sigc::signal<void,Dockable*> signal_dockable_unregistered_;
65 
66  etl::smart_ptr<DockSettings> dock_settings;
67 
68 private:
69  static std::map<Gtk::Container*, bool> containers_to_remove_;
70 
71  void write_separator(std::string &x, bool continue_ = true);
72  void write_string(std::string &x, const std::string &str);
73  void write_int(std::string &x, int i);
74  void write_bool(std::string &x, bool b);
75  void write_widget(std::string &x, Gtk::Widget* widget);
76 
77  bool read_separator(std::string &x);
78  std::string read_string(std::string &x);
79  int read_int(std::string &x);
80  bool read_bool(std::string &x);
81  Gtk::Widget* read_widget(std::string &x);
82 
83 public:
84  DockManager();
85  ~DockManager();
86 
88  const DockDialog& find_dock_dialog(int id)const;
90 
91  sigc::signal<void,Dockable*>& signal_dockable_registered() { return signal_dockable_registered_; }
93 
94  sigc::signal<void,Dockable*>& signal_dockable_unregistered() { return signal_dockable_unregistered_; }
95 
96  void register_dockable(Dockable& x);
98  Dockable& find_dockable(const synfig::String& x);
99  void present(synfig::String x);
100  void show_all_dock_dialogs();
101 
102  std::string save_widget_to_string(Gtk::Widget *widget);
103  Gtk::Widget* load_widget_from_string(const std::string &x);
104 
105  std::string save_layout_to_string();
106  void load_layout_from_string(const std::string &x);
107 
108  void update_window_titles();
109 
110  static std::string layout_from_template(const std::string &tpl, float dx, float dy, float sx, float sy);
111 
112  static bool swap_widgets(Gtk::Widget &widget1, Gtk::Widget &widget2);
113  static void remove_widget_recursive(Gtk::Widget &widget);
114  static void remove_widget_by_pointer_recursive(Gtk::Widget *widget) { remove_widget_recursive(*widget); }
115  static void remove_empty_container_recursive(Gtk::Container &container);
116  static void remove_empty_container_by_pointer_recursive(Gtk::Container *container) { remove_empty_container_recursive(*container); }
117  static bool add_widget(Gtk::Widget &dest_widget, Gtk::Widget &src_widget, bool vertical, bool first);
118  static bool add_dockable(Gtk::Widget &dest_widget, Dockable &dockable, bool vertical, bool first);
119 }; // END of class DockManager
120 
121 }; // END of namespace studio
122 
123 /* === E N D =============================================================== */
124 
125 #endif