gtk_callbacks.c 17.8 KB
Newer Older
Sam Hocevar's avatar
 
Sam Hocevar committed
1 2 3 4
/*****************************************************************************
 * gtk_callbacks.c : Callbacks for the Gtk+ plugin.
 *****************************************************************************
 * Copyright (C) 2000, 2001 VideoLAN
Sam Hocevar's avatar
 
Sam Hocevar committed
5
 * $Id: gtk_callbacks.c,v 1.35 2002/04/03 02:43:14 sam Exp $
Sam Hocevar's avatar
 
Sam Hocevar committed
6 7
 *
 * Authors: Samuel Hocevar <sam@zoy.org>
8
 *          Stphane Borel <stef@via.ecp.fr>
Sam Hocevar's avatar
 
Sam Hocevar committed
9
 *          Julien BLACHE <jb@technologeek.org>
Sam Hocevar's avatar
 
Sam Hocevar committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
 *      
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
29
#include <sys/types.h>                                              /* off_t */
Sam Hocevar's avatar
 
Sam Hocevar committed
30 31
#include <stdlib.h>

Sam Hocevar's avatar
 
Sam Hocevar committed
32 33
#include <videolan/vlc.h>

Sam Hocevar's avatar
 
Sam Hocevar committed
34 35
#include <unistd.h>

Sam Hocevar's avatar
 
Sam Hocevar committed
36 37
#include <gtk/gtk.h>

Pierre Baillet's avatar
Pierre Baillet committed
38 39
#include <string.h>

Sam Hocevar's avatar
 
Sam Hocevar committed
40 41 42 43
#include "stream_control.h"
#include "input_ext-intf.h"

#include "interface.h"
Sam Hocevar's avatar
 
Sam Hocevar committed
44
#include "intf_playlist.h"
Sam Hocevar's avatar
 
Sam Hocevar committed
45
#include "intf_eject.h"
Sam Hocevar's avatar
 
Sam Hocevar committed
46

47 48 49
#include "video.h"
#include "video_output.h"

Sam Hocevar's avatar
 
Sam Hocevar committed
50 51 52
#include "gtk_callbacks.h"
#include "gtk_interface.h"
#include "gtk_support.h"
Sam Hocevar's avatar
 
Sam Hocevar committed
53
#include "gtk_common.h"
Sam Hocevar's avatar
 
Sam Hocevar committed
54

55
#include "netutils.h"
Sam Hocevar's avatar
 
Sam Hocevar committed
56 57 58

/*****************************************************************************
 * Callbacks
Sam Hocevar's avatar
 
Sam Hocevar committed
59
 *****************************************************************************/
Sam Hocevar's avatar
 
Sam Hocevar committed
60

61 62 63
/*
 * Main interface callbacks
 */
Sam Hocevar's avatar
 
Sam Hocevar committed
64

65 66 67
gboolean GtkExit( GtkWidget       *widget,
                  GdkEventButton  *event,
                  gpointer         user_data )
Sam Hocevar's avatar
 
Sam Hocevar committed
68
{
69
    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
70

Sam Hocevar's avatar
 
Sam Hocevar committed
71
    vlc_mutex_lock( &p_intf->change_lock );
Sam Hocevar's avatar
 
Sam Hocevar committed
72
    p_intf->b_die = 1;
Sam Hocevar's avatar
 
Sam Hocevar committed
73
    vlc_mutex_unlock( &p_intf->change_lock );
Sam Hocevar's avatar
 
Sam Hocevar committed
74

75
    return TRUE;
Sam Hocevar's avatar
 
Sam Hocevar committed
76 77
}

78 79 80
gboolean GtkWindowDelete( GtkWidget       *widget,
                          GdkEvent        *event,
                          gpointer         user_data )
Sam Hocevar's avatar
 
Sam Hocevar committed
81
{
82
    GtkExit( GTK_WIDGET( widget ), NULL, user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
83

84
    return TRUE;
Sam Hocevar's avatar
 
Sam Hocevar committed
85 86 87
}


88 89 90
gboolean GtkWindowToggle( GtkWidget       *widget,
                          GdkEventButton  *event,
                          gpointer         user_data )
Sam Hocevar's avatar
 
Sam Hocevar committed
91
{
92 93 94 95 96
    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
    
    if( GTK_WIDGET_VISIBLE(p_intf->p_sys->p_window) )
    {
        gtk_widget_hide( p_intf->p_sys->p_window);
Sam Hocevar's avatar
 
Sam Hocevar committed
97

98 99
    } 
    else 
Sam Hocevar's avatar
 
Sam Hocevar committed
100
    {
101
        gtk_widget_show( p_intf->p_sys->p_window );
Sam Hocevar's avatar
 
Sam Hocevar committed
102 103
    }

104
    return TRUE;
Sam Hocevar's avatar
 
Sam Hocevar committed
105 106
}

107 108 109
gboolean GtkFullscreen( GtkWidget       *widget,
                        GdkEventButton  *event,
                        gpointer         user_data)
Sam Hocevar's avatar
 
Sam Hocevar committed
110
{
111
    if( p_vout_bank->i_count )
Sam Hocevar's avatar
 
Sam Hocevar committed
112
    {
113
        vlc_mutex_lock( &p_vout_bank->pp_vout[0]->change_lock );
114 115 116

        p_vout_bank->pp_vout[0]->i_changes |= VOUT_FULLSCREEN_CHANGE;

117
        vlc_mutex_unlock( &p_vout_bank->pp_vout[0]->change_lock );
Sam Hocevar's avatar
 
Sam Hocevar committed
118

119 120 121 122 123 124
        return TRUE;
    }
    else
    {
        return FALSE;
    }
Sam Hocevar's avatar
 
Sam Hocevar committed
125 126
}

127 128 129 130 131 132 133 134
void GtkWindowDrag( GtkWidget       *widget,
                    GdkDragContext  *drag_context,
                    gint             x,
                    gint             y,
                    GtkSelectionData *data,
                    guint            info,
                    guint            time,
                    gpointer         user_data)
Sam Hocevar's avatar
 
Sam Hocevar committed
135
{
136 137
    intf_thread_t * p_intf =  GetIntf( GTK_WIDGET(widget), "intf_window" );
    int end = p_main->p_playlist->i_size;
138
    GtkDropDataReceived( p_intf, data, info, PLAYLIST_END );
Sam Hocevar's avatar
 
Sam Hocevar committed
139

Sam Hocevar's avatar
 
Sam Hocevar committed
140
    if( p_input_bank->pp_input[0] != NULL )
Sam Hocevar's avatar
 
Sam Hocevar committed
141
    {
142
       /* FIXME: temporary hack */
Sam Hocevar's avatar
 
Sam Hocevar committed
143
       p_input_bank->pp_input[0]->b_eof = 1;
Sam Hocevar's avatar
 
Sam Hocevar committed
144
    }
145 146
     
    intf_PlaylistJumpto( p_main->p_playlist, end-1 );
Sam Hocevar's avatar
 
Sam Hocevar committed
147 148 149
}


150 151 152
/****************************************************************************
 * Slider management
 ****************************************************************************/
Sam Hocevar's avatar
 
Sam Hocevar committed
153

154 155 156
gboolean GtkSliderRelease( GtkWidget       *widget,
                           GdkEventButton  *event,
                           gpointer         user_data )
Sam Hocevar's avatar
 
Sam Hocevar committed
157
{
158
    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
Sam Hocevar's avatar
 
Sam Hocevar committed
159

160 161 162
    vlc_mutex_lock( &p_intf->change_lock );
    p_intf->p_sys->b_slider_free = 1;
    vlc_mutex_unlock( &p_intf->change_lock );
Sam Hocevar's avatar
 
Sam Hocevar committed
163

164
    return FALSE;
Sam Hocevar's avatar
 
Sam Hocevar committed
165 166 167
}


168 169 170
gboolean GtkSliderPress( GtkWidget       *widget,
                         GdkEventButton  *event,
                         gpointer         user_data)
Sam Hocevar's avatar
 
Sam Hocevar committed
171
{
172
    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
Sam Hocevar's avatar
 
Sam Hocevar committed
173

Sam Hocevar's avatar
 
Sam Hocevar committed
174
    vlc_mutex_lock( &p_intf->change_lock );
175
    p_intf->p_sys->b_slider_free = 0;
Sam Hocevar's avatar
 
Sam Hocevar committed
176
    vlc_mutex_unlock( &p_intf->change_lock );
Sam Hocevar's avatar
 
Sam Hocevar committed
177

178
    return FALSE;
Sam Hocevar's avatar
 
Sam Hocevar committed
179 180 181
}


182 183 184 185 186
/****************************************************************************
 * DVD specific items
 ****************************************************************************/

void GtkTitlePrev( GtkButton * button, gpointer user_data )
Sam Hocevar's avatar
 
Sam Hocevar committed
187
{
188 189 190
    intf_thread_t * p_intf;
    input_area_t *  p_area;
    int             i_id;
Sam Hocevar's avatar
 
Sam Hocevar committed
191

192
    p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
193
    i_id = p_input_bank->pp_input[0]->stream.p_selected_area->i_id - 1;
Sam Hocevar's avatar
 
Sam Hocevar committed
194

195 196 197
    /* Disallow area 0 since it is used for video_ts.vob */
    if( i_id > 0 )
    {
Sam Hocevar's avatar
 
Sam Hocevar committed
198 199
        p_area = p_input_bank->pp_input[0]->stream.pp_areas[i_id];
        input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );
Sam Hocevar's avatar
 
Sam Hocevar committed
200

Sam Hocevar's avatar
 
Sam Hocevar committed
201
        input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
Sam Hocevar's avatar
 
Sam Hocevar committed
202

203
        p_intf->p_sys->b_title_update = 1;
Sam Hocevar's avatar
 
Sam Hocevar committed
204
        vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
205
        GtkSetupMenus( p_intf );
Sam Hocevar's avatar
 
Sam Hocevar committed
206
        vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
Sam Hocevar's avatar
 
Sam Hocevar committed
207 208 209 210
    }
}


211
void GtkTitleNext( GtkButton * button, gpointer user_data )
Sam Hocevar's avatar
 
Sam Hocevar committed
212
{
213 214 215
    intf_thread_t * p_intf;
    input_area_t *  p_area;
    int             i_id;
Sam Hocevar's avatar
 
Sam Hocevar committed
216

217
    p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
218
    i_id = p_input_bank->pp_input[0]->stream.p_selected_area->i_id + 1;
Sam Hocevar's avatar
 
Sam Hocevar committed
219

Sam Hocevar's avatar
 
Sam Hocevar committed
220
    if( i_id < p_input_bank->pp_input[0]->stream.i_area_nb )
Sam Hocevar's avatar
 
Sam Hocevar committed
221
    {
Sam Hocevar's avatar
 
Sam Hocevar committed
222 223
        p_area = p_input_bank->pp_input[0]->stream.pp_areas[i_id];   
        input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );
Sam Hocevar's avatar
 
Sam Hocevar committed
224

Sam Hocevar's avatar
 
Sam Hocevar committed
225
        input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
Sam Hocevar's avatar
 
Sam Hocevar committed
226

227
        p_intf->p_sys->b_title_update = 1;
Sam Hocevar's avatar
 
Sam Hocevar committed
228
        vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
229
        GtkSetupMenus( p_intf );
Sam Hocevar's avatar
 
Sam Hocevar committed
230
        vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
Sam Hocevar's avatar
 
Sam Hocevar committed
231 232 233 234 235
    }

}


236
void GtkChapterPrev( GtkButton * button, gpointer user_data )
Sam Hocevar's avatar
 
Sam Hocevar committed
237
{
238 239
    intf_thread_t * p_intf;
    input_area_t *  p_area;
Sam Hocevar's avatar
 
Sam Hocevar committed
240

241
    p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
242
    p_area = p_input_bank->pp_input[0]->stream.p_selected_area;
Sam Hocevar's avatar
 
Sam Hocevar committed
243

244 245 246
    if( p_area->i_part > 0 )
    {
        p_area->i_part--;
Sam Hocevar's avatar
 
Sam Hocevar committed
247
        input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );
Sam Hocevar's avatar
 
Sam Hocevar committed
248

Sam Hocevar's avatar
 
Sam Hocevar committed
249
        input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
Sam Hocevar's avatar
 
Sam Hocevar committed
250

251
        p_intf->p_sys->b_chapter_update = 1;
Sam Hocevar's avatar
 
Sam Hocevar committed
252
        vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
253
        GtkSetupMenus( p_intf );
Sam Hocevar's avatar
 
Sam Hocevar committed
254
        vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
255
    }
Sam Hocevar's avatar
 
Sam Hocevar committed
256 257 258
}


259
void GtkChapterNext( GtkButton * button, gpointer user_data )
Sam Hocevar's avatar
 
Sam Hocevar committed
260
{
261 262
    intf_thread_t * p_intf;
    input_area_t *  p_area;
Sam Hocevar's avatar
 
Sam Hocevar committed
263

264
    p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
265
    p_area = p_input_bank->pp_input[0]->stream.p_selected_area;
Sam Hocevar's avatar
 
Sam Hocevar committed
266

267 268 269
    if( p_area->i_part < p_area->i_part_nb )
    {
        p_area->i_part++;
Sam Hocevar's avatar
 
Sam Hocevar committed
270
        input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );
Sam Hocevar's avatar
 
Sam Hocevar committed
271

Sam Hocevar's avatar
 
Sam Hocevar committed
272
        input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
Sam Hocevar's avatar
 
Sam Hocevar committed
273

274
        p_intf->p_sys->b_chapter_update = 1;
Sam Hocevar's avatar
 
Sam Hocevar committed
275
        vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
276
        GtkSetupMenus( p_intf );
Sam Hocevar's avatar
 
Sam Hocevar committed
277
        vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
278
    }
Sam Hocevar's avatar
 
Sam Hocevar committed
279 280
}

281 282 283 284 285 286 287 288
/****************************************************************************
 * Network specific items
 ****************************************************************************/
void GtkNetworkJoin( GtkEditable * editable, gpointer user_data )
{
    int     i_channel;

    i_channel = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( editable ) );
289
//    intf_WarnMsg( 3, "intf info: joining channel %d", i_channel );
290 291 292 293 294 295 296 297 298 299

//    network_ChannelJoin( i_channel );
}

void GtkChannelGo( GtkButton * button, gpointer user_data )
{
    GtkWidget *     window;
    GtkWidget *     spin;
    int             i_channel;

300 301
    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );

302 303 304 305 306 307 308
    window = gtk_widget_get_toplevel( GTK_WIDGET (button) );
    spin = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( window ),
                       "network_channel_spinbutton" ) );

    i_channel = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( spin ) );
    intf_WarnMsg( 3, "intf info: joining channel %d", i_channel );

309
    vlc_mutex_lock( &p_intf->change_lock );
Sam Hocevar's avatar
 
Sam Hocevar committed
310
    if( p_input_bank->pp_input[0] != NULL )
311 312
    {
        /* end playing item */
Sam Hocevar's avatar
 
Sam Hocevar committed
313
        p_input_bank->pp_input[0]->b_eof = 1;
314 315 316 317 318 319 320 321 322 323 324 325 326

        /* update playlist */
        vlc_mutex_lock( &p_main->p_playlist->change_lock );

        p_main->p_playlist->i_index--;
        p_main->p_playlist->b_stopped = 1;

        vlc_mutex_unlock( &p_main->p_playlist->change_lock );

        /* FIXME: ugly hack to close input and outputs */
        p_intf->pf_manage( p_intf );
    }

327
    network_ChannelJoin( i_channel );
Sam Hocevar's avatar
 
Sam Hocevar committed
328 329 330 331 332 333 334

    /* FIXME 2 */
    p_main->p_playlist->b_stopped = 0;
    p_intf->pf_manage( p_intf );

    vlc_mutex_unlock( &p_intf->change_lock );

Sam Hocevar's avatar
 
Sam Hocevar committed
335
//    input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
336 337 338
}


339 340 341
/****************************************************************************
 * About box
 ****************************************************************************/
Sam Hocevar's avatar
 
Sam Hocevar committed
342

343 344 345
gboolean GtkAboutShow( GtkWidget       *widget,
                       GdkEventButton  *event,
                       gpointer         user_data)
Sam Hocevar's avatar
 
Sam Hocevar committed
346
{
347
    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
348

349
    if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
Sam Hocevar's avatar
 
Sam Hocevar committed
350
    {
351 352
        p_intf->p_sys->p_about = create_intf_about();
        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
Sam Hocevar's avatar
 
Sam Hocevar committed
353 354
                             "p_intf", p_intf );
    }
355 356
    gtk_widget_show( p_intf->p_sys->p_about );
    gdk_window_raise( p_intf->p_sys->p_about->window );
Sam Hocevar's avatar
 
Sam Hocevar committed
357

358
    return TRUE;
Sam Hocevar's avatar
 
Sam Hocevar committed
359 360
}

361
void GtkAboutOk( GtkButton * button, gpointer user_data)
Sam Hocevar's avatar
 
Sam Hocevar committed
362
{
363
    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
364 365 366 367

    gtk_widget_hide( p_intf->p_sys->p_about );
}

Sam Hocevar's avatar
 
Sam Hocevar committed
368

369 370 371
/****************************************************************************
 * Jump box
 ****************************************************************************/
Sam Hocevar's avatar
 
Sam Hocevar committed
372

373 374 375
gboolean GtkJumpShow( GtkWidget       *widget,
                      GdkEventButton  *event,
                      gpointer         user_data)
Sam Hocevar's avatar
 
Sam Hocevar committed
376
{
377
    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
378

379
    if( !GTK_IS_WIDGET( p_intf->p_sys->p_jump ) )
Sam Hocevar's avatar
 
Sam Hocevar committed
380
    {
381 382
        p_intf->p_sys->p_jump = create_intf_jump();
        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_jump ),
Sam Hocevar's avatar
 
Sam Hocevar committed
383 384 385
                             "p_intf", p_intf );
    }

386 387
    gtk_widget_show( p_intf->p_sys->p_jump );
    gdk_window_raise( p_intf->p_sys->p_jump->window );
Sam Hocevar's avatar
 
Sam Hocevar committed
388

389
    return FALSE;
Sam Hocevar's avatar
 
Sam Hocevar committed
390 391 392
}


393 394
void GtkJumpOk( GtkButton       *button,
                gpointer         user_data)
Sam Hocevar's avatar
 
Sam Hocevar committed
395
{
396 397 398 399 400 401
    intf_thread_t * p_intf;
    off_t           i_seek;
    off_t           i_size;
    int             i_hours;
    int             i_minutes;
    int             i_seconds;
Sam Hocevar's avatar
 
Sam Hocevar committed
402

403
    p_intf = GetIntf( GTK_WIDGET( button ), (char*)user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
404

405 406 407
#define GET_VALUE( name )                                                   \
    gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( gtk_object_get_data( \
        GTK_OBJECT( p_intf->p_sys->p_jump ), name ) ) )
Sam Hocevar's avatar
 
Sam Hocevar committed
408

409 410 411
    i_hours   = GET_VALUE( "jump_hour_spinbutton" );
    i_minutes = GET_VALUE( "jump_minute_spinbutton" );
    i_seconds = GET_VALUE( "jump_second_spinbutton" );
Sam Hocevar's avatar
 
Sam Hocevar committed
412

413
#undef GET_VALUE
Sam Hocevar's avatar
 
Sam Hocevar committed
414

415
    i_seconds += 60 *i_minutes + 3600* i_hours;
Sam Hocevar's avatar
 
Sam Hocevar committed
416

Sam Hocevar's avatar
 
Sam Hocevar committed
417 418 419 420
    vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
    i_seek = i_seconds * 50 * p_input_bank->pp_input[0]->stream.i_mux_rate;
    i_size = p_input_bank->pp_input[0]->stream.p_selected_area->i_size;
    vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
Sam Hocevar's avatar
 
Sam Hocevar committed
421

422
    if( i_seek < i_size )
Sam Hocevar's avatar
 
Sam Hocevar committed
423
    {
Sam Hocevar's avatar
 
Sam Hocevar committed
424
        input_Seek( p_input_bank->pp_input[0], i_seek );
Sam Hocevar's avatar
 
Sam Hocevar committed
425
    }
426 427
    p_main->p_playlist->b_stopped = 0;
    gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
428 429 430
}


431 432
void GtkJumpCancel( GtkButton       *button,
                    gpointer         user_data)
433
{
434
    gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
435 436 437
}


438 439 440 441
/****************************************************************************
 * Callbacks for menuitems
 ****************************************************************************/
void GtkExitActivate( GtkMenuItem * menuitem, gpointer user_data )
442
{
443
    GtkExit( GTK_WIDGET( menuitem ), NULL, user_data );
444 445 446
}


447
void GtkFullscreenActivate( GtkMenuItem * menuitem, gpointer user_data )
Pierre Baillet's avatar
Pierre Baillet committed
448
{
449
    GtkFullscreen( GTK_WIDGET( menuitem ), NULL, user_data );
Pierre Baillet's avatar
Pierre Baillet committed
450 451
}

Sam Hocevar's avatar
 
Sam Hocevar committed
452

453
void GtkWindowToggleActivate( GtkMenuItem * menuitem, gpointer user_data )
Sam Hocevar's avatar
 
Sam Hocevar committed
454
{
455
    GtkWindowToggle( GTK_WIDGET( menuitem ), NULL, user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
456 457 458
}


459
void GtkAboutActivate( GtkMenuItem * menuitem, gpointer user_data )
Sam Hocevar's avatar
 
Sam Hocevar committed
460
{
461
    GtkAboutShow( GTK_WIDGET( menuitem ), NULL, user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
462 463 464
}


465
void GtkJumpActivate( GtkMenuItem * menuitem, gpointer user_data )
Sam Hocevar's avatar
 
Sam Hocevar committed
466
{
467
    GtkJumpShow( GTK_WIDGET( menuitem ), NULL, user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
468
}
469

Sam Hocevar's avatar
 
Sam Hocevar committed
470

Sam Hocevar's avatar
 
Sam Hocevar committed
471 472 473 474 475 476
void GtkMessagesActivate( GtkMenuItem * menuitem, gpointer user_data )
{
    GtkMessagesShow( GTK_WIDGET( menuitem ), NULL, user_data );
}


Sam Hocevar's avatar
 
Sam Hocevar committed
477 478 479 480 481 482
/****************************************************************************
 * Callbacks for disc ejection
 ****************************************************************************/
gboolean GtkDiscEject ( GtkWidget *widget, GdkEventButton *event,
                        gpointer user_data )
{
Sam Hocevar's avatar
 
Sam Hocevar committed
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
    char *psz_device = NULL;

    /*
     * Get the active input
     * Determine whether we can eject a media, ie it's a VCD or DVD
     * If it's neither a VCD nor a DVD, then return
     */

    /*
     * Don't really know if I must lock the stuff here, we're using it read-only
     */

    if (p_main->p_playlist->current.psz_name != NULL)
    {
        if( !strncmp(p_main->p_playlist->current.psz_name, "dvd:", 4) )
        {
            switch( p_main->p_playlist->current.psz_name[4] )
            {
            case '\0':
            case '@':
                psz_device = strdup( DVD_DEVICE );
                break;
            default:
                /* Omit the first 4 characters */
                psz_device = strdup( p_main->p_playlist->current.psz_name + 4 );
                break;
            }
        }
        else if( !strncmp(p_main->p_playlist->current.psz_name, "vcd:", 4) )
        {
            switch( p_main->p_playlist->current.psz_name[4] )
            {
            case '\0':
            case '@':
                psz_device = strdup( VCD_DEVICE );
                break;
            default:
                /* Omit the first 4 characters */
                psz_device = strdup( p_main->p_playlist->current.psz_name + 4 );
                break;
            }
        }
        else
        {
            psz_device = strdup( p_main->p_playlist->current.psz_name );
        }
    }

    if( psz_device == NULL )
    {
        return TRUE;
    }

    /* If there's a stream playing, we aren't allowed to eject ! */
    if( p_input_bank->pp_input[0] == NULL )
    {
        intf_WarnMsg( 4, "intf: ejecting %s", psz_device );

        intf_Eject( psz_device );
    }

    free(psz_device);
    return TRUE;
Sam Hocevar's avatar
 
Sam Hocevar committed
546 547 548 549
}

void GtkEjectDiscActivate ( GtkMenuItem *menuitem, gpointer user_data )
{
Sam Hocevar's avatar
 
Sam Hocevar committed
550
    GtkDiscEject( GTK_WIDGET( menuitem ), NULL, user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
551
}
Sam Hocevar's avatar
 
Sam Hocevar committed
552 553 554 555 556 557 558 559 560

/****************************************************************************
 * Messages window
 ****************************************************************************/

gboolean GtkMessagesShow( GtkWidget       *widget,
                          GdkEventButton  *event,
                          gpointer         user_data)
{
Sam Hocevar's avatar
 
Sam Hocevar committed
561 562
    static GdkColor black = { 0, 0x0000, 0x0000, 0x0000 };
    static GdkColormap *colormap;
Sam Hocevar's avatar
 
Sam Hocevar committed
563
    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
Sam Hocevar's avatar
 
Sam Hocevar committed
564

Sam Hocevar's avatar
 
Sam Hocevar committed
565
    gtk_widget_show( p_intf->p_sys->p_messages );
Sam Hocevar's avatar
 
Sam Hocevar committed
566 567 568 569 570
    colormap = gdk_colormap_get_system ();
    gdk_color_alloc( colormap, &black );
    gdk_window_set_background( p_intf->p_sys->p_messages_text->text_area,
                               &black );

Sam Hocevar's avatar
 
Sam Hocevar committed
571
    gdk_window_raise( p_intf->p_sys->p_messages->window );
Sam Hocevar's avatar
 
Sam Hocevar committed
572 573 574 575

    gtk_text_set_point( p_intf->p_sys->p_messages_text,
                    gtk_text_get_length( p_intf->p_sys->p_messages_text ) );

Sam Hocevar's avatar
 
Sam Hocevar committed
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
    return TRUE;
}


void
GtkMessagesOk                          (GtkButton       *button,
                                        gpointer         user_data)
{
    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
    gtk_widget_hide( p_intf->p_sys->p_messages );
}


gboolean
GtkMessagesDelete                      (GtkWidget       *widget,
                                        GdkEvent        *event,
                                        gpointer         user_data)
{
    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
    gtk_widget_hide( p_intf->p_sys->p_messages );
    return TRUE;
}

Johan Bilien's avatar
 
Johan Bilien committed
599