chiark / gitweb /
Don't allocate per-queue tabtype. In fact the allocate version broken
[disorder] / disobedience / queue-generic.h
CommitLineData
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 */
24struct 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 An item in the queue's popup menu */
49struct queue_menuitem {
50 /** @brief Menu item name */
51 const char *name;
52
53 /** @brief Called to activate the menu item */
54 void (*activate)(GtkMenuItem *menuitem,
55 gpointer user_data);
56
57 /** @brief Called to determine whether the menu item is usable.
58 *
59 * Returns @c TRUE if it should be sensitive and @c FALSE otherwise.
60 */
61 int (*sensitive)(struct queuelike *ql);
62
63 /** @brief Signal handler ID */
64 gulong handlerid;
65
66 /** @brief Widget for menu item */
67 GtkWidget *w;
68};
69
70/** @brief Definition of a queue-like window */
71struct queuelike {
72
73 /* Things filled in by the caller: */
74
ee7552f8
RK
75 /** @brief Name for this tab */
76 const char *name;
77
c133bd3c
RK
78 /** @brief Initialization function */
79 void (*init)(void);
80
81 /** @brief Columns */
82 const struct queue_column *columns;
83
84 /** @brief Number of columns in this queuelike */
85 int ncolumns;
86
87 /** @brief Items for popup menu */
88 struct queue_menuitem *menuitems;
89
90 /** @brief Number of menu items */
91 int nmenuitems;
92
93 /* Dynamic state: */
94
95 /** @brief The head of the queue */
96 struct queue_entry *q;
97
98 /* Things created by the implementation: */
99
100 /** @brief The list store */
101 GtkListStore *store;
102
103 /** @brief The tree view */
104 GtkWidget *view;
105
106 /** @brief The selection */
107 GtkTreeSelection *selection;
108
109 /** @brief The popup menu */
110 GtkWidget *menu;
54156c62
RK
111
112 /** @brief Menu callbacks */
113 struct tabtype tabtype;
c133bd3c
RK
114};
115
116extern struct queuelike ql_queue;
117extern struct queuelike ql_recent;
118extern struct queuelike ql_added;
119
120extern time_t last_playing;
121
122int ql_selectall_sensitive(struct queuelike *ql);
123void ql_selectall_activate(GtkMenuItem *menuitem,
124 gpointer user_data);
125int ql_selectnone_sensitive(struct queuelike *ql);
126void ql_selectnone_activate(GtkMenuItem *menuitem,
127 gpointer user_data);
128int ql_properties_sensitive(struct queuelike *ql);
129void ql_properties_activate(GtkMenuItem *menuitem,
130 gpointer user_data);
131int ql_scratch_sensitive(struct queuelike *ql);
132void ql_scratch_activate(GtkMenuItem *menuitem,
133 gpointer user_data);
134int ql_remove_sensitive(struct queuelike *ql);
135void ql_remove_activate(GtkMenuItem *menuitem,
136 gpointer user_data);
137int ql_play_sensitive(struct queuelike *ql);
138void ql_play_activate(GtkMenuItem *menuitem,
139 gpointer user_data);
140gboolean ql_button_release(GtkWidget *widget,
141 GdkEventButton *event,
142 gpointer user_data);
143GtkWidget *init_queuelike(struct queuelike *ql);
144void ql_update_list_store(struct queuelike *ql) ;
145void ql_update_row(struct queue_entry *q,
146 GtkTreeIter *iter);
147void ql_new_queue(struct queuelike *ql,
148 struct queue_entry *newq);
149const char *column_when(const struct queue_entry *q,
150 const char *data);
151const char *column_who(const struct queue_entry *q,
152 const char *data);
153const char *column_namepart(const struct queue_entry *q,
154 const char *data);
155const char *column_length(const struct queue_entry *q,
156 const char *data);
ee7552f8 157struct tabtype *ql_tabtype(struct queuelike *ql);
83fb99f9 158struct queue_entry *ql_iter_to_q(GtkTreeModel *model,
22717074 159 GtkTreeIter *iter);
c133bd3c
RK
160
161#endif /* QUEUE_GENERIC_H */
162
163/*
164Local Variables:
165c-basic-offset:2
166comment-column:40
167fill-column:79
168indent-tabs-mode:nil
169End:
170*/