]> git.sesse.net Git - vlc/blobdiff - modules/gui/pda/pda.c
* Makefile.am: backport of 11352.
[vlc] / modules / gui / pda / pda.c
index bc50518070db5ed98174269e8a415096fc758626..2b22903bb5f815a5084366d8849cd26263d45a73 100644 (file)
@@ -2,7 +2,7 @@
  * pda.c : PDA Gtk2 plugin for vlc
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: pda.c,v 1.20 2004/02/10 20:28:37 jpsaman Exp $
+ * $Id$
  *
  * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
  *          Marc Ariberti <marcari@videolan.org>
@@ -63,7 +63,9 @@ gint E_(GtkModeManage)   ( intf_thread_t * p_intf );
  * Module descriptor
  *****************************************************************************/
 vlc_module_begin();
-    set_description( _("PDA Linux Gtk2+ interface") );
+    set_description( N_("PDA Linux Gtk2+ interface") );
+    set_category( CAT_INTERFACE );
+    set_subcategory( SUBCAT_INTERFACE_GENERAL );
 //    add_bool( "pda-autoplayfile", 1, GtkAutoPlayFile, AUTOPLAYFILE_TEXT, AUTOPLAYFILE_LONGTEXT, VLC_TRUE );
     set_capability( "interface", 70 );
     set_callbacks( Open, Close );
@@ -87,7 +89,8 @@ static int Open( vlc_object_t *p_this )
 
 #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" );
+    p_intf->p_sys->p_gtk_main =
+        module_Need( p_this, "gui-helper", "gtk2", VLC_TRUE );
     if( p_intf->p_sys->p_gtk_main == NULL )
     {
         free( p_intf->p_sys );
@@ -214,31 +217,31 @@ static void Run( intf_thread_t *p_intf )
 
     /* Insert columns 0 */
     p_renderer = gtk_cell_renderer_text_new ();
-    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 0, _("Filename"), p_renderer, NULL);
+    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 0, (gchar *) N_("Filename"), p_renderer, NULL);
     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 0 );
     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 0 );
     gtk_tree_view_column_set_sort_column_id(p_column, 0);
     /* Insert columns 1 */
     p_renderer = gtk_cell_renderer_text_new ();
-    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 1, _("Permissions"), p_renderer, NULL);
+    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 1, (gchar *) N_("Permissions"), p_renderer, NULL);
     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 1 );
     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 1 );
     gtk_tree_view_column_set_sort_column_id(p_column, 1);
     /* Insert columns 2 */
     p_renderer = gtk_cell_renderer_text_new ();
-    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 2, _("Size"), p_renderer, NULL);
+    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 2, (gchar *) N_("Size"), p_renderer, NULL);
     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 2 );
     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 2 );
     gtk_tree_view_column_set_sort_column_id(p_column, 2);
     /* Insert columns 3 */
     p_renderer = gtk_cell_renderer_text_new ();
-    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 3, _("Owner"), p_renderer, NULL);
+    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 3, (gchar *) N_("Owner"), p_renderer, NULL);
     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 3 );
     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 3 );
     gtk_tree_view_column_set_sort_column_id(p_column, 3);
     /* Insert columns 4 */
     p_renderer = gtk_cell_renderer_text_new ();
-    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 4, _("Group"), p_renderer, NULL);
+    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 4, (gchar *) N_("Group"), p_renderer, NULL);
     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 4 );
     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 4 );
     gtk_tree_view_column_set_sort_column_id(p_column, 4);
@@ -269,20 +272,20 @@ static void Run( intf_thread_t *p_intf )
 
     /* Columns 1 */
     p_renderer = gtk_cell_renderer_text_new ();
-    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 0, _("Filename"), p_renderer, NULL);
+    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 0, (gchar *) N_("Filename"), p_renderer, NULL);
     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 0 );
     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 0 );
     gtk_tree_view_column_set_sort_column_id(p_column, 0);
     /* Column 2 */
     p_renderer = gtk_cell_renderer_text_new ();
-    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 1, _("Time"), p_renderer, NULL);
+    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 1, (gchar *) N_("Time"), p_renderer, NULL);
     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 1 );
     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 1 );
     gtk_tree_view_column_set_sort_column_id(p_column, 1);
 #if 0
     /* Column 3 - is a hidden column used for reliable deleting items from the underlying playlist */
     p_renderer = gtk_cell_renderer_text_new ();
-    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 2, _("Index"), p_renderer, NULL);
+    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 2, (gchar *) N_("Index"), p_renderer, NULL);
     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 2 );
     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 2 );
     gtk_tree_view_column_set_sort_column_id(p_column, 2);
@@ -306,6 +309,10 @@ static void Run( intf_thread_t *p_intf )
     /* END OF PLAYLIST GTK_TREE_VIEW */
 
     /* Hide the Preference TAB for now. */
+    GtkWidget *p_preference_tab = NULL;
+    p_preference_tab = gtk_notebook_get_nth_page(p_intf->p_sys->p_notebook,5);
+    if (p_preference_tab != NULL)
+      gtk_widget_hide(p_preference_tab);
 
     /* Show the control window */
     gtk_widget_show( p_intf->p_sys->p_window );
@@ -412,11 +419,9 @@ static int Manage( intf_thread_t *p_intf )
     {
         input_thread_t *p_input = p_intf->p_sys->p_input;
 
-        vlc_mutex_lock( &p_input->stream.stream_lock );
+        vlc_mutex_lock( &p_input->object_lock );
         if( !p_input->b_die )
         {
-            /* New input or stream map change */
-            if( p_input->stream.b_changed )
             {
                 playlist_t *p_playlist;
 
@@ -440,11 +445,12 @@ static int Manage( intf_thread_t *p_intf )
             }
 
             /* Manage the slider */
-#define p_area p_input->stream.p_selected_area
+#if 0
+#define p_area p_input->p_selected_area
             if (p_intf->p_libvlc->i_cpu & CPU_CAPABILITY_FPU)
             {
                 /* Manage the slider for CPU_CAPABILITY_FPU hardware */
-                if( p_input->stream.b_seekable && p_intf->p_sys->b_playing )
+                if( p_intf->p_sys->b_playing )
                 {
                     float newvalue = p_intf->p_sys->p_adj->value;
 
@@ -463,12 +469,12 @@ static int Manage( intf_thread_t *p_intf )
                      * finished dragging the slider */
                     else if( p_intf->p_sys->b_slider_free )
                     {
-                        off_t i_seek = ( newvalue * p_area->i_size ) / 100;
+                        double f_pos = (double)newvalue / 100.0;
 
                         /* 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 );
+                        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;
@@ -478,7 +484,7 @@ static int Manage( intf_thread_t *p_intf )
             else
             {
                 /* Manage the slider without CPU_CAPABILITY_FPU hardware */
-                if( p_input->stream.b_seekable && p_intf->p_sys->b_playing )
+                if( p_intf->p_sys->b_playing )
                 {
                     off_t newvalue = p_intf->p_sys->p_adj->value;
 
@@ -497,12 +503,12 @@ static int Manage( intf_thread_t *p_intf )
                      * finished dragging the slider */
                     else if( p_intf->p_sys->b_slider_free )
                     {
-                        off_t i_seek = ( newvalue * p_area->i_size ) / 100;
+                        double f_pos = (double)newvalue / 100.0;
 
                         /* 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 );
+                        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;
@@ -510,8 +516,9 @@ static int Manage( intf_thread_t *p_intf )
                 }
             }
 #undef p_area
+#endif
         }
-        vlc_mutex_unlock( &p_input->stream.stream_lock );
+        vlc_mutex_unlock( &p_input->object_lock );
     }
     else if( p_intf->p_sys->b_playing && !p_intf->b_die )
     {
@@ -553,13 +560,14 @@ void E_(GtkDisplayDate)( GtkAdjustment *p_adj, gpointer userdata )
 
     if( p_intf->p_sys->p_input )
     {
-#define p_area p_intf->p_sys->p_input->stream.p_selected_area
         char psz_time[ MSTRTIME_MAX_SIZE ];
+        int64_t i_seconds;
+
+        i_seconds = var_GetTime( p_intf->p_sys->p_input, "time" ) / I64C(1000000 );
+        secstotimestr( psz_time, i_seconds );
 
         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
+                            psz_time );
      }
 }
 
@@ -588,20 +596,13 @@ gint E_(GtkModeManage)( intf_thread_t * p_intf )
     if( p_intf->p_sys->p_input )
     {
         /* initialize and show slider for seekable streams */
-        if( p_intf->p_sys->p_input->stream.b_seekable )
         {
             gtk_widget_show( GTK_WIDGET( p_slider ) );
         }
-        else
-        {
-            /* hide slider */
-            gtk_widget_hide( GTK_WIDGET( p_slider ) );
-        }
 
         /* control buttons for free pace streams */
-        b_control = p_intf->p_sys->p_input->stream.b_pace_control;
+        b_control = p_intf->p_sys->p_input->b_can_pace_control;
 
-        p_intf->p_sys->p_input->stream.b_changed = 0;
         msg_Dbg( p_intf, "stream has changed, refreshing interface" );
     }