]> git.sesse.net Git - vlc/blobdiff - modules/gui/gtk/gtk.c
* Fix the play/pause button status
[vlc] / modules / gui / gtk / gtk.c
index 41a5ca33a2f39816d3b5eef61ec6a7c7b2ceef00..10e0114b5215fbdf79de971d0fd44c1bd0b89921 100644 (file)
@@ -2,7 +2,7 @@
  * gtk.c : Gtk+ plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: gtk.c,v 1.13 2003/01/26 22:57:21 gbazin Exp $
+ * $Id$
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -54,27 +54,34 @@ static int  Manage       ( intf_thread_t * );
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-#define TOOLTIPS_TEXT N_("show tooltips")
+#define TOOLTIPS_TEXT N_("Show tooltips")
 #define TOOLTIPS_LONGTEXT N_("Show tooltips for configuration options.")
 
-#define PREFS_MAXH_TEXT N_("maximum height for the configuration windows")
+#define PREFS_MAXH_TEXT N_("Maximum height for the configuration windows")
 #define PREFS_MAXH_LONGTEXT N_( \
     "You can set the maximum height that the configuration windows in the " \
     "preferences menu will occupy.")
 
+#define PATH_TEXT N_("Interface default search path")
+#define PATH_LONGTEXT N_( \
+    "This option allows you to set the default path that the interface will " \
+    "open when looking for a file.")
+
 vlc_module_begin();
 #ifdef WIN32
     int i = 90;
 #else
     int i = getenv( "DISPLAY" ) == NULL ? 10 : 90;
 #endif
-    add_category_hint( N_("Gtk+"), NULL );
+    set_description( _("Gtk+ interface") );
+
     add_bool( "gtk-tooltips", 1, E_(GtkHideTooltips),
-              TOOLTIPS_TEXT, TOOLTIPS_LONGTEXT );
+              TOOLTIPS_TEXT, TOOLTIPS_LONGTEXT, VLC_FALSE );
     add_integer( "gtk-prefs-maxh", 480, NULL,
-                 PREFS_MAXH_TEXT, PREFS_MAXH_LONGTEXT );
+                 PREFS_MAXH_TEXT, PREFS_MAXH_LONGTEXT, VLC_TRUE );
+    add_directory( "gtk-search-path", NULL, NULL, PATH_TEXT,
+                   PATH_LONGTEXT, VLC_TRUE );
 
-    set_description( _("Gtk+ interface module") );
     set_capability( "interface", i );
     set_callbacks( Open, Close );
     add_shortcut( "gtk" );
@@ -97,7 +104,8 @@ static int Open( vlc_object_t *p_this )
     }
 
 #ifdef NEED_GTK_MAIN
-    p_intf->p_sys->p_gtk_main = module_Need( p_this, "gtk_main", "gtk" );
+    p_intf->p_sys->p_gtk_main =
+        module_Need( p_this, "gui-helper", "gtk", VLC_TRUE );
     if( p_intf->p_sys->p_gtk_main == NULL )
     {
         free( p_intf->p_sys );
@@ -110,28 +118,28 @@ static int Open( vlc_object_t *p_this )
     p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
 
     /* Initialize Gtk+ thread */
-    p_intf->p_sys->b_playing = 0;
-    p_intf->p_sys->b_deinterlace_update = 0;
+    p_intf->p_sys->b_playing = VLC_FALSE;
+    p_intf->p_sys->b_deinterlace_update = VLC_FALSE;
 
-    p_intf->p_sys->b_aout_update = 0;
-    p_intf->p_sys->b_vout_update = 0;
+    p_intf->p_sys->b_aout_update = VLC_FALSE;
+    p_intf->p_sys->b_vout_update = VLC_FALSE;
 
-    p_intf->p_sys->b_popup_changed = 0;
-    p_intf->p_sys->b_window_changed = 0;
-    p_intf->p_sys->b_playlist_changed = 0;
-    p_intf->p_sys->b_program_update = 0;
-    p_intf->p_sys->b_title_update = 0;
-    p_intf->p_sys->b_chapter_update = 0;
-    p_intf->p_sys->b_spu_update = 0;
-    p_intf->p_sys->b_audio_update = 0;
+    p_intf->p_sys->b_popup_changed = VLC_FALSE;
+    p_intf->p_sys->b_window_changed = VLC_FALSE;
+    p_intf->p_sys->b_playlist_changed = VLC_FALSE;
+    p_intf->p_sys->b_program_update = VLC_FALSE;
+    p_intf->p_sys->b_title_update = VLC_FALSE;
+    p_intf->p_sys->b_chapter_update = VLC_FALSE;
+    p_intf->p_sys->b_spu_update = VLC_FALSE;
+    p_intf->p_sys->b_audio_update = VLC_FALSE;
 
     p_intf->p_sys->p_input = NULL;
     p_intf->p_sys->i_playing = -1;
-    p_intf->p_sys->b_slider_free = 1;
+    p_intf->p_sys->b_slider_free = VLC_TRUE;
 
     p_intf->p_sys->i_part = 0;
+    p_intf->p_sys->b_mute = VLC_FALSE;
 
-    p_intf->p_sys->b_mute = 0;
     return VLC_SUCCESS;
 }
 
@@ -180,7 +188,7 @@ static void Run( intf_thread_t *p_intf )
 #else
     /* gtk_init needs to know the command line. We don't care, so we
      * give it an empty one */
-    char  *p_args[] = { "" };
+    char  *p_args[] = { "", NULL };
     char **pp_args  = p_args;
     int    i_args   = 1;
     int    i_dummy;
@@ -258,6 +266,12 @@ static void Run( intf_thread_t *p_intf )
 
     gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_popup),
                          "p_intf", p_intf );
+    gtk_object_set_data( GTK_OBJECT( gtk_object_get_data(
+                             GTK_OBJECT(p_intf->p_sys->p_popup),
+                             "popup_audio" ) ), "p_intf", p_intf );
+    gtk_object_set_data( GTK_OBJECT( gtk_object_get_data(
+                             GTK_OBJECT(p_intf->p_sys->p_popup),
+                             "popup_video" ) ), "p_intf", p_intf );
 
     gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playwin ),
                          "p_intf", p_intf );
@@ -389,6 +403,15 @@ static int Manage( intf_thread_t *p_intf )
         p_intf->p_sys->p_sub->i_start = i_start;
         vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
 
+        /* If the messages list becomes too big, just clean half of it. */
+        if( gtk_text_get_length( p_intf->p_sys->p_messages_text ) >
+            VLC_MSG_QSIZE * 1000 )
+        {
+            gtk_text_set_point( p_intf->p_sys->p_messages_text, 0 );
+            gtk_text_forward_delete( p_intf->p_sys->p_messages_text,
+                gtk_text_get_length( p_intf->p_sys->p_messages_text ) / 2 );
+        }
+
         gtk_text_set_point( p_intf->p_sys->p_messages_text,
                     gtk_text_get_length( p_intf->p_sys->p_messages_text ) );
     }
@@ -449,14 +472,17 @@ static int Manage( intf_thread_t *p_intf )
                  * finished dragging the slider.
                  * Beware, the hack below is needed by the dvdplay plugin! */
                 else if( p_intf->p_sys->b_slider_free
-                /* hack -> */ && (p_intf->p_sys->f_adj_oldvalue <= 100.) )
+                /* hack -> */ && (p_intf->p_sys->f_adj_oldvalue < 100.) )
                 {
-                    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 );
+                    if( newvalue >= 0. && newvalue < 100. )
+                    {
+                        double f_fpos = (double)newvalue / 100.0;
+
+                        /* release the lock to be able to seek */
+                        vlc_mutex_unlock( &p_input->stream.stream_lock );
+                        var_SetFloat( p_input, "position", f_fpos );
+                        vlc_mutex_lock( &p_input->stream.stream_lock );
+                    }
 
                     /* Update the old value */
                     p_intf->p_sys->f_adj_oldvalue = newvalue;