Skip to content

Commit

Permalink
Application: store repeat state in an Action (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Dec 10, 2022
1 parent 1689be7 commit b81565b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ namespace Audience {
public const string ACTION_NEXT = "action-next";
public const string ACTION_PLAY_PAUSE = "action-play-pause";
public const string ACTION_PREVIOUS = "action-previous";
public const string ACTION_REPEAT = "action-repeat";

private const ActionEntry[] ACTION_ENTRIES = {
{ ACTION_PLAY_PAUSE, action_play_pause, null, "false" },
{ ACTION_NEXT, action_next },
{ ACTION_REPEAT, null, null, "false"},
{ ACTION_PREVIOUS, action_previous }
};

Expand Down
9 changes: 0 additions & 9 deletions src/Widgets/Player/BottomBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@ public class Audience.Widgets.BottomBar : Gtk.Revealer {
}
}

public bool repeat {
get {
return playlist_popover.rep.active;
}
set {
playlist_popover.rep.active = value;
}
}

public BottomBar (ClutterGst.Playback playback) {
play_button = new Gtk.Button.from_icon_name ("media-playback-start-symbolic", Gtk.IconSize.BUTTON) {
action_name = App.ACTION_PREFIX + App.ACTION_PLAY_PAUSE,
Expand Down
3 changes: 2 additions & 1 deletion src/Widgets/Player/PlayerPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ namespace Audience {
Idle.add (() => {
playback.progress = 0;
if (!get_playlist_widget ().next ()) {
if (bottom_bar.repeat) {
var repeat_action = Application.get_default ().lookup_action (Audience.App.ACTION_REPEAT);
if (repeat_action.get_state ().get_boolean ()) {
string file = get_playlist_widget ().get_first_item ().get_uri ();
((Audience.Window) App.get_instance ().active_window).open_files ({ File.new_for_uri (file) });
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/Widgets/Player/PlaylistPopover.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

public class Audience.Widgets.PlaylistPopover : Gtk.Popover {
public Playlist playlist { get; private set; }
public Gtk.ToggleButton rep { get; private set; }

private Gtk.Button dvd;
private const int HEIGHT_OFFSET = 300;
Expand All @@ -36,7 +35,8 @@ public class Audience.Widgets.PlaylistPopover : Gtk.Popover {
var clear_playlist_button = new Gtk.Button.from_icon_name ("edit-delete-symbolic", Gtk.IconSize.BUTTON);
clear_playlist_button.tooltip_text = _("Clear Playlist");

rep = new Gtk.ToggleButton () {
var rep = new Gtk.ToggleButton () {
action_name = App.ACTION_PREFIX + App.ACTION_REPEAT,
image = new Gtk.Image.from_icon_name ("media-playlist-no-repeat-symbolic", Gtk.IconSize.BUTTON),
tooltip_text = _("Enable Repeat")
};
Expand Down

0 comments on commit b81565b

Please sign in to comment.