Skip to content

Commit

Permalink
Merge pull request #161 from technosf/development
Browse files Browse the repository at this point in the history
Updating manifest, leaving some warning in to look at search performance in flathub build vs local build
  • Loading branch information
technosf authored Nov 6, 2024
2 parents b14bce6 + 5ae7c0b commit dc9207f
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion com.github.louis77.tuner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ finish-args:
- "--share=network"
- "--metadata=X-DConf=migrate-path=/com/github/louis77/tuner/"
- "--socket=pulseaudio"
- "--talk-name=org.gnome.SettingsDaemon.MediaKeys"
- "--talk-name=org.freedesktop.Notifications"
- "--own-name=org.mpris.MediaPlayer2.Tuner"
cleanup:
- "/include"
Expand Down
2 changes: 1 addition & 1 deletion com.github.louis77.tuner.yml.debug
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ finish-args:
- "--share=network"
- "--metadata=X-DConf=migrate-path=/com/github/louis77/tuner/"
- "--socket=pulseaudio"
- "--talk-name=org.gnome.SettingsDaemon.MediaKeys"
- "--talk-name=org.freedesktop.Notifications"
- "--own-name=org.mpris.MediaPlayer2.Tuner"
cleanup:
- "/include"
Expand Down
2 changes: 1 addition & 1 deletion com.github.louis77.tuner.yml.release
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ finish-args:
- "--share=network"
- "--metadata=X-DConf=migrate-path=/com/github/louis77/tuner/"
- "--socket=pulseaudio"
- "--talk-name=org.gnome.SettingsDaemon.MediaKeys"
- "--talk-name=org.freedesktop.Notifications"
- "--own-name=org.mpris.MediaPlayer2.Tuner"
cleanup:
- "/include"
Expand Down
1 change: 0 additions & 1 deletion src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public class Tuner.Application : Gtk.Application {
GLib.Intl.textdomain (GETTEXT_PACKAGE);

settings = new GLib.Settings (this.application_id);
warning(@"Settings path: $(settings.path)");

player = new PlayerController ();

Expand Down
2 changes: 2 additions & 0 deletions src/Models/Station.vala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class Tuner.Model.Station : Object {
public int bitrate { get; set; }

public string? favicon_url { get; set; }
public bool favicon_load_error { get; set; }
public uint clickcount = 0;

public Station (string id, string title, string location, string url) {
Expand All @@ -24,6 +25,7 @@ public class Tuner.Model.Station : Object {
this.location = location;
this.url = url;
this.starred = starred;
this.favicon_load_error = false; // Is favicon load erring? Limit retry reloads during this session
}

public void toggle_starred () {
Expand Down
18 changes: 13 additions & 5 deletions src/Services/Favicon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,27 @@ public class Tuner.Favicon : GLib.Object {
*/
public static async Gdk.Pixbuf? load_async(Model.Station station, bool forceReload = false)
{
if ( station.favicon_url == null || station.favicon_url == "" || station.favicon_load_error ) return null; // Favicon is erring out, so bypss loading it this session

var favicon_cache_file = Path.build_filename(Application.instance.cache_dir, station.id);

// Check cache first if not forcing reload
if (!forceReload && FileUtils.test(favicon_cache_file, FileTest.EXISTS)) {
// Check if not forcing reload and then if favicon is cached
if ( !forceReload
&& FileUtils.test(favicon_cache_file, FileTest.EXISTS))
{
try {
return new Gdk.Pixbuf.from_file_at_scale(favicon_cache_file, 48, 48, true);
} catch (Error e) {
warning("Failed to load cached favicon: %s", e.message);
warning(@"Failed to load cached favicon: $(e.message)");
}
}

// If not in cache or force reload, fetch from internet
uint status_code;

InputStream? stream = yield HttpClient.GETasync(station.favicon_url, out status_code);

if (stream != null && status_code == 200) {
if ( stream != null && status_code == 200) {
try {
var pixbuf = yield new Gdk.Pixbuf.from_stream_async(stream, null);
var scaled_pixbuf = pixbuf.scale_simple(48, 48, Gdk.InterpType.BILINEAR);
Expand All @@ -63,9 +68,12 @@ public class Tuner.Favicon : GLib.Object {

return scaled_pixbuf;
} catch (Error e) {
warning("Failed to process favicon %s: %s", station.favicon_url,e.message);
warning(@"Failed to process favicon $(station.favicon_url) - $(e.message)");
}
}

// Could not load the favicon, so flag not to try again in this session
station.favicon_load_error = true;
return null;
}
}
6 changes: 3 additions & 3 deletions src/Widgets/Window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -595,10 +595,10 @@ public class Tuner.Window : Gtk.ApplicationWindow {
* @param contentBox The ContentBox to update with the search results.
*/
private async void load_search_stations(string searchText, ContentBox contentBox) {
debug(@"Searching for: $(searchText)");


warning(@"Searching for: $(searchText)");
var station_source = _directory.load_search_stations(searchText, 100);
debug(@"Search done");
warning(@"Search done");

try {
var stations = station_source.next();
Expand Down

0 comments on commit dc9207f

Please sign in to comment.