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
=== modified file 'src/Vocal.vala'
--- src/Vocal.vala 2015-02-14 01:49:28 +0000
+++ src/Vocal.vala 2015-03-23 23:26:33 +0000
@@ -20,7 +20,7 @@
20using Gtk;20using Gtk;
21using Granite;21using Granite;
22using Granite.Services;22using Granite.Services;
23using Notify;23//using Notify;
2424
25namespace Vocal {25namespace Vocal {
2626
@@ -28,32 +28,32 @@
28 private static bool OPEN_HIDDEN = false;28 private static bool OPEN_HIDDEN = false;
29 private static bool PRINT_VERSION = false;29 private static bool PRINT_VERSION = false;
30 }30 }
31 31
32 public class VocalApp : Granite.Application {32 public class VocalApp : Granite.Application {
33 33
34 private MainWindow window = null;34 private MainWindow window = null;
35 public string[] args;35 public string[] args;
36 36
37 construct {37 construct {
38 program_name = "Vocal";38 program_name = "Vocal";
39 exec_name = "vocal";39 exec_name = "vocal";
40 40
41 build_data_dir = Constants.DATADIR;41 build_data_dir = Constants.DATADIR;
42 build_pkg_data_dir = Constants.PKGDATADIR;42 build_pkg_data_dir = Constants.PKGDATADIR;
43 build_release_name = Constants.RELEASE_NAME;43 build_release_name = Constants.RELEASE_NAME;
44 build_version = Constants.VERSION;44 build_version = Constants.VERSION;
45 build_version_info = Constants.VERSION_INFO;45 build_version_info = Constants.VERSION_INFO;
46 46
47 app_years = "2014";47 app_years = "2014";
48 app_icon = "vocal";48 app_icon = "vocal";
49 app_launcher = "vocal.desktop";49 app_launcher = "vocal.desktop";
50 application_id = "net.launchpad.vocal";50 application_id = "net.launchpad.vocal";
51 51
52 main_url = "https://code.launchpad.net/vocal";52 main_url = "https://code.launchpad.net/vocal";
53 bug_url = "https://bugs.launchpad.net/vocal";53 bug_url = "https://bugs.launchpad.net/vocal";
54 help_url = "https://code.launchpad.net/vocal";54 help_url = "https://code.launchpad.net/vocal";
55 translate_url = "https://translations.launchpad.net/vocal";55 translate_url = "https://translations.launchpad.net/vocal";
56 56
57 about_authors = { "Nathan Dyer <mail@nathandyer.me>" };57 about_authors = { "Nathan Dyer <mail@nathandyer.me>" };
58 about_documenters = { "Nathan Dyer <mail@nathandyer.me>" };58 about_documenters = { "Nathan Dyer <mail@nathandyer.me>" };
59 about_artists = { "Nathan Dyer (App) <mail@nathandyer.me>", "Harvey Cabaguio (Icons and Branding) <harvey@elementaryos.org", "Mashnoon Ibtesum (Artwork)" };59 about_artists = { "Nathan Dyer (App) <mail@nathandyer.me>", "Harvey Cabaguio (Icons and Branding) <harvey@elementaryos.org", "Mashnoon Ibtesum (Artwork)" };
@@ -68,19 +68,19 @@
68 { "hidden", 'h', 0, OptionArg.NONE, out Option.OPEN_HIDDEN, "Open without displaying the window so podcasts will continue to update", null },68 { "hidden", 'h', 0, OptionArg.NONE, out Option.OPEN_HIDDEN, "Open without displaying the window so podcasts will continue to update", null },
69 { null }69 { null }
70 };70 };
71 71
72 72
73 public VocalApp () {73 public VocalApp () {
74 Logger.initialize ("Vocal");74 Logger.initialize ("Vocal");
75 Logger.DisplayLevel = LogLevel.INFO; 75 Logger.DisplayLevel = LogLevel.INFO;
76 }76 }
77 77
78 public override void activate () {78 public override void activate () {
79 79
80 // Set Vocal to use the dark theme (if available)80 // Set Vocal to use the dark theme (if available)
81 var settings = Gtk.Settings.get_default(); 81 var settings = Gtk.Settings.get_default();
82 settings.gtk_application_prefer_dark_theme = true; 82 settings.gtk_application_prefer_dark_theme = true;
83 83
84 if (get_windows () == null) {84 if (get_windows () == null) {
85 window = new MainWindow (this, Option.OPEN_HIDDEN);85 window = new MainWindow (this, Option.OPEN_HIDDEN);
86 if(!Option.OPEN_HIDDEN)86 if(!Option.OPEN_HIDDEN)
@@ -89,7 +89,7 @@
89 window.present ();89 window.present ();
90 }90 }
91 }91 }
92 92
93 public static void main (string [] args) {93 public static void main (string [] args) {
94 X.init_threads ();94 X.init_threads ();
9595
@@ -136,7 +136,7 @@
136 // Set the media role136 // Set the media role
137 GLib.Environ.set_variable ({"PULSE_PROP_media.role"}, "audio", "true");137 GLib.Environ.set_variable ({"PULSE_PROP_media.role"}, "audio", "true");
138138
139 139
140 var app = new Vocal.VocalApp ();140 var app = new Vocal.VocalApp ();
141 app.args = args;141 app.args = args;
142 app.run (args);142 app.run (args);
143143
=== modified file 'src/Widgets/CoverArt.vala'
--- src/Widgets/CoverArt.vala 2015-03-11 03:43:56 +0000
+++ src/Widgets/CoverArt.vala 2015-03-23 23:26:33 +0000
@@ -15,6 +15,8 @@
15 with this program. If not, see <http://www.gnu.org/licenses>15 with this program. If not, see <http://www.gnu.org/licenses>
1616
17 END LICENSE17 END LICENSE
18
19 Authored by: Artem Anufrij <artem.anufrij@live.de>
18***/20***/
1921
2022
@@ -25,7 +27,9 @@
25namespace Vocal {27namespace Vocal {
2628
27 public class CoverArt : Gtk.Box {29 public class CoverArt : Gtk.Box {
28 30
31 private const int COVER_SIZE = 150;
32
29 private Gtk.Image image; // The actual coverart image33 private Gtk.Image image; // The actual coverart image
30 private Gtk.Image triangle; // The banner in the top right corner34 private Gtk.Image triangle; // The banner in the top right corner
31 private Gtk.Overlay triangle_overlay; // Overlays the banner on top of the image35 private Gtk.Overlay triangle_overlay; // Overlays the banner on top of the image
@@ -52,9 +56,10 @@
52 info("Coverart at %s doesn't exist.".printf(path.replace("%27", "'")));56 info("Coverart at %s doesn't exist.".printf(path.replace("%27", "'")));
53 }57 }
54 InputStream input_stream = cover_file.read();58 InputStream input_stream = cover_file.read();
55 var coverart_pixbuf = new Gdk.Pixbuf.from_stream_at_scale(input_stream, 150, 150, true);59 var coverart_pixbuf = create_cover_image (input_stream);
56 image = new Gtk.Image.from_pixbuf(coverart_pixbuf); 60
57 61 image = new Gtk.Image.from_pixbuf(coverart_pixbuf);
62
58 // Load the banner to be drawn on top of the cover art63 // Load the banner to be drawn on top of the cover art
59 File triangle_file = GLib.File.new_for_uri("""file:///usr/share/vocal/banner.png""");64 File triangle_file = GLib.File.new_for_uri("""file:///usr/share/vocal/banner.png""");
60 InputStream triangle_input_stream = triangle_file.read();65 InputStream triangle_input_stream = triangle_file.read();
@@ -93,7 +98,7 @@
93 this.tooltip_text = podcast.name.replace("%27", "'");98 this.tooltip_text = podcast.name.replace("%27", "'");
9499
95 // Set up the overlays100 // Set up the overlays
96 101
97 count_overlay.add_overlay(count_label);102 count_overlay.add_overlay(count_label);
98 triangle_overlay.add_overlay(count_overlay);103 triangle_overlay.add_overlay(count_overlay);
99104
@@ -113,7 +118,7 @@
113 Gtk.Image mime_image;118 Gtk.Image mime_image;
114 if(podcast.content_type == MediaType.AUDIO)119 if(podcast.content_type == MediaType.AUDIO)
115 mime_image = new Gtk.Image.from_icon_name ("media-audio-symbolic", IconSize.BUTTON);120 mime_image = new Gtk.Image.from_icon_name ("media-audio-symbolic", IconSize.BUTTON);
116 else 121 else
117 mime_image = new Gtk.Image.from_icon_name ("media-video-symbolic", IconSize.BUTTON);122 mime_image = new Gtk.Image.from_icon_name ("media-video-symbolic", IconSize.BUTTON);
118123
119string css = """124string css = """
@@ -176,5 +181,31 @@
176 triangle.set_no_show_all(false);181 triangle.set_no_show_all(false);
177 triangle.show();182 triangle.show();
178 }183 }
184
185 public Gdk.Pixbuf create_cover_image (InputStream input_stream) {
186 var cover_image = new Gdk.Pixbuf.from_stream (input_stream);
187
188 if (cover_image.height == cover_image.width)
189 cover_image = cover_image.scale_simple (COVER_SIZE, COVER_SIZE, Gdk.InterpType.BILINEAR);
190
191 if (cover_image.height > cover_image.width) {
192
193 int new_height = COVER_SIZE * cover_image.height / cover_image.width;
194 int new_width = COVER_SIZE;
195 int offset = (new_height - new_width) / 2;
196
197 cover_image = new Gdk.Pixbuf.subpixbuf(cover_image.scale_simple (new_width, new_height, Gdk.InterpType.BILINEAR), 0, offset, COVER_SIZE, COVER_SIZE);
198
199 } else if (cover_image.height < cover_image.width) {
200
201 int new_height = COVER_SIZE;
202 int new_width = COVER_SIZE * cover_image.width / cover_image.height;
203 int offset = (new_width - new_height) / 2;
204
205 cover_image = new Gdk.Pixbuf.subpixbuf(cover_image.scale_simple (new_width, new_height, Gdk.InterpType.BILINEAR), offset, 0, COVER_SIZE, COVER_SIZE);
206 }
207
208 return cover_image;
209 }
179 }210 }
180}
181\ No newline at end of file211\ No newline at end of file
212}

Subscribers

People subscribed via source and target branches