* gtk_callbacks.c : Callbacks for the Gtk+ plugin.
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
- * $Id: gtk_callbacks.c,v 1.19 2001/05/19 00:39:30 stef Exp $
+ * $Id: gtk_callbacks.c,v 1.34 2002/03/25 02:06:24 jobi Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Stéphane Borel <stef@via.ecp.fr>
+ * Julien BLACHE <jb@technologeek.org>
*
* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#define MODULE_NAME gtk
-#include "modules_inner.h"
-
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include "defs.h"
#include <sys/types.h> /* off_t */
#include <stdlib.h>
+#include <videolan/vlc.h>
+
+#include <unistd.h>
+
#include <gtk/gtk.h>
#include <string.h>
-#include "config.h"
-#include "common.h"
-#include "threads.h"
-#include "mtime.h"
-
#include "stream_control.h"
#include "input_ext-intf.h"
#include "interface.h"
#include "intf_playlist.h"
-#include "intf_msg.h"
+#include "intf_eject.h"
#include "video.h"
#include "video_output.h"
#include "gtk_callbacks.h"
#include "gtk_interface.h"
#include "gtk_support.h"
-#include "intf_gtk.h"
+#include "gtk_common.h"
-#include "main.h"
+#include "netutils.h"
/*****************************************************************************
* Callbacks
int end = p_main->p_playlist->i_size;
GtkDropDataReceived( p_intf, data, info, PLAYLIST_END );
- if( p_intf->p_input != NULL )
+ if( p_input_bank->pp_input[0] != NULL )
{
/* FIXME: temporary hack */
- p_intf->p_input->b_eof = 1;
+ p_input_bank->pp_input[0]->b_eof = 1;
}
intf_PlaylistJumpto( p_main->p_playlist, end-1 );
int i_id;
p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
- i_id = p_intf->p_input->stream.p_selected_area->i_id - 1;
+ i_id = p_input_bank->pp_input[0]->stream.p_selected_area->i_id - 1;
/* Disallow area 0 since it is used for video_ts.vob */
if( i_id > 0 )
{
- p_area = p_intf->p_input->stream.pp_areas[i_id];
- input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
+ 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 );
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+ input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
p_intf->p_sys->b_title_update = 1;
+ vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
GtkSetupMenus( p_intf );
+ vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
}
}
int i_id;
p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
- i_id = p_intf->p_input->stream.p_selected_area->i_id + 1;
+ i_id = p_input_bank->pp_input[0]->stream.p_selected_area->i_id + 1;
- if( i_id < p_intf->p_input->stream.i_area_nb )
+ if( i_id < p_input_bank->pp_input[0]->stream.i_area_nb )
{
- p_area = p_intf->p_input->stream.pp_areas[i_id];
- input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
+ 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 );
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+ input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
p_intf->p_sys->b_title_update = 1;
+ vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
GtkSetupMenus( p_intf );
+ vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
}
}
input_area_t * p_area;
p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
- p_area = p_intf->p_input->stream.p_selected_area;
+ p_area = p_input_bank->pp_input[0]->stream.p_selected_area;
if( p_area->i_part > 0 )
{
p_area->i_part--;
- input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
+ input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+ input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
p_intf->p_sys->b_chapter_update = 1;
+ vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
GtkSetupMenus( p_intf );
+ vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
}
}
input_area_t * p_area;
p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
- p_area = p_intf->p_input->stream.p_selected_area;
+ p_area = p_input_bank->pp_input[0]->stream.p_selected_area;
if( p_area->i_part < p_area->i_part_nb )
{
p_area->i_part++;
- input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
+ input_ChangeArea( p_input_bank->pp_input[0], (input_area_t*)p_area );
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+ input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
p_intf->p_sys->b_chapter_update = 1;
+ vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
GtkSetupMenus( p_intf );
+ vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
+ }
+}
+
+/****************************************************************************
+ * 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 ) );
+// intf_WarnMsg( 3, "intf info: joining channel %d", i_channel );
+
+// network_ChannelJoin( i_channel );
+}
+
+void GtkChannelGo( GtkButton * button, gpointer user_data )
+{
+ GtkWidget * window;
+ GtkWidget * spin;
+ int i_channel;
+
+ intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
+
+ 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 );
+
+ vlc_mutex_lock( &p_intf->change_lock );
+ if( p_input_bank->pp_input[0] != NULL )
+ {
+ /* end playing item */
+ p_input_bank->pp_input[0]->b_eof = 1;
+
+ /* 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 );
}
+
+ network_ChannelJoin( i_channel );
+
+ /* FIXME 2 */
+ p_main->p_playlist->b_stopped = 0;
+ p_intf->pf_manage( p_intf );
+
+ vlc_mutex_unlock( &p_intf->change_lock );
+
+// input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
}
+
/****************************************************************************
* About box
****************************************************************************/
i_seconds += 60 *i_minutes + 3600* i_hours;
- vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
- i_seek = i_seconds * 50 * p_intf->p_input->stream.i_mux_rate;
- i_size = p_intf->p_input->stream.p_selected_area->i_size;
- vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
+ 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 );
if( i_seek < i_size )
{
- input_Seek( p_intf->p_input, i_seek );
+ input_Seek( p_input_bank->pp_input[0], i_seek );
}
p_main->p_playlist->b_stopped = 0;
gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
{
GtkJumpShow( GTK_WIDGET( menuitem ), NULL, user_data );
}
+
+
+void GtkMessagesActivate( GtkMenuItem * menuitem, gpointer user_data )
+{
+ GtkMessagesShow( GTK_WIDGET( menuitem ), NULL, user_data );
+}
+
+
+/****************************************************************************
+ * Callbacks for disc ejection
+ ****************************************************************************/
+gboolean GtkDiscEject ( GtkWidget *widget, GdkEventButton *event,
+ gpointer user_data )
+{
+ 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", 3)
+ || strncmp(p_main->p_playlist->current.psz_name, "vcd", 3))
+ {
+ /* Determine the device name by omitting the first 4 characters */
+ psz_device = strdup((p_main->p_playlist->current.psz_name + 4));
+ }
+ }
+
+ 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;
+}
+
+void GtkEjectDiscActivate ( GtkMenuItem *menuitem, gpointer user_data )
+{
+ GtkDiscEject( GTK_WIDGET( menuitem ), NULL, user_data );
+}
+
+/****************************************************************************
+ * Messages window
+ ****************************************************************************/
+
+gboolean GtkMessagesShow( GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ static GdkColor black = { 0, 0x0000, 0x0000, 0x0000 };
+ static GdkColormap *colormap;
+ intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
+
+ gtk_widget_show( p_intf->p_sys->p_messages );
+ colormap = gdk_colormap_get_system ();
+ gdk_color_alloc( colormap, &black );
+ gdk_window_set_background( p_intf->p_sys->p_messages_text->text_area,
+ &black );
+
+ gdk_window_raise( p_intf->p_sys->p_messages->window );
+
+ gtk_text_set_point( p_intf->p_sys->p_messages_text,
+ gtk_text_get_length( p_intf->p_sys->p_messages_text ) );
+
+ 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;
+}
+
+