chiark / gitweb /
Switch to GPL v3
[disorder] / disobedience / queue-generic.h
... / ...
CommitLineData
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 3 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,
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 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18#ifndef QUEUE_GENERIC_H
19#define QUEUE_GENERIC_H
20
21/** @brief Definition of a column */
22struct queue_column {
23 /** @brief Column name */
24 const char *name;
25
26 /** @brief Compute value for this column */
27 const char *(*value)(const struct queue_entry *q,
28 const char *data);
29
30 /** @brief Passed to value() */
31 const char *data;
32
33 /** @brief Flags word */
34 unsigned flags;
35};
36
37/** @brief Ellipsize column if too wide */
38#define COL_ELLIPSIZE 0x0001
39
40/** @brief Set expand property */
41#define COL_EXPAND 0x0002
42
43/** @brief Right-algin column */
44#define COL_RIGHT 0x0004
45
46/** @brief Definition of a queue-like window */
47struct queuelike {
48
49 /* Things filled in by the caller: */
50
51 /** @brief Name for this tab */
52 const char *name;
53
54 /** @brief Initialization function */
55 void (*init)(void);
56
57 /** @brief Columns */
58 const struct queue_column *columns;
59
60 /** @brief Number of columns in this queuelike */
61 int ncolumns;
62
63 /** @brief Items for popup menu */
64 struct menuitem *menuitems;
65
66 /** @brief Number of menu items */
67 int nmenuitems;
68
69 /* Dynamic state: */
70
71 /** @brief The head of the queue */
72 struct queue_entry *q;
73
74 /* Things created by the implementation: */
75
76 /** @brief The list store */
77 GtkListStore *store;
78
79 /** @brief The tree view */
80 GtkWidget *view;
81
82 /** @brief The selection */
83 GtkTreeSelection *selection;
84
85 /** @brief The popup menu */
86 GtkWidget *menu;
87
88 /** @brief Menu callbacks */
89 struct tabtype tabtype;
90};
91
92enum {
93 QUEUEPOINTER_COLUMN,
94 FOREGROUND_COLUMN,
95 BACKGROUND_COLUMN,
96
97 EXTRA_COLUMNS
98};
99
100/* TODO probably need to set "horizontal-separator" to 0, but can't find any
101 * coherent description of how to set style properties in isolation. */
102#define BG_PLAYING 0
103#define FG_PLAYING 0
104
105#ifndef BG_PLAYING
106# define BG_PLAYING "#e0ffe0"
107# define FG_PLAYING "black"
108#endif
109
110extern struct queuelike ql_queue;
111extern struct queuelike ql_recent;
112extern struct queuelike ql_added;
113
114extern time_t last_playing;
115
116int ql_selectall_sensitive(void *extra);
117void ql_selectall_activate(GtkMenuItem *menuitem,
118 gpointer user_data);
119int ql_selectnone_sensitive(void *extra);
120void ql_selectnone_activate(GtkMenuItem *menuitem,
121 gpointer user_data);
122int ql_properties_sensitive(void *extra);
123void ql_properties_activate(GtkMenuItem *menuitem,
124 gpointer user_data);
125int ql_scratch_sensitive(void *extra);
126void ql_scratch_activate(GtkMenuItem *menuitem,
127 gpointer user_data);
128int ql_remove_sensitive(void *extra);
129void ql_remove_activate(GtkMenuItem *menuitem,
130 gpointer user_data);
131int ql_play_sensitive(void *extra);
132void ql_play_activate(GtkMenuItem *menuitem,
133 gpointer user_data);
134gboolean ql_button_release(GtkWidget *widget,
135 GdkEventButton *event,
136 gpointer user_data);
137GtkWidget *init_queuelike(struct queuelike *ql);
138void ql_update_list_store(struct queuelike *ql) ;
139void ql_update_row(struct queue_entry *q,
140 GtkTreeIter *iter);
141void ql_new_queue(struct queuelike *ql,
142 struct queue_entry *newq);
143const char *column_when(const struct queue_entry *q,
144 const char *data);
145const char *column_who(const struct queue_entry *q,
146 const char *data);
147const char *column_namepart(const struct queue_entry *q,
148 const char *data);
149const char *column_length(const struct queue_entry *q,
150 const char *data);
151struct tabtype *ql_tabtype(struct queuelike *ql);
152struct queue_entry *ql_iter_to_q(GtkTreeModel *model,
153 GtkTreeIter *iter);
154
155#endif /* QUEUE_GENERIC_H */
156
157/*
158Local Variables:
159c-basic-offset:2
160comment-column:40
161fill-column:79
162indent-tabs-mode:nil
163End:
164*/