]> git.sesse.net Git - vlc/commitdiff
dbus: Implement the MPRIS Raise method for the Qt interface
authorJean-Baptiste Kempf <jb@videolan.org>
Thu, 6 Oct 2011 23:00:54 +0000 (01:00 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Thu, 6 Oct 2011 23:15:26 +0000 (01:15 +0200)
* Addd the org.mpris.MediaPlayer2.Raise method in the dbus control module
* Define the "intf-show" variable in libvlc
* Raise the Qt main window when the value of "intf-show" changes

Heavily based on the code from Mirsal, modified by me

modules/control/dbus/dbus_introspect.h
modules/control/dbus/dbus_root.c
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp
src/libvlc.c

index bfdc98e011d0299fb2e1fab35867bf1cfa2de558..ff84c38d2f4d8fa94c581068ddadd131067e99fa 100644 (file)
@@ -65,6 +65,7 @@ static const char* psz_introspection_xml =
 "    <property name=\"CanQuit\" type=\"b\" access=\"read\" />\n"
 "    <property name=\"CanRaise\" type=\"b\" access=\"read\" />\n"
 "    <method name=\"Quit\" />\n"
+"    <method name=\"Raise\" />\n"
 "  </interface>\n"
 "  <interface name=\"org.mpris.MediaPlayer2.Player\">\n"
 "    <property name=\"Metadata\" type=\"a{sv}\" access=\"read\" />\n"
index 75b43cbdc0e1e7e0f5e576545d06e51ecde33ef0..52a22e9eaf52873c9a1c7ac1d4c464fd49453c26 100644 (file)
@@ -219,6 +219,13 @@ DBUS_METHOD( Quit )
     REPLY_SEND;
 }
 
+DBUS_METHOD( Raise )
+{/* shows vlc's main window */
+    REPLY_INIT;
+    var_ToggleBool( INTF->p_libvlc, "intf-show" );
+    REPLY_SEND;
+}
+
 #define PROPERTY_MAPPING_BEGIN if( 0 ) {}
 #define PROPERTY_FUNC( interface, property, function ) \
     else if( !strcmp( psz_interface_name, interface ) && \
@@ -277,6 +284,7 @@ handle_root ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this )
     METHOD_MAPPING_BEGIN
     METHOD_FUNC( DBUS_INTERFACE_PROPERTIES, "Get",          GetProperty );
     METHOD_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "Quit",         Quit );
+    METHOD_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "Raise",        Raise );
     METHOD_MAPPING_END
 }
 
index 1c2948856de76626fa29c35bebbfd91e0432dea8..3b46fc44709d13cc5b014bbc2e1ba2faee98ac0a 100644 (file)
@@ -70,6 +70,9 @@ static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
                        vlc_value_t old_val, vlc_value_t new_val, void *param );
 static int IntfBossCB( vlc_object_t *p_this, const char *psz_variable,
                        vlc_value_t old_val, vlc_value_t new_val, void *param );
+static int IntfRaiseMainCB( vlc_object_t *p_this, const char *psz_variable,
+                           vlc_value_t old_val, vlc_value_t new_val,
+                           void *param );
 
 MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 {
@@ -221,6 +224,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     CONNECT( this, askToQuit(), THEDP, quit() );
 
     CONNECT( this, askBoss(), this, setBoss() );
+    CONNECT( this, askRaise(), this, setRaise() );
 
     /** END of CONNECTS**/
 
@@ -230,6 +234,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
      ************/
     var_AddCallback( p_intf->p_libvlc, "intf-toggle-fscontrol", IntfShowCB, p_intf );
     var_AddCallback( p_intf->p_libvlc, "intf-boss", IntfBossCB, p_intf );
+    var_AddCallback( p_intf->p_libvlc,"intf-show", IntfRaiseMainCB, p_intf );
 
     /* Register callback for the intf-popupmenu variable */
     var_AddCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf );
@@ -1299,6 +1304,16 @@ void MainInterface::setBoss()
     }
 }
 
+void MainInterface::emitRaise()
+{
+    emit askRaise();
+}
+void MainInterface::setRaise()
+{
+    activateWindow();
+    raise();
+}
+
 /*****************************************************************************
  * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
  *  We don't show the menu directly here because we don't want the
@@ -1336,6 +1351,21 @@ static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
      return VLC_SUCCESS;
 }
 
+/*****************************************************************************
+ * IntfRaiseMainCB: callback triggered by the intf-show-main libvlc variable.
+ *****************************************************************************/
+static int IntfRaiseMainCB( vlc_object_t *p_this, const char *psz_variable,
+                       vlc_value_t old_val, vlc_value_t new_val, void *param )
+{
+    VLC_UNUSED( p_this ); VLC_UNUSED( psz_variable ); VLC_UNUSED( old_val );
+    VLC_UNUSED( new_val );
+
+    intf_thread_t *p_intf = (intf_thread_t *)param;
+    p_intf->p_sys->p_mi->emitRaise();
+
+    return VLC_SUCCESS;
+}
+
 /*****************************************************************************
  * IntfBossCB: callback triggered by the intf-boss libvlc variable.
  *****************************************************************************/
index fd925c464503d0aa318f927db221089d196f6ff2..1415bf3421cacf864c2bbb0dcf29a1cd0c1f6966 100644 (file)
@@ -205,6 +205,7 @@ public slots:
     void releaseVideoSlot( void );
 
     void emitBoss();
+    void emitRaise();
 
     void reloadPrefs();
 
@@ -246,6 +247,7 @@ private slots:
     void setVideoFullScreen( bool );
     void setVideoOnTop( bool );
     void setBoss();
+    void setRaise();
 
 signals:
     void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
@@ -258,6 +260,7 @@ signals:
     void fullscreenInterfaceToggled( bool );
     void askToQuit();
     void askBoss();
+    void askRaise();
 
 };
 
index e615f058bd5c3e9a56ed52cea342ef0097002bdd..c8397d63af41c0147ffcc324de3ca4324aee8548 100644 (file)
@@ -536,6 +536,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     /* Create a variable for the Boss Key */
     var_Create( p_libvlc, "intf-boss", VLC_VAR_VOID );
 
+    /* Create a variable for showing the main interface */
+    var_Create( p_libvlc, "intf-show", VLC_VAR_BOOL );
+
     /* Create a variable for showing the right click menu */
     var_Create( p_libvlc, "intf-popupmenu", VLC_VAR_BOOL );