1 /** @file
2 * @brief Whiteboard session playback control dialog - implementation
3 */
4 /* Authors:
5 * David Yip <yipdw@rose-hulman.edu>
6 * Abhishek Sharma
7 *
8 * Copyright (c) 2005 Authors
9 * Released under GNU GPL, read the file 'COPYING' for more information
10 */
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
16 #include <glibmm.h>
17 #include <glibmm/i18n.h>
18 #include <gtk/gtkdialog.h>
19 #include <gtkmm.h>
21 #include "inkscape.h"
22 #include "path-prefix.h"
24 #include "desktop.h"
25 #include "desktop-handles.h"
26 #include "document.h"
28 #include "jabber_whiteboard/node-tracker.h"
29 #include "jabber_whiteboard/session-manager.h"
30 #include "jabber_whiteboard/session-file-player.h"
32 #include "ui/dialog/session-player.h"
34 #include "util/ucompose.hpp"
36 namespace Inkscape {
38 namespace UI {
40 namespace Dialog {
42 SessionPlaybackDialog*
43 SessionPlaybackDialog::create()
44 {
45 return new SessionPlaybackDialogImpl();
46 }
48 SessionPlaybackDialogImpl::SessionPlaybackDialogImpl()
49 : _delay(100, 1, 5000, 10, 100), _delayentry(_delay)
50 {
51 this->_desktop = this->getDesktop();
52 this->_sm = this->_desktop->whiteboard_session_manager();
53 this->_sfp = this->_sm->session_player();
54 this->_openfile.set_text(this->_sfp->filename());
56 this->_construct();
57 this->get_vbox()->show_all_children();
58 }
60 SessionPlaybackDialogImpl::~SessionPlaybackDialogImpl()
61 {
63 }
65 void
66 SessionPlaybackDialogImpl::_construct()
67 {
68 Gtk::VBox* main = this->get_vbox();
70 // Dialog organization
71 this->_filemanager.set_label(_("Session file"));
72 this->_playback.set_label(_("Playback controls"));
73 this->_currentmsgbox.set_label(_("Message information"));
75 this->_filemanager.set_border_width(4);
76 this->_playback.set_border_width(4);
77 this->_fm.set_border_width(4);
78 this->_toolbarbox.set_border_width(4);
80 // Active session file display
81 // fixme: Does this mean the active file for the session, or the file for the active session?
82 // Please indicate which with a TRANSLATORS comment.
83 this->_labels[0].set_text(_("Active session file:"));
84 this->_labels[1].set_text(_("Delay (milliseconds):"));
86 this->_openfile.set_editable(false);
88 this->_filebox.pack_start(this->_labels[0], true, false, 8);
89 this->_filebox.pack_end(this->_openfile, true, true, 0);
91 // Unload/load buttons
92 this->_close.set_label(_("Close file"));
93 this->_open.set_label(_("Open new file"));
94 this->_setdelay.set_label(_("Set delay"));
96 // Attach callbacks
97 this->_close.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), CLOSE_FILE));
98 this->_open.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), OPEN_FILE));
99 this->_setdelay.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), RESET_DELAY));
101 // Button box
102 this->_filebuttons.pack_start(this->_close, true, false, 0);
103 this->_filebuttons.pack_start(this->_open, true, false, 0);
105 // Message information box
106 this->_currentmsgbuffer = Gtk::TextBuffer::create();
107 this->_currentmsgview.set_buffer(this->_currentmsgbuffer);
108 this->_currentmsgview.set_editable(false);
109 this->_currentmsgview.set_cursor_visible(false);
110 this->_currentmsgview.set_wrap_mode(Gtk::WRAP_WORD);
111 this->_currentmsgscroller.add(this->_currentmsgview);
112 this->_currentmsgbox.add(this->_currentmsgscroller);
113 this->_sfp->setMessageOutputWidget(this->_currentmsgbuffer);
115 // Delay setting
116 // parameters: initial lower upper single-incr page-incr
117 this->_delayentry.set_numeric(true);
119 // Playback controls
120 this->_playbackcontrols.set_show_arrow(false);
122 this->_controls[0].set_label("Rewind");
123 this->_controls[1].set_label("Go back one");
124 this->_controls[2].set_label("Pause");
125 this->_controls[3].set_label("Go forward one");
126 this->_controls[4].set_label("Play");
128 this->_controls[0].set_tooltip(this->_tooltips, _("Rewind"));
129 this->_controls[1].set_tooltip(this->_tooltips, _("Go back one change"));
130 this->_controls[2].set_tooltip(this->_tooltips, _("Pause"));
131 this->_controls[3].set_tooltip(this->_tooltips, _("Go forward one change"));
132 this->_controls[4].set_tooltip(this->_tooltips, _("Play"));
134 for(int i = 0; i < 5; i++) {
135 this->_playbackcontrols.append(this->_controls[i], sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), TOOLBAR_BASE + i));
136 }
138 this->_delaybox.pack_start(this->_labels[1]);
139 this->_delaybox.pack_start(this->_delayentry);
140 this->_delaybox.pack_end(this->_setdelay);
142 this->_toolbarbox.pack_start(this->_delaybox);
143 this->_toolbarbox.pack_end(this->_playbackcontrols);
145 // Pack widgets into frames
146 this->_fm.pack_start(this->_filebox);
147 this->_fm.pack_end(this->_filebuttons);
149 this->_filemanager.add(this->_fm);
150 this->_playback.add(this->_toolbarbox);
152 // Pack widgets into main vbox
153 main->pack_start(this->_filemanager);
154 main->pack_start(this->_playback);
155 main->pack_end(this->_currentmsgbox);
156 }
158 void
159 SessionPlaybackDialogImpl::_respCallback(int resp)
160 {
161 g_log(NULL, G_LOG_LEVEL_DEBUG, "_respCallback: %u", resp);
162 switch(resp) {
163 case CLOSE_FILE:
164 this->_sfp->unload();
165 break;
166 case OPEN_FILE: {
167 Gtk::FileChooserDialog sessionfiledlg(_("Open session file"), Gtk::FILE_CHOOSER_ACTION_OPEN);
168 sessionfiledlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
169 sessionfiledlg.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
171 int result = sessionfiledlg.run();
172 switch (result) {
173 case Gtk::RESPONSE_OK:
174 this->_sm->clearDocument();
175 SPDocumentUndo::done(sp_desktop_document(this->_desktop), SP_VERB_NONE,
176 /* TODO: annotate */ "session-player.cpp:186");
177 this->_sm->loadSessionFile(sessionfiledlg.get_filename());
178 this->_openfile.set_text(this->_sfp->filename());
179 break;
180 default:
181 break;
182 }
183 break;
184 }
185 case RESET_DELAY:
186 this->_sfp->setDelay(this->_delayentry.get_value_as_int());
187 break;
188 case REWIND:
189 if (this->_sfp->_playing) {
190 this->_sfp->stop();
191 }
192 this->_sfp->_curdir = Whiteboard::SessionFilePlayer::BACKWARD;
193 this->_sfp->start();
194 break;
195 case STEP_REWIND:
196 this->_sfp->step(Whiteboard::SessionFilePlayer::BACKWARD);
197 break;
198 case PAUSE:
199 this->_sfp->stop();
200 break;
201 case STEP_PLAY:
202 this->_sfp->step(Whiteboard::SessionFilePlayer::FORWARD);
203 break;
204 case PLAY:
205 if (this->_sfp->_playing) {
206 this->_sfp->stop();
207 }
208 this->_sfp->_curdir = Whiteboard::SessionFilePlayer::FORWARD;
209 this->_sfp->start();
210 break;
211 default:
212 break;
213 }
214 }
216 }
218 }
220 }
222 /*
223 Local Variables:
224 mode:c++
225 c-file-style:"stroustrup"
226 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
227 indent-tabs-mode:nil
228 fill-column:99
229 End:
230 */
231 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :