ocarina: Add shortcuts for switching directly to a playlist
Since I don't have dynamic playlists re-implemented yet, I just swtch between the library, recent, and banned playlists. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
be67f81782
commit
5a9f4f4bca
|
@ -31,6 +31,7 @@ void init_window();
|
|||
/* playlist.cpp */
|
||||
bool playlist_entry_focused();
|
||||
void playlist_focus_entry();
|
||||
void playlist_switch_to(string &);
|
||||
void update_playlist(notify_t, libsaria::PlaylistNotification *);
|
||||
void init_playlist();
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ struct PlaylistWidgets {
|
|||
GtkEntry *entry;
|
||||
};
|
||||
|
||||
PlaylistWidgets library_widgets;
|
||||
PlaylistWidgets recent_widgets;
|
||||
PlaylistWidgets banned_widgets;
|
||||
static PlaylistWidgets library_widgets;
|
||||
static PlaylistWidgets recent_widgets;
|
||||
static PlaylistWidgets banned_widgets;
|
||||
static GtkWidget *focused_entry = NULL;
|
||||
|
||||
static string formatted(string str)
|
||||
|
@ -44,10 +44,15 @@ static struct PlaylistWidgets *find_widgets(libsaria::Playlist *plist)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct PlaylistWidgets *find_nth_widgets(unsigned int n)
|
||||
static unsigned int tabs_size()
|
||||
{
|
||||
GtkNotebook *tabs = GTK_NOTEBOOK(get_widget("PlaylistTabs"));
|
||||
unsigned int size = gtk_notebook_get_n_pages(tabs) - 3;
|
||||
return gtk_notebook_get_n_pages(tabs) - 3;
|
||||
}
|
||||
|
||||
static struct PlaylistWidgets *find_nth_widgets(unsigned int n)
|
||||
{
|
||||
unsigned int size = tabs_size();
|
||||
|
||||
/* Dynamic playlists */
|
||||
if (n < size)
|
||||
|
@ -80,6 +85,19 @@ static libsaria::Playlist *current_playlist()
|
|||
return current_widgets()->playlist;
|
||||
}
|
||||
|
||||
void playlist_switch_to(string &key)
|
||||
{
|
||||
GtkNotebook *tabs = GTK_NOTEBOOK(get_widget("PlaylistTabs"));
|
||||
unsigned int size = tabs_size();
|
||||
|
||||
if (key == "l")
|
||||
gtk_notebook_set_current_page(tabs, size);
|
||||
else if (key == "r")
|
||||
gtk_notebook_set_current_page(tabs, size + 1);
|
||||
else if (key == "b")
|
||||
gtk_notebook_set_current_page(tabs, size + 2);
|
||||
}
|
||||
|
||||
static gboolean is_visible(GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
|
||||
{
|
||||
libsaria::Track *track;
|
||||
|
|
|
@ -65,14 +65,9 @@ static gboolean key_pressed(GtkWidget *widget, GdkEvent *event, gpointer data)
|
|||
return FALSE;
|
||||
println("Window handling key press: " + key);
|
||||
|
||||
/*if (key == "l" || key == "L")
|
||||
ocarina::playlist::switch_to_library();
|
||||
else if (key == "r" || key == "R")
|
||||
ocarina::playlist::switch_to_recent();
|
||||
else if (key == "b" || key == "B")
|
||||
ocarina::playlist::switch_to_banned();*/
|
||||
//else if (key == "n")
|
||||
if (key == "n")
|
||||
if (key == "b" || key == "l" || key == "r")
|
||||
playlist_switch_to(key);
|
||||
else if (key == "n")
|
||||
libsaria::deck::next();
|
||||
else if (key == "N")
|
||||
libsaria::deck::prev();
|
||||
|
|
Loading…
Reference in New Issue