From 3c42ee89d903f2bd1a239f2e3e8c236bfe2ef2ba Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 21 Jun 2010 23:28:31 +0100 Subject: trying for support --- src/mpris-controller.vala | 22 +++++++++------------- src/player-item.vala | 5 +++++ src/transport-menu-item.vala | 7 +++++++ src/transport-widget.c | 2 +- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala index c71662a..62077d1 100644 --- a/src/mpris-controller.vala +++ b/src/mpris-controller.vala @@ -20,7 +20,6 @@ with this program. If not, see . using Gee; - public class MprisController : GLib.Object { private DBus.Connection connection; @@ -33,7 +32,6 @@ public class MprisController : GLib.Object public int32 endless; } - public MprisController(string name, PlayerController controller, string mpris_interface="org.freedesktop.MediaPlayer"){ try { this.connection = DBus.Bus.get (DBus.BusType.SESSION); @@ -44,18 +42,13 @@ public class MprisController : GLib.Object this.mpris_player = this.connection.get_object ("org.mpris.".concat(name.down()) , "/Player", mpris_interface); this.mpris_player.TrackChange += onTrackChange; this.mpris_player.StatusChange += onStatusChange; - //this.controller.update_playing_info(get_track_data()); } - //public HashMap get_track_data() - //{ - //return format_metadata(this.mpris_player.GetMetadata()); - //} private void onTrackChange(dynamic DBus.Object mpris_client, HashTable ht) { this.controller.custom_items[this.controller.METADATA].update(ht, - MetadataMenuitem.attributes_format()); + MetadataMenuitem.attributes_format()); } /** @@ -80,11 +73,14 @@ public class MprisController : GLib.Object status* status = &st; unowned ValueArray ar = (ValueArray)status; - int playback = ar.get_nth(0).get_int(); - debug("onStatusChange - play %i", ar.get_nth(0).get_int()); - - //int repeat = ar.get_nth(2).get_int(); - //int endless = ar.get_nth(3).get_int(); + bool play_state = (ar.get_nth(0).get_int() == 1); + debug("onStatusChange - play state %s", play_state.to_string()); + HashTable ht = new HashTable(str_hash, str_equal); + Value v = Value(typeof(bool)); + v.set_boolean(play_state); + ht.insert("state", play_state); + this.controller.custom_items[this.controller.TRANSPORT].update(ht, + TransportMenuitem.attributes_format()); } } diff --git a/src/player-item.vala b/src/player-item.vala index 7bf1063..fe1eeab 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -44,6 +44,11 @@ public class PlayerItem : Dbusmenu.Menuitem int r = *v; this.property_set_int(property, r); } + else if(data.lookup(search_key).holds (typeof (bool))){ + bool* b = (bool*)data.lookup(search_key); + bool input = *b; + this.property_set_bool(property, input); + } } } diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 3c49e1c..aae07cc 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -36,5 +36,12 @@ public class TransportMenuitem : PlayerItem { debug("handle_event with bool value %s", input_value.get_boolean().to_string()); this.mpris_adaptor.toggle_playback(input_value.get_boolean()); + } + + public static HashSet attributes_format() + { + HashSet attrs = new HashSet(); + attrs.add(MENUITEM_STATE); + return attrs; } } \ No newline at end of file diff --git a/src/transport-widget.c b/src/transport-widget.c index 10b96df..e1baa68 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -222,7 +222,7 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property, TransportWidget* bar = (TransportWidget*)userdata; TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar); - gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_toggle_play_label(property))); + gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label(property)); } // will be needed for image swapping -- cgit v1.2.3