gui: Fix up how the gui pauses
I make it look more like o_play(). Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
1a6b6d9c54
commit
78624a6d98
|
@ -12,6 +12,20 @@ static inline bool audio_playing()
|
|||
}
|
||||
|
||||
|
||||
static void hide_show_buttons(const std::string &hide, const std::string &show)
|
||||
{
|
||||
lib :: get_widget<Gtk::Button>(hide)->hide();
|
||||
lib :: get_widget<Gtk::Button>(show)->show();
|
||||
}
|
||||
|
||||
void o_fix_buttons()
|
||||
{
|
||||
if (audio_playing())
|
||||
hide_show_buttons("o_play", "o_pause");
|
||||
else
|
||||
hide_show_buttons("o_pause", "o_play");
|
||||
}
|
||||
|
||||
/*
|
||||
* Timeout function is called every half-second.
|
||||
*/
|
||||
|
@ -24,6 +38,7 @@ static bool on_timeout()
|
|||
bar->set_upper(audio :: duration());
|
||||
bar->set_value(audio :: position());
|
||||
|
||||
o_fix_buttons();
|
||||
return audio_playing();
|
||||
}
|
||||
|
||||
|
@ -33,15 +48,23 @@ static void enable_timeout()
|
|||
}
|
||||
|
||||
|
||||
static void hide_show_buttons(const std::string &hide, const std::string &show)
|
||||
{
|
||||
lib :: get_widget<Gtk::Button>(hide)->hide();
|
||||
lib :: get_widget<Gtk::Button>(show)->show();
|
||||
}
|
||||
|
||||
void o_play()
|
||||
{
|
||||
audio :: play();
|
||||
hide_show_buttons("o_play", "o_pause");
|
||||
o_fix_buttons();
|
||||
enable_timeout();
|
||||
}
|
||||
|
||||
void o_pause()
|
||||
{
|
||||
audio :: pause();
|
||||
o_fix_buttons();
|
||||
}
|
||||
|
||||
void o_toggle()
|
||||
{
|
||||
if (audio_playing())
|
||||
o_pause();
|
||||
else
|
||||
o_play();
|
||||
}
|
||||
|
|
20
gui/gui.cpp
20
gui/gui.cpp
|
@ -15,7 +15,6 @@
|
|||
#include <gui/ocarina.h>
|
||||
#include <gui/tabs.h>
|
||||
|
||||
static bool audio_playing = false;
|
||||
static sigc::connection fav_connection;
|
||||
static sigc::connection ban_connection;
|
||||
|
||||
|
@ -32,13 +31,6 @@ static void on_config_pause()
|
|||
audio :: pause_after(enabled->get_active(), count->get_value());
|
||||
}
|
||||
|
||||
static void on_pause()
|
||||
{
|
||||
lib :: get_widget<Gtk::Button>("o_play")->show();
|
||||
lib :: get_widget<Gtk::Button>("o_pause")->hide();
|
||||
audio_playing = false;
|
||||
}
|
||||
|
||||
static void on_next()
|
||||
{
|
||||
audio :: next();
|
||||
|
@ -162,12 +154,9 @@ static bool on_window_key_released(GdkEventKey *event)
|
|||
{
|
||||
std::string key = gdk_keyval_name(event->keyval);
|
||||
|
||||
if (key == "space") {
|
||||
if (driver :: get_driver()->is_playing())
|
||||
audio :: pause();
|
||||
else
|
||||
o_play();
|
||||
} else
|
||||
if (key == "space")
|
||||
o_toggle();
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -217,12 +206,11 @@ Gtk::Window *setup_gui()
|
|||
Gtk::CheckButton *enabled = lib :: get_widget<Gtk::CheckButton>("o_pause_enabled");
|
||||
Gtk::Scale *position = lib :: get_widget<Gtk::Scale>("o_position_scale");
|
||||
|
||||
cb->on_pause = on_pause;
|
||||
cb->on_track_loaded = on_track_loaded;
|
||||
cb->on_pause_count_changed = on_pause_count_changed;
|
||||
|
||||
connect_button("o_play", o_play);
|
||||
connect_button("o_pause", audio::pause);
|
||||
connect_button("o_pause", o_pause);
|
||||
connect_button("o_stop", audio::stop);
|
||||
connect_button("o_prev", audio::prev);
|
||||
connect_button("o_next", on_next);
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
#ifndef OCARINA_GUI_CONTROLS_H
|
||||
#define OCARINA_GUI_CONTROLS_H
|
||||
|
||||
void o_fix_buttons();
|
||||
|
||||
void o_play();
|
||||
void o_pause();
|
||||
void o_toggle();
|
||||
|
||||
#endif /* OCARINA_GUI_CONTROLS_H */
|
||||
|
|
Loading…
Reference in New Issue