ocarina: Add a text button for library scanning
A text button will use a slightly larger image to make it easier to see. This also gives me an opportunity to add some help text to describe what the button does.
This commit is contained in:
parent
95ebff8b6e
commit
9df15e944c
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,14 +1,33 @@
|
|||
|
||||
#include <ocarina/settings.h>
|
||||
#include <ocarina/button.h>
|
||||
#include <ocarina/gtk.h>
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue