2016-01-16 10:02:32 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#ifndef OCARINA_GUI_MODEL_H
|
|
|
|
#define OCARINA_GUI_MODEL_H
|
2016-08-20 21:01:19 -04:00
|
|
|
#include <core/playlist.h>
|
2016-08-26 09:25:17 -04:00
|
|
|
#include <gui/builder.h>
|
2016-01-16 10:02:32 -05:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2016-08-20 10:08:36 -04:00
|
|
|
#define GUI_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
|
2016-08-20 17:53:45 -04:00
|
|
|
gui_model_get_type(), GuiModel))
|
2016-08-20 10:08:36 -04:00
|
|
|
|
|
|
|
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,
|
2016-01-16 11:38:59 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-08-20 10:08:36 -04:00
|
|
|
struct gui_model {
|
|
|
|
GObject gm_parent; /* This MUST be the first member. */
|
|
|
|
gint gm_stamp; /* This is used to check iter validity. */
|
2016-01-16 10:02:32 -05:00
|
|
|
};
|
2016-08-20 10:08:36 -04:00
|
|
|
typedef struct gui_model GuiModel;
|
|
|
|
|
2016-01-16 10:02:32 -05:00
|
|
|
|
2016-08-20 10:08:36 -04:00
|
|
|
struct gui_model_class {
|
2016-01-16 10:02:32 -05:00
|
|
|
GObjectClass parent_class;
|
|
|
|
};
|
2016-08-20 10:08:36 -04:00
|
|
|
typedef struct gui_model_class GuiModelClass;
|
2016-01-16 10:02:32 -05:00
|
|
|
|
|
|
|
|
2016-08-20 10:08:36 -04:00
|
|
|
/* Called to initialize the GuiModel */
|
|
|
|
void gui_model_init(void);
|
2016-08-02 10:13:36 -04:00
|
|
|
|
2016-08-20 10:08:36 -04:00
|
|
|
/* Called to deinitialize the GuiModel */
|
|
|
|
void gui_model_deinit(void);
|
2016-08-02 10:13:36 -04:00
|
|
|
|
2016-08-20 10:08:36 -04:00
|
|
|
/* Called to get the GuiModel */
|
|
|
|
GuiModel *gui_model_get(void);
|
2016-01-16 10:02:32 -05:00
|
|
|
|
2016-08-20 10:08:36 -04:00
|
|
|
/* Called to find the GType of the GuiModel */
|
|
|
|
GType gui_model_get_type();
|
2016-01-16 10:02:32 -05:00
|
|
|
|
2016-01-18 08:31:48 -05:00
|
|
|
/* Called to add a row to the model */
|
2016-08-20 21:01:19 -04:00
|
|
|
void gui_model_add(struct playlist *, unsigned int);
|
2016-01-18 08:31:48 -05:00
|
|
|
|
|
|
|
/* Called to remove a row from the model */
|
2016-09-20 14:38:46 -04:00
|
|
|
void gui_model_remove(struct playlist *, struct track *);
|
2016-01-18 08:31:48 -05:00
|
|
|
|
|
|
|
/* Called to remove all rows from the model */
|
2016-08-20 21:01:19 -04:00
|
|
|
void gui_model_clear(struct playlist *, unsigned int);
|
2016-01-18 08:31:48 -05:00
|
|
|
|
2016-09-20 11:01:32 -04:00
|
|
|
/*
|
|
|
|
* Called to update a row in the model
|
|
|
|
* If track is NULL, then all rows will be updated
|
|
|
|
*/
|
|
|
|
void gui_model_update(struct playlist *, struct track *);
|
2016-09-17 10:33:09 -04:00
|
|
|
|
2016-08-01 16:45:46 -04:00
|
|
|
/* Called to change the queue represented by the model. */
|
2016-08-20 21:01:19 -04:00
|
|
|
void gui_model_set_playlist(struct playlist *);
|
2016-08-01 16:45:46 -04:00
|
|
|
|
2016-08-02 14:28:05 -04:00
|
|
|
/* Called to get the queue currently attached to the model. */
|
2016-08-20 21:01:19 -04:00
|
|
|
struct playlist *gui_model_get_playlist(void);
|
2016-08-02 14:28:05 -04:00
|
|
|
|
|
|
|
|
2016-01-18 10:14:29 -05:00
|
|
|
/* Called to convert a GtkTreeIter into a struct track */
|
2016-08-20 10:08:36 -04:00
|
|
|
static inline struct track *gui_model_iter_get_track(GtkTreeIter *iter)
|
2016-01-18 10:14:29 -05:00
|
|
|
{
|
|
|
|
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 */
|
2016-08-20 10:08:36 -04:00
|
|
|
struct track *gui_model_path_get_track(GtkTreePath *);
|
2016-01-18 10:14:29 -05:00
|
|
|
|
2016-08-21 10:03:50 -04:00
|
|
|
/* Called to get the runtime label. */
|
|
|
|
static inline GtkLabel *gui_model_runtime()
|
|
|
|
{
|
|
|
|
return GTK_LABEL(gui_builder_widget("runtime"));
|
|
|
|
}
|
|
|
|
|
2016-01-16 10:02:32 -05:00
|
|
|
#endif /* OCARINA_GUI_MODEL_H */
|