summaryrefslogtreecommitdiff
path: root/libmatemixer/matemixer-port.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmatemixer/matemixer-port.c')
-rw-r--r--libmatemixer/matemixer-port.c143
1 files changed, 114 insertions, 29 deletions
diff --git a/libmatemixer/matemixer-port.c b/libmatemixer/matemixer-port.c
index 3a7670d..f89a8bb 100644
--- a/libmatemixer/matemixer-port.c
+++ b/libmatemixer/matemixer-port.c
@@ -21,6 +21,7 @@
#include "matemixer-enums.h"
#include "matemixer-enum-types.h"
#include "matemixer-port.h"
+#include "matemixer-port-private.h"
/**
* SECTION:matemixer-port
@@ -32,7 +33,7 @@ struct _MateMixerPortPrivate
gchar *name;
gchar *description;
gchar *icon;
- gulong priority;
+ guint priority;
MateMixerPortFlags flags;
};
@@ -102,15 +103,15 @@ mate_mixer_port_class_init (MateMixerPortClass *klass)
G_PARAM_STATIC_STRINGS);
properties[PROP_PRIORITY] =
- g_param_spec_ulong ("priority",
- "Priority",
- "Priority of the port",
- 0,
- G_MAXULONG,
- 0,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS);
+ g_param_spec_uint ("priority",
+ "Priority",
+ "Priority of the port",
+ 0,
+ G_MAXUINT,
+ 0,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
properties[PROP_FLAGS] =
g_param_spec_flags ("flags",
@@ -148,7 +149,7 @@ mate_mixer_port_get_property (GObject *object,
g_value_set_string (value, port->priv->icon);
break;
case PROP_PRIORITY:
- g_value_set_ulong (value, port->priv->priority);
+ g_value_set_uint (value, port->priv->priority);
break;
case PROP_FLAGS:
g_value_set_flags (value, port->priv->flags);
@@ -183,7 +184,7 @@ mate_mixer_port_set_property (GObject *object,
port->priv->icon = g_strdup (g_value_get_string (value));
break;
case PROP_PRIORITY:
- port->priv->priority = g_value_get_ulong (value);
+ port->priv->priority = g_value_get_uint (value);
break;
case PROP_FLAGS:
port->priv->flags = g_value_get_flags (value);
@@ -216,22 +217,10 @@ mate_mixer_port_finalize (GObject *object)
G_OBJECT_CLASS (mate_mixer_port_parent_class)->finalize (object);
}
-MateMixerPort *
-mate_mixer_port_new (const gchar *name,
- const gchar *description,
- const gchar *icon,
- gulong priority,
- MateMixerPortFlags flags)
-{
- return g_object_new (MATE_MIXER_TYPE_PORT,
- "name", name,
- "description", description,
- "icon", icon,
- "priority", priority,
- "flags", flags,
- NULL);
-}
-
+/**
+ * mate_mixer_port_get_name:
+ * @port: a #MateMixerPort
+ */
const gchar *
mate_mixer_port_get_name (MateMixerPort *port)
{
@@ -240,6 +229,10 @@ mate_mixer_port_get_name (MateMixerPort *port)
return port->priv->name;
}
+/**
+ * mate_mixer_port_get_description:
+ * @port: a #MateMixerPort
+ */
const gchar *
mate_mixer_port_get_description (MateMixerPort *port)
{
@@ -248,6 +241,10 @@ mate_mixer_port_get_description (MateMixerPort *port)
return port->priv->description;
}
+/**
+ * mate_mixer_port_get_icon:
+ * @port: a #MateMixerPort
+ */
const gchar *
mate_mixer_port_get_icon (MateMixerPort *port)
{
@@ -256,7 +253,11 @@ mate_mixer_port_get_icon (MateMixerPort *port)
return port->priv->icon;
}
-gulong
+/**
+ * mate_mixer_port_get_priority:
+ * @port: a #MateMixerPort
+ */
+guint
mate_mixer_port_get_priority (MateMixerPort *port)
{
g_return_val_if_fail (MATE_MIXER_IS_PORT (port), 0);
@@ -264,6 +265,10 @@ mate_mixer_port_get_priority (MateMixerPort *port)
return port->priv->priority;
}
+/**
+ * mate_mixer_port_get_flags:
+ * @port: a #MateMixerPort
+ */
MateMixerPortFlags
mate_mixer_port_get_flags (MateMixerPort *port)
{
@@ -271,3 +276,83 @@ mate_mixer_port_get_flags (MateMixerPort *port)
return port->priv->flags;
}
+
+MateMixerPort *
+_mate_mixer_port_new (const gchar *name,
+ const gchar *description,
+ const gchar *icon,
+ guint priority,
+ MateMixerPortFlags flags)
+{
+ return g_object_new (MATE_MIXER_TYPE_PORT,
+ "name", name,
+ "description", description,
+ "icon", icon,
+ "priority", priority,
+ "flags", flags,
+ NULL);
+}
+
+gboolean
+_mate_mixer_port_update_description (MateMixerPort *port, const gchar *description)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_PORT (port), FALSE);
+
+ if (g_strcmp0 (port->priv->description, description) != 0) {
+ g_free (port->priv->description);
+
+ port->priv->description = g_strdup (description);
+
+ g_object_notify_by_pspec (G_OBJECT (port), properties[PROP_DESCRIPTION]);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gboolean
+_mate_mixer_port_update_icon (MateMixerPort *port, const gchar *icon)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_PORT (port), FALSE);
+
+ if (g_strcmp0 (port->priv->icon, icon) != 0) {
+ g_free (port->priv->icon);
+
+ port->priv->icon = g_strdup (icon);
+
+ g_object_notify_by_pspec (G_OBJECT (port), properties[PROP_ICON]);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gboolean
+_mate_mixer_port_update_priority (MateMixerPort *port, guint priority)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_PORT (port), FALSE);
+
+ if (port->priv->priority != priority) {
+ port->priv->priority = priority;
+
+ g_object_notify_by_pspec (G_OBJECT (port), properties[PROP_PRIORITY]);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gboolean
+_mate_mixer_port_update_flags (MateMixerPort *port, MateMixerPortFlags flags)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_PORT (port), FALSE);
+
+ if (port->priv->flags != flags) {
+ port->priv->flags = flags;
+
+ g_object_notify_by_pspec (G_OBJECT (port), properties[PROP_FLAGS]);
+ return TRUE;
+ }
+
+ return FALSE;
+}