ocarina: Initialize songlist with a list of menu items
These items will be used to create a right click menu.
This commit is contained in:
parent
dfa3d06142
commit
481c2b4832
|
@ -9,6 +9,17 @@
|
|||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
class MenuItem
|
||||
{
|
||||
private:
|
||||
string text;
|
||||
void (*func)();
|
||||
|
||||
public:
|
||||
MenuItem(string, void (*)());
|
||||
~MenuItem();
|
||||
};
|
||||
|
||||
/* Make this a class to inherit from? */
|
||||
struct SongListFuncs
|
||||
{
|
||||
|
@ -21,6 +32,7 @@ class SongList : public libsaria::SourceModel
|
|||
private:
|
||||
int ins_next;
|
||||
SongListFuncs *list_funcs;
|
||||
list <MenuItem> *menu_items;
|
||||
string name;
|
||||
|
||||
GtkWidget *window;
|
||||
|
@ -38,7 +50,7 @@ class SongList : public libsaria::SourceModel
|
|||
SongList();
|
||||
~SongList();
|
||||
|
||||
void init(string, SongListFuncs *);
|
||||
void init(string, SongListFuncs *, list<MenuItem> *);
|
||||
GtkWidget *get_window();
|
||||
GtkWidget *get_label();
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
using namespace std;
|
||||
|
||||
static SongList library_list;
|
||||
struct SongListFuncs library_funcs;
|
||||
static struct SongListFuncs library_funcs;
|
||||
static list <MenuItem> library_menu;
|
||||
|
||||
namespace ocarina
|
||||
{
|
||||
|
@ -28,7 +29,7 @@ namespace ocarina
|
|||
library_funcs.for_each = libsaria::library::for_each;
|
||||
library_funcs.size = libsaria::library::size;
|
||||
|
||||
library_list.init("Library", &library_funcs);
|
||||
library_list.init("Library", &library_funcs, &library_menu);
|
||||
add_page(library_list.get_label(), library_list.get_window(), true);
|
||||
ocarina::library::refresh();
|
||||
}
|
||||
|
|
|
@ -76,11 +76,12 @@ static void setup_columns(GtkCellRenderer *textcell, GtkWidget *treeview)
|
|||
* the gtk_init() function has been called. This allows the songlst
|
||||
* to be used as a static global variable in other files.
|
||||
*/
|
||||
void SongList::init(string text, SongListFuncs *funcs)
|
||||
void SongList::init(string text, SongListFuncs *funcs, list <MenuItem> *menu)
|
||||
{
|
||||
/* Initialize helper variables */
|
||||
list_funcs = funcs;
|
||||
name = text;
|
||||
menu_items = menu;
|
||||
|
||||
/* Set up the gtk widgets */
|
||||
label = setup_label(name);
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
|
||||
#include "songlist.h"
|
||||
#include <ocarina/songlist.h>
|
||||
#include <libsaria/print.h>
|
||||
#include "songlist.h"
|
||||
|
||||
#define BUTTON_RIGHT 3
|
||||
|
||||
MenuItem::MenuItem(string, void (*func)())
|
||||
{}
|
||||
|
||||
MenuItem::~MenuItem() {}
|
||||
|
||||
void songlist_button_click(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
if (event->button.button == BUTTON_RIGHT)
|
||||
|
|
Loading…
Reference in New Issue