~ubuntu-branches/ubuntu/maverick/vlc/maverick

« back to all changes in this revision

Viewing changes to modules/gui/wxwidgets/dialogs/messages.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-09-17 21:56:14 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20080917215614-tj0vx8xzd57e52t8
Tags: 0.9.2-1ubuntu1
* New Upstream Release, exception granted by
    - dktrkranz, norsetto, Hobbsee (via irc). LP: #270404

Changes done in ubuntu:

* add libxul-dev to build-depends
* make sure that vlc is build against libxul in configure. This doesn't
  change anything in the package, but makes it more robust if building
  in an 'unclean' chroot or when modifying the package.
* debian/control: make Vcs-* fields point to the motumedia branch
* add libx264-dev and libass-dev to build-depends
  LP: #210354, #199870
* actually enable libass support by passing --enable-libass to configure
* enable libdca: add libdca-dev to build depends and --enable-libdca
* install the x264 plugin.

Changes already in the pkg-multimedia branch in debian:

* don't install usr/share/vlc/mozilla in debian/mozilla-plugin-vlc.install  
* new upstream .desktop file now registers flash video mimetype LP: #261567
* add Xb-Npp-Applications to mozilla-plugin-vlc
* remove duplicate entries in debian/vlc-nox.install

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 * messages.cpp : wxWindows plugin for vlc
3
 
 *****************************************************************************
4
 
 * Copyright (C) 2000-2004 the VideoLAN team
5
 
 * $Id: 88827462fe28bd1a6289b8be274a1c893ec314a7 $
6
 
 *
7
 
 * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
8
 
 *
9
 
 * This program is free software; you can redistribute it and/or modify
10
 
 * it under the terms of the GNU General Public License as published by
11
 
 * the Free Software Foundation; either version 2 of the License, or
12
 
 * (at your option) any later version.
13
 
 *
14
 
 * This program is distributed in the hope that it will be useful,
15
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 * GNU General Public License for more details.
18
 
 *
19
 
 * You should have received a copy of the GNU General Public License
20
 
 * along with this program; if not, write to the Free Software
21
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22
 
 *****************************************************************************/
23
 
 
24
 
#include "dialogs/messages.hpp"
25
 
 
26
 
/*****************************************************************************
27
 
 * Event Table.
28
 
 *****************************************************************************/
29
 
 
30
 
/* IDs for the controls and the menu commands */
31
 
 
32
 
BEGIN_EVENT_TABLE(Messages, wxFrame)
33
 
    /* Button events */
34
 
    EVT_BUTTON(wxID_CLOSE, Messages::OnButtonClose)
35
 
    EVT_BUTTON(wxID_CLEAR, Messages::OnClear)
36
 
    EVT_BUTTON(wxID_SAVEAS, Messages::OnSaveLog)
37
 
 
38
 
    /* Special events : we don't want to destroy the window when the user
39
 
     * clicks on (X) */
40
 
    EVT_CLOSE(Messages::OnClose)
41
 
END_EVENT_TABLE()
42
 
 
43
 
/*****************************************************************************
44
 
 * Constructor.
45
 
 *****************************************************************************/
46
 
Messages::Messages( intf_thread_t *_p_intf, wxWindow *p_parent ):
47
 
    wxFrame( p_parent, -1, wxU(_("Messages")), wxDefaultPosition,
48
 
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
49
 
{
50
 
    /* Initializations */
51
 
    p_intf = _p_intf;
52
 
    b_verbose = VLC_FALSE;
53
 
    SetIcon( *p_intf->p_sys->p_icon );
54
 
    save_log_dialog = NULL;
55
 
    b_verbose = VLC_FALSE;
56
 
 
57
 
    /* Create a panel to put everything in */
58
 
    wxPanel *messages_panel = new wxPanel( this, -1 );
59
 
    messages_panel->SetAutoLayout( TRUE );
60
 
 
61
 
    /* Create the textctrl and some text attributes */
62
 
    textctrl = new wxTextCtrl( messages_panel, -1, wxT(""), wxDefaultPosition,
63
 
        wxSize::wxSize( 400, 500 ), wxTE_MULTILINE | wxTE_READONLY |
64
 
                                    wxTE_RICH | wxTE_NOHIDESEL );
65
 
    info_attr = new wxTextAttr( wxColour::wxColour( 0, 128, 0 ) );
66
 
    err_attr = new wxTextAttr( *wxRED );
67
 
    warn_attr = new wxTextAttr( *wxBLUE );
68
 
    dbg_attr = new wxTextAttr( *wxBLACK );
69
 
 
70
 
    /* Create the Close button */
71
 
    wxButton *close_button = new wxButton( messages_panel, wxID_CLOSE,
72
 
                                        wxU(_("&Close")));
73
 
    close_button->SetDefault();
74
 
 
75
 
    /* Create the Clear button */
76
 
    wxButton *clear_button = new wxButton( messages_panel, wxID_CLEAR,
77
 
                                           wxU(_("Clear")));
78
 
 
79
 
    /* Create the Save Log button */
80
 
    wxButton *save_log_button = new wxButton( messages_panel, wxID_SAVEAS,
81
 
                                              wxU(_("Save &As...")));
82
 
 
83
 
 
84
 
    /* Place everything in sizers */
85
 
    wxBoxSizer *buttons_sizer = new wxBoxSizer( wxHORIZONTAL );
86
 
    buttons_sizer->Add( save_log_button, 0, wxEXPAND |wxALIGN_LEFT| wxALL, 5 );
87
 
    buttons_sizer->Add( clear_button, 0, wxEXPAND |wxALIGN_RIGHT| wxALL, 5 );
88
 
    buttons_sizer->Add( close_button, 0, wxEXPAND |wxALIGN_RIGHT| wxALL, 5 );
89
 
    buttons_sizer->Add( new wxPanel( this, -1 ), 1, wxALL, 5 );
90
 
    buttons_sizer->Layout();
91
 
    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
92
 
    wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
93
 
    panel_sizer->Add( textctrl, 1, wxEXPAND | wxALL, 5 );
94
 
    panel_sizer->Add( buttons_sizer, 0, wxEXPAND | wxALL, 5 );
95
 
    panel_sizer->Layout();
96
 
    messages_panel->SetSizerAndFit( panel_sizer );
97
 
    main_sizer->Add( messages_panel, 1, wxGROW, 0 );
98
 
    main_sizer->Layout();
99
 
    SetSizerAndFit( main_sizer );
100
 
}
101
 
 
102
 
Messages::~Messages()
103
 
{
104
 
    /* Clean up */
105
 
    if( save_log_dialog ) delete save_log_dialog;
106
 
 
107
 
    delete info_attr;
108
 
    delete err_attr;
109
 
    delete warn_attr;
110
 
    delete dbg_attr;
111
 
}
112
 
 
113
 
bool Messages::Show( bool show )
114
 
{
115
 
    b_verbose = show;
116
 
    return wxFrame::Show( show );
117
 
}
118
 
 
119
 
void Messages::UpdateLog()
120
 
{
121
 
    msg_subscription_t *p_sub = p_intf->p_sys->p_sub;
122
 
    int i_start;
123
 
 
124
 
    vlc_mutex_lock( p_sub->p_lock );
125
 
    int i_stop = *p_sub->pi_stop;
126
 
    vlc_mutex_unlock( p_sub->p_lock );
127
 
 
128
 
 
129
 
    if( p_sub->i_start != i_stop )
130
 
    {
131
 
        textctrl->SetInsertionPointEnd();
132
 
 
133
 
        for( i_start = p_sub->i_start;
134
 
             i_start != i_stop;
135
 
             i_start = (i_start+1) % VLC_MSG_QSIZE )
136
 
        {
137
 
 
138
 
            if( !b_verbose &&
139
 
                VLC_MSG_ERR != p_sub->p_msg[i_start].i_type )
140
 
                continue;
141
 
 
142
 
            /* Append all messages to log window */
143
 
            textctrl->SetDefaultStyle( *dbg_attr );
144
 
            (*textctrl) << wxL2U(p_sub->p_msg[i_start].psz_module);
145
 
 
146
 
            switch( p_sub->p_msg[i_start].i_type )
147
 
            {
148
 
            case VLC_MSG_INFO:
149
 
                (*textctrl) << wxT(": ");
150
 
                textctrl->SetDefaultStyle( *info_attr );
151
 
                break;
152
 
            case VLC_MSG_ERR:
153
 
                (*textctrl) << wxT(" error: ");
154
 
                textctrl->SetDefaultStyle( *err_attr );
155
 
                break;
156
 
            case VLC_MSG_WARN:
157
 
                (*textctrl) << wxT(" warning: ");
158
 
                textctrl->SetDefaultStyle( *warn_attr );
159
 
                break;
160
 
            case VLC_MSG_DBG:
161
 
            default:
162
 
                (*textctrl) << wxT(" debug: ");
163
 
                break;
164
 
            }
165
 
 
166
 
            /* Add message */
167
 
            (*textctrl) << wxL2U(p_sub->p_msg[i_start].psz_msg) << wxT("\n");
168
 
        }
169
 
 
170
 
        vlc_mutex_lock( p_sub->p_lock );
171
 
        p_sub->i_start = i_start;
172
 
        vlc_mutex_unlock( p_sub->p_lock );
173
 
    }
174
 
}
175
 
 
176
 
/*****************************************************************************
177
 
 * Private methods.
178
 
 *****************************************************************************/
179
 
void Messages::OnButtonClose( wxCommandEvent& WXUNUSED(event) )
180
 
{
181
 
    wxCloseEvent cevent;
182
 
    OnClose(cevent);
183
 
}
184
 
 
185
 
void Messages::OnClose( wxCloseEvent& WXUNUSED(event) )
186
 
{
187
 
    Hide();
188
 
}
189
 
 
190
 
void Messages::OnClear( wxCommandEvent& WXUNUSED(event) )
191
 
{
192
 
    textctrl->Clear();
193
 
}
194
 
 
195
 
void Messages::OnSaveLog( wxCommandEvent& WXUNUSED(event) )
196
 
{
197
 
    if( save_log_dialog == NULL )
198
 
        save_log_dialog = new wxFileDialog( this,
199
 
            wxU(_("Save Messages As...")),
200
 
            wxT(""), wxT("messages"), wxT("*"), wxSAVE | wxOVERWRITE_PROMPT );
201
 
 
202
 
    if( save_log_dialog && save_log_dialog->ShowModal() == wxID_OK )
203
 
    {
204
 
        if( !textctrl->SaveFile( save_log_dialog->GetPath() ) )
205
 
        {
206
 
            // [FIX ME] should print an error message
207
 
        }
208
 
    }
209
 
}