Implements PXEGeek's http://wiki.synfig.com/Wish_list entry: "Optionally display...
[synfig.git] / synfig-studio / trunk / src / gtkmm / compview.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file compview.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 "compview.h"
35 #include "app.h"
36 #include <gtkmm/scrolledwindow.h>
37 #include <cassert>
38 #include <iostream>
39 #include "instance.h"
40 #include <sigc++/signal.h>
41 #include <sigc++/hide.h>
42 #include <sigc++/slot.h>
43 #include "canvasview.h"
44 #include <synfigapp/action.h>
45
46 #endif
47
48 /* === M A C R O S ========================================================= */
49
50 #define ADD_TOOLBOX_BUTTON(button,stockid,tooltip)      \
51         Gtk::Button *button = manage(new class Gtk::Button());  \
52         button->add(*manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::IconSize(4))));   \
53         tooltips.set_tip(*button,tooltip);      \
54         button->show_all()
55
56 using namespace std;
57 using namespace etl;
58 using namespace synfig;
59 using namespace studio;
60
61 #define COLUMNID_JUMP           (787584)
62 #define ColumnID        int
63
64 /* === G L O B A L S ======================================================= */
65
66 /* === P R O C E D U R E S ================================================= */
67
68 /* === M E T H O D S ======================================================= */
69
70 CompView::CompView():
71         Gtk::Window(Gtk::WINDOW_TOPLEVEL),
72         dialog_settings(this,"compview")
73 {
74         init_menu();
75         set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
76
77         Gtk::Table *table = manage(new class Gtk::Table(2, 1, false));
78
79
80         table->attach(*create_instance_selector(), 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
81
82         notebook=manage(new class Gtk::Notebook());
83
84         table->attach(*notebook, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
85
86         notebook->append_page(*create_canvas_tree(),"Canvases");
87         notebook->append_page(*create_action_tree(),"History");
88
89
90
91 /*
92
93         studio::Instance::ImageColumnModel image_column_model;
94         image_list=manage(new class Gtk::TreeView());
95         image_list->append_column("Name",image_column_model.name);
96         image_list->signal_row_activated().connect(sigc::mem_fun(*this,&CompView::on_image_activate));
97         image_list->set_rules_hint();
98
99         Gtk::Table *image_page = manage(new class Gtk::Table(2, 1, false));
100         Gtk::ScrolledWindow *image_list_scroll = manage(new class Gtk::ScrolledWindow());
101         image_list_scroll->set_flags(Gtk::CAN_FOCUS);
102         image_list_scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
103         image_list_scroll->add(*image_list);
104         image_page->attach(*image_list_scroll, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
105         Gtk::HBox *image_buttons=manage(new class Gtk::HBox());
106         image_page->attach(*image_buttons, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
107         ADD_TOOLBOX_BUTTON(button_image_new,"gtk-new","Create a new image");
108         ADD_TOOLBOX_BUTTON(button_image_delete,"gtk-delete","Delete image");
109         ADD_TOOLBOX_BUTTON(button_image_rename,"gtk-rename","Rename image");
110         ADD_TOOLBOX_BUTTON(button_image_copy,"gtk-copy","Duplicate image");
111         button_image_new->signal_clicked().connect(sigc::mem_fun(*this,&CompView::new_image));
112         button_image_delete->signal_clicked().connect(sigc::mem_fun(*this,&CompView::delete_image));
113         button_image_rename->signal_clicked().connect(sigc::mem_fun(*this,&CompView::rename_image));
114         button_image_copy->signal_clicked().connect(sigc::mem_fun(*this,&CompView::copy_image));
115         image_buttons->pack_start(*button_image_new);
116         image_buttons->pack_start(*button_image_delete);
117         image_buttons->pack_start(*button_image_rename);
118         image_buttons->pack_start(*button_image_copy);
119
120         studio::Instance::ValueNodeColumnModel valuenode_column_model;
121         valuenode_list=manage(new class Gtk::TreeView());
122         valuenode_list->append_column("Name",valuenode_column_model.name);
123         valuenode_list->signal_row_activated().connect(sigc::mem_fun(*this,&CompView::on_valuenode_activate));
124         valuenode_list->set_rules_hint();
125
126         Gtk::Table *valuenode_page = manage(new class Gtk::Table(2, 1, false));
127         Gtk::ScrolledWindow *valuenode_list_scroll = manage(new class Gtk::ScrolledWindow());
128         valuenode_list_scroll->set_flags(Gtk::CAN_FOCUS);
129         valuenode_list_scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
130         valuenode_list_scroll->add(*valuenode_list);
131         valuenode_page->attach(*valuenode_list_scroll, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
132         Gtk::HBox *valuenode_buttons=manage(new class Gtk::HBox());
133         valuenode_page->attach(*valuenode_buttons, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
134         ADD_TOOLBOX_BUTTON(button_valuenode_new,"gtk-new","Create a new value_node");
135         ADD_TOOLBOX_BUTTON(button_valuenode_delete,"gtk-delete","Delete value_node");
136         ADD_TOOLBOX_BUTTON(button_valuenode_rename,"gtk-rename","Rename value_node");
137         ADD_TOOLBOX_BUTTON(button_valuenode_copy,"gtk-copy","Duplicate value_node");
138         button_valuenode_new->signal_clicked().connect(sigc::mem_fun(*this,&CompView::new_value_node));
139         button_valuenode_delete->signal_clicked().connect(sigc::mem_fun(*this,&CompView::delete_value_node));
140         button_valuenode_rename->signal_clicked().connect(sigc::mem_fun(*this,&CompView::rename_value_node));
141         button_valuenode_copy->signal_clicked().connect(sigc::mem_fun(*this,&CompView::copy_value_node));
142         valuenode_buttons->pack_start(*button_valuenode_new);
143         valuenode_buttons->pack_start(*button_valuenode_delete);
144         valuenode_buttons->pack_start(*button_valuenode_rename);
145         valuenode_buttons->pack_start(*button_valuenode_copy);
146
147
148         notebook->append_page(*image_page,"Images");
149         notebook->append_page(*valuenode_page,"ValueNodes");
150
151         image_page->show_all();
152         valuenode_page->show_all();
153 */
154 //      notebook->set_current_page(0);
155         signal_delete_event().connect(sigc::hide(sigc::mem_fun(*this, &CompView::close)));
156         App::signal_instance_created().connect(sigc::mem_fun(*this,&studio::CompView::new_instance));
157         App::signal_instance_deleted().connect(sigc::mem_fun(*this,&studio::CompView::delete_instance));
158         App::signal_instance_selected().connect(sigc::mem_fun(*this,&studio::CompView::set_selected_instance_signal));
159
160         table->show_all();
161         add(*table);
162
163
164         set_title("Canvas Browser");
165         set_modal(false);
166         set_resizable(true);
167         property_window_position().set_value(Gtk::WIN_POS_NONE);
168         set_default_size(200,300);
169 }
170
171 CompView::~CompView()
172 {
173 }
174
175 etl::loose_handle<studio::CanvasView>
176 CompView::get_selected_canvas_view()
177 {
178         return get_selected_instance()->find_canvas_view(get_selected_canvas());
179 }
180
181 Gtk::Widget*
182 CompView::create_canvas_tree()
183 {
184         studio::Instance::CanvasTreeModel canvas_tree_model;
185         canvas_tree=manage(new class Gtk::TreeView());
186         {
187                 Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column("ID") );
188 //              Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
189
190                 //column->pack_start(*icon_cellrenderer,false);
191                 column->pack_start(canvas_tree_model.icon, false); //false = don't expand.
192                 column->pack_start(canvas_tree_model.label);
193
194 //#ifdef NDEBUG
195 //              column->add_attribute(icon_cellrenderer->property_pixbuf(), canvas_tree_model.icon);
196 //#endif
197
198                 canvas_tree->append_column(*column);
199         }
200         canvas_tree->set_rules_hint();
201         canvas_tree->signal_row_activated().connect(sigc::mem_fun(*this,&CompView::on_row_activate));
202         canvas_tree->signal_event().connect(sigc::mem_fun(*this,&CompView::on_tree_event));
203         canvas_tree->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
204         canvas_tree->add_events(Gdk::BUTTON1_MOTION_MASK);
205         canvas_tree->show();
206
207         Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
208         scrolledwindow->set_flags(Gtk::CAN_FOCUS);
209         scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
210         scrolledwindow->add(*canvas_tree);
211         scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
212         scrolledwindow->show();
213
214         return scrolledwindow;
215 }
216
217 Gtk::Widget*
218 CompView::create_action_tree()
219 {
220         studio::HistoryTreeStore::Model history_tree_model;
221         action_tree=manage(new class Gtk::TreeView());
222         {
223                 Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column("") );
224
225                 Gtk::CellRendererToggle* toggle_cr = Gtk::manage( new Gtk::CellRendererToggle() );
226                 toggle_cr->signal_toggled().connect(sigc::mem_fun(*this, &studio::CompView::on_action_toggle) );
227
228                 column->pack_start(*toggle_cr); //false = don't expand.
229                 column->add_attribute(toggle_cr->property_active(),history_tree_model.is_active);
230                 column->set_resizable();
231                 column->set_clickable();
232
233                 action_tree->append_column(*column);
234         }
235         /*{
236                 Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column("Canvas") );
237                 Gtk::CellRendererText *text_cr=Gtk::manage(new Gtk::CellRendererText());
238                 text_cr->property_foreground()=Glib::ustring("#7f7f7f");
239
240                 column->pack_start(*text_cr);
241                 column->add_attribute(text_cr->property_text(),history_tree_model.canvas_id);
242                 column->add_attribute(text_cr->property_foreground_set(),history_tree_model.is_redo);
243
244                 action_tree->append_column(*column);
245         }*/
246         {
247                 Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Jump")) );
248
249                 Gtk::CellRendererText* cell_renderer_jump=Gtk::manage(new Gtk::CellRendererText());
250                 column->pack_start(*cell_renderer_jump,true);
251
252                 cell_renderer_jump->property_text()="(JMP)";
253                 cell_renderer_jump->property_foreground()="#003a7f";
254
255                 column->set_resizable();
256                 column->set_clickable();
257
258                 column->set_sort_column_id(COLUMNID_JUMP);
259
260                 action_tree->append_column(*column);
261                 //column->clicked();
262         }
263         {
264                 Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column("Action") );
265
266                 Gtk::CellRendererText *text_cr=Gtk::manage(new Gtk::CellRendererText());
267                 text_cr->property_foreground()=Glib::ustring("#7f7f7f");
268
269
270
271                 //column->pack_start(history_tree_model.icon, false); //false = don't expand.
272                 column->pack_start(*text_cr);
273                 column->add_attribute(text_cr->property_text(),history_tree_model.name);
274                 column->add_attribute(text_cr->property_foreground_set(),history_tree_model.is_redo);
275
276                 action_tree->append_column(*column);
277         }
278
279
280         action_tree->set_rules_hint();
281 //      action_tree->signal_row_activated().connect(sigc::mem_fun(*this,&CompView::on_row_activate));
282         action_tree->signal_event().connect(sigc::mem_fun(*this,&CompView::on_action_event));
283 //      action_tree->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
284 //      action_tree->add_events(Gdk::BUTTON1_MOTION_MASK);
285         action_tree->show();
286
287         Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
288         scrolledwindow->set_flags(Gtk::CAN_FOCUS);
289         scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
290         scrolledwindow->add(*action_tree);
291         scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
292         scrolledwindow->show();
293
294         Gtk::Button* clear_button(manage(new Gtk::Button(_("Clear Undo"))));
295         clear_button->signal_pressed().connect(sigc::mem_fun(*this,&studio::CompView::clear_history));
296
297         Gtk::Button* clear_redo_button(manage(new Gtk::Button(_("Clear Redo"))));
298         clear_redo_button->signal_pressed().connect(sigc::mem_fun(*this,&studio::CompView::clear_redo));
299
300         Gtk::Table* table(manage(new Gtk::Table()));
301         table->attach(*scrolledwindow, 0, 2, 0,1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
302         table->attach(*clear_button, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
303         table->attach(*clear_redo_button, 1, 2, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
304
305         table->show_all();
306
307         return table;
308 }
309
310 Gtk::Widget*
311 CompView::create_instance_selector()
312 {
313         instance_selector=manage(new class Gtk::OptionMenu());
314         instance_selector->show();
315         instance_selector->set_menu(instance_list_menu);
316         return instance_selector;
317 }
318
319 bool
320 CompView::close()
321 {
322         hide();
323         return true;
324 }
325
326 void
327 CompView::clear_history()
328 {
329         if(selected_instance && App::dialog_yes_no(_("Clear History"), _("You will not be able to undo any changes that you have made!\nAre you sure you want to clear the undo stack?")))
330         {
331                 selected_instance->clear_undo_stack();
332         }
333 }
334
335 void
336 CompView::clear_redo()
337 {
338         if(selected_instance && App::dialog_yes_no(_("Clear History"), _("You will not be able to redo any changes that you have made!\nAre you sure you want to clear the redo stack?")))
339         {
340                 selected_instance->clear_redo_stack();
341         }
342 }
343
344 void
345 CompView::init_menu()
346 {
347         menu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
348         menu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-canvas_new"),
349                 sigc::mem_fun(*this,&CompView::menu_new_canvas)));
350         menu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-delete"),
351                 sigc::mem_fun(*this,&CompView::menu_delete)));
352         menu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-rename"),
353                 sigc::mem_fun(*this,&CompView::menu_rename)));
354 }
355
356 etl::loose_handle<synfig::Canvas>
357 CompView::get_selected_canvas()
358 {
359         Glib::RefPtr<Gtk::TreeSelection> selection=canvas_tree->get_selection();
360
361         if(!selection || !selection->get_selected())
362                 return 0;
363
364         studio::Instance::CanvasTreeModel canvas_tree_model;
365
366         return static_cast<etl::handle<synfig::Canvas> >((*selection->get_selected())[canvas_tree_model.canvas]);
367 }
368
369 void
370 CompView::menu_new_canvas()
371 {
372 #warning Update Me!
373 #if 0
374         get_selected_canvas_view()->new_child_canvas();
375 #endif
376 }
377
378 void
379 CompView::menu_delete()
380 {
381         studio::App::dialog_not_implemented();
382 }
383
384 void
385 CompView::menu_rename()
386 {
387         studio::App::dialog_not_implemented();
388 }
389
390 void
391 CompView::set_selected_instance_signal(etl::handle<studio::Instance> x)
392 {
393         set_selected_instance(x);
394 }
395
396 void
397 CompView::set_selected_instance_(etl::handle<studio::Instance> instance)
398 {
399         if(studio::App::shutdown_in_progress)
400                 return;
401
402         selected_instance=instance;
403         if(instance)
404         {
405                 canvas_tree->set_model(instance->canvas_tree_store());
406                 action_tree->set_model(instance->history_tree_store());
407                 canvas_tree->show();
408                 action_tree->show();
409         }
410         else
411         {
412                 canvas_tree->set_model(Glib::RefPtr< Gtk::TreeModel >());
413                 action_tree->set_model(Glib::RefPtr< Gtk::TreeModel >());
414                 canvas_tree->hide();
415                 action_tree->hide();
416         }
417 }
418
419 void
420 CompView::set_selected_instance(etl::loose_handle<studio::Instance> x)
421 {
422         if(studio::App::shutdown_in_progress)
423                 return;
424
425         // if it's already selected, don't select it again
426         if (x==selected_instance)
427                 return;
428
429         std::list<etl::handle<studio::Instance> >::iterator iter;
430
431         if(x)
432         {
433                 int i;
434                 for(i=0,iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end() && ((*iter)!=x);iter++,i++);
435
436                 assert(*iter==x);
437
438                 instance_selector->set_history(i);
439         }
440         else
441                 instance_selector->set_history(0);
442
443         set_selected_instance_(x);
444 }
445
446 void
447 CompView::new_instance(etl::handle<studio::Instance> instance)
448 {
449         if(studio::App::shutdown_in_progress)
450                 return;
451
452         assert(instance);
453
454         etl::loose_handle<studio::Instance> loose_instance(instance);
455
456         instance->synfigapp::Instance::signal_filename_changed().connect(sigc::mem_fun(*this,&CompView::refresh_instances));
457         instance->synfigapp::Instance::signal_filename_changed().connect(
458                 sigc::bind<etl::loose_handle<studio::Instance> >(
459                         sigc::mem_fun(*this,&CompView::set_selected_instance),
460                         loose_instance
461                 )
462         );
463
464         {
465                 std::string name=basename(instance->get_file_name());
466
467                 instance_list_menu.items().push_back(Gtk::Menu_Helpers::MenuElem(name,
468                         sigc::bind<etl::loose_handle<studio::Instance> >(sigc::mem_fun(&studio::App::set_selected_instance),loose_instance)     ));
469         }
470 }
471
472 void
473 CompView::delete_instance(etl::handle<studio::Instance> instance)
474 {
475         if(studio::App::shutdown_in_progress)
476                 return;
477
478         refresh_instances();
479
480         if(selected_instance==instance)
481         {
482                 set_selected_instance(0);
483                 instance_selector->set_history(0);
484         }
485 }
486
487 void
488 CompView::refresh_instances()
489 {
490         if(studio::App::shutdown_in_progress)
491                 return;
492
493         if(!instance_list_menu.items().empty())
494                 instance_list_menu.items().clear();
495
496         std::list<etl::handle<studio::Instance> >::iterator iter;
497         for(iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end();iter++)
498         {
499                 std::string name=basename((*iter)->get_file_name());
500
501                 instance_list_menu.items().push_back(Gtk::Menu_Helpers::MenuElem(name,
502                         sigc::bind<etl::loose_handle<studio::Instance> >(sigc::mem_fun(&studio::App::set_selected_instance),*iter)      ));
503         }
504         instance_selector->set_menu(instance_list_menu);
505 }
506
507 void
508 CompView::on_row_activate(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *)
509 {
510         assert(get_selected_instance());
511         studio::Instance::CanvasTreeModel canvas_tree_model;
512         const Gtk::TreeRow row = *(get_selected_instance()->canvas_tree_store()->get_iter(path));
513         if(row[canvas_tree_model.is_canvas])
514                 get_selected_instance()->focus(row[canvas_tree_model.canvas]);
515         else
516                 studio::App::dialog_not_implemented();
517 }
518
519 bool
520 CompView::on_action_event(GdkEvent *event)
521 {
522         studio::HistoryTreeStore::Model model;
523     switch(event->type)
524     {
525         case GDK_BUTTON_PRESS:
526         case GDK_2BUTTON_PRESS:
527                 {
528                         Gtk::TreeModel::Path path;
529                         Gtk::TreeViewColumn *column;
530                         int cell_x, cell_y;
531                         if(!action_tree->get_path_at_pos(
532                                 int(event->button.x),int(event->button.y),      // x, y
533                                 path, // TreeModel::Path&
534                                 column, //TreeViewColumn*&
535                                 cell_x,cell_y //int&cell_x,int&cell_y
536                                 )
537                         ) break;
538                         const Gtk::TreeRow row = *(action_tree->get_model()->get_iter(path));
539
540                         //signal_user_click()(event->button.button,row,(ColumnID)column->get_sort_column_id());
541                         if((ColumnID)column->get_sort_column_id()==COLUMNID_JUMP)
542                         {
543                                 etl::handle<synfigapp::Action::Undoable> action(row[model.action]);
544                                 if((bool)row[model.is_undo])
545                                 {
546                                         while(get_selected_instance()->undo_action_stack().size() && get_selected_instance()->undo_action_stack().front()!=action)
547                                                 get_selected_instance()->undo();
548                                 }
549                                 else if((bool)row[model.is_redo])
550                                 {
551                                         while(get_selected_instance()->redo_action_stack().size() && get_selected_instance()->undo_action_stack().front()!=action)
552                                                 get_selected_instance()->redo();
553                                 }
554                         }
555                 }
556
557         case GDK_BUTTON_RELEASE:
558                 break;
559         default:
560                 break;
561         }
562         return false;
563 }
564
565 bool
566 CompView::on_tree_event(GdkEvent *event)
567 {
568     switch(event->type)
569     {
570         case GDK_BUTTON_PRESS:
571                 switch(event->button.button)
572                 {
573                 case 3:
574                 if(get_selected_canvas())
575                 {
576                         menu.items().clear();
577
578                         synfigapp::Action::ParamList param_list;
579                         param_list.add("canvas",synfig::Canvas::Handle(get_selected_canvas()));
580                         param_list.add("canvas_interface",get_selected_instance()->find_canvas_interface(get_selected_canvas()));
581                         get_selected_instance()->find_canvas_view(get_selected_canvas())->add_actions_to_menu(&menu, param_list,synfigapp::Action::CATEGORY_CANVAS);
582                         menu.popup(0,0);
583                         menu.show();
584                         break;
585                 }
586                 default:
587                         break;
588                 }
589                 break;
590         case GDK_MOTION_NOTIFY:
591                 break;
592         case GDK_BUTTON_RELEASE:
593                 break;
594         default:
595                 break;
596         }
597         return false;
598 }
599
600 void
601 CompView::on_action_toggle(const Glib::ustring& path_string)
602 {
603         studio::HistoryTreeStore::Model history_tree_model;
604
605         Gtk::TreePath path(path_string);
606
607         const Gtk::TreeRow row = *(selected_instance->history_tree_store()->get_iter(path));
608
609         handle<synfigapp::Action::Undoable> action=row[history_tree_model.action];
610
611         selected_instance->synfigapp::Instance::set_action_status(action,!action->is_active());
612 }