aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common-defs.h2
-rw-r--r--src/mpris-controller.vala27
-rw-r--r--src/player-item.vala2
-rw-r--r--src/sound-service.c4
-rw-r--r--src/transport-menu-item.vala8
-rw-r--r--src/transport-widget.c23
6 files changed, 38 insertions, 28 deletions
diff --git a/src/common-defs.h b/src/common-defs.h
index c12d9c1..5fbf743 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -27,7 +27,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
/* DBUS Custom Items */
#define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-item"
#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-transport-bar"
-#define DBUSMENU_TRANSPORT_MENUITEM_STATE "x-canonical-transport-state"
+#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-transport-state"
#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-metadata-menu-item"
#define DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST "x-canonical-metadata-text-artist"
diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala
index 62077d1..4515c00 100644
--- a/src/mpris-controller.vala
+++ b/src/mpris-controller.vala
@@ -41,12 +41,21 @@ public class MprisController : GLib.Object
this.controller = controller;
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.mpris_player.StatusChange += onStatusChange;
+
+ status st = this.mpris_player.GetStatus();
+ int play_state = st.playback;
+ debug("GetStatusChange - play state %i", play_state);
+ (this.controller.custom_items[this.controller.TRANSPORT] as TransportMenuitem).change_play_state(play_state);
+ this.controller.custom_items[this.controller.METADATA].update(this.mpris_player.GetMetadata(),
+ MetadataMenuitem.attributes_format());
+
}
private void onTrackChange(dynamic DBus.Object mpris_client, HashTable<string,Value?> ht)
{
+ debug("onTrackChange");
this.controller.custom_items[this.controller.METADATA].update(ht,
MetadataMenuitem.attributes_format());
}
@@ -73,14 +82,14 @@ public class MprisController : GLib.Object
status* status = &st;
unowned ValueArray ar = (ValueArray)status;
- bool play_state = (ar.get_nth(0).get_int() == 1);
- debug("onStatusChange - play state %s", play_state.to_string());
- HashTable<string, Value?> ht = new HashTable<string, Value?>(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());
+ int play_state = ar.get_nth(0).get_int();
+ debug("onStatusChange - play state %i", play_state);
+ //HashTable<string, Value?> ht = new HashTable<string, Value?>(str_hash, str_equal);
+ //int* type = &play_state;
+ //Value v = Value(typeof(int*));
+ //v.set_pointer(type);
+ //ht.insert("state", v);
+ (this.controller.custom_items[this.controller.TRANSPORT] as TransportMenuitem).change_play_state(play_state);
}
}
diff --git a/src/player-item.vala b/src/player-item.vala
index fe1eeab..3cac208 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -35,7 +35,9 @@ public class PlayerItem : Dbusmenu.Menuitem
foreach(string property in attributes){
string[] input_keys = property.split("-");
string search_key = input_keys[input_keys.length-1 : input_keys.length][0];
+ debug("search key = %s", search_key);
if (data.lookup(search_key).holds (typeof (string))){
+ debug("track data change player item update");
this.property_set(property, this.sanitize_string(data.lookup(search_key) as string));
}
else if (data.lookup(search_key).holds (typeof (int))){
diff --git a/src/sound-service.c b/src/sound-service.c
index ea04e4b..bcdac07 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -45,8 +45,8 @@ service_shutdown (IndicatorService *service, gpointer user_data)
if (mainloop != NULL) {
g_debug("Service shutdown !");
// TODO: uncomment for release !!
- //close_pulse_activites();
- //g_main_loop_quit(mainloop);
+ close_pulse_activites();
+ g_main_loop_quit(mainloop);
}
return;
}
diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala
index aae07cc..c8733c0 100644
--- a/src/transport-menu-item.vala
+++ b/src/transport-menu-item.vala
@@ -28,10 +28,14 @@ public class TransportMenuitem : PlayerItem
public TransportMenuitem()
{
this.property_set(MENUITEM_PROP_TYPE, MENUITEM_TYPE);
- this.property_set_bool(MENUITEM_STATE, false);
debug("transport on the vala side");
}
+ public void change_play_state(int state)
+ {
+ this.property_set_int(MENUITEM_PLAY_STATE, state);
+ }
+
public override void handle_event(string name, GLib.Value input_value, uint timestamp)
{
debug("handle_event with bool value %s", input_value.get_boolean().to_string());
@@ -41,7 +45,7 @@ public class TransportMenuitem : PlayerItem
public static HashSet<string> attributes_format()
{
HashSet<string> attrs = new HashSet<string>();
- attrs.add(MENUITEM_STATE);
+ attrs.add(MENUITEM_PLAY_STATE);
return attrs;
}
} \ No newline at end of file
diff --git a/src/transport-widget.c b/src/transport-widget.c
index e1baa68..9077c41 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -69,7 +69,7 @@ static void transport_widget_property_update(DbusmenuMenuitem* item,
GValue * value,
gpointer userdata);
// utility methods
-static gchar* transport_widget_toggle_play_label(const gchar* state);
+static gchar* transport_widget_toggle_play_label(gint state);
G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM);
@@ -134,13 +134,8 @@ transport_widget_init (TransportWidget *self)
GtkWidget *hbox;
hbox = gtk_hbox_new(TRUE, 2);
-
- gchar* label = ">";
- if(dbusmenu_menuitem_property_get_bool(twin_item, DBUSMENU_TRANSPORT_MENUITEM_STATE) == TRUE){
- label = "||";
- }
-
- priv->play_button = gtk_button_new_with_label(g_strdup(label));
+ gchar* symbol = transport_widget_toggle_play_label(dbusmenu_menuitem_property_get_int(twin_item, DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE));
+ priv->play_button = gtk_button_new_with_label(symbol);
gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, TRUE, 0);
priv->hbox = hbox;
@@ -178,7 +173,7 @@ transport_widget_button_press_event (GtkWidget *menuitem,
gtk_widget_event (priv->hbox, (GdkEvent*)event);
gboolean state = g_ascii_strcasecmp(gtk_button_get_label(GTK_BUTTON(priv->play_button)), ">") == 0;
- gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label(gtk_button_get_label(GTK_BUTTON(priv->play_button))));
+ gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label((gint)state));
GValue value = {0};
g_value_init(&value, G_TYPE_BOOLEAN);
g_debug("TransportWidget::menu_press_event - going to send value %i", state);
@@ -216,20 +211,20 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property,
GValue* value, gpointer userdata)
{
g_debug("transport_widget_update_state - with property %s", property);
- gchar* input = g_strdup(g_value_get_string(value));
- g_debug("transport_widget_update_state - with value %s", input);
+ int update_value = g_value_get_int(value);
+ g_debug("transport_widget_update_state - with value %i", update_value);
TransportWidget* bar = (TransportWidget*)userdata;
TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar);
- gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label(property));
+ gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label(update_value));
}
// will be needed for image swapping
-static gchar* transport_widget_toggle_play_label(const gchar* state)
+static gchar* transport_widget_toggle_play_label(int play_state)
{
gchar* label = ">";
- if(g_strcmp0(state, ">") == 0){
+ if(play_state == 1){
label = "||";
}
return label;