diff --git a/include/ocarina/button.h b/include/ocarina/button.h index fb1155f9..74f79888 100644 --- a/include/ocarina/button.h +++ b/include/ocarina/button.h @@ -10,6 +10,12 @@ GtkWidget *make_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), + bool show); + + GtkWidget *make_play_button(); GtkWidget *make_pause_button(); GtkWidget *make_stop_button(); diff --git a/include/ocarina/gtk.h b/include/ocarina/gtk.h index 97de2f64..e17058f2 100644 --- a/include/ocarina/gtk.h +++ b/include/ocarina/gtk.h @@ -9,6 +9,7 @@ extern "C" { g_signal_connect(widget, event, G_CALLBACK(func), arg) void box_pack_start(GtkWidget *, GtkWidget *, gboolean, gboolean, guint); +void box_pack_end(GtkWidget *, GtkWidget *, gboolean, gboolean, guint); void container_add(GtkWidget *, GtkWidget *); #endif diff --git a/ocarina/buttons/button.cpp b/ocarina/buttons/button.cpp index 15c755d4..a1a5cd98 100644 --- a/ocarina/buttons/button.cpp +++ b/ocarina/buttons/button.cpp @@ -15,24 +15,48 @@ static GtkWidget *get_button(void (* func)(GtkWidget *, GdkEvent *, gpointer), return button; } -static GtkWidget *get_image(const gchar *stockid) +static GtkWidget *get_image(const gchar *stockid, GtkIconSize size) { - GtkWidget *img = gtk_image_new_from_stock(stockid, GTK_ICON_SIZE_MENU); + GtkWidget *img = gtk_image_new_from_stock(stockid, size); gtk_widget_show(img); return img; } +static GtkWidget *get_label(string text) +{ + GtkWidget *label = gtk_label_new(text.c_str()); + gtk_widget_show(label); + return label; +} + GtkWidget *make_button(const gchar *stockid, void (* func)(GtkWidget *, GdkEvent *, gpointer), bool show) { GtkWidget *button = get_button(func, show); - GtkWidget *image = get_image(stockid); + GtkWidget *image = get_image(stockid, GTK_ICON_SIZE_MENU); container_add(button, image); return button; } +GtkWidget *make_text_button(const gchar *stockid, + string text, + void (* func)(GtkWidget *, GdkEvent *, gpointer), + bool show) +{ + GtkWidget *button = get_button(func, show); + GtkWidget *image = get_image(stockid, GTK_ICON_SIZE_BUTTON); + GtkWidget *label = get_label(text); + GtkWidget *box = gtk_hbox_new(FALSE, 0); + + box_pack_start(box, image, FALSE, FALSE, 0); + box_pack_start(box, label, FALSE, FALSE, 0); + container_add(button, box); + gtk_widget_show(box); + return button; +} + static void on_click_open_file(GtkWidget *b, GdkEvent *e, gpointer d) { string file = ocarina_choose_file(); diff --git a/ocarina/gtk.cpp b/ocarina/gtk.cpp index 4de673ff..c4b5c710 100644 --- a/ocarina/gtk.cpp +++ b/ocarina/gtk.cpp @@ -7,6 +7,12 @@ void box_pack_start(GtkWidget *box, GtkWidget *child, gboolean expand, gtk_box_pack_start(GTK_BOX(box), child, expand, fill, padding); } +void box_pack_end(GtkWidget *box, GtkWidget *child, gboolean expand, + gboolean fill, guint padding) +{ + gtk_box_pack_end(GTK_BOX(box), child, expand, fill, padding); +} + void container_add(GtkWidget *container, GtkWidget *widget) { gtk_container_add(GTK_CONTAINER(container), widget); diff --git a/ocarina/settings/library.cpp b/ocarina/settings/library.cpp index 144e4557..b75d54ef 100644 --- a/ocarina/settings/library.cpp +++ b/ocarina/settings/library.cpp @@ -1,14 +1,33 @@ #include +#include #include /* This is a gtk vbox */ static GtkWidget *library_settings = NULL; +static void on_click_add(GtkWidget *b, GdkEvent *e, gpointer d) +{ + +} + +static GtkWidget *make_add_button() +{ + return make_text_button(GTK_STOCK_ADD, + "Add to Library", + on_click_add, + true); +} + void library_settings_init() { - library_settings = gtk_vbox_new(FALSE, 0); + GtkWidget *add_button = gtk_hbox_new(FALSE, 0); + library_settings = gtk_vbox_new(FALSE, 0); + + box_pack_start(library_settings, add_button, FALSE, FALSE, 0); + box_pack_end(add_button, make_add_button(), FALSE, FALSE, 0); gtk_widget_show(library_settings); + gtk_widget_show(add_button); add_settings_page("Library", library_settings); }