aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/familiar-players-db.vala24
-rw-r--r--src/metadata-menu-item.vala6
-rw-r--r--src/metadata-widget.c10
-rw-r--r--src/mpris2-controller.vala12
-rw-r--r--src/mpris2-watcher.vala16
-rw-r--r--src/music-player-bridge.vala84
-rw-r--r--src/player-controller.vala14
-rw-r--r--src/sound-service.c4
8 files changed, 84 insertions, 86 deletions
diff --git a/src/familiar-players-db.vala b/src/familiar-players-db.vala
index 7012b5a..96d690a 100644
--- a/src/familiar-players-db.vala
+++ b/src/familiar-players-db.vala
@@ -160,29 +160,5 @@ public class FamiliarPlayersDB : GLib.Object
return this.players_DB.keys;
}
- public static string? fetch_icon_name(string desktop_path)
- {
- KeyFile desktop_keyfile = new KeyFile ();
- try{
- desktop_keyfile.load_from_file (desktop_path, KeyFileFlags.NONE);
- }
- catch(GLib.FileError error){
- warning("Error loading keyfile - FileError");
- return null;
- }
- catch(GLib.KeyFileError error){
- warning("Error loading keyfile - KeyFileError");
- return null;
- }
-
- try{
- return desktop_keyfile.get_string (KeyFileDesktop.GROUP,
- KeyFileDesktop.KEY_ICON);
- }
- catch(GLib.KeyFileError error){
- warning("Error trying to fetch the icon name from the keyfile");
- return null;
- }
- }
} \ No newline at end of file
diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala
index e84e902..741bb9f 100644
--- a/src/metadata-menu-item.vala
+++ b/src/metadata-menu-item.vala
@@ -99,10 +99,10 @@ public class MetadataMenuitem : PlayerItem
{
File art_file = File.new_for_uri(uri);
if(art_file.is_native() == true){
- string path;
+ string path;
try{
- path = Filename.from_uri(uri.strip());
- this.property_set(prop, path);
+ path = Filename.from_uri ( uri.strip() );
+ this.property_set ( prop, path );
}
catch(ConvertError e){
warning("Problem converting URI %s to file path",
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index 1e2c891..191e134 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -194,21 +194,23 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user
if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE ||
priv->theme_change_occured == TRUE){
priv->theme_change_occured = FALSE;
- GdkPixbuf* pixbuf;
- pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL);
+ GdkPixbuf* orig_pixbuf;
+ orig_pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL);
//g_debug("metadata_load_new_image -> pixbuf from %s",
// priv->image_path->str);
- if(GDK_IS_PIXBUF(pixbuf) == FALSE){
+ if(GDK_IS_PIXBUF(orig_pixbuf) == FALSE){
//g_debug("problem loading the downloaded image just use the placeholder instead");
draw_album_art_placeholder(metadata);
return TRUE;
}
- pixbuf = gdk_pixbuf_scale_simple(pixbuf,60, 60, GDK_INTERP_BILINEAR);
+ GdkPixbuf* pixbuf;
+ pixbuf = gdk_pixbuf_scale_simple(orig_pixbuf,60, 60, GDK_INTERP_BILINEAR);
gtk_image_set_from_pixbuf(GTK_IMAGE(priv->album_art), pixbuf);
g_string_erase(priv->old_image_path, 0, -1);
g_string_overwrite(priv->old_image_path, 0, priv->image_path->str);
g_object_unref(pixbuf);
+ g_object_unref(orig_pixbuf);
}
return FALSE;
}
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 59e3122..42d08c9 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -31,7 +31,6 @@ using Dbusmenu;
*/
public class Mpris2Controller : GLib.Object
{
- public static const string root_interface = "org.mpris.MediaPlayer2" ;
public MprisRoot mpris2_root {get; construct;}
public MprisPlayer player {get; construct;}
public FreeDesktopProperties properties_interface {get; construct;}
@@ -46,16 +45,16 @@ public class Mpris2Controller : GLib.Object
construct{
try {
this.mpris2_root = Bus.get_proxy_sync ( BusType.SESSION,
- root_interface.concat(".").concat(this.owner.mpris_name),
+ this.owner.dbus_name,
"/org/mpris/MediaPlayer2");
this.player = Bus.get_proxy_sync ( BusType.SESSION,
- root_interface.concat(".").concat(this.owner.mpris_name),
+ this.owner.dbus_name,
"/org/mpris/MediaPlayer2" );
this.properties_interface = Bus.get_proxy_sync ( BusType.SESSION,
"org.freedesktop.Properties.PropertiesChanged",
"/org/mpris/MediaPlayer2" );
- this.properties_interface.PropertiesChanged += property_changed_cb;
+ this.properties_interface.PropertiesChanged.connect ( property_changed_cb );
}
catch (IOError e) {
error("Problems connecting to the session bus - %s", e.message);
@@ -66,8 +65,9 @@ public class Mpris2Controller : GLib.Object
HashTable<string, Variant?> changed_properties,
string[] invalid )
{
- debug("properties-changed for interface %s and owner %s", interface_source, this.owner.mpris_name);
- if(changed_properties == null || interface_source.has_prefix(this.root_interface) == false ){
+ debug("properties-changed for interface %s and owner %s", interface_source, this.owner.dbus_name);
+ if ( changed_properties == null ||
+ interface_source.has_prefix ( Mpris2Watcher.MPRIS_PREFIX ) == false ){
warning("Property-changed hash is null or this is an interface that doesn't concerns us");
return;
}
diff --git a/src/mpris2-watcher.vala b/src/mpris2-watcher.vala
index d154fcb..7814975 100644
--- a/src/mpris2-watcher.vala
+++ b/src/mpris2-watcher.vala
@@ -20,22 +20,22 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
[DBus (name = "org.freedesktop.DBus")]
public interface FreeDesktopObject: Object {
public abstract async string[] list_names() throws IOError;
- public abstract signal void name_owner_changed (string name,
- string old_owner,
- string new_owner);
+ public abstract signal void name_owner_changed ( string name,
+ string old_owner,
+ string new_owner );
}
public class Mpris2Watcher : GLib.Object
{
private const string FREEDESKTOP_SERVICE = "org.freedesktop.DBus";
private const string FREEDESKTOP_OBJECT = "/org/freedesktop/DBus";
- private const string MPRIS_PREFIX = "org.mpris.MediaPlayer2.";
+ public const string MPRIS_PREFIX = "org.mpris.MediaPlayer2.";
private const string MPRIS_MEDIA_PLAYER_PATH = "/org/mpris/MediaPlayer2";
FreeDesktopObject fdesktop_obj;
- public signal void client_appeared ( string desktop_name );
- public signal void client_disappeared ( string mpris_root_interface );
+ public signal void client_appeared ( string desktop_file_name, string dbus_name );
+ public signal void client_disappeared ( string dbus_name );
public Mpris2Watcher ()
{
@@ -72,7 +72,7 @@ public class Mpris2Watcher : GLib.Object
}
else if (previous_owner == "" && current_owner != "") {
debug ("Client '%s' has appeared", name);
- client_appeared (mpris2_root.DesktopEntry);
+ client_appeared (mpris2_root.DesktopEntry, name);
}
}
@@ -109,7 +109,7 @@ public class Mpris2Watcher : GLib.Object
if (address.has_prefix (MPRIS_PREFIX)){
MprisRoot? mpris2_root = this.create_mpris_root(address);
if (mpris2_root == null) return;
- client_appeared (mpris2_root.DesktopEntry);
+ client_appeared (mpris2_root.DesktopEntry, address);
}
}
}
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index 5133770..0d1b0e4 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -25,17 +25,15 @@ public class MusicPlayerBridge : GLib.Object
{
private Dbusmenu.Menuitem root_menu;
private HashMap<string, PlayerController> registered_clients;
- private FamiliarPlayersDB playersDB;
private Mpris2Watcher watcher;
private const string DESKTOP_PREFIX = "/usr/share/applications/";
public MusicPlayerBridge()
{
- playersDB = new FamiliarPlayersDB();
registered_clients = new HashMap<string, PlayerController> ();
}
- private void try_to_add_inactive_familiar_clients(){
+ /*private void try_to_add_inactive_familiar_clients(){
foreach(string app in this.playersDB.records()){
if(app == null){
warning("App string in keyfile is null therefore moving on to next player");
@@ -61,7 +59,7 @@ public class MusicPlayerBridge : GLib.Object
PlayerController.state.OFFLINE);
this.registered_clients.set(mpris_key, ctrl);
}
- }
+ }*/
private int calculate_menu_position()
{
@@ -73,20 +71,15 @@ public class MusicPlayerBridge : GLib.Object
}
}
- /*public void on_server_added(Indicate.ListenerServer object, string type)
+ public void client_has_become_available ( string desktop, string dbus_name )
{
- debug("MusicPlayerBridge -> on_server_added with value %s", type);
- if(server_is_not_of_interest(type)) return;
- if ( this.root_menu != null ){
- listener_get_server_property_cb cb = (listener_get_server_property_cb)desktop_info_callback;
- this.listener.server_get_desktop(object, cb, this);
+ if (desktop == null || desktop == ""){
+ warning("Client %s attempting to register without desktop entry being set on the mpris root",
+ dbus_name);
+ return;
}
- }*/
-
- public void client_has_become_available ( string desktop_file_name )
- {
- debug ( "client_has_become_available %s", desktop_file_name );
- string path = DESKTOP_PREFIX.concat ( desktop_file_name.concat( ".desktop" ) );
+ debug ( "client_has_become_available %s", desktop );
+ string path = DESKTOP_PREFIX.concat ( desktop.concat( ".desktop" ) );
AppInfo? app_info = create_app_info ( path );
if ( app_info == null ){
warning ( "Could not create app_info for path %s \n Getting out of here ", path);
@@ -94,25 +87,24 @@ public class MusicPlayerBridge : GLib.Object
}
var mpris_key = determine_key ( path );
-
- if ( this.playersDB.already_familiar ( path ) == false ){
- debug("New client has registered that we have not seen before: %s", desktop_file_name );
- this.playersDB.insert ( path );
+ // Are we sure clients will appear like this with the new registration method in place.
+ if ( this.registered_clients.has_key (mpris_key) == false ){
+ debug("New client has registered that we have not seen before: %s", desktop );
PlayerController ctrl = new PlayerController ( this.root_menu,
app_info,
- mpris_key,
- playersDB.fetch_icon_name(path),
+ dbus_name,
+ this.fetch_icon_name(path),
this.calculate_menu_position(),
PlayerController.state.READY );
- this.registered_clients.set ( mpris_key, ctrl );
+ this.registered_clients.set ( mpris_key, ctrl );
debug ( "successfully created appinfo and instance from path and set it on the respective instance" );
- }
- else{
- this.registered_clients[mpris_key].update_state ( PlayerController.state.READY );
- this.registered_clients[mpris_key].activate ( );
- debug("Ignoring desktop file path callback because the db cache file has it already: %s \n", path);
- }
}
+ else{
+ this.registered_clients[mpris_key].update_state ( PlayerController.state.READY );
+ this.registered_clients[mpris_key].activate ( );
+ debug("Ignoring desktop file path callback because the db cache file has it already: %s \n", path);
+ }
+ }
public void client_has_vanished ( string mpris_root_interface )
{
@@ -127,16 +119,15 @@ public class MusicPlayerBridge : GLib.Object
}
}
- public void set_root_menu_item(Dbusmenu.Menuitem menu)
+ public void set_root_menu_item ( Dbusmenu.Menuitem menu )
{
this.root_menu = menu;
- this.try_to_add_inactive_familiar_clients();
this.watcher = new Mpris2Watcher ();
this.watcher.client_appeared += this.client_has_become_available;
this.watcher.client_disappeared += this.client_has_vanished;
}
- public static AppInfo? create_app_info ( string path )
+ private static AppInfo? create_app_info ( string path )
{
DesktopAppInfo info = new DesktopAppInfo.from_filename ( path ) ;
if ( path == null || info == null ){
@@ -147,6 +138,35 @@ public class MusicPlayerBridge : GLib.Object
return app_info;
}
+ private static string? fetch_icon_name(string desktop_path)
+ {
+ KeyFile desktop_keyfile = new KeyFile ();
+ try{
+ desktop_keyfile.load_from_file (desktop_path, KeyFileFlags.NONE);
+ }
+ catch(GLib.FileError error){
+ warning("Error loading keyfile - FileError");
+ return null;
+ }
+ catch(GLib.KeyFileError error){
+ warning("Error loading keyfile - KeyFileError");
+ return null;
+ }
+
+ try{
+ return desktop_keyfile.get_string (KeyFileDesktop.GROUP,
+ KeyFileDesktop.KEY_ICON);
+ }
+ catch(GLib.KeyFileError error){
+ warning("Error trying to fetch the icon name from the keyfile");
+ return null;
+ }
+ }
+
+ /*
+ Messy but necessary method to consolidate desktop filesnames and mpris dbus names
+ into the one single word string (used as the key in the players hash).
+ */
private static string? determine_key(owned string path)
{
var tokens = path.split( "/" );
diff --git a/src/player-controller.vala b/src/player-controller.vala
index 0b540f9..9e00258 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -44,7 +44,7 @@ public class PlayerController : GLib.Object
private Dbusmenu.Menuitem root_menu;
public string name { get; set;}
- public string mpris_name { get; set;}
+ public string dbus_name { get; set;}
public ArrayList<PlayerItem> custom_items;
public Mpris2Controller mpris_bridge;
public AppInfo? app_info { get; set;}
@@ -53,21 +53,21 @@ public class PlayerController : GLib.Object
public PlayerController(Dbusmenu.Menuitem root,
GLib.AppInfo app,
- string mpris_name,
+ string dbus_name,
string icon_name,
int offset,
state initial_state)
{
this.root_menu = root;
this.app_info = app;
+ this.dbus_name = dbus_name;
this.name = format_player_name(this.app_info.get_name());
- this.mpris_name = mpris_name;
this.icon_name = icon_name;
this.custom_items = new ArrayList<PlayerItem>();
this.current_state = initial_state;
this.menu_offset = offset;
- construct_widgets();
- establish_mpris_connection();
+ this.construct_widgets();
+ this.establish_mpris_connection();
this.update_layout();
}
@@ -162,7 +162,7 @@ public class PlayerController : GLib.Object
foreach(PlayerItem item in this.custom_items){
root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item));
}
- }
+ }
private static string format_player_name(owned string app_info_name)
{
@@ -173,8 +173,8 @@ public class PlayerController : GLib.Object
}
if(result.length > 1){
result = result.up(1).concat(result.slice(1, result.length));
- debug("PlayerController->format_player_name - : %s", result);
}
+ debug("PlayerController->format_player_name - : %s", result);
return result;
}
diff --git a/src/sound-service.c b/src/sound-service.c
index 98f1881..defcb94 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -40,8 +40,8 @@ service_shutdown (IndicatorService *service, gpointer user_data)
{
if (mainloop != NULL) {
g_debug("Service shutdown !");
- close_pulse_activites();
- g_main_loop_quit(mainloop);
+ //close_pulse_activites();
+ //g_main_loop_quit(mainloop);
}
return;
}