ocarina: Properly respond to a right click
I had a test function, but it wasn't being called. I connected the widget to the activate signal and improved the function to list the rows that are currently selected.
This commit is contained in:
parent
74ab92ea6f
commit
9a9fc87f92
|
@ -13,10 +13,10 @@ class MenuItem
|
|||
{
|
||||
private:
|
||||
string text;
|
||||
void (*func)();
|
||||
void (*func)(GtkMenuItem *, gpointer);
|
||||
|
||||
public:
|
||||
MenuItem(string, void (*)());
|
||||
MenuItem(string, void (*)(GtkMenuItem *, gpointer));
|
||||
~MenuItem();
|
||||
|
||||
GtkWidget *get_widget();
|
||||
|
|
|
@ -15,9 +15,16 @@ static SongList library_list;
|
|||
static struct SongListFuncs library_funcs;
|
||||
static list <MenuItem> library_menu;
|
||||
|
||||
static void test()
|
||||
static void add_to_queue(GtkMenuItem *menu, gpointer data)
|
||||
{
|
||||
list<ino_t> selected;
|
||||
list<ino_t>::iterator it;
|
||||
library_list.list_selected_ids(selected);
|
||||
|
||||
println("Test function!");
|
||||
for (it = selected.begin(); it != selected.end(); it++) {
|
||||
println(*it);
|
||||
}
|
||||
}
|
||||
|
||||
namespace ocarina
|
||||
|
@ -36,7 +43,7 @@ namespace ocarina
|
|||
|
||||
void library::init()
|
||||
{
|
||||
library_menu.push_back(MenuItem("Test", test));
|
||||
library_menu.push_back(MenuItem("Add to Queue", add_to_queue));
|
||||
library_funcs.for_each = libsaria::library::for_each;
|
||||
library_funcs.size = libsaria::library::size;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#define BUTTON_RIGHT 3
|
||||
|
||||
MenuItem::MenuItem(string s, void (*f)())
|
||||
MenuItem::MenuItem(string s, void (*f)(GtkMenuItem *, gpointer))
|
||||
{
|
||||
text = s;
|
||||
func = f;
|
||||
|
@ -16,6 +16,7 @@ MenuItem::~MenuItem() {}
|
|||
GtkWidget *MenuItem::get_widget()
|
||||
{
|
||||
GtkWidget *widget = gtk_menu_item_new_with_label(text.c_str());
|
||||
GTK_CONNECT(widget, "activate", func, NULL);
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue