ocarina: Show and hide the recent and banned lists

Users may not always want to see them, and now I don't have an empty
"settings" tab.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-09-09 13:44:01 -04:00
parent a9d875e05e
commit 97fbd569e9
2 changed files with 63 additions and 2 deletions

View File

@ -2,8 +2,10 @@
#include <libsaria/format.h>
#include <libsaria/audio.h>
#include <libsaria/track.h>
#include <libsaria/prefs.h>
#include <libsaria/deck.h>
#include <libsaria/idle.h>
#include <libsaria/ban.h>
#include "ocarina.h"
#include <sstream>
@ -128,6 +130,23 @@ static void toggle_ban(GtkWidget *b, gpointer d)
libsaria::deck::next();
}
static void toggle_playlist(GtkToggleButton *button, gpointer data)
{
libsaria::Playlist *plist = (libsaria::Playlist *)data;
struct PlaylistWidgets *widgets = find_playlist_widgets(plist);
bool show = gtk_toggle_button_get_active(button);
if (show)
gtk_widget_show(GTK_WIDGET(widgets->page_box));
else
gtk_widget_hide(GTK_WIDGET(widgets->page_box));
if (GTK_WIDGET(button) == get_widget("ShowRecent"))
libsaria::prefs::set("ocarina.showrecent", show);
else if (GTK_WIDGET(button) == get_widget("ShowBanned"))
libsaria::prefs::set("ocarina.showbanned", show);
}
bool update_idle_bar(int size)
{
GtkWidget *idle = get_widget("IdleProgress");
@ -159,6 +178,17 @@ void update_length_label(libsaria::Playlist *playlist)
gtk_label_set_text(GTK_LABEL(label), stream.str().c_str());
}
void init_plist_visible_button(const string &button_name, const string &pref,
libsaria::Playlist *plist)
{
bool show = libsaria::prefs::init(pref, true);
GtkToggleButton *button = GTK_TOGGLE_BUTTON(get_widget(button_name));
gtk_toggle_button_set_active(button, show);
connect_signal(button_name, "toggled", G_CALLBACK(toggle_playlist), plist);
toggle_playlist(button, (void *)plist);
}
void init_status()
{
connect_signal("TrackProgress", "change-value", G_CALLBACK(slider_changed), NULL);
@ -166,4 +196,8 @@ void init_status()
connect_signal("PauseAfterN", "toggled", G_CALLBACK(toggle_pause), NULL);
connect_signal("PauseCounter", "value-changed", G_CALLBACK(counter_changed), NULL);
connect_signal("BanButton", "toggled", G_CALLBACK(toggle_ban), NULL);
connect_signal("ShowBanned", "toggled", G_CALLBACK(toggle_playlist), libsaria::ban::get_banned_plist());
init_plist_visible_button("ShowRecent", "ocarina.showrecent", libsaria::deck::get_recent_plist());
init_plist_visible_button("ShowBanned", "ocarina.showbanned", libsaria::ban::get_banned_plist());
}

View File

@ -643,10 +643,37 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
<object class="GtkCheckButton" id="ShowRecent">
<property name="label" translatable="yes">Show list recently played songs</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
<object class="GtkCheckButton" id="ShowBanned">
<property name="label" translatable="yes">Show list of banned songs</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0.54000002145767212</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>