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 "jabber_whiteboard/node-tracker.h"
28 #include "jabber_whiteboard/session-manager.h"
29 #include "jabber_whiteboard/session-file-player.h"
31 #include "ui/dialog/session-player.h"
33 #include "util/ucompose.hpp"
35 namespace Inkscape {
37 namespace UI {
39 namespace Dialog {
41 SessionPlaybackDialog*
42 SessionPlaybackDialog::create()
43 {
44 return new SessionPlaybackDialogImpl();
45 }
47 SessionPlaybackDialogImpl::SessionPlaybackDialogImpl()
48 : _delay(100, 1, 5000, 10, 100), _delayentry(_delay)
49 {
50 this->_desktop = this->getDesktop();
51 this->_sm = this->_desktop->whiteboard_session_manager();
52 this->_sfp = this->_sm->session_player();
53 this->_openfile.set_text(this->_sfp->filename());
55 this->_construct();
56 this->get_vbox()->show_all_children();
57 }
59 SessionPlaybackDialogImpl::~SessionPlaybackDialogImpl()
60 {
62 }
64 void
65 SessionPlaybackDialogImpl::_construct()
66 {
67 Gtk::VBox* main = this->get_vbox();
69 // Dialog organization
70 this->_filemanager.set_label(_("Session file"));
71 this->_playback.set_label(_("Playback controls"));
72 this->_currentmsgbox.set_label(_("Message information"));
74 this->_filemanager.set_border_width(4);
75 this->_playback.set_border_width(4);
76 this->_fm.set_border_width(4);
77 this->_toolbarbox.set_border_width(4);
79 // Active session file display
80 // fixme: Does this mean the active file for the session, or the file for the active session?
81 // Please indicate which with a TRANSLATORS comment.
82 this->_labels[0].set_text(_("Active session file:"));
83 this->_labels[1].set_text(_("Delay (milliseconds):"));
85 this->_openfile.set_editable(false);
87 this->_filebox.pack_start(this->_labels[0], true, false, 8);
88 this->_filebox.pack_end(this->_openfile, true, true, 0);
90 // Unload/load buttons
91 this->_close.set_label(_("Close file"));
92 this->_open.set_label(_("Open new file"));
93 this->_setdelay.set_label(_("Set delay"));
95 // Attach callbacks
96 this->_close.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), CLOSE_FILE));
97 this->_open.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), OPEN_FILE));
98 this->_setdelay.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), RESET_DELAY));
100 // Button box
101 this->_filebuttons.pack_start(this->_close, true, false, 0);
102 this->_filebuttons.pack_start(this->_open, true, false, 0);
104 // Message information box
105 this->_currentmsgbuffer = Gtk::TextBuffer::create();
106 this->_currentmsgview.set_buffer(this->_currentmsgbuffer);
107 this->_currentmsgview.set_editable(false);
108 this->_currentmsgview.set_cursor_visible(false);
109 this->_currentmsgview.set_wrap_mode(Gtk::WRAP_WORD);
110 this->_currentmsgscroller.add(this->_currentmsgview);
111 this->_currentmsgbox.add(this->_currentmsgscroller);
112 this->_sfp->setMessageOutputWidget(this->_currentmsgbuffer);
114 // Delay setting
115 // parameters: initial lower upper single-incr page-incr
116 this->_delayentry.set_numeric(true);
118 // Playback controls
119 this->_playbackcontrols.set_show_arrow(false);
121 this->_controls[0].set_label("Rewind");
122 this->_controls[1].set_label("Go back one");
123 this->_controls[2].set_label("Pause");
124 this->_controls[3].set_label("Go forward one");
125 this->_controls[4].set_label("Play");
127 this->_controls[0].set_tooltip(this->_tooltips, _("Rewind"));
128 this->_controls[1].set_tooltip(this->_tooltips, _("Go back one change"));
129 this->_controls[2].set_tooltip(this->_tooltips, _("Pause"));
130 this->_controls[3].set_tooltip(this->_tooltips, _("Go forward one change"));
131 this->_controls[4].set_tooltip(this->_tooltips, _("Play"));
133 for(int i = 0; i < 5; i++) {
134 this->_playbackcontrols.append(this->_controls[i], sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), TOOLBAR_BASE + i));
135 }
137 this->_delaybox.pack_start(this->_labels[1]);
138 this->_delaybox.pack_start(this->_delayentry);
139 this->_delaybox.pack_end(this->_setdelay);
141 this->_toolbarbox.pack_start(this->_delaybox);
142 this->_toolbarbox.pack_end(this->_playbackcontrols);
144 // Pack widgets into frames
145 this->_fm.pack_start(this->_filebox);
146 this->_fm.pack_end(this->_filebuttons);
148 this->_filemanager.add(this->_fm);
149 this->_playback.add(this->_toolbarbox);
151 // Pack widgets into main vbox
152 main->pack_start(this->_filemanager);
153 main->pack_start(this->_playback);
154 main->pack_end(this->_currentmsgbox);
155 }
157 void
158 SessionPlaybackDialogImpl::_respCallback(int resp)
159 {
160 g_log(NULL, G_LOG_LEVEL_DEBUG, "_respCallback: %u", resp);
161 switch(resp) {
162 case CLOSE_FILE:
163 this->_sfp->unload();
164 break;
165 case OPEN_FILE: {
166 Gtk::FileChooserDialog sessionfiledlg(_("Open session file"), Gtk::FILE_CHOOSER_ACTION_OPEN);
167 sessionfiledlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
168 sessionfiledlg.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
170 int result = sessionfiledlg.run();
171 switch (result) {
172 case Gtk::RESPONSE_OK:
173 this->_sm->clearDocument();
174 sp_document_done(sp_desktop_document(this->_desktop), SP_VERB_NONE,
175 /* TODO: annotate */ "session-player.cpp:186");
176 this->_sm->loadSessionFile(sessionfiledlg.get_filename());
177 this->_openfile.set_text(this->_sfp->filename());
178 break;
179 default:
180 break;
181 }
182 break;
183 }
184 case RESET_DELAY:
185 this->_sfp->setDelay(this->_delayentry.get_value_as_int());
186 break;
187 case REWIND:
188 if (this->_sfp->_playing) {
189 this->_sfp->stop();
190 }
191 this->_sfp->_curdir = Whiteboard::SessionFilePlayer::BACKWARD;
192 this->_sfp->start();
193 break;
194 case STEP_REWIND:
195 this->_sfp->step(Whiteboard::SessionFilePlayer::BACKWARD);
196 break;
197 case PAUSE:
198 this->_sfp->stop();
199 break;
200 case STEP_PLAY:
201 this->_sfp->step(Whiteboard::SessionFilePlayer::FORWARD);
202 break;
203 case PLAY:
204 if (this->_sfp->_playing) {
205 this->_sfp->stop();
206 }
207 this->_sfp->_curdir = Whiteboard::SessionFilePlayer::FORWARD;
208 this->_sfp->start();
209 break;
210 default:
211 break;
212 }
213 }
215 }
217 }
219 }
221 /*
222 Local Variables:
223 mode:c++
224 c-file-style:"stroustrup"
225 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
226 indent-tabs-mode:nil
227 fill-column:99
228 End:
229 */
230 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :