aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mpris-controller.vala16
-rw-r--r--src/mpris2-controller.vala25
-rw-r--r--src/music-player-bridge.vala6
-rw-r--r--src/play-button.c8
-rw-r--r--src/player-controller.vala83
-rw-r--r--src/player-item.vala2
-rw-r--r--src/scrub-menu-item.vala7
-rw-r--r--src/scrub-widget.c2
-rw-r--r--src/sound-service.c4
-rw-r--r--src/transport-menu-item.vala2
10 files changed, 116 insertions, 39 deletions
diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala
index 8ecd20a..c70c6d5 100644
--- a/src/mpris-controller.vala
+++ b/src/mpris-controller.vala
@@ -124,17 +124,23 @@ public class MprisController : GLib.Object
private void onTrackChange(dynamic DBus.Object mpris_client, HashTable<string,Value?> ht)
{
debug("onTrackChange");
+
this.owner.custom_items[PlayerController.widget_order.METADATA].reset(MetadataMenuitem.attributes_format());
this.owner.custom_items[PlayerController.widget_order.SCRUB].reset(ScrubMenuitem.attributes_format());
+ HashTable<string, Value?> status_hash = new HashTable<string, Value?>(str_hash, str_equal);
+
+ status st = this.mpris_player.GetStatus();
+ int play_state = st.playback;
+ debug("GetStatusChange, about to update scrub with play state - %i", play_state);
+
+ ScrubMenuitem scrub = this.owner.custom_items[PlayerController.widget_order.SCRUB] as ScrubMenuitem;
+ scrub.update_playstate(play_state);
+ this.owner.custom_items[PlayerController.widget_order.SCRUB].update(this.mpris_player.GetMetadata(),
+ ScrubMenuitem.attributes_format());
this.owner.custom_items[PlayerController.widget_order.METADATA].update(ht,
MetadataMenuitem.attributes_format());
debug("about to update the duration on the scrub bar");
- this.owner.custom_items[PlayerController.widget_order.SCRUB].update(this.mpris_player.GetMetadata(),
- ScrubMenuitem.attributes_format());
// temporary fix
- ScrubMenuitem scrub = this.owner.custom_items[PlayerController.widget_order.SCRUB] as ScrubMenuitem;
scrub.update_position(this.mpris_player.PositionGet());
}
-
-
}
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 00d7bb0..20cfc9e 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -126,9 +126,18 @@ public class Mpris2Controller : GLib.Object
debug("total time of track = %i", (int)total_time);
double new_time_position = total_time * position/100.0;
debug("new position = %f", (new_time_position * 1000));
- int32 trackid = this.mpris2_player.Metadata.lookup("trackid");
- debug("the trackid = %i", trackid);
- this.mpris2_player.SetPosition((int32)(new_time_position));
+
+ Value? v = this.mpris2_player.Metadata.lookup("trackid");
+ if(v != null){
+ if(v.holds (typeof (int))){
+ debug("the trackid = %i", v.get_int());
+ }
+ else if(v.holds (typeof (string))){
+ debug("the trackid = %s", v.get_string());
+ }
+ }
+
+ //this.mpris2_player.SetPosition((int32)(new_time_position));
ScrubMenuitem scrub = this.owner.custom_items[PlayerController.widget_order.SCRUB] as ScrubMenuitem;
scrub.update_position(this.mpris2_player.Position);
}
@@ -156,12 +165,18 @@ public class Mpris2Controller : GLib.Object
this.owner.custom_items[PlayerController.widget_order.METADATA].update(ht,
MetadataMenuitem.attributes_format());
debug("about to update the duration on the scrub bar");
-
- this.owner.custom_items[PlayerController.widget_order.SCRUB].update(this.mpris2_player.Metadata,
+ Value? v = ht.lookup("time");
+ if(v != null)
+ {
+ debug("with the duration of %i", (int)v.get_uint());
+ debug("with Position of %i", this.mpris2_player.Position);
+ }
+ this.owner.custom_items[PlayerController.widget_order.SCRUB].update(ht,
ScrubMenuitem.attributes_format());
ScrubMenuitem scrub = this.owner.custom_items[PlayerController.widget_order.SCRUB] as ScrubMenuitem;
scrub.update_position(this.mpris2_player.Position);
}
+
}
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index 352ea7f..daad42f 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -116,10 +116,8 @@ public class MusicPlayerBridge : GLib.Object
if(server_is_not_of_interest(type)) return;
string client_name = type.split(".")[1];
if (root_menu != null && client_name != null){
- registered_clients[client_name].vanish();
- registered_clients.remove(client_name);
- debug("Successively removed menu_item for client %s from registered_clients",
- client_name);
+ registered_clients[client_name].hibernate();
+ debug("Successively offlined client %s", client_name);
}
}
diff --git a/src/play-button.c b/src/play-button.c
index 94e6f98..2f3a553 100644
--- a/src/play-button.c
+++ b/src/play-button.c
@@ -28,7 +28,7 @@ Uses code from ctk
#include "play-button.h"
#define RECT_WIDTH 130.0f
-#define Y 5.0f
+#define Y 7.0f
#define X 37.0f
#define INNER_RADIUS 12.5
#define MIDDLE_RADIUS 13.5f
@@ -42,16 +42,16 @@ Uses code from ctk
#define TRI_HEIGHT 13.0f
#define TRI_OFFSET 6.0f
#define PREV_X 35.0f
-#define PREV_Y 11.0f
+#define PREV_Y 13.0f
#define NEXT_X 113.0f
-#define NEXT_Y 11.0f //prev_y
+#define NEXT_Y 13.0f //prev_y
#define PAUSE_WIDTH 21.0f
#define PAUSE_HEIGHT 27.0f
#define BAR_WIDTH 4.5f
#define BAR_HEIGHT 24.0f
#define BAR_OFFSET 10.0f
#define PAUSE_X 78.0f
-#define PAUSE_Y 5.0f
+#define PAUSE_Y 7.0f
#define PLAY_WIDTH 28.0f
#define PLAY_HEIGHT 29.0f
#define PLAY_PADDING 5.0f
diff --git a/src/player-controller.vala b/src/player-controller.vala
index 84d2374..33a5b1a 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -48,12 +48,15 @@ public class PlayerController : GLib.Object
private Dbusmenu.Menuitem root_menu;
public string name { get; set;}
public ArrayList<PlayerItem> custom_items;
- public Mpris2Controller mpris_adaptor;
+ public Mpris2Controller mpris2_adaptor;
+ public MprisController mpris_adaptor;
+ public bool mpris2;
public AppInfo? app_info { get; set;}
public int menu_offset { get; set;}
public PlayerController(Dbusmenu.Menuitem root, string client_name, int offset, state initial_state)
{
+ this.mpris2 = false;
this.root_menu = root;
this.name = format_client_name(client_name.strip());
this.custom_items = new ArrayList<PlayerItem>();
@@ -74,7 +77,7 @@ public class PlayerController : GLib.Object
public void activate()
{
this.establish_mpris_connection();
- this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, true);
+ //this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, true);
}
/*
@@ -103,19 +106,13 @@ public class PlayerController : GLib.Object
}
if(this.name == "Vlc"){
debug("establishing a vlc mpris controller");
- this.mpris_adaptor = new Mpris2Controller(this);
+ this.mpris2_adaptor = new Mpris2Controller(this);
+ this.mpris2 = true;
}
else{
- //this.mpris_adaptor = new MprisController(this);
- }
- // TODO refactor
- if(this.mpris_adaptor.connected() == true){
- debug("yup I'm connected");
- this.update_state(state.CONNECTED);
- }
- else{
- this.update_state(state.DISCONNECTED);
+ this.mpris_adaptor = new MprisController(this);
}
+ this.determine_state();
}
public void vanish()
@@ -125,8 +122,17 @@ public class PlayerController : GLib.Object
}
}
+ public void hibernate()
+ {
+ update_state(PlayerController.state.OFFLINE);
+ this.custom_items[widget_order.TRANSPORT].reset(TransportMenuitem.attributes_format());
+ this.custom_items[widget_order.METADATA].reset(MetadataMenuitem.attributes_format());
+ this.custom_items[widget_order.SCRUB].reset(ScrubMenuitem.attributes_format());
+ }
+
public void update_layout()
- {
+ {
+
if(this.current_state != state.CONNECTED){
this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE,
false);
@@ -136,12 +142,13 @@ public class PlayerController : GLib.Object
false);
this.custom_items[widget_order.PLAYLIST].property_set_bool(MENUITEM_PROP_VISIBLE,
false);
- return;
+ return;
}
-
debug("update layout - metadata %s", this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format()).to_string());
this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE,
this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format()));
+ //debug("metadata id %i", this.custom_items[widget_order.METADATA].id);
+
debug("update layout - scrub %s", this.custom_items[widget_order.SCRUB].populated(ScrubMenuitem.attributes_format()).to_string());
this.custom_items[widget_order.SCRUB].property_set_bool(MENUITEM_PROP_VISIBLE,
this.custom_items[widget_order.SCRUB].populated(ScrubMenuitem.attributes_format()));
@@ -151,7 +158,7 @@ public class PlayerController : GLib.Object
true);
this.custom_items[widget_order.PLAYLIST].property_set_bool(MENUITEM_PROP_VISIBLE,
- true);
+ true);
}
private void construct_widgets()
@@ -213,4 +220,48 @@ public class PlayerController : GLib.Object
return formatted;
}
+ // Temporarily we will need to handle to different mpris implemenations
+ // Do it for now - a couple of weeks should see this messy carry on out of
+ // the codebase.
+ public void set_track_position(double pos)
+ {
+ if(this.mpris2 == true){
+ this.mpris2_adaptor.set_position(pos);
+ }
+ else{
+ this.mpris_adaptor.set_position(pos);
+ }
+ }
+
+ public void transport_update(TransportMenuitem.action update)
+ {
+ if(this.mpris2 == true){
+ this.mpris2_adaptor.transport_event(update);
+ }
+ else{
+ this.mpris_adaptor.transport_event(update);
+ }
+ }
+
+ public void determine_state()
+ {
+ if(this.mpris2 == true){
+ if(this.mpris2_adaptor.connected() == true){
+ debug("yup I'm connected");
+ this.update_state(state.CONNECTED);
+ }
+ else{
+ this.update_state(state.DISCONNECTED);
+ }
+ }
+ else{
+ if(this.mpris_adaptor.connected() == true){
+ debug("yup I'm connected");
+ this.update_state(state.CONNECTED);
+ }
+ else{
+ this.update_state(state.DISCONNECTED);
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/src/player-item.vala b/src/player-item.vala
index 288ac47..e5d8bfc 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -79,9 +79,11 @@ public class PlayerItem : Dbusmenu.Menuitem
this.property_set_int(property, (int)v.get_uint());
}
else if(v.holds (typeof (bool))){
+ debug("with value : %s", v.get_boolean().to_string());
this.property_set_bool(property, v.get_boolean());
}
}
+
if(this.property_get_bool(MENUITEM_PROP_VISIBLE) == false){
this.property_set_bool(MENUITEM_PROP_VISIBLE, true);
}
diff --git a/src/scrub-menu-item.vala b/src/scrub-menu-item.vala
index ca81c38..e220612 100644
--- a/src/scrub-menu-item.vala
+++ b/src/scrub-menu-item.vala
@@ -32,13 +32,18 @@ public class ScrubMenuitem : PlayerItem
public override void handle_event(string name, GLib.Value input_value, uint timestamp)
{
debug("handle_event for owner %s with value: %f", this.owner.name, input_value.get_double());
- this.owner.mpris_adaptor.set_position(input_value.get_double());
+ this.owner.set_track_position(input_value.get_double());
}
public void update_position(int32 new_position)
{
this.property_set_int(MENUITEM_POSITION, new_position);
}
+
+ public void update_playstate(int state)
+ {
+ this.property_set_int(MENUITEM_PLAY_STATE, state);
+ }
public static HashSet<string> attributes_format()
{
diff --git a/src/scrub-widget.c b/src/scrub-widget.c
index 52d7b83..a1d45d5 100644
--- a/src/scrub-widget.c
+++ b/src/scrub-widget.c
@@ -174,7 +174,7 @@ scrub_widget_check_play_state(ScrubWidget* self)
ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(self);
gint play_state = dbusmenu_menuitem_property_get_int(priv->twin_item,
DBUSMENU_SCRUB_MENUITEM_PLAY_STATE);
-
+ g_debug("play-state = %i", play_state);
if(play_state == 0){
g_debug("START TIMELINE");
ido_timeline_start(priv->time_line);
diff --git a/src/sound-service.c b/src/sound-service.c
index 16fa87c..8768cd3 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -42,8 +42,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 3d6dcdd..45c2692 100644
--- a/src/transport-menu-item.vala
+++ b/src/transport-menu-item.vala
@@ -45,7 +45,7 @@ public class TransportMenuitem : PlayerItem
int input = input_value.get_int();
debug("handle_event with value %s", input.to_string());
debug("transport owner name = %s", this.owner.name);
- this.owner.mpris_adaptor.transport_event((action)input);
+ this.owner.transport_update((action)input);
}
public static HashSet<string> attributes_format()