diff options
Diffstat (limited to 'src/music-player-bridge.c')
-rw-r--r-- | src/music-player-bridge.c | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/src/music-player-bridge.c b/src/music-player-bridge.c index 3746bf6..dddaa1a 100644 --- a/src/music-player-bridge.c +++ b/src/music-player-bridge.c @@ -118,13 +118,13 @@ static void _music_player_bridge_on_server_removed_indicate_listener_server_remo static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlayerBridge* self); GeeSet* familiar_players_db_records (FamiliarPlayersDB* self); static char* music_player_bridge_truncate_player_name (char* app_info_name); +static char* music_player_bridge_determine_key (char* path); static gint music_player_bridge_calculate_menu_position (MusicPlayerBridge* self); GType player_controller_state_get_type (void) G_GNUC_CONST; -PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state); -PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state); +PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, const char* mpris_name, gint offset, PlayerControllerstate initial_state); +PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, const char* mpris_name, gint offset, PlayerControllerstate initial_state); void player_controller_set_app_info (PlayerController* self, GAppInfo* value); GAppInfo* player_controller_get_app_info (PlayerController* self); -static char* music_player_bridge_determine_key (char* path); #define PLAYER_CONTROLLER_WIDGET_QUANTITY 4 static gboolean music_player_bridge_server_is_not_of_interest (MusicPlayerBridge* self, const char* type); static void music_player_bridge_desktop_info_callback (MusicPlayerBridge* self, IndicateListenerServer* server, char* path, void* data); @@ -190,9 +190,10 @@ static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlaye GDesktopAppInfo* _tmp2_; GAppInfo* app_info; char* _tmp3_; - PlayerController* _tmp4_; + char* _tmp4_; + PlayerController* _tmp5_; PlayerController* ctrl; - char* _tmp5_; + char* _tmp6_; if (!gee_iterator_next (_app_it)) { break; } @@ -213,13 +214,13 @@ static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlaye continue; } app_info = _g_object_ref0 ((_tmp2_ = info, G_IS_APP_INFO (_tmp2_) ? ((GAppInfo*) _tmp2_) : NULL)); - ctrl = (_tmp4_ = player_controller_new (self->priv->root_menu, _tmp3_ = music_player_bridge_truncate_player_name (g_strdup (g_app_info_get_name (app_info))), music_player_bridge_calculate_menu_position (self), PLAYER_CONTROLLER_STATE_OFFLINE), _g_free0 (_tmp3_), _tmp4_); + ctrl = (_tmp5_ = player_controller_new (self->priv->root_menu, _tmp3_ = music_player_bridge_truncate_player_name (g_strdup (g_app_info_get_name (app_info))), _tmp4_ = music_player_bridge_determine_key (g_strdup (app)), music_player_bridge_calculate_menu_position (self), PLAYER_CONTROLLER_STATE_OFFLINE), _g_free0 (_tmp4_), _g_free0 (_tmp3_), _tmp5_); player_controller_set_app_info (ctrl, app_info); if (player_controller_get_app_info (ctrl) == NULL) { - g_warning ("music-player-bridge.vala:65: for some reason the app info is null"); + g_warning ("music-player-bridge.vala:66: for some reason the app info is null"); } - gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, _tmp5_ = music_player_bridge_determine_key (g_strdup (app)), ctrl); - _g_free0 (_tmp5_); + gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, _tmp6_ = music_player_bridge_determine_key (g_strdup (app)), ctrl); + _g_free0 (_tmp6_); _g_object_unref0 (ctrl); _g_object_unref0 (app_info); _g_object_unref0 (info); @@ -246,7 +247,7 @@ static gint music_player_bridge_calculate_menu_position (MusicPlayerBridge* self void music_player_bridge_on_server_added (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type) { g_return_if_fail (self != NULL); g_return_if_fail (type != NULL); - g_debug ("music-player-bridge.vala:82: MusicPlayerBridge -> on_server_added with" \ + g_debug ("music-player-bridge.vala:83: MusicPlayerBridge -> on_server_added with" \ " value %s", type); if (music_player_bridge_server_is_not_of_interest (self, type)) { return; @@ -285,27 +286,29 @@ static void music_player_bridge_desktop_info_callback (MusicPlayerBridge* self, _tmp1_ = FALSE; } if (_tmp1_) { - PlayerController* ctrl; char* _tmp2_; - g_debug ("music-player-bridge.vala:98: About to store desktop file path: %s", path); + PlayerController* _tmp3_; + PlayerController* ctrl; + char* _tmp4_; + g_debug ("music-player-bridge.vala:99: About to store desktop file path: %s", path); familiar_players_db_insert (bridge->priv->playersDB, path); - ctrl = player_controller_new (bridge->priv->root_menu, name, music_player_bridge_calculate_menu_position (bridge), PLAYER_CONTROLLER_STATE_READY); + ctrl = (_tmp3_ = player_controller_new (bridge->priv->root_menu, name, _tmp2_ = music_player_bridge_determine_key (g_strdup (path)), music_player_bridge_calculate_menu_position (bridge), PLAYER_CONTROLLER_STATE_READY), _g_free0 (_tmp2_), _tmp3_); g_object_set ((GObject*) ctrl, "app_info", app_info, NULL); - gee_abstract_map_set ((GeeAbstractMap*) bridge->priv->registered_clients, _tmp2_ = music_player_bridge_determine_key (g_strdup (path)), ctrl); - _g_free0 (_tmp2_); - g_debug ("music-player-bridge.vala:106: successfully created appinfo and instanc" \ + gee_abstract_map_set ((GeeAbstractMap*) bridge->priv->registered_clients, _tmp4_ = music_player_bridge_determine_key (g_strdup (path)), ctrl); + _g_free0 (_tmp4_); + g_debug ("music-player-bridge.vala:108: successfully created appinfo and instanc" \ "e from path and set it on the respective instance"); _g_object_unref0 (ctrl); } else { char* key; - PlayerController* _tmp3_; - PlayerController* _tmp4_; + PlayerController* _tmp5_; + PlayerController* _tmp6_; key = music_player_bridge_determine_key (g_strdup (path)); - player_controller_update_state (_tmp3_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, key), PLAYER_CONTROLLER_STATE_READY); - _g_object_unref0 (_tmp3_); - player_controller_activate (_tmp4_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, key)); - _g_object_unref0 (_tmp4_); - g_debug ("music-player-bridge.vala:112: Ignoring desktop file path callback beca" \ + player_controller_update_state (_tmp5_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, key), PLAYER_CONTROLLER_STATE_READY); + _g_object_unref0 (_tmp5_); + player_controller_activate (_tmp6_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, key)); + _g_object_unref0 (_tmp6_); + g_debug ("music-player-bridge.vala:114: Ignoring desktop file path callback beca" \ "use the db cache file has it already: %s", path); _g_free0 (key); } @@ -319,7 +322,7 @@ static void music_player_bridge_desktop_info_callback (MusicPlayerBridge* self, void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type) { g_return_if_fail (self != NULL); g_return_if_fail (type != NULL); - g_debug ("music-player-bridge.vala:118: MusicPlayerBridge -> on_server_removed w" \ + g_debug ("music-player-bridge.vala:120: MusicPlayerBridge -> on_server_removed w" \ "ith value %s", type); if (music_player_bridge_server_is_not_of_interest (self, type)) { return; @@ -331,12 +334,12 @@ void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateLis char** _tmp0_; char** tmp; tmp = (_tmp1_ = _tmp0_ = g_strsplit (type, ".", 0), tmp_length1 = _vala_array_length (_tmp0_), _tmp_size_ = tmp_length1, _tmp1_); - g_debug ("music-player-bridge.vala:122: attempt to remove %s", tmp[tmp_length1 - 1]); + g_debug ("music-player-bridge.vala:124: attempt to remove %s", tmp[tmp_length1 - 1]); if (tmp_length1 > 0) { PlayerController* _tmp2_; player_controller_hibernate (_tmp2_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, tmp[tmp_length1 - 1])); _g_object_unref0 (_tmp2_); - g_debug ("music-player-bridge.vala:125: Successively offlined client %s", tmp[tmp_length1 - 1]); + g_debug ("music-player-bridge.vala:127: Successively offlined client %s", tmp[tmp_length1 - 1]); } tmp = (_vala_array_free (tmp, tmp_length1, (GDestroyNotify) g_free), NULL); } @@ -352,7 +355,7 @@ static gboolean music_player_bridge_server_is_not_of_interest (MusicPlayerBridge return result; } if (string_contains (type, "music") == FALSE) { - g_debug ("music-player-bridge.vala:133: server is of no interest, it is not an " \ + g_debug ("music-player-bridge.vala:135: server is of no interest, it is not an " \ "music server"); result = TRUE; return result; @@ -379,7 +382,7 @@ GAppInfo* music_player_bridge_create_app_info (const char* path) { g_return_val_if_fail (path != NULL, NULL); info = g_desktop_app_info_new_from_filename (path); if (path == NULL) { - g_warning ("music-player-bridge.vala:149: Could not create a desktopappinfo instan" \ + g_warning ("music-player-bridge.vala:151: Could not create a desktopappinfo instan" \ "ce from app: %s", path); result = NULL; _g_object_unref0 (info); @@ -420,7 +423,7 @@ static char* music_player_bridge_truncate_player_name (char* app_info_name) { char* _tmp4_; _result_ = (_tmp4_ = g_strdup (tokens[0]), _g_free0 (_result_), _tmp4_); } - g_debug ("music-player-bridge.vala:165: truncate player name %s", _result_); + g_debug ("music-player-bridge.vala:167: truncate player name %s", _result_); result = _result_; tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL); _g_free0 (app_info_name); @@ -461,7 +464,7 @@ static char* music_player_bridge_determine_key (char* path) { char* _tmp7_; _result_ = (_tmp7_ = g_strdup (temp[0]), _g_free0 (_result_), _tmp7_); } - g_debug ("music-player-bridge.vala:179: determine key result = %s", _result_); + g_debug ("music-player-bridge.vala:181: determine key result = %s", _result_); result = _result_; temp = (_vala_array_free (temp, temp_length1, (GDestroyNotify) g_free), NULL); _g_free0 (filename); |