[rhythmbox] shell: use g_value_transform in setSongProperty dbus method
- From: Jonathan Matthew <jmatthew src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rhythmbox] shell: use g_value_transform in setSongProperty dbus method
- Date: Mon, 14 Dec 2009 11:35:43 +0000 (UTC)
commit 5de6f070d02f5d87e2c1773509b08be30302348b
Author: Jonathan Matthew <jonathan d14n org>
Date: Mon Dec 14 21:23:39 2009 +1000
shell: use g_value_transform in setSongProperty dbus method
This mostly means that the caller can use any numeric type for setting
properties such as play count. Since dbus-glib doesn't map any dbus
value type to G_TYPE_ULONG, it wasn't possible to set the play count,
track number, disc number, or year previously.
shell/rb-shell.c | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/shell/rb-shell.c b/shell/rb-shell.c
index 34f0554..ceeda35 100644
--- a/shell/rb-shell.c
+++ b/shell/rb-shell.c
@@ -3166,16 +3166,24 @@ rb_shell_set_song_property (RBShell *shell,
proptype = rhythmdb_get_property_type (shell->priv->db, propid);
if (G_VALUE_TYPE (value) != proptype) {
- g_set_error (error,
- RB_SHELL_ERROR,
- RB_SHELL_ERROR_INVALID_PROPERTY_TYPE,
- _("Invalid property type %s for property %s"),
- g_type_name (G_VALUE_TYPE (value)),
- uri);
- return FALSE;
+ GValue convert = {0,};
+ g_value_init (&convert, proptype);
+ if (g_value_transform (value, &convert) == FALSE) {
+ g_value_unset (&convert);
+ g_set_error (error,
+ RB_SHELL_ERROR,
+ RB_SHELL_ERROR_INVALID_PROPERTY_TYPE,
+ _("Invalid property type %s for property %s"),
+ g_type_name (G_VALUE_TYPE (value)),
+ propname);
+ return FALSE;
+ } else {
+ rhythmdb_entry_set (shell->priv->db, entry, propid, &convert);
+ g_value_unset (&convert);
+ }
+ } else {
+ rhythmdb_entry_set (shell->priv->db, entry, propid, value);
}
-
- rhythmdb_entry_set (shell->priv->db, entry, propid, value);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]