Fix a crash when running single-threaded and dragging the time slider.
[synfig.git] / synfig-studio / trunk / src / gtkmm / toolbox.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file toolbox.cpp
3 **      \brief writeme
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **      Copyright (c) 2007 Chris Moore
10 **
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.
15 **
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.
20 **      \endlegal
21 **
22 ** === N O T E S ===========================================================
23 **
24 ** ========================================================================= */
25
26 /* === H E A D E R S ======================================================= */
27
28 #ifdef USING_PCH
29 #       include "pch.h"
30 #else
31 #ifdef HAVE_CONFIG_H
32 #       include <config.h>
33 #endif
34
35 #include <gtk/gtk.h>
36 #include <gtkmm/uimanager.h>
37
38 #include <gtkmm/ruler.h>
39 #include <gtkmm/arrow.h>
40 #include <gtkmm/image.h>
41 #include <gdkmm/pixbufloader.h>
42 #include <gtkmm/viewport.h>
43 #include <gtkmm/adjustment.h>
44 #include <gtkmm/scrolledwindow.h>
45 #include <gtkmm/table.h>
46 #include <gtkmm/statusbar.h>
47 #include <gtkmm/menubar.h>
48 #include <gtkmm/menu.h>
49 #include <gtkmm/button.h>
50 #include <gtkmm/toolbar.h>
51 #include <gtkmm/box.h>
52 #include <gtkmm/image.h>
53 #include <gtkmm/stock.h>
54 #include <gtkmm/handlebox.h>
55
56 #include <gtkmm/inputdialog.h>
57
58 #include <sigc++/signal.h>
59 #include <sigc++/hide.h>
60 #include <sigc++/slot.h>
61 #include <sigc++/retype_return.h>
62 #include <sigc++/retype.h>
63
64 #include <sstream>
65
66 #include "toolbox.h"
67 #include "instance.h"
68 #include "app.h"
69 #include "canvasview.h"
70 #include "dialog_gradient.h"
71 #include "dialog_color.h"
72 #include "dialog_tooloptions.h"
73 #include "dialog_preview.h"
74 #include "dockable.h"
75 #include "dockmanager.h"
76 #include "dockdialog.h"
77
78 #include "widget_defaults.h"
79
80 #include <synfigapp/main.h>
81
82 #endif
83
84 using namespace std;
85 using namespace etl;
86 using namespace synfig;
87 using namespace studio;
88 using namespace SigC;
89
90 /* === M A C R O S ========================================================= */
91
92 #define GRAB_HINT_DATA(y,default)       { \
93                 String x; \
94                 if(synfigapp::Main::settings().get_value(String("pref.")+y+"_hints",x)) \
95                 { \
96                         set_type_hint((Gdk::WindowTypeHint)atoi(x.c_str()));    \
97                 } else {\
98                         set_type_hint(default); \
99                 } \
100         }
101
102 /* === G L O B A L S ======================================================= */
103
104 /* === P R O C E D U R E S ================================================= */
105
106 /* === M E T H O D S ======================================================= */
107
108 #define TOGGLE_TOOLBOX_BUTTON(button,stockid,tooltip)   \
109         button = manage(new class Gtk::ToggleButton()); \
110         icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::IconSize(4)));    \
111         button->add(*icon);     \
112         tooltips.set_tip(*button,tooltip);      \
113         icon->show();   \
114         button->show()
115
116 #define TOOLBOX_BUTTON(button,stockid,tooltip)  \
117         button = manage(new class Gtk::Button());       \
118         icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::IconSize(4)));    \
119         button->add(*icon);     \
120         tooltips.set_tip(*button,tooltip);      \
121         icon->show();   \
122         button->show()
123
124 #define ADD_TOOLBOX_BUTTON(button,stockid,tooltip)      Gtk::Button *TOOLBOX_BUTTON(button,stockid,tooltip)
125
126 void
127 save_selected_instance()
128 {
129         if(!studio::App::get_selected_instance())
130         {
131                 App::dialog_error_blocking("Cannot save","Nothing to save");
132                 return;
133         }
134
135         studio::App::get_selected_instance()->save();
136 }
137
138 void
139 save_as_selected_instance()
140 {
141         if(!studio::App::get_selected_instance())
142         {
143                 App::dialog_error_blocking("Cannot save as","Nothing to save");
144                 return;
145         }
146
147         studio::App::get_selected_instance()->dialog_save_as();
148 }
149
150 void
151 save_all()
152 {
153         std::list<etl::handle<Instance> >::iterator iter;
154         for(iter=App::instance_list.begin();iter!=App::instance_list.end();iter++)
155                 (*iter)->save();
156 }
157
158 void
159 close_selected_instance()
160 {
161         etl::handle<studio::Instance> instance=studio::App::get_selected_instance();
162
163         if(!instance)
164         {
165                 App::dialog_error_blocking("Cannot close","Nothing to close");
166                 return;
167         }
168
169         instance->safe_close();
170
171         //assert(instance.unique());
172 }
173
174
175 static void
176 show_dialog_input()
177 {
178         App::dialog_input->present();
179 }
180
181 void _create_stock_dialog1()
182 {
183         DockDialog* dock_dialog(new DockDialog);
184         dock_dialog->set_contents("canvases history");
185         dock_dialog->set_composition_selector(true);
186         dock_dialog->present();
187 }
188 void _create_stock_dialog2()
189 {
190         DockDialog* dock_dialog(new DockDialog);
191         dock_dialog->set_contents("layers children keyframes | params");
192         dock_dialog->present();
193 }
194
195 Toolbox::Toolbox():
196         Gtk::Window(Gtk::WINDOW_TOPLEVEL),
197         dialog_settings(this,"toolbox")
198 {
199         GRAB_HINT_DATA(
200                 "toolbox",
201 //#ifdef __APPLE__
202                 Gdk::WINDOW_TYPE_HINT_NORMAL
203 //#else
204 //              Gdk::WINDOW_TYPE_HINT_UTILITY
205 //#endif
206         );
207         set_keep_above(false);
208         set_role("toolbox");
209
210
211
212         recent_files_menu= manage(new class Gtk::Menu());
213
214         Gtk::Menu       *filemenu       =manage(new class Gtk::Menu());
215
216         dock_dialogs=manage(new class Gtk::Menu());
217
218         dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem("Canvases, History",sigc::ptr_fun(_create_stock_dialog1)));
219         dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem("Layers, Children, Params",sigc::ptr_fun(_create_stock_dialog2)));
220         dock_dialogs->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
221         dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem("Reset Windows to Original Layout",sigc::ptr_fun(App::reset_initial_window_configuration)));
222         dock_dialogs->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
223
224
225         filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::NEW,
226                 sigc::ptr_fun(&studio::App::new_instance)));
227         filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::OPEN,
228                 sigc::ptr_fun(&studio::App::dialog_open)));
229
230         filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Open Recent"),*recent_files_menu));
231
232         filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-saveall"),
233                 sigc::ptr_fun(&studio::App::dialog_not_implemented)));
234         filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::CLOSE,
235                 sigc::ptr_fun(close_selected_instance)));
236         filemenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
237         filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Dialogs"),*dock_dialogs));
238
239         //filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Canvas Browser..."),
240         //      sigc::mem_fun(studio::App::show_comp_view)));
241         //filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Gradient Editor..."),
242         //      sigc::mem_fun(show_dialog_gradient)));
243         //filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Tool Options"),
244         //      sigc::mem_fun(show_dialog_tool_options)));
245         //filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Colors..."),
246         //      sigc::mem_fun(show_dialog_color)));
247         //filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Color Palette..."),
248         //      sigc::mem_fun(show_dialog_palette)));
249         filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Input Devices..."),
250                 sigc::ptr_fun(&show_dialog_input)));
251         filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Setup..."),
252                 sigc::ptr_fun(&studio::App::show_setup)));
253
254         filemenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
255         filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID(Gtk::Stock::QUIT),
256                 sigc::ptr_fun(studio::App::quit)));
257
258         Gtk::Menu       *helpmenu = manage(new class Gtk::Menu());
259         helpmenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::HELP,
260                 sigc::ptr_fun(studio::App::dialog_not_implemented)));
261         helpmenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
262         helpmenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-about"),
263                 sigc::ptr_fun(studio::App::dialog_about)));
264
265         Gtk::MenuBar *menubar1 = manage(new class Gtk::MenuBar());
266         menubar1->items().push_back(Gtk::Menu_Helpers::MenuElem("_File",*filemenu));
267         menubar1->items().push_back(Gtk::Menu_Helpers::MenuElem("_Help",*helpmenu));
268
269
270         menubar1->show();
271
272         Gtk::Image *icon;
273
274         ADD_TOOLBOX_BUTTON(button_new,"gtk-new","New...");
275         ADD_TOOLBOX_BUTTON(button_open,"gtk-open","Open...");
276         ADD_TOOLBOX_BUTTON(button_save,"gtk-save","Save");
277         ADD_TOOLBOX_BUTTON(button_saveas,"gtk-save-as","Save as...");
278         ADD_TOOLBOX_BUTTON(button_save_all,"synfig-saveall","Save All");
279         TOOLBOX_BUTTON(button_undo,"gtk-undo","Undo");
280         TOOLBOX_BUTTON(button_redo,"gtk-redo","Redo");
281         ADD_TOOLBOX_BUTTON(button_about,"synfig-about","About Synfig Studio");
282
283         button_about->signal_clicked().connect(sigc::ptr_fun(studio::App::dialog_about));
284         button_new->signal_clicked().connect(sigc::ptr_fun(studio::App::new_instance));
285         button_open->signal_clicked().connect(sigc::ptr_fun(studio::App::dialog_open));
286         button_save->signal_clicked().connect(sigc::ptr_fun(save_selected_instance));
287         button_saveas->signal_clicked().connect(sigc::ptr_fun(save_as_selected_instance));
288         button_save_all->signal_clicked().connect(sigc::ptr_fun(save_all));
289         button_undo->signal_clicked().connect(sigc::ptr_fun(studio::App::undo));
290         button_redo->signal_clicked().connect(sigc::ptr_fun(studio::App::redo));
291
292         // Create the file button cluster
293         Gtk::Table *file_buttons=manage(new class Gtk::Table(4, 4, false));
294
295         file_buttons->attach(*button_new,      0,1, 0,1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
296         file_buttons->attach(*button_open,     1,2, 0,1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
297         file_buttons->attach(*button_save,     2,3, 0,1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
298         file_buttons->attach(*button_saveas,   3,4, 0,1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
299
300         file_buttons->attach(*button_save_all, 0,1, 1,2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
301         file_buttons->attach(*button_undo,     1,2, 1,2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
302         file_buttons->attach(*button_redo,     2,3, 1,2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
303         file_buttons->attach(*button_about,    3,4, 1,2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
304
305         file_buttons->show();
306
307         tool_table=manage(new class Gtk::Table(4, 4, false));
308         tool_table->show();
309         Gtk::HandleBox* handle_tools(manage(new Gtk::HandleBox()));
310         handle_tools->add(*tool_table);
311         handle_tools->show();
312         handle_tools->set_handle_position(Gtk::POS_TOP);
313         handle_tools->set_snap_edge(Gtk::POS_TOP);
314
315         Widget_Defaults* widget_defaults(manage(new Widget_Defaults()));
316         widget_defaults->show();
317         Gtk::HandleBox* handle_defaults(manage(new Gtk::HandleBox()));
318         handle_defaults->add(*widget_defaults);
319         handle_defaults->show();
320         handle_defaults->set_handle_position(Gtk::POS_TOP);
321         handle_defaults->set_snap_edge(Gtk::POS_TOP);
322
323         // Create the toplevel table
324         Gtk::Table *table1 = manage(new class Gtk::Table(1, 2, false));
325         table1->set_row_spacings(0);
326         table1->set_col_spacings(0);
327         table1->attach(*menubar1,        0,1, 0,1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK, 0, 0);
328         table1->attach(*file_buttons,    0,1, 1,2, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0);
329         //table1->attach(*manage(new Gtk::Label(_("Tools"))), 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0);
330         table1->attach(*handle_tools,    0,1, 3,4, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0);
331         table1->attach(*handle_defaults, 0,1, 4,5, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0);
332         table1->show_all();
333
334
335
336         // Set the parameters for this window
337         add(*table1);
338         set_title("Synfig Studio");
339         set_modal(false);
340         property_window_position().set_value(Gtk::WIN_POS_NONE);
341         signal_delete_event().connect(sigc::ptr_fun(App::shutdown_request));
342         set_resizable(false);
343
344
345
346         App::signal_instance_selected().connect(
347                 sigc::hide(
348                         sigc::mem_fun(*this,&studio::Toolbox::update_undo_redo)
349                 )
350         );
351
352         App::signal_recent_files_changed().connect(
353                         sigc::mem_fun(*this,&studio::Toolbox::on_recent_files_changed)
354         );
355
356         button_undo->set_sensitive(false);
357         button_redo->set_sensitive(false);
358
359         std::list<Gtk::TargetEntry> listTargets;
360         listTargets.push_back( Gtk::TargetEntry("text/plain") );
361         listTargets.push_back( Gtk::TargetEntry("image") );
362 //      listTargets.push_back( Gtk::TargetEntry("image/x-sif") );
363
364         drag_dest_set(listTargets);
365         signal_drag_data_received().connect( sigc::mem_fun(*this, &studio::Toolbox::on_drop_drag_data_received) );
366
367         App::dock_manager->signal_dockable_registered().connect(sigc::mem_fun(*this,&Toolbox::dockable_registered));
368
369         changing_state_=false;
370
371
372         add_accel_group(App::ui_manager()->get_accel_group());
373
374         App::signal_present_all().connect(sigc::mem_fun0(*this,&Toolbox::present));
375 }
376
377 Toolbox::~Toolbox()
378 {
379         hide();
380         //studio::App::cb.task("Toolbox: I was nailed!");
381         //studio::App::quit();
382
383         if(studio::App::toolbox==this)
384                 studio::App::toolbox=NULL;
385
386 }
387
388 void
389 Toolbox::set_active_state(const String& statename)
390 {
391         std::map<synfig::String,Gtk::ToggleButton *>::iterator iter;
392
393         changing_state_=true;
394
395         synfigapp::Main::set_state(statename);
396
397         try
398         {
399
400                 for(iter=state_button_map.begin();iter!=state_button_map.end();++iter)
401                 {
402                         if(iter->first==statename)
403                         {
404                                 if(!iter->second->get_active())
405                                         iter->second->set_active(true);
406                         }
407                         else
408                         {
409                                 if(iter->second->get_active())
410                                         iter->second->set_active(false);
411                         }
412                 }
413         }
414         catch(...)
415         {
416                 changing_state_=false;
417                 throw;
418         }
419         changing_state_=false;
420 }
421
422 void
423 Toolbox::change_state(const synfig::String& statename)
424 {
425         etl::handle<studio::CanvasView> canvas_view(studio::App::get_selected_canvas_view());
426         if(canvas_view)
427         {
428                 if(statename==canvas_view->get_smach().get_state_name())
429                 {
430                         return;
431                 }
432
433                 if(state_button_map.count(statename))
434                 {
435                         state_button_map[statename]->clicked();
436                 }
437                 else
438                 {
439                         synfig::error("Unknown state \"%s\"",statename.c_str());
440                 }
441         }
442 }
443
444 void
445 Toolbox::change_state_(const Smach::state_base *state)
446 {
447         if(changing_state_)
448                 return;
449         changing_state_=true;
450
451         try
452         {
453                 etl::handle<studio::CanvasView> canvas_view(studio::App::get_selected_canvas_view());
454                 if(canvas_view)
455                 {
456                         if(state->get_name()==String("normal"))
457                         {
458                                 canvas_view->get_smach().egress();
459                         }
460                         else
461                         {
462                                 canvas_view->get_smach().enter(state);
463                         }
464                 }
465                 else
466                         refresh();
467         }
468         catch(...)
469         {
470                 changing_state_=false;
471                 throw;
472         }
473
474         changing_state_=false;
475 }
476
477 void
478 Toolbox::add_state(const Smach::state_base *state)
479 {
480         Gtk::Image *icon;
481
482         assert(state);
483
484         String name=state->get_name();
485
486         Gtk::StockItem stock_item;
487         Gtk::Stock::lookup(Gtk::StockID("synfig-"+name),stock_item);
488
489         Gtk::ToggleButton* button;
490         button=manage(new class Gtk::ToggleButton());
491
492         icon=manage(new Gtk::Image(stock_item.get_stock_id(),Gtk::IconSize(4)));
493         button->add(*icon);
494         tooltips.set_tip(*button,stock_item.get_label());
495         icon->show();
496         button->show();
497
498         int row=state_button_map.size()/4;
499         int col=state_button_map.size()%4;
500
501         tool_table->attach(*button,col,col+1,row,row+1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
502
503         state_button_map[name]=button;
504
505         button->signal_clicked().connect(
506                 sigc::bind(
507                         sigc::mem_fun(*this,&studio::Toolbox::change_state_),
508                         state
509                 )
510         );
511
512         refresh();
513 }
514
515
516 void
517 Toolbox::update_undo_redo()
518 {
519         etl::handle<Instance> instance=App::get_selected_instance();
520         if(instance)
521         {
522                 button_undo->set_sensitive(instance->get_undo_status());
523                 button_redo->set_sensitive(instance->get_redo_status());
524         }
525
526         // This should probably go elsewhere, but it should
527         // work fine here with no troubles.
528         // These next several lines just adjust the tool buttons
529         // so that they are only clickable when they should be.
530         if(instance && App::get_selected_canvas_view())
531         {
532                 std::map<synfig::String,Gtk::ToggleButton *>::iterator iter;
533
534                 for(iter=state_button_map.begin();iter!=state_button_map.end();++iter)
535                         iter->second->set_sensitive(true);
536         }
537         else
538         {
539                 std::map<synfig::String,Gtk::ToggleButton *>::iterator iter;
540
541                 for(iter=state_button_map.begin();iter!=state_button_map.end();++iter)
542                         iter->second->set_sensitive(false);
543         }
544
545         etl::handle<CanvasView> canvas_view=App::get_selected_canvas_view();
546         if(canvas_view && canvas_view->get_smach().get_state_name())
547         {
548                 set_active_state(canvas_view->get_smach().get_state_name());
549         }
550         else
551                 set_active_state("none");
552
553 }
554
555 void
556 Toolbox::on_recent_files_changed()
557 {
558         while(recent_files_menu->get_children().size())
559                 recent_files_menu->remove(**recent_files_menu->get_children().begin());
560
561         list<string>::const_iterator iter;
562         for(iter=App::get_recent_files().begin();iter!=App::get_recent_files().end();iter++)
563         {
564                 string raw = basename(*iter), quoted;
565                 size_t pos = 0, last_pos = 0;
566
567                 // replace _ in filenames by __ or it won't show up in the menu
568                 for (pos = last_pos = 0; (pos = raw.find('_', pos)) != string::npos; last_pos = pos)
569                         quoted += raw.substr(last_pos, ++pos - last_pos) + '_';
570                 quoted += raw.substr(last_pos);
571
572                 recent_files_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(quoted,
573                         sigc::hide_return(sigc::bind(sigc::ptr_fun(&App::open),*iter))
574                 ));
575         }
576
577         // HACK
578         show();
579 }
580
581 void
582 Toolbox::on_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int /*x*/, int /*y*/, const Gtk::SelectionData& selection_data_, guint /*info*/, guint time)
583 {
584         // We will make this true once we have a solid drop
585         bool success(false);
586
587         if ((selection_data_.get_length() >= 0) && (selection_data_.get_format() == 8))
588         {
589                 synfig::String selection_data((gchar *)(selection_data_.get_data()));
590
591                 // For some reason, GTK hands us a list of URL's seperated
592                 // by not only Carrage-Returns, but also Line-Feeds.
593                 // Line-Feeds will mess us up. Remove all the line-feeds.
594                 while(selection_data.find_first_of('\r')!=synfig::String::npos)
595                         selection_data.erase(selection_data.begin()+selection_data.find_first_of('\r'));
596
597                 std::stringstream stream(selection_data);
598
599                 while(stream)
600                 {
601                         synfig::String filename,URI;
602                         getline(stream,filename);
603
604                         // If we don't have a filename, move on.
605                         if(filename.empty())
606                                 continue;
607
608                         // Make sure this URL is of the "file://" type.
609                         URI=String(filename.begin(),filename.begin()+sizeof("file://")-1);
610                         if(URI!="file://")
611                         {
612                                 synfig::warning("Unknown URI (%s) in \"%s\"",URI.c_str(),filename.c_str());
613                                 continue;
614                         }
615
616                         // Strip the "file://" part from the filename
617                         filename=synfig::String(filename.begin()+sizeof("file://")-1,filename.end());
618
619                         synfig::info("Attempting to open "+filename);
620                         if(App::open(filename))
621                                 success=true;
622                         else
623                                 synfig::error("Drop failed: Unable to open "+filename);
624                 }
625         }
626         else
627                 synfig::error("Drop failed: bad selection data");
628
629         // Finish the drag
630         context->drag_finish(success, false, time);
631 }
632
633 void
634 Toolbox::dockable_registered(Dockable* x)
635 {
636         dock_dialogs->items().push_back(
637                 Gtk::Menu_Helpers::MenuElem(
638                         x->get_local_name(),
639                         sigc::mem_fun(
640                                 *x,
641                                 &Dockable::present
642                         )
643                 )
644         );
645 }