* gtk_callbacks.c : Callbacks for the Gtk+ plugin.
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
- * $Id: gtk_callbacks.c,v 1.12 2001/03/21 13:42:34 sam Exp $
+ * $Id: gtk_callbacks.c,v 1.41 2002/06/01 18:04:48 sam 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 <gtk/gtk.h>
+#include <vlc/vlc.h>
+#include <vlc/intf.h>
+#include <vlc/vout.h>
-#include <string.h>
+#include <unistd.h>
-#include "config.h"
-#include "common.h"
-#include "threads.h"
-#include "mtime.h"
-
-#include "stream_control.h"
-#include "input_ext-intf.h"
+#include <gtk/gtk.h>
-#include "interface.h"
-#include "intf_playlist.h"
-#include "intf_msg.h"
+#include <string.h>
#include "gtk_callbacks.h"
#include "gtk_interface.h"
#include "gtk_support.h"
-#include "intf_gtk.h"
-
-#include "main.h"
-
-/****************************************************************************
- * External function
- */
-void on_generic_drop_data_received( intf_thread_t * p_intf,
- GtkSelectionData *data, guint info, int position);
-
+#include "gtk_common.h"
+#include "netutils.h"
/*****************************************************************************
* Callbacks
- ******************************************************************************/
-void
-on_menubar_open_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
-
- /* If we have never used the file selector, open it */
- if( p_intf->p_sys->p_fileopen == NULL)
- {
- p_intf->p_sys->p_fileopen = create_intf_fileopen();
- gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
- "p_intf", p_intf );
- }
-
- gtk_widget_show( p_intf->p_sys->p_fileopen );
- gdk_window_raise( p_intf->p_sys->p_fileopen->window );
-}
+ *****************************************************************************/
+/*
+ * Main interface callbacks
+ */
-void
-on_menubar_exit_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+gboolean GtkExit( GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data )
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+ intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
vlc_mutex_lock( &p_intf->change_lock );
- p_intf->b_die = 1;
+ p_intf->p_vlc->b_die = 1;
vlc_mutex_unlock( &p_intf->change_lock );
-}
-
-void
-on_menubar_preferences_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
+ return TRUE;
}
-
-void
-on_menubar_about_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+gboolean GtkWindowDelete( GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data )
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+ GtkExit( GTK_WIDGET( widget ), NULL, user_data );
- if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
- {
- p_intf->p_sys->p_about = create_intf_about();
- gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
- "p_intf", p_intf );
- }
- gtk_widget_show( p_intf->p_sys->p_about );
- gdk_window_raise( p_intf->p_sys->p_about->window );
+ return TRUE;
}
-void
-on_toolbar_open_clicked (GtkButton *button,
- gpointer user_data)
+gboolean GtkWindowToggle( GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data )
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+ 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);
- /* If we have never used the file selector, open it */
- if( p_intf->p_sys->p_fileopen == NULL)
+ }
+ else
{
- p_intf->p_sys->p_fileopen = create_intf_fileopen();
- gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
- "p_intf", p_intf );
+ gtk_widget_show( p_intf->p_sys->p_window );
}
- gtk_widget_show( p_intf->p_sys->p_fileopen );
- gdk_window_raise( p_intf->p_sys->p_fileopen->window );
-}
-
-
-void
-on_toolbar_back_clicked (GtkButton *button,
- gpointer user_data)
-{
-
+ return TRUE;
}
-
-void
-on_toolbar_stop_clicked (GtkButton *button,
- gpointer user_data)
+gboolean GtkFullscreen( GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
{
+ intf_thread_t * p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
+ vout_thread_t *p_vout;
-}
-
-
-void
-on_toolbar_play_clicked (GtkButton *button,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+ p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_CHILD );
- if( p_intf->p_input != NULL )
+ if( p_vout )
{
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+ p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
+ vlc_object_release( p_vout );
+ return TRUE;
}
-}
-
-
-void
-on_toolbar_pause_clicked (GtkButton *button,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
- if( p_intf->p_input != NULL )
- {
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
- }
+ return FALSE;
}
-void
-on_toolbar_prev_clicked (GtkButton *button,
- gpointer user_data)
+void GtkWindowDrag( GtkWidget *widget,
+ GdkDragContext *drag_context,
+ gint x,
+ gint y,
+ GtkSelectionData *data,
+ guint info,
+ guint time,
+ gpointer user_data)
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+#if 0 /* PLAYLIST TARASS */
+ intf_thread_t * p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
+ int end = p_intf->p_vlc->p_playlist->i_size;
+ GtkDropDataReceived( p_intf, data, info, PLAYLIST_END );
- if( p_intf->p_input != NULL )
+ if( p_intf->p_sys->p_input != NULL )
{
/* FIXME: temporary hack */
- intf_PlaylistPrev( p_main->p_playlist );
- intf_PlaylistPrev( p_main->p_playlist );
- p_intf->p_input->b_eof = 1;
+ p_intf->p_sys->p_input->b_eof = 1;
}
+
+ intf_PlaylistJumpto( p_intf->p_vlc->p_playlist, end-1 );
+#endif
}
-void
-on_toolbar_next_clicked (GtkButton *button,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
-
- if( p_intf->p_input != NULL )
- {
- /* FIXME: temporary hack */
- p_intf->p_input->b_eof = 1;
- }
-}
-
+/****************************************************************************
+ * Slider management
+ ****************************************************************************/
-void
-on_popup_play_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+gboolean GtkSliderRelease( GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data )
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
-
- if( p_intf->p_input != NULL )
- {
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
- }
-}
-
+ intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
-void
-on_popup_pause_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+ vlc_mutex_lock( &p_intf->change_lock );
+ p_intf->p_sys->b_slider_free = 1;
+ vlc_mutex_unlock( &p_intf->change_lock );
- if( p_intf->p_input != NULL )
- {
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
- }
+ return FALSE;
}
-void
-on_popup_exit_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+gboolean GtkSliderPress( GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+ intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
vlc_mutex_lock( &p_intf->change_lock );
- p_intf->b_die = 1;
+ p_intf->p_sys->b_slider_free = 0;
vlc_mutex_unlock( &p_intf->change_lock );
-}
-
-void
-on_fileopen_ok_clicked (GtkButton *button,
- gpointer user_data)
-{
- GtkWidget *filesel;
- gchar *filename;
-
- filesel = gtk_widget_get_toplevel (GTK_WIDGET (button));
- gtk_widget_hide (filesel);
- filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
- intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
+ return FALSE;
}
-void
-on_fileopen_cancel_clicked (GtkButton *button,
- gpointer user_data)
-{
- gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
-}
-
+/****************************************************************************
+ * DVD specific items
+ ****************************************************************************/
-void
-on_intf_fileopen_destroy (GtkObject *object,
- gpointer user_data)
+void GtkTitlePrev( GtkButton * button, gpointer user_data )
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_fileopen" );
+ intf_thread_t * p_intf;
+ input_area_t * p_area;
+ int i_id;
- p_intf->p_sys->p_fileopen = NULL;
-}
+ p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
+ i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id - 1;
-void
-on_popup_open_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
-
- /* If we have never used the file selector, open it */
- if( p_intf->p_sys->p_fileopen == NULL)
+ /* Disallow area 0 since it is used for video_ts.vob */
+ if( i_id > 0 )
{
- p_intf->p_sys->p_fileopen = create_intf_fileopen();
- gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_fileopen ),
- "p_intf", p_intf );
- }
-
- gtk_widget_show( p_intf->p_sys->p_fileopen );
- gdk_window_raise( p_intf->p_sys->p_fileopen->window );
-}
+ p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id];
+ input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );
+ input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
-void
-on_popup_about_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
-
- if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
- {
- p_intf->p_sys->p_about = create_intf_about();
- gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
- "p_intf", p_intf );
+ p_intf->p_sys->b_title_update = 1;
+ vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+ GtkSetupMenus( p_intf );
+ vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
}
- gtk_widget_show( p_intf->p_sys->p_about );
- gdk_window_raise( p_intf->p_sys->p_about->window );
-}
-void
-on_popup_slow_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
- if( p_intf->p_input != NULL )
- {
- input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
- }
+ vlc_object_release( p_intf->p_sys->p_input );
}
-void
-on_popup_fast_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+void GtkTitleNext( GtkButton * button, gpointer user_data )
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
-
- if( p_intf->p_input != NULL )
- {
- input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
- }
-}
+ intf_thread_t * p_intf;
+ input_area_t * p_area;
+ int i_id;
+ p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
+ i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id + 1;
-void
-on_toolbar_slow_clicked (GtkButton *button,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
-
- if( p_intf->p_input != NULL )
+ if( i_id < p_intf->p_sys->p_input->stream.i_area_nb )
{
- input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
- }
-}
-
+ p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id];
+ input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );
-void
-on_toolbar_fast_clicked (GtkButton *button,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+ input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
- if( p_intf->p_input != NULL )
- {
- input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
+ p_intf->p_sys->b_title_update = 1;
+ vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+ GtkSetupMenus( p_intf );
+ vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
}
-}
-
-
-void
-on_intf_modules_destroy (GtkObject *object,
- gpointer user_data)
-{
}
-void
-on_modules_ok_clicked (GtkButton *button,
- gpointer user_data)
+void GtkChapterPrev( GtkButton * button, gpointer user_data )
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
-
- gtk_widget_hide( p_intf->p_sys->p_modules );
+ intf_thread_t * p_intf;
+ input_area_t * p_area;
-}
+ p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
+ p_area = p_intf->p_sys->p_input->stream.p_selected_area;
+ if( p_area->i_part > 0 )
+ {
+ p_area->i_part--;
+ input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );
-void
-on_modules_apply_clicked (GtkButton *button,
- gpointer user_data)
-{
+ input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
+ p_intf->p_sys->b_chapter_update = 1;
+ vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+ GtkSetupMenus( p_intf );
+ vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+ }
}
-void
-on_modules_cancel_clicked (GtkButton *button,
- gpointer user_data)
+void GtkChapterNext( GtkButton * button, gpointer user_data )
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_modules" );
-
- gtk_widget_hide( p_intf->p_sys->p_modules );
-}
+ intf_thread_t * p_intf;
+ input_area_t * p_area;
-void
-on_menubar_modules_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+ p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
+ p_area = p_intf->p_sys->p_input->stream.p_selected_area;
- if( !GTK_IS_WIDGET( p_intf->p_sys->p_modules ) )
+ if( p_area->i_part < p_area->i_part_nb )
{
-// p_intf->p_sys->p_modules = create_intf_modules();
- gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_modules ),
- "p_intf", p_intf );
- }
- gtk_widget_show( p_intf->p_sys->p_modules );
- gdk_window_raise( p_intf->p_sys->p_modules->window );
-}
+ p_area->i_part++;
+ input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );
+ input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
-void
-on_intf_window_drag_data_received (GtkWidget *widget,
- GdkDragContext *drag_context,
- gint x,
- gint y,
- GtkSelectionData *data,
- guint info,
- guint time,
- gpointer user_data)
-{
- intf_thread_t * p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
- int end = p_main->p_playlist->i_size;
- on_generic_drop_data_received( p_intf, data, info, PLAYLIST_END);
-
- if( p_intf->p_input != NULL )
- {
- /* FIXME: temporary hack */
- p_intf->p_input->b_eof = 1;
- }
-
- intf_PlaylistJumpto( p_main->p_playlist, end-1 );
-
+ p_intf->p_sys->b_chapter_update = 1;
+ vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+ GtkSetupMenus( p_intf );
+ vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+ }
}
-
-void
-on_about_ok_clicked (GtkButton *button,
- gpointer user_data)
+/****************************************************************************
+ * Network specific items
+ ****************************************************************************/
+void GtkNetworkJoin( GtkEditable * editable, gpointer user_data )
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_about" );
+ int i_channel;
- gtk_widget_hide( p_intf->p_sys->p_about );
-}
+ i_channel = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( editable ) );
+// msg_Dbg( "intf info: joining channel %d", i_channel );
+// network_ChannelJoin( i_channel );
+}
-void
-on_menubar_disc_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+void GtkChannelGo( GtkButton * button, gpointer user_data )
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+ GtkWidget * window;
+ GtkWidget * spin;
+ int i_channel;
- if( !GTK_IS_WIDGET( p_intf->p_sys->p_disc ) )
- {
- p_intf->p_sys->p_disc = create_intf_disc();
- gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_disc ),
- "p_intf", p_intf );
- }
- gtk_widget_show( p_intf->p_sys->p_disc );
- gdk_window_raise( p_intf->p_sys->p_disc->window );
-}
+ 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" ) );
-void
-on_toolbar_disc_clicked (GtkButton *button,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+ i_channel = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( spin ) );
+ msg_Dbg( p_intf, "joining channel %d", i_channel );
- if( !GTK_IS_WIDGET( p_intf->p_sys->p_disc ) )
+ vlc_mutex_lock( &p_intf->change_lock );
+ if( p_intf->p_sys->p_input != NULL )
{
- p_intf->p_sys->p_disc = create_intf_disc();
- gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_disc ),
- "p_intf", p_intf );
- }
- gtk_widget_show( p_intf->p_sys->p_disc );
- gdk_window_raise( p_intf->p_sys->p_disc->window );
-}
-
+ /* end playing item */
+ p_intf->p_sys->p_input->b_eof = 1;
-void
-on_disc_ok_clicked (GtkButton *button,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
- char *psz_device, *psz_source, *psz_method;
+#if 0 /* PLAYLIST TARASS */
+ /* update playlist */
+ vlc_mutex_lock( &p_intf->p_vlc->p_playlist->change_lock );
- psz_device = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
- GTK_WIDGET(button), "disc_name" ) ) );
+ p_intf->p_vlc->p_playlist->i_index--;
+ p_intf->p_vlc->p_playlist->b_stopped = 1;
- /* "dvd:foo" has size 5 + strlen(foo) */
- psz_source = malloc( 5 + strlen( psz_device ) );
- if( psz_source == NULL )
- {
- return;
+ vlc_mutex_unlock( &p_intf->p_vlc->p_playlist->change_lock );
+#endif
}
- /* Check which method was activated */
- if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
- "disc_dvd" ) )->active )
- {
- psz_method = "dvd";
- }
- else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
- "disc_vcd" ) )->active )
- {
- psz_method = "vcd";
- }
- else
- {
- intf_ErrMsg( "intf error: unknown toggle button configuration" );
- free( psz_source );
- return;
- }
-
- /* Select title and chapter */
- main_PutIntVariable( INPUT_TITLE_VAR, gtk_spin_button_get_value_as_int(
- GTK_SPIN_BUTTON( lookup_widget(
- GTK_WIDGET(button), "disc_title" ) ) ) );
+ network_ChannelJoin( p_intf, i_channel );
- main_PutIntVariable( INPUT_CHAPTER_VAR, gtk_spin_button_get_value_as_int(
- GTK_SPIN_BUTTON( lookup_widget(
- GTK_WIDGET(button), "disc_chapter" ) ) ) );
+ /* FIXME 2 */
+#if 0 /* PLAYLIST TARASS */
+ p_intf->p_vlc->p_playlist->b_stopped = 0;
+#endif
- /* Build source name and add it to playlist */
- sprintf( psz_source, "%s:%s", psz_method, psz_device );
- intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
+ vlc_mutex_unlock( &p_intf->change_lock );
- gtk_widget_hide( p_intf->p_sys->p_disc );
+// input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
}
-void
-on_disc_cancel_clicked (GtkButton *button,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_disc" );
-
- gtk_widget_hide( p_intf->p_sys->p_disc );
-}
-
+/****************************************************************************
+ * About box
+ ****************************************************************************/
-void
-on_disc_dvd_toggled (GtkToggleButton *togglebutton,
- gpointer user_data)
+gboolean GtkAboutShow( GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
{
- if( togglebutton->active )
+ intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
+
+ if( !GTK_IS_WIDGET( p_intf->p_sys->p_about ) )
{
- gtk_entry_set_text( GTK_ENTRY( lookup_widget(
- GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/dvd" );
+ p_intf->p_sys->p_about = create_intf_about();
+ gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_about ),
+ "p_intf", p_intf );
}
-}
+ gtk_widget_show( p_intf->p_sys->p_about );
+ gdk_window_raise( p_intf->p_sys->p_about->window );
+ return TRUE;
+}
-void
-on_disc_vcd_toggled (GtkToggleButton *togglebutton,
- gpointer user_data)
+void GtkAboutOk( GtkButton * button, gpointer user_data)
{
- if( togglebutton->active )
- {
- gtk_entry_set_text( GTK_ENTRY( lookup_widget(
- GTK_WIDGET(togglebutton), "disc_name" ) ), "/dev/cdrom" );
- }
+ intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
+
+ gtk_widget_hide( p_intf->p_sys->p_about );
}
-void
-on_popup_disc_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+/****************************************************************************
+ * Jump box
+ ****************************************************************************/
+
+gboolean GtkJumpShow( GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+ intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
- if( !GTK_IS_WIDGET( p_intf->p_sys->p_disc ) )
+ if( !GTK_IS_WIDGET( p_intf->p_sys->p_jump ) )
{
- p_intf->p_sys->p_disc = create_intf_disc();
- gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_disc ),
+ p_intf->p_sys->p_jump = create_intf_jump();
+ gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_jump ),
"p_intf", p_intf );
}
- gtk_widget_show( p_intf->p_sys->p_disc );
- gdk_window_raise( p_intf->p_sys->p_disc->window );
-}
-
-void
-on_popup_audio_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
- es_descriptor_t * p_es;
- p_es = (es_descriptor_t*)user_data;
+ gtk_widget_show( p_intf->p_sys->p_jump );
+ gdk_window_raise( p_intf->p_sys->p_jump->window );
- input_ChangeES( p_intf->p_input, p_es, 1 );
+ return FALSE;
}
-void
-on_popup_subpictures_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+void GtkJumpOk( GtkButton *button,
+ gpointer user_data)
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
- es_descriptor_t * p_es;
+ intf_thread_t * p_intf = GetIntf( GTK_WIDGET( button ), (char*)user_data );
+ int i_hours, i_minutes, i_seconds;
- p_es = (es_descriptor_t*)user_data;
+#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 ) ) )
+ i_hours = GET_VALUE( "jump_hour_spinbutton" );
+ i_minutes = GET_VALUE( "jump_minute_spinbutton" );
+ i_seconds = GET_VALUE( "jump_second_spinbutton" );
+#undef GET_VALUE
- input_ChangeES( p_intf->p_input, p_es, 2 );
-}
+ input_Seek( p_intf, i_seconds + 60 * i_minutes + 3600 * i_hours,
+ INPUT_SEEK_SECONDS | INPUT_SEEK_SET );
-
-void
-on_menubar_audio_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
- es_descriptor_t * p_es;
-
- p_es = (es_descriptor_t*)user_data;
-
- input_ChangeES( p_intf->p_input, p_es, 1 );
+#if 0 /* PLAYLIST TARASS */
+ p_intf->p_vlc->p_playlist->b_stopped = 0;
+#endif
+ gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
}
-void
-on_menubar_subpictures_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+void GtkJumpCancel( GtkButton *button,
+ gpointer user_data)
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
- es_descriptor_t * p_es;
-
- p_es = (es_descriptor_t*)user_data;
-
- input_ChangeES( p_intf->p_input, p_es, 2 );
+ gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
}
-void
-on_popup_navigation_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+/****************************************************************************
+ * Callbacks for menuitems
+ ****************************************************************************/
+void GtkExitActivate( GtkMenuItem * menuitem, gpointer user_data )
{
- intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
- input_area_t * p_area;
- gint i_title;
- gint i_chapter;
-
- i_title = (gint)(user_data) / 100 ;
- i_chapter = (gint)(user_data) - ( 100 * i_title );
- p_area = p_intf->p_input->stream.pp_areas[i_title];
- p_area->i_part = i_chapter;
-
- p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+ GtkExit( GTK_WIDGET( menuitem ), NULL, user_data );
}
-void
-on_menubar_title_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+void GtkFullscreenActivate( GtkMenuItem * menuitem, gpointer user_data )
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
-
- p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)user_data );
- p_intf->p_sys->b_menus_update = 1;
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+ GtkFullscreen( GTK_WIDGET( menuitem ), NULL, user_data );
}
-void
-on_menubar_chapter_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+void GtkWindowToggleActivate( GtkMenuItem * menuitem, gpointer user_data )
{
- intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
- input_area_t * p_area = p_intf->p_input->stream.p_selected_area;
- gint i_chapter = (gint)user_data;
-
- p_area->i_part = i_chapter;
-
- p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
- input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+ GtkWindowToggle( GTK_WIDGET( menuitem ), NULL, user_data );
}
-gboolean
-on_intf_window_destroy (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
-
- vlc_mutex_lock( &p_intf->change_lock );
- p_intf->b_die = 1;
- vlc_mutex_unlock( &p_intf->change_lock );
- return TRUE;
-}
-
-
-void
-on_main_window_toggle (GtkMenuItem *menuitem,
- gpointer user_data)
+void GtkAboutActivate( GtkMenuItem * menuitem, gpointer user_data )
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
-
- if( GTK_WIDGET_VISIBLE(p_intf->p_sys->p_window) ) {
- gtk_widget_hide( p_intf->p_sys->p_window);
-
- }
- else
- {
- gtk_widget_show( p_intf->p_sys->p_window );
- }
+ GtkAboutShow( GTK_WIDGET( menuitem ), NULL, user_data );
}
-gboolean
-on_playlist_clist_drag_motion (GtkWidget *widget,
- GdkDragContext *drag_context,
- gint x,
- gint y,
- guint time,
- gpointer user_data)
+void GtkJumpActivate( GtkMenuItem * menuitem, gpointer user_data )
{
- GtkCList * clist;
- gint row,col;
- int dummy;
- GdkColor color;
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_playlist" );
-
-
- clist = GTK_CLIST(lookup_widget( p_intf->p_sys->p_playlist,"playlist_clist"
- ));
-
- if(!GTK_WIDGET_TOPLEVEL(widget))
- {
- gdk_window_raise( p_intf->p_sys->p_playlist->window );
- }
-
- color.red = 0xffff;
- color.green = 0xffff;
- color.blue = 0xffff;
-
- gtk_clist_freeze( clist );
-
- for(dummy=0; dummy<clist->rows; dummy++)
- {
- gtk_clist_set_background ( clist, dummy , &color);
- }
- color.red = 0xffff;
- color.green = 0;
- color.blue = 0;
- gtk_clist_set_background ( clist, p_main->p_playlist->i_index , &color);
-
- if( gtk_clist_get_selection_info( clist,x,y ,&row,&col )== 1)
- {
- color.red = 0;
- color.green = 0x9000;
- color.blue = 0xf000;
- gtk_clist_set_background ( clist, row-1 , &color);
- gtk_clist_set_background ( clist, row , &color);
- }
-
- gtk_clist_thaw( clist );
-
- return TRUE;
+ GtkJumpShow( GTK_WIDGET( menuitem ), NULL, user_data );
}
-void
-on_intf_network_destroy (GtkObject *object,
- gpointer user_data)
+void GtkMessagesActivate( GtkMenuItem * menuitem, gpointer user_data )
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(object), "intf_network" );
-
- p_intf->p_sys->p_network = NULL;
+ GtkMessagesShow( GTK_WIDGET( menuitem ), NULL, user_data );
}
-void
-on_network_ok_clicked (GtkButton *button,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_network" );
- char *psz_source, *psz_server, *psz_protocol;
- unsigned int i_port;
-
- psz_server = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
- GTK_WIDGET(button), "network_server" ) ) );
-
- /* Check which protocol was activated */
- if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
- "network_ts" ) )->active )
- {
- psz_protocol = "ts";
- }
- else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
- "network_rtp" ) )->active )
- {
- psz_protocol = "rtp";
- }
- else
- {
- intf_ErrMsg( "intf error: unknown protocol toggle button position" );
- return;
- }
-
- /* Get the port number and make sure it will not overflow 5 characters */
- i_port = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(
- lookup_widget( GTK_WIDGET(button), "network_port" ) ) );
- if( i_port > 65535 )
- {
- intf_ErrMsg( "intf error: invalid port %i", i_port );
- }
-
- /* Allocate room for "protocol://server:port" */
- psz_source = malloc( strlen( psz_protocol ) + strlen( psz_server ) + 10 );
- if( psz_source == NULL )
- {
- return;
- }
-
- /* Build source name and add it to playlist */
- sprintf( psz_source, "%s://%s:%i", psz_protocol, psz_server, i_port );
- intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
- free( psz_source );
-
- gtk_widget_hide( p_intf->p_sys->p_network );
+/****************************************************************************
+ * Callbacks for disc ejection
+ ****************************************************************************/
+gboolean GtkDiscEject ( GtkWidget *widget, GdkEventButton *event,
+ gpointer user_data )
+{
+#if 0 /* PLAYLIST TARASS */
+ intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
+
+ char *psz_device = NULL;
+ char *psz_parser;
+ char *psz_current = p_intf->p_vlc->p_playlist->current.psz_name;
+
+ /*
+ * 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( psz_current != NULL )
+ {
+ if( !strncmp(psz_current, "dvd:", 4) )
+ {
+ switch( psz_current[4] )
+ {
+ case '\0':
+ case '@':
+ psz_device = config_GetPsz( p_intf, "dvd" );
+ break;
+ default:
+ /* Omit the first 4 characters */
+ psz_device = strdup( psz_current + 4 );
+ break;
+ }
+ }
+ else if( !strncmp(psz_current, "vcd:", 4) )
+ {
+ switch( psz_current[4] )
+ {
+ case '\0':
+ case '@':
+ psz_device = config_GetPsz( p_intf, "vcd" );
+ break;
+ default:
+ /* Omit the first 4 characters */
+ psz_device = strdup( psz_current + 4 );
+ break;
+ }
+ }
+ else
+ {
+ psz_device = strdup( psz_current );
+ }
+ }
+
+ if( psz_device == NULL )
+ {
+ return TRUE;
+ }
+
+ /* Remove what we have after @ */
+ psz_parser = psz_device;
+ for( psz_parser = psz_device ; *psz_parser ; psz_parser++ )
+ {
+ if( *psz_parser == '@' )
+ {
+ *psz_parser = '\0';
+ break;
+ }
+ }
+
+ /* If there's a stream playing, we aren't allowed to eject ! */
+ if( p_intf->p_sys->p_input == NULL )
+ {
+ msg_Dbg( p_intf, "ejecting %s", psz_device );
+
+ intf_Eject( p_intf, psz_device );
+ }
+
+ free(psz_device);
+#endif
+ return TRUE;
}
-
-void
-on_network_cancel_clicked (GtkButton *button,
- gpointer user_data)
+void GtkEjectDiscActivate ( GtkMenuItem *menuitem, gpointer user_data )
{
- gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
+ GtkDiscEject( GTK_WIDGET( menuitem ), NULL, user_data );
}
+/****************************************************************************
+ * Messages window
+ ****************************************************************************/
-void
-on_menubar_network_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+gboolean GtkMessagesShow( GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
-
- gtk_widget_show( p_intf->p_sys->p_network );
- gdk_window_raise( p_intf->p_sys->p_network->window );
-}
-
+ static GdkColor black = { 0, 0x0000, 0x0000, 0x0000 };
+ static GdkColormap *colormap;
+ intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
-void
-on_popup_network_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+ 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 );
- gtk_widget_show( p_intf->p_sys->p_network );
- gdk_window_raise( p_intf->p_sys->p_network->window );
-}
+ gdk_window_raise( p_intf->p_sys->p_messages->window );
-void
-on_toolbar_network_clicked (GtkButton *button,
- gpointer user_data)
-{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+ gtk_text_set_point( p_intf->p_sys->p_messages_text,
+ gtk_text_get_length( p_intf->p_sys->p_messages_text ) );
- gtk_widget_show( p_intf->p_sys->p_network );
- gdk_window_raise( p_intf->p_sys->p_network->window );
+ return TRUE;
}
-gboolean
-on_slider_button_release_event (GtkWidget *widget,
- GdkEventButton *event,
+void
+GtkMessagesOk (GtkButton *button,
gpointer user_data)
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
-
- vlc_mutex_lock( &p_intf->change_lock );
- p_intf->p_sys->b_slider_free = 1;
- vlc_mutex_unlock( &p_intf->change_lock );
-
- return FALSE;
+ intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), (char*)user_data );
+ gtk_widget_hide( p_intf->p_sys->p_messages );
}
gboolean
-on_slider_button_press_event (GtkWidget *widget,
- GdkEventButton *event,
+GtkMessagesDelete (GtkWidget *widget,
+ GdkEvent *event,
gpointer user_data)
{
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), "intf_window" );
-
- vlc_mutex_lock( &p_intf->change_lock );
- p_intf->p_sys->b_slider_free = 0;
- vlc_mutex_unlock( &p_intf->change_lock );
-
- return FALSE;
+ intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
+ gtk_widget_hide( p_intf->p_sys->p_messages );
+ return TRUE;
}