Merge lp:~artem-anufrij/vocal/vocal into lp:vocal

Proposed by Artem Anufrij
Status: Merged
Approved by: Nathan Dyer
Approved revision: 244
Merged at revision: 244
Proposed branch: lp:~artem-anufrij/vocal/vocal
Merge into: lp:vocal
Diff against target: 188 lines (+56/-25)
2 files modified
src/Vocal.vala (+18/-18)
src/Widgets/CoverArt.vala (+38/-7)
To merge this branch: bzr merge lp:~artem-anufrij/vocal/vocal
Reviewer Review Type Date Requested Status
Nathan Dyer Pending
Review via email: mp+253896@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Artem Anufrij (artem-anufrij) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Vocal.vala'
2--- src/Vocal.vala 2015-02-14 01:49:28 +0000
3+++ src/Vocal.vala 2015-03-23 23:26:33 +0000
4@@ -20,7 +20,7 @@
5 using Gtk;
6 using Granite;
7 using Granite.Services;
8-using Notify;
9+//using Notify;
10
11 namespace Vocal {
12
13@@ -28,32 +28,32 @@
14 private static bool OPEN_HIDDEN = false;
15 private static bool PRINT_VERSION = false;
16 }
17-
18+
19 public class VocalApp : Granite.Application {
20-
21+
22 private MainWindow window = null;
23 public string[] args;
24-
25+
26 construct {
27 program_name = "Vocal";
28 exec_name = "vocal";
29-
30+
31 build_data_dir = Constants.DATADIR;
32 build_pkg_data_dir = Constants.PKGDATADIR;
33 build_release_name = Constants.RELEASE_NAME;
34 build_version = Constants.VERSION;
35 build_version_info = Constants.VERSION_INFO;
36-
37+
38 app_years = "2014";
39 app_icon = "vocal";
40 app_launcher = "vocal.desktop";
41 application_id = "net.launchpad.vocal";
42-
43+
44 main_url = "https://code.launchpad.net/vocal";
45 bug_url = "https://bugs.launchpad.net/vocal";
46 help_url = "https://code.launchpad.net/vocal";
47 translate_url = "https://translations.launchpad.net/vocal";
48-
49+
50 about_authors = { "Nathan Dyer <mail@nathandyer.me>" };
51 about_documenters = { "Nathan Dyer <mail@nathandyer.me>" };
52 about_artists = { "Nathan Dyer (App) <mail@nathandyer.me>", "Harvey Cabaguio (Icons and Branding) <harvey@elementaryos.org", "Mashnoon Ibtesum (Artwork)" };
53@@ -68,19 +68,19 @@
54 { "hidden", 'h', 0, OptionArg.NONE, out Option.OPEN_HIDDEN, "Open without displaying the window so podcasts will continue to update", null },
55 { null }
56 };
57-
58-
59+
60+
61 public VocalApp () {
62 Logger.initialize ("Vocal");
63- Logger.DisplayLevel = LogLevel.INFO;
64+ Logger.DisplayLevel = LogLevel.INFO;
65 }
66-
67+
68 public override void activate () {
69-
70+
71 // Set Vocal to use the dark theme (if available)
72- var settings = Gtk.Settings.get_default();
73- settings.gtk_application_prefer_dark_theme = true;
74-
75+ var settings = Gtk.Settings.get_default();
76+ settings.gtk_application_prefer_dark_theme = true;
77+
78 if (get_windows () == null) {
79 window = new MainWindow (this, Option.OPEN_HIDDEN);
80 if(!Option.OPEN_HIDDEN)
81@@ -89,7 +89,7 @@
82 window.present ();
83 }
84 }
85-
86+
87 public static void main (string [] args) {
88 X.init_threads ();
89
90@@ -136,7 +136,7 @@
91 // Set the media role
92 GLib.Environ.set_variable ({"PULSE_PROP_media.role"}, "audio", "true");
93
94-
95+
96 var app = new Vocal.VocalApp ();
97 app.args = args;
98 app.run (args);
99
100=== modified file 'src/Widgets/CoverArt.vala'
101--- src/Widgets/CoverArt.vala 2015-03-11 03:43:56 +0000
102+++ src/Widgets/CoverArt.vala 2015-03-23 23:26:33 +0000
103@@ -15,6 +15,8 @@
104 with this program. If not, see <http://www.gnu.org/licenses>
105
106 END LICENSE
107+
108+ Authored by: Artem Anufrij <artem.anufrij@live.de>
109 ***/
110
111
112@@ -25,7 +27,9 @@
113 namespace Vocal {
114
115 public class CoverArt : Gtk.Box {
116-
117+
118+ private const int COVER_SIZE = 150;
119+
120 private Gtk.Image image; // The actual coverart image
121 private Gtk.Image triangle; // The banner in the top right corner
122 private Gtk.Overlay triangle_overlay; // Overlays the banner on top of the image
123@@ -52,9 +56,10 @@
124 info("Coverart at %s doesn't exist.".printf(path.replace("%27", "'")));
125 }
126 InputStream input_stream = cover_file.read();
127- var coverart_pixbuf = new Gdk.Pixbuf.from_stream_at_scale(input_stream, 150, 150, true);
128- image = new Gtk.Image.from_pixbuf(coverart_pixbuf);
129-
130+ var coverart_pixbuf = create_cover_image (input_stream);
131+
132+ image = new Gtk.Image.from_pixbuf(coverart_pixbuf);
133+
134 // Load the banner to be drawn on top of the cover art
135 File triangle_file = GLib.File.new_for_uri("""file:///usr/share/vocal/banner.png""");
136 InputStream triangle_input_stream = triangle_file.read();
137@@ -93,7 +98,7 @@
138 this.tooltip_text = podcast.name.replace("%27", "'");
139
140 // Set up the overlays
141-
142+
143 count_overlay.add_overlay(count_label);
144 triangle_overlay.add_overlay(count_overlay);
145
146@@ -113,7 +118,7 @@
147 Gtk.Image mime_image;
148 if(podcast.content_type == MediaType.AUDIO)
149 mime_image = new Gtk.Image.from_icon_name ("media-audio-symbolic", IconSize.BUTTON);
150- else
151+ else
152 mime_image = new Gtk.Image.from_icon_name ("media-video-symbolic", IconSize.BUTTON);
153
154 string css = """
155@@ -176,5 +181,31 @@
156 triangle.set_no_show_all(false);
157 triangle.show();
158 }
159+
160+ public Gdk.Pixbuf create_cover_image (InputStream input_stream) {
161+ var cover_image = new Gdk.Pixbuf.from_stream (input_stream);
162+
163+ if (cover_image.height == cover_image.width)
164+ cover_image = cover_image.scale_simple (COVER_SIZE, COVER_SIZE, Gdk.InterpType.BILINEAR);
165+
166+ if (cover_image.height > cover_image.width) {
167+
168+ int new_height = COVER_SIZE * cover_image.height / cover_image.width;
169+ int new_width = COVER_SIZE;
170+ int offset = (new_height - new_width) / 2;
171+
172+ cover_image = new Gdk.Pixbuf.subpixbuf(cover_image.scale_simple (new_width, new_height, Gdk.InterpType.BILINEAR), 0, offset, COVER_SIZE, COVER_SIZE);
173+
174+ } else if (cover_image.height < cover_image.width) {
175+
176+ int new_height = COVER_SIZE;
177+ int new_width = COVER_SIZE * cover_image.width / cover_image.height;
178+ int offset = (new_width - new_height) / 2;
179+
180+ cover_image = new Gdk.Pixbuf.subpixbuf(cover_image.scale_simple (new_width, new_height, Gdk.InterpType.BILINEAR), offset, 0, COVER_SIZE, COVER_SIZE);
181+ }
182+
183+ return cover_image;
184+ }
185 }
186-}
187\ No newline at end of file
188+}

Subscribers

People subscribed via source and target branches