chiark / gitweb /
disorder_eclient_queue_response now gets error as well as success
[disorder] / disobedience / disobedience.h
CommitLineData
460b9539 1/*
2 * This file is part of DisOrder.
fb009628 3 * Copyright (C) 2006-2008 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
05b75f8d 27#include "common.h"
460b9539 28
460b9539 29#include <time.h>
460b9539 30#include <ctype.h>
31#include <errno.h>
32#include <math.h>
33
34#include "mem.h"
35#include "log.h"
36#include "eclient.h"
37#include "printf.h"
38#include "cache.h"
39#include "queue.h"
40#include "printf.h"
41#include "vector.h"
42#include "trackname.h"
43#include "syscalls.h"
44#include "defs.h"
45#include "configuration.h"
46#include "hash.h"
47#include "selection.h"
53fa91bb 48#include "kvp.h"
460b9539 49
50#include <glib.h>
51#include <gtk/gtk.h>
52#include <gdk-pixbuf/gdk-pixbuf.h>
53
54/* Types ------------------------------------------------------------------- */
55
56struct queuelike;
57struct choosenode;
c3df9503 58struct progress_window;
460b9539 59
2c348789
RK
60/** @brief Callback data structure
61 *
62 * This program is extremely heavily callback-driven. Rather than have
63 * numerous different callback structures we have a single one which can be
64 * interpreted adequately both by success and error handlers.
65 */
460b9539 66struct callbackdata {
67 void (*onerror)(struct callbackdata *cbd,
68 int code,
69 const char *msg); /* called on error */
70 union {
71 const char *key; /* gtkqueue.c op_part_lookup */
72 struct choosenode *choosenode; /* gtkchoose.c got_files/got_dirs */
73 struct queuelike *ql; /* gtkqueue.c queuelike_completed */
74 struct prefdata *f; /* properties.c */
4aa8a0a4 75 const char *user; /* users.c */
0d719587
RK
76 struct {
77 const char *user, *email; /* users.c */
78 } edituser;
460b9539 79 } u;
80};
81
2c348789
RK
82/** @brief Per-tab callbacks
83 *
84 * Some of the options in the main menu depend on which tab is displayed, so we
85 * have some callbacks to set them appropriately.
86 */
460b9539 87struct tabtype {
88 int (*properties_sensitive)(GtkWidget *tab);
89 int (*selectall_sensitive)(GtkWidget *tab);
fb009628 90 int (*selectnone_sensitive)(GtkWidget *tab);
460b9539 91 void (*properties_activate)(GtkWidget *tab);
92 void (*selectall_activate)(GtkWidget *tab);
fb009628 93 void (*selectnone_activate)(GtkWidget *tab);
460b9539 94};
95
73f1b9f3
RK
96/** @brief Button definitions */
97struct button {
98 const gchar *stock;
99 void (*clicked)(GtkButton *button, gpointer userdata);
100 const char *tip;
f44417cf 101 GtkWidget *widget;
73f1b9f3
RK
102};
103
460b9539 104/* Variables --------------------------------------------------------------- */
105
106extern GMainLoop *mainloop;
107extern GtkWidget *toplevel; /* top level window */
108extern GtkWidget *report_label; /* label for progress indicator */
109extern GtkWidget *tabs; /* main tabs */
110extern disorder_eclient *client; /* main client */
111
112extern unsigned long last_state; /* last reported state */
113extern int playing; /* true if playing some track */
114extern int volume_l, volume_r; /* current volume */
115extern double goesupto; /* volume upper bound */
116extern int choosealpha; /* break up choose by letter */
348ef780 117extern GtkTooltips *tips;
a99c4e9a
RK
118extern int rtp_supported;
119extern int rtp_is_running;
ac6bf2ba 120extern GtkItemFactory *mainmenufactory;
460b9539 121
10e226b3
RK
122extern const disorder_eclient_log_callbacks log_callbacks;
123
00959300 124typedef void monitor_callback(void *u);
186f896b 125
460b9539 126/* Functions --------------------------------------------------------------- */
127
128disorder_eclient *gtkclient(void);
129/* Configure C for use in GTK+ programs */
130
131void popup_protocol_error(int code,
132 const char *msg);
133/* Report an error */
134
16e145a5 135void properties(int ntracks, const char **tracks);
460b9539 136/* Pop up a properties window for a list of tracks */
137
73f1b9f3
RK
138void properties_reset(void);
139
d4ef4132 140GtkWidget *scroll_widget(GtkWidget *child);
460b9539 141/* Wrap a widget up for scrolling */
142
e18c4734
RK
143GtkWidget *frame_widget(GtkWidget *w, const char *title);
144
460b9539 145GdkPixbuf *find_image(const char *name);
146/* Get the pixbuf for an image. Returns a null pointer if it cannot be
147 * found. */
148
043d60b1 149void popup_msg(GtkMessageType mt, const char *msg);
34239ce4 150void popup_submsg(GtkWidget *parent, GtkMessageType mt, const char *msg);
460b9539 151
043d60b1 152void fpopup_msg(GtkMessageType mt, const char *fmt, ...);
73f1b9f3 153
c3df9503
RK
154struct progress_window *progress_window_new(const char *title);
155/* Pop up a progress window */
156
157void progress_window_progress(struct progress_window *pw,
158 int progress,
159 int limit);
160/* Report current progress */
161
fcc8b9f7
RK
162GtkWidget *iconbutton(const char *path, const char *tip);
163
f44417cf 164GtkWidget *create_buttons(struct button *buttons,
73f1b9f3 165 size_t nbuttons);
f44417cf 166GtkWidget *create_buttons_box(struct button *buttons,
ffc4dbaf
RK
167 size_t nbuttons,
168 GtkWidget *box);
73f1b9f3 169
186f896b
RK
170void register_monitor(monitor_callback *callback,
171 void *u,
172 unsigned long mask);
173/* Register a state monitor */
174
73f1b9f3
RK
175/** @brief Type signature for a reset callback */
176typedef void reset_callback(void);
177
178void register_reset(reset_callback *callback);
179/* Register a reset callback */
180
181void reset(void);
182
10e226b3
RK
183void all_update(void);
184/* Update everything */
460b9539 185
186/* Main menu */
187
188GtkWidget *menubar(GtkWidget *w);
189/* Create the menu bar */
190
191void menu_update(int page);
192/* Called whenever the main menu might need to change. PAGE is the current
193 * page if known or -1 otherwise. */
194
c73bd6c1 195void users_set_sensitive(int sensitive);
460b9539 196
197/* Controls */
198
199GtkWidget *control_widget(void);
200/* Make the controls widget */
201
6d1302f0
RK
202void volume_update(void);
203/* Called whenever we think the volume control has changed */
460b9539 204
a99c4e9a
RK
205void control_monitor(void *u);
206
fb44b59e
RK
207extern int suppress_actions;
208
4eb1f430 209/* Queue/Recent/Added */
460b9539 210
211GtkWidget *queue_widget(void);
212GtkWidget *recent_widget(void);
4eb1f430
RK
213GtkWidget *added_widget(void);
214/* Create widgets for displaying the queue, the recently played list and the
215 * newly added tracks list */
460b9539 216
217void queue_update(void);
218void recent_update(void);
4eb1f430
RK
219void added_update(void);
220/* Called whenever we think the queue, recent or newly-added list might have
221 * changed */
460b9539 222
223void queue_select_all(struct queuelike *ql);
fb009628
RK
224void queue_select_none(struct queuelike *ql);
225/* Select all/none on some queue */
460b9539 226
227void queue_properties(struct queuelike *ql);
228/* Pop up properties of selected items in some queue */
229
460b9539 230int queued(const char *track);
231/* Return nonzero iff TRACK is queued or playing */
232
233void namepart_update(const char *track,
234 const char *context,
235 const char *part);
236/* Called when a namepart might have changed */
237
460b9539 238/* Choose */
239
240GtkWidget *choose_widget(void);
241/* Create a widget for choosing tracks */
242
243void choose_update(void);
244/* Called when we think the choose tree might need updating */
245
53fa91bb
RK
246void play_completed(void *v,
247 const char *error);
248
a99c4e9a
RK
249/* Login details */
250
73f1b9f3
RK
251void login_box(void);
252
e9e8a16d
RK
253GtkWidget *login_window;
254
ffc4dbaf
RK
255/* User management */
256
257void manage_users(void);
258
13affe66
RK
259/* Help */
260
261void popup_help(void);
262
a99c4e9a
RK
263/* RTP */
264
265int rtp_running(void);
266void start_rtp(void);
267void stop_rtp(void);
268
f486ea18 269/* Settings */
d4ef4132 270
33288048
RK
271void init_styles(void);
272extern GtkStyle *layout_style;
273extern GtkStyle *title_style;
274extern GtkStyle *even_style;
275extern GtkStyle *odd_style;
276extern GtkStyle *active_style;
277extern GtkStyle *tool_style;
278extern GtkStyle *search_style;
279extern GtkStyle *drag_style;
d4ef4132 280
f486ea18
RK
281extern const char *browser;
282
283void save_settings(void);
284void load_settings(void);
d4ef4132 285void set_tool_colors(GtkWidget *w);
46fb1b05 286void popup_settings(void);
d4ef4132 287
e9b70a84 288/* Widget leakage debugging rubbish ---------------------------------------- */
289
290#if MDEBUG
291#define NW(what) do { \
292 if(++current##what % 100 > max##what) { \
293 fprintf(stderr, "%s:%d: %d %s\n", \
294 __FILE__, __LINE__, current##what, #what); \
295 max##what = current##what; \
296 } \
297} while(0)
298#define WT(what) static int current##what, max##what
299#define DW(what) (--current##what)
300#else
1a48886f
RK
301#define NW(what) do { } while(0)
302#define DW(what) do { } while(0)
e9b70a84 303#define WT(what) struct neverused
304#endif
305
e1d4a32b 306#if MTRACK
307extern const char *mtag;
308#define MTAG(x) do { mtag = x; } while(0)
309#define MTAG_PUSH(x) do { const char *save_mtag = mtag; mtag = x; (void)0
310#define MTAG_POP() mtag = save_mtag; } while(0)
311#else
312#define MTAG(x) do { } while(0)
313#define MTAG_PUSH(x) do {} while(0)
314#define MTAG_POP() do {} while(0)
315#endif
316
460b9539 317#endif /* DISOBEDIENCE_H */
318
319/*
320Local Variables:
321c-basic-offset:2
322comment-column:40
323fill-column:79
324indent-tabs-mode:nil
325End:
326*/