Discman
Loading...
Searching...
No Matches
application.h
Go to the documentation of this file.
1
6
7#ifndef DISCMAN_H
8#define DISCMAN_H
9
10#include <glibmm/main.h>
11#include <glibmm.h>
12#include <glibmm/dispatcher.h>
13#include <gtkmm/application.h>
14#include <gtkmm/builder.h>
15#include <gtkmm/window.h>
16#include <gtkmm/stack.h>
17#include <gtkmm/box.h>
18#include <glibmm/refptr.h>
19#include <glibmm/variant.h>
20#include <giomm/dbusproxy.h>
21
22#include <iostream>
23#include <mutex>
24#include <libgen.h>
25
26#include <discdb/discdb.h>
27
28#include "cd/cd_drive.h"
29#include "cd/cd_ripper.h"
37
40
41 public:
42
46 Application(int argc, char **argv);
47
50
52 void run();
53
54 private:
55 int _argc;
56 char** _argv;
57
58 Glib::RefPtr<Gtk::Builder> _builder;
59 Glib::RefPtr<Gtk::Application> _app;
60 Gtk::Window* _window;
63 DiscDB::Disc _disc;
65 unsigned int _track;
66 std::string _album_art_url;
67
68 Glib::RefPtr<Gio::DBus::Proxy> _systemd_proxy;
69
70 sigc::connection _timer_connection;
71
76 Gtk::Stack* _stack;
77 Gtk::Box* _player_box;
78 Gtk::Box* _bluetooth_box;
79 Gtk::Box* _album_art_box;
81
85 // Normally a component manages an entire screen.
93
94 Gtk::Button* _shutdown_button;
95
97 void on_activate();
98
101 void on_insert(DriveManager::Drive drive);
102
105 void on_eject(DriveManager::Drive drive);
106
108 void on_bluetooth_done();
109
113 void on_track_progress(unsigned int track, unsigned int progress);
114
116 void on_rip_done();
117
119 void on_album_art_done();
120
122 void on_album_art_art(const std::string url);
123
126 void on_track_selected(unsigned int track);
127
130 void on_button(const NowPlayingComponent::Button button);
131
136 void on_prev();
138 void on_stop();
139 void on_next();
141
149 void play(unsigned int track);
150
153 void play();
154
157 void pause();
158
161 void stop();
163
164 void on_album_art_button();
165 void on_bluetooth_button();
166 void on_shutdown_button();
167
168 bool on_timeout();
169
172 void eject(const DriveManager::Drive drive);
173
176 void rip(unsigned int track);
177
179 void query_discdb();
180
181};
182
183#endif // DISCMAN_H
Handles the interactions with the album art selection screen.
AudioOutput< int16_t > * _audio_output
The audio output.
Definition application.h:64
void on_album_art_button()
AlbumArtComponent done button handler.
void on_shutdown_button()
Shutdown button handler.
void on_prev()
Previous button handler.
void on_album_art_done()
Called when the AlbumArtComponent done button is clicked.
void on_bluetooth_button()
Bluetooth button handler.
Glib::RefPtr< Gio::DBus::Proxy > _systemd_proxy
The systemd D-Bus proxy, used for host shutdown.
Definition application.h:68
void stop()
Stop handler.
Gtk::Stack * _stack
Stack that switches between application screens.
Definition application.h:76
sigc::connection _timer_connection
A connection of a timer to the callback that periodically checks the current track state.
Definition application.h:70
void on_track_progress(unsigned int track, unsigned int progress)
Called when the CDRipper reports progress on a certain track.
void on_stop()
Stop button handler.
NowPlayingComponent * _now_playing_component
Handles the left-hand side of the main application screen showing album art and current track.
Definition application.h:89
void on_next()
Next button handler.
Gtk::Box * _player_box
Box holding the main application screen.
Definition application.h:77
void on_rip_done()
Called when the CDRipper reports it is done.
void eject(const DriveManager::Drive drive)
Instructs the DriveManager to eject a drive.
void on_button(const NowPlayingComponent::Button button)
Called when a playback control button (prev/next, play/pause, stop) is clicked.
void on_eject(DriveManager::Drive drive)
Called when a drive (disc or iPod/thumb drive) is removed.
DiscComponent * _disc_component
Handles the album labels, track listing and eject/rip buttons on the main application screen.
Definition application.h:88
void rip(unsigned int track)
Instructs the CDRipper to begin ripping one specific track.
void query_discdb()
Queries DiscDB for the full information of the disc inserted.
Gtk::Button * _shutdown_button
Shutdown button.
Definition application.h:94
Gtk::Window * _window
Reference to the application window.
Definition application.h:60
void run()
Runs Discman.
std::string _album_art_url
The URL of the currently displayed album art.
Definition application.h:66
bool on_timeout()
Called when the track monitoring timer reaches zero.
DriveManager _drive_manager
Drive manager.
Definition application.h:61
~Application()
Application destructor.
Application(int argc, char **argv)
Application constructor.
Definition application.cc:9
void on_playpause()
Play/pause button handler.
DiscDB::Disc _disc
The Disc returned by DiscDB for the inserted CD.
Definition application.h:63
void on_track_selected(unsigned int track)
Called when a track is selected in the DiscComponent.
BluetoothComponent * _bluetooth_component
Handles the Bluetooth device selection screen.
Definition application.h:90
void on_insert(DriveManager::Drive drive)
Called when a drive (disc or iPod/thumb drive) is inserted.
Gtk::Box * _bluetooth_box
Box holding the Bluetooth device selection screen.
Definition application.h:78
void on_activate()
Called when _app is activated.
unsigned int _track
The current 1-based track being played.
Definition application.h:65
Glib::RefPtr< Gtk::Application > _app
The underlying Gtk::Application.
Definition application.h:59
Glib::RefPtr< Gtk::Builder > _builder
The builder initialized with the Discman UI.
Definition application.h:58
void pause()
Pause handler.
char ** _argv
The application arguments.
Definition application.h:56
int _argc
The application argument count.
Definition application.h:55
void on_album_art_art(const std::string url)
Called when album art is selected in the AlbumArtComponent.
void play()
Play handler.
AlbumArtComponent * _album_art_component
Handles the album art selection screen.
Definition application.h:91
void on_bluetooth_connected()
Called when the user connects to a Bluetooth device.
Gtk::Box * _album_art_box
Box holding the album art selection screen.
Definition application.h:79
CDRipper * _ripper
CD ripper.
Definition application.h:62
void on_bluetooth_done()
Called when the BluetoothComponent done button is clicked.
Abstracts PortAudio using a given audio sample data type.
Handles the interactions with the Bluetooth device selection screen.
Rips CDs and individual tracks to M4A files.
Definition cd_ripper.h:41
Handles the interactions with the album labels, track listing and ipod/eject buttons.
Manages the state of the disc drive and any removable (iPod) drive.
Drive
The two drives supported.
Handles the interactions with the "now playing" side of the main screen.
Button
Playback control button identifiers.