1 /* === S Y N F I G ========================================================= */
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
35 #include "dockmanager.h"
37 #include <gtkmm/image.h>
38 #include <gtkmm/eventbox.h>
39 #include <gtkmm/menu.h>
43 /* === U S I N G =========================================================== */
47 using namespace synfig;
48 using namespace studio;
50 /* === M A C R O S ========================================================= */
52 /* === G L O B A L S ======================================================= */
54 /* === P R O C E D U R E S ================================================= */
56 /* === M E T H O D S ======================================================= */
60 std::list<Gtk::TargetEntry> listTargets;
61 listTargets.push_back( Gtk::TargetEntry("DOCK") );
63 drag_dest_set(listTargets);
64 //set_sensitive(true);
65 set_flags(get_flags()|Gtk::RECEIVES_DEFAULT|Gtk::HAS_GRAB);
66 //add_events(Gdk::ALL_EVENTS_MASK);
67 //set_extension_events(Gdk::EXTENSION_EVENTS_ALL);
82 remove(static_cast<Dockable&>(*get_nth_page(get_n_pages()-1)));
86 DockBook::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
88 if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
90 Dockable& dockable(**reinterpret_cast<Dockable**>(const_cast<guint8*>(selection_data.get_data())));
91 if(dockable.parent_!=this)
94 context->drag_finish(true, false, time);
98 context->drag_finish(false, false, time);
102 DockBook::add(Dockable& dockable, int position)
107 append_page(dockable, " ");
109 insert_page(dockable, " ", position);
111 refresh_tab(&dockable);
113 dockable.signal_stock_id_changed().connect(
117 &DockBook::refresh_tab
123 dockable.parent_=this;
127 //set_current_page(get_n_pages()-1);
133 DockBook::refresh_tab(Dockable* dockable)
135 Gtk::Widget* label(dockable->create_tab_label());
137 label->signal_button_press_event().connect(
141 &DockBook::tab_button_pressed
147 set_tab_label(*dockable, *label);
153 DockBook::remove(Dockable& dockable)
156 remove_page(dockable);
175 DockBook::get_local_contents()const
179 for(int i(0);i!=const_cast<DockBook*>(this)->get_n_pages();i++)
181 Dockable& dockable(static_cast<Dockable&>(*const_cast<DockBook*>(this)->get_nth_page(i)));
185 ret+=dockable.get_local_name();
192 DockBook::get_contents()const
196 for(int i(0);i!=const_cast<DockBook*>(this)->get_n_pages();i++)
198 Dockable& dockable(static_cast<Dockable&>(*const_cast<DockBook*>(this)->get_nth_page(i)));
202 ret+=dockable.get_name();
209 DockBook::set_contents(const synfig::String& x)
211 synfig::String str(x);
214 synfig::String::size_type separator=str.find_first_of(' ');
216 if(separator==synfig::String::npos)
223 dock=String(str.begin(),str.begin()+separator);
224 str=String(str.begin()+separator+1,str.end());
229 add(App::dock_manager->find_dockable(dock));
235 DockBook::tab_button_pressed(GdkEventButton* event, Dockable* dockable)
240 Gtk::Menu *tabmenu=manage(new class Gtk::Menu());
242 tabmenu->items().push_back(
243 Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-close"),
244 sigc::mem_fun(*dockable,&Dockable::detach)
248 tabmenu->popup(event->button,gtk_get_current_event_time());