chiark / gitweb /
Make the properties window's progress window a transient of the right
[disorder] / disobedience / disobedience.h
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 3 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,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU 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, see <http://www.gnu.org/licenses/>.
17  */
18 /** @file disobedience/disobedience.h
19  * @brief Header file for Disobedience, the DisOrder GTK+ client
20  */
21
22 #ifndef DISOBEDIENCE_H
23 #define DISOBEDIENCE_H
24
25 #define PLAYLISTS 1
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 #include "timeval.h"
52 #include "uaudio.h"
53
54 #include <glib.h>
55 #include <gtk/gtk.h>
56 #include <gdk-pixbuf/gdk-pixbuf.h>
57 #include <gdk/gdkkeysyms.h>
58
59 /* Types ------------------------------------------------------------------- */
60
61 struct queuelike;
62 struct choosenode;
63 struct progress_window;
64
65 /** @brief Per-tab callbacks
66  *
67  * Some of the options in the main menu depend on which tab is displayed, so we
68  * have some callbacks to set them appropriately.
69  */
70 struct tabtype {
71   int (*properties_sensitive)(void *extra);
72   int (*selectall_sensitive)(void *extra);
73   int (*selectnone_sensitive)(void *extra);
74   void (*properties_activate)(GtkMenuItem *menuitem,
75                               gpointer user_data);
76   void (*selectall_activate)(GtkMenuItem *menuitem,
77                              gpointer user_data);
78   void (*selectnone_activate)(GtkMenuItem *menuitem,
79                               gpointer user_data);
80   void (*selected)(void);
81   void *extra;
82 };
83
84 /** @brief Button definitions */
85 struct button {
86   const gchar *stock;
87   void (*clicked)(GtkButton *button, gpointer userdata);
88   const char *tip;
89   GtkWidget *widget;
90 };
91
92 /* Variables --------------------------------------------------------------- */
93
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 */
99
100 extern unsigned long last_state;        /* last reported state */
101 extern rights_type last_rights;         /* last reported rights bitmap */
102 extern int playing;                     /* true if playing some track */
103 extern int volume_l, volume_r;          /* current volume */
104 extern double goesupto;                 /* volume upper bound */
105 extern int choosealpha;                 /* break up choose by letter */
106 extern int rtp_supported;
107 extern int rtp_is_running;
108 extern GtkItemFactory *mainmenufactory;
109 extern const struct uaudio *backend;
110
111 extern const disorder_eclient_log_callbacks log_callbacks;
112
113 /* Functions --------------------------------------------------------------- */
114
115 disorder_eclient *gtkclient(void);
116 /* Configure C for use in GTK+ programs */
117
118 void popup_protocol_error(int code,
119                           const char *msg);
120 /* Report an error */
121
122 void properties(int ntracks, const char **tracks,
123                 GtkWidget *parent);
124 /* Pop up a properties window for a list of tracks */
125
126 GtkWidget *scroll_widget(GtkWidget *child);
127 /* Wrap a widget up for scrolling */
128
129 GtkWidget *frame_widget(GtkWidget *w, const char *title);
130
131 GdkPixbuf *find_image(const char *name);
132 /* Get the pixbuf for an image.  Returns a null pointer if it cannot be
133  * found. */
134
135 void popup_msg(GtkMessageType mt, const char *msg);
136 void popup_submsg(GtkWidget *parent, GtkMessageType mt, const char *msg);
137
138 void fpopup_msg(GtkMessageType mt, const char *fmt, ...);
139
140 struct progress_window *progress_window_new(const char *title,
141                                             GtkWidget *parent);
142 /* Pop up a progress window */
143
144 void progress_window_progress(struct progress_window *pw,
145                               int progress,
146                               int limit);
147 /* Report current progress */
148
149 GtkWidget *iconbutton(const char *path, const char *tip);
150
151 GtkWidget *create_buttons(struct button *buttons,
152                           size_t nbuttons);
153 GtkWidget *create_buttons_box(struct button *buttons,
154                               size_t nbuttons,
155                               GtkWidget *box);
156
157 void logged_in(void);
158
159 void all_update(void);
160 /* Update everything */
161
162 /* Main menu */
163
164 GtkWidget *menubar(GtkWidget *w);
165 /* Create the menu bar */
166
167 void users_set_sensitive(int sensitive);
168
169 /* Controls */
170
171 GtkWidget *control_widget(void);
172 /* Make the controls widget */
173
174 extern int suppress_actions;
175
176 /* Queue/Recent/Added */
177
178 GtkWidget *queue_widget(void);
179 GtkWidget *recent_widget(void);
180 GtkWidget *added_widget(void);
181 /* Create widgets for displaying the queue, the recently played list and the
182  * newly added tracks list */
183
184 void queue_select_all(struct queuelike *ql);
185 void queue_select_none(struct queuelike *ql);
186 /* Select all/none on some queue */
187
188 void queue_properties(struct queuelike *ql);
189 /* Pop up properties of selected items in some queue */
190
191 int queued(const char *track);
192 /* Return nonzero iff TRACK is queued or playing */
193
194 extern struct queue_entry *playing_track;
195
196 /* Lookups */
197 const char *namepart(const char *track,
198                      const char *context,
199                      const char *part);
200 long namepart_length(const char *track);
201 char *namepart_resolve(const char *track);
202
203 void namepart_update(const char *track,
204                      const char *context,
205                      const char *part);
206 /* Called when a namepart might have changed */
207
208 /* Choose */
209
210 GtkWidget *choose_widget(void);
211 /* Create a widget for choosing tracks */
212
213 void choose_update(void);
214 /* Called when we think the choose tree might need updating */
215
216 void play_completed(void *v,
217                     const char *err);
218
219 extern const GtkTargetEntry choose_targets[];
220
221 /* Login details */
222
223 void login_box(void);
224
225 GtkWidget *login_window;
226
227 /* User management */
228
229 void manage_users(void);
230
231 /* Help */
232
233 void popup_help(void);
234
235 /* RTP */
236
237 int rtp_running(void);
238 void start_rtp(void);
239 void stop_rtp(void);
240
241 /* Settings */
242
243 void init_styles(void);
244 extern GtkStyle *layout_style;
245 extern GtkStyle *title_style;
246 extern GtkStyle *even_style;
247 extern GtkStyle *odd_style;
248 extern GtkStyle *active_style;
249 extern GtkStyle *tool_style;
250 extern GtkStyle *search_style;
251 extern GtkStyle *drag_style;
252
253 extern const char *browser;
254
255 void save_settings(void);
256 void load_settings(void);
257 void set_tool_colors(GtkWidget *w);
258 void popup_settings(void);
259
260 /* Playlists */
261
262 #if PLAYLISTS
263 void playlists_init(void);
264 void playlist_window_create(gpointer callback_data,
265                             guint callback_action,
266                             GtkWidget  *menu_item);
267 extern char **playlists;
268 extern int nplaylists;
269 extern GtkWidget *menu_playlists_widget;
270 extern GtkWidget *playlists_menu;
271 extern GtkWidget *menu_editplaylists_widget;
272 #endif
273
274 #endif /* DISOBEDIENCE_H */
275
276 /*
277 Local Variables:
278 c-basic-offset:2
279 comment-column:40
280 fill-column:79
281 indent-tabs-mode:nil
282 End:
283 */