| 1 | /* |
| 2 | * This file is part of DisOrder. |
| 3 | * Copyright (C) 2006 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 | |
| 21 | #ifndef DISOBEDIENCE_H |
| 22 | #define DISOBEDIENCE_H |
| 23 | |
| 24 | #include <config.h> |
| 25 | #include "types.h" |
| 26 | |
| 27 | #include <stdio.h> |
| 28 | #include <time.h> |
| 29 | #include <string.h> |
| 30 | #include <assert.h> |
| 31 | #include <ctype.h> |
| 32 | #include <errno.h> |
| 33 | #include <math.h> |
| 34 | |
| 35 | #include "mem.h" |
| 36 | #include "log.h" |
| 37 | #include "eclient.h" |
| 38 | #include "printf.h" |
| 39 | #include "cache.h" |
| 40 | #include "queue.h" |
| 41 | #include "printf.h" |
| 42 | #include "vector.h" |
| 43 | #include "trackname.h" |
| 44 | #include "syscalls.h" |
| 45 | #include "defs.h" |
| 46 | #include "configuration.h" |
| 47 | #include "hash.h" |
| 48 | #include "selection.h" |
| 49 | |
| 50 | #include <glib.h> |
| 51 | #include <gtk/gtk.h> |
| 52 | #include <gdk-pixbuf/gdk-pixbuf.h> |
| 53 | |
| 54 | /* Types ------------------------------------------------------------------- */ |
| 55 | |
| 56 | struct queuelike; |
| 57 | struct choosenode; |
| 58 | |
| 59 | struct callbackdata { |
| 60 | void (*onerror)(struct callbackdata *cbd, |
| 61 | int code, |
| 62 | const char *msg); /* called on error */ |
| 63 | union { |
| 64 | const char *key; /* gtkqueue.c op_part_lookup */ |
| 65 | struct choosenode *choosenode; /* gtkchoose.c got_files/got_dirs */ |
| 66 | struct queuelike *ql; /* gtkqueue.c queuelike_completed */ |
| 67 | struct prefdata *f; /* properties.c */ |
| 68 | } u; |
| 69 | }; |
| 70 | |
| 71 | struct tabtype { |
| 72 | int (*properties_sensitive)(GtkWidget *tab); |
| 73 | int (*selectall_sensitive)(GtkWidget *tab); |
| 74 | void (*properties_activate)(GtkWidget *tab); |
| 75 | void (*selectall_activate)(GtkWidget *tab); |
| 76 | }; |
| 77 | |
| 78 | /* Variables --------------------------------------------------------------- */ |
| 79 | |
| 80 | extern GMainLoop *mainloop; |
| 81 | extern GtkWidget *toplevel; /* top level window */ |
| 82 | extern GtkWidget *report_label; /* label for progress indicator */ |
| 83 | extern GtkWidget *tabs; /* main tabs */ |
| 84 | extern disorder_eclient *client; /* main client */ |
| 85 | |
| 86 | extern unsigned long last_state; /* last reported state */ |
| 87 | extern int playing; /* true if playing some track */ |
| 88 | extern int volume_l, volume_r; /* current volume */ |
| 89 | extern double goesupto; /* volume upper bound */ |
| 90 | extern int choosealpha; /* break up choose by letter */ |
| 91 | |
| 92 | /* Functions --------------------------------------------------------------- */ |
| 93 | |
| 94 | disorder_eclient *gtkclient(void); |
| 95 | /* Configure C for use in GTK+ programs */ |
| 96 | |
| 97 | void popup_protocol_error(int code, |
| 98 | const char *msg); |
| 99 | /* Report an error */ |
| 100 | |
| 101 | void properties(int ntracks, char **tracks); |
| 102 | /* Pop up a properties window for a list of tracks */ |
| 103 | |
| 104 | GtkWidget *scroll_widget(GtkWidget *child, const char *name); |
| 105 | /* Wrap a widget up for scrolling */ |
| 106 | |
| 107 | GdkPixbuf *find_image(const char *name); |
| 108 | /* Get the pixbuf for an image. Returns a null pointer if it cannot be |
| 109 | * found. */ |
| 110 | |
| 111 | void popup_error(const char *msg); |
| 112 | /* Pop up an error message */ |
| 113 | |
| 114 | |
| 115 | /* Main menu */ |
| 116 | |
| 117 | GtkWidget *menubar(GtkWidget *w); |
| 118 | /* Create the menu bar */ |
| 119 | |
| 120 | void menu_update(int page); |
| 121 | /* Called whenever the main menu might need to change. PAGE is the current |
| 122 | * page if known or -1 otherwise. */ |
| 123 | |
| 124 | |
| 125 | /* Controls */ |
| 126 | |
| 127 | GtkWidget *control_widget(void); |
| 128 | /* Make the controls widget */ |
| 129 | |
| 130 | void control_update(void); |
| 131 | /* Called whenever we think the control widget needs changing */ |
| 132 | |
| 133 | |
| 134 | /* Queue/Recent */ |
| 135 | |
| 136 | GtkWidget *queue_widget(void); |
| 137 | GtkWidget *recent_widget(void); |
| 138 | /* Create widgets for displaying the queue and the recently played list */ |
| 139 | |
| 140 | void queue_update(void); |
| 141 | void recent_update(void); |
| 142 | /* Called whenever we think the queue or recent list might have chanegd */ |
| 143 | |
| 144 | void queue_select_all(struct queuelike *ql); |
| 145 | /* Select all on some queue */ |
| 146 | |
| 147 | void queue_properties(struct queuelike *ql); |
| 148 | /* Pop up properties of selected items in some queue */ |
| 149 | |
| 150 | void playing_update(void); |
| 151 | /* Called whenever we think the currently playing track might have changed */ |
| 152 | |
| 153 | int queued(const char *track); |
| 154 | /* Return nonzero iff TRACK is queued or playing */ |
| 155 | |
| 156 | void namepart_update(const char *track, |
| 157 | const char *context, |
| 158 | const char *part); |
| 159 | /* Called when a namepart might have changed */ |
| 160 | |
| 161 | |
| 162 | /* Choose */ |
| 163 | |
| 164 | GtkWidget *choose_widget(void); |
| 165 | /* Create a widget for choosing tracks */ |
| 166 | |
| 167 | void choose_update(void); |
| 168 | /* Called when we think the choose tree might need updating */ |
| 169 | |
| 170 | /* Widget leakage debugging rubbish ---------------------------------------- */ |
| 171 | |
| 172 | #if MDEBUG |
| 173 | #define NW(what) do { \ |
| 174 | if(++current##what % 100 > max##what) { \ |
| 175 | fprintf(stderr, "%s:%d: %d %s\n", \ |
| 176 | __FILE__, __LINE__, current##what, #what); \ |
| 177 | max##what = current##what; \ |
| 178 | } \ |
| 179 | } while(0) |
| 180 | #define WT(what) static int current##what, max##what |
| 181 | #define DW(what) (--current##what) |
| 182 | #else |
| 183 | #define NW(what) do { } while(0) |
| 184 | #define DW(what) do { } while(0) |
| 185 | #define WT(what) struct neverused |
| 186 | #endif |
| 187 | |
| 188 | #if MTRACK |
| 189 | extern const char *mtag; |
| 190 | #define MTAG(x) do { mtag = x; } while(0) |
| 191 | #define MTAG_PUSH(x) do { const char *save_mtag = mtag; mtag = x; (void)0 |
| 192 | #define MTAG_POP() mtag = save_mtag; } while(0) |
| 193 | #else |
| 194 | #define MTAG(x) do { } while(0) |
| 195 | #define MTAG_PUSH(x) do {} while(0) |
| 196 | #define MTAG_POP() do {} while(0) |
| 197 | #endif |
| 198 | |
| 199 | #endif /* DISOBEDIENCE_H */ |
| 200 | |
| 201 | /* |
| 202 | Local Variables: |
| 203 | c-basic-offset:2 |
| 204 | comment-column:40 |
| 205 | fill-column:79 |
| 206 | indent-tabs-mode:nil |
| 207 | End: |
| 208 | */ |