X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fgui%2Fpda%2Fpda.c;h=2b74125970b4cfd0019d2b28bc1e1fe33a3f4d61;hb=e982566383a3045d27adc7e5d526c0ffdb2bb0bf;hp=07d92328b34f06799e7d6fc4bfba6436585dc7c0;hpb=449fd28aaf007c6411251dae9d0dbfdc65b135d1;p=vlc diff --git a/modules/gui/pda/pda.c b/modules/gui/pda/pda.c index 07d92328b3..2b74125970 100644 --- a/modules/gui/pda/pda.c +++ b/modules/gui/pda/pda.c @@ -31,7 +31,8 @@ # include "config.h" #endif -#include +#include +#include #include #include #include @@ -50,10 +51,9 @@ static int Open ( vlc_object_t * ); static void Close ( vlc_object_t * ); 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, gpointer userdata ); -gint E_(GtkModeManage) ( intf_thread_t * p_intf ); +void GtkDisplayDate ( GtkAdjustment *p_adj, gpointer userdata ); +gint GtkModeManage ( intf_thread_t * p_intf ); /***************************************************************************** * Module descriptor @@ -65,15 +65,14 @@ gint E_(GtkModeManage) ( intf_thread_t * p_intf ); /***************************************************************************** * Module descriptor *****************************************************************************/ -vlc_module_begin(); - set_description( _("PDA Linux Gtk2+ interface") ); - set_category( CAT_INTERFACE ); - set_subcategory( SUBCAT_INTERFACE_MAIN ); -// add_bool( "pda-autoplayfile", 1, GtkAutoPlayFile, AUTOPLAYFILE_TEXT, AUTOPLAYFILE_LONGTEXT, true ); - set_capability( "interface", 70 ); - set_callbacks( Open, Close ); - add_shortcut( "pda" ); -vlc_module_end(); +vlc_module_begin () + set_description( N_("PDA Linux Gtk2+ interface") ) + set_category( CAT_INTERFACE ) + set_subcategory( SUBCAT_INTERFACE_MAIN ) + set_capability( "interface", 0 ) + set_callbacks( Open, Close ) + add_shortcut( "pda" ) +vlc_module_end () /***************************************************************************** * Open: initialize and create window @@ -85,15 +84,12 @@ static int Open( vlc_object_t *p_this ) /* Allocate instance and initialize some members */ p_intf->p_sys = malloc( sizeof( intf_sys_t ) ); if( p_intf->p_sys == NULL ) - { - msg_Err( p_intf, "out of memory" ); return VLC_ENOMEM; - } #ifdef NEED_GTK2_MAIN msg_Dbg( p_intf, "Using gui-helper" ); p_intf->p_sys->p_gtk_main = - module_Need( p_this, "gui-helper", "gtk2", true ); + module_need( p_this, "gui-helper", "gtk2", true ); if( p_intf->p_sys->p_gtk_main == NULL ) { free( p_intf->p_sys ); @@ -127,7 +123,7 @@ static void Close( vlc_object_t *p_this ) #ifdef NEED_GTK2_MAIN msg_Dbg( p_intf, "Releasing gui-helper" ); - module_Unneed( p_intf, p_intf->p_sys->p_gtk_main ); + module_unneed( p_intf, p_intf->p_sys->p_gtk_main ); #endif /* Destroy structure */ @@ -155,6 +151,7 @@ static void Run( intf_thread_t *p_intf ) GtkTreeViewColumn *p_column = NULL; GtkListStore *p_filelist = NULL; GtkListStore *p_playlist_store = NULL; + int canc = vlc_savecancel(); #ifndef NEED_GTK2_MAIN gtk_set_locale (); @@ -167,14 +164,7 @@ static void Run( intf_thread_t *p_intf ) #endif /* Create some useful widgets that will certainly be used */ -/* FIXME: magic path */ - add_pixmap_directory("share"); - add_pixmap_directory("/usr/share/vlc"); - - /* Path for pixmaps under linupy 1.4 */ - add_pixmap_directory("/usr/local/share/pixmaps/vlc"); - /* Path for pixmaps under linupy 2.0 */ - add_pixmap_directory("/usr/share/pixmaps/vlc"); + add_pixmap_directory(config_GetDataDir()); p_intf->p_sys->p_window = create_pda(); if (p_intf->p_sys->p_window == NULL) @@ -207,7 +197,7 @@ static void Run( intf_thread_t *p_intf ) if (p_intf->p_sys->p_adj == NULL) msg_Err( p_intf, "Adjustment range not found." ); g_signal_connect( GTK_OBJECT( p_intf->p_sys->p_adj ), "value_changed", - G_CALLBACK( E_(GtkDisplayDate) ), p_intf ); + G_CALLBACK( GtkDisplayDate ), p_intf ); p_intf->p_sys->f_adj_oldvalue = 0; p_intf->p_sys->i_adj_oldvalue = 0; @@ -256,7 +246,7 @@ static void Run( intf_thread_t *p_intf ) G_TYPE_UINT64, /* File size */ G_TYPE_STRING, /* Owner */ G_TYPE_STRING);/* Group */ - ReadDirectory(p_intf, p_filelist, "."); + ReadDirectory(p_intf, p_filelist, (char*)"."); gtk_tree_view_set_model(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile), GTK_TREE_MODEL(p_filelist)); g_object_unref(p_filelist); /* Model will be released by GtkTreeView */ gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile)),GTK_SELECTION_MULTIPLE); @@ -294,7 +284,7 @@ static void Run( intf_thread_t *p_intf ) gtk_tree_view_column_set_sort_column_id(p_column, 2); #endif /* update the playlist */ - p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); + p_playlist = pl_Hold( p_intf ); p_playlist_store = gtk_list_store_new (3, G_TYPE_STRING, /* Filename */ G_TYPE_STRING, /* Time */ @@ -302,7 +292,7 @@ static void Run( intf_thread_t *p_intf ) PlaylistRebuildListStore(p_intf,p_playlist_store, p_playlist); gtk_tree_view_set_model(GTK_TREE_VIEW(p_intf->p_sys->p_tvplaylist), GTK_TREE_MODEL(p_playlist_store)); g_object_unref(p_playlist_store); - vlc_object_release(p_playlist); /* Free the playlist */ + pl_Release( p_intf ); /* Free the playlist */ gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvplaylist)),GTK_SELECTION_MULTIPLE); /* Column properties */ @@ -322,7 +312,7 @@ static void Run( intf_thread_t *p_intf ) #ifdef NEED_GTK2_MAIN msg_Dbg( p_intf, "Manage GTK keyboard events using threads" ); - while( !intf_ShouldDie( p_intf ) ) + while( vlc_object_alive( p_intf ) ) { Manage( p_intf ); @@ -354,43 +344,7 @@ static void Run( intf_thread_t *p_intf ) #ifdef NEED_GTK2_MAIN gdk_threads_leave(); #endif -} - -/***************************************************************************** - * GtkAutoplayFile: Autoplay file depending on configuration settings - *****************************************************************************/ -void GtkAutoPlayFile( vlc_object_t *p_this ) -{ - GtkWidget *cbautoplay; - intf_thread_t *p_intf; - int i_index; - vlc_list_t *p_list = vlc_list_find( p_this, VLC_OBJECT_INTF, - FIND_ANYWHERE ); - - for( i_index = 0; i_index < p_list->i_count; i_index++ ) - { - p_intf = (intf_thread_t *)p_list->p_values[i_index].p_object ; - - if( strcmp( MODULE_STRING, module_GetObjName(p_intf->p_module) ) ) - { - continue; - } - cbautoplay = GTK_WIDGET( gtk_object_get_data( - GTK_OBJECT( p_intf->p_sys->p_window ), - "cbautoplay" ) ); - - if( !config_GetInt( p_this, "pda-autoplayfile" ) ) - { - p_intf->p_sys->b_autoplayfile = false; - } - else - { - p_intf->p_sys->b_autoplayfile = true; - } - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( cbautoplay ), - p_intf->p_sys->b_autoplayfile ); - } - vlc_list_release( p_list ); + vlc_restorecancel(canc); } /* following functions are local */ @@ -404,7 +358,6 @@ void GtkAutoPlayFile( vlc_object_t *p_this ) static int Manage( intf_thread_t *p_intf ) { GtkListStore *p_liststore; - vlc_mutex_lock( &p_intf->change_lock ); /* Update the input */ if( p_intf->p_sys->p_input == NULL ) @@ -423,17 +376,15 @@ static int Manage( intf_thread_t *p_intf ) input_thread_t *p_input = p_intf->p_sys->p_input; int64_t i_time = 0, i_length = 0; - vlc_mutex_lock( &p_input->object_lock ); - if( !p_input->b_die ) + if( vlc_object_alive (p_input) ) { playlist_t *p_playlist; - E_(GtkModeManage)( p_intf ); + GtkModeManage( p_intf ); p_intf->p_sys->b_playing = 1; /* update playlist interface */ - p_playlist = (playlist_t *) vlc_object_find( - p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); + p_playlist = pl_Hold( p_intf ); if (p_playlist != NULL) { p_liststore = gtk_list_store_new (3, @@ -443,7 +394,7 @@ static int Manage( intf_thread_t *p_intf ) PlaylistRebuildListStore(p_intf, p_liststore, p_playlist); gtk_tree_view_set_model(p_intf->p_sys->p_tvplaylist, (GtkTreeModel*) p_liststore); g_object_unref(p_liststore); - vlc_object_release( p_playlist ); + pl_Release( p_intf ); } /* Manage the slider */ @@ -475,9 +426,7 @@ static int Manage( intf_thread_t *p_intf ) double f_pos = (double)newvalue / 100.0; /* release the lock to be able to seek */ - vlc_mutex_unlock( &p_input->object_lock ); var_SetFloat( p_input, "position", f_pos ); - vlc_mutex_lock( &p_input->object_lock ); /* Update the old value */ p_intf->p_sys->f_adj_oldvalue = newvalue; @@ -509,9 +458,7 @@ static int Manage( intf_thread_t *p_intf ) double f_pos = (double)newvalue / 100.0; /* release the lock to be able to seek */ - vlc_mutex_unlock( &p_input->object_lock ); var_SetFloat( p_input, "position", f_pos ); - vlc_mutex_lock( &p_input->object_lock ); /* Update the old value */ p_intf->p_sys->i_adj_oldvalue = newvalue; @@ -519,19 +466,16 @@ static int Manage( intf_thread_t *p_intf ) } } } - vlc_mutex_unlock( &p_input->object_lock ); } - else if( p_intf->p_sys->b_playing && !intf_ShouldDie( p_intf ) ) + else if( p_intf->p_sys->b_playing && vlc_object_alive( p_intf ) ) { - E_(GtkModeManage)( p_intf ); + GtkModeManage( p_intf ); p_intf->p_sys->b_playing = 0; } #ifndef NEED_GTK2_MAIN - if( intf_ShouldDie( p_intf ) ) + if( !vlc_object_alive( p_intf ) ) { - vlc_mutex_unlock( &p_intf->change_lock ); - /* Prepare to die, young Skywalker */ gtk_main_quit(); @@ -539,8 +483,6 @@ static int Manage( intf_thread_t *p_intf ) } #endif - vlc_mutex_unlock( &p_intf->change_lock ); - return TRUE; } @@ -551,8 +493,10 @@ static int Manage( intf_thread_t *p_intf ) * 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, gpointer userdata ) +void GtkDisplayDate( GtkAdjustment *p_adj, gpointer userdata ) { + (void)p_adj; + intf_thread_t *p_intf; p_intf = (intf_thread_t*) userdata; @@ -564,7 +508,7 @@ void E_(GtkDisplayDate)( GtkAdjustment *p_adj, gpointer userdata ) char psz_time[ MSTRTIME_MAX_SIZE ]; int64_t i_seconds; - i_seconds = var_GetTime( p_intf->p_sys->p_input, "time" ) / I64C(1000000 ); + i_seconds = var_GetTime( p_intf->p_sys->p_input, "time" ) / INT64_C(1000000 ); secstotimestr( psz_time, i_seconds ); gtk_label_set_text( GTK_LABEL( p_intf->p_sys->p_slider_label ), @@ -578,7 +522,7 @@ void E_(GtkDisplayDate)( GtkAdjustment *p_adj, gpointer userdata ) ***************************************************************************** * The lock has to be taken before you call the function. *****************************************************************************/ -gint E_(GtkModeManage)( intf_thread_t * p_intf ) +gint GtkModeManage( intf_thread_t * p_intf ) { GtkWidget * p_slider = NULL; bool b_control; @@ -602,7 +546,7 @@ gint E_(GtkModeManage)( intf_thread_t * p_intf ) } /* control buttons for free pace streams */ - b_control = p_intf->p_sys->p_input->b_can_pace_control; + b_control = var_GetBool( p_intf->p_sys->p_input, "can-rate" ); msg_Dbg( p_intf, "stream has changed, refreshing interface" ); }