Skip to content

Commit

Permalink
fix #6 #12
Browse files Browse the repository at this point in the history
  • Loading branch information
Alain M committed Aug 10, 2019
1 parent 937667d commit 1d7ccda
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 102 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Byte
A music player without the library management. Just toss in your music to the playlist from your meticulously managed music folder.
Rediscover your music

Interact with your music and fall in love with your library all over again.
Byte offers a beautiful presentation of your Music Library with loads of powerful features in a minimalistic yet highly customizable UI.

## Handy features:
* Light and Dark themes.</li>
* Add up to 100 items under "Recently Added" for songs.
* Sort individual playlists by album, title, play count or recently added.
* Advanced Media Details and Artist Info.
* Group Playlists, Albums, Artists, Songs, etc.
* Search, add and play your favorite online radio stations.

<a href="https://appcenter.elementary.io/com.github.alainm23.byte"><img src="https://appcenter.elementary.io/badge.svg?new" alt="Get it on AppCenter" /></a>

Expand Down Expand Up @@ -31,6 +42,6 @@ com.github.alainm23.byte
```

## Donations
Stripe is not yet available in my country, If you like Planner and you want to support its development, consider donating via [PayPal](https://www.paypal.me/alainm23)
Stripe is not yet available in my country, If you like Planner and you want to support its development, consider donating via [Patreon](https://www.patreon.com/alainm23)

Made with 💗 in Perú
7 changes: 7 additions & 0 deletions data/com.github.alainm23.byte.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
<binary>com.github.alainm23.byte</binary>
</provides>
​<releases>
<release version="0.1.2" date="2019-08-10">
<description>
<p>Fix some error and performance improvement</p>
</description>
</release>
<release version="0.1.1" date="2019-08-06">
<description>
<p>Initial release</p>
Expand Down Expand Up @@ -78,6 +83,8 @@
<developer_name>Alain M.</developer_name>
<url type="homepage">https://github.com/alainm23/byte</url>
<url type="bugtracker">https://github.com/alainm23/byte/issues</url>
<url type="donation">https://www.patreon.com/alainm23</url>
<url type="help">https://www.patreon.com/alainm23</url>
<custom>
<value key="x-appcenter-color-primary">#333333</value>
<value key="x-appcenter-color-primary-text">#FE2851</value>
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project('com.github.alainm23.byte',
'vala', 'c',
version: '0.0.1')
version: '0.1.2')

gnome = import('gnome')
i18n = import('i18n')
Expand Down
1 change: 1 addition & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class Byte : Gtk.Application {
application_id: "com.github.alainm23.byte",
flags: ApplicationFlags.HANDLES_OPEN
);

// Dir to Database
utils = new Utils ();
utils.create_dir_with_parents ("/.local/share/com.github.alainm23.byte");
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Database.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
public class Services.Database : GLib.Object {
private Sqlite.Database db;
private Sqlite.Database db;
private string db_path;

public signal void adden_new_track (Objects.Track track);
Expand Down
61 changes: 34 additions & 27 deletions src/Services/Scan.vala
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,42 @@ public class Services.Scan : GLib.Object {
Byte.tg_manager.discovered_new_item.connect (discovered_new_local_item);

Byte.database.adden_new_track.connect ((track) => {
counter--;
sync_progress (((double) counter_max - (double) counter) / (double) counter_max);
if (counter == 0) {
sync_finished ();
is_sync = false;

Timeout.add (1 * 1000, () => {
Byte.notification.send_notification (
_("Import Complete"),
_("Your Library Has Been Imported.")
);

if (counter_max > 1500) {
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
_("Wow! your library is very big"),
_("All your library was imported correctly, but for a better experience we recommend you re-open the application."),
"process-completed",
Gtk.ButtonsType.CLOSE
Idle.add (() => {
counter--;
sync_progress (((double) counter_max - (double) counter) / (double) counter_max);
if (counter == 0) {
sync_finished ();
is_sync = false;
counter_max = 0;

/*
Timeout.add (1 * 1000, () => {
counter_max = 0;
Byte.notification.send_notification (
_("Import Complete"),
_("Your Library Has Been Imported.")
);
/*
if (counter_max > 1500) {
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
_("Wow! your library is very big"),
_("All your library was imported correctly, but for a better experience we recommend you re-open the application."),
"process-completed",
Gtk.ButtonsType.CLOSE
);
message_dialog.run ();
message_dialog.destroy ();
}
message_dialog.run ();
message_dialog.destroy ();

counter_max = 0;
}

return false;
});
}
return false;
});
*/
}

return false;
});
});
}

Expand Down
36 changes: 22 additions & 14 deletions src/Views/Album.vala
Original file line number Diff line number Diff line change
Expand Up @@ -214,24 +214,32 @@ public class Views.Album : Gtk.EventBox {
});

Byte.database.adden_new_track.connect ((track) => {
if (_album != null && track.album_id == _album.id) {
var row = new Widgets.TrackAlbumRow (track);
listbox.add (row);
listbox.show_all ();
}
Idle.add (() => {
if (_album != null && track.album_id == _album.id) {
var row = new Widgets.TrackAlbumRow (track);
listbox.add (row);
listbox.show_all ();
}

return false;
});
});

Byte.database.updated_album_cover.connect ((album_id) => {
if (_album != null && album_id == _album.id) {
try {
image_cover.pixbuf = new Gdk.Pixbuf.from_file_at_size (
GLib.Path.build_filename (Byte.utils.COVER_FOLDER, ("album-%i.jpg").printf (album_id)),
128,
128);
} catch (Error e) {
stderr.printf ("Error setting default avatar icon: %s ", e.message);
Idle.add (() => {
if (_album != null && album_id == _album.id) {
try {
image_cover.pixbuf = new Gdk.Pixbuf.from_file_at_size (
GLib.Path.build_filename (Byte.utils.COVER_FOLDER, ("album-%i.jpg").printf (album_id)),
128,
128);
} catch (Error e) {
stderr.printf ("Error setting default avatar icon: %s ", e.message);
}
}
}

return false;
});
});

Byte.database.reset_library.connect (() => {
Expand Down
8 changes: 8 additions & 0 deletions src/Views/Playlists.vala
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ public class Views.Playlists : Gtk.EventBox {
widget.destroy ();
});
});

Byte.scan_service.sync_started.connect (() => {
add_button.sensitive = false;
});

Byte.scan_service.sync_finished.connect (() => {
add_button.sensitive = true;
});
}

private void add_item (Objects.Playlist playlist) {
Expand Down
22 changes: 13 additions & 9 deletions src/Widgets/AlbumRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,20 @@ public class Widgets.AlbumRow : Gtk.ListBoxRow {
add (main_grid);

Byte.database.updated_album_cover.connect ((album_id) => {
if (album_id == album.id) {
try {
image_cover.pixbuf = new Gdk.Pixbuf.from_file_at_size (
GLib.Path.build_filename (Byte.utils.COVER_FOLDER, ("album-%i.jpg").printf (album_id)),
64,
64);
} catch (Error e) {
stderr.printf ("Error setting default avatar icon: %s ", e.message);
Idle.add (() => {
if (album_id == album.id) {
try {
image_cover.pixbuf = new Gdk.Pixbuf.from_file_at_size (
GLib.Path.build_filename (Byte.utils.COVER_FOLDER, ("album-%i.jpg").printf (album_id)),
64,
64);
} catch (Error e) {
stderr.printf ("Error setting default avatar icon: %s ", e.message);
}
}
}

return false;
});
});
}
}
22 changes: 13 additions & 9 deletions src/Widgets/MediaControl.vala
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,20 @@ public class Widgets.MediaControl : Gtk.Revealer {
});

Byte.database.updated_track_cover.connect ((track_id) => {
if (Byte.player.current_track != null && track_id == Byte.player.current_track.id) {
try {
image_cover.pixbuf = new Gdk.Pixbuf.from_file_at_size (
GLib.Path.build_filename (Byte.utils.COVER_FOLDER, ("track-%i.jpg").printf (track_id)),
32,
32);
} catch (Error e) {
stderr.printf ("Error setting default avatar icon: %s ", e.message);
Idle.add (() => {
if (Byte.player.current_track != null && track_id == Byte.player.current_track.id) {
try {
image_cover.pixbuf = new Gdk.Pixbuf.from_file_at_size (
GLib.Path.build_filename (Byte.utils.COVER_FOLDER, ("track-%i.jpg").printf (track_id)),
32,
32);
} catch (Error e) {
stderr.printf ("Error setting default avatar icon: %s ", e.message);
}
}
}

return false;
});
});

timeline.scale.change_value.connect ((scroll, new_value) => {
Expand Down
32 changes: 17 additions & 15 deletions src/Widgets/TrackAlbumRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,29 @@ public class Widgets.TrackAlbumRow : Gtk.ListBoxRow {
child.destroy ();
}

var all_items = Byte.database.get_all_playlists ();

var item = new Gtk.MenuItem.with_label (_ ("Create New Playlist"));
item.get_style_context ().add_class ("track-options");
item.get_style_context ().add_class ("css-item");
item.activate.connect (() => {
//var new_playlist = library_manager.create_new_playlist ();
//library_manager.add_track_into_playlist (new_playlist, track.ID);
});
//playlists.add (item);
if (Byte.scan_service.is_sync == false) {
var all_items = Byte.database.get_all_playlists ();

foreach (var playlist in all_items) {
item = new Gtk.MenuItem.with_label (playlist.title);
var item = new Gtk.MenuItem.with_label (_ ("Create New Playlist"));
item.get_style_context ().add_class ("track-options");
item.get_style_context ().add_class ("css-item");
item.activate.connect (() => {
Byte.database.insert_track_into_playlist (playlist, track.id);
//var new_playlist = library_manager.create_new_playlist ();
//library_manager.add_track_into_playlist (new_playlist, track.ID);
});
playlists.add (item);
//playlists.add (item);

foreach (var playlist in all_items) {
item = new Gtk.MenuItem.with_label (playlist.title);
item.get_style_context ().add_class ("track-options");
item.get_style_context ().add_class ("css-item");
item.activate.connect (() => {
Byte.database.insert_track_into_playlist (playlist, track.id);
});
playlists.add (item);
}
playlists.show_all ();
}
playlists.show_all ();

menu.popup_at_pointer (null);
}
Expand Down
54 changes: 30 additions & 24 deletions src/Widgets/TrackRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,20 @@ public class Widgets.TrackRow : Gtk.ListBoxRow {
});

Byte.database.updated_track_cover.connect ((track_id) => {
if (track_id == track.id) {
try {
image_cover.pixbuf = new Gdk.Pixbuf.from_file_at_size (
GLib.Path.build_filename (Byte.utils.COVER_FOLDER, ("track-%i.jpg").printf (track_id)),
32,
32);
} catch (Error e) {
stderr.printf ("Error setting default avatar icon: %s ", e.message);
Idle.add (() => {
if (track_id == track.id) {
try {
image_cover.pixbuf = new Gdk.Pixbuf.from_file_at_size (
GLib.Path.build_filename (Byte.utils.COVER_FOLDER, ("track-%i.jpg").printf (track_id)),
32,
32);
} catch (Error e) {
stderr.printf ("Error setting default avatar icon: %s ", e.message);
}
}
}

return false;
});
});

Byte.database.updated_track_favorite.connect ((_track, favorite) => {
Expand Down Expand Up @@ -231,27 +235,29 @@ public class Widgets.TrackRow : Gtk.ListBoxRow {
child.destroy ();
}

var all_items = Byte.database.get_all_playlists ();
if (Byte.scan_service.is_sync == false) {
var all_items = Byte.database.get_all_playlists ();

var item = new Gtk.MenuItem.with_label (_ ("Create New Playlist"));
item.get_style_context ().add_class ("track-options");
item.get_style_context ().add_class ("css-item");
item.activate.connect (() => {
//var new_playlist = library_manager.create_new_playlist ();
//library_manager.add_track_into_playlist (new_playlist, track.ID);
});
//playlists.add (item);

foreach (var playlist in all_items) {
item = new Gtk.MenuItem.with_label (playlist.title);
var item = new Gtk.MenuItem.with_label (_ ("Create New Playlist"));
item.get_style_context ().add_class ("track-options");
item.get_style_context ().add_class ("css-item");
item.activate.connect (() => {
Byte.database.insert_track_into_playlist (playlist, track.id);
//var new_playlist = library_manager.create_new_playlist ();
//library_manager.add_track_into_playlist (new_playlist, track.ID);
});
playlists.add (item);
//playlists.add (item);

foreach (var playlist in all_items) {
item = new Gtk.MenuItem.with_label (playlist.title);
item.get_style_context ().add_class ("track-options");
item.get_style_context ().add_class ("css-item");
item.activate.connect (() => {
Byte.database.insert_track_into_playlist (playlist, track.id);
});
playlists.add (item);
}
playlists.show_all ();
}
playlists.show_all ();

menu.popup_at_pointer (null);
}
Expand Down

0 comments on commit 1d7ccda

Please sign in to comment.