]> git.sesse.net Git - vlc/blobdiff - plugins/gnome/gnome_callbacks.c
* Mandatory step for video output IV and the audio output quality
[vlc] / plugins / gnome / gnome_callbacks.c
index e727f93fa5b705bd96f2a8c5e60ae9c6335f8a69..e3f6a635bb0e6c485262136cf38ff75ef67e551a 100644 (file)
@@ -2,9 +2,10 @@
  * gnome_callbacks.c : Callbacks for the Gnome plugin.
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: gnome_callbacks.c,v 1.18 2001/03/21 13:42:34 sam Exp $
+ * $Id: gnome_callbacks.c,v 1.25 2001/05/01 04:18:18 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
+ *          Stéphane Borel <stef@via.ecp.fr>
  *      
  * 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
@@ -159,6 +160,96 @@ on_intf_window_drag_data_received      (GtkWidget       *widget,
 }
 
 
+void
+on_button_title_prev_clicked           (GtkButton       *button,
+                                        gpointer         user_data)
+{
+    intf_thread_t * p_intf;
+    input_area_t *  p_area;
+    int             i_id;
+
+    p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+    i_id = p_intf->p_input->stream.p_selected_area->i_id - 1;
+
+    if( i_id >= 0 )
+    {
+        p_area = p_intf->p_input->stream.pp_areas[i_id];
+        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 );
+
+        p_intf->p_sys->b_title_update = 1;
+    }
+}
+
+
+void
+on_button_title_next_clicked           (GtkButton       *button,
+                                        gpointer         user_data)
+{
+    intf_thread_t * p_intf;
+    input_area_t *  p_area;
+    int             i_id;
+
+    p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+    i_id = p_intf->p_input->stream.p_selected_area->i_id + 1;
+
+    if( i_id < p_intf->p_input->stream.i_area_nb )
+    {
+        p_area = p_intf->p_input->stream.pp_areas[i_id];   
+        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 );
+
+        p_intf->p_sys->b_title_update = 1;
+    }
+}
+
+
+void
+on_button_chapter_prev_clicked         (GtkButton       *button,
+                                        gpointer         user_data)
+{
+    intf_thread_t * p_intf;
+    input_area_t *  p_area;
+
+    p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+    p_area = p_intf->p_input->stream.p_selected_area;
+
+    if( p_area->i_part > 0 )
+    {
+        p_area->i_part--;
+        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 );
+
+        p_intf->p_sys->b_chapter_update = 1;
+    }
+}
+
+
+void
+on_button_chapter_next_clicked         (GtkButton       *button,
+                                        gpointer         user_data)
+{
+    intf_thread_t * p_intf;
+    input_area_t *  p_area;
+
+    p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+    p_area = p_intf->p_input->stream.p_selected_area;
+
+    if( p_area->i_part < p_area->i_part_nb )
+    {
+        p_area->i_part++;
+        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 );
+
+        p_intf->p_sys->b_chapter_update = 1;
+    }
+}
+
+
 /*****************************************************************************
  * Menubar callbacks
  *****************************************************************************
@@ -239,12 +330,19 @@ void
 on_menubar_audio_toggle                (GtkCheckMenuItem     *menuitem,
                                         gpointer              user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+    intf_thread_t *         p_intf;
     es_descriptor_t *       p_es;
 
-    p_es = (es_descriptor_t*)user_data;
+    p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
 
-    input_ChangeES( p_intf->p_input, p_es, 1 );
+    if( !p_intf->p_sys->b_audio_update )
+    {
+        p_es = (es_descriptor_t*)user_data;
+
+        input_ToggleES( p_intf->p_input, p_es, menuitem->active );
+
+        p_intf->p_sys->b_audio_update = menuitem->active;
+    }
 }
 
 
@@ -252,12 +350,19 @@ void
 on_menubar_subtitle_toggle             (GtkCheckMenuItem     *menuitem,
                                         gpointer              user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+    intf_thread_t *         p_intf;
     es_descriptor_t *       p_es;
 
-    p_es = (es_descriptor_t*)user_data;
+    p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+
+    if( !p_intf->p_sys->b_spu_update )
+    {
+        p_es = (es_descriptor_t*)user_data;
 
-    input_ChangeES( p_intf->p_input, p_es, 2 );
+        input_ToggleES( p_intf->p_input, p_es, menuitem->active );
+
+        p_intf->p_sys->b_spu_update = menuitem->active;
+    }
 }
 
 
@@ -265,11 +370,17 @@ void
 on_menubar_title_toggle                (GtkCheckMenuItem     *menuitem,
                                         gpointer              user_data)
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+    intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
+
+    if( menuitem->active && !p_intf->p_sys->b_title_update )
+    {
+        p_intf->p_input->pf_set_area( p_intf->p_input,
+                                     (input_area_t*)user_data );
 
-    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 );
+        input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+
+        p_intf->p_sys->b_title_update = 1;
+    }
 }
 
 
@@ -280,13 +391,42 @@ on_menubar_chapter_toggle              (GtkCheckMenuItem     *menuitem,
     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;
+    char            psz_chapter[3];
 
-    p_area->i_part = i_chapter;
+    if( menuitem->active && !p_intf->p_sys->b_chapter_update )
+    {
+        p_area->i_part = i_chapter;
+        p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
+
+        snprintf( psz_chapter, 3, "%02d", p_area->i_part );
+        gtk_label_set_text( p_intf->p_sys->p_label_chapter, psz_chapter );
+
+        input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
+
+        p_intf->p_sys->b_chapter_update = 1;
+    }
 
-    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 );
 }
 
+
+void
+on_menubar_angle_toggle                (GtkCheckMenuItem     *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_angle   = (gint)user_data;
+
+    if( menuitem->active && !p_intf->p_sys->b_angle_update )
+    {
+        p_area->i_angle = i_angle;
+        p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
+
+        p_intf->p_sys->b_angle_update = 1;
+    }
+}
+
+
 void
 on_menubar_modules_activate            (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
@@ -474,6 +614,8 @@ on_toolbar_prev_clicked                (GtkButton       *button,
         intf_PlaylistPrev( p_main->p_playlist );
         p_intf->p_input->b_eof = 1;
     }
+
+    p_intf->p_sys->b_mode_changed = 1;
 }
 
 
@@ -488,6 +630,8 @@ on_toolbar_next_clicked                (GtkButton       *button,
         /* FIXME: temporary hack */
         p_intf->p_input->b_eof = 1;
     }
+
+    p_intf->p_sys->b_mode_changed = 1;
 }
 
 
@@ -558,7 +702,12 @@ on_popup_audio_toggle                  (GtkCheckMenuItem     *menuitem,
 
     p_es = (es_descriptor_t*)user_data;
 
-    input_ChangeES( p_intf->p_input, p_es, 1 );
+    if( !p_intf->p_sys->b_audio_update )
+    {
+        input_ToggleES( p_intf->p_input, p_es, menuitem->active );
+
+        p_intf->p_sys->b_audio_update = menuitem->active;
+    }
 }
 
 
@@ -571,7 +720,12 @@ on_popup_subtitle_toggle            (GtkCheckMenuItem     *menuitem,
 
     p_es = (es_descriptor_t*)user_data;
 
-    input_ChangeES( p_intf->p_input, p_es, 2 );
+    if( !p_intf->p_sys->b_spu_update )
+    {
+        input_ToggleES( p_intf->p_input, p_es, menuitem->active );
+
+        p_intf->p_sys->b_spu_update = menuitem->active;
+    }
 }
 
 
@@ -579,26 +733,51 @@ void
 on_popup_navigation_toggle             (GtkCheckMenuItem     *menuitem,
                                         gpointer             user_data)
 {
-    if( menuitem->active )
+    intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+
+    if( menuitem->active &&
+        !p_intf->p_sys->b_title_update &&
+        !p_intf->p_sys->b_chapter_update )
     {
-        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_title   = (gint)(user_data) / 100;
         i_chapter = (gint)(user_data) - ( 100 * i_title );
+        p_area = p_intf->p_input->stream.p_selected_area;
 
-        if( i_title != p_intf->p_input->stream.p_selected_area->i_id )
+
+        if( p_area != p_intf->p_input->stream.pp_areas[i_title] )
         {
-            p_intf->p_sys->b_menus_update = 1;
+            p_area = p_intf->p_input->stream.pp_areas[i_title];
+            p_intf->p_sys->b_title_update = 1;
         }
 
-        p_area = p_intf->p_input->stream.pp_areas[i_title];
         p_area->i_part = i_chapter;
+        p_intf->p_sys->b_chapter_update = 1;
+
+        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 );
+    }
+}
+
+
+void
+on_popup_angle_toggle                  (GtkCheckMenuItem     *menuitem,
+                                        gpointer             user_data)
+{
+    intf_thread_t * p_intf    = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
+    input_area_t *  p_area    = p_intf->p_input->stream.p_selected_area;
+    gint            i_angle   = (gint)user_data;
 
+    if( menuitem->active && !p_intf->p_sys->b_angle_update )
+    {
+        p_area->i_angle = i_angle;
         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 );
+
+        p_intf->p_sys->b_angle_update = 1;
     }
 }
 
@@ -692,6 +871,8 @@ void
 on_fileopen_ok_clicked                 (GtkButton       *button,
                                         gpointer         user_data)
 {
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_fileopen" );
+
     GtkWidget *filesel;
     gchar *filename;
 
@@ -700,6 +881,12 @@ on_fileopen_ok_clicked                 (GtkButton       *button,
     filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
 
     intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, (char*)filename );
+
+    /* Select added item and switch to file interface */
+    if( p_intf->p_input != NULL )
+        p_intf->p_input->b_eof = 1;
+
+//    p_intf->p_sys->b_mode_changed = 1;
 }
 
 
@@ -824,7 +1011,8 @@ on_disc_ok_clicked                     (GtkButton       *button,
                                          GTK_WIDGET(button), "disc_name" ) ) );
 
     /* "dvd:foo" has size 5 + strlen(foo) */
-    psz_source = malloc( 5 + strlen( psz_device ) );
+    psz_source = malloc( 3 /* "dvd" */ + 1 /* ":" */
+                           + strlen( psz_device ) + 1 /* "\0" */ );
     if( psz_source == NULL )
     {
         return;
@@ -835,6 +1023,7 @@ on_disc_ok_clicked                     (GtkButton       *button,
                                           "disc_dvd" ) )->active )
     {
         psz_method = "dvd";
+        p_intf->p_sys->i_intf_mode = DVD_MODE;
     }
     else if( GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button),
                                                "disc_vcd" ) )->active )
@@ -862,6 +1051,12 @@ on_disc_ok_clicked                     (GtkButton       *button,
     intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
     free( psz_source );
 
+    /* Select added item and switch to DVD interface */
+    intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
+    if( p_intf->p_input != NULL )
+        p_intf->p_input->b_eof = 1;
+//    p_intf->p_sys->b_mode_changed = 1;
+
     gtk_widget_hide( p_intf->p_sys->p_disc );
 }
 
@@ -916,7 +1111,9 @@ on_network_ok_clicked                  (GtkButton       *button,
     }
 
     /* Allocate room for "protocol://server:port" */
-    psz_source = malloc( strlen( psz_protocol ) + strlen( psz_server ) + 10 );
+    psz_source = malloc( strlen( psz_protocol ) + 3 /* "://" */
+                           + strlen( psz_server ) + 1 /* ":" */
+                           + 5 /* 0-65535 */ + 1 /* "\0" */ );
     if( psz_source == NULL )
     {
         return;
@@ -927,6 +1124,12 @@ on_network_ok_clicked                  (GtkButton       *button,
     intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_source );
     free( psz_source );
 
+    /* Select added item and switch to network interface */
+    intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
+    if( p_intf->p_input != NULL )
+        p_intf->p_input->b_eof = 1;
+//    p_intf->p_sys->b_mode_changed = 1;
+
     gtk_widget_hide( p_intf->p_sys->p_network );
 }