aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-07-09 16:37:51 +0100
committerConor Curran <conor.curran@canonical.com>2010-07-09 16:37:51 +0100
commita7cd627d578066b3383629dee572aa6385a33281 (patch)
tree5c92ad2738bd9faed1f120ea0ee59e4bbd9a22e3 /src
parentb0a09afe59a904ce4b4e90e58d933ad1f0b036d9 (diff)
downloadayatana-indicator-sound-a7cd627d578066b3383629dee572aa6385a33281.tar.gz
ayatana-indicator-sound-a7cd627d578066b3383629dee572aa6385a33281.tar.bz2
ayatana-indicator-sound-a7cd627d578066b3383629dee572aa6385a33281.zip
album art bug fixed
Diffstat (limited to 'src')
-rw-r--r--src/indicator-sound.c4
-rw-r--r--src/mpris-controller-v2.vala4
-rw-r--r--src/mpris-controller.vala40
-rw-r--r--src/music-player-bridge.vala47
-rw-r--r--src/player-controller.vala20
-rw-r--r--src/player-item.vala18
-rw-r--r--src/sound-service.c4
-rw-r--r--src/transport-menu-item.vala1
8 files changed, 82 insertions, 56 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 8be97b4..a2d9762 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -366,10 +366,10 @@ new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmenu
title = title_widget_new (newitem);
GtkMenuItem *menu_title_widget = GTK_MENU_ITEM(title);
- dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_title_widget, parent);
-
gtk_widget_show_all(title);
+ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_title_widget, parent);
+
return TRUE;
}
diff --git a/src/mpris-controller-v2.vala b/src/mpris-controller-v2.vala
index 0392cfc..efb5084 100644
--- a/src/mpris-controller-v2.vala
+++ b/src/mpris-controller-v2.vala
@@ -21,8 +21,8 @@ using Gee;
public class MprisControllerV2 : MprisController
{
- public MprisControllerV2(string name, PlayerController controller){
- base(name, controller, "org.mpris.MediaPlayer.Player");
+ public MprisControllerV2(PlayerController ctrl, string inter="org.mpris.MediaPlayer.Player"){
+ Object(owner: ctrl, mpris_interface: inter);
}
}
diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala
index 2194d44..8dd0cc9 100644
--- a/src/mpris-controller.vala
+++ b/src/mpris-controller.vala
@@ -22,32 +22,42 @@ using Gee;
public class MprisController : GLib.Object
{
- private DBus.Connection connection;
- public dynamic DBus.Object mpris_player;
- private PlayerController controller;
- struct status {
+ private DBus.Connection connection;
+ public dynamic DBus.Object mpris_player{get; construct;}
+ public PlayerController owner {get; construct;}
+ public string mpris_interface {get; construct;}
+ private string name;
+
+
+ struct status {
public int32 playback;
//public int32 shuffle; // Not used just yet
//public int32 repeat;
//public int32 endless;
}
- public MprisController(string name, PlayerController controller, string mpris_interface="org.freedesktop.MediaPlayer"){
+ public MprisController(PlayerController ctrl, string inter="org.freedesktop.MediaPlayer"){
+ Object(owner: ctrl, mpris_interface: inter);
+ }
+
+ construct{
try {
this.connection = DBus.Bus.get (DBus.BusType.SESSION);
} catch (Error e) {
error("Problems connecting to the session bus - %s", e.message);
}
- 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 = this.connection.get_object ("org.mpris.".concat(this.owner.name.down()) , "/Player", this.mpris_interface);
+
+ debug("just attempting to establish an mpris connection to %s, %s, %s", "org.mpris.".concat(this.owner.name.down()) , "/Player", this.mpris_interface);
+
+ this.mpris_player.TrackChange += onTrackChange;
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(),
+ (this.owner.custom_items[this.owner.TRANSPORT] as TransportMenuitem).change_play_state(play_state);
+ this.owner.custom_items[this.owner.METADATA].update(this.mpris_player.GetMetadata(),
MetadataMenuitem.attributes_format());
}
@@ -56,8 +66,8 @@ public class MprisController : GLib.Object
private void onTrackChange(dynamic DBus.Object mpris_client, HashTable<string,Value?> ht)
{
debug("onTrackChange");
- this.controller.custom_items[this.controller.METADATA].reset(MetadataMenuitem.attributes_format());
- this.controller.custom_items[this.controller.METADATA].update(ht,
+ this.owner.custom_items[this.owner.METADATA].reset(MetadataMenuitem.attributes_format());
+ this.owner.custom_items[this.owner.METADATA].update(ht,
MetadataMenuitem.attributes_format());
}
@@ -84,10 +94,10 @@ public class MprisController : GLib.Object
}
}
else if(command == TransportMenuitem.action.PREVIOUS){
- this.mpris_player.previous();
+ this.mpris_player.Prev();
}
else if(command == TransportMenuitem.action.NEXT){
- this.mpris_player.next();
+ this.mpris_player.Next();
}
}
@@ -107,7 +117,7 @@ public class MprisController : GLib.Object
Value v = Value(typeof(int));
v.set_int(play_state);
ht.insert("state", v);
- this.controller.custom_items[this.controller.TRANSPORT].update(ht, TransportMenuitem.attributes_format());
+ this.owner.custom_items[this.owner.TRANSPORT].update(ht, TransportMenuitem.attributes_format());
}
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index d771192..03947d0 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -52,28 +52,34 @@ public class MusicPlayerBridge : GLib.Object
warning("App string in keyfile is null therefore moving on to next player");
continue;
}
- try{
- DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
- if(info == null){
- warning("Could not create a desktopappinfo instance from app: %s", app);
- continue;
- }
- GLib.AppInfo app_info = info as GLib.AppInfo;
- PlayerController ctrl = new PlayerController(this.root_menu,
- app_info.get_name(),
- PlayerController.state.OFFLINE);
- ctrl.set("app_info", app_info);
- this.registered_clients.set(app_info.get_name().down().strip(), ctrl);
- debug("Created a player controller for %s which was found in the cache file", app_info.get_name().down().strip());
- count += 1;
- }
- catch(Error er){
- warning("desktop path in cache is not formatted as we have anticipated");
+ DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
+ if(info == null){
+ warning("Could not create a desktopappinfo instance from app: %s", app);
+ continue;
}
+ GLib.AppInfo app_info = info as GLib.AppInfo;
+ PlayerController ctrl = new PlayerController(this.root_menu,
+ app_info.get_name(),
+ calculate_menu_position(),
+ PlayerController.state.OFFLINE);
+ ctrl.set("app_info", app_info);
+ this.registered_clients.set(app_info.get_name().down().strip(), ctrl);
+ debug("Created a player controller for %s which was found in the cache file", app_info.get_name().down().strip());
+ count += 1;
}
break;
}
}
+
+ private int calculate_menu_position()
+ {
+ if(this.registered_clients.size == 0){
+ return 2;
+ }
+ else{
+ return (2 + (this.registered_clients.size * 3));
+ }
+ }
public void on_server_added(Indicate.ListenerServer object, string type)
{
@@ -89,8 +95,13 @@ public class MusicPlayerBridge : GLib.Object
}
//else init a new one
else{
- PlayerController ctrl = new PlayerController(root_menu, client_name, PlayerController.state.READY);
+
+ PlayerController ctrl = new PlayerController(root_menu,
+ client_name,
+ calculate_menu_position(),
+ PlayerController.state.READY);
registered_clients.set(client_name, ctrl);
+
debug("New Client of name %s has successfully registered with us", client_name);
}
// irregardless check that it has a desktop file if not kick off a request for it
diff --git a/src/player-controller.vala b/src/player-controller.vala
index 3fb4750..d7fd422 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -42,13 +42,16 @@ public class PlayerController : GLib.Object
public ArrayList<PlayerItem> custom_items;
public MprisController mpris_adaptor;
public AppInfo? app_info { get; set;}
+ public int menu_offset { get; set;}
- public PlayerController(Dbusmenu.Menuitem root, string client_name, state initial_state)
+ public PlayerController(Dbusmenu.Menuitem root, string client_name, int offset, state initial_state)
{
this.root_menu = root;
this.name = format_client_name(client_name.strip());
this.custom_items = new ArrayList<PlayerItem>();
this.update_state(initial_state);
+ this.menu_offset = offset;
+ debug("offset = %i", offset);
construct_widgets();
establish_mpris_connection();
update_layout();
@@ -89,13 +92,17 @@ public class PlayerController : GLib.Object
debug("establish_mpris_connection - Not ready to connect");
return;
}
+
if(this.name == "Vlc"){
- this.mpris_adaptor = new MprisControllerV2(this.name, this);
+ debug("establishing a vlc mpris controller");
+ this.mpris_adaptor = new MprisController(this, "org.mpris.MediaPlayer.Player");
}
else{
- this.mpris_adaptor = new MprisController(this.name, this);
+ this.mpris_adaptor = new MprisController(this);
}
+
if(this.mpris_adaptor.connected() == true){
+ debug("yup I'm connected");
this.update_state(state.CONNECTED);
}
else{
@@ -120,6 +127,10 @@ public class PlayerController : GLib.Object
debug("about the set the visibility on both the transport and metadata widget to %s", visibility.to_string());
this.custom_items[TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, visibility);
this.custom_items[METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, visibility);
+ // DEBUG
+ if(this.mpris_adaptor == null){
+ warning("Why is the mpris object null");
+ }
}
@@ -140,9 +151,8 @@ public class PlayerController : GLib.Object
TransportMenuitem transport_item = new TransportMenuitem(this);
this.custom_items.add(transport_item);
- int offset = 2;
foreach(PlayerItem item in this.custom_items){
- root_menu.child_add_position(item, offset + this.custom_items.index_of(item));
+ root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item));
}
}
diff --git a/src/player-item.vala b/src/player-item.vala
index 171c140..4f95b0c 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -55,8 +55,12 @@ public class PlayerItem : Dbusmenu.Menuitem
Value? v = data.lookup(search_key);
if (v.holds (typeof (string))){
- debug("with value : %s", v.get_string());
- this.property_set(property, this.sanitize_string(v.get_string()));
+ string update = v.get_string().strip();
+ debug("with value : %s", update);
+ if(property.contains("arturl")){
+ update = Filename.from_uri(update.strip());
+ }
+ this.property_set(property, update);
}
else if (v.holds (typeof (int))){
debug("with value : %i", v.get_int());
@@ -80,15 +84,5 @@ public class PlayerItem : Dbusmenu.Menuitem
return true;
}
- public static string sanitize_string(string st)
- {
- string result = st.strip();
- if(result.has_prefix("file:///")){
- result = result.slice(7, result.len());
- }
- debug("Sanitize string - result = %s", result);
- return result;
- }
-
}
diff --git a/src/sound-service.c b/src/sound-service.c
index 8f4e941..a5f3941 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -43,8 +43,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 e0710a8..33f1d9d 100644
--- a/src/transport-menu-item.vala
+++ b/src/transport-menu-item.vala
@@ -44,6 +44,7 @@ public class TransportMenuitem : PlayerItem
int input = input_value.get_int();
debug("handle_event with value %s", input.to_string());
// Fire and forgot - the widget would not have sent it over it didn't think it was relevant.
+ debug("transport owner name = %s", this.owner.name);
this.owner.mpris_adaptor.transport_event((action)input);
}