summaryrefslogtreecommitdiff
path: root/libmatemixer
diff options
context:
space:
mode:
authorMichal Ratajsky <[email protected]>2014-09-07 23:07:49 +0200
committerMichal Ratajsky <[email protected]>2014-09-07 23:07:49 +0200
commit3c4f6e0bfbc6fdca6f0e18c83a02fbfd050d1083 (patch)
treec48eaac68865a29caa74f80976aefe00d8e27861 /libmatemixer
parent5997585cc046956479feffea7c414bea2814d403 (diff)
downloadlibmatemixer-3c4f6e0bfbc6fdca6f0e18c83a02fbfd050d1083.tar.bz2
libmatemixer-3c4f6e0bfbc6fdca6f0e18c83a02fbfd050d1083.tar.xz
Turn MateMixerStoredControl into an abstract class
Diffstat (limited to 'libmatemixer')
-rw-r--r--libmatemixer/matemixer-stored-control.c108
-rw-r--r--libmatemixer/matemixer-stored-control.h41
2 files changed, 125 insertions, 24 deletions
diff --git a/libmatemixer/matemixer-stored-control.c b/libmatemixer/matemixer-stored-control.c
index eb2a448..d150490 100644
--- a/libmatemixer/matemixer-stored-control.c
+++ b/libmatemixer/matemixer-stored-control.c
@@ -23,20 +23,104 @@
#include "matemixer-stream-control.h"
#include "matemixer-stored-control.h"
-G_DEFINE_INTERFACE (MateMixerStoredControl, mate_mixer_stored_control, MATE_MIXER_TYPE_STREAM_CONTROL)
+struct _MateMixerStoredControlPrivate
+{
+ MateMixerDirection direction;
+};
+
+enum {
+ PROP_0,
+ PROP_DIRECTION,
+ N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
+static void mate_mixer_stored_control_class_init (MateMixerStoredControlClass *klass);
+
+static void mate_mixer_stored_control_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void mate_mixer_stored_control_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+static void mate_mixer_stored_control_init (MateMixerStoredControl *control);
+
+G_DEFINE_ABSTRACT_TYPE (MateMixerStoredControl, mate_mixer_stored_control, MATE_MIXER_TYPE_STREAM_CONTROL)
+
+static void
+mate_mixer_stored_control_class_init (MateMixerStoredControlClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->get_property = mate_mixer_stored_control_get_property;
+ object_class->set_property = mate_mixer_stored_control_set_property;
+
+ properties[PROP_DIRECTION] =
+ g_param_spec_enum ("direction",
+ "Direction",
+ "Direction of the stored control",
+ MATE_MIXER_TYPE_DIRECTION,
+ MATE_MIXER_DIRECTION_UNKNOWN,
+ 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 (MateMixerStoredControlPrivate));
+}
+
+static void
+mate_mixer_stored_control_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ MateMixerStoredControl *control;
+
+ control = MATE_MIXER_STORED_CONTROL (object);
+
+ switch (param_id) {
+ case PROP_DIRECTION:
+ g_value_set_enum (value, control->priv->direction);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+mate_mixer_stored_control_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ MateMixerStoredControl *control;
+
+ control = MATE_MIXER_STORED_CONTROL (object);
+
+ switch (param_id) {
+ case PROP_DIRECTION:
+ control->priv->direction = g_value_get_enum (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
static void
-mate_mixer_stored_control_default_init (MateMixerStoredControlInterface *iface)
+mate_mixer_stored_control_init (MateMixerStoredControl *control)
{
- g_object_interface_install_property (iface,
- g_param_spec_enum ("direction",
- "Direction",
- "Direction of the stored control",
- MATE_MIXER_TYPE_DIRECTION,
- MATE_MIXER_DIRECTION_UNKNOWN,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ control->priv = G_TYPE_INSTANCE_GET_PRIVATE (control,
+ MATE_MIXER_TYPE_STORED_CONTROL,
+ MateMixerStoredControlPrivate);
}
/**
@@ -48,5 +132,5 @@ mate_mixer_stored_control_get_direction (MateMixerStoredControl *control)
{
g_return_val_if_fail (MATE_MIXER_IS_STORED_CONTROL (control), MATE_MIXER_DIRECTION_UNKNOWN);
- return MATE_MIXER_STORED_CONTROL_GET_INTERFACE (control)->get_direction (control);
+ return control->priv->direction;
}
diff --git a/libmatemixer/matemixer-stored-control.h b/libmatemixer/matemixer-stored-control.h
index 09731ef..d21209e 100644
--- a/libmatemixer/matemixer-stored-control.h
+++ b/libmatemixer/matemixer-stored-control.h
@@ -22,33 +22,50 @@
#include <glib-object.h>
#include <libmatemixer/matemixer-enums.h>
+#include <libmatemixer/matemixer-stream-control.h>
#include <libmatemixer/matemixer-types.h>
G_BEGIN_DECLS
-#define MATE_MIXER_TYPE_STORED_CONTROL \
+#define MATE_MIXER_TYPE_STORED_CONTROL \
(mate_mixer_stored_control_get_type ())
-#define MATE_MIXER_STORED_CONTROL(o) \
+#define MATE_MIXER_STORED_CONTROL(o) \
(G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_STORED_CONTROL, MateMixerStoredControl))
-#define MATE_MIXER_IS_STORED_CONTROL(o) \
+#define MATE_MIXER_IS_STORED_CONTROL(o) \
(G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_STORED_CONTROL))
-#define MATE_MIXER_STORED_CONTROL_GET_INTERFACE(o) \
- (G_TYPE_INSTANCE_GET_INTERFACE ((o), MATE_MIXER_TYPE_STORED_CONTROL, MateMixerStoredControlInterface))
+#define MATE_MIXER_STORED_CONTROL_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_CAST ((k), MATE_MIXER_TYPE_STORED_CONTROL, MateMixerStoredControlClass))
+#define MATE_MIXER_IS_STORED_CONTROL_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_TYPE ((k), MATE_MIXER_TYPE_STORED_CONTROL))
+#define MATE_MIXER_STORED_CONTROL_GET_CLASS(o) \
+ (G_TYPE_INSTANCE_GET_CLASS ((o), MATE_MIXER_TYPE_STORED_CONTROL, MateMixerStoredControlClass))
-typedef struct _MateMixerStoredControlInterface MateMixerStoredControlInterface;
+typedef struct _MateMixerStoredControlClass MateMixerStoredControlClass;
+typedef struct _MateMixerStoredControlPrivate MateMixerStoredControlPrivate;
/**
- * MateMixerStoredControlInterface:
- * @parent_iface: The parent interface.
+ * MateMixerStoredControl:
*
- * The interface structure for #MateMixerStoredControl.
+ * The #MateMixerStoredControl structure contains only private data and should only
+ * be accessed using the provided API.
*/
-struct _MateMixerStoredControlInterface
+struct _MateMixerStoredControl
{
- GTypeInterface parent_iface;
+ MateMixerStreamControl object;
/*< private >*/
- MateMixerDirection (*get_direction) (MateMixerStoredControl *control);
+ MateMixerStoredControlPrivate *priv;
+};
+
+/**
+ * MateMixerStoredControlClass:
+ * @parent_class: The parent class.
+ *
+ * The class structure for #MateMixerStoredControl.
+ */
+struct _MateMixerStoredControlClass
+{
+ MateMixerStreamControlClass parent_class;
};
GType mate_mixer_stored_control_get_type (void) G_GNUC_CONST;