Commit 10c935ba authored by Jean-Paul Saman's avatar Jean-Paul Saman
Browse files

Slider functionality for Familiar interface.

parent 1be74338
......@@ -2,7 +2,7 @@
* callbacks.c : Callbacks for the Familiar Linux Gtk+ plugin.
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: callbacks.c,v 1.19 2002/12/22 21:46:50 jpsaman Exp $
* $Id: callbacks.c,v 1.20 2003/01/03 20:55:00 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -497,3 +497,34 @@ on_familiar_delete_event (GtkWidget *widget,
return TRUE;
}
/* Slider Management */
gboolean
FamiliarSliderRelease (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data)
{
intf_thread_t *p_intf = GtkGetIntf( widget );
vlc_mutex_lock( &p_intf->change_lock );
p_intf->p_sys->b_slider_free = 1;
vlc_mutex_unlock( &p_intf->change_lock );
return FALSE;
}
gboolean
FamiliarSliderPress (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data)
{
intf_thread_t *p_intf = GtkGetIntf( widget );
vlc_mutex_lock( &p_intf->change_lock );
p_intf->p_sys->b_slider_free = 0;
vlc_mutex_unlock( &p_intf->change_lock );
return FALSE;
}
......@@ -2,7 +2,7 @@
* callbacks.h : familiar plugin for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: callbacks.h,v 1.7 2002/09/30 11:05:38 sam Exp $
* $Id: callbacks.h,v 1.8 2003/01/03 20:55:00 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -85,3 +85,13 @@ gboolean
on_familiar_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
gboolean
FamiliarSliderRelease (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
gboolean
FamiliarSliderPress (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
......@@ -2,7 +2,7 @@
* familiar.c : familiar plugin for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: familiar.c,v 1.21 2002/12/22 23:23:45 jpsaman Exp $
* $Id: familiar.c,v 1.22 2003/01/03 20:55:00 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -52,6 +52,8 @@ static void Run ( intf_thread_t * );
void GtkAutoPlayFile ( vlc_object_t * );
static int Manage ( intf_thread_t *p_intf );
void E_(GtkDisplayDate) ( GtkAdjustment *p_adj );
gint E_(GtkModeManage) ( intf_thread_t * p_intf );
/*****************************************************************************
* Module descriptor
......@@ -100,6 +102,9 @@ static int Open( vlc_object_t *p_this )
p_intf->p_sys->p_input = NULL;
p_intf->p_sys->b_autoplayfile = 1;
p_intf->p_sys->b_playing = 0;
p_intf->p_sys->b_slider_free = 1;
p_intf->pf_run = Run;
return VLC_SUCCESS;
......@@ -178,9 +183,21 @@ static void Run( intf_thread_t *p_intf )
p_intf->p_sys->p_notebook = GTK_NOTEBOOK( gtk_object_get_data(
GTK_OBJECT( p_intf->p_sys->p_window ), "notebook" ) );
p_intf->p_sys->p_progess = GTK_PROGRESS_BAR( gtk_object_get_data(
GTK_OBJECT( p_intf->p_sys->p_window ), "progress" ) );
gtk_widget_hide( GTK_WIDGET(p_intf->p_sys->p_progess) );
/* Get the slider object */
p_intf->p_sys->p_slider = GTK_HSCALE( gtk_object_get_data(
GTK_OBJECT( p_intf->p_sys->p_window ), "slider" ) );
p_intf->p_sys->p_slider_label = GTK_LABEL( gtk_object_get_data(
GTK_OBJECT( p_intf->p_sys->p_window ), "slider_label" ) );
/* Connect the date display to the slider */
#define P_SLIDER GTK_RANGE( gtk_object_get_data( \
GTK_OBJECT( p_intf->p_sys->p_window ), "slider" ) )
p_intf->p_sys->p_adj = gtk_range_get_adjustment( P_SLIDER );
gtk_signal_connect ( GTK_OBJECT( p_intf->p_sys->p_adj ), "value_changed",
GTK_SIGNAL_FUNC( E_(GtkDisplayDate) ), NULL );
p_intf->p_sys->f_adj_oldvalue = 0;
#undef P_SLIDER
p_intf->p_sys->p_clist = GTK_CLIST( gtk_object_get_data(
GTK_OBJECT( p_intf->p_sys->p_window ), "clistmedia" ) );
......@@ -192,6 +209,9 @@ static void Run( intf_thread_t *p_intf )
/* Store p_intf to keep an eye on it */
gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_window),
"p_intf", p_intf );
gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_adj),
"p_intf", p_intf );
/* Show the control window */
gtk_widget_show( p_intf->p_sys->p_window );
ReadDirectory(p_intf->p_sys->p_clist, "/mnt");
......@@ -212,8 +232,7 @@ static void Run( intf_thread_t *p_intf )
msg_Dbg( p_intf, "Manage GTK keyboard events using timeouts" );
/* Sleep to avoid using all CPU - since some interfaces needs to access
* keyboard events, a 100ms delay is a good compromise */
i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, (GtkFunction)Manage,
p_intf );
i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, (GtkFunction)Manage, p_intf );
/* Enter Gtk mode */
gtk_main();
......@@ -222,7 +241,6 @@ static void Run( intf_thread_t *p_intf )
#endif
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_window) );
#ifdef NEED_GTK_MAIN
gdk_threads_leave();
#else
......@@ -238,8 +256,7 @@ void GtkAutoPlayFile( vlc_object_t *p_this )
GtkWidget *cbautoplay;
intf_thread_t *p_intf;
int i_index;
vlc_list_t list = vlc_list_find( p_this, VLC_OBJECT_INTF,
FIND_ANYWHERE );
vlc_list_t list = vlc_list_find( p_this, VLC_OBJECT_INTF, FIND_ANYWHERE );
for( i_index = 0; i_index < list.i_count; i_index++ )
{
......@@ -249,7 +266,6 @@ void GtkAutoPlayFile( vlc_object_t *p_this )
{
continue;
}
cbautoplay = GTK_WIDGET( gtk_object_get_data(
GTK_OBJECT( p_intf->p_sys->p_window ),
"cbautoplay" ) );
......@@ -262,11 +278,9 @@ void GtkAutoPlayFile( vlc_object_t *p_this )
{
p_intf->p_sys->b_autoplayfile = VLC_TRUE;
}
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( cbautoplay ),
p_intf->p_sys->b_autoplayfile );
}
vlc_list_release( &list );
}
......@@ -294,6 +308,63 @@ static int Manage( intf_thread_t *p_intf )
p_intf->p_sys->p_input = NULL;
}
if( p_intf->p_sys->p_input )
{
input_thread_t *p_input = p_intf->p_sys->p_input;
vlc_mutex_lock( &p_input->stream.stream_lock );
if( !p_input->b_die )
{
/* New input or stream map change */
if( p_input->stream.b_changed )
{
E_(GtkModeManage)( p_intf );
p_intf->p_sys->b_playing = 1;
}
/* Manage the slider */
if( p_input->stream.b_seekable && p_intf->p_sys->b_playing )
{
float newvalue = p_intf->p_sys->p_adj->value;
#define p_area p_input->stream.p_selected_area
/* If the user hasn't touched the slider since the last time,
* then the input can safely change it */
if( newvalue == p_intf->p_sys->f_adj_oldvalue )
{
/* Update the value */
p_intf->p_sys->p_adj->value =
p_intf->p_sys->f_adj_oldvalue =
( 100. * p_area->i_tell ) / p_area->i_size;
gtk_signal_emit_by_name( GTK_OBJECT( p_intf->p_sys->p_adj ),
"value_changed" );
}
/* Otherwise, send message to the input if the user has
* finished dragging the slider */
else if( p_intf->p_sys->b_slider_free )
{
off_t i_seek = ( newvalue * p_area->i_size ) / 100;
/* release the lock to be able to seek */
vlc_mutex_unlock( &p_input->stream.stream_lock );
input_Seek( p_input, i_seek, INPUT_SEEK_SET );
vlc_mutex_lock( &p_input->stream.stream_lock );
/* Update the old value */
p_intf->p_sys->f_adj_oldvalue = newvalue;
}
#undef p_area
}
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
else if( p_intf->p_sys->b_playing && !p_intf->b_die )
{
E_(GtkModeManage)( p_intf );
p_intf->p_sys->b_playing = 0;
}
#ifndef NEED_GTK_MAIN
if( p_intf->b_die )
{
......@@ -310,3 +381,78 @@ static int Manage( intf_thread_t *p_intf )
return TRUE;
}
/*****************************************************************************
* GtkDisplayDate: display stream date
*****************************************************************************
* This function displays the current date related to the position in
* the stream. It is called whenever the slider changes its value.
* The lock has to be taken before you call the function.
*****************************************************************************/
void E_(GtkDisplayDate)( GtkAdjustment *p_adj )
{
intf_thread_t *p_intf;
p_intf = gtk_object_get_data( GTK_OBJECT( p_adj ), "p_intf" );
if( p_intf->p_sys->p_input )
{
#define p_area p_intf->p_sys->p_input->stream.p_selected_area
char psz_time[ OFFSETTOTIME_MAX_SIZE ];
gtk_label_set_text( GTK_LABEL( p_intf->p_sys->p_slider_label ),
input_OffsetToTime( p_intf->p_sys->p_input, psz_time,
( p_area->i_size * p_adj->value ) / 100 ) );
#undef p_area
}
}
/*****************************************************************************
* GtkModeManage: actualize the aspect of the interface whenever the input
* changes.
*****************************************************************************
* The lock has to be taken before you call the function.
*****************************************************************************/
gint E_(GtkModeManage)( intf_thread_t * p_intf )
{
GtkWidget * p_slider;
vlc_bool_t b_control;
#define GETWIDGET( ptr, name ) GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( \
p_intf->p_sys->ptr ) , ( name ) ) )
/* hide slider */
p_slider = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_window ), "slider" ) );
gtk_widget_hide( GTK_WIDGET( p_slider ) );
/* controls unavailable */
b_control = 0;
/* show the box related to current input mode */
if( p_intf->p_sys->p_input )
{
/* initialize and show slider for seekable streams */
if( p_intf->p_sys->p_input->stream.b_seekable )
{
p_intf->p_sys->p_adj->value = p_intf->p_sys->f_adj_oldvalue = 0;
gtk_signal_emit_by_name( GTK_OBJECT( p_intf->p_sys->p_adj ),
"value_changed" );
gtk_widget_show( GTK_WIDGET( p_slider ) );
}
/* control buttons for free pace streams */
b_control = p_intf->p_sys->p_input->stream.b_pace_control;
p_intf->p_sys->p_input->stream.b_changed = 0;
msg_Dbg( p_intf, "stream has changed, refreshing interface" );
}
/* set control items */
gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_rewind"), b_control );
gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_pause"), b_control );
gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_forward"), b_control );
#undef GETWIDGET
return TRUE;
}
......@@ -173,24 +173,50 @@
<new_group>True</new_group>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>slider_label</name>
<label>0:00:00</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<new_group>True</new_group>
</child>
</widget>
</widget>
<widget>
<class>GtkProgressBar</class>
<name>progress</name>
<class>GtkHScale</class>
<name>slider</name>
<can_focus>True</can_focus>
<signal>
<name>button_release_event</name>
<handler>FamiliarSliderRelease</handler>
<last_modification_time>Fri, 03 Jan 2003 12:33:38 GMT</last_modification_time>
</signal>
<signal>
<name>button_press_event</name>
<handler>FamiliarSliderPress</handler>
<last_modification_time>Fri, 03 Jan 2003 12:33:54 GMT</last_modification_time>
</signal>
<draw_value>False</draw_value>
<value_pos>GTK_POS_RIGHT</value_pos>
<digits>3</digits>
<policy>GTK_UPDATE_CONTINUOUS</policy>
<value>0</value>
<lower>0</lower>
<upper>100</upper>
<bar_style>GTK_PROGRESS_CONTINUOUS</bar_style>
<orientation>GTK_PROGRESS_LEFT_TO_RIGHT</orientation>
<activity_mode>True</activity_mode>
<show_text>False</show_text>
<format>%P %%</format>
<text_xalign>0.5</text_xalign>
<text_yalign>0.5</text_yalign>
<step>1</step>
<page>6.25</page>
<page_size>0</page_size>
<child>
<padding>0</padding>
<expand>False</expand>
<expand>True</expand>
<fill>False</fill>
</child>
</widget>
......@@ -232,42 +258,6 @@
<ypad>0</ypad>
</widget>
<widget>
<class>GtkCombo</class>
<name>comboURL</name>
<x>40</x>
<y>4</y>
<width>185</width>
<height>24</height>
<value_in_list>False</value_in_list>
<ok_if_empty>True</ok_if_empty>
<case_sensitive>False</case_sensitive>
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items>file://
ftp://
http://
udp://:1234
udpstream://@:1234
</items>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>comboURL-entry</name>
<can_focus>True</can_focus>
<signal>
<name>changed</name>
<handler>on_comboURL-entry_changed</handler>
<last_modification_time>Thu, 01 Aug 2002 19:37:06 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text>file://</text>
</widget>
</widget>
<widget>
<class>GtkScrolledWindow</class>
<name>scrolledwindow1</name>
......@@ -366,6 +356,44 @@ udpstream://@:1234
</widget>
</widget>
</widget>
<widget>
<class>GtkCombo</class>
<name>comboURL</name>
<x>40</x>
<y>4</y>
<width>185</width>
<height>24</height>
<value_in_list>False</value_in_list>
<ok_if_empty>True</ok_if_empty>
<case_sensitive>False</case_sensitive>
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items>file://
ftp://
http://
udp://:1234
udp6://:1234
rtp://:1234
rtp6://:1234
</items>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>comboURL-entry</name>
<can_focus>True</can_focus>
<signal>
<name>changed</name>
<handler>on_comboURL-entry_changed</handler>
<last_modification_time>Thu, 01 Aug 2002 19:37:06 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text>file://</text>
</widget>
</widget>
</widget>
<widget>
......
......@@ -2,7 +2,7 @@
* familiar.h: private Gtk+ interface description
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: familiar.h,v 1.9 2002/12/16 22:06:59 jpsaman Exp $
* $Id: familiar.h,v 1.10 2003/01/03 20:55:01 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -34,13 +34,22 @@ struct intf_sys_t
/* windows and widgets */
GtkWidget * p_window; /* main window */
GtkNotebook * p_notebook;
GtkProgressBar * p_progess;
// GtkWidget * p_notebook_about;
// GtkWidget * p_notebook_open;
// GtkWidget * p_notebook_preferences;
GtkHScale * p_slider;
GtkCList * p_clist;
/* slider */
GtkLabel * p_slider_label;
GtkAdjustment * p_adj; /* slider adjustment object */
float f_adj_oldvalue; /* previous value */
/* special actions */
vlc_bool_t b_playing;
vlc_bool_t b_window_changed; /* window display toggled ? */
vlc_bool_t b_slider_free; /* slider status */
/* Preference settings */
vlc_bool_t b_autoplayfile;
/* The input thread */
input_thread_t * p_input;
};
......
......@@ -33,13 +33,11 @@ create_familiar (void)
GtkWidget *toolbar_stop;
GtkWidget *toolbar_forward;
GtkWidget *toolbar_about;
GtkWidget *progress;
GtkWidget *slider_label;
GtkWidget *slider;
GtkWidget *notebook;
GtkWidget *fixedMedia;
GtkWidget *labelUrl;
GtkWidget *comboURL;
GList *comboURL_items = NULL;
GtkWidget *comboURL_entry;
GtkWidget *scrolledwindow1;
GtkWidget *clistmedia;
GtkWidget *labelname;
......@@ -47,6 +45,9 @@ create_familiar (void)
GtkWidget *labelsize;
GtkWidget *labeluid;
GtkWidget *labelgid;
GtkWidget *comboURL;
GList *comboURL_items = NULL;
GtkWidget *comboURL_entry;
GtkWidget *media;
GtkWidget *fixedPreferences;
GtkWidget *buttonSave;
......@@ -194,14 +195,26 @@ create_familiar (void)
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (toolbar_about);
progress = gtk_progress_bar_new ();
gtk_widget_set_name (progress, "progress");
gtk_widget_ref (progress);
gtk_object_set_data_full (GTK_OBJECT (familiar), "progress", progress,
slider_label = gtk_label_new (_("0:00:00"));
gtk_widget_set_name (slider_label, "slider_label");
gtk_widget_ref (slider_label);
gtk_object_set_data_full (GTK_OBJECT (familiar), "slider_label", slider_label,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (slider_label);
gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
gtk_toolbar_append_widget (GTK_TOOLBAR (toolbar), slider_label, NULL, NULL);
slider = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 100, 1, 6.25, 0)));
gtk_widget_set_name (slider, "slider");
gtk_widget_ref (slider);
gtk_object_set_data_full (GTK_OBJECT (familiar), "slider", slider,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (progress);
gtk_box_pack_start (GTK_BOX (vbox), progress, FALSE, FALSE, 0);
gtk_progress_set_activity_mode (GTK_PROGRESS (progress), TRUE);
gtk_widget_show (slider);
gtk_box_pack_start (GTK_BOX (vbox), slider, TRUE, FALSE, 0);
gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE);
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_RIGHT);
gtk_scale_set_digits (GTK_SCALE (slider), 3);
notebook = gtk_notebook_new ();
gtk_widget_set_name (notebook, "notebook");
......@@ -229,31 +242,6 @@ create_familiar (void)
gtk_widget_set_uposition (labelUrl, 4, 8);
gtk_widget_set_usize (labelUrl, 38, 18);
comboURL = gtk_combo_new ();
gtk_widget_set_name (comboURL, "comboURL");
gtk_widget_ref (comboURL);
gtk_object_set_data_full (GTK_OBJECT (familiar), "comboURL", comboURL,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (comboURL);
gtk_fixed_put (GTK_FIXED (fixedMedia), comboURL, 40, 4);
gtk_widget_set_uposition (comboURL, 40, 4);
gtk_widget_set_usize (comboURL, 185, 24);
comboURL_items = g_list_append (comboURL_items, (gpointer) _("file://"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("ftp://"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("http://"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("udp://:1234"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("udpstream://@:1234"));
gtk_combo_set_popdown_strings (GTK_COMBO (comboURL), comboURL_items);
g_list_free (comboURL_items);
comboURL_entry = GTK_COMBO (comboURL)->entry;
gtk_widget_set_name (comboURL_entry, "comboURL_entry");
gtk_widget_ref (comboURL_entry);
gtk_object_set_data_full (GTK_OBJECT (familiar), "comboURL_entry", comboURL_entry,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (comboURL_entry);
gtk_entry_set_text (GTK_ENTRY (comboURL_entry), _("file://"));
scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_name (scrolledwindow1, "scrolledwindow1");
gtk_widget_ref (scrolledwindow1);
......@@ -318,6 +306,33 @@ create_familiar (void)
gtk_widget_show (labelgid);
gtk_clist_set_column_widget (GTK_CLIST (clistmedia), 4, labelgid);
comboURL = gtk_combo_new ();
gtk_widget_set_name (comboURL, "comboURL");
gtk_widget_ref (comboURL);
gtk_object_set_data_full (GTK_OBJECT (familiar), "comboURL", comboURL,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (comboURL);
gtk_fixed_put (GTK_FIXED (fixedMedia), comboURL, 40, 4);
gtk_widget_set_uposition (comboURL, 40, 4);
gtk_widget_set_usize (comboURL, 185, 24);
comboURL_items = g_list_append (comboURL_items, (gpointer) _("file://"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("ftp://"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("http://"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("udp://:1234"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("udp6://:1234"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("rtp://:1234"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("rtp6://:1234"));
gtk_combo_set_popdown_strings (GTK_COMBO (comboURL), comboURL_items);
g_list_free (comboURL_items);
comboURL_entry = GTK_COMBO (comboURL)->entry;
gtk_widget_set_name (comboURL_entry, "comboURL_entry");
gtk_widget_ref (comboURL_entry);
gtk_object_set_data_full (GTK_OBJECT (familiar), "comboURL_entry", comboURL_entry,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (comboURL_entry);
gtk_entry_set_text (GTK_ENTRY (comboURL_entry), _("file://"));