summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/reference/libmatemixer-sections.txt36
-rw-r--r--libmatemixer/Makefile.am4
-rw-r--r--libmatemixer/matemixer-device-switch.c144
-rw-r--r--libmatemixer/matemixer-device-switch.h76
-rw-r--r--libmatemixer/matemixer-stream-switch.c144
-rw-r--r--libmatemixer/matemixer-stream-switch.h76
-rw-r--r--libmatemixer/matemixer-types.h2
-rw-r--r--libmatemixer/matemixer.h2
8 files changed, 484 insertions, 0 deletions
diff --git a/docs/reference/libmatemixer-sections.txt b/docs/reference/libmatemixer-sections.txt
index 911d43d..02b0f7e 100644
--- a/docs/reference/libmatemixer-sections.txt
+++ b/docs/reference/libmatemixer-sections.txt
@@ -89,6 +89,24 @@ mate_mixer_device_get_type
</SECTION>
<SECTION>
+<FILE>matemixer-device-switch</FILE>
+<TITLE>MateMixerDeviceSwitch</TITLE>
+MateMixerDeviceSwitch
+MateMixerDeviceSwitchClass
+mate_mixer_device_switch_get_device
+<SUBSECTION Standard>
+MATE_MIXER_IS_DEVICE_SWITCH
+MATE_MIXER_IS_DEVICE_SWITCH_CLASS
+MATE_MIXER_DEVICE_SWITCH
+MATE_MIXER_DEVICE_SWITCH_CLASS
+MATE_MIXER_DEVICE_SWITCH_GET_CLASS
+MATE_MIXER_TYPE_DEVICE_SWITCH
+<SUBSECTION Private>
+MateMixerDeviceSwitchPrivate
+mate_mixer_device_switch_get_type
+</SECTION>
+
+<SECTION>
<FILE>matemixer-stored-control</FILE>
<TITLE>MateMixerStoredControl</TITLE>
MateMixerStoredControl
@@ -187,6 +205,24 @@ mate_mixer_stream_control_get_type
</SECTION>
<SECTION>
+<FILE>matemixer-stream-switch</FILE>
+<TITLE>MateMixerStreamSwitch</TITLE>
+MateMixerStreamSwitch
+MateMixerStreamSwitchClass
+mate_mixer_stream_switch_get_stream
+<SUBSECTION Standard>
+MATE_MIXER_IS_STREAM_SWITCH
+MATE_MIXER_IS_STREAM_SWITCH_CLASS
+MATE_MIXER_STREAM_SWITCH
+MATE_MIXER_STREAM_SWITCH_CLASS
+MATE_MIXER_STREAM_SWITCH_GET_CLASS
+MATE_MIXER_TYPE_STREAM_SWITCH
+<SUBSECTION Private>
+MateMixerStreamSwitchPrivate
+mate_mixer_stream_switch_get_type
+</SECTION>
+
+<SECTION>
<FILE>matemixer-switch</FILE>
<TITLE>MateMixerSwitch</TITLE>
MateMixerSwitchFlags
diff --git a/libmatemixer/Makefile.am b/libmatemixer/Makefile.am
index e419c89..f89f784 100644
--- a/libmatemixer/Makefile.am
+++ b/libmatemixer/Makefile.am
@@ -13,11 +13,13 @@ libmatemixer_include_HEADERS = \
matemixer-app-info.h \
matemixer-context.h \
matemixer-device.h \
+ matemixer-device-switch.h \
matemixer-enums.h \
matemixer-enum-types.h \
matemixer-stored-control.h \
matemixer-stream.h \
matemixer-stream-control.h \
+ matemixer-stream-switch.h \
matemixer-switch.h \
matemixer-switch-option.h \
matemixer-toggle.h \
@@ -37,12 +39,14 @@ libmatemixer_la_SOURCES = \
matemixer-backend-module.h \
matemixer-context.c \
matemixer-device.c \
+ matemixer-device-switch.c \
matemixer-enum-types.c \
matemixer-stored-control.c \
matemixer-stream.c \
matemixer-stream-private.h \
matemixer-stream-control.c \
matemixer-stream-control-private.h \
+ matemixer-stream-switch.c \
matemixer-switch.c \
matemixer-switch-private.h \
matemixer-switch-option.c \
diff --git a/libmatemixer/matemixer-device-switch.c b/libmatemixer/matemixer-device-switch.c
new file mode 100644
index 0000000..cc0bbec
--- /dev/null
+++ b/libmatemixer/matemixer-device-switch.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "matemixer-device.h"
+#include "matemixer-switch.h"
+#include "matemixer-device-switch.h"
+
+/**
+ * SECTION:matemixer-device-switch
+ * @include: libmatemixer/matemixer.h
+ */
+
+struct _MateMixerDeviceSwitchPrivate
+{
+ MateMixerDevice *device;
+};
+
+enum {
+ PROP_0,
+ PROP_DEVICE,
+ N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
+static void mate_mixer_device_switch_class_init (MateMixerDeviceSwitchClass *klass);
+
+static void mate_mixer_device_switch_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void mate_mixer_device_switch_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+static void mate_mixer_device_switch_init (MateMixerDeviceSwitch *swtch);
+
+G_DEFINE_ABSTRACT_TYPE (MateMixerDeviceSwitch, mate_mixer_device_switch, MATE_MIXER_TYPE_SWITCH)
+
+static void
+mate_mixer_device_switch_class_init (MateMixerDeviceSwitchClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->get_property = mate_mixer_device_switch_get_property;
+ object_class->set_property = mate_mixer_device_switch_set_property;
+
+ properties[PROP_DEVICE] =
+ g_param_spec_object ("device",
+ "Device",
+ "Device owning the switch",
+ MATE_MIXER_TYPE_DEVICE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+
+ g_type_class_add_private (object_class, sizeof (MateMixerDeviceSwitchPrivate));
+}
+
+static void
+mate_mixer_device_switch_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ MateMixerDeviceSwitch *swtch;
+
+ swtch = MATE_MIXER_DEVICE_SWITCH (object);
+
+ switch (param_id) {
+ case PROP_DEVICE:
+ g_value_set_object (value, swtch->priv->device);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+mate_mixer_device_switch_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ MateMixerDeviceSwitch *swtch;
+
+ swtch = MATE_MIXER_DEVICE_SWITCH (object);
+
+ switch (param_id) {
+ case PROP_DEVICE:
+ /* Construct-only object */
+ swtch->priv->device = g_value_get_object (value);
+
+ if (swtch->priv->device != NULL)
+ g_object_add_weak_pointer (G_OBJECT (swtch->priv->device),
+ (gpointer *) &swtch->priv->device);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+mate_mixer_device_switch_init (MateMixerDeviceSwitch *swtch)
+{
+ swtch->priv = G_TYPE_INSTANCE_GET_PRIVATE (swtch,
+ MATE_MIXER_TYPE_DEVICE_SWITCH,
+ MateMixerDeviceSwitchPrivate);
+}
+
+/**
+ * mate_mixer_device_switch_get_device:
+ * @swtch: a #MateMixerDeviceSwitch
+ */
+MateMixerDevice *
+mate_mixer_device_switch_get_device (MateMixerDeviceSwitch *swtch)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_DEVICE_SWITCH (swtch), NULL);
+
+ return swtch->priv->device;
+}
diff --git a/libmatemixer/matemixer-device-switch.h b/libmatemixer/matemixer-device-switch.h
new file mode 100644
index 0000000..ad3f103
--- /dev/null
+++ b/libmatemixer/matemixer-device-switch.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_DEVICE_SWITCH_H
+#define MATEMIXER_DEVICE_SWITCH_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libmatemixer/matemixer-switch.h>
+#include <libmatemixer/matemixer-types.h>
+
+G_BEGIN_DECLS
+
+#define MATE_MIXER_TYPE_DEVICE_SWITCH \
+ (mate_mixer_device_switch_get_type ())
+#define MATE_MIXER_DEVICE_SWITCH(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_DEVICE_SWITCH, MateMixerDeviceSwitch))
+#define MATE_MIXER_IS_DEVICE_SWITCH(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_DEVICE_SWITCH))
+#define MATE_MIXER_DEVICE_SWITCH_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_CAST ((k), MATE_MIXER_TYPE_DEVICE_SWITCH, MateMixerDeviceSwitchClass))
+#define MATE_MIXER_IS_DEVICE_SWITCH_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_TYPE ((k), MATE_MIXER_TYPE_DEVICE_SWITCH))
+#define MATE_MIXER_DEVICE_SWITCH_GET_CLASS(o) \
+ (G_TYPE_INSTANCE_GET_CLASS ((o), MATE_MIXER_TYPE_DEVICE_SWITCH, MateMixerDeviceSwitchClass))
+
+typedef struct _MateMixerDeviceSwitchClass MateMixerDeviceSwitchClass;
+typedef struct _MateMixerDeviceSwitchPrivate MateMixerDeviceSwitchPrivate;
+
+/**
+ * MateMixerDeviceSwitch:
+ *
+ * The #MateMixerDeviceSwitch structure contains only private data and should only
+ * be accessed using the provided API.
+ */
+struct _MateMixerDeviceSwitch
+{
+ MateMixerSwitch object;
+
+ /*< private >*/
+ MateMixerDeviceSwitchPrivate *priv;
+};
+
+/**
+ * MateMixerDeviceSwitchClass:
+ * @parent_class: The parent class.
+ *
+ * The class structure for #MateMixerDeviceSwitch.
+ */
+struct _MateMixerDeviceSwitchClass
+{
+ MateMixerSwitchClass parent_class;
+};
+
+GType mate_mixer_device_switch_get_type (void) G_GNUC_CONST;
+
+MateMixerDevice *mate_mixer_device_switch_get_device (MateMixerDeviceSwitch *swtch);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_DEVICE_SWITCH_H */
diff --git a/libmatemixer/matemixer-stream-switch.c b/libmatemixer/matemixer-stream-switch.c
new file mode 100644
index 0000000..57c8c53
--- /dev/null
+++ b/libmatemixer/matemixer-stream-switch.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "matemixer-stream.h"
+#include "matemixer-switch.h"
+#include "matemixer-stream-switch.h"
+
+/**
+ * SECTION:matemixer-stream-switch
+ * @include: libmatemixer/matemixer.h
+ */
+
+struct _MateMixerStreamSwitchPrivate
+{
+ MateMixerStream *stream;
+};
+
+enum {
+ PROP_0,
+ PROP_STREAM,
+ N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
+static void mate_mixer_stream_switch_class_init (MateMixerStreamSwitchClass *klass);
+
+static void mate_mixer_stream_switch_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void mate_mixer_stream_switch_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+static void mate_mixer_stream_switch_init (MateMixerStreamSwitch *swtch);
+
+G_DEFINE_ABSTRACT_TYPE (MateMixerStreamSwitch, mate_mixer_stream_switch, MATE_MIXER_TYPE_SWITCH)
+
+static void
+mate_mixer_stream_switch_class_init (MateMixerStreamSwitchClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->get_property = mate_mixer_stream_switch_get_property;
+ object_class->set_property = mate_mixer_stream_switch_set_property;
+
+ properties[PROP_STREAM] =
+ g_param_spec_object ("stream",
+ "Stream",
+ "Stream owning the switch",
+ MATE_MIXER_TYPE_STREAM,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+
+ g_type_class_add_private (object_class, sizeof (MateMixerStreamSwitchPrivate));
+}
+
+static void
+mate_mixer_stream_switch_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ MateMixerStreamSwitch *swtch;
+
+ swtch = MATE_MIXER_STREAM_SWITCH (object);
+
+ switch (param_id) {
+ case PROP_STREAM:
+ g_value_set_object (value, swtch->priv->stream);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+mate_mixer_stream_switch_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ MateMixerStreamSwitch *swtch;
+
+ swtch = MATE_MIXER_STREAM_SWITCH (object);
+
+ switch (param_id) {
+ case PROP_STREAM:
+ /* Construct-only object */
+ swtch->priv->stream = g_value_get_object (value);
+
+ if (swtch->priv->stream != NULL)
+ g_object_add_weak_pointer (G_OBJECT (swtch->priv->stream),
+ (gpointer *) &swtch->priv->stream);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+mate_mixer_stream_switch_init (MateMixerStreamSwitch *swtch)
+{
+ swtch->priv = G_TYPE_INSTANCE_GET_PRIVATE (swtch,
+ MATE_MIXER_TYPE_STREAM_SWITCH,
+ MateMixerStreamSwitchPrivate);
+}
+
+/**
+ * mate_mixer_stream_switch_get_stream:
+ * @swtch: a #MateMixerStreamSwitch
+ */
+MateMixerStream *
+mate_mixer_stream_switch_get_stream (MateMixerStreamSwitch *swtch)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_SWITCH (swtch), NULL);
+
+ return swtch->priv->stream;
+}
diff --git a/libmatemixer/matemixer-stream-switch.h b/libmatemixer/matemixer-stream-switch.h
new file mode 100644
index 0000000..ed37c5e
--- /dev/null
+++ b/libmatemixer/matemixer-stream-switch.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_STREAM_SWITCH_H
+#define MATEMIXER_STREAM_SWITCH_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libmatemixer/matemixer-switch.h>
+#include <libmatemixer/matemixer-types.h>
+
+G_BEGIN_DECLS
+
+#define MATE_MIXER_TYPE_STREAM_SWITCH \
+ (mate_mixer_stream_switch_get_type ())
+#define MATE_MIXER_STREAM_SWITCH(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_STREAM_SWITCH, MateMixerStreamSwitch))
+#define MATE_MIXER_IS_STREAM_SWITCH(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_STREAM_SWITCH))
+#define MATE_MIXER_STREAM_SWITCH_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_CAST ((k), MATE_MIXER_TYPE_STREAM_SWITCH, MateMixerStreamSwitchClass))
+#define MATE_MIXER_IS_STREAM_SWITCH_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_TYPE ((k), MATE_MIXER_TYPE_STREAM_SWITCH))
+#define MATE_MIXER_STREAM_SWITCH_GET_CLASS(o) \
+ (G_TYPE_INSTANCE_GET_CLASS ((o), MATE_MIXER_TYPE_STREAM_SWITCH, MateMixerStreamSwitchClass))
+
+typedef struct _MateMixerStreamSwitchClass MateMixerStreamSwitchClass;
+typedef struct _MateMixerStreamSwitchPrivate MateMixerStreamSwitchPrivate;
+
+/**
+ * MateMixerStreamSwitch:
+ *
+ * The #MateMixerStreamSwitch structure contains only private data and should only
+ * be accessed using the provided API.
+ */
+struct _MateMixerStreamSwitch
+{
+ MateMixerSwitch object;
+
+ /*< private >*/
+ MateMixerStreamSwitchPrivate *priv;
+};
+
+/**
+ * MateMixerStreamSwitchClass:
+ * @parent_class: The parent class.
+ *
+ * The class structure for #MateMixerStreamSwitch.
+ */
+struct _MateMixerStreamSwitchClass
+{
+ MateMixerSwitchClass parent_class;
+};
+
+GType mate_mixer_stream_switch_get_type (void) G_GNUC_CONST;
+
+MateMixerStream *mate_mixer_stream_switch_get_stream (MateMixerStreamSwitch *swtch);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_STREAM_SWITCH_H */
diff --git a/libmatemixer/matemixer-types.h b/libmatemixer/matemixer-types.h
index 271009c..1d116d1 100644
--- a/libmatemixer/matemixer-types.h
+++ b/libmatemixer/matemixer-types.h
@@ -23,9 +23,11 @@ G_BEGIN_DECLS
typedef struct _MateMixerAppInfo MateMixerAppInfo;
typedef struct _MateMixerContext MateMixerContext;
typedef struct _MateMixerDevice MateMixerDevice;
+typedef struct _MateMixerDeviceSwitch MateMixerDeviceSwitch;
typedef struct _MateMixerStoredControl MateMixerStoredControl;
typedef struct _MateMixerStream MateMixerStream;
typedef struct _MateMixerStreamControl MateMixerStreamControl;
+typedef struct _MateMixerStreamSwitch MateMixerStreamSwitch;
typedef struct _MateMixerSwitch MateMixerSwitch;
typedef struct _MateMixerSwitchOption MateMixerSwitchOption;
typedef struct _MateMixerToggle MateMixerToggle;
diff --git a/libmatemixer/matemixer.h b/libmatemixer/matemixer.h
index 589bf0d..2df604d 100644
--- a/libmatemixer/matemixer.h
+++ b/libmatemixer/matemixer.h
@@ -26,11 +26,13 @@
#include <libmatemixer/matemixer-app-info.h>
#include <libmatemixer/matemixer-context.h>
#include <libmatemixer/matemixer-device.h>
+#include <libmatemixer/matemixer-device-switch.h>
#include <libmatemixer/matemixer-enums.h>
#include <libmatemixer/matemixer-enum-types.h>
#include <libmatemixer/matemixer-stored-control.h>
#include <libmatemixer/matemixer-stream.h>
#include <libmatemixer/matemixer-stream-control.h>
+#include <libmatemixer/matemixer-stream-switch.h>
#include <libmatemixer/matemixer-switch.h>
#include <libmatemixer/matemixer-switch-option.h>
#include <libmatemixer/matemixer-toggle.h>