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