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