Skip to content

Commit

Permalink
fix #13 #11 #10 #9
Browse files Browse the repository at this point in the history
  • Loading branch information
Alain M committed Aug 10, 2019
1 parent bbb7407 commit 937667d
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 13 deletions.
23 changes: 14 additions & 9 deletions data/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
background-color: @colorAccent;
}

.album-row button {
color: @colorAccent;
background-color: transparent;
}

.album-row button image {
color: @colorAccent;
}

.album-row {
color: @text_color;
background-color: transparent;
}

.track-row {
background-color: transparent;
}
Expand Down Expand Up @@ -112,15 +126,6 @@
0 1px 2px alpha (#000, 0.24);
}

.album-row {
background-color: transparent;
}

.album-row:focus {
background-color: transparent;
color: @text_color;
}

.radio-search-row:selected {
background-color: transparent;
}
Expand Down
22 changes: 22 additions & 0 deletions src/Services/Database.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,28 @@ public class Services.Database : GLib.Object {
}
}

public bool remove_radio_from_library (Objects.Radio radio) {
Sqlite.Statement stmt;
string sql;
int res;

sql = """
DELETE FROM radios where id = ?;
""";

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

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

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

return false;
}

public bool remove_from_playlist (Objects.Track track) {
Sqlite.Statement stmt;
string sql;
Expand Down
1 change: 0 additions & 1 deletion src/Widgets/HeaderBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ public class Widgets.HeaderBar : Gtk.HeaderBar {
menu_popover.add (menu_grid);

app_menu = new Gtk.MenuButton ();
//app_menu.border_width = 6;
app_menu.valign = Gtk.Align.CENTER;
app_menu.tooltip_text = _("Menu");
app_menu.popover = menu_popover;
Expand Down
62 changes: 60 additions & 2 deletions src/Widgets/RadioRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class Widgets.RadioRow : Gtk.ListBoxRow {
name_label.get_style_context ().add_class ("font-bold");
name_label.ellipsize = Pango.EllipsizeMode.END;
name_label.halign = Gtk.Align.START;
name_label.valign = Gtk.Align.END;
name_label.valign = Gtk.Align.END;

country_state_label = new Gtk.Label ("%s - %s".printf (radio.country, radio.state));
country_state_label.halign = Gtk.Align.START;
Expand All @@ -53,15 +53,36 @@ public class Widgets.RadioRow : Gtk.ListBoxRow {
overlay.add_overlay (playing_revealer);
overlay.add (image_cover);

var remove_button = new Gtk.Button.from_icon_name ("edit-delete-symbolic", Gtk.IconSize.MENU);
remove_button.can_focus = false;
remove_button.valign = Gtk.Align.CENTER;
remove_button.tooltip_text = _("Remove");
remove_button.margin_end = 3;
remove_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);
remove_button.get_style_context ().add_class ("options-button");
remove_button.get_style_context ().remove_class ("button");

var remove_revealer = new Gtk.Revealer ();
remove_revealer.halign = Gtk.Align.END;
remove_revealer.hexpand = true;
remove_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT ;
remove_revealer.add (remove_button);
remove_revealer.reveal_child = false;

var main_grid = new Gtk.Grid ();
main_grid.margin = 3;
main_grid.margin_end = 6;
main_grid.column_spacing = 6;
main_grid.attach (overlay, 0, 0, 1, 2);
main_grid.attach (name_label, 1, 0, 1, 1);
main_grid.attach (country_state_label, 1, 1, 1, 1);
main_grid.attach (remove_revealer, 2, 0, 2, 2);

add (main_grid);
var eventbox = new Gtk.EventBox ();
eventbox.add_events (Gdk.EventMask.ENTER_NOTIFY_MASK | Gdk.EventMask.LEAVE_NOTIFY_MASK);
eventbox.add (main_grid);

add (eventbox);

Byte.player.current_radio_changed.connect ((current_radio) => {
if (radio.id == current_radio.id) {
Expand All @@ -70,5 +91,42 @@ public class Widgets.RadioRow : Gtk.ListBoxRow {
playing_revealer.reveal_child = false;
}
});

eventbox.enter_notify_event.connect ((event) => {
remove_revealer.reveal_child = true;
return false;
});

eventbox.leave_notify_event.connect ((event) => {
if (event.detail == Gdk.NotifyType.INFERIOR) {
return false;
}

remove_revealer.reveal_child = false;
return false;
});

remove_button.clicked.connect (() => {
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
"Delete from library?",
"Are you sure you want to delete <b>%s</b> from your library?".printf (radio.name),
"dialog-warning",
Gtk.ButtonsType.CANCEL
);

var set_button = new Gtk.Button.with_label (_("Delete"));
set_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
message_dialog.add_action_widget (set_button, Gtk.ResponseType.ACCEPT);

message_dialog.show_all ();

if (message_dialog.run () == Gtk.ResponseType.ACCEPT) {
if (Byte.database.remove_radio_from_library (radio)) {
destroy ();
}
}

message_dialog.destroy ();
});
}
}
19 changes: 18 additions & 1 deletion src/Widgets/TrackRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,24 @@ public class Widgets.TrackRow : Gtk.ListBoxRow {
});

remove_db_menu.activate.connect (() => {
Byte.database.remove_from_library (track);
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
"Delete from library?",
"Are you sure you want to delete <b>%s</b> from your library?".printf (track.title),
"dialog-warning",
Gtk.ButtonsType.CANCEL
);

var set_button = new Gtk.Button.with_label (_("Delete"));
set_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
message_dialog.add_action_widget (set_button, Gtk.ResponseType.ACCEPT);

message_dialog.show_all ();

if (message_dialog.run () == Gtk.ResponseType.ACCEPT) {
Byte.database.remove_from_library (track);
}

message_dialog.destroy ();
});

remove_file_menu.activate.connect (() => {
Expand Down

0 comments on commit 937667d

Please sign in to comment.