[vlc-devel] commit: Activate 2 more one instance mode optins with DBus ( Antoine Cellerier )

git version control git at videolan.org
Sun Sep 14 00:33:12 CEST 2008


vlc | branch: 0.9-bugfix | Antoine Cellerier <dionoea at videolan.org> | Sun Sep 14 00:34:09 2008 +0200| [de4c527aeac8e6873b2b190f97a395ee11b6f031] | committer: Antoine Cellerier 

Activate 2 more one instance mode optins with DBus

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.
(cherry picked from commit a8821cd85000619bf8fd806cac2a133848f352d5)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=de4c527aeac8e6873b2b190f97a395ee11b6f031
---

 src/libvlc-module.c |   25 ++++++++++++-------------
 src/libvlc.c        |    8 ++++++--
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index e0b95b3..cfcd9af 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1041,16 +1041,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 " \
@@ -1058,6 +1058,7 @@ static const char *const ppsz_clock_descriptions[] =
     "to play the file with the already running instance or enqueue it. " \
     "This option require 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_( \
@@ -1869,18 +1870,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();
@@ -1891,6 +1887,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();
diff --git a/src/libvlc.c b/src/libvlc.c
index 58c2124..c111ea9 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -536,7 +536,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;
@@ -834,7 +836,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




More information about the vlc-devel mailing list