| 1 | /* |
| 2 | * This file is part of DisOrder |
| 3 | * Copyright (C) 2006-2008 Richard Kettlewell |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 18 | * USA |
| 19 | */ |
| 20 | #ifndef QUEUE_GENERIC_H |
| 21 | #define QUEUE_GENERIC_H |
| 22 | |
| 23 | /** @brief Definition of a column */ |
| 24 | struct queue_column { |
| 25 | /** @brief Column name */ |
| 26 | const char *name; |
| 27 | |
| 28 | /** @brief Compute value for this column */ |
| 29 | const char *(*value)(const struct queue_entry *q, |
| 30 | const char *data); |
| 31 | |
| 32 | /** @brief Passed to value() */ |
| 33 | const char *data; |
| 34 | |
| 35 | /** @brief TODO */ |
| 36 | gfloat xalign; |
| 37 | }; |
| 38 | |
| 39 | /** @brief An item in the queue's popup menu */ |
| 40 | struct queue_menuitem { |
| 41 | /** @brief Menu item name */ |
| 42 | const char *name; |
| 43 | |
| 44 | /** @brief Called to activate the menu item */ |
| 45 | void (*activate)(GtkMenuItem *menuitem, |
| 46 | gpointer user_data); |
| 47 | |
| 48 | /** @brief Called to determine whether the menu item is usable. |
| 49 | * |
| 50 | * Returns @c TRUE if it should be sensitive and @c FALSE otherwise. |
| 51 | */ |
| 52 | int (*sensitive)(struct queuelike *ql); |
| 53 | |
| 54 | /** @brief Signal handler ID */ |
| 55 | gulong handlerid; |
| 56 | |
| 57 | /** @brief Widget for menu item */ |
| 58 | GtkWidget *w; |
| 59 | }; |
| 60 | |
| 61 | /** @brief Definition of a queue-like window */ |
| 62 | struct queuelike { |
| 63 | |
| 64 | /* Things filled in by the caller: */ |
| 65 | |
| 66 | /** @brief Initialization function */ |
| 67 | void (*init)(void); |
| 68 | |
| 69 | /** @brief Columns */ |
| 70 | const struct queue_column *columns; |
| 71 | |
| 72 | /** @brief Number of columns in this queuelike */ |
| 73 | int ncolumns; |
| 74 | |
| 75 | /** @brief Items for popup menu */ |
| 76 | struct queue_menuitem *menuitems; |
| 77 | |
| 78 | /** @brief Number of menu items */ |
| 79 | int nmenuitems; |
| 80 | |
| 81 | /* Dynamic state: */ |
| 82 | |
| 83 | /** @brief The head of the queue */ |
| 84 | struct queue_entry *q; |
| 85 | |
| 86 | /* Things created by the implementation: */ |
| 87 | |
| 88 | /** @brief The list store */ |
| 89 | GtkListStore *store; |
| 90 | |
| 91 | /** @brief The tree view */ |
| 92 | GtkWidget *view; |
| 93 | |
| 94 | /** @brief The selection */ |
| 95 | GtkTreeSelection *selection; |
| 96 | |
| 97 | /** @brief The popup menu */ |
| 98 | GtkWidget *menu; |
| 99 | }; |
| 100 | |
| 101 | extern struct queuelike ql_queue; |
| 102 | extern struct queuelike ql_recent; |
| 103 | extern struct queuelike ql_added; |
| 104 | |
| 105 | extern time_t last_playing; |
| 106 | |
| 107 | int ql_selectall_sensitive(struct queuelike *ql); |
| 108 | void ql_selectall_activate(GtkMenuItem *menuitem, |
| 109 | gpointer user_data); |
| 110 | int ql_selectnone_sensitive(struct queuelike *ql); |
| 111 | void ql_selectnone_activate(GtkMenuItem *menuitem, |
| 112 | gpointer user_data); |
| 113 | int ql_properties_sensitive(struct queuelike *ql); |
| 114 | void ql_properties_activate(GtkMenuItem *menuitem, |
| 115 | gpointer user_data); |
| 116 | int ql_scratch_sensitive(struct queuelike *ql); |
| 117 | void ql_scratch_activate(GtkMenuItem *menuitem, |
| 118 | gpointer user_data); |
| 119 | int ql_remove_sensitive(struct queuelike *ql); |
| 120 | void ql_remove_activate(GtkMenuItem *menuitem, |
| 121 | gpointer user_data); |
| 122 | int ql_play_sensitive(struct queuelike *ql); |
| 123 | void ql_play_activate(GtkMenuItem *menuitem, |
| 124 | gpointer user_data); |
| 125 | gboolean ql_button_release(GtkWidget *widget, |
| 126 | GdkEventButton *event, |
| 127 | gpointer user_data); |
| 128 | GtkWidget *init_queuelike(struct queuelike *ql); |
| 129 | void ql_update_list_store(struct queuelike *ql) ; |
| 130 | void ql_update_row(struct queue_entry *q, |
| 131 | GtkTreeIter *iter); |
| 132 | void ql_new_queue(struct queuelike *ql, |
| 133 | struct queue_entry *newq); |
| 134 | const char *column_when(const struct queue_entry *q, |
| 135 | const char *data); |
| 136 | const char *column_who(const struct queue_entry *q, |
| 137 | const char *data); |
| 138 | const char *column_namepart(const struct queue_entry *q, |
| 139 | const char *data); |
| 140 | const char *column_length(const struct queue_entry *q, |
| 141 | const char *data); |
| 142 | |
| 143 | #endif /* QUEUE_GENERIC_H */ |
| 144 | |
| 145 | /* |
| 146 | Local Variables: |
| 147 | c-basic-offset:2 |
| 148 | comment-column:40 |
| 149 | fill-column:79 |
| 150 | indent-tabs-mode:nil |
| 151 | End: |
| 152 | */ |