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