Commit | Line | Data |
---|---|---|
c133bd3c RK |
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 | ||
b0b15b7c RK |
35 | /** @brief Flags word */ |
36 | unsigned flags; | |
c133bd3c RK |
37 | }; |
38 | ||
b0b15b7c RK |
39 | /** @brief Ellipsize column if too wide */ |
40 | #define COL_ELLIPSIZE 0x0001 | |
41 | ||
42 | /** @brief Set expand property */ | |
43 | #define COL_EXPAND 0x0002 | |
44 | ||
45 | /** @brief Right-algin column */ | |
46 | #define COL_RIGHT 0x0004 | |
47 | ||
c133bd3c RK |
48 | /** @brief Definition of a queue-like window */ |
49 | struct queuelike { | |
50 | ||
51 | /* Things filled in by the caller: */ | |
52 | ||
ee7552f8 RK |
53 | /** @brief Name for this tab */ |
54 | const char *name; | |
55 | ||
c133bd3c RK |
56 | /** @brief Initialization function */ |
57 | void (*init)(void); | |
58 | ||
59 | /** @brief Columns */ | |
60 | const struct queue_column *columns; | |
61 | ||
62 | /** @brief Number of columns in this queuelike */ | |
63 | int ncolumns; | |
64 | ||
65 | /** @brief Items for popup menu */ | |
6982880f | 66 | struct menuitem *menuitems; |
c133bd3c RK |
67 | |
68 | /** @brief Number of menu items */ | |
69 | int nmenuitems; | |
70 | ||
71 | /* Dynamic state: */ | |
72 | ||
73 | /** @brief The head of the queue */ | |
74 | struct queue_entry *q; | |
75 | ||
76 | /* Things created by the implementation: */ | |
77 | ||
78 | /** @brief The list store */ | |
79 | GtkListStore *store; | |
80 | ||
81 | /** @brief The tree view */ | |
82 | GtkWidget *view; | |
83 | ||
84 | /** @brief The selection */ | |
85 | GtkTreeSelection *selection; | |
86 | ||
87 | /** @brief The popup menu */ | |
88 | GtkWidget *menu; | |
54156c62 RK |
89 | |
90 | /** @brief Menu callbacks */ | |
91 | struct tabtype tabtype; | |
82db9336 RK |
92 | |
93 | /** @brief Drag-drop callback, or NULL for no drag+drop | |
94 | * @param src Row to move | |
95 | * @param dst Destination position | |
96 | * | |
97 | * If the rearrangement is impossible then the displayed queue must be put | |
98 | * back. | |
99 | */ | |
100 | void (*drop)(int src, int dst); | |
101 | ||
102 | /** @brief Stashed drag target row */ | |
103 | GtkTreePath *drag_target; | |
c133bd3c RK |
104 | }; |
105 | ||
0fb5e8f3 RK |
106 | enum { |
107 | QUEUEPOINTER_COLUMN, | |
108 | FOREGROUND_COLUMN, | |
109 | BACKGROUND_COLUMN, | |
110 | ||
111 | EXTRA_COLUMNS | |
112 | }; | |
113 | ||
114 | /* TODO probably need to set "horizontal-separator" to 0, but can't find any | |
115 | * coherent description of how to set style properties in isolation. */ | |
116 | #define BG_PLAYING 0 | |
117 | #define FG_PLAYING 0 | |
118 | ||
119 | #ifndef BG_PLAYING | |
120 | # define BG_PLAYING "#e0ffe0" | |
121 | # define FG_PLAYING "black" | |
122 | #endif | |
123 | ||
c133bd3c RK |
124 | extern struct queuelike ql_queue; |
125 | extern struct queuelike ql_recent; | |
126 | extern struct queuelike ql_added; | |
127 | ||
128 | extern time_t last_playing; | |
129 | ||
6982880f | 130 | int ql_selectall_sensitive(void *extra); |
c133bd3c RK |
131 | void ql_selectall_activate(GtkMenuItem *menuitem, |
132 | gpointer user_data); | |
6982880f | 133 | int ql_selectnone_sensitive(void *extra); |
c133bd3c RK |
134 | void ql_selectnone_activate(GtkMenuItem *menuitem, |
135 | gpointer user_data); | |
6982880f | 136 | int ql_properties_sensitive(void *extra); |
c133bd3c RK |
137 | void ql_properties_activate(GtkMenuItem *menuitem, |
138 | gpointer user_data); | |
6982880f | 139 | int ql_scratch_sensitive(void *extra); |
c133bd3c RK |
140 | void ql_scratch_activate(GtkMenuItem *menuitem, |
141 | gpointer user_data); | |
6982880f | 142 | int ql_remove_sensitive(void *extra); |
c133bd3c RK |
143 | void ql_remove_activate(GtkMenuItem *menuitem, |
144 | gpointer user_data); | |
6982880f | 145 | int ql_play_sensitive(void *extra); |
c133bd3c RK |
146 | void ql_play_activate(GtkMenuItem *menuitem, |
147 | gpointer user_data); | |
148 | gboolean ql_button_release(GtkWidget *widget, | |
149 | GdkEventButton *event, | |
150 | gpointer user_data); | |
151 | GtkWidget *init_queuelike(struct queuelike *ql); | |
152 | void ql_update_list_store(struct queuelike *ql) ; | |
153 | void ql_update_row(struct queue_entry *q, | |
154 | GtkTreeIter *iter); | |
155 | void ql_new_queue(struct queuelike *ql, | |
156 | struct queue_entry *newq); | |
157 | const char *column_when(const struct queue_entry *q, | |
158 | const char *data); | |
159 | const char *column_who(const struct queue_entry *q, | |
160 | const char *data); | |
161 | const char *column_namepart(const struct queue_entry *q, | |
162 | const char *data); | |
163 | const char *column_length(const struct queue_entry *q, | |
164 | const char *data); | |
ee7552f8 | 165 | struct tabtype *ql_tabtype(struct queuelike *ql); |
83fb99f9 | 166 | struct queue_entry *ql_iter_to_q(GtkTreeModel *model, |
22717074 | 167 | GtkTreeIter *iter); |
c133bd3c RK |
168 | |
169 | #endif /* QUEUE_GENERIC_H */ | |
170 | ||
171 | /* | |
172 | Local Variables: | |
173 | c-basic-offset:2 | |
174 | comment-column:40 | |
175 | fill-column:79 | |
176 | indent-tabs-mode:nil | |
177 | End: | |
178 | */ |