~ubuntu-branches/debian/experimental/inkscape/experimental

« back to all changes in this revision

Viewing changes to src/ui/dialog/session-player.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * Whiteboard session playback control dialog
3
 
 *
4
 
 * Authors:
5
 
 * David Yip <yipdw@rose-hulman.edu>
6
 
 *
7
 
 * Copyright (c) 2005 Authors
8
 
 *
9
 
 * Released under GNU GPL, read the file 'COPYING' for more information
10
 
 */
11
 
 
12
 
#ifdef HAVE_CONFIG_H
13
 
#include "config.h"
14
 
#endif
15
 
 
16
 
#include <glibmm.h>
17
 
#include <glibmm/i18n.h>
18
 
#include <gtk/gtkdialog.h>
19
 
#include <gtkmm.h>
20
 
 
21
 
#include "inkscape.h"
22
 
#include "path-prefix.h"
23
 
 
24
 
#include "desktop.h"
25
 
#include "desktop-handles.h"
26
 
#include "document.h"
27
 
 
28
 
#include "ui/stock.h"
29
 
 
30
 
#include "jabber_whiteboard/node-tracker.h"
31
 
#include "jabber_whiteboard/session-manager.h"
32
 
#include "jabber_whiteboard/session-file-player.h"
33
 
 
34
 
#include "ui/dialog/session-player.h"
35
 
 
36
 
#include "util/ucompose.hpp"
37
 
 
38
 
namespace Inkscape {
39
 
 
40
 
namespace UI {
41
 
 
42
 
namespace Dialog {
43
 
 
44
 
SessionPlaybackDialog*
45
 
SessionPlaybackDialog::create()
46
 
{
47
 
        return new SessionPlaybackDialogImpl();
48
 
}
49
 
 
50
 
SessionPlaybackDialogImpl::SessionPlaybackDialogImpl() 
51
 
        : _delay(100, 1, 5000, 10, 100), _delayentry(_delay)
52
 
{
53
 
        this->_desktop = SP_ACTIVE_DESKTOP;
54
 
        this->_sm = this->_desktop->whiteboard_session_manager();
55
 
        this->_sfp = this->_sm->session_player();
56
 
        this->_openfile.set_text(this->_sfp->filename());
57
 
 
58
 
        this->_construct();
59
 
        this->get_vbox()->show_all_children();
60
 
}
61
 
 
62
 
SessionPlaybackDialogImpl::~SessionPlaybackDialogImpl()
63
 
{
64
 
 
65
 
}
66
 
 
67
 
void
68
 
SessionPlaybackDialogImpl::_construct()
69
 
{
70
 
        Gtk::VBox* main = this->get_vbox();
71
 
 
72
 
        // Dialog organization
73
 
        this->_filemanager.set_label(_("Session file"));
74
 
        this->_playback.set_label(_("Playback controls"));
75
 
        this->_currentmsgbox.set_label(_("Message information"));
76
 
 
77
 
        this->_filemanager.set_border_width(4);
78
 
        this->_playback.set_border_width(4);
79
 
        this->_fm.set_border_width(4);
80
 
        this->_toolbarbox.set_border_width(4);
81
 
 
82
 
        // Active session file display
83
 
        // fixme: Does this mean the active file for the session, or the file for the active session?
84
 
        // Please indicate which with a TRANSLATORS comment.
85
 
        this->_labels[0].set_text(_("Active session file:"));
86
 
        this->_labels[1].set_text(_("Delay (milliseconds):"));
87
 
 
88
 
        this->_openfile.set_editable(false);
89
 
 
90
 
        this->_filebox.pack_start(this->_labels[0], true, false, 8);
91
 
        this->_filebox.pack_end(this->_openfile, true, true, 0);
92
 
 
93
 
        // Unload/load buttons
94
 
        this->_close.set_label(_("Close file"));
95
 
        this->_open.set_label(_("Open new file"));
96
 
        this->_setdelay.set_label(_("Set delay"));
97
 
 
98
 
        // Attach callbacks
99
 
        this->_close.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), CLOSE_FILE));
100
 
        this->_open.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), OPEN_FILE));
101
 
        this->_setdelay.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), RESET_DELAY));
102
 
 
103
 
        // Button box
104
 
        this->_filebuttons.pack_start(this->_close, true, false, 0);
105
 
        this->_filebuttons.pack_start(this->_open, true, false, 0);
106
 
 
107
 
        // Message information box
108
 
        this->_currentmsgbuffer = Gtk::TextBuffer::create();
109
 
        this->_currentmsgview.set_buffer(this->_currentmsgbuffer);
110
 
        this->_currentmsgview.set_editable(false);
111
 
        this->_currentmsgview.set_cursor_visible(false);
112
 
        this->_currentmsgview.set_wrap_mode(Gtk::WRAP_WORD);
113
 
        this->_currentmsgscroller.add(this->_currentmsgview);
114
 
        this->_currentmsgbox.add(this->_currentmsgscroller);
115
 
        this->_sfp->setMessageOutputWidget(this->_currentmsgbuffer);
116
 
        
117
 
        // Delay setting
118
 
        // parameters: initial lower upper single-incr page-incr
119
 
        this->_delayentry.set_numeric(true);
120
 
 
121
 
        // Playback controls
122
 
        this->_playbackcontrols.set_show_arrow(false);
123
 
 
124
 
        /* these are waiting for the Gtkmm conversion
125
 
        this->_controls[0].set_stock_id(Stock::SESSION_PLAYBACK_REW);
126
 
        this->_controls[1].set_stock_id(Stock::SESSION_PLAYBACK_STEPBACK);
127
 
        this->_controls[2].set_stock_id(Stock::SESSION_PLAYBACK_PAUSE);
128
 
        this->_controls[3].set_stock_id(Stock::SESSION_PLAYBACK_STEPFORWARD);
129
 
        this->_controls[4].set_stock_id(Stock::SESSION_PLAYBACK_PLAY);
130
 
        */
131
 
 
132
 
        this->_controls[0].set_label("Rewind");
133
 
        this->_controls[1].set_label("Go back one");
134
 
        this->_controls[2].set_label("Pause");
135
 
        this->_controls[3].set_label("Go forward one");
136
 
        this->_controls[4].set_label("Play");
137
 
 
138
 
        this->_controls[0].set_tooltip(this->_tooltips, _("Rewind"));
139
 
        this->_controls[1].set_tooltip(this->_tooltips, _("Go back one change"));
140
 
        this->_controls[2].set_tooltip(this->_tooltips, _("Pause"));
141
 
        this->_controls[3].set_tooltip(this->_tooltips, _("Go forward one change"));
142
 
        this->_controls[4].set_tooltip(this->_tooltips, _("Play"));
143
 
 
144
 
        for(int i = 0; i < 5; i++) {
145
 
                this->_playbackcontrols.append(this->_controls[i], sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), TOOLBAR_BASE + i));
146
 
        }
147
 
 
148
 
        this->_delaybox.pack_start(this->_labels[1]);
149
 
        this->_delaybox.pack_start(this->_delayentry);
150
 
        this->_delaybox.pack_end(this->_setdelay);
151
 
 
152
 
        this->_toolbarbox.pack_start(this->_delaybox);
153
 
        this->_toolbarbox.pack_end(this->_playbackcontrols);
154
 
 
155
 
        // Pack widgets into frames
156
 
        this->_fm.pack_start(this->_filebox);
157
 
        this->_fm.pack_end(this->_filebuttons);
158
 
 
159
 
        this->_filemanager.add(this->_fm);
160
 
        this->_playback.add(this->_toolbarbox);
161
 
                        
162
 
        // Pack widgets into main vbox
163
 
        main->pack_start(this->_filemanager);
164
 
        main->pack_start(this->_playback);
165
 
        main->pack_end(this->_currentmsgbox);
166
 
}
167
 
 
168
 
void
169
 
SessionPlaybackDialogImpl::_respCallback(int resp)
170
 
{
171
 
        g_log(NULL, G_LOG_LEVEL_DEBUG, "_respCallback: %u", resp);
172
 
        switch(resp) {
173
 
                case CLOSE_FILE:
174
 
                        this->_sfp->unload();
175
 
                        break;
176
 
                case OPEN_FILE: {
177
 
                        Gtk::FileChooserDialog sessionfiledlg(_("Open session file"), Gtk::FILE_CHOOSER_ACTION_OPEN);
178
 
                        sessionfiledlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
179
 
                        sessionfiledlg.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
180
 
 
181
 
                        int result = sessionfiledlg.run();
182
 
                        switch (result) {
183
 
                                case Gtk::RESPONSE_OK:
184
 
                                        this->_sm->clearDocument();
185
 
                                        sp_document_done(sp_desktop_document(this->_desktop));
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
 
}
224
 
 
225
 
}
226
 
 
227
 
}
228
 
 
229
 
}