]> git.sesse.net Git - vlc/commitdiff
Activate 2 more one instance mode optins with DBus
authorAntoine Cellerier <dionoea@videolan.org>
Sat, 13 Sep 2008 22:34:09 +0000 (00:34 +0200)
committerAntoine Cellerier <dionoea@videolan.org>
Sat, 13 Sep 2008 22:36:09 +0000 (00:36 +0200)
Now that we have a one instance mode with DBus under linux, also make
it possible to use the "one-instance-when-started-from-file" and
"started-from-file" options.
Consider using --started-from-file in the file association scripts,
like what we do in the win32 NSIS script, so that all files opened
through the GUI are enqueued/played in the same instance.

src/libvlc-module.c
src/libvlc.c

index 285d1d502c2b3b68acd1dd17bc47c687a0146552..464239cb0cf535f41989bd15d89fbf04030f07e1 100644 (file)
@@ -1067,16 +1067,16 @@ static const char *const ppsz_clock_descriptions[] =
 #define SYSLOG_LONGTEXT N_( \
     "Log all VLC messages to syslog (UNIX systems)." )
 
-#define ONEINSTANCE_WIN_TEXT N_("Allow only one running instance")
-#define ONEINSTANCE_WIN_LONGTEXT N_( \
+#define ONEINSTANCE_TEXT N_("Allow only one running instance")
+#if defined( WIN32 )
+#define ONEINSTANCE_LONGTEXT N_( \
     "Allowing only one running instance of VLC can sometimes be useful, " \
     "for example if you associated VLC with some media types and you " \
     "don't want a new instance of VLC to be opened each time you " \
     "double-click on a file in the explorer. This option will allow you " \
     "to play the file with the already running instance or enqueue it.")
-
-#define ONEINSTANCE_DBUS_TEXT ONEINSTANCE_WIN_TEXT
-#define ONEINSTANCE_DBUS_LONGTEXT N_( \
+#elif defined( HAVE_DBUS )
+#define ONEINSTANCE_LONGTEXT N_( \
     "Allowing only one running instance of VLC can sometimes be useful, " \
     "for example if you associated VLC with some media types and you " \
     "don't want a new instance of VLC to be opened each time you " \
@@ -1084,6 +1084,7 @@ static const char *const ppsz_clock_descriptions[] =
     "to play the file with the already running instance or enqueue it. " \
     "This option requires the D-Bus session daemon to be active " \
     "and the running instance of VLC to use D-Bus control interface.")
+#endif
 
 #define STARTEDFROMFILE_TEXT N_("VLC is started from file association")
 #define STARTEDFROMFILE_LONGTEXT N_( \
@@ -1902,18 +1903,13 @@ vlc_module_begin();
 #endif
 
 #if defined(HAVE_DBUS)
-    add_bool( "one-instance", 0, NULL, ONEINSTANCE_DBUS_TEXT,
-              ONEINSTANCE_DBUS_LONGTEXT, true );
-    add_bool( "playlist-enqueue", 0, NULL, PLAYLISTENQUEUE_TEXT,
-              PLAYLISTENQUEUE_LONGTEXT, true );
-
     add_bool( "inhibit", 1, NULL, INHIBIT_TEXT,
               INHIBIT_LONGTEXT, true );
 #endif
 
-#if defined(WIN32)
-    add_bool( "one-instance", 0, NULL, ONEINSTANCE_WIN_TEXT,
-              ONEINSTANCE_WIN_LONGTEXT, true );
+#if defined(WIN32) || defined(HAVE_DBUS)
+    add_bool( "one-instance", 0, NULL, ONEINSTANCE_TEXT,
+              ONEINSTANCE_LONGTEXT, true );
     add_bool( "started-from-file", 0, NULL, STARTEDFROMFILE_TEXT,
               STARTEDFROMFILE_LONGTEXT, true );
         change_internal();
@@ -1924,6 +1920,9 @@ vlc_module_begin();
     add_bool( "playlist-enqueue", 0, NULL, PLAYLISTENQUEUE_TEXT,
               PLAYLISTENQUEUE_LONGTEXT, true );
         change_unsaveable();
+#endif
+
+#if defined(WIN32)
     add_bool( "high-priority", 0, NULL, HPRIORITY_TEXT,
               HPRIORITY_LONGTEXT, false );
         change_need_restart();
index dc5020d60a0bc8f22fb4d71e6540c94ffc55ae8c..03b6a61cd438b15996f83e4a6ec5c5c877c5aaa4 100644 (file)
@@ -534,7 +534,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 #ifdef HAVE_DBUS
     dbus_threads_init_default();
 
-    if( config_GetInt( p_libvlc, "one-instance" ) > 0 )
+    if( config_GetInt( p_libvlc, "one-instance" ) > 0
+        || ( config_GetInt( p_libvlc, "one-instance-when-started-from-file" )
+             && config_GetInt( p_libvlc, "started-from-file" ) ) )
     {
         /* Initialise D-Bus interface, check for other instances */
         DBusConnection  *p_conn = NULL;
@@ -854,7 +856,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 #ifdef HAVE_DBUS
     /* loads dbus control interface if in one-instance mode
      * we do it only when playlist exists, because dbus module needs it */
-    if( config_GetInt( p_libvlc, "one-instance" ) > 0 )
+    if( config_GetInt( p_libvlc, "one-instance" ) > 0
+        || ( config_GetInt( p_libvlc, "one-instance-when-started-from-file" )
+             && config_GetInt( p_libvlc, "started-from-file" ) ) )
         libvlc_InternalAddIntf( p_libvlc, "dbus,none" );
 
     /* Prevents the power management daemon from suspending the system