2 * This file is part of DisOrder.
3 * Copyright (C) 2006, 2007 Richard Kettlewell
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.
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.
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
20 /** @file disobedience/disobedience.h
21 * @brief Header file for Disobedience, the DisOrder GTK+ client
24 #ifndef DISOBEDIENCE_H
25 #define DISOBEDIENCE_H
46 #include "trackname.h"
49 #include "configuration.h"
51 #include "selection.h"
55 #include <gdk-pixbuf/gdk-pixbuf.h>
57 /* Types ------------------------------------------------------------------- */
62 /** @brief Callback data structure
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.
69 void (*onerror)(struct callbackdata *cbd,
71 const char *msg); /* called on error */
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 */
80 /** @brief Per-tab callbacks
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.
86 int (*properties_sensitive)(GtkWidget *tab);
87 int (*selectall_sensitive)(GtkWidget *tab);
88 void (*properties_activate)(GtkWidget *tab);
89 void (*selectall_activate)(GtkWidget *tab);
92 /* Variables --------------------------------------------------------------- */
94 extern GMainLoop *mainloop;
95 extern GtkWidget *toplevel; /* top level window */
96 extern GtkWidget *report_label; /* label for progress indicator */
97 extern GtkWidget *tabs; /* main tabs */
98 extern disorder_eclient *client; /* main client */
100 extern unsigned long last_state; /* last reported state */
101 extern int playing; /* true if playing some track */
102 extern int volume_l, volume_r; /* current volume */
103 extern double goesupto; /* volume upper bound */
104 extern int choosealpha; /* break up choose by letter */
105 extern GtkTooltips *tips;
107 extern const disorder_eclient_log_callbacks log_callbacks;
109 typedef void monitor_callback(void *u);
111 /* Functions --------------------------------------------------------------- */
113 disorder_eclient *gtkclient(void);
114 /* Configure C for use in GTK+ programs */
116 void popup_protocol_error(int code,
118 /* Report an error */
120 void properties(int ntracks, const char **tracks);
121 /* Pop up a properties window for a list of tracks */
123 GtkWidget *scroll_widget(GtkWidget *child, const char *name);
124 /* Wrap a widget up for scrolling */
126 GdkPixbuf *find_image(const char *name);
127 /* Get the pixbuf for an image. Returns a null pointer if it cannot be
130 void popup_error(const char *msg);
131 /* Pop up an error message */
133 void register_monitor(monitor_callback *callback,
136 /* Register a state monitor */
138 void all_update(void);
139 /* Update everything */
143 GtkWidget *menubar(GtkWidget *w);
144 /* Create the menu bar */
146 void 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. */
153 GtkWidget *control_widget(void);
154 /* Make the controls widget */
156 void volume_update(void);
157 /* Called whenever we think the volume control has changed */
159 /* Queue/Recent/Added */
161 GtkWidget *queue_widget(void);
162 GtkWidget *recent_widget(void);
163 GtkWidget *added_widget(void);
164 /* Create widgets for displaying the queue, the recently played list and the
165 * newly added tracks list */
167 void queue_update(void);
168 void recent_update(void);
169 void added_update(void);
170 /* Called whenever we think the queue, recent or newly-added list might have
173 void queue_select_all(struct queuelike *ql);
174 /* Select all on some queue */
176 void queue_properties(struct queuelike *ql);
177 /* Pop up properties of selected items in some queue */
179 int queued(const char *track);
180 /* Return nonzero iff TRACK is queued or playing */
182 void namepart_update(const char *track,
185 /* Called when a namepart might have changed */
190 GtkWidget *choose_widget(void);
191 /* Create a widget for choosing tracks */
193 void choose_update(void);
194 /* Called when we think the choose tree might need updating */
196 /* Widget leakage debugging rubbish ---------------------------------------- */
199 #define NW(what) do { \
200 if(++current##what % 100 > max##what) { \
201 fprintf(stderr, "%s:%d: %d %s\n", \
202 __FILE__, __LINE__, current##what, #what); \
203 max##what = current##what; \
206 #define WT(what) static int current##what, max##what
207 #define DW(what) (--current##what)
209 #define NW(what) do { } while(0)
210 #define DW(what) do { } while(0)
211 #define WT(what) struct neverused
215 extern const char *mtag;
216 #define MTAG(x) do { mtag = x; } while(0)
217 #define MTAG_PUSH(x) do { const char *save_mtag = mtag; mtag = x; (void)0
218 #define MTAG_POP() mtag = save_mtag; } while(0)
220 #define MTAG(x) do { } while(0)
221 #define MTAG_PUSH(x) do {} while(0)
222 #define MTAG_POP() do {} while(0)
225 #endif /* DISOBEDIENCE_H */