diff --git a/CMakeLists.txt b/CMakeLists.txt
index 45d412a1..81a8dff9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,6 +39,7 @@ set (SOURCE_LIST
src/Data/StationProvider.vala
src/Data/RadioBrowser.vala
src/Data/CategoryItemProvider.vala
+ src/Data/ImageProvider.vala
src/Widgets/DiscoverBox/DiscoverBox.vala
src/Widgets/DiscoverBox/DiscoverSidebar.vala
src/Widgets/DiscoverBox/CategoriesRow.vala
diff --git a/Ungesichertes Dokument 1 b/Ungesichertes Dokument 1
new file mode 100644
index 00000000..6f5b25ef
--- /dev/null
+++ b/Ungesichertes Dokument 1
@@ -0,0 +1,18 @@
+sub scale_pixbuf {
+ my ($pixbuf, $parent) = @_;
+ my $max_w = $parent->get_allocation()->{width};
+ my $max_h = $parent->get_allocation()->{height};
+ my $pixb_w = $pixbuf->get_width();
+ my $pixb_h = $pixbuf->get_height();
+ if (($pixb_w > $max_w) || ($pixb_h > $max_h)) {
+ my $sc_factor_w = $max_w / $pixb_w;
+ my $sc_factor_h = $max_h / $pixb_h;
+ my $sc_factor = min $sc_factor_w, $sc_factor_h;
+ my $sc_w = int($pixb_w * $sc_factor);
+ my $sc_h = int($pixb_h * $sc_factor);
+ my $scaled
+ = $pixbuf->scale_simple($sc_w, $sc_h, 'GDK_INTERP_HYPER');
+ return $scaled;
+ }
+ return $pixbuf;
+}
diff --git a/data/style/style.css b/data/style/style.css
index 883753ea..036e534a 100644
--- a/data/style/style.css
+++ b/data/style/style.css
@@ -18,7 +18,7 @@
.grid-item:backdrop {
box-shadow: none;
- border-color: @unfocused_borders;
+ border-color: @un3ocused_borders;
}
.stations-view{
@@ -37,6 +37,16 @@
color: @theme_selected_fg_color;
}
+.round-border{
+ border-radius: 3px;
+}
+
+.border{
+ border-width: 1px 1px 1px 1px;
+ border-style: solid;
+ border-color: @borders;
+}
+
.border-top{
border-width: 1px 0px 0px 0px;
border-style: solid;
diff --git a/data/ui/grid-item.ui b/data/ui/grid-item.ui
index aa280aa0..d2d4a7c1 100644
--- a/data/ui/grid-item.ui
+++ b/data/ui/grid-item.ui
@@ -24,17 +24,33 @@
True
False
-
+
+ -1
+
diff --git a/data/ui/grid-item.ui~ b/data/ui/grid-item.ui~
new file mode 100644
index 00000000..383620a3
--- /dev/null
+++ b/data/ui/grid-item.ui~
@@ -0,0 +1,245 @@
+
+
+
+
+
+ True
+ False
+ 2
+ 2
+ 2
+ 2
+
+
+ True
+ False
+ True
+
+
+
+ True
+ False
+
+
+ True
+ False
+
+
+ True
+ False
+ vertical
+
+
+ 64
+ 64
+ True
+ False
+ 7
+ 7
+ 7
+ 7
+ application-rss+xml-symbolic
+ 6
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ start
+ center
+ 7
+ 7
+ vertical
+
+
+ True
+ False
+ start
+ label
+
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ start
+ label
+
+
+ False
+ True
+ 1
+
+
+
+
+ True
+ False
+ start
+ label
+
+
+
+
+
+ False
+ True
+ 2
+
+
+
+
+ False
+ False
+ 1
+
+
+
+
+ -1
+
+
+
+
+ True
+ False
+ True
+
+
+ 30
+ True
+ False
+ end
+ vertical
+
+
+ True
+ False
+ 2
+ 2
+ 2
+ 2
+ vertical
+
+
+ True
+ False
+ 2
+ vertical
+ True
+
+
+ False
+ True
+ starred-symbolic
+
+
+ False
+ True
+ 0
+
+
+
+
+ False
+ True
+ non-starred-symbolic
+
+
+ False
+ True
+ 1
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ vertical
+ 6
+
+
+ True
+ False
+ emote-love-symbolic
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ 999
+
+
+ False
+ True
+ 1
+
+
+
+
+ False
+ True
+ end
+ 1
+
+
+
+
+ True
+ True
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/ui/list-item.ui b/data/ui/list-item.ui
index ac0b3f30..84de6159 100644
--- a/data/ui/list-item.ui
+++ b/data/ui/list-item.ui
@@ -10,17 +10,33 @@
True
False
-
- 32
- 32
+
True
False
5
5
5
5
- application-rss+xml-symbolic
- 5
+ vertical
+
+
+ 32
+ 32
+ True
+ False
+ application-rss+xml-symbolic
+ 5
+
+
+ True
+ True
+ 0
+
+
+
False
diff --git a/data/ui/list-item.ui~ b/data/ui/list-item.ui~
new file mode 100644
index 00000000..7f44b2f9
--- /dev/null
+++ b/data/ui/list-item.ui~
@@ -0,0 +1,172 @@
+
+
+
+
+
+ True
+ False
+
+
+ True
+ False
+
+
+ True
+ False
+ vertical
+
+
+ 32
+ 32
+ True
+ False
+ application-rss+xml-symbolic
+ 5
+
+
+ True
+ True
+ 0
+
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ start
+ Unbekannter Radiosender
+ start
+
+
+
+
+
+ False
+ True
+ 1
+
+
+
+
+ True
+ False
+ start
+ 5
+ 5
+
+
+
+
+
+ False
+ True
+ 2
+
+
+
+
+ True
+ False
+ 5
+ 5
+ True
+
+
+ False
+ True
+ starred-symbolic
+
+
+ False
+ True
+ 0
+
+
+
+
+ False
+ True
+ non-starred-symbolic
+
+
+ False
+ True
+ 1
+
+
+
+
+ False
+ True
+ end
+ 2
+
+
+
+
+ True
+ False
+ 5
+ 5
+ 6
+
+
+ True
+ False
+ emote-love-symbolic
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ 999
+
+
+ False
+ True
+ 1
+
+
+
+
+ False
+ True
+ end
+ 3
+
+
+
+
+ True
+ False
+ 5
+ 5
+
+
+ False
+ True
+ end
+ 4
+
+
+
+
+
+
diff --git a/data/ui/player-toolbar.ui b/data/ui/player-toolbar.ui
index d32f1b5c..073b2d0f 100644
--- a/data/ui/player-toolbar.ui
+++ b/data/ui/player-toolbar.ui
@@ -550,14 +550,30 @@ audio-volume-medium-symbolic
-
- 43
- 43
+
True
False
- center
- center
- application-rss+xml-symbolic
- 5
+ vertical
+
+
+ 43
+ 43
+ True
+ False
+ center
+ center
+ application-rss+xml-symbolic
+ 5
+
+
+ True
+ True
+ 0
+
+
+
diff --git a/data/ui/player-toolbar.ui~ b/data/ui/player-toolbar.ui~
new file mode 100644
index 00000000..b303412d
--- /dev/null
+++ b/data/ui/player-toolbar.ui~
@@ -0,0 +1,579 @@
+
+
+
+
+
+ True
+ False
+ True
+
+
+ True
+ False
+ center
+ vertical
+
+
+ True
+ False
+ start
+ start
+
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ start
+ start
+
+
+
+
+
+ False
+ True
+ 1
+
+
+
+
+ False
+
+
+ True
+ False
+ 5
+ 5
+ 5
+ 5
+ 5
+
+
+ True
+ False
+ start
+
+
+
+
+
+ 1
+ 0
+
+
+
+
+ True
+ False
+ start
+ Channel Mode:
+
+
+
+
+
+ 0
+ 1
+
+
+
+
+ True
+ False
+ start
+
+
+
+
+
+ 1
+ 1
+
+
+
+
+ True
+ False
+ start
+ Nominal Bitrate:
+
+
+
+
+
+ 0
+ 2
+
+
+
+
+ True
+ False
+ start
+ Minimum Bitrate:
+
+
+
+
+
+ 0
+ 3
+
+
+
+
+ True
+ False
+ start
+ Maximum Bitrate:
+
+
+
+
+
+ 0
+ 4
+
+
+
+
+ True
+ False
+ start
+ Bitrate:
+
+
+
+
+
+ 0
+ 5
+
+
+
+
+ True
+ False
+ start
+
+
+
+
+
+ 1
+ 2
+
+
+
+
+ True
+ False
+ start
+
+
+
+
+
+ 1
+ 3
+
+
+
+
+ True
+ False
+ start
+
+
+
+
+
+ 1
+ 4
+
+
+
+
+ True
+ False
+ start
+
+
+
+
+
+ 1
+ 5
+
+
+
+
+ True
+ False
+
+
+ 0
+ 6
+ 2
+
+
+
+
+ True
+ False
+ True
+
+
+ True
+ True
+ True
+ none
+
+
+
+ True
+ False
+ go-home-symbolic
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ True
+ True
+ none
+
+
+
+ True
+ False
+ center
+ 6
+
+
+ True
+ False
+ emote-love-symbolic
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ 0
+
+
+ False
+ True
+ 1
+
+
+
+
+
+
+ False
+ True
+ 1
+
+
+
+
+
+
+
+ 0
+ 7
+ 2
+
+
+
+
+ True
+ False
+ start
+ Codec:
+
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ True
+ False
+
+
+
+ False
+ True
+ end
+ -1
+
+
+
+
+
+
+
+ True
+ True
+ True
+ none
+
+
+
+ True
+ False
+ vertical
+ True
+
+
+ False
+ True
+ starred-symbolic
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ non-starred-symbolic
+
+
+ False
+ True
+ 1
+
+
+
+
+
+
+ False
+ True
+ 2
+
+
+
+
+ True
+ True
+ False
+ True
+ none
+ vertical
+ 1
+ audio-volume-muted-symbolic
+audio-volume-high-symbolic
+audio-volume-low-symbolic
+audio-volume-medium-symbolic
+
+
+
+ True
+ True
+ center
+ center
+ none
+
+
+
+
+ True
+ True
+ center
+ center
+ none
+
+
+
+
+ False
+ True
+ 3
+
+
+
+
+ True
+ False
+
+
+ True
+ False
+
+
+ True
+ True
+ True
+
+
+ True
+ False
+ 1
+ media-skip-backward-symbolic
+ 1
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ 40
+ 40
+ True
+ True
+ True
+
+
+
+ True
+ False
+ vertical
+ True
+
+
+ False
+ True
+ media-playback-stop-symbolic
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ media-playback-start-symbolic
+
+
+ False
+ True
+ 1
+
+
+
+
+
+
+ False
+ True
+ 1
+
+
+
+
+ True
+ True
+ True
+
+
+ True
+ False
+ 1
+ media-skip-forward-symbolic
+ 1
+
+
+
+
+ False
+ True
+ 2
+
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
+
+ True
+ False
+ vertical
+
+
+ 43
+ 43
+ True
+ False
+ center
+ center
+ application-rss+xml-symbolic
+ 5
+
+
+ False
+ True
+ 0
+
+
+
+
+
diff --git a/po/gradio.pot b/po/gradio.pot
index 106a5a3f..377f3e78 100644
--- a/po/gradio.pot
+++ b/po/gradio.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-09-17 17:37+0200\n"
+"POT-Creation-Date: 2016-09-17 22:36+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -17,11 +17,11 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: src/Gradio.vala:61
+#: src/Gradio.vala:64
msgid "translator-credits"
msgstr ""
-#: src/Gradio.vala:63
+#: src/Gradio.vala:66
msgid "About Gradio"
msgstr ""
diff --git a/src/Data/ImageProvider.vala b/src/Data/ImageProvider.vala
new file mode 100644
index 00000000..0ce588fc
--- /dev/null
+++ b/src/Data/ImageProvider.vala
@@ -0,0 +1,84 @@
+namespace Gradio{
+
+ public class ImageProvider{
+
+ public ImageProvider(){
+
+ }
+
+ public async Gdk.Pixbuf? get_station_logo (RadioStation station, int size){
+ if(Gradio.App.settings.get_boolean ("load-pictures")){
+ SourceFunc callback = get_station_logo.callback;
+ Gdk.Pixbuf output = null;
+
+ ThreadFunc run = () => {
+ if(station.Icon != ""){
+ var session = new Soup.Session ();
+ var message = new Soup.Message ("GET", station.Icon);
+ var loader = new Gdk.PixbufLoader();
+
+ if(message == null){
+ try{
+ loader.close();
+ }catch(GLib.Error e){
+ warning(e.message);
+ }
+ return null;
+ }
+
+ session.user_agent = "gradio/"+Constants.VERSION;
+ session.send_message (message);
+
+ try{
+ if(message.response_body.data != null)
+ loader.write(message.response_body.data);
+
+ loader.close();
+ var pixbuf = loader.get_pixbuf();
+
+ optiscale(ref pixbuf, size);
+ output = pixbuf;
+ }catch (Error e){
+ debug("Pixbufloader: " + e.message);
+ }
+
+ session.abort();
+ }
+
+ Idle.add((owned) callback);
+ Thread.exit (1.to_pointer ());
+ return null;
+ };
+
+ new Thread ("image_thread", run);
+ yield;
+ return output;
+ }else{
+ return null;
+ }
+ }
+
+ // returns a resized pixbuf to fit the current user's screen resolution
+ private void optiscale (ref Gdk.Pixbuf pixbuf, int size) {
+ double pixb_w = pixbuf.get_width();
+ double pixb_h = pixbuf.get_height();
+
+ if((pixb_w > size) || (pixb_h > size)){
+ double sc_factor_w = size / pixb_w;
+ double sc_factor_h = size / pixb_h;
+
+ double sc_factor = 0;
+
+ if(sc_factor_w >= sc_factor_h)
+ sc_factor = sc_factor_h;
+ if(sc_factor_h >= sc_factor_w)
+ sc_factor = sc_factor_w;
+
+ double sc_w = pixb_w * sc_factor;
+ double sc_h = pixb_h * sc_factor;
+
+ pixbuf = pixbuf.scale_simple ((int)sc_w, (int)sc_h, Gdk.InterpType.BILINEAR);
+ }
+ }
+ }
+}
diff --git a/src/Gradio.vala b/src/Gradio.vala
index 883801ee..68382551 100644
--- a/src/Gradio.vala
+++ b/src/Gradio.vala
@@ -5,6 +5,7 @@ namespace Gradio {
public class App : Gtk.Application {
+ public static ImageProvider imgprovider;
public static MainWindow window;
public static AudioPlayer player;
public static Library library;
@@ -28,6 +29,8 @@ namespace Gradio {
mpris = new MPRIS();
mpris.initialize();
+ imgprovider = new ImageProvider();
+
window = new MainWindow(this);
this.add_window(window);
window.show_all();
diff --git a/src/Util.vala b/src/Util.vala
index cc6d632d..60bcbcc5 100644
--- a/src/Util.vala
+++ b/src/Util.vala
@@ -17,56 +17,6 @@ public class Util{
return "";
}
- public static async Gdk.Pixbuf get_image_from_url (string url, int height, int width){
- if(Gradio.App.settings.get_boolean ("load-pictures")){
- SourceFunc callback = get_image_from_url.callback;
- Gdk.Pixbuf output = null;
-
- ThreadFunc run = () => {
- if(url != ""){
- var session = new Soup.Session ();
- var message = new Soup.Message ("GET", url);
- var loader = new Gdk.PixbufLoader();
-
- session.user_agent = "gradio/"+Constants.VERSION;
- if(message == null){
- try{
- loader.close();
- }catch(GLib.Error e){
- warning(e.message);
- }
-
- return null;
- }
- session.send_message (message);
-
- try{
- if(message.response_body.data != null)
- loader.write(message.response_body.data);
-
- loader.close();
- var pixbuf = loader.get_pixbuf();
- output = pixbuf.scale_simple(width, height, Gdk.InterpType.BILINEAR);
- }catch (Error e){
- debug("Pixbufloader: " + e.message);
- }
-
- session.abort();
- }
-
- Idle.add((owned) callback);
- Thread.exit (1.to_pointer ());
- return null;
- };
-
- new Thread ("image_thread", run);
- yield;
- return output;
- }else{
- return null;
- }
- }
-
public static void remove_all_items_from_list_box (Gtk.ListBox container) {
container.foreach(remove_all_cb);
}
diff --git a/src/Widgets/MiniPlayer.vala b/src/Widgets/MiniPlayer.vala
index 9e5c141b..56e65bcd 100644
--- a/src/Widgets/MiniPlayer.vala
+++ b/src/Widgets/MiniPlayer.vala
@@ -45,17 +45,6 @@ namespace Gradio{
ChannelCurrentTitleLabel.set_text("");
StationLogo.set_from_icon_name("application-rss+xml-symbolic", IconSize.DND);
- Gdk.Pixbuf icon = null;
- Util.get_image_from_url.begin(station.Icon, 90, 90, (obj, res) => {
- icon = Util.get_image_from_url.end(res);
-
- if(icon != null){
- StationLogo.set_from_pixbuf(icon);
- }else{
- StationLogo.set_from_icon_name("application-rss+xml-symbolic", IconSize.DND);
- }
-
- });
refresh_add_remove_button();
refresh_like_button();
diff --git a/src/Widgets/PlayerToolbar.vala b/src/Widgets/PlayerToolbar.vala
index ed9526cc..5dd2b609 100644
--- a/src/Widgets/PlayerToolbar.vala
+++ b/src/Widgets/PlayerToolbar.vala
@@ -16,6 +16,8 @@ namespace Gradio{
[GtkChild]
private Image StationLogo;
[GtkChild]
+ private Box StationLogoBox;
+ [GtkChild]
private Box MediaControlBox;
[GtkChild]
private Box InfoBox;
@@ -47,7 +49,7 @@ namespace Gradio{
public PlayerToolbar(){
this.pack_start(MediaControlBox);
- this.pack_start(StationLogo);
+ this.pack_start(StationLogoBox);
this.pack_start(InfoBox);
this.pack_end(ActionBox);
@@ -69,15 +71,15 @@ namespace Gradio{
StationLogo.set_from_icon_name("application-rss+xml-symbolic", IconSize.DND);
Gdk.Pixbuf icon = null;
- Util.get_image_from_url.begin(station.Icon, 41, 41, (obj, res) => {
- icon = Util.get_image_from_url.end(res);
+
+ Gradio.App.imgprovider.get_station_logo.begin(station, 41, (obj, res) => {
+ icon = Gradio.App.imgprovider.get_station_logo.end(res);
if(icon != null){
StationLogo.set_from_pixbuf(icon);
}else{
StationLogo.set_from_icon_name("application-rss+xml-symbolic", IconSize.DND);
}
-
});
refresh_add_remove_button();
diff --git a/src/Widgets/StationsView/GridItem.vala b/src/Widgets/StationsView/GridItem.vala
index f7c127a0..4e96b58d 100644
--- a/src/Widgets/StationsView/GridItem.vala
+++ b/src/Widgets/StationsView/GridItem.vala
@@ -50,8 +50,8 @@ namespace Gradio{
}
Gdk.Pixbuf icon = null;
- Util.get_image_from_url.begin(station.Icon, 64, 64, (obj, res) => {
- icon = Util.get_image_from_url.end(res);
+ Gradio.App.imgprovider.get_station_logo.begin(station, 64, (obj, res) => {
+ icon = Gradio.App.imgprovider.get_station_logo.end(res);
if(icon != null){
ChannelLogoImage.set_from_pixbuf(icon);
diff --git a/src/Widgets/StationsView/ListItem.vala b/src/Widgets/StationsView/ListItem.vala
index 9fedc980..2a33552d 100644
--- a/src/Widgets/StationsView/ListItem.vala
+++ b/src/Widgets/StationsView/ListItem.vala
@@ -43,8 +43,8 @@ namespace Gradio{
}
Gdk.Pixbuf icon = null;
- Util.get_image_from_url.begin(station.Icon, 32, 32, (obj, res) => {
- icon = Util.get_image_from_url.end(res);
+ Gradio.App.imgprovider.get_station_logo.begin(station, 32, (obj, res) => {
+ icon = Gradio.App.imgprovider.get_station_logo.end(res);
if(icon != null){
ChannelLogoImage.set_from_pixbuf(icon);