ocarina: Provide an open file button
To play random songs from the filesystem. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
cb663075bd
commit
297f81213d
|
@ -10,6 +10,10 @@ GtkWidget *make_button(const gchar *stockid,
|
|||
void (* func)(GtkWidget *, GdkEvent *, gpointer),
|
||||
bool show);
|
||||
|
||||
GtkWidget *make_larger_button(const gchar *stockid,
|
||||
void (* func)(GtkWidget *, GdkEvent *, gpointer),
|
||||
bool show);
|
||||
|
||||
GtkWidget *make_text_button(const gchar *stockid,
|
||||
string text,
|
||||
void (* func)(GtkWidget *, GdkEvent *, gpointer),
|
||||
|
@ -17,8 +21,6 @@ GtkWidget *make_text_button(const gchar *stockid,
|
|||
|
||||
|
||||
GtkWidget *make_random_button();
|
||||
|
||||
GtkWidget *make_open_button();
|
||||
GtkWidget *make_volume_button();
|
||||
|
||||
#endif /* OCARINA_BUTTON_H */
|
||||
|
|
|
@ -1,8 +1,20 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <ocarina/chooser.h>
|
||||
#include <ocarina/button.h>
|
||||
#include <ocarina/body.h>
|
||||
|
||||
static GtkWidget *tabs;
|
||||
static GtkWidget *action_box;
|
||||
static GtkWidget *open_button;
|
||||
|
||||
static void on_click_open_file(GtkWidget *b, GdkEvent *e, gpointer d)
|
||||
{
|
||||
string file = ocarina::choose_file();
|
||||
if (file != "") {
|
||||
println("Playing file: " + file);
|
||||
}
|
||||
}
|
||||
|
||||
namespace ocarina
|
||||
{
|
||||
|
@ -10,9 +22,19 @@ namespace ocarina
|
|||
GtkWidget *body::playlist_init()
|
||||
{
|
||||
tabs = gtk_notebook_new();
|
||||
action_box = gtk_vbox_new(FALSE, 0);
|
||||
open_button = make_larger_button(GTK_STOCK_OPEN, on_click_open_file, true);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(action_box), open_button, FALSE, FALSE, 0);
|
||||
|
||||
gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tabs), GTK_POS_LEFT);
|
||||
gtk_notebook_set_action_widget(GTK_NOTEBOOK(tabs), action_box, GTK_PACK_END);
|
||||
g_object_set(tabs, "tab-border", 0, NULL);
|
||||
|
||||
gtk_widget_show(tabs);
|
||||
gtk_widget_show(action_box);
|
||||
|
||||
|
||||
return tabs;
|
||||
};
|
||||
|
||||
|
|
|
@ -40,6 +40,16 @@ GtkWidget *make_button(const gchar *stockid,
|
|||
return button;
|
||||
}
|
||||
|
||||
GtkWidget *make_larger_button(const gchar *stockid,
|
||||
void (* func)(GtkWidget *, GdkEvent *, gpointer),
|
||||
bool show)
|
||||
{
|
||||
GtkWidget *button = get_button(func, show);
|
||||
GtkWidget *image = get_image(stockid, GTK_ICON_SIZE_BUTTON);
|
||||
gtk_container_add(GTK_CONTAINER(button), image);
|
||||
return button;
|
||||
}
|
||||
|
||||
GtkWidget *make_text_button(const gchar *stockid,
|
||||
string text,
|
||||
void (* func)(GtkWidget *, GdkEvent *, gpointer),
|
||||
|
@ -56,18 +66,3 @@ GtkWidget *make_text_button(const gchar *stockid,
|
|||
gtk_widget_show(box);
|
||||
return button;
|
||||
}
|
||||
|
||||
static void on_click_open_file(GtkWidget *b, GdkEvent *e, gpointer d)
|
||||
{
|
||||
string file = ocarina::choose_file();
|
||||
if (file != "") {
|
||||
println("Playing file: " + file);
|
||||
//libsaria::audio::load(file);
|
||||
//libsaria::audio::play();
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *make_open_button()
|
||||
{
|
||||
return make_button(GTK_STOCK_OPEN, on_click_open_file, true);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ GtkWidget *get_header()
|
|||
GtkWidget *content = gtk_hbox_new(FALSE, 0);
|
||||
|
||||
box_pack_start(content, get_entry(), TRUE, TRUE, 0);
|
||||
box_pack_start(content, make_open_button(), FALSE, FALSE, 0);
|
||||
//box_pack_start(content, make_open_button(), FALSE, FALSE, 0);
|
||||
box_pack_start(content, make_random_button(), FALSE, FALSE, 0);
|
||||
box_pack_start(content, make_volume_button(), FALSE, FALSE, 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue