chiark / gitweb /
disobedience support for recently added track list
[disorder] / disobedience / disobedience.h
CommitLineData
460b9539 1/*
2 * This file is part of DisOrder.
348ef780 3 * Copyright (C) 2006, 2007 Richard Kettlewell
460b9539 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 */
2c348789
RK
20/** @file disobedience/disobedience.h
21 * @brief Header file for Disobedience, the DisOrder GTK+ client
22 */
460b9539 23
24#ifndef DISOBEDIENCE_H
25#define DISOBEDIENCE_H
26
27#include <config.h>
28#include "types.h"
29
30#include <stdio.h>
31#include <time.h>
32#include <string.h>
33#include <assert.h>
34#include <ctype.h>
35#include <errno.h>
36#include <math.h>
37
38#include "mem.h"
39#include "log.h"
40#include "eclient.h"
41#include "printf.h"
42#include "cache.h"
43#include "queue.h"
44#include "printf.h"
45#include "vector.h"
46#include "trackname.h"
47#include "syscalls.h"
48#include "defs.h"
49#include "configuration.h"
50#include "hash.h"
51#include "selection.h"
52
53#include <glib.h>
54#include <gtk/gtk.h>
55#include <gdk-pixbuf/gdk-pixbuf.h>
56
57/* Types ------------------------------------------------------------------- */
58
59struct queuelike;
60struct choosenode;
61
2c348789
RK
62/** @brief Callback data structure
63 *
64 * This program is extremely heavily callback-driven. Rather than have
65 * numerous different callback structures we have a single one which can be
66 * interpreted adequately both by success and error handlers.
67 */
460b9539 68struct callbackdata {
69 void (*onerror)(struct callbackdata *cbd,
70 int code,
71 const char *msg); /* called on error */
72 union {
73 const char *key; /* gtkqueue.c op_part_lookup */
74 struct choosenode *choosenode; /* gtkchoose.c got_files/got_dirs */
75 struct queuelike *ql; /* gtkqueue.c queuelike_completed */
76 struct prefdata *f; /* properties.c */
77 } u;
78};
79
2c348789
RK
80/** @brief Per-tab callbacks
81 *
82 * Some of the options in the main menu depend on which tab is displayed, so we
83 * have some callbacks to set them appropriately.
84 */
460b9539 85struct tabtype {
86 int (*properties_sensitive)(GtkWidget *tab);
87 int (*selectall_sensitive)(GtkWidget *tab);
88 void (*properties_activate)(GtkWidget *tab);
89 void (*selectall_activate)(GtkWidget *tab);
90};
91
92/* Variables --------------------------------------------------------------- */
93
94extern GMainLoop *mainloop;
95extern GtkWidget *toplevel; /* top level window */
96extern GtkWidget *report_label; /* label for progress indicator */
97extern GtkWidget *tabs; /* main tabs */
98extern disorder_eclient *client; /* main client */
99
100extern unsigned long last_state; /* last reported state */
101extern int playing; /* true if playing some track */
102extern int volume_l, volume_r; /* current volume */
103extern double goesupto; /* volume upper bound */
104extern int choosealpha; /* break up choose by letter */
348ef780 105extern GtkTooltips *tips;
460b9539 106
10e226b3
RK
107extern const disorder_eclient_log_callbacks log_callbacks;
108
00959300 109typedef void monitor_callback(void *u);
186f896b 110
460b9539 111/* Functions --------------------------------------------------------------- */
112
113disorder_eclient *gtkclient(void);
114/* Configure C for use in GTK+ programs */
115
116void popup_protocol_error(int code,
117 const char *msg);
118/* Report an error */
119
16e145a5 120void properties(int ntracks, const char **tracks);
460b9539 121/* Pop up a properties window for a list of tracks */
122
123GtkWidget *scroll_widget(GtkWidget *child, const char *name);
124/* Wrap a widget up for scrolling */
125
126GdkPixbuf *find_image(const char *name);
127/* Get the pixbuf for an image. Returns a null pointer if it cannot be
128 * found. */
129
130void popup_error(const char *msg);
131/* Pop up an error message */
132
186f896b
RK
133void register_monitor(monitor_callback *callback,
134 void *u,
135 unsigned long mask);
136/* Register a state monitor */
137
10e226b3
RK
138void all_update(void);
139/* Update everything */
460b9539 140
141/* Main menu */
142
143GtkWidget *menubar(GtkWidget *w);
144/* Create the menu bar */
145
146void menu_update(int page);
147/* Called whenever the main menu might need to change. PAGE is the current
148 * page if known or -1 otherwise. */
149
150
151/* Controls */
152
153GtkWidget *control_widget(void);
154/* Make the controls widget */
155
6d1302f0
RK
156void volume_update(void);
157/* Called whenever we think the volume control has changed */
460b9539 158
4eb1f430 159/* Queue/Recent/Added */
460b9539 160
161GtkWidget *queue_widget(void);
162GtkWidget *recent_widget(void);
4eb1f430
RK
163GtkWidget *added_widget(void);
164/* Create widgets for displaying the queue, the recently played list and the
165 * newly added tracks list */
460b9539 166
167void queue_update(void);
168void recent_update(void);
4eb1f430
RK
169void added_update(void);
170/* Called whenever we think the queue, recent or newly-added list might have
171 * changed */
460b9539 172
173void queue_select_all(struct queuelike *ql);
174/* Select all on some queue */
175
176void queue_properties(struct queuelike *ql);
177/* Pop up properties of selected items in some queue */
178
460b9539 179int queued(const char *track);
180/* Return nonzero iff TRACK is queued or playing */
181
182void namepart_update(const char *track,
183 const char *context,
184 const char *part);
185/* Called when a namepart might have changed */
186
187
188/* Choose */
189
190GtkWidget *choose_widget(void);
191/* Create a widget for choosing tracks */
192
193void choose_update(void);
194/* Called when we think the choose tree might need updating */
195
e9b70a84 196/* Widget leakage debugging rubbish ---------------------------------------- */
197
198#if MDEBUG
199#define NW(what) do { \
200 if(++current##what % 100 > max##what) { \
201 fprintf(stderr, "%s:%d: %d %s\n", \
202 __FILE__, __LINE__, current##what, #what); \
203 max##what = current##what; \
204 } \
205} while(0)
206#define WT(what) static int current##what, max##what
207#define DW(what) (--current##what)
208#else
1a48886f
RK
209#define NW(what) do { } while(0)
210#define DW(what) do { } while(0)
e9b70a84 211#define WT(what) struct neverused
212#endif
213
e1d4a32b 214#if MTRACK
215extern const char *mtag;
216#define MTAG(x) do { mtag = x; } while(0)
217#define MTAG_PUSH(x) do { const char *save_mtag = mtag; mtag = x; (void)0
218#define MTAG_POP() mtag = save_mtag; } while(0)
219#else
220#define MTAG(x) do { } while(0)
221#define MTAG_PUSH(x) do {} while(0)
222#define MTAG_POP() do {} while(0)
223#endif
224
460b9539 225#endif /* DISOBEDIENCE_H */
226
227/*
228Local Variables:
229c-basic-offset:2
230comment-column:40
231fill-column:79
232indent-tabs-mode:nil
233End:
234*/