1 /***************************************************************************
2 * Copyright (C) 2008-2012 by Andrzej Rybczak *
3 * electricityispower@gmail.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
31 aDummy
, aMouseEvent
, aScrollUp
, aScrollDown
, aScrollUpArtist
, aScrollUpAlbum
, aScrollDownArtist
,
32 aScrollDownAlbum
, aPageUp
, aPageDown
, aMoveHome
, aMoveEnd
, aToggleInterface
, aJumpToParentDir
,
33 aPressEnter
, aPressSpace
, aPreviousColumn
, aNextColumn
, aMasterScreen
, aSlaveScreen
, aVolumeUp
,
34 aVolumeDown
, aDelete
, aReplaySong
, aPreviousSong
, aNextSong
, aPause
, aStop
, aSavePlaylist
,
35 aMoveSortOrderUp
, aMoveSortOrderDown
, aMoveSelectedItemsUp
, aMoveSelectedItemsDown
,
36 aMoveSelectedItemsTo
, aAdd
, aSeekForward
, aSeekBackward
, aToggleDisplayMode
, aToggleSeparatorsBetweenAlbums
,
37 aToggleLyricsFetcher
, aToggleFetchingLyricsInBackground
, aToggleAutoCenter
, aUpdateDatabase
,
38 aJumpToPlayingSong
, aToggleRepeat
, aShuffle
, aToggleRandom
, aStartSearching
, aSaveTagChanges
,
39 aToggleSingle
, aToggleConsume
, aToggleCrossfade
, aSetCrossfade
, aEditSong
, aEditLibraryTag
,
40 aEditLibraryAlbum
, aEditDirectoryName
, aEditPlaylistName
, aEditLyrics
, aJumpToBrowser
,
41 aJumpToMediaLibrary
, aJumpToPlaylistEditor
, aToggleScreenLock
, aJumpToTagEditor
,
42 aJumpToPositionInSong
, aReverseSelection
, aRemoveSelection
, aSelectAlbum
, aAddSelectedItems
,
43 aCropMainPlaylist
, aCropPlaylist
, aClearMainPlaylist
, aClearPlaylist
, aSortPlaylist
, aReversePlaylist
,
44 aApplyFilter
, aFind
, aFindItemForward
, aFindItemBackward
, aNextFoundItem
,
45 aPreviousFoundItem
, aToggleFindMode
, aToggleReplayGainMode
, aToggleSpaceMode
, aToggleAddMode
,
46 aToggleMouse
, aToggleBitrateVisibility
, aAddRandomItems
, aToggleBrowserSortMode
, aToggleLibraryTagType
,
47 aRefetchLyrics
, aRefetchArtistInfo
, aSetSelectedItemsPriority
, aShowSongInfo
, aShowArtistInfo
,
48 aShowLyrics
, aQuit
, aNextScreen
, aPreviousScreen
, aShowHelp
, aShowPlaylist
, aShowBrowser
,
49 aShowSearchEngine
, aShowMediaLibrary
, aShowPlaylistEditor
, aShowTagEditor
, aShowOutputs
,
50 aShowVisualizer
, aShowClock
, aShowServerInfo
55 enum FindDirection
{ fdForward
, fdBackward
};
57 Action(ActionType type
, const char *name
) : itsType(type
), itsName(name
) { }
59 const char *Name() const { return itsName
; }
60 ActionType
Type() const { return itsType
; }
62 virtual bool canBeRun() const { return true; }
74 static void ValidateScreenSize();
75 static void SetResizeFlags();
76 static void ResizeScreen();
77 static void SetWindowsDimensions();
79 static bool ConnectToMPD();
80 static bool AskYesNoQuestion(const std::string
&question
, void (*callback
)());
81 static bool isMPDMusicDirSet();
83 static Action
*Get(ActionType at
);
84 static Action
*Get(const std::string
&name
);
86 static bool OriginalStatusbarVisibility
;
87 static bool DesignChanged
;
88 static bool OrderResize
;
89 static bool ExitMainLoop
;
91 static size_t HeaderHeight
;
92 static size_t FooterHeight
;
93 static size_t FooterStartY
;
96 virtual void Run() = 0;
99 static void FindItem(const FindDirection
);
100 static void ListsChangeFinisher();
107 struct Dummy
: public Action
109 Dummy() : Action(aDummy
, "dummy") { }
112 virtual void Run() { }
115 struct MouseEvent
: public Action
117 MouseEvent() : Action(aMouseEvent
, "mouse_event") { }
120 virtual bool canBeRun() const;
124 MEVENT itsMouseEvent
;
125 MEVENT itsOldMouseEvent
;
128 struct ScrollUp
: public Action
130 ScrollUp() : Action(aScrollUp
, "scroll_up") { }
136 struct ScrollDown
: public Action
138 ScrollDown() : Action(aScrollDown
, "scroll_down") { }
144 struct ScrollUpArtist
: public Action
146 ScrollUpArtist() : Action(aScrollUpArtist
, "scroll_up_artist") { }
149 virtual bool canBeRun() const;
153 struct ScrollUpAlbum
: public Action
155 ScrollUpAlbum() : Action(aScrollUpAlbum
, "scroll_up_album") { }
158 virtual bool canBeRun() const;
162 struct ScrollDownArtist
: public Action
164 ScrollDownArtist() : Action(aScrollDownArtist
, "scroll_down_artist") { }
167 virtual bool canBeRun() const;
171 struct ScrollDownAlbum
: public Action
173 ScrollDownAlbum() : Action(aScrollDownAlbum
, "scroll_down_album") { }
176 virtual bool canBeRun() const;
180 struct PageUp
: public Action
182 PageUp() : Action(aPageUp
, "page_up") { }
188 struct PageDown
: public Action
190 PageDown() : Action(aPageDown
, "page_down") { }
196 struct MoveHome
: public Action
198 MoveHome() : Action(aMoveHome
, "move_home") { }
204 struct MoveEnd
: public Action
206 MoveEnd() : Action(aMoveEnd
, "move_end") { }
212 struct ToggleInterface
: public Action
214 ToggleInterface() : Action(aToggleInterface
, "toggle_inferface") { }
220 struct JumpToParentDir
: public Action
222 JumpToParentDir() : Action(aJumpToParentDir
, "jump_to_parent_dir") { }
225 virtual bool canBeRun() const;
229 struct PressEnter
: public Action
231 PressEnter() : Action(aPressEnter
, "press_enter") { }
237 struct PressSpace
: public Action
239 PressSpace() : Action(aPressSpace
, "press_space") { }
245 struct PreviousColumn
: public Action
247 PreviousColumn() : Action(aPreviousColumn
, "previous_column") { }
250 virtual bool canBeRun() const;
254 struct NextColumn
: public Action
256 NextColumn() : Action(aNextColumn
, "next_column") { }
259 virtual bool canBeRun() const;
263 struct MasterScreen
: public Action
265 MasterScreen() : Action(aMasterScreen
, "master_screen") { }
268 virtual bool canBeRun() const;
272 struct SlaveScreen
: public Action
274 SlaveScreen() : Action(aSlaveScreen
, "slave_screen") { }
277 virtual bool canBeRun() const;
281 struct VolumeUp
: public Action
283 VolumeUp() : Action(aVolumeUp
, "volume_up") { }
289 struct VolumeDown
: public Action
291 VolumeDown() : Action(aVolumeDown
, "volume_down") { }
297 struct Delete
: public Action
299 Delete() : Action(aDelete
, "delete") { }
305 struct ReplaySong
: public Action
307 ReplaySong() : Action(aReplaySong
, "replay_song") { }
313 struct PreviousSong
: public Action
315 PreviousSong() : Action(aPreviousSong
, "previous") { }
321 struct NextSong
: public Action
323 NextSong() : Action(aNextSong
, "next") { }
329 struct Pause
: public Action
331 Pause() : Action(aPause
, "pause") { }
337 struct Stop
: public Action
339 Stop() : Action(aStop
, "stop") { }
345 struct SavePlaylist
: public Action
347 SavePlaylist() : Action(aSavePlaylist
, "save_playlist") { }
353 struct MoveSortOrderUp
: public Action
355 MoveSortOrderUp() : Action(aMoveSortOrderUp
, "move_sort_order_up") { }
358 virtual bool canBeRun() const;
362 struct MoveSortOrderDown
: public Action
364 MoveSortOrderDown() : Action(aMoveSortOrderDown
, "move_sort_order_down") { }
367 virtual bool canBeRun() const;
371 struct MoveSelectedItemsUp
: public Action
373 MoveSelectedItemsUp() : Action(aMoveSelectedItemsUp
, "move_selected_items_up") { }
376 virtual bool canBeRun() const;
380 struct MoveSelectedItemsDown
: public Action
382 MoveSelectedItemsDown() : Action(aMoveSelectedItemsDown
, "move_selected_items_down") { }
385 virtual bool canBeRun() const;
389 struct MoveSelectedItemsTo
: public Action
391 MoveSelectedItemsTo() : Action(aMoveSelectedItemsTo
, "move_selected_items_to") { }
394 virtual bool canBeRun() const;
398 struct Add
: public Action
400 Add() : Action(aAdd
, "add") { }
403 virtual bool canBeRun() const;
407 struct SeekForward
: public Action
409 SeekForward() : Action(aSeekForward
, "seek_forward") { }
412 virtual bool canBeRun() const;
416 struct SeekBackward
: public Action
418 SeekBackward() : Action(aSeekBackward
, "seek_backward") { }
421 virtual bool canBeRun() const;
425 struct ToggleDisplayMode
: public Action
427 ToggleDisplayMode() : Action(aToggleDisplayMode
, "toggle_display_mode") { }
430 virtual bool canBeRun() const;
434 struct ToggleSeparatorsBetweenAlbums
: public Action
436 ToggleSeparatorsBetweenAlbums()
437 : Action(aToggleSeparatorsBetweenAlbums
, "toggle_separators_between_albums") { }
440 virtual bool canBeRun() const;
444 struct ToggleLyricsFetcher
: public Action
446 ToggleLyricsFetcher() : Action(aToggleLyricsFetcher
, "toggle_lyrics_fetcher") { }
449 # ifndef HAVE_CURL_CURL_H
450 virtual bool canBeRun() const;
451 # endif // NOT HAVE_CURL_CURL_H
455 struct ToggleFetchingLyricsInBackground
: public Action
457 ToggleFetchingLyricsInBackground()
458 : Action(aToggleFetchingLyricsInBackground
, "toggle_fetching_lyrics_in_background") { }
461 # ifndef HAVE_CURL_CURL_H
462 virtual bool canBeRun() const;
463 # endif // NOT HAVE_CURL_CURL_H
467 struct ToggleAutoCenter
: public Action
469 ToggleAutoCenter() : Action(aToggleAutoCenter
, "toggle_autocentering") { }
475 struct UpdateDatabase
: public Action
477 UpdateDatabase() : Action(aUpdateDatabase
, "update_database") { }
483 struct JumpToPlayingSong
: public Action
485 JumpToPlayingSong() : Action(aJumpToPlayingSong
, "jump_to_playing_song") { }
488 virtual bool canBeRun() const;
492 struct ToggleRepeat
: public Action
494 ToggleRepeat() : Action(aToggleRepeat
, "toggle_repeat") { }
500 struct Shuffle
: public Action
502 Shuffle() : Action(aShuffle
, "shuffle") { }
508 struct ToggleRandom
: public Action
510 ToggleRandom() : Action(aToggleRandom
, "toggle_random") { }
516 struct StartSearching
: public Action
518 StartSearching() : Action(aStartSearching
, "start_searching") { }
521 virtual bool canBeRun() const;
525 struct SaveTagChanges
: public Action
527 SaveTagChanges() : Action(aSaveTagChanges
, "save_tag_changes") { }
530 virtual bool canBeRun() const;
534 struct ToggleSingle
: public Action
536 ToggleSingle() : Action(aToggleSingle
, "toggle_single") { }
542 struct ToggleConsume
: public Action
544 ToggleConsume() : Action(aToggleConsume
, "toggle_consume") { }
550 struct ToggleCrossfade
: public Action
552 ToggleCrossfade() : Action(aToggleCrossfade
, "toggle_crossfade") { }
558 struct SetCrossfade
: public Action
560 SetCrossfade() : Action(aSetCrossfade
, "set_crossfade") { }
566 struct EditSong
: public Action
568 EditSong() : Action(aEditSong
, "edit_song") { }
571 virtual bool canBeRun() const;
575 struct EditLibraryTag
: public Action
577 EditLibraryTag() : Action(aEditLibraryTag
, "edit_library_tag") { }
580 virtual bool canBeRun() const;
584 struct EditLibraryAlbum
: public Action
586 EditLibraryAlbum() : Action(aEditLibraryAlbum
, "edit_library_album") { }
589 virtual bool canBeRun() const;
593 struct EditDirectoryName
: public Action
595 EditDirectoryName() : Action(aEditDirectoryName
, "edit_directory_name") { }
598 virtual bool canBeRun() const;
602 struct EditPlaylistName
: public Action
604 EditPlaylistName() : Action(aEditPlaylistName
, "edit_playlist_name") { }
607 virtual bool canBeRun() const;
611 struct EditLyrics
: public Action
613 EditLyrics() : Action(aEditLyrics
, "edit_lyrics") { }
616 virtual bool canBeRun() const;
620 struct JumpToBrowser
: public Action
622 JumpToBrowser() : Action(aJumpToBrowser
, "jump_to_browser") { }
625 virtual bool canBeRun() const;
629 struct JumpToMediaLibrary
: public Action
631 JumpToMediaLibrary() : Action(aJumpToMediaLibrary
, "jump_to_media_library") { }
634 virtual bool canBeRun() const;
638 struct JumpToPlaylistEditor
: public Action
640 JumpToPlaylistEditor() : Action(aJumpToPlaylistEditor
, "jump_to_playlist_editor") { }
643 virtual bool canBeRun() const;
647 struct ToggleScreenLock
: public Action
649 ToggleScreenLock() : Action(aToggleScreenLock
, "toggle_screen_lock") { }
655 struct JumpToTagEditor
: public Action
657 JumpToTagEditor() : Action(aJumpToTagEditor
, "jump_to_tag_editor") { }
660 virtual bool canBeRun() const;
664 struct JumpToPositionInSong
: public Action
666 JumpToPositionInSong() : Action(aJumpToPositionInSong
, "jump_to_position_in_song") { }
669 virtual bool canBeRun() const;
673 struct ReverseSelection
: public Action
675 ReverseSelection() : Action(aReverseSelection
, "reverse_selection") { }
678 virtual bool canBeRun() const;
682 struct RemoveSelection
: public Action
684 RemoveSelection() : Action(aRemoveSelection
, "remove_selection") { }
687 virtual bool canBeRun() const;
691 struct SelectAlbum
: public Action
693 SelectAlbum() : Action(aSelectAlbum
, "select_album") { }
696 virtual bool canBeRun() const;
700 struct AddSelectedItems
: public Action
702 AddSelectedItems() : Action(aAddSelectedItems
, "add_selected_items") { }
708 struct CropMainPlaylist
: public Action
710 CropMainPlaylist() : Action(aCropMainPlaylist
, "crop_main_playlist") { }
716 struct CropPlaylist
: public Action
718 CropPlaylist() : Action(aCropPlaylist
, "crop_playlist") { }
721 virtual bool canBeRun() const;
725 struct ClearMainPlaylist
: public Action
727 ClearMainPlaylist() : Action(aClearMainPlaylist
, "clear_main_playlist") { }
733 struct ClearPlaylist
: public Action
735 ClearPlaylist() : Action(aClearPlaylist
, "clear_playlist") { }
738 virtual bool canBeRun() const;
742 struct SortPlaylist
: public Action
744 SortPlaylist() : Action(aSortPlaylist
, "sort_playlist") { }
747 virtual bool canBeRun() const;
751 struct ReversePlaylist
: public Action
753 ReversePlaylist() : Action(aReversePlaylist
, "reverse_playlist") { }
756 virtual bool canBeRun() const;
760 struct ApplyFilter
: public Action
762 ApplyFilter() : Action(aApplyFilter
, "apply_filter") { }
765 virtual bool canBeRun() const;
769 struct Find
: public Action
771 Find() : Action(aFind
, "find") { }
774 virtual bool canBeRun() const;
778 struct FindItemForward
: public Action
780 FindItemForward() : Action(aFindItemForward
, "find_item_forward") { }
783 virtual bool canBeRun() const;
787 struct FindItemBackward
: public Action
789 FindItemBackward() : Action(aFindItemBackward
, "find_item_backward") { }
792 virtual bool canBeRun() const;
796 struct NextFoundItem
: public Action
798 NextFoundItem() : Action(aNextFoundItem
, "next_found_item") { }
801 virtual bool canBeRun() const;
805 struct PreviousFoundItem
: public Action
807 PreviousFoundItem() : Action(aPreviousFoundItem
, "previous_found_item") { }
810 virtual bool canBeRun() const;
814 struct ToggleFindMode
: public Action
816 ToggleFindMode() : Action(aToggleFindMode
, "toggle_find_mode") { }
822 struct ToggleReplayGainMode
: public Action
824 ToggleReplayGainMode() : Action(aToggleReplayGainMode
, "toggle_replay_gain_mode") { }
827 virtual bool canBeRun() const;
831 struct ToggleSpaceMode
: public Action
833 ToggleSpaceMode() : Action(aToggleSpaceMode
, "toggle_space_mode") { }
839 struct ToggleAddMode
: public Action
841 ToggleAddMode() : Action(aToggleAddMode
, "toggle_add_mode") { }
847 struct ToggleMouse
: public Action
849 ToggleMouse() : Action(aToggleMouse
, "toggle_mouse") { }
855 struct ToggleBitrateVisibility
: public Action
857 ToggleBitrateVisibility() : Action(aToggleBitrateVisibility
, "toggle_bitrate_visibility") { }
863 struct AddRandomItems
: public Action
865 AddRandomItems() : Action(aAddRandomItems
, "add_random_items") { }
871 struct ToggleBrowserSortMode
: public Action
873 ToggleBrowserSortMode() : Action(aToggleBrowserSortMode
, "toggle_browser_sort_mode") { }
876 virtual bool canBeRun() const;
880 struct ToggleLibraryTagType
: public Action
882 ToggleLibraryTagType() : Action(aToggleLibraryTagType
, "toggle_library_tag_type") { }
885 virtual bool canBeRun() const;
889 struct RefetchLyrics
: public Action
891 RefetchLyrics() : Action(aRefetchLyrics
, "refetch_lyrics") { }
894 virtual bool canBeRun() const;
898 struct RefetchArtistInfo
: public Action
900 RefetchArtistInfo() : Action(aRefetchArtistInfo
, "refetch_artist_info") { }
903 virtual bool canBeRun() const;
907 struct SetSelectedItemsPriority
: public Action
909 SetSelectedItemsPriority()
910 : Action(aSetSelectedItemsPriority
, "set_selected_items_priority") { }
913 virtual bool canBeRun() const;
917 struct ShowSongInfo
: public Action
919 ShowSongInfo() : Action(aShowSongInfo
, "show_song_info") { }
925 struct ShowArtistInfo
: public Action
927 ShowArtistInfo() : Action(aShowArtistInfo
, "show_artist_info") { }
930 virtual bool canBeRun() const;
934 struct ShowLyrics
: public Action
936 ShowLyrics() : Action(aShowLyrics
, "show_lyrics") { }
942 struct Quit
: public Action
944 Quit() : Action(aQuit
, "quit") { }
950 struct NextScreen
: public Action
952 NextScreen() : Action(aNextScreen
, "next_screen") { }
958 struct PreviousScreen
: public Action
960 PreviousScreen() : Action(aPreviousScreen
, "previous_screen") { }
966 struct ShowHelp
: public Action
968 ShowHelp() : Action(aShowHelp
, "show_help") { }
971 # ifdef HAVE_TAGLIB_H
972 virtual bool canBeRun() const;
973 # endif // HAVE_TAGLIB_H
977 struct ShowPlaylist
: public Action
979 ShowPlaylist() : Action(aShowPlaylist
, "show_playlist") { }
982 # ifdef HAVE_TAGLIB_H
983 virtual bool canBeRun() const;
984 # endif // HAVE_TAGLIB_H
988 struct ShowBrowser
: public Action
990 ShowBrowser() : Action(aShowBrowser
, "show_browser") { }
993 # ifdef HAVE_TAGLIB_H
994 virtual bool canBeRun() const;
995 # endif // HAVE_TAGLIB_H
999 struct ShowSearchEngine
: public Action
1001 ShowSearchEngine() : Action(aShowSearchEngine
, "show_search_engine") { }
1004 # ifdef HAVE_TAGLIB_H
1005 virtual bool canBeRun() const;
1006 # endif // HAVE_TAGLIB_H
1010 struct ShowMediaLibrary
: public Action
1012 ShowMediaLibrary() : Action(aShowMediaLibrary
, "show_media_library") { }
1015 # ifdef HAVE_TAGLIB_H
1016 virtual bool canBeRun() const;
1017 # endif // HAVE_TAGLIB_H
1021 struct ShowPlaylistEditor
: public Action
1023 ShowPlaylistEditor() : Action(aShowPlaylistEditor
, "show_playlist_editor") { }
1026 # ifdef HAVE_TAGLIB_H
1027 virtual bool canBeRun() const;
1028 # endif // HAVE_TAGLIB_H
1032 struct ShowTagEditor
: public Action
1034 ShowTagEditor() : Action(aShowTagEditor
, "show_tag_editor") { }
1037 virtual bool canBeRun() const;
1041 struct ShowOutputs
: public Action
1043 ShowOutputs() : Action(aShowOutputs
, "show_outputs") { }
1046 virtual bool canBeRun() const;
1050 struct ShowVisualizer
: public Action
1052 ShowVisualizer() : Action(aShowVisualizer
, "show_visualizer") { }
1055 virtual bool canBeRun() const;
1059 struct ShowClock
: public Action
1061 ShowClock() : Action(aShowClock
, "show_clock") { }
1064 virtual bool canBeRun() const;
1068 struct ShowServerInfo
: public Action
1070 ShowServerInfo() : Action(aShowServerInfo
, "show_server_info") { }
1073 # ifdef HAVE_TAGLIB_H
1074 virtual bool canBeRun() const;
1075 # endif // HAVE_TAGLIB_H
1079 #endif // _ACTIONS_H