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