Ocarina: Add a test menu item
The label for the menu reads "test", but it doesn't do anything yet.
This commit is contained in:
parent
481c2b4832
commit
6930c1ccf3
|
@ -18,6 +18,8 @@ class MenuItem
|
|||
public:
|
||||
MenuItem(string, void (*)());
|
||||
~MenuItem();
|
||||
|
||||
GtkWidget *get_widget();
|
||||
};
|
||||
|
||||
/* Make this a class to inherit from? */
|
||||
|
@ -57,6 +59,8 @@ class SongList : public libsaria::SourceModel
|
|||
void insert(Track &);
|
||||
void fill();
|
||||
void clear();
|
||||
|
||||
gint right_click(guint, guint64);
|
||||
};
|
||||
|
||||
#endif /* OCARINA_SONGLIST_H */
|
||||
|
|
|
@ -15,6 +15,11 @@ static SongList library_list;
|
|||
static struct SongListFuncs library_funcs;
|
||||
static list <MenuItem> library_menu;
|
||||
|
||||
static void test()
|
||||
{
|
||||
println("Test function!");
|
||||
}
|
||||
|
||||
namespace ocarina
|
||||
{
|
||||
|
||||
|
@ -26,6 +31,7 @@ namespace ocarina
|
|||
|
||||
void library::init()
|
||||
{
|
||||
library_menu.push_back(MenuItem("Test", test));
|
||||
library_funcs.for_each = libsaria::library::for_each;
|
||||
library_funcs.size = libsaria::library::size;
|
||||
|
||||
|
|
|
@ -5,13 +5,39 @@
|
|||
|
||||
#define BUTTON_RIGHT 3
|
||||
|
||||
MenuItem::MenuItem(string, void (*func)())
|
||||
{}
|
||||
MenuItem::MenuItem(string s, void (*f)())
|
||||
{
|
||||
text = s;
|
||||
func = f;
|
||||
}
|
||||
|
||||
MenuItem::~MenuItem() {}
|
||||
|
||||
GtkWidget *MenuItem::get_widget()
|
||||
{
|
||||
GtkWidget *widget = gtk_menu_item_new_with_label(text.c_str());
|
||||
return widget;
|
||||
}
|
||||
|
||||
gint SongList::right_click(guint button, guint64 time)
|
||||
{
|
||||
list<MenuItem>::iterator it;
|
||||
GtkWidget *menu = gtk_menu_new();
|
||||
|
||||
for (it = menu_items->begin(); it != menu_items->end(); it++)
|
||||
gtk_menu_append(GTK_MENU(menu), it->get_widget());
|
||||
|
||||
gtk_widget_show_all(menu);
|
||||
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, time);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void songlist_button_click(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
if (event->button.button == BUTTON_RIGHT)
|
||||
println("right click!");
|
||||
SongList *list = (SongList *)data;
|
||||
|
||||
if (event->button.button != BUTTON_RIGHT)
|
||||
return;
|
||||
println("right click!");
|
||||
list->right_click(event->button.button, event->button.time);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue