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