chiark / gitweb /
Leave a comment about iffy icon sensivity; it's definitely setting the
[disorder] / disobedience / disobedience.h
... / ...
CommitLineData
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/** @file disobedience/disobedience.h
21 * @brief Header file for Disobedience, the DisOrder GTK+ client
22 */
23
24#ifndef DISOBEDIENCE_H
25#define DISOBEDIENCE_H
26
27#include "common.h"
28
29#include <time.h>
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"
48#include "kvp.h"
49#include "eventdist.h"
50#include "split.h"
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;
60struct progress_window;
61
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 */
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 const char *user; /* users.c */
78 struct {
79 const char *user, *email; /* users.c */
80 } edituser;
81 } u;
82};
83
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 */
89struct tabtype {
90 int (*properties_sensitive)(void *extra);
91 int (*selectall_sensitive)(void *extra);
92 int (*selectnone_sensitive)(void *extra);
93 void (*properties_activate)(void *extra);
94 void (*selectall_activate)(void *extra);
95 void (*selectnone_activate)(void *extra);
96 void (*selected)(void);
97 void *extra;
98};
99
100/** @brief Button definitions */
101struct button {
102 const gchar *stock;
103 void (*clicked)(GtkButton *button, gpointer userdata);
104 const char *tip;
105 GtkWidget *widget;
106};
107
108/* Variables --------------------------------------------------------------- */
109
110extern GMainLoop *mainloop;
111extern GtkWidget *toplevel; /* top level window */
112extern GtkWidget *report_label; /* label for progress indicator */
113extern GtkWidget *tabs; /* main tabs */
114extern disorder_eclient *client; /* main client */
115
116extern unsigned long last_state; /* last reported state */
117extern rights_type last_rights; /* last reported rights bitmap */
118extern int playing; /* true if playing some track */
119extern int volume_l, volume_r; /* current volume */
120extern double goesupto; /* volume upper bound */
121extern int choosealpha; /* break up choose by letter */
122extern GtkTooltips *tips;
123extern int rtp_supported;
124extern int rtp_is_running;
125extern GtkItemFactory *mainmenufactory;
126
127extern const disorder_eclient_log_callbacks log_callbacks;
128
129/* Functions --------------------------------------------------------------- */
130
131disorder_eclient *gtkclient(void);
132/* Configure C for use in GTK+ programs */
133
134void popup_protocol_error(int code,
135 const char *msg);
136/* Report an error */
137
138void properties(int ntracks, const char **tracks);
139/* Pop up a properties window for a list of tracks */
140
141GtkWidget *scroll_widget(GtkWidget *child);
142/* Wrap a widget up for scrolling */
143
144GtkWidget *frame_widget(GtkWidget *w, const char *title);
145
146GdkPixbuf *find_image(const char *name);
147/* Get the pixbuf for an image. Returns a null pointer if it cannot be
148 * found. */
149
150void popup_msg(GtkMessageType mt, const char *msg);
151void popup_submsg(GtkWidget *parent, GtkMessageType mt, const char *msg);
152
153void fpopup_msg(GtkMessageType mt, const char *fmt, ...);
154
155struct progress_window *progress_window_new(const char *title);
156/* Pop up a progress window */
157
158void progress_window_progress(struct progress_window *pw,
159 int progress,
160 int limit);
161/* Report current progress */
162
163GtkWidget *iconbutton(const char *path, const char *tip);
164
165GtkWidget *create_buttons(struct button *buttons,
166 size_t nbuttons);
167GtkWidget *create_buttons_box(struct button *buttons,
168 size_t nbuttons,
169 GtkWidget *box);
170
171void logged_in(void);
172
173void all_update(void);
174/* Update everything */
175
176/* Main menu */
177
178GtkWidget *menubar(GtkWidget *w);
179/* Create the menu bar */
180
181void menu_update(int page);
182/* Called whenever the main menu might need to change. PAGE is the current
183 * page if known or -1 otherwise. */
184
185void users_set_sensitive(int sensitive);
186
187/* Controls */
188
189GtkWidget *control_widget(void);
190/* Make the controls widget */
191
192extern int suppress_actions;
193
194/* Queue/Recent/Added */
195
196GtkWidget *queue_widget(void);
197GtkWidget *recent_widget(void);
198GtkWidget *added_widget(void);
199/* Create widgets for displaying the queue, the recently played list and the
200 * newly added tracks list */
201
202void queue_select_all(struct queuelike *ql);
203void queue_select_none(struct queuelike *ql);
204/* Select all/none on some queue */
205
206void queue_properties(struct queuelike *ql);
207/* Pop up properties of selected items in some queue */
208
209int queued(const char *track);
210/* Return nonzero iff TRACK is queued or playing */
211
212void namepart_update(const char *track,
213 const char *context,
214 const char *part);
215/* Called when a namepart might have changed */
216
217extern struct queue_entry *playing_track;
218
219/* Choose */
220
221GtkWidget *choose_widget(void);
222/* Create a widget for choosing tracks */
223
224void choose_update(void);
225/* Called when we think the choose tree might need updating */
226
227void play_completed(void *v,
228 const char *error);
229
230/* Login details */
231
232void login_box(void);
233
234GtkWidget *login_window;
235
236/* User management */
237
238void manage_users(void);
239
240/* Help */
241
242void popup_help(void);
243
244/* RTP */
245
246int rtp_running(void);
247void start_rtp(void);
248void stop_rtp(void);
249
250/* Settings */
251
252void init_styles(void);
253extern GtkStyle *layout_style;
254extern GtkStyle *title_style;
255extern GtkStyle *even_style;
256extern GtkStyle *odd_style;
257extern GtkStyle *active_style;
258extern GtkStyle *tool_style;
259extern GtkStyle *search_style;
260extern GtkStyle *drag_style;
261
262extern const char *browser;
263
264void save_settings(void);
265void load_settings(void);
266void set_tool_colors(GtkWidget *w);
267void popup_settings(void);
268
269/* Widget leakage debugging rubbish ---------------------------------------- */
270
271#if MDEBUG
272#define NW(what) do { \
273 if(++current##what % 100 > max##what) { \
274 fprintf(stderr, "%s:%d: %d %s\n", \
275 __FILE__, __LINE__, current##what, #what); \
276 max##what = current##what; \
277 } \
278} while(0)
279#define WT(what) static int current##what, max##what
280#define DW(what) (--current##what)
281#else
282#define NW(what) do { } while(0)
283#define DW(what) do { } while(0)
284#define WT(what) struct neverused
285#endif
286
287#if MTRACK
288extern const char *mtag;
289#define MTAG(x) do { mtag = x; } while(0)
290#define MTAG_PUSH(x) do { const char *save_mtag = mtag; mtag = x; (void)0
291#define MTAG_POP() mtag = save_mtag; } while(0)
292#else
293#define MTAG(x) do { } while(0)
294#define MTAG_PUSH(x) do {} while(0)
295#define MTAG_POP() do {} while(0)
296#endif
297
298#endif /* DISOBEDIENCE_H */
299
300/*
301Local Variables:
302c-basic-offset:2
303comment-column:40
304fill-column:79
305indent-tabs-mode:nil
306End:
307*/