1 /** @file
2 * @brief Whiteboard session playback control dialog - implementation
3 */
4 /* Authors:
5 * David Yip <yipdw@rose-hulman.edu>
6 *
7 * Copyright (c) 2005 Authors
8 * Released under GNU GPL, read the file 'COPYING' for more information
9 */
11 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
15 #include <glibmm.h>
16 #include <glibmm/i18n.h>
17 #include <gtk/gtkdialog.h>
18 #include <gtkmm.h>
20 #include "inkscape.h"
21 #include "path-prefix.h"
23 #include "desktop.h"
24 #include "desktop-handles.h"
25 #include "document.h"
27 #include "ui/stock.h"
29 #include "jabber_whiteboard/node-tracker.h"
30 #include "jabber_whiteboard/session-manager.h"
31 #include "jabber_whiteboard/session-file-player.h"
33 #include "ui/dialog/session-player.h"
35 #include "util/ucompose.hpp"
37 namespace Inkscape {
39 namespace UI {
41 namespace Dialog {
43 SessionPlaybackDialog*
44 SessionPlaybackDialog::create()
45 {
46 return new SessionPlaybackDialogImpl();
47 }
49 SessionPlaybackDialogImpl::SessionPlaybackDialogImpl()
50 : _delay(100, 1, 5000, 10, 100), _delayentry(_delay)
51 {
52 this->_desktop = this->getDesktop();
53 this->_sm = this->_desktop->whiteboard_session_manager();
54 this->_sfp = this->_sm->session_player();
55 this->_openfile.set_text(this->_sfp->filename());
57 this->_construct();
58 this->get_vbox()->show_all_children();
59 }
61 SessionPlaybackDialogImpl::~SessionPlaybackDialogImpl()
62 {
64 }
66 void
67 SessionPlaybackDialogImpl::_construct()
68 {
69 Gtk::VBox* main = this->get_vbox();
71 // Dialog organization
72 this->_filemanager.set_label(_("Session file"));
73 this->_playback.set_label(_("Playback controls"));
74 this->_currentmsgbox.set_label(_("Message information"));
76 this->_filemanager.set_border_width(4);
77 this->_playback.set_border_width(4);
78 this->_fm.set_border_width(4);
79 this->_toolbarbox.set_border_width(4);
81 // Active session file display
82 // fixme: Does this mean the active file for the session, or the file for the active session?
83 // Please indicate which with a TRANSLATORS comment.
84 this->_labels[0].set_text(_("Active session file:"));
85 this->_labels[1].set_text(_("Delay (milliseconds):"));
87 this->_openfile.set_editable(false);
89 this->_filebox.pack_start(this->_labels[0], true, false, 8);
90 this->_filebox.pack_end(this->_openfile, true, true, 0);
92 // Unload/load buttons
93 this->_close.set_label(_("Close file"));
94 this->_open.set_label(_("Open new file"));
95 this->_setdelay.set_label(_("Set delay"));
97 // Attach callbacks
98 this->_close.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), CLOSE_FILE));
99 this->_open.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), OPEN_FILE));
100 this->_setdelay.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), RESET_DELAY));
102 // Button box
103 this->_filebuttons.pack_start(this->_close, true, false, 0);
104 this->_filebuttons.pack_start(this->_open, true, false, 0);
106 // Message information box
107 this->_currentmsgbuffer = Gtk::TextBuffer::create();
108 this->_currentmsgview.set_buffer(this->_currentmsgbuffer);
109 this->_currentmsgview.set_editable(false);
110 this->_currentmsgview.set_cursor_visible(false);
111 this->_currentmsgview.set_wrap_mode(Gtk::WRAP_WORD);
112 this->_currentmsgscroller.add(this->_currentmsgview);
113 this->_currentmsgbox.add(this->_currentmsgscroller);
114 this->_sfp->setMessageOutputWidget(this->_currentmsgbuffer);
116 // Delay setting
117 // parameters: initial lower upper single-incr page-incr
118 this->_delayentry.set_numeric(true);
120 // Playback controls
121 this->_playbackcontrols.set_show_arrow(false);
123 /* these are waiting for the Gtkmm conversion
124 this->_controls[0].set_stock_id(Stock::SESSION_PLAYBACK_REW);
125 this->_controls[1].set_stock_id(Stock::SESSION_PLAYBACK_STEPBACK);
126 this->_controls[2].set_stock_id(Stock::SESSION_PLAYBACK_PAUSE);
127 this->_controls[3].set_stock_id(Stock::SESSION_PLAYBACK_STEPFORWARD);
128 this->_controls[4].set_stock_id(Stock::SESSION_PLAYBACK_PLAY);
129 */
131 this->_controls[0].set_label("Rewind");
132 this->_controls[1].set_label("Go back one");
133 this->_controls[2].set_label("Pause");
134 this->_controls[3].set_label("Go forward one");
135 this->_controls[4].set_label("Play");
137 this->_controls[0].set_tooltip(this->_tooltips, _("Rewind"));
138 this->_controls[1].set_tooltip(this->_tooltips, _("Go back one change"));
139 this->_controls[2].set_tooltip(this->_tooltips, _("Pause"));
140 this->_controls[3].set_tooltip(this->_tooltips, _("Go forward one change"));
141 this->_controls[4].set_tooltip(this->_tooltips, _("Play"));
143 for(int i = 0; i < 5; i++) {
144 this->_playbackcontrols.append(this->_controls[i], sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), TOOLBAR_BASE + i));
145 }
147 this->_delaybox.pack_start(this->_labels[1]);
148 this->_delaybox.pack_start(this->_delayentry);
149 this->_delaybox.pack_end(this->_setdelay);
151 this->_toolbarbox.pack_start(this->_delaybox);
152 this->_toolbarbox.pack_end(this->_playbackcontrols);
154 // Pack widgets into frames
155 this->_fm.pack_start(this->_filebox);
156 this->_fm.pack_end(this->_filebuttons);
158 this->_filemanager.add(this->_fm);
159 this->_playback.add(this->_toolbarbox);
161 // Pack widgets into main vbox
162 main->pack_start(this->_filemanager);
163 main->pack_start(this->_playback);
164 main->pack_end(this->_currentmsgbox);
165 }
167 void
168 SessionPlaybackDialogImpl::_respCallback(int resp)
169 {
170 g_log(NULL, G_LOG_LEVEL_DEBUG, "_respCallback: %u", resp);
171 switch(resp) {
172 case CLOSE_FILE:
173 this->_sfp->unload();
174 break;
175 case OPEN_FILE: {
176 Gtk::FileChooserDialog sessionfiledlg(_("Open session file"), Gtk::FILE_CHOOSER_ACTION_OPEN);
177 sessionfiledlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
178 sessionfiledlg.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
180 int result = sessionfiledlg.run();
181 switch (result) {
182 case Gtk::RESPONSE_OK:
183 this->_sm->clearDocument();
184 sp_document_done(sp_desktop_document(this->_desktop), SP_VERB_NONE,
185 /* TODO: annotate */ "session-player.cpp:186");
186 this->_sm->loadSessionFile(sessionfiledlg.get_filename());
187 this->_openfile.set_text(this->_sfp->filename());
188 break;
189 default:
190 break;
191 }
192 break;
193 }
194 case RESET_DELAY:
195 this->_sfp->setDelay(this->_delayentry.get_value_as_int());
196 break;
197 case REWIND:
198 if (this->_sfp->_playing) {
199 this->_sfp->stop();
200 }
201 this->_sfp->_curdir = Whiteboard::SessionFilePlayer::BACKWARD;
202 this->_sfp->start();
203 break;
204 case STEP_REWIND:
205 this->_sfp->step(Whiteboard::SessionFilePlayer::BACKWARD);
206 break;
207 case PAUSE:
208 this->_sfp->stop();
209 break;
210 case STEP_PLAY:
211 this->_sfp->step(Whiteboard::SessionFilePlayer::FORWARD);
212 break;
213 case PLAY:
214 if (this->_sfp->_playing) {
215 this->_sfp->stop();
216 }
217 this->_sfp->_curdir = Whiteboard::SessionFilePlayer::FORWARD;
218 this->_sfp->start();
219 break;
220 default:
221 break;
222 }
223 }
225 }
227 }
229 }
231 /*
232 Local Variables:
233 mode:c++
234 c-file-style:"stroustrup"
235 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
236 indent-tabs-mode:nil
237 fill-column:99
238 End:
239 */
240 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :