ocarina/include/gui/model.h

86 lines
2.1 KiB
C

/*
* Copyright 2016 (c) Anna Schumaker.
*/
#ifndef OCARINA_GUI_MODEL_H
#define OCARINA_GUI_MODEL_H
#include <core/playlist.h>
#include <gtk/gtk.h>
#define GUI_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
gui_model_get_type(), GuiModel))
enum gui_model_columns {
GUI_MODEL_TRACK_NR,
GUI_MODEL_TITLE,
GUI_MODEL_LENGTH,
GUI_MODEL_ARTIST,
GUI_MODEL_ALBUM,
GUI_MODEL_YEAR,
GUI_MODEL_GENRE,
GUI_MODEL_COUNT,
GUI_MODEL_LAST_PLAY,
GUI_MODEL_FILE_PATH,
GUI_MODEL_FONT,
GUI_MODEL_N_COLUMNS,
};
struct gui_model {
GObject gm_parent; /* This MUST be the first member. */
gint gm_stamp; /* This is used to check iter validity. */
struct queue_iter gm_iter; /* The current _q_iter. */
};
typedef struct gui_model GuiModel;
struct gui_model_class {
GObjectClass parent_class;
};
typedef struct gui_model_class GuiModelClass;
/* Called to initialize the GuiModel */
void gui_model_init(void);
/* Called to deinitialize the GuiModel */
void gui_model_deinit(void);
/* Called to get the GuiModel */
GuiModel *gui_model_get(void);
/* Called to find the GType of the GuiModel */
GType gui_model_get_type();
/* Called to add a row to the model */
void gui_model_add(struct playlist *, unsigned int);
/* Called to remove a row from the model */
void gui_model_remove(struct playlist *, unsigned int);
/* Called to remove all rows from the model */
void gui_model_clear(struct playlist *, unsigned int);
/* Called to update a row in the model */
void gui_model_update(struct playlist *, unsigned int);
/* Called to change the queue represented by the model. */
void gui_model_set_playlist(struct playlist *);
/* Called to get the queue currently attached to the model. */
struct playlist *gui_model_get_playlist(void);
/* Called to convert a GtkTreeIter into a struct track */
static inline struct track *gui_model_iter_get_track(GtkTreeIter *iter)
{
g_return_val_if_fail(iter != NULL, NULL);
g_return_val_if_fail(iter->user_data2 != NULL, NULL);
return (struct track *)iter->user_data2;
}
/* Called to convert a GtkTreePath into a struct track */
struct track *gui_model_path_get_track(GtkTreePath *);
#endif /* OCARINA_GUI_MODEL_H */