Commit | Line | Data |
---|---|---|
c133bd3c RK |
1 | /* |
2 | * This file is part of DisOrder | |
3 | * Copyright (C) 2006-2008 Richard Kettlewell | |
4 | * | |
e7eb3a27 | 5 | * This program is free software: you can redistribute it and/or modify |
c133bd3c | 6 | * it under the terms of the GNU General Public License as published by |
e7eb3a27 | 7 | * the Free Software Foundation, either version 3 of the License, or |
c133bd3c RK |
8 | * (at your option) any later version. |
9 | * | |
e7eb3a27 RK |
10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
c133bd3c | 15 | * You should have received a copy of the GNU General Public License |
e7eb3a27 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
c133bd3c | 17 | */ |
132a5a4a RK |
18 | /** @file disobedience/queue-generic.h |
19 | * @brief Disobedience queue widgets | |
20 | */ | |
c133bd3c RK |
21 | #ifndef QUEUE_GENERIC_H |
22 | #define QUEUE_GENERIC_H | |
23 | ||
24 | /** @brief Definition of a column */ | |
25 | struct queue_column { | |
26 | /** @brief Column name */ | |
27 | const char *name; | |
28 | ||
29 | /** @brief Compute value for this column */ | |
30 | const char *(*value)(const struct queue_entry *q, | |
31 | const char *data); | |
32 | ||
33 | /** @brief Passed to value() */ | |
34 | const char *data; | |
35 | ||
b0b15b7c RK |
36 | /** @brief Flags word */ |
37 | unsigned flags; | |
c133bd3c RK |
38 | }; |
39 | ||
b0b15b7c RK |
40 | /** @brief Ellipsize column if too wide */ |
41 | #define COL_ELLIPSIZE 0x0001 | |
42 | ||
43 | /** @brief Set expand property */ | |
44 | #define COL_EXPAND 0x0002 | |
45 | ||
46 | /** @brief Right-algin column */ | |
47 | #define COL_RIGHT 0x0004 | |
48 | ||
c133bd3c RK |
49 | /** @brief Definition of a queue-like window */ |
50 | struct queuelike { | |
51 | ||
52 | /* Things filled in by the caller: */ | |
53 | ||
ee7552f8 RK |
54 | /** @brief Name for this tab */ |
55 | const char *name; | |
56 | ||
c133bd3c RK |
57 | /** @brief Initialization function */ |
58 | void (*init)(void); | |
59 | ||
60 | /** @brief Columns */ | |
61 | const struct queue_column *columns; | |
62 | ||
63 | /** @brief Number of columns in this queuelike */ | |
64 | int ncolumns; | |
65 | ||
66 | /** @brief Items for popup menu */ | |
6982880f | 67 | struct menuitem *menuitems; |
c133bd3c RK |
68 | |
69 | /** @brief Number of menu items */ | |
70 | int nmenuitems; | |
71 | ||
72 | /* Dynamic state: */ | |
73 | ||
74 | /** @brief The head of the queue */ | |
75 | struct queue_entry *q; | |
76 | ||
77 | /* Things created by the implementation: */ | |
78 | ||
79 | /** @brief The list store */ | |
80 | GtkListStore *store; | |
81 | ||
82 | /** @brief The tree view */ | |
83 | GtkWidget *view; | |
84 | ||
85 | /** @brief The selection */ | |
86 | GtkTreeSelection *selection; | |
87 | ||
88 | /** @brief The popup menu */ | |
89 | GtkWidget *menu; | |
54156c62 RK |
90 | |
91 | /** @brief Menu callbacks */ | |
92 | struct tabtype tabtype; | |
82db9336 RK |
93 | |
94 | /** @brief Drag-drop callback, or NULL for no drag+drop | |
95 | * @param src Row to move | |
96 | * @param dst Destination position | |
97 | * | |
98 | * If the rearrangement is impossible then the displayed queue must be put | |
99 | * back. | |
100 | */ | |
101 | void (*drop)(int src, int dst); | |
102 | ||
103 | /** @brief Stashed drag target row */ | |
104 | GtkTreePath *drag_target; | |
c133bd3c RK |
105 | }; |
106 | ||
0fb5e8f3 RK |
107 | enum { |
108 | QUEUEPOINTER_COLUMN, | |
109 | FOREGROUND_COLUMN, | |
110 | BACKGROUND_COLUMN, | |
111 | ||
112 | EXTRA_COLUMNS | |
113 | }; | |
114 | ||
115 | /* TODO probably need to set "horizontal-separator" to 0, but can't find any | |
116 | * coherent description of how to set style properties in isolation. */ | |
117 | #define BG_PLAYING 0 | |
118 | #define FG_PLAYING 0 | |
119 | ||
120 | #ifndef BG_PLAYING | |
121 | # define BG_PLAYING "#e0ffe0" | |
122 | # define FG_PLAYING "black" | |
123 | #endif | |
124 | ||
c133bd3c RK |
125 | extern struct queuelike ql_queue; |
126 | extern struct queuelike ql_recent; | |
127 | extern struct queuelike ql_added; | |
128 | ||
129 | extern time_t last_playing; | |
130 | ||
6982880f | 131 | int ql_selectall_sensitive(void *extra); |
c133bd3c RK |
132 | void ql_selectall_activate(GtkMenuItem *menuitem, |
133 | gpointer user_data); | |
6982880f | 134 | int ql_selectnone_sensitive(void *extra); |
c133bd3c RK |
135 | void ql_selectnone_activate(GtkMenuItem *menuitem, |
136 | gpointer user_data); | |
6982880f | 137 | int ql_properties_sensitive(void *extra); |
c133bd3c RK |
138 | void ql_properties_activate(GtkMenuItem *menuitem, |
139 | gpointer user_data); | |
6982880f | 140 | int ql_scratch_sensitive(void *extra); |
c133bd3c RK |
141 | void ql_scratch_activate(GtkMenuItem *menuitem, |
142 | gpointer user_data); | |
6982880f | 143 | int ql_remove_sensitive(void *extra); |
c133bd3c RK |
144 | void ql_remove_activate(GtkMenuItem *menuitem, |
145 | gpointer user_data); | |
6982880f | 146 | int ql_play_sensitive(void *extra); |
c133bd3c RK |
147 | void ql_play_activate(GtkMenuItem *menuitem, |
148 | gpointer user_data); | |
a49c2c0f RK |
149 | int ql_adopt_sensitive(void *extra); |
150 | void ql_adopt_activate(GtkMenuItem *menuitem, | |
151 | gpointer user_data); | |
c133bd3c RK |
152 | gboolean ql_button_release(GtkWidget *widget, |
153 | GdkEventButton *event, | |
154 | gpointer user_data); | |
155 | GtkWidget *init_queuelike(struct queuelike *ql); | |
156 | void ql_update_list_store(struct queuelike *ql) ; | |
157 | void ql_update_row(struct queue_entry *q, | |
158 | GtkTreeIter *iter); | |
159 | void ql_new_queue(struct queuelike *ql, | |
160 | struct queue_entry *newq); | |
161 | const char *column_when(const struct queue_entry *q, | |
162 | const char *data); | |
163 | const char *column_who(const struct queue_entry *q, | |
164 | const char *data); | |
165 | const char *column_namepart(const struct queue_entry *q, | |
166 | const char *data); | |
167 | const char *column_length(const struct queue_entry *q, | |
168 | const char *data); | |
ee7552f8 | 169 | struct tabtype *ql_tabtype(struct queuelike *ql); |
83fb99f9 | 170 | struct queue_entry *ql_iter_to_q(GtkTreeModel *model, |
22717074 | 171 | GtkTreeIter *iter); |
c133bd3c RK |
172 | |
173 | #endif /* QUEUE_GENERIC_H */ | |
174 | ||
175 | /* | |
176 | Local Variables: | |
177 | c-basic-offset:2 | |
178 | comment-column:40 | |
179 | fill-column:79 | |
180 | indent-tabs-mode:nil | |
181 | End: | |
182 | */ |