Merge lp:~donadigo/wingpanel-indicator-sound/cache-dbus-variables into lp:~wingpanel-devs/wingpanel-indicator-sound/trunk

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Djax
Approved revision: 128
Merged at revision: 128
Proposed branch: lp:~donadigo/wingpanel-indicator-sound/cache-dbus-variables
Merge into: lp:~wingpanel-devs/wingpanel-indicator-sound/trunk
Diff against target: 54 lines (+14/-10)
1 file modified
src/Widgets/MprisGui.vala (+14/-10)
To merge this branch: bzr merge lp:~donadigo/wingpanel-indicator-sound/cache-dbus-variables
Reviewer Review Type Date Requested Status
Djax Approve
Review via email: mp+310145@code.launchpad.net

Commit message

* Cache DBus variables in ClientWidget

Description of the change

Cache DBus variables to not call them everytime we need them.

To post a comment you must log in.
Revision history for this message
Djax (parnold-x) wrote :

Works fine. Nice, thx.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Widgets/MprisGui.vala'
2--- src/Widgets/MprisGui.vala 2016-11-06 15:09:00 +0000
3+++ src/Widgets/MprisGui.vala 2016-11-06 18:58:52 +0000
4@@ -72,8 +72,9 @@
5 } set {
6 this.client_ = value;
7 if (value != null) {
8- if (client.player.desktop_entry != null && client.player.desktop_entry != "") {
9- app_info = new DesktopAppInfo (client.player.desktop_entry + ".desktop");
10+ string? desktop_entry = client.player.desktop_entry;
11+ if (desktop_entry != null && desktop_entry != "") {
12+ app_info = new DesktopAppInfo ("%s.desktop".printf (desktop_entry));
13 }
14
15 connect_to_client ();
16@@ -420,8 +421,9 @@
17 * Update display info such as artist, the background image, etc.
18 */
19 protected void update_from_meta () {
20- if ("mpris:artUrl" in client.player.metadata) {
21- var url = client.player.metadata["mpris:artUrl"].get_string ();
22+ var metadata = client.player.metadata;
23+ if ("mpris:artUrl" in metadata) {
24+ var url = metadata["mpris:artUrl"].get_string ();
25 last_artUrl = url;
26 update_art (url);
27 } else {
28@@ -429,18 +431,20 @@
29 background.pixel_size = ICON_SIZE;
30 background.set_from_gicon (app_icon, Gtk.IconSize.DIALOG);
31 }
32+
33 string title;
34- if ("xesam:title" in client.player.metadata && client.player.metadata["xesam:title"].is_of_type (VariantType.STRING)
35- && client.player.metadata["xesam:title"].get_string () != "") {
36- title = client.player.metadata["xesam:title"].get_string ();
37+ if ("xesam:title" in metadata && metadata["xesam:title"].is_of_type (VariantType.STRING)
38+ && metadata["xesam:title"].get_string () != "") {
39+ title = metadata["xesam:title"].get_string ();
40 } else {
41- title = app_name;
42+ title = app_name;
43 }
44+
45 title_label.set_markup ("<b>%s</b>".printf (Markup.escape_text (title)));
46
47- if ("xesam:artist" in client.player.metadata && client.player.metadata["xesam:artist"].is_of_type (VariantType.STRING_ARRAY)) {
48+ if ("xesam:artist" in metadata && metadata["xesam:artist"].is_of_type (VariantType.STRING_ARRAY)) {
49 /* get_strv causes a segfault from multiple free's on vala's side. */
50- string[] artists = client.player.metadata["xesam:artist"].dup_strv ();
51+ string[] artists = metadata["xesam:artist"].dup_strv ();
52 artist_label.set_text (_("by ")+string.joinv (", ", artists));
53 } else {
54 if (client.player.playback_status == "Playing") {

Subscribers

People subscribed via source and target branches

to all changes: