summaryrefslogtreecommitdiff
path: root/libmatemixer
diff options
context:
space:
mode:
authorMichal Ratajsky <[email protected]>2014-11-08 23:04:31 +0100
committerMichal Ratajsky <[email protected]>2014-11-08 23:04:31 +0100
commit44651c5d2334da5dd295eca9c2e530b99348bdd6 (patch)
treeff27dab4ba61563bf04442d7d2c5f0547e2dbaea /libmatemixer
parent068d95e1c28b0e20e692c5ecb24f044542e82ae9 (diff)
downloadlibmatemixer-44651c5d2334da5dd295eca9c2e530b99348bdd6.tar.bz2
libmatemixer-44651c5d2334da5dd295eca9c2e530b99348bdd6.tar.xz
Split MateMixerSwitchRole into MateMixerDeviceSwitchRole and MateMixerStreamSwitchRole
Diffstat (limited to 'libmatemixer')
-rw-r--r--libmatemixer/matemixer-device-switch.c38
-rw-r--r--libmatemixer/matemixer-device-switch.h5
-rw-r--r--libmatemixer/matemixer-enum-types.c29
-rw-r--r--libmatemixer/matemixer-enum-types.h7
-rw-r--r--libmatemixer/matemixer-enums.h31
-rw-r--r--libmatemixer/matemixer-stream-switch.c38
-rw-r--r--libmatemixer/matemixer-stream-switch.h5
-rw-r--r--libmatemixer/matemixer-switch.c35
-rw-r--r--libmatemixer/matemixer-switch.h1
9 files changed, 128 insertions, 61 deletions
diff --git a/libmatemixer/matemixer-device-switch.c b/libmatemixer/matemixer-device-switch.c
index cc0bbec..bc0ea70 100644
--- a/libmatemixer/matemixer-device-switch.c
+++ b/libmatemixer/matemixer-device-switch.c
@@ -19,6 +19,8 @@
#include <glib-object.h>
#include "matemixer-device.h"
+#include "matemixer-enums.h"
+#include "matemixer-enum-types.h"
#include "matemixer-switch.h"
#include "matemixer-device-switch.h"
@@ -29,11 +31,13 @@
struct _MateMixerDeviceSwitchPrivate
{
- MateMixerDevice *device;
+ MateMixerDevice *device;
+ MateMixerDeviceSwitchRole role;
};
enum {
PROP_0,
+ PROP_ROLE,
PROP_DEVICE,
N_PROPERTIES
};
@@ -64,6 +68,16 @@ mate_mixer_device_switch_class_init (MateMixerDeviceSwitchClass *klass)
object_class->get_property = mate_mixer_device_switch_get_property;
object_class->set_property = mate_mixer_device_switch_set_property;
+ properties[PROP_ROLE] =
+ g_param_spec_enum ("role",
+ "Role",
+ "Role of the switch",
+ MATE_MIXER_TYPE_DEVICE_SWITCH_ROLE,
+ MATE_MIXER_DEVICE_SWITCH_ROLE_UNKNOWN,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
properties[PROP_DEVICE] =
g_param_spec_object ("device",
"Device",
@@ -89,6 +103,9 @@ mate_mixer_device_switch_get_property (GObject *object,
swtch = MATE_MIXER_DEVICE_SWITCH (object);
switch (param_id) {
+ case PROP_ROLE:
+ g_value_set_enum (value, swtch->priv->role);
+ break;
case PROP_DEVICE:
g_value_set_object (value, swtch->priv->device);
break;
@@ -109,6 +126,9 @@ mate_mixer_device_switch_set_property (GObject *object,
swtch = MATE_MIXER_DEVICE_SWITCH (object);
switch (param_id) {
+ case PROP_ROLE:
+ swtch->priv->role = g_value_get_enum (value);
+ break;
case PROP_DEVICE:
/* Construct-only object */
swtch->priv->device = g_value_get_object (value);
@@ -132,6 +152,22 @@ mate_mixer_device_switch_init (MateMixerDeviceSwitch *swtch)
}
/**
+ * mate_mixer_device_switch_get_role:
+ * @swtch: a #MateMixerDeviceSwitch
+ *
+ * Gets the role of the switch. The role identifies the purpose of the switch.
+ *
+ * Returns: the switch role.
+ */
+MateMixerDeviceSwitchRole
+mate_mixer_device_switch_get_role (MateMixerDeviceSwitch *swtch)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_DEVICE_SWITCH (swtch), MATE_MIXER_DEVICE_SWITCH_ROLE_UNKNOWN);
+
+ return swtch->priv->role;
+}
+
+/**
* mate_mixer_device_switch_get_device:
* @swtch: a #MateMixerDeviceSwitch
*/
diff --git a/libmatemixer/matemixer-device-switch.h b/libmatemixer/matemixer-device-switch.h
index ad3f103..246abce 100644
--- a/libmatemixer/matemixer-device-switch.h
+++ b/libmatemixer/matemixer-device-switch.h
@@ -67,9 +67,10 @@ struct _MateMixerDeviceSwitchClass
MateMixerSwitchClass parent_class;
};
-GType mate_mixer_device_switch_get_type (void) G_GNUC_CONST;
+GType mate_mixer_device_switch_get_type (void) G_GNUC_CONST;
-MateMixerDevice *mate_mixer_device_switch_get_device (MateMixerDeviceSwitch *swtch);
+MateMixerDeviceSwitchRole mate_mixer_device_switch_get_role (MateMixerDeviceSwitch *swtch);
+MateMixerDevice * mate_mixer_device_switch_get_device (MateMixerDeviceSwitch *swtch);
G_END_DECLS
diff --git a/libmatemixer/matemixer-enum-types.c b/libmatemixer/matemixer-enum-types.c
index 6d88a83..3d4d039 100644
--- a/libmatemixer/matemixer-enum-types.c
+++ b/libmatemixer/matemixer-enum-types.c
@@ -208,20 +208,37 @@ mate_mixer_switch_flags_get_type (void)
}
GType
-mate_mixer_switch_role_get_type (void)
+mate_mixer_device_switch_role_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GEnumValue values[] = {
- { MATE_MIXER_SWITCH_ROLE_UNKNOWN, "MATE_MIXER_SWITCH_ROLE_UNKNOWN", "unknown" },
- { MATE_MIXER_SWITCH_ROLE_DEVICE_PROFILE, "MATE_MIXER_SWITCH_ROLE_DEVICE_PROFILE", "device-profile" },
- { MATE_MIXER_SWITCH_ROLE_PORT, "MATE_MIXER_SWITCH_ROLE_PORT", "port" },
- { MATE_MIXER_SWITCH_ROLE_BOOST, "MATE_MIXER_SWITCH_ROLE_BOOST", "boost" },
+ { MATE_MIXER_DEVICE_SWITCH_ROLE_UNKNOWN, "MATE_MIXER_DEVICE_SWITCH_ROLE_UNKNOWN", "unknown" },
+ { MATE_MIXER_DEVICE_SWITCH_ROLE_PROFILE, "MATE_MIXER_DEVICE_SWITCH_ROLE_PROFILE", "profile" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static (
- g_intern_static_string ("MateMixerSwitchRole"),
+ g_intern_static_string ("MateMixerDeviceSwitchRole"),
+ values);
+ }
+ return etype;
+}
+
+GType
+mate_mixer_stream_switch_role_get_type (void)
+{
+ static GType etype = 0;
+
+ if (etype == 0) {
+ static const GEnumValue values[] = {
+ { MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN, "MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN", "unknown" },
+ { MATE_MIXER_STREAM_SWITCH_ROLE_PORT, "MATE_MIXER_STREAM_SWITCH_ROLE_PORT", "port" },
+ { MATE_MIXER_STREAM_SWITCH_ROLE_BOOST, "MATE_MIXER_STREAM_SWITCH_ROLE_BOOST", "boost" },
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static (
+ g_intern_static_string ("MateMixerStreamSwitchRole"),
values);
}
return etype;
diff --git a/libmatemixer/matemixer-enum-types.h b/libmatemixer/matemixer-enum-types.h
index f96dc85..42b996b 100644
--- a/libmatemixer/matemixer-enum-types.h
+++ b/libmatemixer/matemixer-enum-types.h
@@ -52,8 +52,11 @@ GType mate_mixer_stream_control_media_role_get_type (void) G_GNUC_CONST;
#define MATE_MIXER_TYPE_SWITCH_FLAGS (mate_mixer_switch_flags_get_type ())
GType mate_mixer_switch_flags_get_type (void) G_GNUC_CONST;
-#define MATE_MIXER_TYPE_SWITCH_ROLE (mate_mixer_switch_role_get_type ())
-GType mate_mixer_switch_role_get_type (void) G_GNUC_CONST;
+#define MATE_MIXER_TYPE_DEVICE_SWITCH_ROLE (mate_mixer_device_switch_role_get_type ())
+GType mate_mixer_device_switch_role_get_type (void) G_GNUC_CONST;
+
+#define MATE_MIXER_TYPE_STREAM_SWITCH_ROLE (mate_mixer_stream_switch_role_get_type ())
+GType mate_mixer_stream_switch_role_get_type (void) G_GNUC_CONST;
#define MATE_MIXER_TYPE_CHANNEL_POSITION (mate_mixer_channel_position_get_type ())
GType mate_mixer_channel_position_get_type (void) G_GNUC_CONST;
diff --git a/libmatemixer/matemixer-enums.h b/libmatemixer/matemixer-enums.h
index befc651..6cbd78d 100644
--- a/libmatemixer/matemixer-enums.h
+++ b/libmatemixer/matemixer-enums.h
@@ -271,22 +271,31 @@ typedef enum { /*< flags >*/
} MateMixerSwitchFlags;
/**
- * MateMixerSwitchRole:
- * @MATE_MIXER_SWITCH_ROLE_UNKNOWN:
- * Unknown switch role.
- * @MATE_MIXER_SWITCH_ROLE_DEVICE_PROFILE:
+ * MateMixerDeviceSwitchRole:
+ * @MATE_MIXER_DEVICE_SWITCH_ROLE_UNKNOWN:
+ * Unknown device switch role.
+ * @MATE_MIXER_DEVICE_SWITCH_ROLE_PROFILE:
* The switch changes the active sound device profile.
- * @MATE_MIXER_SWITCH_ROLE_PORT:
+ */
+typedef enum {
+ MATE_MIXER_DEVICE_SWITCH_ROLE_UNKNOWN,
+ MATE_MIXER_DEVICE_SWITCH_ROLE_PROFILE,
+} MateMixerDeviceSwitchRole;
+
+/**
+ * MateMixerStreamSwitchRole:
+ * @MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN:
+ * Unknown stream switch role.
+ * @MATE_MIXER_STREAM_SWITCH_ROLE_PORT:
* The switch changes the active port.
- * @MATE_MIXER_SWITCH_ROLE_BOOST:
+ * @MATE_MIXER_STREAM_SWITCH_ROLE_BOOST:
* The switch changes the boost value.
*/
typedef enum {
- MATE_MIXER_SWITCH_ROLE_UNKNOWN,
- MATE_MIXER_SWITCH_ROLE_DEVICE_PROFILE,
- MATE_MIXER_SWITCH_ROLE_PORT,
- MATE_MIXER_SWITCH_ROLE_BOOST
-} MateMixerSwitchRole;
+ MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN,
+ MATE_MIXER_STREAM_SWITCH_ROLE_PORT,
+ MATE_MIXER_STREAM_SWITCH_ROLE_BOOST
+} MateMixerStreamSwitchRole;
/**
* MateMixerChannelPosition:
diff --git a/libmatemixer/matemixer-stream-switch.c b/libmatemixer/matemixer-stream-switch.c
index 57c8c53..20af819 100644
--- a/libmatemixer/matemixer-stream-switch.c
+++ b/libmatemixer/matemixer-stream-switch.c
@@ -18,6 +18,8 @@
#include <glib.h>
#include <glib-object.h>
+#include "matemixer-enums.h"
+#include "matemixer-enum-types.h"
#include "matemixer-stream.h"
#include "matemixer-switch.h"
#include "matemixer-stream-switch.h"
@@ -29,11 +31,13 @@
struct _MateMixerStreamSwitchPrivate
{
- MateMixerStream *stream;
+ MateMixerStream *stream;
+ MateMixerStreamSwitchRole role;
};
enum {
PROP_0,
+ PROP_ROLE,
PROP_STREAM,
N_PROPERTIES
};
@@ -64,6 +68,16 @@ mate_mixer_stream_switch_class_init (MateMixerStreamSwitchClass *klass)
object_class->get_property = mate_mixer_stream_switch_get_property;
object_class->set_property = mate_mixer_stream_switch_set_property;
+ properties[PROP_ROLE] =
+ g_param_spec_enum ("role",
+ "Role",
+ "Role of the switch",
+ MATE_MIXER_TYPE_STREAM_SWITCH_ROLE,
+ MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
properties[PROP_STREAM] =
g_param_spec_object ("stream",
"Stream",
@@ -89,6 +103,9 @@ mate_mixer_stream_switch_get_property (GObject *object,
swtch = MATE_MIXER_STREAM_SWITCH (object);
switch (param_id) {
+ case PROP_ROLE:
+ g_value_set_enum (value, swtch->priv->role);
+ break;
case PROP_STREAM:
g_value_set_object (value, swtch->priv->stream);
break;
@@ -109,6 +126,9 @@ mate_mixer_stream_switch_set_property (GObject *object,
swtch = MATE_MIXER_STREAM_SWITCH (object);
switch (param_id) {
+ case PROP_ROLE:
+ swtch->priv->role = g_value_get_enum (value);
+ break;
case PROP_STREAM:
/* Construct-only object */
swtch->priv->stream = g_value_get_object (value);
@@ -132,6 +152,22 @@ mate_mixer_stream_switch_init (MateMixerStreamSwitch *swtch)
}
/**
+ * mate_mixer_stream_switch_get_role:
+ * @swtch: a #MateMixerStreamSwitch
+ *
+ * Gets the role of the switch. The role identifies the purpose of the switch.
+ *
+ * Returns: the switch role.
+ */
+MateMixerStreamSwitchRole
+mate_mixer_stream_switch_get_role (MateMixerStreamSwitch *swtch)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_SWITCH (swtch), MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN);
+
+ return swtch->priv->role;
+}
+
+/**
* mate_mixer_stream_switch_get_stream:
* @swtch: a #MateMixerStreamSwitch
*/
diff --git a/libmatemixer/matemixer-stream-switch.h b/libmatemixer/matemixer-stream-switch.h
index ed37c5e..b6978fa 100644
--- a/libmatemixer/matemixer-stream-switch.h
+++ b/libmatemixer/matemixer-stream-switch.h
@@ -67,9 +67,10 @@ struct _MateMixerStreamSwitchClass
MateMixerSwitchClass parent_class;
};
-GType mate_mixer_stream_switch_get_type (void) G_GNUC_CONST;
+GType mate_mixer_stream_switch_get_type (void) G_GNUC_CONST;
-MateMixerStream *mate_mixer_stream_switch_get_stream (MateMixerStreamSwitch *swtch);
+MateMixerStreamSwitchRole mate_mixer_stream_switch_get_role (MateMixerStreamSwitch *swtch);
+MateMixerStream * mate_mixer_stream_switch_get_stream (MateMixerStreamSwitch *swtch);
G_END_DECLS
diff --git a/libmatemixer/matemixer-switch.c b/libmatemixer/matemixer-switch.c
index 6466838..d0f2691 100644
--- a/libmatemixer/matemixer-switch.c
+++ b/libmatemixer/matemixer-switch.c
@@ -35,7 +35,6 @@ struct _MateMixerSwitchPrivate
gchar *name;
gchar *label;
MateMixerSwitchFlags flags;
- MateMixerSwitchRole role;
MateMixerSwitchOption *active;
};
@@ -44,7 +43,6 @@ enum {
PROP_NAME,
PROP_LABEL,
PROP_FLAGS,
- PROP_ROLE,
PROP_ACTIVE_OPTION,
N_PROPERTIES
};
@@ -102,16 +100,6 @@ mate_mixer_switch_class_init (MateMixerSwitchClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
- properties[PROP_ROLE] =
- g_param_spec_enum ("role",
- "Role",
- "Role of the switch",
- MATE_MIXER_TYPE_SWITCH_ROLE,
- MATE_MIXER_SWITCH_ROLE_UNKNOWN,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS);
-
properties[PROP_FLAGS] =
g_param_spec_flags ("flags",
"Flags",
@@ -156,9 +144,6 @@ mate_mixer_switch_get_property (GObject *object,
case PROP_FLAGS:
g_value_set_flags (value, swtch->priv->flags);
break;
- case PROP_ROLE:
- g_value_set_enum (value, swtch->priv->role);
- break;
case PROP_ACTIVE_OPTION:
g_value_set_object (value, swtch->priv->active);
break;
@@ -191,9 +176,6 @@ mate_mixer_switch_set_property (GObject *object,
case PROP_FLAGS:
swtch->priv->flags = g_value_get_flags (value);
break;
- case PROP_ROLE:
- swtch->priv->role = g_value_get_enum (value);
- break;
case PROP_ACTIVE_OPTION:
/* Construct-only object */
swtch->priv->active = g_value_dup_object (value);
@@ -294,23 +276,6 @@ mate_mixer_switch_get_flags (MateMixerSwitch *swtch)
}
/**
- * mate_mixer_switch_get_role:
- * @swtch: a #MateMixerSwitch
- *
- * Gets the role of the switch. The role identifies the purpose of the switch.
-
- * Note that while the role identification should be reliable, it may be based on
- * looking for well-known switch names on some sound systems.
- */
-MateMixerSwitchRole
-mate_mixer_switch_get_role (MateMixerSwitch *swtch)
-{
- g_return_val_if_fail (MATE_MIXER_IS_SWITCH (swtch), MATE_MIXER_SWITCH_ROLE_UNKNOWN);
-
- return swtch->priv->role;
-}
-
-/**
* mate_mixer_switch_get_option:
* @swtch: a #MateMixerSwitch
* @name: the name of an option
diff --git a/libmatemixer/matemixer-switch.h b/libmatemixer/matemixer-switch.h
index 7881486..a6b6d49 100644
--- a/libmatemixer/matemixer-switch.h
+++ b/libmatemixer/matemixer-switch.h
@@ -81,7 +81,6 @@ GType mate_mixer_switch_get_type (void) G_GNUC_CONST;
const gchar * mate_mixer_switch_get_name (MateMixerSwitch *swtch);
const gchar * mate_mixer_switch_get_label (MateMixerSwitch *swtch);
MateMixerSwitchFlags mate_mixer_switch_get_flags (MateMixerSwitch *swtch);
-MateMixerSwitchRole mate_mixer_switch_get_role (MateMixerSwitch *swtch);
MateMixerSwitchOption *mate_mixer_switch_get_option (MateMixerSwitch *swtch,
const gchar *name);