-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from louis77/development
Release v1.5.4
- Loading branch information
Showing
23 changed files
with
1,220 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,7 @@ build-aux | |
*~ | ||
.vscode | ||
.buildconfig | ||
.flatpak-builder | ||
.flatpak-builder | ||
code.sh | ||
favicon.ico | ||
tuner.code-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# ![icon](docs/logo_01.png) Develop, Build and Contribute to Tuner [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0) | ||
|
||
|
||
Discover and Listen to your favourite internet radio stations. | ||
|
||
## Overview | ||
|
||
Tuner is hosted on Github, and linked to Flathub so as releases are pushed Flathub will automatically update its repositary. It is writen in [Vala](https://vala.dev/), a C#/Java/JavaFX-like language with a self-hosting compiler that generates C code and uses the GObject type system and wrapping a number of GTK libraries. It uses [Meson](https://mesonbuild.com/) as its build system. | ||
|
||
|
||
|
||
### Dependencies | ||
|
||
```bash | ||
granite | ||
gstreamer-1.0 | ||
gstreamer-player-1.0 | ||
gtk+-3.0 | ||
json-glib-1.0 | ||
libgee-0.8 | ||
libsoup-3.0 | ||
meson | ||
vala | ||
``` | ||
|
||
### Building | ||
|
||
Make sure you have the dependencies installed: | ||
|
||
```bash | ||
sudo apt install git valac meson | ||
sudo apt install libgtk-3-dev libgee-0.8-dev libgranite-dev libgstreamer1.0-dev libgstreamer-plugins-bad1.0-dev libsoup-3.0-dev libjson-glib-dev | ||
``` | ||
|
||
Clone the repo and drop into the Tuner directory. Configure Meson for development debug build, build Tuner with Ninja, and run the result: | ||
|
||
```bash | ||
meson setup --buildtype=debug builddir | ||
ninja -C builddir | ||
./builddir/com.github.louis77.tuner | ||
``` | ||
|
||
|
||
```bash | ||
meson configure -Dprefix=/usr | ||
sudo ninja install | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,14 @@ | |
* SPDX-FileCopyrightText: 2020-2022 Louis Brauer <[email protected]> | ||
*/ | ||
|
||
/** | ||
Application | ||
Entry point for Tuner | ||
*/ | ||
/** | ||
* @brief Entry point for Tuner application | ||
*/ | ||
public class Tuner.Application : Gtk.Application { | ||
|
||
public GLib.Settings settings { get; construct; } | ||
|
@@ -12,7 +20,7 @@ public class Tuner.Application : Gtk.Application { | |
|
||
public Window window; | ||
|
||
public const string APP_VERSION = "1.5.3"; | ||
public const string APP_VERSION = VERSION; | ||
public const string APP_ID = "com.github.louis77.tuner"; | ||
public const string STAR_CHAR = "★ "; | ||
public const string UNSTAR_CHAR = "☆ "; | ||
|
@@ -21,13 +29,19 @@ public class Tuner.Application : Gtk.Application { | |
{ "resume-window", on_resume_window } | ||
}; | ||
|
||
/** | ||
* @brief Constructor for the Application | ||
*/ | ||
public Application () { | ||
Object ( | ||
application_id: APP_ID, | ||
flags: ApplicationFlags.FLAGS_NONE | ||
); | ||
} | ||
|
||
/** | ||
* @brief Construct block for initializing the application | ||
*/ | ||
construct { | ||
GLib.Intl.setlocale (LocaleCategory.ALL, ""); | ||
GLib.Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); | ||
|
@@ -46,8 +60,15 @@ public class Tuner.Application : Gtk.Application { | |
add_action_entries(ACTION_ENTRIES, this); | ||
} | ||
|
||
/** | ||
* @brief Singleton instance of the Application | ||
*/ | ||
public static Application _instance = null; | ||
|
||
/** | ||
* @brief Getter for the singleton instance | ||
* @return The Application instance | ||
*/ | ||
public static Application instance { | ||
get { | ||
if (_instance == null) { | ||
|
@@ -57,6 +78,9 @@ public class Tuner.Application : Gtk.Application { | |
} | ||
} | ||
|
||
/** | ||
* @brief Activates the application | ||
*/ | ||
protected override void activate() { | ||
if (window == null) { | ||
window = new Window (this, player); | ||
|
@@ -68,10 +92,17 @@ public class Tuner.Application : Gtk.Application { | |
|
||
} | ||
|
||
/** | ||
* @brief Resumes the window | ||
*/ | ||
private void on_resume_window() { | ||
window.present(); | ||
} | ||
|
||
/** | ||
* @brief Ensures a directory exists | ||
* @param path The directory path to ensure | ||
*/ | ||
private void ensure_dir (string path) { | ||
var dir = File.new_for_path (path); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
public const string GETTEXT_PACKAGE = @GETTEXT_PACKAGE@; | ||
public const string LOCALEDIR = @LOCALEDIR@; | ||
public const string VERSION = @VERSION@; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* SPDX-FileCopyrightText: 2020-2022 Louis Brauer <[email protected]> | ||
*/ | ||
|
||
public static int main (string[] args) { | ||
Gst.init (ref args); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,25 +3,30 @@ | |
* SPDX-FileCopyrightText: 2020-2022 Louis Brauer <[email protected]> | ||
*/ | ||
|
||
// StationStore can store and retrieve a collection of stations | ||
// in a JSON file | ||
/** | ||
StationStore | ||
Store and retrieve a collection of stations in a JSON file, i.e. favorites | ||
Uses libgee for data structures. | ||
*/ | ||
|
||
using Gee; | ||
|
||
namespace Tuner.Model { | ||
|
||
public class StationStore : Object { | ||
private ArrayList<Station> _store; | ||
private File _data_file; | ||
private File _favorites_file; | ||
|
||
public StationStore (string data_path) { | ||
public StationStore (string favorites_path) { | ||
Object (); | ||
|
||
_store = new ArrayList<Station> (); | ||
_data_file = File.new_for_path (data_path); | ||
_favorites_file = File.new_for_path (favorites_path); | ||
ensure (); | ||
load (); | ||
debug (@"store initialized in path $data_path"); | ||
debug (@"store initialized in path $favorites_path"); | ||
} | ||
|
||
public void add (Station station) { | ||
|
@@ -43,7 +48,7 @@ public class StationStore : Object { | |
// Non-racy approach is to try to create the file first | ||
// and ignore errors if it already exists | ||
try { | ||
var df = _data_file.create (FileCreateFlags.PRIVATE); | ||
var df = _favorites_file.create (FileCreateFlags.PRIVATE); | ||
df.close (); | ||
debug (@"store created"); | ||
} catch (Error e) { | ||
|
@@ -56,16 +61,19 @@ public class StationStore : Object { | |
Json.Parser parser = new Json.Parser (); | ||
|
||
try { | ||
var stream = _data_file.read (); | ||
var stream = _favorites_file.read (); | ||
parser.load_from_stream (stream); | ||
stream.close (); | ||
} catch (Error e) { | ||
warning (@"store: unable to load data, does it exist? $(e.message)"); | ||
} | ||
|
||
Json.Node node = parser.get_root (); | ||
Json.Array array = node.get_array (); | ||
array.foreach_element ((a, i, elem) => { | ||
Json.Node? node = parser.get_root (); | ||
|
||
if ( node == null ) return; // No favorites store | ||
|
||
Json.Array array = node.get_array (); // Json-CRITICAL **: 21:02:51.821: json_node_get_array: assertion 'JSON_NODE_IS_VALID (node)' failed | ||
array.foreach_element ((a, i, elem) => { // json_array_foreach_element: assertion 'array != NULL' failed | ||
Station station = Json.gobject_deserialize (typeof (Station), elem) as Station; | ||
// TODO This should probably not be here but in | ||
// DirectoryController | ||
|
@@ -88,8 +96,8 @@ public class StationStore : Object { | |
var data = serialize (); | ||
|
||
try { | ||
_data_file.delete (); | ||
var stream = _data_file.create ( | ||
_favorites_file.delete (); | ||
var stream = _favorites_file.create ( | ||
FileCreateFlags.REPLACE_DESTINATION | FileCreateFlags.PRIVATE | ||
); | ||
var s = new DataOutputStream (stream); | ||
|
@@ -130,4 +138,4 @@ public class StationStore : Object { | |
} | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.