gui/audio: Handle favorite and hide buttons
This lets me remove gui/playlist_tab.cpp Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
f328b1686d
commit
a1c6502226
18
gui/audio.c
18
gui/audio.c
|
@ -2,6 +2,7 @@
|
||||||
* Copyright 2014 (c) Anna Schumaker.
|
* Copyright 2014 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
#include <core/audio.h>
|
#include <core/audio.h>
|
||||||
|
#include <core/collection.h>
|
||||||
#include <core/playlist.h>
|
#include <core/playlist.h>
|
||||||
#include <core/string.h>
|
#include <core/string.h>
|
||||||
#include <gui/audio.h>
|
#include <gui/audio.h>
|
||||||
|
@ -67,6 +68,23 @@ void __audio_seek(GtkRange *range, GtkScrollType type, double value, gpointer da
|
||||||
audio_seek(value * GST_SECOND);
|
audio_seek(value * GST_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __audio_favorite(GtkToggleButton *toggle, gpointer data)
|
||||||
|
{
|
||||||
|
if (gtk_toggle_button_get_active(toggle))
|
||||||
|
playlist_add(PL_FAVORITED, audio_cur_track());
|
||||||
|
else
|
||||||
|
playlist_remove(PL_FAVORITED, audio_cur_track());
|
||||||
|
}
|
||||||
|
|
||||||
|
void __audio_hide(GtkToggleButton *toggle, gpointer data)
|
||||||
|
{
|
||||||
|
if (gtk_toggle_button_get_active(toggle)) {
|
||||||
|
if (collection_ban(audio_cur_track()))
|
||||||
|
audio_next();
|
||||||
|
} else
|
||||||
|
collection_unban(audio_cur_track());
|
||||||
|
}
|
||||||
|
|
||||||
static int __audio_timeout(gpointer data)
|
static int __audio_timeout(gpointer data)
|
||||||
{
|
{
|
||||||
GtkAdjustment *progress = data;
|
GtkAdjustment *progress = data;
|
||||||
|
|
|
@ -13,11 +13,6 @@ extern "C" {
|
||||||
#include <gui/queue/label.h>
|
#include <gui/queue/label.h>
|
||||||
|
|
||||||
|
|
||||||
static Gtk::ToggleButton *o_ban;
|
|
||||||
static Gtk::ToggleButton *o_fav;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static class PlaylistTab : public Tab {
|
static class PlaylistTab : public Tab {
|
||||||
private:
|
private:
|
||||||
PlaylistLabel *playlist_label;
|
PlaylistLabel *playlist_label;
|
||||||
|
@ -45,25 +40,6 @@ public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void on_ban()
|
|
||||||
{
|
|
||||||
struct track *track = audio_cur_track();
|
|
||||||
if (o_ban->get_active()) {
|
|
||||||
if (collection_ban(track))
|
|
||||||
audio_next();
|
|
||||||
} else
|
|
||||||
collection_unban(track);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void on_favorite()
|
|
||||||
{
|
|
||||||
struct track *track = audio_cur_track();
|
|
||||||
if (o_fav->get_active())
|
|
||||||
playlist_add(PL_FAVORITED, track);
|
|
||||||
else
|
|
||||||
playlist_remove(PL_FAVORITED, track);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *playlist_init(struct queue *queue)
|
static void *playlist_init(struct queue *queue)
|
||||||
{
|
{
|
||||||
return gui_queue_alloc(queue, "Playlist", 0);
|
return gui_queue_alloc(queue, "Playlist", 0);
|
||||||
|
@ -106,10 +82,4 @@ struct queue_ops playlist_ops = {
|
||||||
void plist :: init()
|
void plist :: init()
|
||||||
{
|
{
|
||||||
p_tab = new PlaylistTab;
|
p_tab = new PlaylistTab;
|
||||||
|
|
||||||
o_ban = Glib :: wrap(GTK_TOGGLE_BUTTON(gui_builder_widget("o_hide")), false);
|
|
||||||
o_fav = Glib :: wrap(GTK_TOGGLE_BUTTON(gui_builder_widget("o_favorite")), false);
|
|
||||||
|
|
||||||
o_ban->signal_toggled().connect(sigc::ptr_fun(on_ban));
|
|
||||||
o_fav->signal_toggled().connect(sigc::ptr_fun(on_favorite));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#ifdef TEST_NEED_AUDIO
|
#ifdef TEST_NEED_AUDIO
|
||||||
void __audio_can_accel() {}
|
void __audio_can_accel() {}
|
||||||
|
void __audio_favorite() {}
|
||||||
|
void __audio_hide() {}
|
||||||
void __audio_pause_changed() {}
|
void __audio_pause_changed() {}
|
||||||
void __audio_seek() {}
|
void __audio_seek() {}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -838,6 +838,7 @@
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="tooltip_text" translatable="yes">Add this track to Favorites playlist</property>
|
<property name="tooltip_text" translatable="yes">Add this track to Favorites playlist</property>
|
||||||
<property name="inconsistent">True</property>
|
<property name="inconsistent">True</property>
|
||||||
|
<signal name="toggled" handler="__audio_favorite" swapped="no"/>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="image6">
|
<object class="GtkImage" id="image6">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -859,6 +860,7 @@
|
||||||
<property name="focus_on_click">False</property>
|
<property name="focus_on_click">False</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="tooltip_text" translatable="yes">Hide this track from the Collection</property>
|
<property name="tooltip_text" translatable="yes">Hide this track from the Collection</property>
|
||||||
|
<signal name="toggled" handler="__audio_hide" swapped="no"/>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="image7">
|
<object class="GtkImage" id="image7">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
Loading…
Reference in New Issue