]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/skin_main.cpp
Remove unneeded psz_program hack.
[vlc] / modules / gui / skins2 / src / skin_main.cpp
index 91801ef391a0852e65a1eeb194006224b3285582..9f37ebaf2dbee4f83ab08a7eab37c5f1806556ff 100644 (file)
@@ -5,7 +5,7 @@
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teulière <ipkiss@via.ecp.fr>
+ *          Olivier Teulière <ipkiss@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
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#include <stdlib.h>
-#include <vlc/input.h>
+#include <vlc/vlc.h>
+#include <vlc_input.h>
+#include <vlc_demux.h>
+#include <vlc_playlist.h>
+
 #include "dialogs.hpp"
 #include "os_factory.hpp"
 #include "os_loop.hpp"
@@ -36,7 +39,7 @@
 #include "../commands/async_queue.hpp"
 #include "../commands/cmd_quit.hpp"
 #include "../commands/cmd_dialogs.hpp"
-
+#include "../commands/cmd_minimize.hpp"
 
 //---------------------------------------------------------------------------
 // Exported interface functions.
@@ -48,7 +51,7 @@ extern "C" __declspec( dllexport )
 
 
 //---------------------------------------------------------------------------
-// Local prototypes.
+// Local prototypes
 //---------------------------------------------------------------------------
 static int  Open  ( vlc_object_t * );
 static void Close ( vlc_object_t * );
@@ -58,6 +61,16 @@ static int DemuxOpen( vlc_object_t * );
 static int Demux( demux_t * );
 static int DemuxControl( demux_t *, int, va_list );
 
+//---------------------------------------------------------------------------
+// Prototypes for configuration callbacks
+//---------------------------------------------------------------------------
+static int onSystrayChange( vlc_object_t *pObj, const char *pVariable,
+                            vlc_value_t oldVal, vlc_value_t newVal,
+                            void *pParam );
+static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable,
+                            vlc_value_t oldVal, vlc_value_t newVal,
+                            void *pParam );
+
 
 //---------------------------------------------------------------------------
 // Open: initialize interface
@@ -77,7 +90,7 @@ static int Open( vlc_object_t *p_this )
     p_intf->pf_run = Run;
 
     // Suscribe to messages bank
-    p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
+    p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
 
     p_intf->p_sys->p_input = NULL;
     p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf,
@@ -109,35 +122,35 @@ static int Open( vlc_object_t *p_this )
     // Initialize singletons
     if( OSFactory::instance( p_intf ) == NULL )
     {
-        msg_Err( p_intf, "Cannot initialize OSFactory" );
+        msg_Err( p_intf, "cannot initialize OSFactory" );
         vlc_object_release( p_intf->p_sys->p_playlist );
         msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
         return VLC_EGENERIC;
     }
     if( AsyncQueue::instance( p_intf ) == NULL )
     {
-        msg_Err( p_intf, "Cannot initialize AsyncQueue" );
+        msg_Err( p_intf, "cannot initialize AsyncQueue" );
         vlc_object_release( p_intf->p_sys->p_playlist );
         msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
         return VLC_EGENERIC;
     }
     if( Interpreter::instance( p_intf ) == NULL )
     {
-        msg_Err( p_intf, "Cannot instanciate Interpreter" );
+        msg_Err( p_intf, "cannot instanciate Interpreter" );
         vlc_object_release( p_intf->p_sys->p_playlist );
         msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
         return VLC_EGENERIC;
     }
     if( VarManager::instance( p_intf ) == NULL )
     {
-        msg_Err( p_intf, "Cannot instanciate VarManager" );
+        msg_Err( p_intf, "cannot instanciate VarManager" );
         vlc_object_release( p_intf->p_sys->p_playlist );
         msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
         return VLC_EGENERIC;
     }
     if( VlcProc::instance( p_intf ) == NULL )
     {
-        msg_Err( p_intf, "Cannot initialize VLCProc" );
+        msg_Err( p_intf, "cannot initialize VLCProc" );
         vlc_object_release( p_intf->p_sys->p_playlist );
         msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
         return VLC_EGENERIC;
@@ -223,7 +236,7 @@ static void Run( intf_thread_t *p_intf )
                 AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
                 pQueue->push( CmdGenericPtr( pCmd ) );
                 msg_Err( p_intf,
-                         "Cannot show the \"open skin\" dialog: exiting...");
+                         "cannot show the \"open skin\" dialog: exiting...");
             }
         }
     }
@@ -245,8 +258,7 @@ static void Run( intf_thread_t *p_intf )
                                            FIND_ANYWHERE );
         if( p_playlist )
         {
-            p_playlist->status.i_view = -1;
-            playlist_Control( p_playlist, PLAYLIST_AUTOPLAY );
+            playlist_Control( p_playlist, PLAYLIST_AUTOPLAY, VLC_FALSE );
             vlc_object_release( p_playlist );
         }
     }
@@ -277,10 +289,10 @@ static int DemuxOpen( vlc_object_t *p_this )
     p_demux->pf_demux   = Demux;
     p_demux->pf_control = DemuxControl;
 
-    // Test that we have a valid .vlt file, based on the extension
+    // Test that we have a valid .vlt or .wsz file, based on the extension
     // TODO: an actual check of the contents would be better...
     if( ( ext = strchr( p_demux->psz_path, '.' ) ) == NULL ||
-        strcasecmp( ext, ".vlt" ) )
+        ( strcasecmp( ext, ".vlt" ) && strcasecmp( ext, ".wsz" ) ) )
     {
         return VLC_EGENERIC;
     }
@@ -298,8 +310,8 @@ static int DemuxOpen( vlc_object_t *p_this )
             if( p_playlist != NULL )
             {
                 // Make sure the item is deleted afterwards
-                p_playlist->pp_items[p_playlist->i_index]->b_autodeletion =
-                    VLC_TRUE;
+                /// \bug does not always work
+                p_playlist->status.p_item->i_flags |= PLAYLIST_REMOVE_FLAG;
                 vlc_object_release( p_playlist );
             }
 
@@ -338,37 +350,123 @@ static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
 }
 
 
+//---------------------------------------------------------------------------
+// Callbacks
+//---------------------------------------------------------------------------
+
+/// Callback for the systray configuration option
+static int onSystrayChange( vlc_object_t *pObj, const char *pVariable,
+                            vlc_value_t oldVal, vlc_value_t newVal,
+                            void *pParam )
+{
+    intf_thread_t *pIntf =
+        (intf_thread_t*)vlc_object_find( pObj, VLC_OBJECT_INTF, FIND_ANYWHERE );
+
+    if( pIntf == NULL )
+    {
+        return VLC_EGENERIC;
+    }
+
+    // Check that we found the correct interface (same check as for the demux)
+    if( var_Type( pIntf, "skin-to-load" ) == VLC_VAR_STRING )
+    {
+        AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
+        if( newVal.b_bool )
+        {
+            CmdAddInTray *pCmd = new CmdAddInTray( pIntf );
+            pQueue->push( CmdGenericPtr( pCmd ) );
+        }
+        else
+        {
+            CmdRemoveFromTray *pCmd = new CmdRemoveFromTray( pIntf );
+            pQueue->push( CmdGenericPtr( pCmd ) );
+        }
+    }
+
+    vlc_object_release( pIntf );
+    return VLC_SUCCESS;
+}
+
+
+/// Callback for the systray configuration option
+static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable,
+                            vlc_value_t oldVal, vlc_value_t newVal,
+                            void *pParam )
+{
+    intf_thread_t *pIntf =
+        (intf_thread_t*)vlc_object_find( pObj, VLC_OBJECT_INTF, FIND_ANYWHERE );
+
+    if( pIntf == NULL )
+    {
+        return VLC_EGENERIC;
+    }
+
+    // Check that we found the correct interface (same check as for the demux)
+    if( var_Type( pIntf, "skin-to-load" ) == VLC_VAR_STRING )
+    {
+        AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
+        if( newVal.b_bool )
+        {
+            CmdAddInTaskBar *pCmd = new CmdAddInTaskBar( pIntf );
+            pQueue->push( CmdGenericPtr( pCmd ) );
+        }
+        else
+        {
+            CmdRemoveFromTaskBar *pCmd = new CmdRemoveFromTaskBar( pIntf );
+            pQueue->push( CmdGenericPtr( pCmd ) );
+        }
+    }
+
+    vlc_object_release( pIntf );
+    return VLC_SUCCESS;
+}
+
+
 //---------------------------------------------------------------------------
 // Module descriptor
 //---------------------------------------------------------------------------
-#define SKINS2_LAST      N_("Last skin used")
-#define SKINS2_LAST_LONG N_("Select the path to the last skin used.")
+#define SKINS2_LAST      N_("Skin to use")
+#define SKINS2_LAST_LONG N_("Path to the skin to use.")
 #define SKINS2_CONFIG      N_("Config of last used skin")
-#define SKINS2_CONFIG_LONG N_("Config of last used skin.")
+#define SKINS2_CONFIG_LONG N_("Windows configuration of the last skin used. " \
+        "This option is updated automatically, do not touch it." )
+#define SKINS2_SYSTRAY      N_("Systray icon")
+#define SKINS2_SYSTRAY_LONG N_("Show a systray icon for VLC")
+#define SKINS2_TASKBAR      N_("Show VLC on the taskbar")
+#define SKINS2_TASKBAR_LONG N_("Show VLC on the taskbar")
 #define SKINS2_TRANSPARENCY      N_("Enable transparency effects")
 #define SKINS2_TRANSPARENCY_LONG N_("You can disable all transparency effects"\
     " if you want. This is mainly useful when moving windows does not behave" \
     " correctly.")
+#define SKINS2_PLAYLIST N_("Use a skinned playlist")
+#define SKINS2_PLAYLIST_LONG N_("Use a skinned playlist")
 
 vlc_module_begin();
     set_category( CAT_INTERFACE );
-    set_subcategory( SUBCAT_INTERFACE_GENERAL );
-    add_string( "skins2-last", "", NULL, SKINS2_LAST, SKINS2_LAST_LONG,
-                VLC_TRUE );
+    set_subcategory( SUBCAT_INTERFACE_MAIN );
+    add_file( "skins2-last", "", NULL, SKINS2_LAST, SKINS2_LAST_LONG,
+              VLC_TRUE );
         change_autosave();
     add_string( "skins2-config", "", NULL, SKINS2_CONFIG, SKINS2_CONFIG_LONG,
                 VLC_TRUE );
         change_autosave();
+        change_internal();
 #ifdef WIN32
+    add_bool( "skins2-systray", VLC_FALSE, onSystrayChange, SKINS2_SYSTRAY,
+              SKINS2_SYSTRAY_LONG, VLC_FALSE );
+    add_bool( "skins2-taskbar", VLC_TRUE, onTaskBarChange, SKINS2_TASKBAR,
+              SKINS2_TASKBAR_LONG, VLC_FALSE );
     add_bool( "skins2-transparency", VLC_FALSE, NULL, SKINS2_TRANSPARENCY,
               SKINS2_TRANSPARENCY_LONG, VLC_FALSE );
 #endif
+
+    add_bool( "skinned-playlist", VLC_TRUE, NULL, SKINS2_PLAYLIST,
+              SKINS2_PLAYLIST_LONG, VLC_FALSE );
     set_shortname( _("Skins"));
     set_description( _("Skinnable Interface") );
     set_capability( "interface", 30 );
     set_callbacks( Open, Close );
     add_shortcut( "skins" );
-    set_program( "svlc" );
 
     add_submodule();
         set_description( _("Skins loader demux") );