Add a PLAYLIST_DISABLE notification
Disabled playlists are ignored when picking the next song. I grey-out the widgets on the UI when this notification is received. I keep filtering enabled this time (the entry was disabled too in Ocarina 5.9) Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
3bb8053ea2
commit
50b4198001
|
@ -15,6 +15,7 @@ enum notify_t {
|
|||
PLAYLIST_NEW, // libsaria::Playlist *
|
||||
PLAYLIST_DELETE, // libsaria::Playlist *
|
||||
PLAYLIST_RENUMBER, // libsaria::Playlist *
|
||||
PLAYLIST_DISABLE, // libsaria::Playlist *
|
||||
PLAYLIST_ADD, // libsaria::PlaylistNotification *
|
||||
PLAYLIST_RM, // libsaria::PlaylistNotification *
|
||||
PLAYLIST_UPDATE, // libsaria::PlaylistNotification *
|
||||
|
|
|
@ -19,8 +19,6 @@ namespace libsaria
|
|||
Playlist *get_playlist();
|
||||
|
||||
bool is_static();
|
||||
|
||||
virtual void on_disable(bool);
|
||||
};
|
||||
|
||||
}; /* Namespace: libsaria */
|
||||
|
|
|
@ -13,17 +13,20 @@ using namespace std;
|
|||
enum ExtraWidgets {
|
||||
NO_EXTRA_WIDGETS = 0,
|
||||
CLOSE_BUTTON = (1 << 0),
|
||||
DISABLE_BUTTON = (1 << 1),
|
||||
};
|
||||
|
||||
struct PlaylistWidgets {
|
||||
libsaria::Playlist *playlist;
|
||||
GtkListStore *liststore;
|
||||
GtkBox *page_box;
|
||||
GtkBox *tab_box;
|
||||
GtkTreeView *treeview;
|
||||
GtkTreeModel *filter;
|
||||
GtkLabel *size_label;
|
||||
GtkLabel *page_label;
|
||||
GtkEntry *entry;
|
||||
GtkToggleButton *disable;
|
||||
};
|
||||
|
||||
/* library.cpp */
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace libsaria
|
|||
else
|
||||
flags &= ~PL_DISABLED;
|
||||
schedule_save();
|
||||
RENDER( on_disable(is_disabled()) );
|
||||
notify(PLAYLIST_DISABLE, this);
|
||||
}
|
||||
|
||||
void Playlist::track_updated(Track *track)
|
||||
|
|
|
@ -30,8 +30,4 @@ namespace libsaria
|
|||
return (flags & PL_STATIC) == PL_STATIC;
|
||||
}
|
||||
|
||||
void PlaylistRenderer::on_disable(bool disabled)
|
||||
{
|
||||
}
|
||||
|
||||
}; /* Namespace: libsaria */
|
||||
|
|
|
@ -38,6 +38,7 @@ void on_notify(notify_t event, void *data)
|
|||
case PLAYLIST_NEW:
|
||||
case PLAYLIST_DELETE:
|
||||
case PLAYLIST_RENUMBER:
|
||||
case PLAYLIST_DISABLE:
|
||||
update_tabs(event, (libsaria::Playlist *)data);
|
||||
break;
|
||||
case PLAYLIST_ADD:
|
||||
|
|
|
@ -127,6 +127,14 @@ static void init(int argc, char **argv)
|
|||
builder = gtk_builder_new();
|
||||
gtk_builder_add_from_file(builder, lib_file("ocarina.xml").c_str(), NULL);
|
||||
|
||||
/* Set up small button style */
|
||||
gtk_rc_parse_string(
|
||||
"style \"small-button-style\"\n"
|
||||
"{\n"
|
||||
" GtkButton::inner-border = {0,0,0,0}\n"
|
||||
"}\n"
|
||||
"widget \"*.ocarina-small-button\" style \"small-button-style\"");
|
||||
|
||||
/* Initialize widgets static to this file */
|
||||
init_widgets();
|
||||
|
||||
|
|
|
@ -249,6 +249,12 @@ static void playlist_close(GtkWidget *button, gpointer data)
|
|||
libsaria::deck::delete_playlist(playlist);
|
||||
}
|
||||
|
||||
static void playlist_disable(GtkToggleButton *button, gpointer data)
|
||||
{
|
||||
struct libsaria::Playlist *playlist = (libsaria::Playlist *)data;
|
||||
playlist->set_disabled(gtk_toggle_button_get_active(button));
|
||||
}
|
||||
|
||||
void setup_widgets(struct PlaylistWidgets *widgets, libsaria::Playlist *playlist)
|
||||
{
|
||||
unsigned int num_columns = sizeof(types) / sizeof(GType);
|
||||
|
@ -288,20 +294,24 @@ static GtkWidget *setup_close_button(struct PlaylistWidgets *widgets)
|
|||
|
||||
gtk_button_set_image(GTK_BUTTON(close), image);
|
||||
gtk_button_set_relief(GTK_BUTTON(close), GTK_RELIEF_NONE);
|
||||
|
||||
gtk_rc_parse_string(
|
||||
"style \"close-button-style\"\n"
|
||||
"{\n"
|
||||
" GtkButton::inner-border = {0,0,0,0}\n"
|
||||
"}\n"
|
||||
"widget \"*.ocarina-close-button\" style \"close-button-style\"");
|
||||
gtk_widget_set_name(close, "ocarina-close-button");
|
||||
|
||||
gtk_widget_set_name(close, "ocarina-small-button");
|
||||
g_signal_connect(close, "clicked", G_CALLBACK(playlist_close), widgets->playlist);
|
||||
|
||||
return close;
|
||||
}
|
||||
|
||||
static GtkWidget *setup_disable_button(struct PlaylistWidgets *widgets)
|
||||
{
|
||||
GtkWidget *image = gtk_image_new_from_stock(GTK_STOCK_YES, GTK_ICON_SIZE_MENU);
|
||||
widgets->disable = GTK_TOGGLE_BUTTON(gtk_toggle_button_new());
|
||||
|
||||
gtk_button_set_image(GTK_BUTTON(widgets->disable), image);
|
||||
gtk_widget_set_name(GTK_WIDGET(widgets->disable), "ocarina-small-button");
|
||||
g_signal_connect(GTK_WIDGET(widgets->disable), "toggled", G_CALLBACK(playlist_disable), widgets->playlist);
|
||||
|
||||
return GTK_WIDGET(widgets->disable);
|
||||
}
|
||||
|
||||
static void add_column(GtkTreeView *treeview, const string &title, int index,
|
||||
GtkTreeViewColumnSizing sizing, unsigned int fixed_width)
|
||||
{
|
||||
|
@ -328,6 +338,8 @@ void setup_playlist_page(struct PlaylistWidgets *widgets, int flags)
|
|||
if (flags & CLOSE_BUTTON)
|
||||
gtk_box_pack_start(GTK_BOX(top_box), setup_close_button(widgets), FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(top_box), GTK_WIDGET(widgets->entry), TRUE, TRUE, 0);
|
||||
if (flags & DISABLE_BUTTON)
|
||||
gtk_box_pack_start(GTK_BOX(top_box), setup_disable_button(widgets), FALSE, FALSE, 0);
|
||||
|
||||
gtk_box_pack_start(widgets->page_box, top_box, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(widgets->page_box, window, TRUE, TRUE, 0);
|
||||
|
|
|
@ -168,23 +168,22 @@ static void add_page(GtkWidget *page, GtkWidget *tab_label, int page_num)
|
|||
gtk_notebook_insert_page(tabs, page, tab_label, page_num);
|
||||
}
|
||||
|
||||
static GtkWidget *make_tab_label(const string &name, struct PlaylistWidgets *widgets)
|
||||
static void make_tab_label(const string &name, struct PlaylistWidgets *widgets)
|
||||
{
|
||||
GtkWidget *tab = gtk_hbox_new(FALSE, 0);
|
||||
GtkWidget *box = gtk_vbox_new(FALSE, 0);
|
||||
GtkWidget *label = gtk_label_new(name.c_str());
|
||||
widgets->tab_box = GTK_BOX(gtk_hbox_new(FALSE, 0));
|
||||
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.0);
|
||||
gtk_misc_set_alignment(GTK_MISC(widgets->size_label), 1.0, 0.0);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(tab), GTK_WIDGET(widgets->page_label), FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(tab), box, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start(widgets->tab_box, GTK_WIDGET(widgets->page_label), FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(widgets->tab_box, box, TRUE, TRUE, 0);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(widgets->size_label), FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_show_all(tab);
|
||||
return tab;
|
||||
gtk_widget_show_all(GTK_WIDGET(widgets->tab_box));
|
||||
}
|
||||
|
||||
static void init_widgets(struct PlaylistWidgets *widgets, libsaria::Playlist *playlist,
|
||||
|
@ -198,7 +197,8 @@ static void add_static_page(const string &name, struct PlaylistWidgets *widgets,
|
|||
libsaria::Playlist *playlist)
|
||||
{
|
||||
init_widgets(widgets, playlist, NO_EXTRA_WIDGETS);
|
||||
add_page(GTK_WIDGET(widgets->page_box), make_tab_label(name, widgets), -1);
|
||||
make_tab_label(name, widgets);
|
||||
add_page(GTK_WIDGET(widgets->page_box), GTK_WIDGET(widgets->tab_box), -1);
|
||||
}
|
||||
|
||||
void init_tabs()
|
||||
|
@ -219,9 +219,9 @@ static void new_playlist(libsaria::Playlist *playlist)
|
|||
struct PlaylistWidgets *widgets = new struct PlaylistWidgets;
|
||||
dynamic_widgets.push_back(widgets);
|
||||
|
||||
init_widgets(widgets, playlist, CLOSE_BUTTON);
|
||||
add_page(GTK_WIDGET(widgets->page_box),
|
||||
make_tab_label(playlist->get_name(), widgets),
|
||||
init_widgets(widgets, playlist, CLOSE_BUTTON | DISABLE_BUTTON);
|
||||
make_tab_label(playlist->get_name(), widgets);
|
||||
add_page(GTK_WIDGET(widgets->page_box), GTK_WIDGET(widgets->tab_box),
|
||||
libsaria::deck::get_playlist_index(playlist));
|
||||
gtk_notebook_set_tab_reorderable(tabs, GTK_WIDGET(widgets->page_box), true);
|
||||
}
|
||||
|
@ -249,6 +249,16 @@ static void renumber_playlist(libsaria::Playlist *playlist)
|
|||
playlist->get_number());
|
||||
}
|
||||
|
||||
static void disable_playlist(libsaria::Playlist *playlist)
|
||||
{
|
||||
bool enabled = !playlist->is_disabled();
|
||||
struct PlaylistWidgets *widgets = find_playlist_widgets(playlist);
|
||||
|
||||
gtk_toggle_button_set_active(widgets->disable, !enabled);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(widgets->treeview), enabled);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(widgets->tab_box), enabled);
|
||||
}
|
||||
|
||||
void update_tabs(notify_t event, libsaria::Playlist *playlist)
|
||||
{
|
||||
if (event == PLAYLIST_NEW)
|
||||
|
@ -257,4 +267,6 @@ void update_tabs(notify_t event, libsaria::Playlist *playlist)
|
|||
delete_playlist(playlist);
|
||||
else if (event == PLAYLIST_RENUMBER)
|
||||
renumber_playlist(playlist);
|
||||
else if (event == PLAYLIST_DISABLE)
|
||||
disable_playlist(playlist);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue