diff options
Diffstat (limited to 'libmatemixer/matemixer-client-stream.c')
-rw-r--r-- | libmatemixer/matemixer-client-stream.c | 173 |
1 files changed, 171 insertions, 2 deletions
diff --git a/libmatemixer/matemixer-client-stream.c b/libmatemixer/matemixer-client-stream.c index 80f48a9..d05b1bf 100644 --- a/libmatemixer/matemixer-client-stream.c +++ b/libmatemixer/matemixer-client-stream.c @@ -21,6 +21,18 @@ #include "matemixer-client-stream.h" #include "matemixer-stream.h" +/** + * SECTION:matemixer-client-stream + * @short_description: An interface providing extra functionality for client streams + * @see_also: #MateMixerStream + * @include: libmatemixer/matemixer.h + * + * #MateMixerClientStream represents a special kind of stream, which belongs + * to a parent input or output stream. + * + * A typical example of a client stream is a stream provided by an application. + */ + G_DEFINE_INTERFACE (MateMixerClientStream, mate_mixer_client_stream, G_TYPE_OBJECT) static void @@ -31,11 +43,50 @@ mate_mixer_client_stream_default_init (MateMixerClientStreamInterface *iface) "Parent", "Parent stream of the client stream", MATE_MIXER_TYPE_STREAM, - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_READWRITE | + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + + g_object_interface_install_property (iface, + g_param_spec_string ("app-name", + "App name", + "Name of the client stream application", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + + g_object_interface_install_property (iface, + g_param_spec_string ("app-id", + "App ID", + "Identifier of the client stream application", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + + g_object_interface_install_property (iface, + g_param_spec_string ("app-version", + "App version", + "Version of the client stream application", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + + g_object_interface_install_property (iface, + g_param_spec_string ("app-icon", + "App icon", + "Icon name of the client stream application", + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); } +/** + * mate_mixer_client_stream_get_parent: + * @client: a #MateMixerClientStream + * + * Gets the parent stream of the client stream. + * + * Returns: a #MateMixerStream or %NULL on failure. + */ MateMixerStream * mate_mixer_client_stream_get_parent (MateMixerClientStream *client) { @@ -51,6 +102,16 @@ mate_mixer_client_stream_get_parent (MateMixerClientStream *client) return NULL; } +/** + * mate_mixer_client_stream_set_parent: + * @client: a #MateMixerClientStream + * @parent: a #MateMixerStream + * + * Changes the parent stream of the client stream. The parent stream must be a + * non-client output stream. + * + * Returns: %TRUE on success or %FALSE on failure. + */ gboolean mate_mixer_client_stream_set_parent (MateMixerClientStream *client, MateMixerStream *parent) { @@ -67,6 +128,14 @@ mate_mixer_client_stream_set_parent (MateMixerClientStream *client, MateMixerStr return FALSE; } +/** + * mate_mixer_client_stream_remove: + * @client: a #MateMixerClientStream + * + * Removes the client stream. + * + * Returns: %TRUE on success or %FALSE on failure. + */ gboolean mate_mixer_client_stream_remove (MateMixerClientStream *client) { @@ -81,3 +150,103 @@ mate_mixer_client_stream_remove (MateMixerClientStream *client) return FALSE; } + +/** + * mate_mixer_client_stream_get_app_name: + * @client: a #MateMixerClientStream + * + * Gets the name of the application in case the stream is an application + * stream. + * + * Returns: a string on success, or %NULL if the stream is not an application + * stream or if the application does not provide a name. + */ +const gchar * +mate_mixer_client_stream_get_app_name (MateMixerClientStream *client) +{ + MateMixerClientStreamInterface *iface; + + g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), NULL); + + iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client); + + if (iface->get_app_name) + return iface->get_app_name (client); + + return NULL; +} + +/** + * mate_mixer_client_stream_get_app_id: + * @client: a #MateMixerClientStream + * + * Gets the identifier (e.g. org.example.app) of the application in case the + * stream is an application stream. + * + * Returns: a string on success, or %NULL if the stream is not an application + * stream or if the application does not provide an identifier. + */ +const gchar * +mate_mixer_client_stream_get_app_id (MateMixerClientStream *client) +{ + MateMixerClientStreamInterface *iface; + + g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), NULL); + + iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client); + + if (iface->get_app_id) + return iface->get_app_id (client); + + return NULL; +} + +/** + * mate_mixer_client_stream_get_app_version: + * @client: a #MateMixerClientStream + * + * Gets the version of the application in case the stream is an application + * stream. + * + * Returns: a string on success, or %NULL if the stream is not an application + * stream or if the application does not provide a version string. + */ +const gchar * +mate_mixer_client_stream_get_app_version (MateMixerClientStream *client) +{ + MateMixerClientStreamInterface *iface; + + g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), NULL); + + iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client); + + if (iface->get_app_version) + return iface->get_app_version (client); + + return NULL; +} + +/** + * mate_mixer_client_stream_get_app_icon: + * @client: a #MateMixerClientStream + * + * Gets the XDG icon name of the application in case the stream is an + * application stream. + * + * Returns: a string on success, or %NULL if the stream is not an application + * stream or if the application does not provide an icon name. + */ +const gchar * +mate_mixer_client_stream_get_app_icon (MateMixerClientStream *client) +{ + MateMixerClientStreamInterface *iface; + + g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), NULL); + + iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client); + + if (iface->get_app_icon) + return iface->get_app_icon (client); + + return NULL; +} |