Fix a crash when running single-threaded and dragging the time slider.
[synfig.git] / synfig-studio / trunk / src / gtkmm / dialog_keyframe.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file dialog_keyframe.cpp
3 **      \brief Template File
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 /* ========================================================================= */
22
23 /* === H E A D E R S ======================================================= */
24
25 #ifdef USING_PCH
26 #       include "pch.h"
27 #else
28 #ifdef HAVE_CONFIG_H
29 #       include <config.h>
30 #endif
31
32 #include "dialog_keyframe.h"
33 #include <gtkmm/scrolledwindow.h>
34 #include <gtkmm/button.h>
35 #include "widget_waypointmodel.h"
36 #include <synfigapp/action.h>
37 #include <synfigapp/instance.h>
38
39 #endif
40
41 /* === U S I N G =========================================================== */
42
43 using namespace std;
44 using namespace etl;
45 using namespace synfig;
46 using namespace studio;
47
48 /* === M A C R O S ========================================================= */
49
50 /* === G L O B A L S ======================================================= */
51
52 /* === P R O C E D U R E S ================================================= */
53
54 /* === M E T H O D S ======================================================= */
55
56 Dialog_Keyframe::Dialog_Keyframe(Gtk::Window& parent,handle<synfigapp::CanvasInterface> canvas_interface):
57         Gtk::Dialog(_("Keyframe Dialog"),parent,false,true),
58         canvas_interface(canvas_interface)
59 {
60         // Set up the buttons
61         {
62                 Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
63                 ok_button->show();
64                 add_action_widget(*ok_button,2);
65                 ok_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::on_ok_pressed));
66
67 /*              Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
68                 apply_button->show();
69                 add_action_widget(*apply_button,1);
70                 apply_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::on_apply_pressed));
71 */
72                 Gtk::Button *delete_button(manage(new class Gtk::Button(Gtk::StockID("gtk-delete"))));
73                 delete_button->show();
74                 add_action_widget(*delete_button,3);
75                 delete_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::on_delete_pressed));
76
77                 Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
78                 cancel_button->show();
79                 add_action_widget(*cancel_button,0);
80                 cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::hide));
81         }
82
83         Gtk::Table *table=manage(new Gtk::Table(2,2,false));
84
85         get_vbox()->pack_start(*table);
86
87         entry_description.set_text("Not yet implemented");
88
89         //table->attach(*manage(new Gtk::Label(_("Description"))), 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
90         //table->attach(entry_description, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
91
92         table->show_all();
93
94         widget_waypoint_model=Gtk::manage(new Widget_WaypointModel());
95         widget_waypoint_model->show();
96         table->attach(*widget_waypoint_model, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
97
98 }
99
100 Dialog_Keyframe::~Dialog_Keyframe()
101 {
102 }
103
104 const synfig::Keyframe&
105 Dialog_Keyframe::get_keyframe()const
106 {
107         return keyframe_;
108 }
109
110 void
111 Dialog_Keyframe::set_keyframe(const synfig::Keyframe& x)
112 {
113         keyframe_=x;
114 }
115
116 void
117 Dialog_Keyframe::on_ok_pressed()
118 {
119         if(widget_waypoint_model->get_waypoint_model().is_trivial())
120                 return;
121
122         synfigapp::Action::Handle action(synfigapp::Action::create("keyframe_waypoint_set"));
123
124         assert(action);
125
126         action->set_param("canvas",canvas_interface->get_canvas());
127         action->set_param("canvas_interface",canvas_interface);
128         action->set_param("keyframe",keyframe_);
129         action->set_param("model",widget_waypoint_model->get_waypoint_model());
130
131         if(!canvas_interface->get_instance()->perform_action(action))
132         {
133         }
134 }
135
136
137 void
138 Dialog_Keyframe::on_delete_pressed()
139 {
140 }
141
142
143 void
144 Dialog_Keyframe::on_apply_pressed()
145 {
146 }