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