| 1 | /* fre:ac - free audio converter |
| 2 | * Copyright (C) 2001-2018 Robert Kausch <[email protected]> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License as |
| 6 | * published by the Free Software Foundation, either version 2 of |
| 7 | * the License, or (at your option) any later version. |
| 8 | * |
| 9 | * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR |
| 10 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 11 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ |
| 12 | |
| 13 | #include <jobs/joblist/removeall.h> |
| 14 | |
| 15 | #include <boca.h> |
| 16 | |
| 17 | Signal0<Void> freac::JobRemoveAllTracks::onRemoveAllTracksJobScheduled; |
| 18 | |
| 19 | freac::JobRemoveAllTracks::JobRemoveAllTracks() |
| 20 | { |
| 21 | onPlanJob.Connect(&JobRemoveAllTracks::OnPlanJob, this); |
| 22 | } |
| 23 | |
| 24 | freac::JobRemoveAllTracks::~JobRemoveAllTracks() |
| 25 | { |
| 26 | onPlanJob.Disconnect(&JobRemoveAllTracks::OnPlanJob, this); |
| 27 | } |
| 28 | |
| 29 | Void freac::JobRemoveAllTracks::OnPlanJob(Job *job) |
| 30 | { |
| 31 | if (job != this) return; |
| 32 | |
| 33 | onRemoveAllTracksJobScheduled.Emit(); |
| 34 | } |
| 35 | |
| 36 | Bool freac::JobRemoveAllTracks::ReadyToRun() |
| 37 | { |
| 38 | BoCA::JobList *joblist = BoCA::JobList::Get(); |
| 39 | |
| 40 | if (joblist->IsLocked()) return False; |
| 41 | |
| 42 | joblist->Lock(); |
| 43 | |
| 44 | return True; |
| 45 | } |
| 46 | |
| 47 | Error freac::JobRemoveAllTracks::Perform() |
| 48 | { |
| 49 | BoCA::JobList *joblist = BoCA::JobList::Get(); |
| 50 | BoCA::I18n *i18n = BoCA::I18n::Get(); |
| 51 | |
| 52 | SetText(i18n->AddEllipsis(i18n->TranslateString("Removing all tracks", "Jobs::Joblist"))); |
| 53 | |
| 54 | joblist->doRemoveAllTracks.Call(); |
| 55 | |
| 56 | SetText(i18n->TranslateString("Removed all tracks from joblist", "Jobs::Joblist")); |
| 57 | |
| 58 | SetProgress(1000); |
| 59 | |
| 60 | joblist->Unlock(); |
| 61 | |
| 62 | return Success(); |
| 63 | } |