chiark / gitweb /
DisOrder 4.1
[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"
9eeb9f12 51#include "timeval.h"
460b9539 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;
c3df9503 61struct progress_window;
460b9539 62
2c348789
RK
63/** @brief Callback data structure
64 *
65 * This program is extremely heavily callback-driven. Rather than have
66 * numerous different callback structures we have a single one which can be
67 * interpreted adequately both by success and error handlers.
68 */
460b9539 69struct callbackdata {
70 void (*onerror)(struct callbackdata *cbd,
71 int code,
72 const char *msg); /* called on error */
73 union {
74 const char *key; /* gtkqueue.c op_part_lookup */
75 struct choosenode *choosenode; /* gtkchoose.c got_files/got_dirs */
76 struct queuelike *ql; /* gtkqueue.c queuelike_completed */
77 struct prefdata *f; /* properties.c */
4aa8a0a4 78 const char *user; /* users.c */
0d719587
RK
79 struct {
80 const char *user, *email; /* users.c */
81 } edituser;
460b9539 82 } u;
83};
84
2c348789
RK
85/** @brief Per-tab callbacks
86 *
87 * Some of the options in the main menu depend on which tab is displayed, so we
88 * have some callbacks to set them appropriately.
89 */
460b9539 90struct tabtype {
ee7552f8
RK
91 int (*properties_sensitive)(void *extra);
92 int (*selectall_sensitive)(void *extra);
93 int (*selectnone_sensitive)(void *extra);
6982880f
RK
94 void (*properties_activate)(GtkMenuItem *menuitem,
95 gpointer user_data);
96 void (*selectall_activate)(GtkMenuItem *menuitem,
97 gpointer user_data);
98 void (*selectnone_activate)(GtkMenuItem *menuitem,
99 gpointer user_data);
2a3fe554 100 void (*selected)(void);
ee7552f8 101 void *extra;
460b9539 102};
103
73f1b9f3
RK
104/** @brief Button definitions */
105struct button {
106 const gchar *stock;
107 void (*clicked)(GtkButton *button, gpointer userdata);
108 const char *tip;
f44417cf 109 GtkWidget *widget;
73f1b9f3
RK
110};
111
460b9539 112/* Variables --------------------------------------------------------------- */
113
114extern GMainLoop *mainloop;
115extern GtkWidget *toplevel; /* top level window */
116extern GtkWidget *report_label; /* label for progress indicator */
117extern GtkWidget *tabs; /* main tabs */
118extern disorder_eclient *client; /* main client */
119
120extern unsigned long last_state; /* last reported state */
6f09d54d 121extern rights_type last_rights; /* last reported rights bitmap */
460b9539 122extern int playing; /* true if playing some track */
123extern int volume_l, volume_r; /* current volume */
124extern double goesupto; /* volume upper bound */
125extern int choosealpha; /* break up choose by letter */
348ef780 126extern GtkTooltips *tips;
a99c4e9a
RK
127extern int rtp_supported;
128extern int rtp_is_running;
ac6bf2ba 129extern GtkItemFactory *mainmenufactory;
460b9539 130
10e226b3
RK
131extern const disorder_eclient_log_callbacks log_callbacks;
132
460b9539 133/* Functions --------------------------------------------------------------- */
134
135disorder_eclient *gtkclient(void);
136/* Configure C for use in GTK+ programs */
137
138void popup_protocol_error(int code,
139 const char *msg);
140/* Report an error */
141
16e145a5 142void properties(int ntracks, const char **tracks);
460b9539 143/* Pop up a properties window for a list of tracks */
144
d4ef4132 145GtkWidget *scroll_widget(GtkWidget *child);
460b9539 146/* Wrap a widget up for scrolling */
147
e18c4734
RK
148GtkWidget *frame_widget(GtkWidget *w, const char *title);
149
460b9539 150GdkPixbuf *find_image(const char *name);
151/* Get the pixbuf for an image. Returns a null pointer if it cannot be
152 * found. */
153
043d60b1 154void popup_msg(GtkMessageType mt, const char *msg);
34239ce4 155void popup_submsg(GtkWidget *parent, GtkMessageType mt, const char *msg);
460b9539 156
043d60b1 157void fpopup_msg(GtkMessageType mt, const char *fmt, ...);
73f1b9f3 158
c3df9503
RK
159struct progress_window *progress_window_new(const char *title);
160/* Pop up a progress window */
161
162void progress_window_progress(struct progress_window *pw,
163 int progress,
164 int limit);
165/* Report current progress */
166
fcc8b9f7
RK
167GtkWidget *iconbutton(const char *path, const char *tip);
168
f44417cf 169GtkWidget *create_buttons(struct button *buttons,
73f1b9f3 170 size_t nbuttons);
f44417cf 171GtkWidget *create_buttons_box(struct button *buttons,
ffc4dbaf
RK
172 size_t nbuttons,
173 GtkWidget *box);
73f1b9f3 174
7c30fc75 175void logged_in(void);
73f1b9f3 176
10e226b3
RK
177void all_update(void);
178/* Update everything */
460b9539 179
180/* Main menu */
181
182GtkWidget *menubar(GtkWidget *w);
183/* Create the menu bar */
460b9539 184
c73bd6c1 185void users_set_sensitive(int sensitive);
460b9539 186
187/* Controls */
188
189GtkWidget *control_widget(void);
190/* Make the controls widget */
191
fb44b59e
RK
192extern int suppress_actions;
193
4eb1f430 194/* Queue/Recent/Added */
460b9539 195
196GtkWidget *queue_widget(void);
197GtkWidget *recent_widget(void);
4eb1f430
RK
198GtkWidget *added_widget(void);
199/* Create widgets for displaying the queue, the recently played list and the
200 * newly added tracks list */
460b9539 201
460b9539 202void queue_select_all(struct queuelike *ql);
fb009628
RK
203void queue_select_none(struct queuelike *ql);
204/* Select all/none on some queue */
460b9539 205
206void queue_properties(struct queuelike *ql);
207/* Pop up properties of selected items in some queue */
208
460b9539 209int queued(const char *track);
210/* Return nonzero iff TRACK is queued or playing */
211
ad47bd4c
RK
212extern struct queue_entry *playing_track;
213
214/* Lookups */
215const char *namepart(const char *track,
216 const char *context,
217 const char *part);
218long namepart_length(const char *track);
68110302 219char *namepart_resolve(const char *track);
ad47bd4c 220
460b9539 221void namepart_update(const char *track,
222 const char *context,
223 const char *part);
224/* Called when a namepart might have changed */
225
460b9539 226/* Choose */
227
228GtkWidget *choose_widget(void);
229/* Create a widget for choosing tracks */
230
231void choose_update(void);
232/* Called when we think the choose tree might need updating */
233
53fa91bb 234void play_completed(void *v,
e2717131 235 const char *err);
53fa91bb 236
a99c4e9a
RK
237/* Login details */
238
73f1b9f3
RK
239void login_box(void);
240
e9e8a16d
RK
241GtkWidget *login_window;
242
ffc4dbaf
RK
243/* User management */
244
245void manage_users(void);
246
13affe66
RK
247/* Help */
248
249void popup_help(void);
250
a99c4e9a
RK
251/* RTP */
252
253int rtp_running(void);
254void start_rtp(void);
255void stop_rtp(void);
256
f486ea18 257/* Settings */
d4ef4132 258
33288048
RK
259void init_styles(void);
260extern GtkStyle *layout_style;
261extern GtkStyle *title_style;
262extern GtkStyle *even_style;
263extern GtkStyle *odd_style;
264extern GtkStyle *active_style;
265extern GtkStyle *tool_style;
266extern GtkStyle *search_style;
267extern GtkStyle *drag_style;
d4ef4132 268
f486ea18
RK
269extern const char *browser;
270
271void save_settings(void);
272void load_settings(void);
d4ef4132 273void set_tool_colors(GtkWidget *w);
46fb1b05 274void popup_settings(void);
d4ef4132 275
460b9539 276#endif /* DISOBEDIENCE_H */
277
278/*
279Local Variables:
280c-basic-offset:2
281comment-column:40
282fill-column:79
283indent-tabs-mode:nil
284End:
285*/