chiark / gitweb /
Columns are now resizable and wide columns are ellipsized. Columns
[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"
3569ddb8 49#include "eventdist.h"
6856f665 50#include "split.h"
460b9539 51
52#include <glib.h>
53#include <gtk/gtk.h>
54#include <gdk-pixbuf/gdk-pixbuf.h>
55
56/* Types ------------------------------------------------------------------- */
57
58struct queuelike;
59struct choosenode;
c3df9503 60struct progress_window;
460b9539 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 */
4aa8a0a4 77 const char *user; /* users.c */
0d719587
RK
78 struct {
79 const char *user, *email; /* users.c */
80 } edituser;
460b9539 81 } u;
82};
83
2c348789
RK
84/** @brief Per-tab callbacks
85 *
86 * Some of the options in the main menu depend on which tab is displayed, so we
87 * have some callbacks to set them appropriately.
88 */
460b9539 89struct tabtype {
90 int (*properties_sensitive)(GtkWidget *tab);
91 int (*selectall_sensitive)(GtkWidget *tab);
fb009628 92 int (*selectnone_sensitive)(GtkWidget *tab);
460b9539 93 void (*properties_activate)(GtkWidget *tab);
94 void (*selectall_activate)(GtkWidget *tab);
fb009628 95 void (*selectnone_activate)(GtkWidget *tab);
2a3fe554 96 void (*selected)(void);
460b9539 97};
98
73f1b9f3
RK
99/** @brief Button definitions */
100struct button {
101 const gchar *stock;
102 void (*clicked)(GtkButton *button, gpointer userdata);
103 const char *tip;
f44417cf 104 GtkWidget *widget;
73f1b9f3
RK
105};
106
460b9539 107/* Variables --------------------------------------------------------------- */
108
109extern GMainLoop *mainloop;
110extern GtkWidget *toplevel; /* top level window */
111extern GtkWidget *report_label; /* label for progress indicator */
112extern GtkWidget *tabs; /* main tabs */
113extern disorder_eclient *client; /* main client */
114
115extern unsigned long last_state; /* last reported state */
6f09d54d 116extern rights_type last_rights; /* last reported rights bitmap */
460b9539 117extern int playing; /* true if playing some track */
118extern int volume_l, volume_r; /* current volume */
119extern double goesupto; /* volume upper bound */
120extern int choosealpha; /* break up choose by letter */
348ef780 121extern GtkTooltips *tips;
a99c4e9a
RK
122extern int rtp_supported;
123extern int rtp_is_running;
ac6bf2ba 124extern GtkItemFactory *mainmenufactory;
460b9539 125
10e226b3
RK
126extern const disorder_eclient_log_callbacks log_callbacks;
127
460b9539 128/* Functions --------------------------------------------------------------- */
129
130disorder_eclient *gtkclient(void);
131/* Configure C for use in GTK+ programs */
132
133void popup_protocol_error(int code,
134 const char *msg);
135/* Report an error */
136
16e145a5 137void properties(int ntracks, const char **tracks);
460b9539 138/* Pop up a properties window for a list of tracks */
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
7c30fc75 170void logged_in(void);
73f1b9f3 171
10e226b3
RK
172void all_update(void);
173/* Update everything */
460b9539 174
175/* Main menu */
176
177GtkWidget *menubar(GtkWidget *w);
178/* Create the menu bar */
179
180void menu_update(int page);
181/* Called whenever the main menu might need to change. PAGE is the current
182 * page if known or -1 otherwise. */
183
c73bd6c1 184void users_set_sensitive(int sensitive);
460b9539 185
186/* Controls */
187
188GtkWidget *control_widget(void);
189/* Make the controls widget */
190
fb44b59e
RK
191extern int suppress_actions;
192
4eb1f430 193/* Queue/Recent/Added */
460b9539 194
195GtkWidget *queue_widget(void);
196GtkWidget *recent_widget(void);
4eb1f430
RK
197GtkWidget *added_widget(void);
198/* Create widgets for displaying the queue, the recently played list and the
199 * newly added tracks list */
460b9539 200
460b9539 201void queue_select_all(struct queuelike *ql);
fb009628
RK
202void queue_select_none(struct queuelike *ql);
203/* Select all/none on some queue */
460b9539 204
205void queue_properties(struct queuelike *ql);
206/* Pop up properties of selected items in some queue */
207
460b9539 208int queued(const char *track);
209/* Return nonzero iff TRACK is queued or playing */
210
211void namepart_update(const char *track,
212 const char *context,
213 const char *part);
214/* Called when a namepart might have changed */
215
afe9f743
RK
216extern struct queue_entry *playing_track;
217
460b9539 218/* Choose */
219
220GtkWidget *choose_widget(void);
221/* Create a widget for choosing tracks */
222
223void choose_update(void);
224/* Called when we think the choose tree might need updating */
225
53fa91bb
RK
226void play_completed(void *v,
227 const char *error);
228
a99c4e9a
RK
229/* Login details */
230
73f1b9f3
RK
231void login_box(void);
232
e9e8a16d
RK
233GtkWidget *login_window;
234
ffc4dbaf
RK
235/* User management */
236
237void manage_users(void);
238
13affe66
RK
239/* Help */
240
241void popup_help(void);
242
a99c4e9a
RK
243/* RTP */
244
245int rtp_running(void);
246void start_rtp(void);
247void stop_rtp(void);
248
f486ea18 249/* Settings */
d4ef4132 250
33288048
RK
251void init_styles(void);
252extern GtkStyle *layout_style;
253extern GtkStyle *title_style;
254extern GtkStyle *even_style;
255extern GtkStyle *odd_style;
256extern GtkStyle *active_style;
257extern GtkStyle *tool_style;
258extern GtkStyle *search_style;
259extern GtkStyle *drag_style;
d4ef4132 260
f486ea18
RK
261extern const char *browser;
262
263void save_settings(void);
264void load_settings(void);
d4ef4132 265void set_tool_colors(GtkWidget *w);
46fb1b05 266void popup_settings(void);
d4ef4132 267
e9b70a84 268/* Widget leakage debugging rubbish ---------------------------------------- */
269
270#if MDEBUG
271#define NW(what) do { \
272 if(++current##what % 100 > max##what) { \
273 fprintf(stderr, "%s:%d: %d %s\n", \
274 __FILE__, __LINE__, current##what, #what); \
275 max##what = current##what; \
276 } \
277} while(0)
278#define WT(what) static int current##what, max##what
279#define DW(what) (--current##what)
280#else
1a48886f
RK
281#define NW(what) do { } while(0)
282#define DW(what) do { } while(0)
e9b70a84 283#define WT(what) struct neverused
284#endif
285
e1d4a32b 286#if MTRACK
287extern const char *mtag;
288#define MTAG(x) do { mtag = x; } while(0)
289#define MTAG_PUSH(x) do { const char *save_mtag = mtag; mtag = x; (void)0
290#define MTAG_POP() mtag = save_mtag; } while(0)
291#else
292#define MTAG(x) do { } while(0)
293#define MTAG_PUSH(x) do {} while(0)
294#define MTAG_POP() do {} while(0)
295#endif
296
460b9539 297#endif /* DISOBEDIENCE_H */
298
299/*
300Local Variables:
301c-basic-offset:2
302comment-column:40
303fill-column:79
304indent-tabs-mode:nil
305End:
306*/