gui: Move ban and favorite buttons into playlist code
These buttons directly change the playlists, so let's handle them there. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
b940fe710c
commit
d299bc464c
47
gui/gui.cpp
47
gui/gui.cpp
|
@ -11,8 +11,6 @@
|
|||
#include <gui/ocarina.h>
|
||||
#include <gui/tabs.h>
|
||||
|
||||
static sigc::connection fav_connection;
|
||||
static sigc::connection ban_connection;
|
||||
Gtk::SpinButton *count;
|
||||
Gtk::CheckButton *enabled;
|
||||
|
||||
|
@ -31,24 +29,6 @@ static void on_config_pause_count()
|
|||
enabled->set_active(true);
|
||||
}
|
||||
|
||||
void on_track_loaded(Track *track)
|
||||
{
|
||||
Gtk::ToggleButton *ban = lib :: get_widget<Gtk::ToggleButton>("o_ban");
|
||||
Gtk::ToggleButton *fav = lib :: get_widget<Gtk::ToggleButton>("o_favorite");
|
||||
|
||||
bool banned = playlist :: has(track, "Banned");
|
||||
bool favorite = playlist :: has(track, "Favorites");
|
||||
|
||||
ban_connection.block();
|
||||
fav_connection.block();
|
||||
if (ban->get_active() != banned)
|
||||
ban->set_active(banned);
|
||||
if (fav->get_active() != favorite)
|
||||
fav->set_active(favorite);
|
||||
ban_connection.unblock();
|
||||
fav_connection.unblock();
|
||||
}
|
||||
|
||||
void on_pause_count_changed(bool enabled, unsigned int count)
|
||||
{
|
||||
Gtk::CheckButton *p_enabled = lib :: get_widget<Gtk::CheckButton>("o_pause_enabled");
|
||||
|
@ -60,27 +40,6 @@ void on_pause_count_changed(bool enabled, unsigned int count)
|
|||
p_count->set_value(count);
|
||||
}
|
||||
|
||||
static void on_ban_toggled()
|
||||
{
|
||||
Gtk::ToggleButton *ban = lib :: get_widget<Gtk::ToggleButton>("o_ban");
|
||||
|
||||
if (ban->get_active() == true) {
|
||||
playlist :: add(audio :: current_track(), "Banned");
|
||||
on_next();
|
||||
} else
|
||||
playlist :: del(audio::current_track(), "Banned");
|
||||
}
|
||||
|
||||
static void on_fav_toggled()
|
||||
{
|
||||
Gtk::ToggleButton *fav = lib :: get_widget<Gtk::ToggleButton>("o_favorite");
|
||||
|
||||
if (fav->get_active() == true)
|
||||
playlist :: add(audio::current_track(), "Favorites");
|
||||
else
|
||||
playlist :: del(audio::current_track(), "Favorites");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
@ -102,12 +61,6 @@ Gtk::Window *setup_gui()
|
|||
|
||||
|
||||
/* Favorite and ban buttons */
|
||||
Gtk::ToggleButton *ban = lib :: get_widget<Gtk::ToggleButton>("o_ban");
|
||||
Gtk::ToggleButton *fav = lib :: get_widget<Gtk::ToggleButton>("o_favorite");
|
||||
|
||||
ban_connection = ban->signal_toggled().connect(sigc::ptr_fun(on_ban_toggled));
|
||||
fav_connection = fav->signal_toggled().connect(sigc::ptr_fun(on_fav_toggled));
|
||||
|
||||
if (audio :: current_track())
|
||||
on_track_loaded(audio :: current_track());
|
||||
|
||||
|
|
|
@ -10,7 +10,10 @@
|
|||
Gtk::Window *ocarina_init(int *argc, char ***argv)
|
||||
{
|
||||
lib :: init(argc, argv, "ocarina6.glade");
|
||||
|
||||
init_gst(argc, argv);
|
||||
init_playlist_tab();
|
||||
|
||||
core :: init();
|
||||
|
||||
Gtk::Window *window = setup_gui();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/audio.h>
|
||||
#include <core/playlist.h>
|
||||
#include <lib/plist.h>
|
||||
#include <gui/tabs.h>
|
||||
|
@ -39,6 +40,9 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
static Gtk::ToggleButton *o_ban;
|
||||
static Gtk::ToggleButton *o_fav;
|
||||
|
||||
static PlaylistTab *p_tab;
|
||||
static Gtk::TreeView *p_treeview;
|
||||
|
||||
|
@ -67,6 +71,35 @@ static bool on_playlist_clicked(GdkEventButton *button)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void on_ban()
|
||||
{
|
||||
Track *track = audio :: current_track();
|
||||
if (o_ban->get_active()) {
|
||||
if (!playlist :: has(track, "Banned")) {
|
||||
playlist :: add(track, "Banned");
|
||||
on_next();
|
||||
}
|
||||
} else
|
||||
playlist :: del(track, "Banned");
|
||||
}
|
||||
|
||||
static void on_favorite()
|
||||
{
|
||||
Track *track = audio :: current_track();
|
||||
if (o_fav->get_active())
|
||||
playlist :: add(track, "Favorites");
|
||||
else
|
||||
playlist :: del(track, "Favorites");
|
||||
}
|
||||
|
||||
void on_track_loaded(Track *track)
|
||||
{
|
||||
o_ban->set_active(playlist :: has(track, "Banned"));
|
||||
o_fav->set_active(playlist :: has(track, "Favorites"));
|
||||
}
|
||||
|
||||
|
||||
void init_playlist_tab()
|
||||
{
|
||||
plist :: init();
|
||||
|
@ -76,4 +109,10 @@ void init_playlist_tab()
|
|||
p_treeview->signal_cursor_changed().connect(sigc::ptr_fun(on_playlist_cursor_changed));
|
||||
p_treeview->signal_button_press_event().connect(sigc::ptr_fun(on_playlist_clicked));
|
||||
p_treeview->set_cursor(Gtk::TreePath("0"));
|
||||
|
||||
o_ban = lib :: get_widget<Gtk::ToggleButton>("o_ban");
|
||||
o_fav = lib :: get_widget<Gtk::ToggleButton>("o_favorite");
|
||||
|
||||
o_ban->signal_toggled().connect(sigc::ptr_fun(on_ban));
|
||||
o_fav->signal_toggled().connect(sigc::ptr_fun(on_favorite));
|
||||
}
|
||||
|
|
|
@ -514,7 +514,6 @@ void init_tabs()
|
|||
/* Initialize other tabs */
|
||||
init_collection_tab();
|
||||
init_history_tab();
|
||||
init_playlist_tab();
|
||||
init_queue_tabs();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue