Skip to content

Commit

Permalink
fix ...
Browse files Browse the repository at this point in the history
  • Loading branch information
Alain M committed Aug 6, 2019
1 parent c8395f7 commit 447e173
Show file tree
Hide file tree
Showing 19 changed files with 83 additions and 57 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ A music player without the library management. Just toss in your music to the pl
![Byte Screenshot](https://github.com/alainm23/byte/raw/master/data/screenshot/screenshot-01.png)
![Byte Screenshot](https://github.com/alainm23/byte/raw/master/data/screenshot/screenshot-02.png)
![Byte Screenshot](https://github.com/alainm23/byte/raw/master/data/screenshot/screenshot-03.png)
![Byte Screenshot](https://github.com/alainm23/byte/raw/master/data/screenshot/screenshot-04.png)
![Byte Screenshot](https://github.com/alainm23/byte/raw/master/data/screenshot/screenshot-05.png)

## Building and Installation

Expand Down
6 changes: 6 additions & 0 deletions data/com.github.alainm23.byte.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
<screenshot>
<image>https://raw.githubusercontent.com/alainm23/byte/master/data/screenshot/screenshot-03.png</image>
</screenshot>
<screenshot>
<image>https://raw.githubusercontent.com/alainm23/byte/master/data/screenshot/screenshot-04.png</image>
</screenshot>
<screenshot>
<image>https://raw.githubusercontent.com/alainm23/byte/master/data/screenshot/screenshot-05.png</image>
</screenshot>
</screenshots>
<content_rating type="oars-1.1">
<content_attribute id="violence-cartoon">none</content_attribute>
Expand Down
Binary file modified data/screenshot/screenshot-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/screenshot/screenshot-02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/screenshot/screenshot-03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/screenshot/screenshot-04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/screenshot/screenshot-05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/Services/Database.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,31 @@ public class Services.Database : GLib.Object {
}
}

public bool remove_from_playlist (Objects.Track track) {
Sqlite.Statement stmt;
string sql;
int res;

sql = """
DELETE FROM playlist_tracks where track_id = ? AND playlist_id = ?;
""";

res = db.prepare_v2 (sql, -1, out stmt);
assert (res == Sqlite.OK);

res = stmt.bind_int (1, track.id);
assert (res == Sqlite.OK);

res = stmt.bind_int (2, track.playlist);
assert (res == Sqlite.OK);

if (stmt.step () == Sqlite.DONE) {
return true;
} else {
return false;
}
}

public void reset_all_library () {
File db_path = File.new_for_path (db_path);
try {
Expand Down
40 changes: 17 additions & 23 deletions src/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,25 @@ public class Utils : GLib.Object {
COVER_FOLDER = GLib.Path.build_filename (MAIN_FOLDER, "covers");
}

public void set_items (Gee.ArrayList<Objects.Track?> all_items, bool shuffle_mode, Objects.Track? track) {
/*
print ("-------------------\n");
foreach (var item in queue_playlist) {
print ("Track: %s\n".printf (item.title));
}
print ("--------------------\n");
*/

if (shuffle_mode) {
queue_playlist = generate_shuffle (all_items);

if (track != null) {
int index = get_track_index_by_id (track.id, queue_playlist);
queue_playlist.remove_at (index);
queue_playlist.insert (0, track);
public void set_items (Gee.ArrayList<Objects.Track?> all_items, bool shuffle_mode, Objects.Track? track) {
if (all_items.size > 0) {
if (shuffle_mode) {
queue_playlist = generate_shuffle (all_items);

if (track != null) {
int index = get_track_index_by_id (track.id, queue_playlist);
queue_playlist.remove_at (index);
queue_playlist.insert (0, track);
}

Byte.settings.set_boolean ("shuffle-mode", true);
} else {
queue_playlist = playlist_order (all_items);
Byte.settings.set_boolean ("shuffle-mode", false);
}

Byte.settings.set_boolean ("shuffle-mode", true);
} else {
queue_playlist = playlist_order (all_items);
Byte.settings.set_boolean ("shuffle-mode", false);
}

play_items (queue_playlist, track);
play_items (queue_playlist, track);
}
}

public void shuffle_changed (bool shuffle_mode) {
Expand Down
12 changes: 3 additions & 9 deletions src/Views/Album.vala
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ public class Views.Album : Gtk.EventBox {

var action_grid = new Gtk.Grid ();
action_grid.margin = 6;
action_grid.margin_start = 12;
action_grid.margin_end = 12;
action_grid.column_spacing = 12;
action_grid.add (play_button);
action_grid.add (shuffle_button);
Expand All @@ -153,20 +151,16 @@ public class Views.Album : Gtk.EventBox {

var album_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
album_box.hexpand = true;
album_box.margin = 12;
album_box.margin_bottom = 6;
album_box.margin_top = 12;
album_box.margin = 6;
album_box.pack_start (image_cover, false, false, 0);
album_box.pack_start (detail_box, false, false, 0);

listbox = new Gtk.ListBox ();
listbox.expand = true;
listbox.margin_start = 9;
listbox.margin_end = 9;

var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
separator.margin_start = 14;
separator.margin_end = 9;
separator.margin_start = 6;
separator.margin_end = 6;

var scrolled_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
scrolled_box.expand = true;
Expand Down
3 changes: 3 additions & 0 deletions src/Views/Home.vala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ public class Views.Home : Gtk.EventBox {
var playlists_button = new Widgets.HomeButton (_("Playlists"), "playlist-symbolic");
var albums_button = new Widgets.HomeButton (_("Albums"), "byte-album-symbolic");
var songs_button = new Widgets.HomeButton (_("Songs"), "folder-music-symbolic");

var artists_button = new Widgets.HomeButton ("Artists", "byte-artist-symbolic");
artists_button.sensitive = false;

var radios_button = new Widgets.HomeButton ("Radios", "byte-radio-symbolic");
var favorites_button = new Widgets.HomeButton ("Favorites", "byte-favorite-symbolic");

Expand Down
16 changes: 5 additions & 11 deletions src/Views/Playlist.vala
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ public class Views.Playlist : Gtk.EventBox {

var action_grid = new Gtk.Grid ();
action_grid.margin = 6;
action_grid.margin_start = 12;
action_grid.margin_end = 12;
action_grid.column_spacing = 12;
action_grid.add (play_button);
action_grid.add (shuffle_button);
Expand All @@ -175,24 +173,20 @@ public class Views.Playlist : Gtk.EventBox {

var album_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
album_box.hexpand = true;
album_box.margin = 12;
album_box.margin_bottom = 6;
album_box.margin_top = 12;
album_box.margin = 6;
album_box.pack_start (image_cover, false, false, 0);
album_box.pack_start (detail_box, false, false, 0);

listbox = new Gtk.ListBox ();
listbox.expand = true;
listbox.margin_start = 9;
listbox.margin_end = 9;

var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
separator.margin_start = 14;
separator.margin_end = 9;
separator.margin_start = 6;
separator.margin_end = 6;

var separator_2 = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
separator_2.margin_start = 14;
separator_2.margin_end = 9;
separator_2.margin_start = 6;
separator_2.margin_end = 6;

var scrolled_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
scrolled_box.expand = true;
Expand Down
9 changes: 5 additions & 4 deletions src/Widgets/AlertView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class Widgets.AlertView : Gtk.Grid {
set {
if (value != null && value != "") {
image.gicon = new ThemedIcon (value);
image.pixel_size = 48;
image.pixel_size = 32;
image.no_show_all = false;
image.show ();
} else {
Expand Down Expand Up @@ -73,7 +73,7 @@ public class Widgets.AlertView : Gtk.Grid {
title_label = new Gtk.Label (null);
title_label.halign = Gtk.Align.CENTER;
title_label.hexpand = true;
title_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL);
title_label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);
title_label.max_width_chars = 75;
title_label.wrap = true;
title_label.wrap_mode = Pango.WrapMode.WORD_CHAR;
Expand All @@ -83,20 +83,21 @@ public class Widgets.AlertView : Gtk.Grid {
description_label.hexpand = true;
description_label.max_width_chars = 75;
description_label.wrap = true;
description_label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);
//description_label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);
description_label.use_markup = true;
description_label.xalign = 0;
description_label.valign = Gtk.Align.START;
description_label.halign = Gtk.Align.CENTER;

image = new Gtk.Image ();
image.opacity = 1;
image.margin_bottom = 6;
image.valign = Gtk.Align.START;

var layout = new Gtk.Grid ();
//layout.get_style_context ().add_class ("label-color-primary");
layout.orientation = Gtk.Orientation.VERTICAL;
layout.row_spacing = 6;
layout.row_spacing = 0;
layout.halign = Gtk.Align.CENTER;
layout.valign = Gtk.Align.START;
layout.vexpand = true;
Expand Down
1 change: 1 addition & 0 deletions src/Widgets/HeaderBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public class Widgets.HeaderBar : Gtk.HeaderBar {
*/

var search_menuitem = new Widgets.ModelButton (_("Search"), "edit-find-symbolic", _("Search"));
search_menuitem.sensitive = false;
var import_menuitem = new Widgets.ModelButton (_("Import Music"), "document-import-symbolic", _("Import Music"));
var resync_menuitem = new Widgets.ModelButton (_("Resync Libray"), "emblem-synchronizing-symbolic", _("Resync Libray"));
var preferences_menuitem = new Widgets.ModelButton (_("Preferences"), "preferences-system-symbolic", _("Preferences"));
Expand Down
3 changes: 3 additions & 0 deletions src/Widgets/PlaylistRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ public class Widgets.PlaylistRow : Gtk.ListBoxRow {
title_label.halign = Gtk.Align.START;
title_label.valign = Gtk.Align.END;

/*
var tracks_label = new Gtk.Label ("Updated %s".printf(
Granite.DateTime.get_relative_datetime (
new GLib.DateTime.from_iso8601 (playlist.date_updated, new GLib.TimeZone.local ())
))
);
*/
var tracks_label = new Gtk.Label (null);
tracks_label.get_style_context ().add_class ("h3");
tracks_label.halign = Gtk.Align.START;
tracks_label.valign = Gtk.Align.START;
Expand Down
6 changes: 3 additions & 3 deletions src/Widgets/Queue.vala
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public class Widgets.Queue : Gtk.Revealer {
*/

var notification_image = new Gtk.Image ();
notification_image.gicon = new ThemedIcon ("notification-symbolic");
notification_image.pixel_size = 24;
notification_image.gicon = new ThemedIcon ("byte-favorite-symbolic");
notification_image.pixel_size = 16;
notification_image.margin_top = 1;
notification_image.valign = Gtk.Align.CENTER;
notification_image.halign = Gtk.Align.CENTER;
Expand Down Expand Up @@ -145,7 +145,7 @@ public class Widgets.Queue : Gtk.Revealer {
mode_button.margin = 3;
mode_button.append_text (_("Up Next"));
//mode_button.append_text (_("History"));
mode_button.append_text (_("Lyrics"));
//mode_button.append_text (_("Lyrics"));
mode_button.selected = 0;

var title_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
Expand Down
4 changes: 2 additions & 2 deletions src/Widgets/QuickFind.vala
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public class Widgets.QuickFind : Gtk.Revealer {
radios_spinner.start ();

var alert_view = new Widgets.AlertView (
_("No Results"),
_("lorem"),
_("Discovery..."),
_("Search your favorite radios"),
"edit-find-symbolic"
);

Expand Down
5 changes: 3 additions & 2 deletions src/Widgets/TrackAlbumRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class Widgets.TrackAlbumRow : Gtk.ListBoxRow {

var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
separator.margin_start = 6;
separator.margin_end = 6;

var grid = new Gtk.Grid ();
grid.hexpand = true;
Expand Down Expand Up @@ -157,7 +158,7 @@ public class Widgets.TrackAlbumRow : Gtk.ListBoxRow {
//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);
Expand Down Expand Up @@ -236,7 +237,7 @@ public class Widgets.TrackAlbumRow : Gtk.ListBoxRow {
menu.add (play_last_menu);
menu.add (new Gtk.SeparatorMenuItem ());
menu.add (add_playlist_menu);
menu.add (edit_menu);
//menu.add (edit_menu);
menu.add (favorite_menu);
menu.add (new Gtk.SeparatorMenuItem ());

Expand Down
8 changes: 5 additions & 3 deletions src/Widgets/TrackRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public class Widgets.TrackRow : Gtk.ListBoxRow {
//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);
Expand Down Expand Up @@ -319,7 +319,7 @@ public class Widgets.TrackRow : Gtk.ListBoxRow {
menu.add (play_last_menu);
menu.add (new Gtk.SeparatorMenuItem ());
menu.add (add_playlist_menu);
menu.add (edit_menu);
//menu.add (edit_menu);
menu.add (favorite_menu);
menu.add (new Gtk.SeparatorMenuItem ());

Expand Down Expand Up @@ -372,7 +372,9 @@ public class Widgets.TrackRow : Gtk.ListBoxRow {
});

remove_playlist_menu.activate.connect (() => {
destroy ();
if (Byte.database.remove_from_playlist (track)) {
destroy ();
}
});
}
}

0 comments on commit 447e173

Please sign in to comment.