ocarina: Store PlaylistTabs in a variable
This way I don't need to keep calling get_widget() and then casting to a notebook. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
5bce295251
commit
b125fa2595
|
@ -10,6 +10,7 @@
|
|||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
static GtkNotebook *tabs;
|
||||
static PlaylistWidgets library_widgets;
|
||||
static PlaylistWidgets recent_widgets;
|
||||
static PlaylistWidgets banned_widgets;
|
||||
|
@ -54,7 +55,6 @@ static struct PlaylistWidgets *find_nth_widgets(unsigned int n)
|
|||
|
||||
static struct PlaylistWidgets *current_widgets()
|
||||
{
|
||||
GtkNotebook *tabs = GTK_NOTEBOOK(get_widget("PlaylistTabs"));
|
||||
return find_nth_widgets(gtk_notebook_get_current_page(tabs));
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,6 @@ libsaria::Playlist *current_playlist()
|
|||
|
||||
void playlist_switch_to(string &key)
|
||||
{
|
||||
GtkNotebook *tabs = GTK_NOTEBOOK(get_widget("PlaylistTabs"));
|
||||
unsigned int size = dynamic_widgets.size();
|
||||
|
||||
if (key == "l")
|
||||
|
@ -78,7 +77,6 @@ void playlist_switch_to(string &key)
|
|||
|
||||
void playlist_switch_to_n(unsigned int n)
|
||||
{
|
||||
GtkNotebook *tabs = GTK_NOTEBOOK(get_widget("PlaylistTabs"));
|
||||
unsigned int size = dynamic_widgets.size();
|
||||
if (size <= n)
|
||||
return;
|
||||
|
@ -127,14 +125,12 @@ static void init_tab_action()
|
|||
gtk_box_pack_start(GTK_BOX(box), open, false, false, 0);
|
||||
gtk_box_pack_start(GTK_BOX(box), get_widget("BanButton"), false, false, 0);
|
||||
gtk_widget_show_all(box);
|
||||
gtk_notebook_set_action_widget(GTK_NOTEBOOK(get_widget("PlaylistTabs")),
|
||||
box, GTK_PACK_END);
|
||||
gtk_notebook_set_action_widget(tabs, box, GTK_PACK_END);
|
||||
}
|
||||
|
||||
static void add_page(GtkWidget *page, GtkWidget *tab_label, int page_num)
|
||||
{
|
||||
gtk_notebook_insert_page(GTK_NOTEBOOK(get_widget("PlaylistTabs")),
|
||||
page, tab_label, page_num);
|
||||
gtk_notebook_insert_page(tabs, page, tab_label, page_num);
|
||||
}
|
||||
|
||||
static GtkWidget *make_tab_label(const string &name, struct PlaylistWidgets *widgets)
|
||||
|
@ -171,6 +167,7 @@ static void add_static_page(const string &name, struct PlaylistWidgets *widgets,
|
|||
|
||||
void init_tabs()
|
||||
{
|
||||
tabs = GTK_NOTEBOOK(get_widget("PlaylistTabs"));
|
||||
init_tab_action();
|
||||
|
||||
add_static_page("Library", &library_widgets, libsaria::library::get_playlist());
|
||||
|
@ -192,15 +189,14 @@ static void new_playlist(libsaria::Playlist *playlist)
|
|||
static void delete_playlist(libsaria::Playlist *playlist)
|
||||
{
|
||||
struct PlaylistWidgets *widgets = find_playlist_widgets(playlist);
|
||||
int page_num = gtk_notebook_page_num(GTK_NOTEBOOK(get_widget("PlaylistTabs")),
|
||||
GTK_WIDGET(widgets->page_box));
|
||||
int cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(get_widget("PlaylistTabs")));
|
||||
int page_num = gtk_notebook_page_num(tabs, GTK_WIDGET(widgets->page_box));
|
||||
int cur_page = gtk_notebook_get_current_page(tabs);
|
||||
|
||||
if (cur_page == page_num)
|
||||
gtk_notebook_set_current_page(GTK_NOTEBOOK(get_widget("PlaylistTabs")), cur_page + 1);
|
||||
gtk_notebook_set_current_page(tabs, cur_page + 1);
|
||||
|
||||
dynamic_widgets.remove(widgets);
|
||||
gtk_notebook_remove_page(GTK_NOTEBOOK(get_widget("PlaylistTabs")), page_num);
|
||||
gtk_notebook_remove_page(tabs, page_num);
|
||||
}
|
||||
|
||||
static void renumber_playlist(libsaria::Playlist *playlist)
|
||||
|
@ -209,8 +205,7 @@ static void renumber_playlist(libsaria::Playlist *playlist)
|
|||
struct PlaylistWidgets *widgets = find_playlist_widgets(playlist);
|
||||
s << "<span size='x-large'>" << playlist->get_number() << " </span>";
|
||||
gtk_label_set_markup(widgets->page_label, s.str().c_str());
|
||||
gtk_notebook_reorder_child(GTK_NOTEBOOK(get_widget("PlaylistTabs")),
|
||||
GTK_WIDGET(widgets->page_box),
|
||||
gtk_notebook_reorder_child(tabs, GTK_WIDGET(widgets->page_box),
|
||||
playlist->get_number());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue