chiark / gitweb /
correct eclient for new hashes
[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
159/* Queue/Recent */
160
161GtkWidget *queue_widget(void);
162GtkWidget *recent_widget(void);
163/* Create widgets for displaying the queue and the recently played list */
164
165void queue_update(void);
166void recent_update(void);
167/* Called whenever we think the queue or recent list might have chanegd */
168
169void queue_select_all(struct queuelike *ql);
170/* Select all on some queue */
171
172void queue_properties(struct queuelike *ql);
173/* Pop up properties of selected items in some queue */
174
460b9539 175int queued(const char *track);
176/* Return nonzero iff TRACK is queued or playing */
177
178void namepart_update(const char *track,
179 const char *context,
180 const char *part);
181/* Called when a namepart might have changed */
182
183
184/* Choose */
185
186GtkWidget *choose_widget(void);
187/* Create a widget for choosing tracks */
188
189void choose_update(void);
190/* Called when we think the choose tree might need updating */
191
e9b70a84 192/* Widget leakage debugging rubbish ---------------------------------------- */
193
194#if MDEBUG
195#define NW(what) do { \
196 if(++current##what % 100 > max##what) { \
197 fprintf(stderr, "%s:%d: %d %s\n", \
198 __FILE__, __LINE__, current##what, #what); \
199 max##what = current##what; \
200 } \
201} while(0)
202#define WT(what) static int current##what, max##what
203#define DW(what) (--current##what)
204#else
1a48886f
RK
205#define NW(what) do { } while(0)
206#define DW(what) do { } while(0)
e9b70a84 207#define WT(what) struct neverused
208#endif
209
e1d4a32b 210#if MTRACK
211extern const char *mtag;
212#define MTAG(x) do { mtag = x; } while(0)
213#define MTAG_PUSH(x) do { const char *save_mtag = mtag; mtag = x; (void)0
214#define MTAG_POP() mtag = save_mtag; } while(0)
215#else
216#define MTAG(x) do { } while(0)
217#define MTAG_PUSH(x) do {} while(0)
218#define MTAG_POP() do {} while(0)
219#endif
220
460b9539 221#endif /* DISOBEDIENCE_H */
222
223/*
224Local Variables:
225c-basic-offset:2
226comment-column:40
227fill-column:79
228indent-tabs-mode:nil
229End:
230*/