Mercurial > audlegacy
annotate audacious/mainwin.c @ 1853:1c19a0dca33d trunk
[svn] - resize fixes
| author | nenolod |
|---|---|
| date | Mon, 09 Oct 2006 03:56:32 -0700 |
| parents | aceb472cce6c |
| children | ec2899d8b8af |
| rev | line source |
|---|---|
| 1653 | 1 /* Audacious - Cross-platform multimedia player |
| 2 * Copyright (C) 2005-2006 Audacious development team. | |
| 3 * | |
| 4 * BMP - Cross-platform multimedia player | |
| 5 * Copyright (C) 2003-2004 BMP development team. | |
| 6 * | |
| 7 * Based on XMMS: | |
| 8 * Copyright (C) 1998-2003 XMMS development team. | |
| 9 * | |
| 10 * This program is free software; you can redistribute it and/or modify | |
| 11 * it under the terms of the GNU General Public License as published by | |
| 12 * the Free Software Foundation; either version 2 of the License, or | |
| 13 * (at your option) any later version. | |
| 14 * | |
| 15 * This program is distributed in the hope that it will be useful, | |
| 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 * GNU General Public License for more details. | |
| 19 * | |
| 20 * You should have received a copy of the GNU General Public License | |
| 21 * along with this program; if not, write to the Free Software | |
| 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
| 23 */ | |
| 24 | |
| 25 #ifdef HAVE_CONFIG_H | |
| 26 # include "config.h" | |
| 27 #endif | |
| 28 | |
| 29 | |
| 30 #include <glib.h> | |
| 31 #include <glib/gi18n.h> | |
| 32 #include <glib/gprintf.h> | |
| 33 #include <gtk/gtk.h> | |
| 34 #include <gtk/gtkmessagedialog.h> | |
| 35 | |
| 36 /* GDK including */ | |
| 37 #include "platform/smartinclude.h" | |
| 38 | |
| 39 #include <math.h> | |
| 40 #include <stdlib.h> | |
| 41 #include <string.h> | |
| 42 | |
| 43 #include <X11/Xlib.h> | |
| 44 | |
| 45 #include "widgets/widgetcore.h" | |
| 46 #include "mainwin.h" | |
| 47 #include "pixmaps.h" | |
| 48 | |
| 49 #include "main.h" | |
| 50 | |
| 51 #include "controlsocket.h" | |
| 52 #include "pluginenum.h" | |
| 53 | |
| 54 #include "credits.h" | |
| 55 #include "dnd.h" | |
| 56 #include "dock.h" | |
| 57 #include "equalizer.h" | |
| 58 #include "hints.h" | |
| 59 #include "input.h" | |
| 60 #include "ui_playlist.h" | |
| 61 #include "prefswin.h" | |
| 62 #include "skinwin.h" | |
| 63 #include "genevent.h" | |
| 64 #include "playback.h" | |
| 65 #include "playlist.h" | |
| 66 #include "urldecode.h" | |
| 67 #include "util.h" | |
| 68 #include "visualization.h" | |
| 69 #include "libaudacious/configdb.h" | |
| 70 | |
| 71 static GTimeVal cb_time; /* click delay for tristate is defined by TRISTATE_THRESHOLD */ | |
| 72 | |
| 73 #define ITEM_SEPARATOR {"/-", NULL, NULL, 0, "<Separator>"} | |
| 74 #define TRISTATE_THRESHOLD 200 | |
| 75 | |
| 76 /* | |
| 77 * If you change the menu above change these defines also | |
| 78 */ | |
| 79 | |
| 80 #define MAINWIN_VIS_MENU_VIS_MODE 1 | |
| 81 #define MAINWIN_VIS_MENU_NUM_VIS_MODE 3 | |
| 82 #define MAINWIN_VIS_MENU_ANALYZER_MODE 5 | |
| 83 #define MAINWIN_VIS_MENU_NUM_ANALYZER_MODE 3 | |
| 84 #define MAINWIN_VIS_MENU_ANALYZER_TYPE 9 | |
| 85 #define MAINWIN_VIS_MENU_NUM_ANALYZER_TYPE 2 | |
| 86 #define MAINWIN_VIS_MENU_ANALYZER_PEAKS 12 | |
| 87 #define MAINWIN_VIS_MENU_SCOPE_MODE 14 | |
| 88 #define MAINWIN_VIS_MENU_NUM_SCOPE_MODE 3 | |
| 89 #define MAINWIN_VIS_MENU_WSHADEVU_MODE 18 | |
| 90 #define MAINWIN_VIS_MENU_NUM_WSHADEVU_MODE 2 | |
| 91 #define MAINWIN_VIS_MENU_REFRESH_RATE 21 | |
| 92 #define MAINWIN_VIS_MENU_NUM_REFRESH_RATE 4 | |
| 93 #define MAINWIN_VIS_MENU_AFALLOFF 26 | |
| 94 #define MAINWIN_VIS_MENU_NUM_AFALLOFF 5 | |
| 95 #define MAINWIN_VIS_MENU_PFALLOFF 32 | |
| 96 #define MAINWIN_VIS_MENU_NUM_PFALLOFF 5 | |
| 97 | |
| 98 #define VOLSET_DISP_TIMES 5 | |
| 99 | |
| 100 enum { | |
| 101 MAINWIN_SEEK_REV = -1, | |
| 102 MAINWIN_SEEK_NIL, | |
| 103 MAINWIN_SEEK_FWD | |
| 104 }; | |
| 105 | |
| 106 enum { | |
| 107 MAINWIN_SONGNAME_FILEINFO, | |
| 108 MAINWIN_SONGNAME_JTF, | |
| 109 MAINWIN_SONGNAME_JTT, | |
| 110 MAINWIN_SONGNAME_SCROLL, | |
| 111 MAINWIN_SONGNAME_STOPAFTERSONG | |
| 112 }; | |
| 113 | |
| 114 enum { | |
| 115 MAINWIN_OPT_SKIN, MAINWIN_OPT_RELOADSKIN, | |
| 116 MAINWIN_OPT_REPEAT, MAINWIN_OPT_SHUFFLE, MAINWIN_OPT_NPA, | |
| 117 MAINWIN_OPT_TELAPSED, MAINWIN_OPT_TREMAINING, | |
| 118 MAINWIN_OPT_ALWAYS, | |
| 119 MAINWIN_OPT_STICKY, | |
| 120 MAINWIN_OPT_WS, | |
| 121 MAINWIN_OPT_PWS, | |
| 122 MAINWIN_OPT_EQWS | |
| 123 }; | |
| 124 | |
| 125 enum { | |
| 126 MAINWIN_VIS_ANALYZER, MAINWIN_VIS_SCOPE, MAINWIN_VIS_OFF, | |
| 127 MAINWIN_VIS_ANALYZER_NORMAL, MAINWIN_VIS_ANALYZER_FIRE, | |
| 128 MAINWIN_VIS_ANALYZER_VLINES, | |
| 129 MAINWIN_VIS_ANALYZER_LINES, MAINWIN_VIS_ANALYZER_BARS, | |
| 130 MAINWIN_VIS_ANALYZER_PEAKS, | |
| 131 MAINWIN_VIS_SCOPE_DOT, MAINWIN_VIS_SCOPE_LINE, MAINWIN_VIS_SCOPE_SOLID, | |
| 132 MAINWIN_VIS_VU_NORMAL, MAINWIN_VIS_VU_SMOOTH, | |
| 133 MAINWIN_VIS_REFRESH_FULL, MAINWIN_VIS_REFRESH_HALF, | |
| 134 MAINWIN_VIS_REFRESH_QUARTER, MAINWIN_VIS_REFRESH_EIGHTH, | |
| 135 MAINWIN_VIS_AFALLOFF_SLOWEST, MAINWIN_VIS_AFALLOFF_SLOW, | |
| 136 MAINWIN_VIS_AFALLOFF_MEDIUM, MAINWIN_VIS_AFALLOFF_FAST, | |
| 137 MAINWIN_VIS_AFALLOFF_FASTEST, | |
| 138 MAINWIN_VIS_PFALLOFF_SLOWEST, MAINWIN_VIS_PFALLOFF_SLOW, | |
| 139 MAINWIN_VIS_PFALLOFF_MEDIUM, MAINWIN_VIS_PFALLOFF_FAST, | |
| 140 MAINWIN_VIS_PFALLOFF_FASTEST, | |
| 141 MAINWIN_VIS_PLUGINS | |
| 142 }; | |
| 143 | |
| 144 enum { | |
| 145 MAINWIN_VIS_ACTIVE_MAINWIN, MAINWIN_VIS_ACTIVE_PLAYLISTWIN | |
| 146 }; | |
| 147 | |
| 148 | |
| 149 typedef struct _PlaybackInfo PlaybackInfo; | |
| 150 | |
| 151 struct _PlaybackInfo { | |
| 152 gchar *title; | |
| 153 gint bitrate; | |
| 154 gint frequency; | |
| 155 gint n_channels; | |
| 156 }; | |
| 157 | |
| 158 | |
| 159 GtkWidget *mainwin = NULL; | |
| 160 GtkWidget *err = NULL; /* an error dialog for miscellaneous error messages */ | |
| 161 | |
| 162 static GdkBitmap *nullmask; | |
| 163 static gint balance; | |
| 164 | |
| 165 GtkWidget *mainwin_jtf = NULL; | |
| 166 static GtkWidget *mainwin_jtt = NULL; | |
| 167 | |
| 168 GtkItemFactory *mainwin_songname_menu, *mainwin_vis_menu; | |
| 169 GtkItemFactory *mainwin_general_menu, *mainwin_play_menu, *mainwin_add_menu; | |
| 170 GtkItemFactory *mainwin_view_menu; | |
| 171 | |
| 172 gint seek_state = MAINWIN_SEEK_NIL; | |
| 173 gint seek_initial_pos = 0; | |
| 174 | |
| 175 GdkGC *mainwin_gc; | |
| 176 static GdkPixmap *mainwin_bg = NULL; | |
| 177 | |
| 178 GtkAccelGroup *mainwin_accel = NULL; | |
| 179 | |
| 180 static PButton *mainwin_menubtn; | |
| 181 static PButton *mainwin_minimize, *mainwin_shade, *mainwin_close; | |
| 182 | |
| 183 static PButton *mainwin_rew, *mainwin_fwd; | |
| 184 static PButton *mainwin_eject; | |
| 185 static PButton *mainwin_play, *mainwin_pause, *mainwin_stop; | |
| 186 | |
| 187 TButton *mainwin_shuffle, *mainwin_repeat, *mainwin_eq, *mainwin_pl; | |
| 188 TextBox *mainwin_info; | |
| 189 TextBox *mainwin_stime_min, *mainwin_stime_sec; | |
| 190 | |
| 191 static TextBox *mainwin_rate_text, *mainwin_freq_text, | |
| 192 *mainwin_othertext; | |
| 193 | |
| 194 PlayStatus *mainwin_playstatus; | |
| 195 | |
| 196 Number *mainwin_minus_num, *mainwin_10min_num, *mainwin_min_num; | |
| 197 Number *mainwin_10sec_num, *mainwin_sec_num; | |
| 198 | |
| 199 static gboolean setting_volume = FALSE; | |
| 200 | |
| 201 Vis *active_vis; | |
| 202 Vis *mainwin_vis; | |
| 203 SVis *mainwin_svis; | |
| 204 | |
| 205 HSlider *mainwin_sposition = NULL; | |
| 206 | |
| 207 static MenuRow *mainwin_menurow; | |
| 208 static HSlider *mainwin_volume, *mainwin_balance, *mainwin_position; | |
| 209 static MonoStereo *mainwin_monostereo; | |
| 210 static SButton *mainwin_srew, *mainwin_splay, *mainwin_spause; | |
| 211 static SButton *mainwin_sstop, *mainwin_sfwd, *mainwin_seject, *mainwin_about; | |
| 212 | |
| 213 static GList *mainwin_wlist = NULL; | |
| 214 | |
| 215 static gint mainwin_timeout_id; | |
| 216 | |
| 217 G_LOCK_DEFINE_STATIC(mainwin_title); | |
| 218 | |
| 219 static gboolean mainwin_force_redraw = FALSE; | |
| 220 static gchar *mainwin_title_text = NULL; | |
| 221 static gboolean mainwin_info_text_locked = FALSE; | |
| 222 | |
| 223 | |
| 224 static void mainwin_songname_menu_callback(gpointer user_data, | |
| 225 guint action, | |
| 226 GtkWidget * widget); | |
| 227 | |
| 228 static void mainwin_vis_menu_callback(gpointer user_data, | |
| 229 guint action, | |
| 230 GtkWidget * widget); | |
| 231 | |
| 232 static void mainwin_view_menu_callback(gpointer user_data, | |
| 233 guint action, | |
| 234 GtkWidget * widget); | |
| 235 | |
| 236 static void mainwin_play_menu_callback(gpointer user_data, | |
| 237 guint action, | |
| 238 GtkWidget * widget); | |
| 239 | |
| 240 /* Song name area menu */ | |
| 241 | |
| 242 GtkItemFactoryEntry mainwin_songname_menu_entries[] = { | |
| 243 {N_("/View Track Details"), "<alt>i", mainwin_general_menu_callback, | |
| 244 MAINWIN_GENERAL_FILEINFO, "<ImageItem>", my_pixbuf}, | |
| 245 {N_("/Jump to File"), "J", mainwin_songname_menu_callback, | |
| 246 MAINWIN_SONGNAME_JTF, "<StockItem>", GTK_STOCK_JUMP_TO}, | |
| 247 {"/-", NULL, NULL, 0, "<Separator>", NULL}, | |
| 248 {N_("/Autoscroll Songname"), NULL, mainwin_songname_menu_callback, | |
| 249 MAINWIN_SONGNAME_SCROLL, "<ToggleItem>", NULL}, | |
| 250 {N_("/Stop After Current Song"), "<control>M", mainwin_songname_menu_callback, | |
| 251 MAINWIN_SONGNAME_STOPAFTERSONG, "<ToggleItem>", NULL}, | |
| 252 }; | |
| 253 | |
| 254 static gint mainwin_songname_menu_entries_num = | |
| 255 G_N_ELEMENTS(mainwin_songname_menu_entries); | |
| 256 | |
| 257 /* Mini-visualizer area menu */ | |
| 258 | |
| 259 GtkItemFactoryEntry mainwin_vis_menu_entries[] = { | |
| 260 {N_("/Visualization Mode"), NULL, NULL, 0, "<Branch>", NULL}, | |
| 261 {N_("/Visualization Mode/Analyzer"), NULL, mainwin_vis_menu_callback, | |
| 262 MAINWIN_VIS_ANALYZER, "<RadioItem>", NULL}, | |
| 263 {N_("/Visualization Mode/Scope"), NULL, mainwin_vis_menu_callback, | |
| 264 MAINWIN_VIS_SCOPE, "/Visualization Mode/Analyzer", NULL}, | |
| 265 {N_("/Visualization Mode/Off"), NULL, mainwin_vis_menu_callback, | |
| 266 MAINWIN_VIS_OFF, "/Visualization Mode/Analyzer", NULL}, | |
| 267 {N_("/Analyzer Mode"), NULL, NULL, 0, "<Branch>", NULL}, | |
| 268 {N_("/Analyzer Mode/Normal"), NULL, mainwin_vis_menu_callback, | |
| 269 MAINWIN_VIS_ANALYZER_NORMAL, "<RadioItem>", NULL}, | |
| 270 {N_("/Analyzer Mode/Fire"), NULL, mainwin_vis_menu_callback, | |
| 271 MAINWIN_VIS_ANALYZER_FIRE, "/Analyzer Mode/Normal", NULL}, | |
| 272 {N_("/Analyzer Mode/Vertical Lines"), NULL, mainwin_vis_menu_callback, | |
| 273 MAINWIN_VIS_ANALYZER_VLINES, "/Analyzer Mode/Normal", NULL}, | |
| 274 {"/Analyzer Mode/-", NULL, NULL, 0, "<Separator>", NULL}, | |
| 275 {N_("/Analyzer Mode/Lines"), NULL, mainwin_vis_menu_callback, | |
| 276 MAINWIN_VIS_ANALYZER_LINES, "<RadioItem>", NULL}, | |
| 277 {N_("/Analyzer Mode/Bars"), NULL, mainwin_vis_menu_callback, | |
| 278 MAINWIN_VIS_ANALYZER_BARS, "/Analyzer Mode/Lines", NULL}, | |
| 279 {"/Analyzer Mode/-", NULL, NULL, 0, "<Separator>", NULL}, | |
| 280 {N_("/Analyzer Mode/Peaks"), NULL, mainwin_vis_menu_callback, | |
| 281 MAINWIN_VIS_ANALYZER_PEAKS, "<ToggleItem>", NULL}, | |
| 282 {N_("/Scope Mode"), NULL, NULL, 0, "<Branch>", NULL}, | |
| 283 {N_("/Scope Mode/Dot Scope"), NULL, mainwin_vis_menu_callback, | |
| 284 MAINWIN_VIS_SCOPE_DOT, "<RadioItem>", NULL}, | |
| 285 {N_("/Scope Mode/Line Scope"), NULL, mainwin_vis_menu_callback, | |
| 286 MAINWIN_VIS_SCOPE_LINE, "/Scope Mode/Dot Scope", NULL}, | |
| 287 {N_("/Scope Mode/Solid Scope"), NULL, mainwin_vis_menu_callback, | |
| 288 MAINWIN_VIS_SCOPE_SOLID, "/Scope Mode/Dot Scope", NULL}, | |
| 289 {N_("/WindowShade VU Mode"), NULL, NULL, 0, "<Branch>", NULL}, | |
| 290 {N_("/WindowShade VU Mode/Normal"), NULL, mainwin_vis_menu_callback, | |
| 291 MAINWIN_VIS_VU_NORMAL, "<RadioItem>", NULL}, | |
| 292 {N_("/WindowShade VU Mode/Smooth"), NULL, mainwin_vis_menu_callback, | |
| 293 MAINWIN_VIS_VU_SMOOTH, "/WindowShade VU Mode/Normal", NULL}, | |
| 294 {N_("/Refresh Rate"), NULL, NULL, 0, "<Branch>", NULL}, | |
| 295 {N_("/Refresh Rate/Full (~50 fps)"), NULL, mainwin_vis_menu_callback, | |
| 296 MAINWIN_VIS_REFRESH_FULL, "<RadioItem>", NULL}, | |
| 297 {N_("/Refresh Rate/Half (~25 fps)"), NULL, mainwin_vis_menu_callback, | |
| 298 MAINWIN_VIS_REFRESH_HALF, "/Refresh Rate/Full (~50 fps)", NULL}, | |
| 299 {N_("/Refresh Rate/Quarter (~13 fps)"), NULL, mainwin_vis_menu_callback, | |
| 300 MAINWIN_VIS_REFRESH_QUARTER, "/Refresh Rate/Full (~50 fps)", NULL}, | |
| 301 {N_("/Refresh Rate/Eighth (~6 fps)"), NULL, mainwin_vis_menu_callback, | |
| 302 MAINWIN_VIS_REFRESH_EIGHTH, "/Refresh Rate/Full (~50 fps)", NULL}, | |
| 303 {N_("/Analyzer Falloff"), NULL, NULL, 0, "<Branch>", NULL}, | |
| 304 {N_("/Analyzer Falloff/Slowest"), NULL, mainwin_vis_menu_callback, | |
| 305 MAINWIN_VIS_AFALLOFF_SLOWEST, "<RadioItem>", NULL}, | |
| 306 {N_("/Analyzer Falloff/Slow"), NULL, mainwin_vis_menu_callback, | |
| 307 MAINWIN_VIS_AFALLOFF_SLOW, "/Analyzer Falloff/Slowest", NULL}, | |
| 308 {N_("/Analyzer Falloff/Medium"), NULL, mainwin_vis_menu_callback, | |
| 309 MAINWIN_VIS_AFALLOFF_MEDIUM, "/Analyzer Falloff/Slowest", NULL}, | |
| 310 {N_("/Analyzer Falloff/Fast"), NULL, mainwin_vis_menu_callback, | |
| 311 MAINWIN_VIS_AFALLOFF_FAST, "/Analyzer Falloff/Slowest", NULL}, | |
| 312 {N_("/Analyzer Falloff/Fastest"), NULL, mainwin_vis_menu_callback, | |
| 313 MAINWIN_VIS_AFALLOFF_FASTEST, "/Analyzer Falloff/Slowest", NULL}, | |
| 314 {N_("/Peaks Falloff"), NULL, NULL, 0, "<Branch>", NULL}, | |
| 315 {N_("/Peaks Falloff/Slowest"), NULL, mainwin_vis_menu_callback, | |
| 316 MAINWIN_VIS_PFALLOFF_SLOWEST, "<RadioItem>", NULL}, | |
| 317 {N_("/Peaks Falloff/Slow"), NULL, mainwin_vis_menu_callback, | |
| 318 MAINWIN_VIS_PFALLOFF_SLOW, "/Peaks Falloff/Slowest", NULL}, | |
| 319 {N_("/Peaks Falloff/Medium"), NULL, mainwin_vis_menu_callback, | |
| 320 MAINWIN_VIS_PFALLOFF_MEDIUM, "/Peaks Falloff/Slowest", NULL}, | |
| 321 {N_("/Peaks Falloff/Fast"), NULL, mainwin_vis_menu_callback, | |
| 322 MAINWIN_VIS_PFALLOFF_FAST, "/Peaks Falloff/Slowest", NULL}, | |
| 323 {N_("/Peaks Falloff/Fastest"), NULL, mainwin_vis_menu_callback, | |
| 324 MAINWIN_VIS_PFALLOFF_FASTEST, "/Peaks Falloff/Slowest", NULL} | |
| 325 }; | |
| 326 | |
| 327 static const gint mainwin_vis_menu_entries_num = | |
| 328 G_N_ELEMENTS(mainwin_vis_menu_entries); | |
| 329 | |
| 330 /* Playback menu (now used only for accelerators) */ | |
| 331 | |
| 332 GtkItemFactoryEntry mainwin_playback_menu_entries[] = { | |
| 333 {N_("/Play CD"), "<alt>C", mainwin_general_menu_callback, | |
| 334 MAINWIN_GENERAL_PLAYCD, "<StockItem>", GTK_STOCK_CDROM}, | |
| 335 {"/-", NULL, NULL, 0, "<Separator>", NULL}, | |
| 336 {N_("/Repeat"), "R", mainwin_play_menu_callback, | |
| 337 MAINWIN_OPT_REPEAT, "<ToggleItem>", NULL}, | |
| 338 {N_("/Shuffle"), "S", mainwin_play_menu_callback, | |
| 339 MAINWIN_OPT_SHUFFLE, "<ToggleItem>", NULL}, | |
| 340 {N_("/No Playlist Advance"), "<control>N", mainwin_play_menu_callback, | |
| 341 MAINWIN_OPT_NPA, "<ToggleItem>", NULL}, | |
| 342 {N_("/Stop After Current Song"), "<control>M", mainwin_songname_menu_callback, | |
| 343 MAINWIN_SONGNAME_STOPAFTERSONG, "<ToggleItem>", NULL}, | |
| 344 {"/-", NULL, NULL, 0, "<Separator>", NULL}, | |
| 345 {N_("/Play"), "x", mainwin_general_menu_callback, | |
| 346 MAINWIN_GENERAL_PLAY, "<StockItem>", GTK_STOCK_MEDIA_PLAY}, | |
| 347 {N_("/Pause"), "c", mainwin_general_menu_callback, | |
| 348 MAINWIN_GENERAL_PAUSE, "<StockItem>", GTK_STOCK_MEDIA_PAUSE}, | |
| 349 {N_("/Stop"), "v", mainwin_general_menu_callback, | |
| 350 MAINWIN_GENERAL_STOP, "<StockItem>", GTK_STOCK_MEDIA_STOP}, | |
| 351 {N_("/Previous"), "z", mainwin_general_menu_callback, | |
| 352 MAINWIN_GENERAL_PREV, "<StockItem>", GTK_STOCK_MEDIA_PREVIOUS}, | |
| 353 {N_("/Next"), "b", mainwin_general_menu_callback, | |
| 354 MAINWIN_GENERAL_NEXT, "<StockItem>", GTK_STOCK_MEDIA_NEXT}, | |
| 355 {"/-", NULL, NULL, 0, "<Separator>", NULL}, | |
| 356 {N_("/Jump to Playlist Start"), "<control>Z", mainwin_general_menu_callback, | |
| 357 MAINWIN_GENERAL_START, "<StockItem>", GTK_STOCK_GOTO_TOP}, | |
| 358 {"/-", NULL, NULL, 0, "<Separator>", NULL}, | |
| 359 {N_("/Jump to File"), "J", mainwin_general_menu_callback, | |
| 360 MAINWIN_GENERAL_JTF, "<StockItem>", GTK_STOCK_JUMP_TO}, | |
| 361 {N_("/Jump to Time"), "<control>J", mainwin_general_menu_callback, | |
| 362 MAINWIN_GENERAL_JTT, "<StockItem>", GTK_STOCK_JUMP_TO}, | |
| 363 {"/-", NULL, NULL, 0, "<Separator>", NULL}, | |
| 364 {N_("/View Track Details"), "<alt>I", mainwin_general_menu_callback, | |
| 365 MAINWIN_GENERAL_FILEINFO, "<ImageItem>", my_pixbuf} | |
| 366 }; | |
| 367 | |
| 368 static const gint mainwin_playback_menu_entries_num = | |
| 369 G_N_ELEMENTS(mainwin_playback_menu_entries); | |
| 370 | |
| 371 /* Main menu */ | |
| 372 | |
| 373 GtkItemFactoryEntry mainwin_general_menu_entries[] = { | |
| 374 {N_("/About Audacious"), NULL, mainwin_general_menu_callback, | |
| 375 MAINWIN_GENERAL_ABOUT, "<StockItem>", GTK_STOCK_DIALOG_INFO}, | |
| 376 {"/-", NULL, NULL, 0, "<Separator>", NULL}, | |
| 377 {N_("/Play File"), "L", mainwin_general_menu_callback, | |
| 378 MAINWIN_GENERAL_PLAYFILE, "<StockItem>", GTK_STOCK_OPEN}, | |
| 379 {N_("/Play Location"), "<control>L", mainwin_general_menu_callback, | |
| 380 MAINWIN_GENERAL_PLAYLOCATION, "<StockItem>", GTK_STOCK_NETWORK}, | |
| 381 {"/-", NULL, NULL, 0, "<Separator>", NULL}, | |
| 382 {N_("/V_isualization"), NULL, NULL, 0, "<Item>", NULL}, | |
| 383 {N_("/_Playback"), NULL, NULL, 0, "<Item>", NULL}, | |
| 384 {N_("/_View"), NULL, NULL, 0, "<Item>", NULL}, | |
| 385 {"/-", NULL, NULL, 0, "<Separator>", NULL}, | |
| 386 {N_("/Preferences"), "<control>P", mainwin_general_menu_callback, | |
| 387 MAINWIN_GENERAL_PREFS, "<StockItem>", GTK_STOCK_PREFERENCES}, | |
| 388 {N_("/_Quit"), NULL, mainwin_general_menu_callback, | |
| 389 MAINWIN_GENERAL_EXIT, "<StockItem>", GTK_STOCK_QUIT} | |
| 390 }; | |
| 391 | |
| 392 static const gint mainwin_general_menu_entries_num = | |
| 393 G_N_ELEMENTS(mainwin_general_menu_entries); | |
| 394 | |
| 395 /* Add submenu */ | |
| 396 | |
| 397 GtkItemFactoryEntry mainwin_add_menu_entries[] = { | |
| 398 {N_("/Files..."), "f", mainwin_general_menu_callback, | |
| 399 MAINWIN_GENERAL_PLAYFILE, "<StockItem>", GTK_STOCK_OPEN}, | |
| 400 {N_("/Internet location..."), "<control>h", mainwin_general_menu_callback, | |
| 401 MAINWIN_GENERAL_PLAYLOCATION, "<StockItem>", GTK_STOCK_NETWORK}, | |
| 402 }; | |
| 403 | |
| 404 static const gint mainwin_add_menu_entries_num = | |
| 405 G_N_ELEMENTS(mainwin_add_menu_entries); | |
| 406 | |
| 407 /* View submenu */ | |
| 408 | |
| 409 GtkItemFactoryEntry mainwin_view_menu_entries[] = { | |
| 410 {N_("/Show Player"), "<alt>M", mainwin_general_menu_callback, | |
| 411 MAINWIN_GENERAL_SHOWMWIN, "<ToggleItem>", NULL}, | |
| 412 {N_("/Show Playlist Editor"), "<alt>E", mainwin_general_menu_callback, | |
| 413 MAINWIN_GENERAL_SHOWPLWIN, "<ToggleItem>", NULL}, | |
| 414 {N_("/Show Equalizer"), "<alt>G", mainwin_general_menu_callback, | |
| 415 MAINWIN_GENERAL_SHOWEQWIN, "<ToggleItem>", NULL}, | |
| 416 {"/-", NULL, NULL, 0, "<Separator>", NULL}, | |
| 417 {N_("/Time Elapsed"), "<control>E", mainwin_view_menu_callback, | |
| 418 MAINWIN_OPT_TELAPSED, "<RadioItem>", NULL}, | |
| 419 {N_("/Time Remaining"), "<control>R", mainwin_view_menu_callback, | |
| 420 MAINWIN_OPT_TREMAINING, "/Time Elapsed", NULL}, | |
| 421 {"/-", NULL, NULL, 0, "<Separator>", NULL}, | |
| 422 {N_("/Always On Top"), "<control>o", mainwin_view_menu_callback, | |
| 423 MAINWIN_OPT_ALWAYS, "<ToggleItem>", NULL}, | |
| 424 {N_("/Put on All Workspaces"), "<control>S", | |
| 425 mainwin_view_menu_callback, MAINWIN_OPT_STICKY, "<ToggleItem>", NULL}, | |
| 1775 | 426 {N_("/Autoscroll Songname"), NULL, mainwin_view_menu_callback, |
| 427 MAINWIN_SONGNAME_SCROLL, "<ToggleItem>", NULL}, | |
| 1653 | 428 {"/-", NULL, NULL, 0, "<Separator>", NULL}, |
| 429 {N_("/Roll up Player"), "<control>W", mainwin_view_menu_callback, | |
| 430 MAINWIN_OPT_WS, "<ToggleItem>", NULL}, | |
| 431 {N_("/Roll up Playlist Editor"), "<control><shift>W", mainwin_view_menu_callback, | |
| 432 MAINWIN_OPT_PWS, "<ToggleItem>", NULL}, | |
| 433 {N_("/Roll up Equalizer"), "<control><alt>W", mainwin_view_menu_callback, | |
| 434 MAINWIN_OPT_EQWS, "<ToggleItem>", NULL} | |
| 435 }; | |
| 436 | |
| 437 static const gint mainwin_view_menu_entries_num = | |
| 438 G_N_ELEMENTS(mainwin_view_menu_entries); | |
| 439 | |
| 440 | |
| 441 static PlaybackInfo playback_info = { NULL, 0, 0, 0 }; | |
| 442 | |
| 443 | |
| 444 static gint mainwin_idle_func(gpointer data); | |
| 445 | |
| 446 static void set_timer_mode_menu_cb(TimerMode mode); | |
| 447 static void set_timer_mode(TimerMode mode); | |
| 448 | |
| 449 static void mainwin_refresh_hints(void); | |
| 450 | |
| 451 void mainwin_position_motion_cb(gint pos); | |
| 452 void mainwin_position_release_cb(gint pos); | |
| 453 | |
| 454 | |
| 455 /* FIXME: placed here for now */ | |
| 456 void | |
| 457 playback_get_sample_params(gint * bitrate, | |
| 458 gint * frequency, | |
| 459 gint * n_channels) | |
| 460 { | |
| 461 if (bitrate) | |
| 462 *bitrate = playback_info.bitrate; | |
| 463 | |
| 464 if (frequency) | |
| 465 *frequency = playback_info.frequency; | |
| 466 | |
| 467 if (n_channels) | |
| 468 *n_channels = playback_info.n_channels; | |
| 469 } | |
| 470 | |
| 471 static void | |
| 472 playback_set_sample_params(gint bitrate, | |
| 473 gint frequency, | |
| 474 gint n_channels) | |
| 475 { | |
| 476 if (bitrate >= 0) | |
| 477 playback_info.bitrate = bitrate; | |
| 478 | |
| 479 if (frequency >= 0) | |
| 480 playback_info.frequency = frequency; | |
| 481 | |
| 482 if (n_channels >= 0) | |
| 483 playback_info.n_channels = n_channels; | |
| 484 } | |
| 485 | |
| 486 static void | |
| 487 mainwin_set_title_scroll(gboolean scroll) | |
| 488 { | |
| 489 cfg.autoscroll = scroll; | |
| 490 textbox_set_scroll(mainwin_info, cfg.autoscroll); | |
| 491 } | |
| 492 | |
| 493 | |
| 494 void | |
| 495 mainwin_set_always_on_top(gboolean always) | |
| 496 { | |
| 497 GtkWidget *widget = gtk_item_factory_get_widget(mainwin_view_menu, | |
| 498 "/Always On Top"); | |
| 499 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), | |
| 500 mainwin_menurow->mr_always_selected); | |
| 501 } | |
| 502 | |
| 503 static void | |
| 504 mainwin_set_shape_mask(void) | |
| 505 { | |
| 506 GdkBitmap *mask; | |
| 507 | |
| 508 if (!cfg.player_visible) | |
| 509 return; | |
| 510 | |
| 511 mask = skin_get_mask(bmp_active_skin, SKIN_MASK_MAIN + cfg.player_shaded); | |
| 512 gtk_widget_shape_combine_mask(mainwin, mask, 0, 0); | |
| 513 } | |
| 514 | |
| 515 static void | |
| 516 mainwin_set_shade(gboolean shaded) | |
| 517 { | |
| 518 GtkWidget *widget; | |
| 519 widget = gtk_item_factory_get_widget(mainwin_view_menu, | |
| 520 "/Roll up Player"); | |
| 521 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), shaded); | |
| 522 } | |
| 523 | |
| 524 static void | |
| 525 mainwin_set_shade_menu_cb(gboolean shaded) | |
| 526 { | |
| 527 cfg.player_shaded = shaded; | |
| 528 | |
| 529 mainwin_set_shape_mask(); | |
| 530 | |
| 531 if (shaded) { | |
| 532 dock_shade(dock_window_list, GTK_WINDOW(mainwin), | |
| 533 MAINWIN_SHADED_HEIGHT); | |
| 534 | |
| 535 widget_show(WIDGET(mainwin_svis)); | |
| 536 vis_clear_data(mainwin_vis); | |
| 537 | |
| 538 widget_show(WIDGET(mainwin_srew)); | |
| 539 widget_show(WIDGET(mainwin_splay)); | |
| 540 widget_show(WIDGET(mainwin_spause)); | |
| 541 widget_show(WIDGET(mainwin_sstop)); | |
| 542 widget_show(WIDGET(mainwin_sfwd)); | |
| 543 widget_show(WIDGET(mainwin_seject)); | |
| 544 | |
| 545 textbox_set_scroll(mainwin_info, FALSE); | |
| 546 if (bmp_playback_get_playing()) | |
| 1809 | 547 { |
| 1653 | 548 widget_show(WIDGET(mainwin_sposition)); |
| 549 widget_show(WIDGET(mainwin_stime_min)); | |
| 550 widget_show(WIDGET(mainwin_stime_sec)); | |
| 1809 | 551 } |
| 1653 | 552 else |
| 1809 | 553 { |
| 1653 | 554 widget_hide(WIDGET(mainwin_sposition)); |
| 555 widget_hide(WIDGET(mainwin_stime_min)); | |
| 556 widget_hide(WIDGET(mainwin_stime_sec)); | |
| 1809 | 557 } |
| 558 | |
| 1653 | 559 mainwin_shade->pb_ny = mainwin_shade->pb_py = 27; |
| 560 } | |
| 561 else { | |
| 1809 | 562 dock_shade(dock_window_list, GTK_WINDOW(mainwin), |
| 563 !bmp_active_skin->properties.mainwin_height ? MAINWIN_HEIGHT : | |
| 564 bmp_active_skin->properties.mainwin_height); | |
| 1653 | 565 |
| 566 widget_hide(WIDGET(mainwin_svis)); | |
| 567 svis_clear_data(mainwin_svis); | |
| 568 | |
| 569 widget_hide(WIDGET(mainwin_srew)); | |
| 570 widget_hide(WIDGET(mainwin_splay)); | |
| 571 widget_hide(WIDGET(mainwin_spause)); | |
| 572 widget_hide(WIDGET(mainwin_sstop)); | |
| 573 widget_hide(WIDGET(mainwin_sfwd)); | |
| 574 widget_hide(WIDGET(mainwin_seject)); | |
| 575 | |
| 576 widget_hide(WIDGET(mainwin_stime_min)); | |
| 577 widget_hide(WIDGET(mainwin_stime_sec)); | |
| 578 widget_hide(WIDGET(mainwin_sposition)); | |
| 579 | |
|
1763
50d5ef36b035
[svn] - now mainwindow remembers "autoscroll songname" setting after returns from shaded mode.
yaz
parents:
1696
diff
changeset
|
580 textbox_set_scroll(mainwin_info, cfg.autoscroll); |
| 1653 | 581 mainwin_shade->pb_ny = mainwin_shade->pb_py = 18; |
| 582 } | |
| 583 | |
| 584 draw_main_window(TRUE); | |
| 585 } | |
| 586 | |
| 587 static void | |
| 588 mainwin_vis_set_active_vis(gint new_vis) | |
| 589 { | |
| 590 active_vis = mainwin_vis; | |
| 591 } | |
| 592 | |
| 593 static void | |
| 594 mainwin_vis_set_refresh(RefreshRate rate) | |
| 595 { | |
| 596 cfg.vis_refresh = rate; | |
| 597 } | |
| 598 | |
| 599 static void | |
| 600 mainwin_vis_set_afalloff(FalloffSpeed speed) | |
| 601 { | |
| 602 cfg.analyzer_falloff = speed; | |
| 603 } | |
| 604 | |
| 605 static void | |
| 606 mainwin_vis_set_pfalloff(FalloffSpeed speed) | |
| 607 { | |
| 608 cfg.peaks_falloff = speed; | |
| 609 } | |
| 610 | |
| 611 static void | |
| 612 mainwin_vis_set_analyzer_mode(AnalyzerMode mode) | |
| 613 { | |
| 614 cfg.analyzer_mode = mode; | |
| 615 } | |
| 616 | |
| 617 static void | |
| 618 mainwin_vis_set_analyzer_type(AnalyzerType mode) | |
| 619 { | |
| 620 cfg.analyzer_type = mode; | |
| 621 } | |
| 622 | |
| 623 void | |
| 624 mainwin_vis_set_type(VisType mode) | |
| 625 { | |
| 626 gchar *path = | |
| 627 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_VIS_MODE + mode].path; | |
| 628 GtkWidget *widget = gtk_item_factory_get_widget(mainwin_vis_menu, path); | |
| 629 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), TRUE); | |
| 630 } | |
| 631 | |
| 632 static void | |
| 633 mainwin_vis_set_type_menu_cb(VisType mode) | |
| 634 { | |
| 635 cfg.vis_type = mode; | |
| 636 | |
| 637 if (mode == VIS_OFF) { | |
| 638 if (cfg.player_shaded && cfg.player_visible) | |
| 639 svis_clear(mainwin_svis); | |
| 640 else | |
| 641 vis_clear(active_vis); | |
| 642 } | |
| 643 if (mode == VIS_ANALYZER || mode == VIS_SCOPE) { | |
| 644 vis_clear_data(active_vis); | |
| 645 svis_clear_data(mainwin_svis); | |
| 646 } | |
| 647 } | |
| 648 | |
| 649 static void | |
| 650 mainwin_menubtn_cb(void) | |
| 651 { | |
| 652 gint x, y; | |
| 653 gtk_window_get_position(GTK_WINDOW(mainwin), &x, &y); | |
| 654 util_item_factory_popup(mainwin_general_menu, | |
| 655 x + 6, | |
| 656 y + MAINWIN_SHADED_HEIGHT, | |
| 657 1, GDK_CURRENT_TIME); | |
| 658 } | |
| 659 | |
| 660 void | |
| 661 mainwin_minimize_cb(void) | |
| 662 { | |
| 663 if (!mainwin) | |
| 664 return; | |
| 665 | |
| 666 gtk_window_iconify(GTK_WINDOW(mainwin)); | |
| 667 } | |
| 668 | |
| 669 static void | |
| 670 mainwin_shade_toggle(void) | |
| 671 { | |
| 672 mainwin_set_shade(!cfg.player_shaded); | |
| 673 } | |
| 674 | |
| 675 void | |
| 676 mainwin_quit_cb(void) | |
| 677 { | |
| 678 gtk_widget_hide(equalizerwin); | |
| 679 gtk_widget_hide(playlistwin); | |
| 680 gtk_widget_hide(mainwin); | |
| 681 gdk_flush(); | |
| 682 | |
| 683 g_source_remove(mainwin_timeout_id); | |
| 684 | |
| 685 util_set_cursor(NULL); | |
| 686 | |
| 687 bmp_config_save(); | |
| 688 gtk_accel_map_save(bmp_paths[BMP_PATH_ACCEL_FILE]); | |
| 689 | |
| 690 ctrlsocket_cleanup(); | |
| 691 | |
| 692 playlist_stop_get_info_thread(); | |
| 693 playlist_clear(); | |
| 694 | |
| 695 plugin_system_cleanup(); | |
| 696 | |
| 697 gtk_main_quit(); | |
| 698 | |
| 699 exit(EXIT_SUCCESS); | |
| 700 } | |
| 701 | |
| 702 static void | |
| 703 mainwin_destroy(GtkWidget * widget, gpointer data) | |
| 704 { | |
| 705 mainwin_quit_cb(); | |
| 706 } | |
| 707 | |
| 708 static void | |
| 709 mainwin_draw_titlebar(gboolean focus) | |
| 710 { | |
| 711 skin_draw_mainwin_titlebar(bmp_active_skin, mainwin_bg, mainwin_gc, | |
| 712 cfg.player_shaded, focus || !cfg.dim_titlebar); | |
| 713 } | |
| 714 | |
| 715 void | |
| 716 draw_main_window(gboolean force) | |
| 717 { | |
| 718 GList *wl; | |
| 719 Widget *w; | |
| 720 gboolean redraw; | |
| 721 | |
| 722 if (!cfg.player_visible) | |
| 723 return; | |
| 724 | |
| 725 if (force) | |
| 726 mainwin_refresh_hints(); | |
| 727 | |
| 728 widget_list_lock(mainwin_wlist); | |
| 729 | |
| 730 if (force) { | |
| 731 if (!cfg.player_shaded) | |
| 732 skin_draw_pixmap(bmp_active_skin, mainwin_bg, mainwin_gc, | |
| 1809 | 733 SKIN_MAIN, 0, 0, 0, 0, bmp_active_skin->properties.mainwin_width, |
| 734 bmp_active_skin->properties.mainwin_height); | |
| 1653 | 735 mainwin_draw_titlebar(gtk_window_has_toplevel_focus |
| 736 (GTK_WINDOW(mainwin))); | |
| 737 } | |
| 738 | |
| 739 widget_list_draw(mainwin_wlist, &redraw, force); | |
| 740 | |
| 741 if (redraw || force) { | |
| 742 if (force) { | |
| 743 gdk_window_clear(mainwin->window); | |
| 744 } | |
| 745 else { | |
| 746 for (wl = mainwin_wlist; wl; wl = g_list_next(wl)) { | |
| 747 w = WIDGET(wl->data); | |
| 748 | |
| 749 if (!w->redraw || !w->visible) | |
| 750 continue; | |
| 751 | |
| 752 gdk_window_clear_area(mainwin->window, w->x, w->y, | |
| 753 w->width, w->height); | |
| 754 w->redraw = FALSE; | |
| 755 } | |
| 756 } | |
| 757 | |
| 758 gdk_flush(); | |
| 759 } | |
| 760 | |
| 761 widget_list_unlock(mainwin_wlist); | |
| 762 } | |
| 763 | |
| 764 | |
| 765 void | |
| 766 mainwin_set_info_text(void) | |
| 767 { | |
| 768 gchar *text; | |
| 769 | |
| 770 if (mainwin_info_text_locked) | |
| 771 return; | |
| 772 | |
| 773 if ((text = input_get_info_text()) != NULL) { | |
| 774 textbox_set_text(mainwin_info, text); | |
| 775 g_free(text); | |
| 776 } | |
| 777 else if ((text = playlist_get_info_text()) != NULL) { | |
| 778 textbox_set_text(mainwin_info, text); | |
| 779 g_free(text); | |
| 780 } | |
| 781 } | |
| 782 | |
|
1788
80b6282a31ae
[svn] - implement mainwinOthertextIsStatus property.
nenolod
parents:
1786
diff
changeset
|
783 static gchar *mainwin_tb_old_text = NULL; |
|
80b6282a31ae
[svn] - implement mainwinOthertextIsStatus property.
nenolod
parents:
1786
diff
changeset
|
784 |
| 1653 | 785 void |
| 786 mainwin_lock_info_text(const gchar * text) | |
| 787 { | |
|
1791
15c92d5aebcd
[svn] - really preserve the old message on othertext info
nenolod
parents:
1790
diff
changeset
|
788 if (mainwin_info_text_locked != TRUE) |
|
15c92d5aebcd
[svn] - really preserve the old message on othertext info
nenolod
parents:
1790
diff
changeset
|
789 mainwin_tb_old_text = g_strdup(bmp_active_skin->properties.mainwin_othertext_is_status ? |
|
15c92d5aebcd
[svn] - really preserve the old message on othertext info
nenolod
parents:
1790
diff
changeset
|
790 mainwin_othertext->tb_text : mainwin_info->tb_text); |
|
15c92d5aebcd
[svn] - really preserve the old message on othertext info
nenolod
parents:
1790
diff
changeset
|
791 |
| 1653 | 792 mainwin_info_text_locked = TRUE; |
|
1788
80b6282a31ae
[svn] - implement mainwinOthertextIsStatus property.
nenolod
parents:
1786
diff
changeset
|
793 textbox_set_text(bmp_active_skin->properties.mainwin_othertext_is_status ? |
| 1789 | 794 mainwin_othertext : mainwin_info, text); |
| 1653 | 795 } |
| 796 | |
| 797 void | |
| 798 mainwin_release_info_text(void) | |
| 799 { | |
| 800 mainwin_info_text_locked = FALSE; | |
|
1788
80b6282a31ae
[svn] - implement mainwinOthertextIsStatus property.
nenolod
parents:
1786
diff
changeset
|
801 |
|
80b6282a31ae
[svn] - implement mainwinOthertextIsStatus property.
nenolod
parents:
1786
diff
changeset
|
802 if (mainwin_tb_old_text != NULL) |
|
80b6282a31ae
[svn] - implement mainwinOthertextIsStatus property.
nenolod
parents:
1786
diff
changeset
|
803 { |
|
80b6282a31ae
[svn] - implement mainwinOthertextIsStatus property.
nenolod
parents:
1786
diff
changeset
|
804 textbox_set_text(bmp_active_skin->properties.mainwin_othertext_is_status ? |
| 1790 | 805 mainwin_othertext : mainwin_info, mainwin_tb_old_text); |
|
1788
80b6282a31ae
[svn] - implement mainwinOthertextIsStatus property.
nenolod
parents:
1786
diff
changeset
|
806 g_free(mainwin_tb_old_text); |
|
80b6282a31ae
[svn] - implement mainwinOthertextIsStatus property.
nenolod
parents:
1786
diff
changeset
|
807 mainwin_tb_old_text = NULL; |
|
80b6282a31ae
[svn] - implement mainwinOthertextIsStatus property.
nenolod
parents:
1786
diff
changeset
|
808 } |
|
80b6282a31ae
[svn] - implement mainwinOthertextIsStatus property.
nenolod
parents:
1786
diff
changeset
|
809 else |
|
80b6282a31ae
[svn] - implement mainwinOthertextIsStatus property.
nenolod
parents:
1786
diff
changeset
|
810 mainwin_set_info_text(); /* XXX: best we can do */ |
| 1653 | 811 } |
| 812 | |
| 813 | |
| 814 static gchar * | |
| 815 make_mainwin_title(const gchar * title) | |
| 816 { | |
| 817 if (title) | |
| 818 return g_strdup_printf(_("%s - Audacious"), title); | |
| 819 else | |
| 820 return g_strdup(_("Audacious")); | |
| 821 } | |
| 822 | |
| 823 void | |
| 824 mainwin_set_song_title(const gchar * title) | |
| 825 { | |
| 826 G_LOCK(mainwin_title); | |
| 827 g_free(mainwin_title_text); | |
| 828 mainwin_title_text = make_mainwin_title(title); | |
| 829 G_UNLOCK(mainwin_title); | |
| 830 } | |
| 831 | |
| 832 static void | |
| 833 mainwin_refresh_hints(void) | |
| 834 { | |
| 835 if (bmp_active_skin && bmp_active_skin->properties.mainwin_othertext | |
| 836 == TRUE) | |
| 837 { | |
| 838 widget_hide(WIDGET(mainwin_rate_text)); | |
| 839 widget_hide(WIDGET(mainwin_freq_text)); | |
| 840 widget_hide(WIDGET(mainwin_monostereo)); | |
| 1799 | 841 |
| 842 if (bmp_active_skin->properties.mainwin_othertext_visible) | |
| 843 widget_show(WIDGET(mainwin_othertext)); | |
| 1653 | 844 } |
| 845 else | |
| 846 { | |
| 847 widget_show(WIDGET(mainwin_rate_text)); | |
| 848 widget_show(WIDGET(mainwin_freq_text)); | |
| 849 widget_show(WIDGET(mainwin_monostereo)); | |
| 850 widget_hide(WIDGET(mainwin_othertext)); | |
| 851 } | |
|
1774
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
852 |
| 1784 | 853 /* positioning and size attributes */ |
|
1774
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
854 if (bmp_active_skin->properties.mainwin_vis_x && bmp_active_skin->properties.mainwin_vis_y) |
|
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
855 widget_move(WIDGET(mainwin_vis), bmp_active_skin->properties.mainwin_vis_x, |
|
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
856 bmp_active_skin->properties.mainwin_vis_y); |
|
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
857 |
|
1780
be1de1dd7262
[svn] - implement [skin.hints:mainwinVisWidth] property.
nenolod
parents:
1779
diff
changeset
|
858 if (bmp_active_skin->properties.mainwin_vis_width) |
|
be1de1dd7262
[svn] - implement [skin.hints:mainwinVisWidth] property.
nenolod
parents:
1779
diff
changeset
|
859 widget_resize(WIDGET(mainwin_info), bmp_active_skin->properties.mainwin_vis_width, |
|
be1de1dd7262
[svn] - implement [skin.hints:mainwinVisWidth] property.
nenolod
parents:
1779
diff
changeset
|
860 mainwin_vis->vs_widget.height); |
|
be1de1dd7262
[svn] - implement [skin.hints:mainwinVisWidth] property.
nenolod
parents:
1779
diff
changeset
|
861 |
|
1774
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
862 if (bmp_active_skin->properties.mainwin_text_x && bmp_active_skin->properties.mainwin_text_y) |
|
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
863 widget_move(WIDGET(mainwin_info), bmp_active_skin->properties.mainwin_text_x, |
|
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
864 bmp_active_skin->properties.mainwin_text_y); |
|
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
865 |
|
1777
17e38b5c8e2f
[svn] - support for the [skin.hints:mainwinTextWidth] property.
nenolod
parents:
1775
diff
changeset
|
866 if (bmp_active_skin->properties.mainwin_text_width) |
|
17e38b5c8e2f
[svn] - support for the [skin.hints:mainwinTextWidth] property.
nenolod
parents:
1775
diff
changeset
|
867 widget_resize(WIDGET(mainwin_info), bmp_active_skin->properties.mainwin_text_width, |
|
17e38b5c8e2f
[svn] - support for the [skin.hints:mainwinTextWidth] property.
nenolod
parents:
1775
diff
changeset
|
868 mainwin_info->tb_widget.height); |
|
17e38b5c8e2f
[svn] - support for the [skin.hints:mainwinTextWidth] property.
nenolod
parents:
1775
diff
changeset
|
869 |
|
1774
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
870 if (bmp_active_skin->properties.mainwin_infobar_x && bmp_active_skin->properties.mainwin_infobar_y) |
|
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
871 widget_move(WIDGET(mainwin_othertext), bmp_active_skin->properties.mainwin_infobar_x, |
|
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
872 bmp_active_skin->properties.mainwin_infobar_y); |
|
1778
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
873 |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
874 if (bmp_active_skin->properties.mainwin_number_0_x && bmp_active_skin->properties.mainwin_number_0_y) |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
875 widget_move(WIDGET(mainwin_minus_num), bmp_active_skin->properties.mainwin_number_0_x, |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
876 bmp_active_skin->properties.mainwin_number_0_y); |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
877 |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
878 if (bmp_active_skin->properties.mainwin_number_1_x && bmp_active_skin->properties.mainwin_number_1_y) |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
879 widget_move(WIDGET(mainwin_10min_num), bmp_active_skin->properties.mainwin_number_1_x, |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
880 bmp_active_skin->properties.mainwin_number_1_y); |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
881 |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
882 if (bmp_active_skin->properties.mainwin_number_2_x && bmp_active_skin->properties.mainwin_number_2_y) |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
883 widget_move(WIDGET(mainwin_min_num), bmp_active_skin->properties.mainwin_number_2_x, |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
884 bmp_active_skin->properties.mainwin_number_2_y); |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
885 |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
886 if (bmp_active_skin->properties.mainwin_number_3_x && bmp_active_skin->properties.mainwin_number_3_y) |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
887 widget_move(WIDGET(mainwin_10sec_num), bmp_active_skin->properties.mainwin_number_3_x, |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
888 bmp_active_skin->properties.mainwin_number_3_y); |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
889 |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
890 if (bmp_active_skin->properties.mainwin_number_4_x && bmp_active_skin->properties.mainwin_number_4_y) |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
891 widget_move(WIDGET(mainwin_sec_num), bmp_active_skin->properties.mainwin_number_4_x, |
|
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
892 bmp_active_skin->properties.mainwin_number_4_y); |
|
1779
87d4da9b31ea
[svn] - implement [skin.hints:mainwinPlayStatus(X,Y)] properties.
nenolod
parents:
1778
diff
changeset
|
893 |
|
87d4da9b31ea
[svn] - implement [skin.hints:mainwinPlayStatus(X,Y)] properties.
nenolod
parents:
1778
diff
changeset
|
894 if (bmp_active_skin->properties.mainwin_playstatus_x && bmp_active_skin->properties.mainwin_playstatus_y) |
|
87d4da9b31ea
[svn] - implement [skin.hints:mainwinPlayStatus(X,Y)] properties.
nenolod
parents:
1778
diff
changeset
|
895 widget_move(WIDGET(mainwin_playstatus), bmp_active_skin->properties.mainwin_playstatus_x, |
|
87d4da9b31ea
[svn] - implement [skin.hints:mainwinPlayStatus(X,Y)] properties.
nenolod
parents:
1778
diff
changeset
|
896 bmp_active_skin->properties.mainwin_playstatus_y); |
| 1784 | 897 |
| 1786 | 898 if (bmp_active_skin->properties.mainwin_volume_x && bmp_active_skin->properties.mainwin_volume_y) |
| 899 widget_move(WIDGET(mainwin_volume), bmp_active_skin->properties.mainwin_volume_x, | |
| 900 bmp_active_skin->properties.mainwin_volume_y); | |
| 901 | |
| 902 if (bmp_active_skin->properties.mainwin_balance_x && bmp_active_skin->properties.mainwin_balance_y) | |
| 903 widget_move(WIDGET(mainwin_balance), bmp_active_skin->properties.mainwin_balance_x, | |
| 904 bmp_active_skin->properties.mainwin_balance_y); | |
| 905 | |
| 906 if (bmp_active_skin->properties.mainwin_position_x && bmp_active_skin->properties.mainwin_position_y) | |
| 907 widget_move(WIDGET(mainwin_position), bmp_active_skin->properties.mainwin_position_x, | |
| 908 bmp_active_skin->properties.mainwin_position_y); | |
| 909 | |
|
1804
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
910 if (bmp_active_skin->properties.mainwin_previous_x && bmp_active_skin->properties.mainwin_previous_y) |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
911 widget_move(WIDGET(mainwin_rew), bmp_active_skin->properties.mainwin_previous_x, |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
912 bmp_active_skin->properties.mainwin_previous_y); |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
913 |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
914 if (bmp_active_skin->properties.mainwin_play_x && bmp_active_skin->properties.mainwin_play_y) |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
915 widget_move(WIDGET(mainwin_play), bmp_active_skin->properties.mainwin_play_x, |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
916 bmp_active_skin->properties.mainwin_play_y); |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
917 |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
918 if (bmp_active_skin->properties.mainwin_pause_x && bmp_active_skin->properties.mainwin_pause_y) |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
919 widget_move(WIDGET(mainwin_pause), bmp_active_skin->properties.mainwin_pause_x, |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
920 bmp_active_skin->properties.mainwin_pause_y); |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
921 |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
922 if (bmp_active_skin->properties.mainwin_stop_x && bmp_active_skin->properties.mainwin_stop_y) |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
923 widget_move(WIDGET(mainwin_stop), bmp_active_skin->properties.mainwin_stop_x, |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
924 bmp_active_skin->properties.mainwin_stop_y); |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
925 |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
926 if (bmp_active_skin->properties.mainwin_next_x && bmp_active_skin->properties.mainwin_next_y) |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
927 widget_move(WIDGET(mainwin_fwd), bmp_active_skin->properties.mainwin_next_x, |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
928 bmp_active_skin->properties.mainwin_next_y); |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
929 |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
930 if (bmp_active_skin->properties.mainwin_eject_x && bmp_active_skin->properties.mainwin_eject_y) |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
931 widget_move(WIDGET(mainwin_eject), bmp_active_skin->properties.mainwin_eject_x, |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
932 bmp_active_skin->properties.mainwin_eject_y); |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
933 |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
934 if (bmp_active_skin->properties.mainwin_eqbutton_x && bmp_active_skin->properties.mainwin_eqbutton_y) |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
935 widget_move(WIDGET(mainwin_eq), bmp_active_skin->properties.mainwin_eqbutton_x, |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
936 bmp_active_skin->properties.mainwin_eqbutton_y); |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
937 |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
938 if (bmp_active_skin->properties.mainwin_plbutton_x && bmp_active_skin->properties.mainwin_plbutton_y) |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
939 widget_move(WIDGET(mainwin_pl), bmp_active_skin->properties.mainwin_plbutton_x, |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
940 bmp_active_skin->properties.mainwin_plbutton_y); |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
941 |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
942 if (bmp_active_skin->properties.mainwin_shuffle_x && bmp_active_skin->properties.mainwin_shuffle_y) |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
943 widget_move(WIDGET(mainwin_shuffle), bmp_active_skin->properties.mainwin_shuffle_x, |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
944 bmp_active_skin->properties.mainwin_shuffle_y); |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
945 |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
946 if (bmp_active_skin->properties.mainwin_repeat_x && bmp_active_skin->properties.mainwin_repeat_y) |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
947 widget_move(WIDGET(mainwin_repeat), bmp_active_skin->properties.mainwin_repeat_x, |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
948 bmp_active_skin->properties.mainwin_repeat_y); |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
949 |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
950 if (bmp_active_skin->properties.mainwin_about_x && bmp_active_skin->properties.mainwin_about_y) |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
951 widget_move(WIDGET(mainwin_about), bmp_active_skin->properties.mainwin_about_x, |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
952 bmp_active_skin->properties.mainwin_about_y); |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
953 |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
954 /* window size, mainwinWidth && mainwinHeight properties */ |
|
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
955 if (bmp_active_skin->properties.mainwin_height && bmp_active_skin->properties.mainwin_width) |
| 1805 | 956 { |
|
1840
b64edd53d3a9
[svn] - actually, apparently we need that... fucking apple
nenolod
parents:
1839
diff
changeset
|
957 gdk_window_set_hints(mainwin->window, 0, 0, |
|
b64edd53d3a9
[svn] - actually, apparently we need that... fucking apple
nenolod
parents:
1839
diff
changeset
|
958 bmp_active_skin->properties.mainwin_width, |
|
b64edd53d3a9
[svn] - actually, apparently we need that... fucking apple
nenolod
parents:
1839
diff
changeset
|
959 cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : bmp_active_skin->properties.mainwin_height, |
|
b64edd53d3a9
[svn] - actually, apparently we need that... fucking apple
nenolod
parents:
1839
diff
changeset
|
960 bmp_active_skin->properties.mainwin_width, |
|
b64edd53d3a9
[svn] - actually, apparently we need that... fucking apple
nenolod
parents:
1839
diff
changeset
|
961 cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : bmp_active_skin->properties.mainwin_height, |
|
b64edd53d3a9
[svn] - actually, apparently we need that... fucking apple
nenolod
parents:
1839
diff
changeset
|
962 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); |
| 1837 | 963 gdk_window_resize(mainwin->window, bmp_active_skin->properties.mainwin_width, |
| 964 cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : bmp_active_skin->properties.mainwin_height); | |
| 965 gdk_window_set_hints(mainwin->window, 0, 0, | |
| 966 bmp_active_skin->properties.mainwin_width, | |
| 967 cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : bmp_active_skin->properties.mainwin_height, | |
| 968 bmp_active_skin->properties.mainwin_width, | |
| 969 cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : bmp_active_skin->properties.mainwin_height, | |
| 970 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); | |
| 1853 | 971 g_object_unref(mainwin_bg); |
| 972 mainwin_bg = gdk_pixmap_new(mainwin->window, | |
| 973 bmp_active_skin->properties.mainwin_width, | |
| 974 bmp_active_skin->properties.mainwin_height, -1); | |
|
1851
aceb472cce6c
[svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents:
1848
diff
changeset
|
975 mainwin_set_back_pixmap(); |
| 1853 | 976 widget_list_change_pixmap(mainwin_wlist, mainwin_bg); |
| 1837 | 977 gdk_flush(); |
| 1805 | 978 } |
|
1804
e0e46bce806e
[svn] - mainwinEQButtonX, mainwinEQButtonY, mainwinPLButtonX, mainwinPLButtonY, mainwinAboutX,
nenolod
parents:
1799
diff
changeset
|
979 |
| 1784 | 980 /* visibility attributes */ |
| 981 if (bmp_active_skin->properties.mainwin_menurow_visible) | |
| 982 widget_show(WIDGET(mainwin_menurow)); | |
| 983 else | |
| 984 widget_hide(WIDGET(mainwin_menurow)); | |
|
1792
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
985 |
|
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
986 if (bmp_active_skin->properties.mainwin_text_visible) |
|
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
987 widget_show(WIDGET(mainwin_info)); |
|
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
988 else |
|
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
989 widget_hide(WIDGET(mainwin_info)); |
|
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
990 |
|
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
991 if (bmp_active_skin->properties.mainwin_othertext_visible) |
|
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
992 widget_show(WIDGET(mainwin_othertext)); |
|
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
993 else |
|
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
994 widget_hide(WIDGET(mainwin_othertext)); |
|
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
995 |
|
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
996 if (bmp_active_skin->properties.mainwin_vis_visible) |
|
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
997 widget_show(WIDGET(mainwin_vis)); |
|
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
998 else |
|
b8f082ddd9f1
[svn] - implement mainwinTextVisible, mainwinVisVisible, mainwinOthertextVisible hints
nenolod
parents:
1791
diff
changeset
|
999 widget_hide(WIDGET(mainwin_vis)); |
| 1653 | 1000 } |
| 1001 | |
| 1002 void | |
| 1003 mainwin_set_song_info(gint bitrate, | |
| 1004 gint frequency, | |
| 1005 gint n_channels) | |
| 1006 { | |
| 1007 gchar text[512]; | |
| 1008 gchar *title; | |
| 1009 | |
| 1010 playback_set_sample_params(bitrate, frequency, n_channels); | |
| 1011 | |
| 1012 if (bitrate != -1) { | |
| 1013 bitrate /= 1000; | |
| 1014 | |
| 1015 if (bitrate < 1000) { | |
| 1016 /* Show bitrate in 1000s */ | |
| 1017 g_snprintf(text, sizeof(text), "%3d", bitrate); | |
| 1018 textbox_set_text(mainwin_rate_text, text); | |
| 1019 } | |
| 1020 else { | |
| 1021 /* Show bitrate in 100,000s */ | |
| 1022 g_snprintf(text, sizeof(text), "%2dH", bitrate / 100); | |
| 1023 textbox_set_text(mainwin_rate_text, text); | |
| 1024 } | |
| 1025 } | |
| 1026 else | |
| 1027 textbox_set_text(mainwin_rate_text, _("VBR")); | |
| 1028 | |
| 1029 /* Show sampling frequency in kHz */ | |
| 1030 g_snprintf(text, sizeof(text), "%2d", frequency / 1000); | |
| 1031 textbox_set_text(mainwin_freq_text, text); | |
| 1032 | |
| 1033 monostereo_set_num_channels(mainwin_monostereo, n_channels); | |
| 1034 | |
| 1035 if (cfg.player_shaded) | |
| 1036 { | |
| 1037 widget_show(WIDGET(mainwin_stime_min)); | |
| 1038 widget_show(WIDGET(mainwin_stime_sec)); | |
| 1039 } | |
| 1040 | |
| 1041 widget_show(WIDGET(mainwin_minus_num)); | |
| 1042 widget_show(WIDGET(mainwin_10min_num)); | |
| 1043 widget_show(WIDGET(mainwin_min_num)); | |
| 1044 widget_show(WIDGET(mainwin_10sec_num)); | |
| 1045 widget_show(WIDGET(mainwin_sec_num)); | |
| 1046 | |
|
1672
600efc52c645
[svn] - be careful about referencing a NULL widget (e.g. headless/serveronly mode crashes on streams, bug #562)
nenolod
parents:
1653
diff
changeset
|
1047 if (!bmp_playback_get_paused() && mainwin_playstatus != NULL) |
| 1653 | 1048 playstatus_set_status(mainwin_playstatus, STATUS_PLAY); |
| 1049 | |
| 1050 if (playlist_get_current_length() != -1) { | |
| 1051 if (cfg.player_shaded) | |
| 1052 widget_show(WIDGET(mainwin_sposition)); | |
| 1053 widget_show(WIDGET(mainwin_position)); | |
| 1054 } | |
| 1055 else { | |
| 1056 widget_hide(WIDGET(mainwin_position)); | |
| 1057 widget_hide(WIDGET(mainwin_sposition)); | |
| 1058 mainwin_force_redraw = TRUE; | |
| 1059 } | |
| 1060 | |
| 1061 if (bmp_active_skin && bmp_active_skin->properties.mainwin_othertext | |
| 1062 == TRUE) | |
| 1063 { | |
| 1064 if (bitrate != -1) | |
| 1065 g_snprintf(text, 512, "%d kbps, %0.1f kHz, %s", | |
| 1066 bitrate, | |
| 1067 (gfloat) frequency / 1000, | |
| 1068 (n_channels > 1) ? _("stereo") : _("mono")); | |
| 1069 else | |
| 1070 g_snprintf(text, 512, "VBR, %0.1f kHz, %s", | |
| 1071 (gfloat) frequency / 1000, | |
| 1072 (n_channels > 1) ? _("stereo") : _("mono")); | |
| 1073 | |
| 1074 textbox_set_text(mainwin_othertext, text); | |
| 1075 | |
| 1076 widget_hide(WIDGET(mainwin_rate_text)); | |
| 1077 widget_hide(WIDGET(mainwin_freq_text)); | |
| 1078 widget_hide(WIDGET(mainwin_monostereo)); | |
| 1799 | 1079 |
| 1080 if (bmp_active_skin->properties.mainwin_othertext_visible) | |
| 1081 widget_show(WIDGET(mainwin_othertext)); | |
| 1653 | 1082 } |
| 1083 else | |
| 1084 { | |
| 1085 widget_show(WIDGET(mainwin_rate_text)); | |
| 1086 widget_show(WIDGET(mainwin_freq_text)); | |
| 1087 widget_show(WIDGET(mainwin_monostereo)); | |
| 1088 widget_hide(WIDGET(mainwin_othertext)); | |
| 1089 } | |
| 1090 | |
| 1091 title = playlist_get_info_text(); | |
| 1092 mainwin_set_song_title(title); | |
| 1093 g_free(title); | |
| 1094 } | |
| 1095 | |
| 1096 void | |
| 1097 mainwin_clear_song_info(void) | |
| 1098 { | |
| 1099 if (!mainwin) | |
| 1100 return; | |
| 1101 | |
| 1102 /* clear title */ | |
| 1103 G_LOCK(mainwin_title); | |
| 1104 g_free(mainwin_title_text); | |
| 1105 mainwin_title_text = NULL; | |
| 1106 G_UNLOCK(mainwin_title); | |
| 1107 | |
| 1108 /* clear sampling parameters */ | |
| 1109 playback_set_sample_params(0, 0, 0); | |
| 1110 | |
| 1111 mainwin_position->hs_pressed = FALSE; | |
| 1112 mainwin_sposition->hs_pressed = FALSE; | |
| 1113 | |
| 1114 /* clear sampling parameter displays */ | |
| 1115 textbox_set_text(mainwin_rate_text, " "); | |
| 1116 textbox_set_text(mainwin_freq_text, " "); | |
| 1117 monostereo_set_num_channels(mainwin_monostereo, 0); | |
| 1118 | |
|
1672
600efc52c645
[svn] - be careful about referencing a NULL widget (e.g. headless/serveronly mode crashes on streams, bug #562)
nenolod
parents:
1653
diff
changeset
|
1119 if (mainwin_playstatus != NULL) |
|
600efc52c645
[svn] - be careful about referencing a NULL widget (e.g. headless/serveronly mode crashes on streams, bug #562)
nenolod
parents:
1653
diff
changeset
|
1120 playstatus_set_status(mainwin_playstatus, STATUS_STOP); |
| 1653 | 1121 |
| 1122 /* hide playback time */ | |
| 1123 widget_hide(WIDGET(mainwin_minus_num)); | |
| 1124 widget_hide(WIDGET(mainwin_10min_num)); | |
| 1125 widget_hide(WIDGET(mainwin_min_num)); | |
| 1126 widget_hide(WIDGET(mainwin_10sec_num)); | |
| 1127 widget_hide(WIDGET(mainwin_sec_num)); | |
| 1128 | |
| 1129 widget_hide(WIDGET(mainwin_stime_min)); | |
| 1130 widget_hide(WIDGET(mainwin_stime_sec)); | |
| 1131 | |
| 1132 widget_hide(WIDGET(mainwin_position)); | |
| 1133 widget_hide(WIDGET(mainwin_sposition)); | |
| 1134 | |
| 1135 widget_hide(WIDGET(mainwin_othertext)); | |
| 1136 | |
| 1137 playlistwin_hide_timer(); | |
| 1138 draw_main_window(TRUE); | |
| 1139 | |
| 1140 vis_clear(active_vis); | |
| 1141 } | |
| 1142 | |
| 1143 void | |
| 1144 mainwin_disable_seekbar(void) | |
| 1145 { | |
| 1146 if (!mainwin) | |
| 1147 return; | |
| 1148 | |
| 1149 /* | |
| 1150 * We dont call draw_main_window() here so this will not | |
| 1151 * remove them visually. It will only prevent us from sending | |
| 1152 * any seek calls to the input plugin before the input plugin | |
| 1153 * calls ->set_info(). | |
| 1154 */ | |
| 1155 widget_hide(WIDGET(mainwin_position)); | |
| 1156 widget_hide(WIDGET(mainwin_sposition)); | |
| 1157 } | |
| 1158 | |
| 1159 static gboolean | |
| 1160 mainwin_mouse_button_release(GtkWidget * widget, | |
| 1161 GdkEventButton * event, | |
| 1162 gpointer callback_data) | |
| 1163 { | |
| 1164 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
| 1165 | |
| 1166 /* | |
| 1167 * The gdk_flush() is just for making sure that the pointer really | |
| 1168 * gets ungrabbed before calling any button callbacks | |
| 1169 * | |
| 1170 */ | |
| 1171 | |
| 1172 gdk_flush(); | |
| 1173 | |
| 1174 if (dock_is_moving(GTK_WINDOW(mainwin))) { | |
| 1175 dock_move_release(GTK_WINDOW(mainwin)); | |
| 1176 draw_playlist_window(TRUE); | |
| 1177 } | |
| 1178 | |
| 1179 if (mainwin_menurow->mr_doublesize_selected) { | |
| 1180 event->x /= 2; | |
| 1181 event->y /= 2; | |
| 1182 } | |
| 1183 | |
| 1184 handle_release_cb(mainwin_wlist, widget, event); | |
| 1185 | |
| 1186 draw_main_window(FALSE); | |
| 1187 | |
| 1188 return FALSE; | |
| 1189 } | |
| 1190 | |
| 1191 static gboolean | |
| 1192 mainwin_motion(GtkWidget * widget, | |
| 1193 GdkEventMotion * event, | |
| 1194 gpointer callback_data) | |
| 1195 { | |
| 1196 int x, y; | |
| 1197 GdkModifierType state; | |
| 1198 | |
| 1199 if (event->is_hint != FALSE) | |
| 1200 { | |
| 1201 gdk_window_get_pointer(GDK_WINDOW(mainwin->window), | |
| 1202 &x, &y, &state); | |
| 1203 | |
| 1204 /* If it's a hint, we had to query X, so override the | |
| 1205 * information we we're given... it's probably useless... --nenolod | |
| 1206 */ | |
| 1207 event->x = x; | |
| 1208 event->y = y; | |
| 1209 event->state = state; | |
| 1210 } | |
| 1211 else | |
| 1212 { | |
| 1213 x = event->x; | |
| 1214 y = event->y; | |
| 1215 state = event->state; | |
| 1216 } | |
| 1217 | |
| 1218 if (dock_is_moving(GTK_WINDOW(mainwin))) { | |
| 1219 dock_move_motion(GTK_WINDOW(mainwin), event); | |
| 1220 } | |
| 1221 else { | |
| 1222 handle_motion_cb(mainwin_wlist, widget, event); | |
| 1223 draw_main_window(FALSE); | |
| 1224 } | |
| 1225 | |
| 1226 gdk_flush(); | |
| 1227 | |
| 1228 return FALSE; | |
| 1229 } | |
| 1230 | |
| 1231 static gboolean | |
| 1232 inside_sensitive_widgets(gint x, gint y) | |
| 1233 { | |
| 1234 return (widget_contains(WIDGET(mainwin_menubtn), x, y) | |
| 1235 || widget_contains(WIDGET(mainwin_minimize), x, y) | |
| 1236 || widget_contains(WIDGET(mainwin_shade), x, y) | |
| 1237 || widget_contains(WIDGET(mainwin_close), x, y) | |
| 1238 || widget_contains(WIDGET(mainwin_rew), x, y) | |
| 1239 || widget_contains(WIDGET(mainwin_play), x, y) | |
| 1240 || widget_contains(WIDGET(mainwin_pause), x, y) | |
| 1241 || widget_contains(WIDGET(mainwin_stop), x, y) | |
| 1242 || widget_contains(WIDGET(mainwin_fwd), x, y) | |
| 1243 || widget_contains(WIDGET(mainwin_eject), x, y) | |
| 1244 || widget_contains(WIDGET(mainwin_shuffle), x, y) | |
| 1245 || widget_contains(WIDGET(mainwin_repeat), x, y) | |
| 1246 || widget_contains(WIDGET(mainwin_pl), x, y) | |
| 1247 || widget_contains(WIDGET(mainwin_eq), x, y) | |
| 1248 || widget_contains(WIDGET(mainwin_info), x, y) | |
| 1249 || widget_contains(WIDGET(mainwin_menurow), x, y) | |
| 1250 || widget_contains(WIDGET(mainwin_volume), x, y) | |
| 1251 || widget_contains(WIDGET(mainwin_balance), x, y) | |
| 1252 || (widget_contains(WIDGET(mainwin_position), x, y) && | |
| 1253 widget_is_visible(WIDGET(mainwin_position))) | |
| 1254 || widget_contains(WIDGET(mainwin_minus_num), x, y) | |
| 1255 || widget_contains(WIDGET(mainwin_10min_num), x, y) | |
| 1256 || widget_contains(WIDGET(mainwin_min_num), x, y) | |
| 1257 || widget_contains(WIDGET(mainwin_10sec_num), x, y) | |
| 1258 || widget_contains(WIDGET(mainwin_sec_num), x, y) | |
| 1259 || widget_contains(WIDGET(mainwin_vis), x, y) | |
| 1260 || widget_contains(WIDGET(mainwin_minimize), x, y) | |
| 1261 || widget_contains(WIDGET(mainwin_shade), x, y) | |
| 1262 || widget_contains(WIDGET(mainwin_close), x, y) | |
| 1263 || widget_contains(WIDGET(mainwin_menubtn), x, y) | |
| 1264 || widget_contains(WIDGET(mainwin_sposition), x, y) | |
| 1265 || widget_contains(WIDGET(mainwin_stime_min), x, y) | |
| 1266 || widget_contains(WIDGET(mainwin_stime_sec), x, y) | |
| 1267 || widget_contains(WIDGET(mainwin_srew), x, y) | |
| 1268 || widget_contains(WIDGET(mainwin_splay), x, y) | |
| 1269 || widget_contains(WIDGET(mainwin_spause), x, y) | |
| 1270 || widget_contains(WIDGET(mainwin_sstop), x, y) | |
| 1271 || widget_contains(WIDGET(mainwin_sfwd), x, y) | |
| 1272 || widget_contains(WIDGET(mainwin_seject), x, y) | |
| 1273 || widget_contains(WIDGET(mainwin_svis), x, y) | |
| 1274 || widget_contains(WIDGET(mainwin_about), x, y)); | |
| 1275 } | |
| 1276 | |
| 1277 void | |
|
1676
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1278 mainwin_scrolled(GtkWidget *widget, GdkEventScroll *event, |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1279 gpointer callback_data) |
| 1653 | 1280 { |
|
1676
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1281 switch (event->direction) { |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1282 case GDK_SCROLL_UP: |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1283 mainwin_set_volume_diff(cfg.mouse_change); |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1284 break; |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1285 case GDK_SCROLL_DOWN: |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1286 mainwin_set_volume_diff(-cfg.mouse_change); |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1287 break; |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1288 case GDK_SCROLL_LEFT: |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1289 if (playlist_get_current_length() != -1) |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1290 bmp_playback_seek(CLAMP(bmp_playback_get_time() - 1000, |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1291 0, playlist_get_current_length()) / 1000); |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1292 break; |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1293 case GDK_SCROLL_RIGHT: |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1294 if (playlist_get_current_length() != -1) |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1295 bmp_playback_seek(CLAMP(bmp_playback_get_time() + 1000, |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1296 0, playlist_get_current_length()) / 1000); |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1297 break; |
|
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1298 } |
| 1653 | 1299 } |
| 1300 | |
| 1301 static gboolean | |
| 1302 mainwin_mouse_button_press(GtkWidget * widget, | |
| 1303 GdkEventButton * event, | |
| 1304 gpointer callback_data) | |
| 1305 { | |
| 1306 | |
| 1307 gboolean grab = TRUE; | |
| 1308 | |
| 1309 if (event->button == 1 && event->type == GDK_BUTTON_PRESS && | |
| 1310 !inside_sensitive_widgets(event->x, event->y) && event->y < 14) { | |
| 1311 if (0 && hint_move_resize_available()) { | |
| 1312 hint_move_resize(mainwin, event->x_root, event->y_root, TRUE); | |
| 1313 grab = FALSE; | |
| 1314 } | |
| 1315 else { | |
| 1316 gtk_window_present(GTK_WINDOW(mainwin)); | |
| 1317 dock_move_press(dock_window_list, GTK_WINDOW(mainwin), event, | |
| 1318 TRUE); | |
| 1319 } | |
| 1320 } | |
| 1321 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
| 1322 event->y < 14 && !inside_sensitive_widgets(event->x, event->y)) { | |
| 1323 mainwin_set_shade(!cfg.player_shaded); | |
| 1324 if (dock_is_moving(GTK_WINDOW(mainwin))) | |
| 1325 dock_move_release(GTK_WINDOW(mainwin)); | |
| 1326 } | |
| 1327 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
| 1328 widget_contains(WIDGET(mainwin_info), event->x, event->y)) { | |
| 1329 playlist_fileinfo_current(); | |
| 1330 } | |
| 1331 else { | |
| 1332 handle_press_cb(mainwin_wlist, widget, event); | |
| 1333 draw_main_window(FALSE); | |
| 1334 } | |
| 1335 | |
| 1336 if ((event->button == 1) && event->type != GDK_2BUTTON_PRESS && | |
| 1337 (widget_contains(WIDGET(mainwin_vis), event->x, event->y) || | |
| 1338 widget_contains(WIDGET(mainwin_svis), event->x, event->y))) { | |
| 1339 | |
| 1340 cfg.vis_type++; | |
| 1341 | |
| 1342 if (cfg.vis_type > VIS_OFF) | |
| 1343 cfg.vis_type = VIS_ANALYZER; | |
| 1344 | |
| 1345 mainwin_vis_set_type(cfg.vis_type); | |
| 1346 } | |
| 1347 | |
| 1348 if (event->button == 3) { | |
| 1349 if (widget_contains(WIDGET(mainwin_info), event->x, event->y)) { | |
| 1350 util_item_factory_popup(mainwin_songname_menu, | |
| 1351 event->x_root, event->y_root, | |
| 1352 3, event->time); | |
| 1353 grab = FALSE; | |
| 1354 } | |
| 1355 else if (widget_contains(WIDGET(mainwin_vis), event->x, event->y) || | |
| 1356 widget_contains(WIDGET(mainwin_svis), event->x, event->y)) { | |
| 1357 util_item_factory_popup(mainwin_vis_menu, event->x_root, | |
| 1358 event->y_root, 3, event->time); | |
| 1359 grab = FALSE; | |
| 1360 } | |
| 1361 else if ( (event->y > 70) && (event->x < 128) ) | |
| 1362 { | |
| 1363 | |
| 1364 util_item_factory_popup(mainwin_play_menu, | |
| 1365 event->x_root, | |
| 1366 event->y_root, 3, event->time); | |
| 1367 grab = FALSE; | |
| 1368 } else { | |
| 1369 /* | |
| 1370 * Pop up the main menu a few pixels down. | |
| 1371 * This will avoid that anything is selected | |
| 1372 * if one right-clicks to focus the window | |
| 1373 * without raising it. | |
| 1374 * | |
| 1375 ***MD I think the above is stupid, people don't expect this | |
| 1376 * | |
| 1377 */ | |
| 1378 util_item_factory_popup(mainwin_general_menu, | |
| 1379 event->x_root, | |
| 1380 event->y_root, 3, event->time); | |
| 1381 grab = FALSE; | |
| 1382 } | |
| 1383 } | |
| 1384 if (event->button == 1) { | |
| 1385 if ((event->x > 35 && event->x < 100 && | |
| 1386 event->y > 25 && event->y < 40) || | |
| 1387 widget_contains(WIDGET(mainwin_stime_min), event->x, event->y) || | |
| 1388 widget_contains(WIDGET(mainwin_stime_sec), event->x, event->y)) { | |
| 1389 | |
| 1390 if (cfg.timer_mode == TIMER_ELAPSED) | |
| 1391 set_timer_mode(TIMER_REMAINING); | |
| 1392 else | |
| 1393 set_timer_mode(TIMER_ELAPSED); | |
| 1394 } | |
| 1395 | |
| 1396 } | |
| 1397 | |
| 1398 if (grab) | |
| 1399 gdk_pointer_grab(mainwin->window, FALSE, | |
| 1400 GDK_BUTTON_MOTION_MASK | | |
| 1401 GDK_BUTTON_RELEASE_MASK, | |
| 1402 GDK_WINDOW(GDK_NONE), NULL, GDK_CURRENT_TIME); | |
| 1403 | |
| 1404 return FALSE; | |
| 1405 } | |
| 1406 | |
| 1407 static gboolean | |
| 1408 mainwin_focus_in(GtkWidget * window, | |
| 1409 GdkEventFocus * event, | |
| 1410 gpointer data) | |
| 1411 { | |
| 1412 mainwin_menubtn->pb_allow_draw = TRUE; | |
| 1413 mainwin_minimize->pb_allow_draw = TRUE; | |
| 1414 mainwin_shade->pb_allow_draw = TRUE; | |
| 1415 mainwin_close->pb_allow_draw = TRUE; | |
| 1416 draw_main_window(TRUE); | |
| 1417 | |
| 1418 return TRUE; | |
| 1419 } | |
| 1420 | |
| 1421 | |
| 1422 static gboolean | |
| 1423 mainwin_focus_out(GtkWidget * widget, | |
| 1424 GdkEventFocus * event, | |
| 1425 gpointer callback_data) | |
| 1426 { | |
| 1427 mainwin_menubtn->pb_allow_draw = FALSE; | |
| 1428 mainwin_minimize->pb_allow_draw = FALSE; | |
| 1429 mainwin_shade->pb_allow_draw = FALSE; | |
| 1430 mainwin_close->pb_allow_draw = FALSE; | |
| 1431 draw_main_window(TRUE); | |
| 1432 | |
| 1433 return TRUE; | |
| 1434 } | |
| 1435 | |
| 1436 static gboolean | |
| 1437 mainwin_keypress(GtkWidget * grab_widget, | |
| 1438 GdkEventKey * event, | |
| 1439 gpointer data) | |
| 1440 { | |
| 1441 | |
| 1442 switch (event->keyval) { | |
| 1443 | |
| 1444 case GDK_Up: | |
| 1445 case GDK_KP_Up: | |
| 1446 case GDK_KP_8: | |
| 1447 mainwin_set_volume_diff(2); | |
| 1448 break; | |
| 1449 case GDK_Down: | |
| 1450 case GDK_KP_Down: | |
| 1451 case GDK_KP_2: | |
| 1452 mainwin_set_volume_diff(-2); | |
| 1453 break; | |
| 1454 case GDK_Left: | |
| 1455 case GDK_KP_Left: | |
| 1456 case GDK_KP_7: | |
| 1457 if (playlist_get_current_length() != -1) | |
| 1458 bmp_playback_seek(CLAMP | |
| 1459 (bmp_playback_get_time() - 1000, 0, | |
| 1460 playlist_get_current_length()) / 1000); | |
| 1461 break; | |
| 1462 case GDK_Right: | |
| 1463 case GDK_KP_Right: | |
| 1464 case GDK_KP_9: | |
| 1465 if (playlist_get_current_length() != -1) | |
| 1466 bmp_playback_seek(CLAMP | |
| 1467 (bmp_playback_get_time() + 1000, 0, | |
| 1468 playlist_get_current_length()) / 1000); | |
| 1469 break; | |
| 1470 case GDK_KP_4: | |
| 1471 playlist_prev(); | |
| 1472 break; | |
| 1473 case GDK_KP_6: | |
| 1474 playlist_next(); | |
| 1475 break; | |
| 1476 case GDK_KP_Insert: | |
| 1477 mainwin_jump_to_file(); | |
| 1478 break; | |
| 1479 case GDK_KP_5: | |
| 1480 mainwin_play_pushed(); | |
| 1481 break; | |
| 1482 case GDK_Escape: | |
| 1483 mainwin_minimize_cb(); | |
| 1484 break; | |
| 1485 default: | |
| 1486 return FALSE; | |
| 1487 } | |
| 1488 | |
| 1489 return TRUE; | |
| 1490 } | |
| 1491 | |
| 1492 static void | |
| 1493 mainwin_jump_to_time_cb(GtkWidget * widget, | |
| 1494 GtkWidget * entry) | |
| 1495 { | |
| 1496 guint min = 0, sec = 0, params; | |
| 1497 gint time; | |
| 1498 | |
| 1499 params = sscanf(gtk_entry_get_text(GTK_ENTRY(entry)), "%u:%u", | |
| 1500 &min, &sec); | |
| 1501 if (params == 2) | |
| 1502 time = (min * 60) + sec; | |
| 1503 else if (params == 1) | |
| 1504 time = min; | |
| 1505 else | |
| 1506 return; | |
| 1507 | |
| 1508 if (playlist_get_current_length() > -1 && | |
| 1509 time <= (playlist_get_current_length() / 1000)) { | |
| 1510 bmp_playback_seek(time); | |
| 1511 gtk_widget_destroy(mainwin_jtt); | |
| 1512 } | |
| 1513 } | |
| 1514 | |
| 1515 | |
| 1516 void | |
| 1517 mainwin_jump_to_time(void) | |
| 1518 { | |
| 1519 GtkWidget *vbox, *hbox_new, *hbox_total; | |
| 1520 GtkWidget *time_entry, *label, *bbox, *jump, *cancel; | |
| 1521 guint tindex; | |
| 1522 gchar time_str[10]; | |
| 1523 | |
| 1524 if (!bmp_playback_get_playing()) { | |
| 1525 report_error("JIT can't be launched when no track is being played.\n"); | |
| 1526 return; | |
| 1527 } | |
| 1528 | |
| 1529 if (mainwin_jtt) { | |
| 1530 gtk_window_present(GTK_WINDOW(mainwin_jtt)); | |
| 1531 return; | |
| 1532 } | |
| 1533 | |
| 1534 mainwin_jtt = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
| 1535 gtk_window_set_type_hint(GTK_WINDOW(mainwin_jtt), | |
| 1536 GDK_WINDOW_TYPE_HINT_DIALOG); | |
| 1537 | |
| 1538 gtk_window_set_title(GTK_WINDOW(mainwin_jtt), _("Jump to Time")); | |
| 1539 gtk_window_set_position(GTK_WINDOW(mainwin_jtt), GTK_WIN_POS_CENTER); | |
| 1540 gtk_window_set_transient_for(GTK_WINDOW(mainwin_jtt), | |
| 1541 GTK_WINDOW(mainwin)); | |
| 1542 | |
| 1543 g_signal_connect(mainwin_jtt, "destroy", | |
| 1544 G_CALLBACK(gtk_widget_destroyed), &mainwin_jtt); | |
| 1545 gtk_container_border_width(GTK_CONTAINER(mainwin_jtt), 10); | |
| 1546 | |
| 1547 vbox = gtk_vbox_new(FALSE, 5); | |
| 1548 gtk_container_add(GTK_CONTAINER(mainwin_jtt), vbox); | |
| 1549 | |
| 1550 hbox_new = gtk_hbox_new(FALSE, 0); | |
| 1551 gtk_box_pack_start(GTK_BOX(vbox), hbox_new, TRUE, TRUE, 5); | |
| 1552 | |
| 1553 time_entry = gtk_entry_new(); | |
| 1554 gtk_box_pack_start(GTK_BOX(hbox_new), time_entry, FALSE, FALSE, 5); | |
| 1555 g_signal_connect(time_entry, "activate", | |
| 1556 G_CALLBACK(mainwin_jump_to_time_cb), time_entry); | |
| 1557 | |
| 1558 gtk_widget_set_size_request(time_entry, 70, -1); | |
| 1559 label = gtk_label_new(_("minutes:seconds")); | |
| 1560 gtk_box_pack_start(GTK_BOX(hbox_new), label, FALSE, FALSE, 5); | |
| 1561 | |
| 1562 hbox_total = gtk_hbox_new(FALSE, 0); | |
| 1563 gtk_box_pack_start(GTK_BOX(vbox), hbox_total, TRUE, TRUE, 5); | |
| 1564 gtk_widget_show(hbox_total); | |
| 1565 | |
| 1566 /* FIXME: Disable display of current track length. It's not | |
| 1567 updated when track changes */ | |
| 1568 #if 0 | |
| 1569 label = gtk_label_new(_("Track length:")); | |
| 1570 gtk_box_pack_start(GTK_BOX(hbox_total), label, FALSE, FALSE, 5); | |
| 1571 | |
| 1572 len = playlist_get_current_length() / 1000; | |
| 1573 g_snprintf(time_str, sizeof(time_str), "%u:%2.2u", len / 60, len % 60); | |
| 1574 label = gtk_label_new(time_str); | |
| 1575 | |
| 1576 gtk_box_pack_start(GTK_BOX(hbox_total), label, FALSE, FALSE, 10); | |
| 1577 #endif | |
| 1578 | |
| 1579 bbox = gtk_hbutton_box_new(); | |
| 1580 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 0); | |
| 1581 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
| 1582 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
| 1583 | |
| 1584 cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
| 1585 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
| 1586 gtk_container_add(GTK_CONTAINER(bbox), cancel); | |
| 1587 g_signal_connect_swapped(cancel, "clicked", | |
| 1588 G_CALLBACK(gtk_widget_destroy), mainwin_jtt); | |
| 1589 | |
| 1590 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
| 1591 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
| 1592 gtk_container_add(GTK_CONTAINER(bbox), jump); | |
| 1593 g_signal_connect(jump, "clicked", | |
| 1594 G_CALLBACK(mainwin_jump_to_time_cb), time_entry); | |
| 1595 | |
| 1596 tindex = bmp_playback_get_time() / 1000; | |
| 1597 g_snprintf(time_str, sizeof(time_str), "%u:%2.2u", tindex / 60, | |
| 1598 tindex % 60); | |
| 1599 gtk_entry_set_text(GTK_ENTRY(time_entry), time_str); | |
| 1600 | |
| 1601 gtk_entry_select_region(GTK_ENTRY(time_entry), 0, strlen(time_str)); | |
| 1602 | |
| 1603 gtk_widget_show_all(mainwin_jtt); | |
| 1604 | |
| 1605 gtk_widget_grab_focus(time_entry); | |
| 1606 gtk_widget_grab_default(jump); | |
| 1607 } | |
| 1608 | |
| 1609 static void | |
| 1610 change_song(guint pos) | |
| 1611 { | |
| 1612 if (bmp_playback_get_playing()) | |
| 1613 bmp_playback_stop(); | |
| 1614 | |
| 1615 playlist_set_position(pos); | |
| 1616 bmp_playback_initiate(); | |
| 1617 } | |
| 1618 | |
| 1619 static void | |
| 1620 mainwin_jump_to_file_jump(GtkTreeView * treeview) | |
| 1621 { | |
| 1622 GtkTreeModel *model; | |
| 1623 GtkTreeSelection *selection; | |
| 1624 GtkTreeIter iter; | |
| 1625 gchar *pos_str; | |
| 1626 guint pos; | |
| 1627 | |
| 1628 model = gtk_tree_view_get_model(treeview); | |
| 1629 selection = gtk_tree_view_get_selection(treeview); | |
| 1630 | |
| 1631 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
| 1632 return; | |
| 1633 | |
| 1634 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
| 1635 pos = g_ascii_strtoull(pos_str, NULL, 10) - 1; | |
| 1636 g_free(pos_str); | |
| 1637 | |
| 1638 change_song(pos); | |
| 1639 | |
| 1640 /* FIXME: should only hide window */ | |
| 1641 gtk_widget_destroy(mainwin_jtf); | |
| 1642 mainwin_jtf = NULL; | |
| 1643 } | |
| 1644 | |
| 1645 static void | |
| 1646 mainwin_jump_to_file_jump_cb(GtkTreeView * treeview, | |
| 1647 gpointer data) | |
| 1648 { | |
| 1649 mainwin_jump_to_file_jump(treeview); | |
| 1650 } | |
| 1651 | |
| 1652 static void | |
| 1653 mainwin_jump_to_file_set_queue_button_label(GtkButton * button, | |
| 1654 guint pos) | |
| 1655 { | |
| 1656 if (playlist_is_position_queued(pos)) | |
| 1657 gtk_button_set_label(button, _("Un_queue")); | |
| 1658 else | |
| 1659 gtk_button_set_label(button, _("_Queue")); | |
| 1660 } | |
| 1661 | |
| 1662 static void | |
| 1663 mainwin_jump_to_file_queue_cb(GtkButton * button, | |
| 1664 gpointer data) | |
| 1665 { | |
| 1666 GtkTreeView *treeview; | |
| 1667 GtkTreeModel *model; | |
| 1668 GtkTreeSelection *selection; | |
| 1669 GtkTreeIter iter; | |
| 1670 gchar *pos_str; | |
| 1671 guint pos; | |
| 1672 | |
| 1673 treeview = GTK_TREE_VIEW(data); | |
| 1674 model = gtk_tree_view_get_model(treeview); | |
| 1675 selection = gtk_tree_view_get_selection(treeview); | |
| 1676 | |
| 1677 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
| 1678 return; | |
| 1679 | |
| 1680 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
| 1681 pos = g_ascii_strtoull(pos_str, NULL, 10) - 1; | |
| 1682 | |
| 1683 playlist_queue_position(pos); | |
| 1684 | |
| 1685 mainwin_jump_to_file_set_queue_button_label(button, pos); | |
| 1686 } | |
| 1687 | |
| 1688 static void | |
| 1689 mainwin_jump_to_file_selection_changed_cb(GtkTreeSelection *treesel, | |
| 1690 gpointer data) | |
| 1691 { | |
| 1692 GtkTreeView *treeview; | |
| 1693 GtkTreeModel *model; | |
| 1694 GtkTreeSelection *selection; | |
| 1695 GtkTreeIter iter; | |
| 1696 gchar *pos_str; | |
| 1697 guint pos; | |
| 1698 | |
| 1699 treeview = gtk_tree_selection_get_tree_view(treesel); | |
| 1700 model = gtk_tree_view_get_model(treeview); | |
| 1701 selection = gtk_tree_view_get_selection(treeview); | |
| 1702 | |
| 1703 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
| 1704 return; | |
| 1705 | |
| 1706 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
| 1707 pos = g_ascii_strtoull(pos_str, NULL, 10) - 1; | |
| 1708 g_free(pos_str); | |
| 1709 | |
| 1710 mainwin_jump_to_file_set_queue_button_label(GTK_BUTTON(data), pos); | |
| 1711 } | |
| 1712 | |
| 1713 static gboolean | |
| 1714 mainwin_jump_to_file_edit_keypress_cb(GtkWidget * object, | |
| 1715 GdkEventKey * event, | |
| 1716 gpointer data) | |
| 1717 { | |
| 1718 switch (event->keyval) { | |
| 1719 case GDK_Return: | |
| 1720 if (gtk_im_context_filter_keypress (GTK_ENTRY (object)->im_context, event)) { | |
| 1721 GTK_ENTRY (object)->need_im_reset = TRUE; | |
| 1722 return TRUE; | |
| 1723 } else { | |
| 1724 mainwin_jump_to_file_jump(GTK_TREE_VIEW(data)); | |
| 1725 return TRUE; | |
| 1726 } | |
| 1727 default: | |
| 1728 return FALSE; | |
| 1729 } | |
| 1730 } | |
| 1731 | |
| 1732 static gboolean | |
| 1733 mainwin_jump_to_file_keypress_cb(GtkWidget * object, | |
| 1734 GdkEventKey * event, | |
| 1735 gpointer data) | |
| 1736 { | |
| 1737 switch (event->keyval) { | |
| 1738 case GDK_Escape: | |
| 1739 /* FIXME: show only hide window */ | |
| 1740 gtk_widget_destroy(mainwin_jtf); | |
| 1741 mainwin_jtf = NULL; | |
| 1742 return TRUE; | |
| 1743 default: | |
| 1744 return FALSE; | |
| 1745 }; | |
| 1746 } | |
| 1747 | |
| 1748 static gboolean | |
| 1749 mainwin_jump_to_file_match(const gchar * song, gchar ** keys) | |
| 1750 { | |
| 1751 gint i = 0; | |
| 1752 gchar *key; | |
| 1753 gchar *song_lc; | |
| 1754 | |
| 1755 song_lc = g_ascii_strdown(song, -1); | |
| 1756 | |
| 1757 while (keys[i]) { | |
| 1758 key = g_ascii_strdown(keys[i], -1); | |
| 1759 if (!g_strrstr(song_lc, key)) { | |
| 1760 g_free(key); | |
| 1761 g_free(song_lc); | |
| 1762 return FALSE; | |
| 1763 } | |
| 1764 | |
| 1765 g_free(key); | |
| 1766 i++; | |
| 1767 } | |
| 1768 | |
| 1769 g_free(song_lc); | |
| 1770 | |
| 1771 return TRUE; | |
| 1772 } | |
| 1773 | |
| 1774 /* FIXME: Clear the entry when the list gets updated */ | |
| 1775 static void | |
| 1776 mainwin_update_jtf(GtkWidget * widget, gpointer user_data) | |
| 1777 { | |
| 1778 /* FIXME: Is not in sync with playlist due to delayed extinfo | |
| 1779 * reading */ | |
| 1780 gint row; | |
| 1781 GList *playlist; | |
| 1782 gchar *desc_buf = NULL; | |
| 1783 gchar *row_str; | |
| 1784 GtkTreeIter iter; | |
| 1785 GtkTreeSelection *selection; | |
| 1786 | |
| 1787 GtkTreeModel *store; | |
| 1788 | |
| 1789 if (!mainwin_jtf) | |
| 1790 return; | |
| 1791 | |
| 1792 store = gtk_tree_view_get_model(GTK_TREE_VIEW(user_data)); | |
| 1793 gtk_list_store_clear(GTK_LIST_STORE(store)); | |
| 1794 | |
| 1795 row = 1; | |
| 1796 for (playlist = playlist_get(); playlist; | |
| 1797 playlist = g_list_next(playlist)) { | |
| 1798 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
| 1799 | |
| 1800 if (entry->title) | |
| 1801 desc_buf = g_strdup(entry->title); | |
| 1802 else if (strchr(entry->filename, '/')) | |
| 1803 desc_buf = str_to_utf8(strrchr(entry->filename, '/') + 1); | |
| 1804 else | |
| 1805 desc_buf = str_to_utf8(entry->filename); | |
| 1806 | |
| 1807 row_str = g_strdup_printf("%d", row++); | |
| 1808 | |
| 1809 gtk_list_store_append(GTK_LIST_STORE(store), &iter); | |
| 1810 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
| 1811 0, row_str, 1, desc_buf, -1); | |
| 1812 | |
| 1813 if(desc_buf) { | |
| 1814 g_free(desc_buf); | |
| 1815 desc_buf = NULL; | |
| 1816 } | |
| 1817 | |
| 1818 g_free(row_str); | |
| 1819 } | |
| 1820 | |
| 1821 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); | |
| 1822 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(user_data)); | |
| 1823 gtk_tree_selection_select_iter(selection, &iter); | |
| 1824 } | |
| 1825 | |
| 1826 static void | |
| 1827 mainwin_jump_to_file_edit_cb(GtkEntry * entry, gpointer user_data) | |
| 1828 { | |
| 1829 GtkTreeView *treeview = GTK_TREE_VIEW(user_data); | |
| 1830 GtkTreeSelection *selection; | |
| 1831 GtkTreeIter iter; | |
| 1832 | |
| 1833 GtkListStore *store; | |
| 1834 | |
| 1835 gint song_index = 0; | |
| 1836 gchar **words; | |
| 1837 GList *playlist; | |
| 1838 | |
| 1839 gboolean match = FALSE; | |
| 1840 | |
| 1841 /* Chop the key string into ' '-separated key words */ | |
| 1842 words = g_strsplit(gtk_entry_get_text(entry), " ", 0); | |
| 1843 | |
| 1844 /* FIXME: Remove the connected signals before clearing | |
| 1845 * (row-selected will still eventually arrive once) */ | |
| 1846 store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview)); | |
| 1847 gtk_list_store_clear(store); | |
| 1848 | |
| 1849 PLAYLIST_LOCK(); | |
| 1850 | |
| 1851 for (playlist = playlist_get(); playlist; | |
| 1852 playlist = g_list_next(playlist)) { | |
| 1853 | |
| 1854 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
| 1855 const gchar *title; | |
| 1856 gchar *filename = NULL; | |
| 1857 | |
| 1858 title = entry->title; | |
| 1859 if (!title) { | |
| 1860 filename = str_to_utf8(entry->filename); | |
| 1861 | |
| 1862 if (strchr(filename, '/')) | |
| 1863 title = strrchr(filename, '/') + 1; | |
| 1864 else | |
| 1865 title = filename; | |
| 1866 } | |
| 1867 | |
| 1868 /* Compare the key words to the string - if all the words | |
| 1869 match, add to the ListStore */ | |
| 1870 | |
| 1871 /* | |
| 1872 * FIXME: The search string should be adapted to the | |
| 1873 * current display setting, e.g. if the user has set it to | |
| 1874 * "%p - %t" then build the match string like that too, or | |
| 1875 * even better, search for each of the tags seperatly. | |
| 1876 * | |
| 1877 * In any case the string to match should _never_ contain | |
| 1878 * something the user can't actually see in the playlist. | |
| 1879 */ | |
| 1880 if (words[0]) | |
| 1881 match = mainwin_jump_to_file_match(title, words); | |
| 1882 else | |
| 1883 match = TRUE; | |
| 1884 | |
| 1885 if (match) { | |
| 1886 gchar *song_index_str = g_strdup_printf("%d", song_index + 1); | |
| 1887 gtk_list_store_append(store, &iter); | |
| 1888 gtk_list_store_set(store, &iter, 0, song_index_str, 1, title, -1); | |
| 1889 g_free(song_index_str); | |
| 1890 } | |
| 1891 | |
| 1892 song_index++; | |
| 1893 if (filename) { | |
| 1894 g_free(filename); | |
| 1895 filename = NULL; | |
| 1896 } | |
| 1897 } | |
| 1898 | |
| 1899 PLAYLIST_UNLOCK(); | |
| 1900 | |
| 1901 g_strfreev(words); | |
| 1902 | |
| 1903 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) { | |
| 1904 selection = gtk_tree_view_get_selection(treeview); | |
| 1905 gtk_tree_selection_select_iter(selection, &iter); | |
| 1906 } | |
| 1907 } | |
| 1908 | |
| 1909 void | |
| 1910 mainwin_jump_to_file(void) | |
| 1911 { | |
| 1912 GtkWidget *scrollwin; | |
| 1913 GtkWidget *vbox, *bbox, *sep; | |
| 1914 GtkWidget *jump, *queue, *cancel; | |
| 1915 GtkWidget *rescan, *edit; | |
| 1916 GtkWidget *search_label, *hbox; | |
| 1917 GList *playlist; | |
| 1918 gchar *desc_buf = NULL; | |
| 1919 gchar *row_str; | |
| 1920 gint row; | |
| 1921 | |
| 1922 GtkWidget *treeview; | |
| 1923 GtkListStore *jtf_store; | |
| 1924 | |
| 1925 GtkTreeIter iter; | |
| 1926 GtkCellRenderer *renderer; | |
| 1927 GtkTreeViewColumn *column; | |
| 1928 | |
| 1929 if (mainwin_jtf) { | |
| 1930 gtk_window_present(GTK_WINDOW(mainwin_jtf)); | |
| 1931 return; | |
| 1932 } | |
| 1933 | |
| 1934 mainwin_jtf = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
| 1935 gtk_window_set_type_hint(GTK_WINDOW(mainwin_jtf), | |
| 1936 GDK_WINDOW_TYPE_HINT_DIALOG); | |
| 1937 | |
| 1938 gtk_window_set_title(GTK_WINDOW(mainwin_jtf), _("Jump to Track")); | |
| 1939 | |
| 1940 gtk_window_set_position(GTK_WINDOW(mainwin_jtf), GTK_WIN_POS_CENTER); | |
| 1941 g_signal_connect(mainwin_jtf, "destroy", | |
| 1942 G_CALLBACK(gtk_widget_destroyed), &mainwin_jtf); | |
| 1943 | |
| 1944 gtk_container_border_width(GTK_CONTAINER(mainwin_jtf), 10); | |
| 1945 gtk_window_set_default_size(GTK_WINDOW(mainwin_jtf), 550, 350); | |
| 1946 | |
| 1947 vbox = gtk_vbox_new(FALSE, 5); | |
| 1948 gtk_container_add(GTK_CONTAINER(mainwin_jtf), vbox); | |
| 1949 | |
| 1950 jtf_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); | |
| 1951 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(jtf_store)); | |
| 1952 g_object_unref(jtf_store); | |
| 1953 | |
| 1954 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
| 1955 | |
| 1956 column = gtk_tree_view_column_new(); | |
| 1957 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
| 1958 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
| 1959 | |
| 1960 renderer = gtk_cell_renderer_text_new(); | |
| 1961 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
| 1962 gtk_tree_view_column_set_attributes(column, renderer, "text", 0, NULL); | |
| 1963 gtk_tree_view_column_set_spacing(column, 4); | |
| 1964 | |
| 1965 renderer = gtk_cell_renderer_text_new(); | |
| 1966 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
| 1967 gtk_tree_view_column_set_attributes(column, renderer, "text", 1, NULL); | |
| 1968 gtk_tree_view_column_set_spacing(column, 4); | |
| 1969 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); | |
| 1970 | |
| 1971 gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), 1); | |
| 1972 | |
| 1973 g_signal_connect(treeview, "row-activated", | |
| 1974 G_CALLBACK(mainwin_jump_to_file_jump), NULL); | |
| 1975 | |
| 1976 hbox = gtk_hbox_new(FALSE, 3); | |
| 1977 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3); | |
| 1978 | |
| 1979 search_label = gtk_label_new(_("Filter: ")); | |
| 1980 gtk_label_set_markup_with_mnemonic(GTK_LABEL(search_label), "_Filter:"); | |
| 1981 gtk_box_pack_start(GTK_BOX(hbox), search_label, FALSE, FALSE, 0); | |
| 1982 | |
| 1983 edit = gtk_entry_new(); | |
| 1984 gtk_entry_set_editable(GTK_ENTRY(edit), TRUE); | |
| 1985 gtk_label_set_mnemonic_widget(GTK_LABEL(search_label), edit); | |
| 1986 g_signal_connect(edit, "changed", | |
| 1987 G_CALLBACK(mainwin_jump_to_file_edit_cb), treeview); | |
| 1988 | |
| 1989 g_signal_connect(edit, "key_press_event", | |
| 1990 G_CALLBACK(mainwin_jump_to_file_edit_keypress_cb), treeview); | |
| 1991 | |
| 1992 g_signal_connect(mainwin_jtf, "key_press_event", | |
| 1993 G_CALLBACK(mainwin_jump_to_file_keypress_cb), treeview); | |
| 1994 | |
| 1995 gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 3); | |
| 1996 | |
| 1997 scrollwin = gtk_scrolled_window_new(NULL, NULL); | |
| 1998 gtk_container_add(GTK_CONTAINER(scrollwin), treeview); | |
| 1999 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), | |
| 2000 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
| 2001 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin), | |
| 2002 GTK_SHADOW_IN); | |
| 2003 gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0); | |
| 2004 | |
| 2005 sep = gtk_hseparator_new(); | |
| 2006 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
| 2007 | |
| 2008 bbox = gtk_hbutton_box_new(); | |
| 2009 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
| 2010 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
| 2011 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
| 2012 | |
| 2013 queue = gtk_button_new_with_mnemonic(_("_Queue")); | |
| 2014 gtk_box_pack_start(GTK_BOX(bbox), queue, FALSE, FALSE, 0); | |
| 2015 GTK_WIDGET_SET_FLAGS(queue, GTK_CAN_DEFAULT); | |
| 2016 g_signal_connect(queue, "clicked", | |
| 2017 G_CALLBACK(mainwin_jump_to_file_queue_cb), | |
| 2018 treeview); | |
| 2019 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), "changed", | |
| 2020 G_CALLBACK(mainwin_jump_to_file_selection_changed_cb), | |
| 2021 queue); | |
| 2022 | |
| 2023 rescan = gtk_button_new_from_stock(GTK_STOCK_REFRESH); | |
| 2024 gtk_box_pack_start(GTK_BOX(bbox), rescan, FALSE, FALSE, 0); | |
| 2025 g_signal_connect(rescan, "clicked", | |
| 2026 G_CALLBACK(mainwin_update_jtf), treeview); | |
| 2027 GTK_WIDGET_SET_FLAGS(rescan, GTK_CAN_DEFAULT); | |
| 2028 gtk_widget_grab_default(rescan); | |
| 2029 | |
| 2030 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
| 2031 gtk_box_pack_start(GTK_BOX(bbox), jump, FALSE, FALSE, 0); | |
| 2032 | |
| 2033 g_signal_connect_swapped(jump, "clicked", | |
| 2034 G_CALLBACK(mainwin_jump_to_file_jump_cb), | |
| 2035 treeview); | |
| 2036 | |
| 2037 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
| 2038 gtk_widget_grab_default(jump); | |
| 2039 | |
| 2040 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
| 2041 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0); | |
| 2042 g_signal_connect_swapped(cancel, "clicked", | |
| 2043 G_CALLBACK(gtk_widget_destroy), | |
| 2044 mainwin_jtf); | |
| 2045 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
| 2046 | |
| 2047 gtk_list_store_clear(jtf_store); | |
| 2048 | |
| 2049 row = 1; | |
| 2050 | |
| 2051 PLAYLIST_LOCK(); | |
| 2052 | |
| 2053 for (playlist = playlist_get(); playlist; | |
| 2054 playlist = g_list_next(playlist)) { | |
| 2055 | |
| 2056 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
| 2057 | |
| 2058 if (entry->title) | |
| 2059 desc_buf = g_strdup(entry->title); | |
| 2060 else if (strchr(entry->filename, '/')) | |
| 2061 desc_buf = str_to_utf8(strrchr(entry->filename, '/') + 1); | |
| 2062 else | |
| 2063 desc_buf = str_to_utf8(entry->filename); | |
| 2064 | |
| 2065 row_str = g_strdup_printf("%d", row++); | |
| 2066 | |
| 2067 gtk_list_store_append(GTK_LIST_STORE(jtf_store), &iter); | |
| 2068 gtk_list_store_set(GTK_LIST_STORE(jtf_store), &iter, | |
| 2069 0, row_str, 1, desc_buf, -1); | |
| 2070 | |
| 2071 if (desc_buf) { | |
| 2072 g_free(desc_buf); | |
| 2073 desc_buf = NULL; | |
| 2074 } | |
| 2075 g_free(row_str); | |
| 2076 } | |
| 2077 | |
| 2078 PLAYLIST_UNLOCK(); | |
| 2079 | |
| 2080 gtk_widget_show_all(mainwin_jtf); | |
| 2081 } | |
| 2082 | |
| 2083 static gboolean | |
| 2084 mainwin_configure(GtkWidget * window, | |
| 2085 GdkEventConfigure * event, | |
| 2086 gpointer data) | |
| 2087 { | |
| 2088 if (!GTK_WIDGET_VISIBLE(window)) | |
| 2089 return FALSE; | |
| 2090 | |
| 2091 if (cfg.show_wm_decorations) | |
| 2092 gdk_window_get_root_origin(window->window, | |
| 2093 &cfg.player_x, &cfg.player_y); | |
| 2094 else | |
| 2095 gdk_window_get_deskrelative_origin(window->window, | |
| 2096 &cfg.player_x, &cfg.player_y); | |
| 2097 return FALSE; | |
| 2098 } | |
| 2099 | |
| 2100 void | |
| 2101 mainwin_set_back_pixmap(void) | |
| 2102 { | |
| 2103 gdk_window_set_back_pixmap(mainwin->window, mainwin_bg, 0); | |
| 2104 gdk_window_clear(mainwin->window); | |
| 2105 } | |
| 2106 | |
| 1673 | 2107 /* |
| 2108 * Rewritten 09/13/06: | |
| 2109 * | |
| 2110 * Remove all of this flaky iter/sourcelist/strsplit stuff. | |
| 2111 * All we care about is the filepath. | |
| 2112 * | |
| 2113 * We can figure this out and easily pass it to xmms_urldecode_plain(). | |
| 2114 * - nenolod | |
| 2115 */ | |
| 1653 | 2116 void |
| 2117 mainwin_drag_data_received(GtkWidget * widget, | |
| 2118 GdkDragContext * context, | |
| 2119 gint x, | |
| 2120 gint y, | |
| 2121 GtkSelectionData * selection_data, | |
| 2122 guint info, | |
| 2123 guint time, | |
| 2124 gpointer user_data) | |
| 2125 { | |
| 1673 | 2126 g_return_if_fail(selection_data != NULL); |
| 2127 g_return_if_fail(selection_data->data != NULL); | |
| 2128 | |
| 2129 if (str_has_prefix_nocase((gchar *) selection_data->data, "fonts:///")) | |
| 1653 | 2130 { |
| 1696 | 2131 gchar *path = (gchar *) selection_data->data + 9; /* skip fonts:/// */ |
| 1673 | 2132 gchar *decoded = xmms_urldecode_plain(path); |
| 2133 | |
| 1696 | 2134 cfg.playlist_font = g_strconcat(decoded, strrchr(cfg.playlist_font, ' '), NULL); |
| 1673 | 2135 playlist_list_set_font(cfg.playlist_font); |
| 2136 playlistwin_update_list(); | |
| 2137 | |
| 2138 g_free(decoded); | |
| 2139 | |
| 1653 | 2140 return; |
| 2141 } | |
| 2142 | |
| 1673 | 2143 playlist_clear(); |
| 2144 playlist_add_url((gchar *) selection_data->data); | |
| 2145 bmp_playback_initiate(); | |
| 1653 | 2146 } |
| 2147 | |
| 2148 static void | |
| 2149 on_add_url_add_clicked(GtkWidget * widget, | |
| 2150 GtkWidget * entry) | |
| 2151 { | |
| 2152 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
| 2153 if (text && *text) | |
| 2154 playlist_add_url(text); | |
| 2155 } | |
| 2156 | |
| 2157 static void | |
| 2158 on_add_url_ok_clicked(GtkWidget * widget, | |
| 2159 GtkWidget * entry) | |
| 2160 { | |
| 2161 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
| 2162 if (text && *text) | |
| 2163 { | |
| 2164 playlist_clear(); | |
| 2165 playlist_add_url(text); | |
| 2166 bmp_playback_initiate(); | |
| 2167 } | |
| 2168 } | |
| 2169 | |
| 2170 void | |
| 2171 mainwin_show_add_url_window(void) | |
| 2172 { | |
| 2173 static GtkWidget *url_window = NULL; | |
| 2174 | |
| 2175 if (!url_window) { | |
| 2176 url_window = | |
| 2177 util_add_url_dialog_new(_("Enter location to play:"), | |
| 2178 G_CALLBACK(on_add_url_ok_clicked), | |
| 2179 G_CALLBACK(on_add_url_add_clicked)); | |
| 2180 gtk_window_set_transient_for(GTK_WINDOW(url_window), | |
| 2181 GTK_WINDOW(mainwin)); | |
| 2182 g_signal_connect(url_window, "destroy", | |
| 2183 G_CALLBACK(gtk_widget_destroyed), | |
| 2184 &url_window); | |
| 2185 } | |
| 2186 | |
| 2187 gtk_window_present(GTK_WINDOW(url_window)); | |
| 2188 } | |
| 2189 | |
| 2190 static void | |
| 2191 check_set(GtkItemFactory * factory, | |
| 2192 const gchar * path, | |
| 2193 gboolean active) | |
| 2194 { | |
| 2195 GtkWidget *item = gtk_item_factory_get_widget(factory, path); | |
| 2196 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), active); | |
| 2197 } | |
| 2198 | |
| 2199 void | |
| 2200 mainwin_eject_pushed(void) | |
| 2201 { | |
| 2202 util_run_filebrowser(PLAY_BUTTON); | |
| 2203 } | |
| 2204 | |
| 2205 void | |
| 2206 mainwin_rev_pushed(void) | |
| 2207 { | |
| 2208 g_get_current_time(&cb_time); | |
| 2209 | |
| 2210 seek_initial_pos = hslider_get_position(mainwin_position); | |
| 2211 seek_state = MAINWIN_SEEK_REV; | |
| 2212 } | |
| 2213 | |
| 2214 void | |
| 2215 mainwin_rev_release(void) | |
| 2216 { | |
| 2217 GTimeVal now_time; | |
| 2218 GTimeVal delta_time; | |
| 2219 gulong now_dur; | |
| 2220 | |
| 2221 g_get_current_time(&now_time); | |
| 2222 | |
| 2223 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec; | |
| 2224 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec; | |
| 2225 | |
| 2226 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000)); | |
| 2227 | |
| 2228 if ( now_dur <= TRISTATE_THRESHOLD ) | |
| 2229 { | |
| 2230 /* interpret as 'skip to previous song' */ | |
| 2231 playlist_prev(); | |
| 2232 } | |
| 2233 else | |
| 2234 { | |
| 2235 /* interpret as 'seek' */ | |
| 2236 mainwin_position_release_cb( hslider_get_position(mainwin_position) ); | |
| 2237 } | |
| 2238 | |
| 2239 seek_state = MAINWIN_SEEK_NIL; | |
| 2240 } | |
| 2241 | |
| 2242 void | |
| 2243 mainwin_fwd_pushed(void) | |
| 2244 { | |
| 2245 g_get_current_time(&cb_time); | |
| 2246 | |
| 2247 seek_initial_pos = hslider_get_position(mainwin_position); | |
| 2248 seek_state = MAINWIN_SEEK_FWD; | |
| 2249 } | |
| 2250 | |
| 2251 void | |
| 2252 mainwin_fwd_release(void) | |
| 2253 { | |
| 2254 GTimeVal now_time; | |
| 2255 GTimeVal delta_time; | |
| 2256 gulong now_dur; | |
| 2257 | |
| 2258 g_get_current_time(&now_time); | |
| 2259 | |
| 2260 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec; | |
| 2261 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec; | |
| 2262 | |
| 2263 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000)); | |
| 2264 | |
| 2265 if ( now_dur <= TRISTATE_THRESHOLD ) | |
| 2266 { | |
| 2267 /* interpret as 'skip to previous song' */ | |
| 2268 playlist_next(); | |
| 2269 } | |
| 2270 else | |
| 2271 { | |
| 2272 /* interpret as 'seek' */ | |
| 2273 mainwin_position_release_cb( hslider_get_position(mainwin_position) ); | |
| 2274 } | |
| 2275 | |
| 2276 seek_state = MAINWIN_SEEK_NIL; | |
| 2277 } | |
| 2278 | |
| 2279 void | |
| 2280 mainwin_play_pushed(void) | |
| 2281 { | |
| 2282 if (bmp_playback_get_paused()) { | |
| 2283 bmp_playback_pause(); | |
| 2284 return; | |
| 2285 } | |
| 2286 | |
| 2287 if (playlist_get_length()) | |
| 2288 bmp_playback_initiate(); | |
| 2289 else | |
| 2290 mainwin_eject_pushed(); | |
| 2291 } | |
| 2292 | |
| 2293 void | |
| 2294 mainwin_stop_pushed(void) | |
| 2295 { | |
| 2296 ip_data.stop = TRUE; | |
| 2297 mainwin_clear_song_info(); | |
| 2298 bmp_playback_stop(); | |
| 2299 ip_data.stop = FALSE; | |
| 2300 } | |
| 2301 | |
| 2302 void | |
| 2303 mainwin_shuffle_pushed(gboolean toggled) | |
| 2304 { | |
| 2305 check_set(mainwin_play_menu, "/Shuffle", toggled); | |
| 2306 } | |
| 2307 | |
| 2308 void | |
| 2309 mainwin_repeat_pushed(gboolean toggled) | |
| 2310 { | |
| 2311 check_set(mainwin_play_menu, "/Repeat", toggled); | |
| 2312 } | |
| 2313 | |
| 2314 void | |
| 2315 mainwin_pl_pushed(gboolean toggled) | |
| 2316 { | |
| 2317 if (toggled) | |
| 2318 playlistwin_show(); | |
| 2319 else | |
| 2320 playlistwin_hide(); | |
| 2321 } | |
| 2322 | |
| 2323 gint | |
| 2324 mainwin_spos_frame_cb(gint pos) | |
| 2325 { | |
| 2326 if (mainwin_sposition) { | |
| 2327 if (pos < 6) | |
| 2328 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
| 2329 17; | |
| 2330 else if (pos < 9) | |
| 2331 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
| 2332 20; | |
| 2333 else | |
| 2334 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
| 2335 23; | |
| 2336 } | |
| 2337 return 1; | |
| 2338 } | |
| 2339 | |
| 2340 void | |
| 2341 mainwin_spos_motion_cb(gint pos) | |
| 2342 { | |
| 2343 gint time; | |
| 2344 gchar *time_msg; | |
| 2345 | |
| 2346 pos--; | |
| 2347 | |
| 2348 time = ((playlist_get_current_length() / 1000) * pos) / 12; | |
| 2349 | |
| 2350 if (cfg.timer_mode == TIMER_REMAINING) { | |
| 2351 time = (playlist_get_current_length() / 1000) - time; | |
| 2352 time_msg = g_strdup_printf("-%2.2d", time / 60); | |
| 2353 textbox_set_text(mainwin_stime_min, time_msg); | |
| 2354 g_free(time_msg); | |
| 2355 } | |
| 2356 else { | |
| 2357 time_msg = g_strdup_printf(" %2.2d", time / 60); | |
| 2358 textbox_set_text(mainwin_stime_min, time_msg); | |
| 2359 g_free(time_msg); | |
| 2360 } | |
| 2361 | |
| 2362 time_msg = g_strdup_printf("%2.2d", time % 60); | |
| 2363 textbox_set_text(mainwin_stime_sec, time_msg); | |
| 2364 g_free(time_msg); | |
| 2365 } | |
| 2366 | |
| 2367 void | |
| 2368 mainwin_spos_release_cb(gint pos) | |
| 2369 { | |
| 2370 bmp_playback_seek(((playlist_get_current_length() / 1000) * | |
| 2371 (pos - 1)) / 12); | |
| 2372 } | |
| 2373 | |
| 2374 void | |
| 2375 mainwin_position_motion_cb(gint pos) | |
| 2376 { | |
| 2377 gint length, time; | |
| 2378 gchar *seek_msg; | |
| 2379 | |
| 2380 length = playlist_get_current_length() / 1000; | |
| 2381 time = (length * pos) / 219; | |
| 2382 seek_msg = g_strdup_printf(_("SEEK TO: %d:%-2.2d/%d:%-2.2d (%d%%)"), | |
| 2383 time / 60, time % 60, | |
| 2384 length / 60, length % 60, | |
| 2385 (length != 0) ? (time * 100) / length : 0); | |
| 2386 mainwin_lock_info_text(seek_msg); | |
| 2387 g_free(seek_msg); | |
| 2388 } | |
| 2389 | |
| 2390 void | |
| 2391 mainwin_position_release_cb(gint pos) | |
| 2392 { | |
| 2393 gint length, time; | |
| 2394 | |
| 2395 length = playlist_get_current_length() / 1000; | |
| 2396 time = (length * pos) / 219; | |
| 2397 bmp_playback_seek(time); | |
| 2398 mainwin_release_info_text(); | |
| 2399 } | |
| 2400 | |
| 2401 gint | |
| 2402 mainwin_volume_frame_cb(gint pos) | |
| 2403 { | |
| 2404 return (gint) rint((pos / 52.0) * 28); | |
| 2405 } | |
| 2406 | |
| 2407 void | |
| 2408 mainwin_adjust_volume_motion(gint v) | |
| 2409 { | |
| 2410 gchar *volume_msg; | |
| 2411 | |
| 2412 setting_volume = TRUE; | |
| 2413 | |
| 2414 volume_msg = g_strdup_printf(_("VOLUME: %d%%"), v); | |
| 2415 mainwin_lock_info_text(volume_msg); | |
| 2416 g_free(volume_msg); | |
| 2417 | |
| 2418 if (balance < 0) | |
| 2419 input_set_volume(v, (v * (100 - abs(balance))) / 100); | |
| 2420 else if (balance > 0) | |
| 2421 input_set_volume((v * (100 - abs(balance))) / 100, v); | |
| 2422 else | |
| 2423 input_set_volume(v, v); | |
| 2424 } | |
| 2425 | |
| 2426 void | |
| 2427 mainwin_adjust_volume_release(void) | |
| 2428 { | |
| 2429 mainwin_release_info_text(); | |
| 2430 setting_volume = FALSE; | |
| 2431 read_volume(VOLUME_ADJUSTED); | |
| 2432 } | |
| 2433 | |
| 2434 void | |
| 2435 mainwin_adjust_balance_motion(gint b) | |
| 2436 { | |
| 2437 gchar *balance_msg; | |
| 2438 gint v, pvl, pvr; | |
| 2439 | |
| 2440 setting_volume = TRUE; | |
| 2441 balance = b; | |
| 2442 input_get_volume(&pvl, &pvr); | |
| 2443 v = MAX(pvl, pvr); | |
| 2444 if (b < 0) { | |
| 2445 balance_msg = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b); | |
| 2446 input_set_volume(v, (gint) rint(((100 + b) / 100.0) * v)); | |
| 2447 } | |
| 2448 else if (b == 0) { | |
| 2449 balance_msg = g_strdup_printf(_("BALANCE: CENTER")); | |
| 2450 input_set_volume(v, v); | |
| 2451 } | |
| 2452 else { /* b > 0 */ | |
| 2453 balance_msg = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b); | |
| 2454 input_set_volume((gint) rint(((100 - b) / 100.0) * v), v); | |
| 2455 } | |
| 2456 mainwin_lock_info_text(balance_msg); | |
| 2457 g_free(balance_msg); | |
| 2458 } | |
| 2459 | |
| 2460 void | |
| 2461 mainwin_adjust_balance_release(void) | |
| 2462 { | |
| 2463 mainwin_release_info_text(); | |
| 2464 setting_volume = FALSE; | |
| 2465 read_volume(VOLUME_ADJUSTED); | |
| 2466 } | |
| 2467 | |
| 2468 void | |
| 2469 mainwin_set_volume_slider(gint percent) | |
| 2470 { | |
| 2471 hslider_set_position(mainwin_volume, (gint) rint((percent * 51) / 100.0)); | |
| 2472 } | |
| 2473 | |
| 2474 void | |
| 2475 mainwin_set_balance_slider(gint percent) | |
| 2476 { | |
| 2477 hslider_set_position(mainwin_balance, | |
| 2478 (gint) rint(((percent * 12) / 100.0) + 12)); | |
| 2479 } | |
| 2480 | |
| 2481 void | |
| 2482 mainwin_volume_motion_cb(gint pos) | |
| 2483 { | |
| 2484 gint vol = (pos * 100) / 51; | |
| 2485 mainwin_adjust_volume_motion(vol); | |
| 2486 equalizerwin_set_volume_slider(vol); | |
| 2487 } | |
| 2488 | |
| 2489 void | |
| 2490 mainwin_volume_release_cb(gint pos) | |
| 2491 { | |
| 2492 mainwin_adjust_volume_release(); | |
| 2493 } | |
| 2494 | |
| 2495 gint | |
| 2496 mainwin_balance_frame_cb(gint pos) | |
| 2497 { | |
| 2498 return ((abs(pos - 12) * 28) / 13); | |
| 2499 } | |
| 2500 | |
| 2501 void | |
| 2502 mainwin_balance_motion_cb(gint pos) | |
| 2503 { | |
| 2504 gint bal = ((pos - 12) * 100) / 12; | |
| 2505 mainwin_adjust_balance_motion(bal); | |
| 2506 equalizerwin_set_balance_slider(bal); | |
| 2507 } | |
| 2508 | |
| 2509 void | |
| 2510 mainwin_balance_release_cb(gint pos) | |
| 2511 { | |
| 2512 mainwin_adjust_volume_release(); | |
| 2513 } | |
| 2514 | |
| 2515 void | |
| 2516 mainwin_set_volume_diff(gint diff) | |
| 2517 { | |
| 2518 gint vl, vr, vol; | |
| 2519 | |
| 2520 input_get_volume(&vl, &vr); | |
| 2521 vol = MAX(vl, vr); | |
| 2522 vol = CLAMP(vol + diff, 0, 100); | |
| 2523 | |
| 2524 mainwin_adjust_volume_motion(vol); | |
| 2525 setting_volume = FALSE; | |
| 2526 mainwin_set_volume_slider(vol); | |
| 2527 equalizerwin_set_volume_slider(vol); | |
| 2528 read_volume(VOLUME_SET); | |
| 2529 } | |
| 2530 | |
| 2531 void | |
| 2532 mainwin_set_balance_diff(gint diff) | |
| 2533 { | |
| 2534 gint b; | |
| 2535 b = CLAMP(balance + diff, -100, 100); | |
| 2536 mainwin_adjust_balance_motion(b); | |
| 2537 setting_volume = FALSE; | |
| 2538 mainwin_set_balance_slider(b); | |
| 2539 equalizerwin_set_balance_slider(b); | |
| 2540 read_volume(VOLUME_SET); | |
| 2541 } | |
| 2542 | |
| 2543 void | |
| 2544 mainwin_show(gboolean show) | |
| 2545 { | |
| 2546 if (show) | |
| 2547 mainwin_real_show(); | |
| 2548 else | |
| 2549 mainwin_real_hide(); | |
| 2550 } | |
| 2551 | |
| 2552 void | |
| 2553 mainwin_real_show(void) | |
| 2554 { | |
| 2555 cfg.player_visible = TRUE; | |
| 2556 | |
| 2557 check_set(mainwin_view_menu, "/Show Player", TRUE); | |
| 2558 | |
| 2559 if (cfg.player_shaded) | |
| 2560 vis_clear_data(active_vis); | |
| 2561 | |
| 2562 mainwin_vis_set_active_vis(MAINWIN_VIS_ACTIVE_MAINWIN); | |
| 2563 mainwin_set_shape_mask(); | |
| 2564 | |
| 2565 if (cfg.show_wm_decorations) { | |
| 2566 if (!pposition_broken && cfg.player_x != -1 | |
| 2567 && cfg.save_window_position) | |
| 2568 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
| 2569 | |
| 2570 gtk_widget_show(mainwin); | |
| 2571 | |
| 2572 if (pposition_broken && cfg.player_x != -1 | |
| 2573 && cfg.save_window_position) | |
| 2574 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
| 2575 | |
| 2576 return; | |
| 2577 } | |
| 2578 | |
| 2579 gtk_widget_show_all(mainwin); | |
| 2580 | |
| 2581 if (!nullmask) | |
| 2582 return; | |
| 2583 | |
| 2584 g_object_unref(nullmask); | |
| 2585 nullmask = NULL; | |
| 2586 | |
| 2587 gdk_window_set_hints(mainwin->window, 0, 0, | |
| 1805 | 2588 !bmp_active_skin->properties.mainwin_width ? PLAYER_WIDTH : |
| 2589 bmp_active_skin->properties.mainwin_width, | |
| 2590 !bmp_active_skin->properties.mainwin_height ? PLAYER_HEIGHT : | |
| 2591 bmp_active_skin->properties.mainwin_height, | |
| 2592 !bmp_active_skin->properties.mainwin_width ? PLAYER_WIDTH : | |
| 2593 bmp_active_skin->properties.mainwin_width, | |
| 2594 !bmp_active_skin->properties.mainwin_height ? PLAYER_HEIGHT : | |
| 2595 bmp_active_skin->properties.mainwin_height, | |
| 1653 | 2596 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); |
|
1808
ae21feb9459c
[svn] - make sure all size requests match the skin size
nenolod
parents:
1806
diff
changeset
|
2597 gtk_window_resize(GTK_WINDOW(mainwin), |
|
ae21feb9459c
[svn] - make sure all size requests match the skin size
nenolod
parents:
1806
diff
changeset
|
2598 !bmp_active_skin->properties.mainwin_width ? PLAYER_WIDTH : |
|
ae21feb9459c
[svn] - make sure all size requests match the skin size
nenolod
parents:
1806
diff
changeset
|
2599 bmp_active_skin->properties.mainwin_width, |
|
ae21feb9459c
[svn] - make sure all size requests match the skin size
nenolod
parents:
1806
diff
changeset
|
2600 !bmp_active_skin->properties.mainwin_height ? PLAYER_HEIGHT : |
|
ae21feb9459c
[svn] - make sure all size requests match the skin size
nenolod
parents:
1806
diff
changeset
|
2601 bmp_active_skin->properties.mainwin_height); |
| 1653 | 2602 if (cfg.player_x != -1 && cfg.player_y != -1) |
| 2603 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
| 2604 | |
| 2605 draw_main_window(TRUE); | |
| 2606 | |
| 2607 gtk_window_present(GTK_WINDOW(mainwin)); | |
| 2608 } | |
| 2609 | |
| 2610 void | |
| 2611 mainwin_real_hide(void) | |
| 2612 { | |
| 2613 GdkGC *gc; | |
| 2614 GdkColor pattern; | |
| 2615 | |
| 2616 check_set(mainwin_view_menu, "/Show Player", FALSE); | |
| 2617 | |
| 2618 if (cfg.player_shaded) | |
| 2619 svis_clear_data(mainwin_svis); | |
| 2620 | |
| 2621 if (!cfg.show_wm_decorations) { | |
| 2622 nullmask = gdk_pixmap_new(mainwin->window, 20, 20, 1); | |
| 2623 gc = gdk_gc_new(nullmask); | |
| 2624 pattern.pixel = 0; | |
| 2625 gdk_gc_set_foreground(gc, &pattern); | |
| 2626 gdk_draw_rectangle(nullmask, gc, TRUE, 0, 0, 20, 20); | |
| 2627 gdk_gc_destroy(gc); | |
| 2628 gtk_widget_shape_combine_mask(mainwin, nullmask, 0, 0); | |
| 2629 | |
| 2630 gdk_window_set_hints(mainwin->window, 0, 0, 0, 0, 0, 0, | |
| 2631 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); | |
| 2632 gdk_window_resize(mainwin->window, 0, 0); | |
| 2633 } | |
| 2634 | |
| 2635 gtk_widget_hide(mainwin); | |
| 2636 | |
| 2637 mainwin_vis_set_active_vis(MAINWIN_VIS_ACTIVE_PLAYLISTWIN); | |
| 2638 cfg.player_visible = FALSE; | |
| 2639 } | |
| 2640 | |
| 2641 static void | |
| 2642 mainwin_songname_menu_callback(gpointer data, | |
| 2643 guint action, | |
| 2644 GtkWidget * item) | |
| 2645 { | |
| 2646 GtkCheckMenuItem *check; | |
| 2647 | |
| 2648 switch (action) { | |
| 2649 case MAINWIN_SONGNAME_FILEINFO: | |
| 2650 playlist_fileinfo_current(); | |
| 2651 break; | |
| 2652 case MAINWIN_SONGNAME_JTF: | |
| 2653 mainwin_jump_to_file(); | |
| 2654 break; | |
| 2655 case MAINWIN_SONGNAME_JTT: | |
| 2656 mainwin_jump_to_time(); | |
| 2657 break; | |
| 2658 case MAINWIN_SONGNAME_SCROLL: | |
| 2659 check = GTK_CHECK_MENU_ITEM(item); | |
| 2660 mainwin_set_title_scroll(gtk_check_menu_item_get_active(check)); | |
| 1775 | 2661 check_set(mainwin_view_menu, "/Autoscroll Songname", cfg.autoscroll); |
| 2662 playlistwin_set_sinfo_scroll(cfg.autoscroll); /* propagate scroll setting to playlistwin_sinfo */ | |
| 1653 | 2663 break; |
| 2664 case MAINWIN_SONGNAME_STOPAFTERSONG: | |
| 2665 check = GTK_CHECK_MENU_ITEM(item); | |
| 2666 cfg.stopaftersong = gtk_check_menu_item_get_active(check); | |
| 2667 check_set(mainwin_songname_menu, "/Stop After Current Song", cfg.stopaftersong); | |
| 2668 check_set(mainwin_play_menu, "/Stop After Current Song", cfg.stopaftersong); | |
| 2669 break; | |
| 2670 } | |
| 2671 } | |
| 2672 | |
| 2673 void | |
| 2674 mainwin_set_stopaftersong(gboolean stop) | |
| 2675 { | |
| 2676 cfg.stopaftersong = stop; | |
| 2677 check_set(mainwin_songname_menu, "/Stop After Current Song", cfg.stopaftersong); | |
| 2678 } | |
| 2679 | |
| 2680 static void | |
| 2681 mainwin_play_menu_callback(gpointer data, | |
| 2682 guint action, | |
| 2683 GtkWidget * item) | |
| 2684 { | |
| 2685 GtkCheckMenuItem *check; | |
| 2686 | |
| 2687 switch (action) { | |
| 2688 case MAINWIN_OPT_SHUFFLE: | |
| 2689 check = GTK_CHECK_MENU_ITEM(item); | |
| 2690 cfg.shuffle = gtk_check_menu_item_get_active(check); | |
| 2691 playlist_set_shuffle(cfg.shuffle); | |
| 2692 tbutton_set_toggled(mainwin_shuffle, cfg.shuffle); | |
| 2693 break; | |
| 2694 case MAINWIN_OPT_REPEAT: | |
| 2695 check = GTK_CHECK_MENU_ITEM(item); | |
| 2696 cfg.repeat = gtk_check_menu_item_get_active(check); | |
| 2697 tbutton_set_toggled(mainwin_repeat, cfg.repeat); | |
| 2698 break; | |
| 2699 case MAINWIN_OPT_NPA: | |
| 2700 check = GTK_CHECK_MENU_ITEM(item); | |
| 2701 cfg.no_playlist_advance = gtk_check_menu_item_get_active(check); | |
| 2702 break; | |
| 2703 } | |
| 2704 } | |
| 2705 | |
| 2706 | |
| 2707 static void | |
| 2708 mainwin_view_menu_callback(gpointer data, | |
| 2709 guint action, | |
| 2710 GtkWidget * item) | |
| 2711 { | |
| 1775 | 2712 GtkCheckMenuItem *check; |
| 2713 | |
| 1653 | 2714 switch (action) { |
| 2715 case MAINWIN_OPT_TELAPSED: | |
| 2716 set_timer_mode_menu_cb(TIMER_ELAPSED); | |
| 2717 break; | |
| 2718 case MAINWIN_OPT_TREMAINING: | |
| 2719 set_timer_mode_menu_cb(TIMER_REMAINING); | |
| 2720 break; | |
| 2721 case MAINWIN_OPT_ALWAYS: | |
| 2722 mainwin_menurow->mr_always_selected = GTK_CHECK_MENU_ITEM(item)->active; | |
| 2723 cfg.always_on_top = mainwin_menurow->mr_always_selected; | |
| 2724 widget_draw(WIDGET(mainwin_menurow)); | |
| 2725 | |
| 2726 if (starting_up == FALSE) | |
| 2727 hint_set_always(cfg.always_on_top); | |
| 2728 | |
| 2729 break; | |
| 2730 case MAINWIN_OPT_STICKY: | |
| 2731 cfg.sticky = GTK_CHECK_MENU_ITEM(item)->active; | |
| 2732 hint_set_sticky(cfg.sticky); | |
| 2733 break; | |
| 2734 case MAINWIN_OPT_WS: | |
| 2735 mainwin_set_shade_menu_cb(GTK_CHECK_MENU_ITEM(item)->active); | |
| 2736 break; | |
| 2737 case MAINWIN_OPT_PWS: | |
| 2738 playlistwin_set_shade(GTK_CHECK_MENU_ITEM(item)->active); | |
| 2739 break; | |
| 2740 case MAINWIN_OPT_EQWS: | |
| 2741 equalizerwin_set_shade_menu_cb(GTK_CHECK_MENU_ITEM(item)->active); | |
| 2742 break; | |
| 1775 | 2743 case MAINWIN_SONGNAME_SCROLL: |
| 2744 check = GTK_CHECK_MENU_ITEM(item); | |
| 2745 mainwin_set_title_scroll(gtk_check_menu_item_get_active(check)); | |
| 2746 check_set(mainwin_songname_menu, "/Autoscroll Songname", cfg.autoscroll); | |
| 2747 playlistwin_set_sinfo_scroll(cfg.autoscroll); /* propagate scroll setting to playlistwin_sinfo */ | |
| 2748 break; | |
| 1653 | 2749 } |
| 2750 } | |
| 2751 | |
| 2752 void | |
| 2753 mainwin_vis_menu_callback(gpointer data, | |
| 2754 guint action, | |
| 2755 GtkWidget * item) | |
| 2756 { | |
| 2757 switch (action) { | |
| 2758 case MAINWIN_VIS_ANALYZER: | |
| 2759 case MAINWIN_VIS_SCOPE: | |
| 2760 case MAINWIN_VIS_OFF: | |
| 2761 mainwin_vis_set_type_menu_cb(action - MAINWIN_VIS_ANALYZER); | |
| 2762 break; | |
| 2763 case MAINWIN_VIS_ANALYZER_NORMAL: | |
| 2764 case MAINWIN_VIS_ANALYZER_FIRE: | |
| 2765 case MAINWIN_VIS_ANALYZER_VLINES: | |
| 2766 mainwin_vis_set_analyzer_mode(action - MAINWIN_VIS_ANALYZER_NORMAL); | |
| 2767 break; | |
| 2768 case MAINWIN_VIS_ANALYZER_LINES: | |
| 2769 case MAINWIN_VIS_ANALYZER_BARS: | |
| 2770 mainwin_vis_set_analyzer_type(action - MAINWIN_VIS_ANALYZER_LINES); | |
| 2771 break; | |
| 2772 case MAINWIN_VIS_ANALYZER_PEAKS: | |
| 2773 cfg.analyzer_peaks = GTK_CHECK_MENU_ITEM(item)->active; | |
| 2774 break; | |
| 2775 case MAINWIN_VIS_SCOPE_DOT: | |
| 2776 case MAINWIN_VIS_SCOPE_LINE: | |
| 2777 case MAINWIN_VIS_SCOPE_SOLID: | |
| 2778 cfg.scope_mode = action - MAINWIN_VIS_SCOPE_DOT; | |
| 2779 break; | |
| 2780 case MAINWIN_VIS_VU_NORMAL: | |
| 2781 case MAINWIN_VIS_VU_SMOOTH: | |
| 2782 cfg.vu_mode = action - MAINWIN_VIS_VU_NORMAL; | |
| 2783 break; | |
| 2784 case MAINWIN_VIS_REFRESH_FULL: | |
| 2785 case MAINWIN_VIS_REFRESH_HALF: | |
| 2786 case MAINWIN_VIS_REFRESH_QUARTER: | |
| 2787 case MAINWIN_VIS_REFRESH_EIGHTH: | |
| 2788 mainwin_vis_set_refresh(action - MAINWIN_VIS_REFRESH_FULL); | |
| 2789 break; | |
| 2790 case MAINWIN_VIS_AFALLOFF_SLOWEST: | |
| 2791 case MAINWIN_VIS_AFALLOFF_SLOW: | |
| 2792 case MAINWIN_VIS_AFALLOFF_MEDIUM: | |
| 2793 case MAINWIN_VIS_AFALLOFF_FAST: | |
| 2794 case MAINWIN_VIS_AFALLOFF_FASTEST: | |
| 2795 mainwin_vis_set_afalloff(action - MAINWIN_VIS_AFALLOFF_SLOWEST); | |
| 2796 break; | |
| 2797 case MAINWIN_VIS_PFALLOFF_SLOWEST: | |
| 2798 case MAINWIN_VIS_PFALLOFF_SLOW: | |
| 2799 case MAINWIN_VIS_PFALLOFF_MEDIUM: | |
| 2800 case MAINWIN_VIS_PFALLOFF_FAST: | |
| 2801 case MAINWIN_VIS_PFALLOFF_FASTEST: | |
| 2802 mainwin_vis_set_pfalloff(action - MAINWIN_VIS_PFALLOFF_SLOWEST); | |
| 2803 break; | |
| 2804 } | |
| 2805 } | |
| 2806 | |
| 2807 void | |
| 2808 mainwin_general_menu_callback(gpointer data, | |
| 2809 guint action, | |
| 2810 GtkWidget * item) | |
| 2811 { | |
| 2812 switch (action) { | |
| 2813 case MAINWIN_GENERAL_PREFS: | |
| 2814 show_prefs_window(); | |
| 2815 break; | |
| 2816 case MAINWIN_GENERAL_ABOUT: | |
| 2817 show_about_window(); | |
| 2818 break; | |
| 2819 case MAINWIN_GENERAL_PLAYFILE: | |
| 2820 util_run_filebrowser(NO_PLAY_BUTTON); | |
| 2821 break; | |
| 2822 case MAINWIN_GENERAL_PLAYCD: | |
| 2823 play_medium(); | |
| 2824 break; | |
| 2825 case MAINWIN_GENERAL_ADDCD: | |
| 2826 add_medium(); | |
| 2827 break; | |
| 2828 case MAINWIN_GENERAL_PLAYLOCATION: | |
| 2829 mainwin_show_add_url_window(); | |
| 2830 break; | |
| 2831 case MAINWIN_GENERAL_FILEINFO: | |
| 2832 playlist_fileinfo_current(); | |
| 2833 break; | |
| 2834 case MAINWIN_GENERAL_FOCUSPLWIN: | |
| 2835 gtk_window_present(GTK_WINDOW(playlistwin)); | |
| 2836 break; | |
| 2837 case MAINWIN_GENERAL_SHOWMWIN: | |
| 2838 mainwin_show(GTK_CHECK_MENU_ITEM(item)->active); | |
| 2839 break; | |
| 2840 case MAINWIN_GENERAL_SHOWPLWIN: | |
| 2841 if (GTK_CHECK_MENU_ITEM(item)->active) | |
| 2842 playlistwin_show(); | |
| 2843 else | |
| 2844 playlistwin_hide(); | |
| 2845 break; | |
| 2846 case MAINWIN_GENERAL_SHOWEQWIN: | |
| 2847 if (GTK_CHECK_MENU_ITEM(item)->active) | |
| 2848 equalizerwin_real_show(); | |
| 2849 else | |
| 2850 equalizerwin_real_hide(); | |
| 2851 break; | |
| 2852 case MAINWIN_GENERAL_PREV: | |
| 2853 playlist_prev(); | |
| 2854 break; | |
| 2855 case MAINWIN_GENERAL_PLAY: | |
| 2856 mainwin_play_pushed(); | |
| 2857 break; | |
| 2858 case MAINWIN_GENERAL_PAUSE: | |
| 2859 bmp_playback_pause(); | |
| 2860 break; | |
| 2861 case MAINWIN_GENERAL_STOP: | |
| 2862 mainwin_stop_pushed(); | |
| 2863 break; | |
| 2864 case MAINWIN_GENERAL_NEXT: | |
| 2865 playlist_next(); | |
| 2866 break; | |
| 2867 case MAINWIN_GENERAL_BACK5SEC: | |
| 2868 if (bmp_playback_get_playing() | |
| 2869 && playlist_get_current_length() != -1) | |
| 2870 bmp_playback_seek_relative(-5); | |
| 2871 break; | |
| 2872 case MAINWIN_GENERAL_FWD5SEC: | |
| 2873 if (bmp_playback_get_playing() | |
| 2874 && playlist_get_current_length() != -1) | |
| 2875 bmp_playback_seek_relative(5); | |
| 2876 break; | |
| 2877 case MAINWIN_GENERAL_START: | |
| 2878 playlist_set_position(0); | |
| 2879 break; | |
| 2880 case MAINWIN_GENERAL_JTT: | |
| 2881 mainwin_jump_to_time(); | |
| 2882 break; | |
| 2883 case MAINWIN_GENERAL_JTF: | |
| 2884 mainwin_jump_to_file(); | |
| 2885 break; | |
| 2886 case MAINWIN_GENERAL_EXIT: | |
| 2887 mainwin_quit_cb(); | |
| 2888 break; | |
| 2889 } | |
| 2890 } | |
| 2891 | |
| 2892 static void | |
| 2893 mainwin_mr_change(MenuRowItem i) | |
| 2894 { | |
| 2895 switch (i) { | |
| 2896 case MENUROW_NONE: | |
| 2897 mainwin_set_info_text(); | |
| 2898 break; | |
| 2899 case MENUROW_OPTIONS: | |
| 2900 mainwin_lock_info_text(_("OPTIONS MENU")); | |
| 2901 break; | |
| 2902 case MENUROW_ALWAYS: | |
| 2903 if (mainwin_menurow->mr_always_selected) | |
| 2904 mainwin_lock_info_text(_("DISABLE ALWAYS ON TOP")); | |
| 2905 else | |
| 2906 mainwin_lock_info_text(_("ENABLE ALWAYS ON TOP")); | |
| 2907 break; | |
| 2908 case MENUROW_FILEINFOBOX: | |
| 2909 mainwin_lock_info_text(_("FILE INFO BOX")); | |
| 2910 break; | |
| 2911 case MENUROW_DOUBLESIZE: | |
| 2912 mainwin_lock_info_text(_("** DOUBLESIZE HAS BEEN REMOVED **")); | |
| 2913 break; | |
| 2914 case MENUROW_VISUALIZATION: | |
| 2915 mainwin_lock_info_text(_("VISUALIZATION MENU")); | |
| 2916 break; | |
| 2917 } | |
| 2918 } | |
| 2919 | |
| 2920 static void | |
| 2921 mainwin_mr_release(MenuRowItem i) | |
| 2922 { | |
| 2923 GdkModifierType modmask; | |
| 2924 GtkWidget *widget; | |
| 2925 gint x, y; | |
| 2926 | |
| 2927 switch (i) { | |
| 2928 case MENUROW_OPTIONS: | |
| 2929 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
| 2930 util_item_factory_popup(mainwin_view_menu, x, y, 1, | |
| 2931 GDK_CURRENT_TIME); | |
| 2932 break; | |
| 2933 case MENUROW_ALWAYS: | |
| 2934 widget = | |
| 2935 gtk_item_factory_get_widget(mainwin_view_menu, | |
| 2936 "/Always On Top"); | |
| 2937 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), | |
| 2938 mainwin_menurow->mr_always_selected); | |
| 2939 break; | |
| 2940 case MENUROW_FILEINFOBOX: | |
| 2941 playlist_fileinfo_current(); | |
| 2942 break; | |
| 2943 case MENUROW_DOUBLESIZE: | |
| 2944 /* double size removed, do nothing */ | |
| 2945 break; | |
| 2946 case MENUROW_VISUALIZATION: | |
| 2947 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
| 2948 util_item_factory_popup(mainwin_vis_menu, x, y, 1, GDK_CURRENT_TIME); | |
| 2949 break; | |
| 2950 case MENUROW_NONE: | |
| 2951 break; | |
| 2952 } | |
| 2953 mainwin_release_info_text(); | |
| 2954 } | |
| 2955 | |
| 2956 static void | |
| 2957 run_no_audiocd_dialog(void) | |
| 2958 { | |
| 2959 const gchar *markup = | |
| 2960 N_("<b><big>No playable CD found.</big></b>\n\n" | |
| 2961 "No CD inserted, or inserted CD is not an audio CD.\n"); | |
| 2962 | |
| 2963 GtkWidget *dialog = | |
| 2964 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
| 2965 GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 2966 GTK_MESSAGE_ERROR, | |
| 2967 GTK_BUTTONS_OK, | |
| 2968 _(markup)); | |
| 2969 gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 2970 gtk_widget_destroy(dialog); | |
| 2971 } | |
| 2972 | |
| 2973 static void | |
| 2974 run_no_output_device_dialog(void) | |
| 2975 { | |
| 2976 const gchar *markup = | |
| 2977 N_("<b><big>Couldn't open audio.</big></b>\n\n" | |
| 2978 "Please check that:\n" | |
| 2979 "1. You have the correct output plugin selected.\n" | |
| 2980 "2. No other programs is blocking the soundcard.\n" | |
| 2981 "3. Your soundcard is configured properly.\n"); | |
| 2982 | |
| 2983 GtkWidget *dialog = | |
| 2984 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
| 2985 GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 2986 GTK_MESSAGE_ERROR, | |
| 2987 GTK_BUTTONS_OK, | |
| 2988 _(markup)); | |
| 2989 gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 2990 gtk_widget_destroy(dialog); | |
| 2991 } | |
| 2992 | |
| 2993 | |
| 2994 void | |
| 2995 add_medium(void) | |
| 2996 { | |
| 2997 GList *list, *node; | |
| 2998 gchar *filename; | |
| 2999 gchar *path; | |
| 3000 ConfigDb *db; | |
| 3001 | |
| 3002 db = bmp_cfg_db_open(); | |
| 3003 | |
| 3004 bmp_cfg_db_get_string(db, "CDDA", "directory", &path); | |
| 3005 bmp_cfg_db_close(db); | |
| 3006 | |
| 3007 if (!(list = input_scan_dir(path))) { | |
| 3008 run_no_audiocd_dialog(); | |
| 3009 return; | |
| 3010 } | |
| 3011 | |
| 3012 for (node = list; node; node = g_list_next(node)) { | |
| 3013 filename = g_build_filename(path, node->data, NULL); | |
| 3014 playlist_add(filename); | |
| 3015 g_free(filename); | |
| 3016 g_free(node->data); | |
| 3017 } | |
| 3018 | |
| 3019 g_free(path); | |
| 3020 g_list_free(list); | |
| 3021 | |
| 3022 } | |
| 3023 | |
| 3024 void | |
| 3025 play_medium(void) | |
| 3026 { | |
| 3027 GList *list, *node; | |
| 3028 gchar *filename; | |
| 3029 gchar *path; | |
| 3030 ConfigDb *db; | |
| 3031 | |
| 3032 db = bmp_cfg_db_open(); | |
| 3033 bmp_cfg_db_get_string(db, "CDDA", "directory", &path); | |
| 3034 bmp_cfg_db_close(db); | |
| 3035 | |
| 3036 if (!(list = input_scan_dir(path))) { | |
| 3037 run_no_audiocd_dialog(); | |
| 3038 return; | |
| 3039 } | |
| 3040 | |
| 3041 playlist_clear(); | |
| 3042 | |
| 3043 for (node = list; node; node = g_list_next(node)) { | |
| 3044 filename = g_build_filename(path, node->data, NULL); | |
| 3045 playlist_add(filename); | |
| 3046 g_free(filename); | |
| 3047 g_free(node->data); | |
| 3048 } | |
| 3049 | |
| 3050 g_free(path); | |
| 3051 g_list_free(list); | |
| 3052 | |
| 3053 playlist_set_position(0); | |
| 3054 bmp_playback_initiate(); | |
| 3055 } | |
| 3056 | |
| 3057 void | |
| 3058 read_volume(gint when) | |
| 3059 { | |
| 3060 static gint pvl = 0, pvr = 0; | |
| 3061 static gint times = VOLSET_DISP_TIMES; | |
| 3062 static gboolean changing = FALSE; | |
| 3063 | |
| 3064 gint vl, vr, b, v; | |
| 3065 | |
| 3066 input_get_volume(&vl, &vr); | |
| 3067 | |
| 3068 switch (when) { | |
| 3069 case VOLSET_STARTUP: | |
| 3070 vl = CLAMP(vl, 0, 100); | |
| 3071 vr = CLAMP(vr, 0, 100); | |
| 3072 pvl = vl; | |
| 3073 pvr = vr; | |
| 3074 v = MAX(vl, vr); | |
| 3075 if (vl > vr) | |
| 3076 b = (gint) rint(((gdouble) vr / vl) * 100) - 100; | |
| 3077 else if (vl < vr) | |
| 3078 b = 100 - (gint) rint(((gdouble) vl / vr) * 100); | |
| 3079 else | |
| 3080 b = 0; | |
| 3081 | |
| 3082 balance = b; | |
| 3083 mainwin_set_volume_slider(v); | |
| 3084 equalizerwin_set_volume_slider(v); | |
| 3085 mainwin_set_balance_slider(b); | |
| 3086 equalizerwin_set_balance_slider(b); | |
| 3087 return; | |
| 3088 | |
| 3089 case VOLSET_UPDATE: | |
| 3090 if (vl == -1 || vr == -1) | |
| 3091 return; | |
| 3092 | |
| 3093 if (setting_volume) { | |
| 3094 pvl = vl; | |
| 3095 pvr = vr; | |
| 3096 return; | |
| 3097 } | |
| 3098 | |
| 3099 if (pvr == vr && pvl == vl && changing) { | |
| 3100 if (times < VOLSET_DISP_TIMES) | |
| 3101 times++; | |
| 3102 else { | |
| 3103 mainwin_release_info_text(); | |
| 3104 changing = FALSE; | |
| 3105 } | |
| 3106 } | |
| 3107 else if (pvr != vr || pvl != vl) { | |
| 3108 gchar *tmp; | |
| 3109 | |
| 3110 v = MAX(vl, vr); | |
| 3111 if (vl > vr) | |
| 3112 b = (gint) rint(((gdouble) vr / vl) * 100) - 100; | |
| 3113 else if (vl < vr) | |
| 3114 b = 100 - (gint) rint(((gdouble) vl / vr) * 100); | |
| 3115 else | |
| 3116 b = 0; | |
| 3117 | |
| 3118 if (MAX(vl, vr) != MAX(pvl, pvr)) | |
| 3119 tmp = g_strdup_printf(_("VOLUME: %d%%"), v); | |
| 3120 else { | |
| 3121 if (vl > vr) { | |
| 3122 tmp = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b); | |
| 3123 } | |
| 3124 else if (vr == vl) | |
| 3125 tmp = g_strdup_printf(_("BALANCE: CENTER")); | |
| 3126 else { /* (vl < vr) */ | |
| 3127 tmp = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b); | |
| 3128 } | |
| 3129 } | |
| 3130 mainwin_lock_info_text(tmp); | |
| 3131 g_free(tmp); | |
| 3132 | |
| 3133 pvr = vr; | |
| 3134 pvl = vl; | |
| 3135 times = 0; | |
| 3136 changing = TRUE; | |
| 3137 mainwin_set_volume_slider(v); | |
| 3138 equalizerwin_set_volume_slider(v); | |
| 3139 | |
| 3140 /* Don't change the balance slider if the volume has been | |
| 3141 * set to zero. The balance can be anything, and our best | |
| 3142 * guess is what is was before. */ | |
| 3143 if (v > 0) { | |
| 3144 balance = b; | |
| 3145 mainwin_set_balance_slider(b); | |
| 3146 equalizerwin_set_balance_slider(b); | |
| 3147 } | |
| 3148 } | |
| 3149 break; | |
| 3150 | |
| 3151 case VOLUME_ADJUSTED: | |
| 3152 pvl = vl; | |
| 3153 pvr = vr; | |
| 3154 break; | |
| 3155 | |
| 3156 case VOLUME_SET: | |
| 3157 times = 0; | |
| 3158 changing = TRUE; | |
| 3159 pvl = vl; | |
| 3160 pvr = vr; | |
| 3161 break; | |
| 3162 } | |
| 3163 } | |
| 3164 | |
| 3165 | |
| 3166 /* TODO: HAL! */ | |
| 3167 gboolean | |
| 3168 can_play_cd(void) | |
| 3169 { | |
| 3170 GList *ilist; | |
| 3171 | |
| 3172 for (ilist = get_input_list(); ilist; ilist = g_list_next(ilist)) { | |
| 3173 InputPlugin *ip = INPUT_PLUGIN(ilist->data); | |
| 3174 | |
| 3175 if (!g_ascii_strcasecmp(g_basename(ip->filename), | |
| 3176 PLUGIN_FILENAME("cdaudio"))) { | |
| 3177 return TRUE; | |
| 3178 } | |
| 3179 } | |
| 3180 | |
| 3181 return FALSE; | |
| 3182 } | |
| 3183 | |
| 3184 | |
| 3185 static void | |
| 3186 set_timer_mode(TimerMode mode) | |
| 3187 { | |
| 3188 if (mode == TIMER_ELAPSED) | |
| 3189 check_set(mainwin_view_menu, "/Time Elapsed", TRUE); | |
| 3190 else | |
| 3191 check_set(mainwin_view_menu, "/Time Remaining", TRUE); | |
| 3192 } | |
| 3193 | |
| 3194 static void | |
| 3195 set_timer_mode_menu_cb(TimerMode mode) | |
| 3196 { | |
| 3197 cfg.timer_mode = mode; | |
| 3198 } | |
| 3199 | |
| 3200 | |
| 3201 void | |
| 3202 mainwin_setup_menus(void) | |
| 3203 { | |
| 3204 set_timer_mode(cfg.timer_mode); | |
| 3205 | |
| 3206 /* View menu */ | |
| 3207 | |
| 3208 check_set(mainwin_view_menu, "/Always On Top", cfg.always_on_top); | |
| 3209 check_set(mainwin_view_menu, "/Put on All Workspaces", cfg.sticky); | |
| 3210 check_set(mainwin_view_menu, "/Roll up Player", cfg.player_shaded); | |
| 3211 check_set(mainwin_view_menu, "/Roll up Playlist Editor", cfg.playlist_shaded); | |
| 3212 check_set(mainwin_view_menu, "/Roll up Equalizer", cfg.equalizer_shaded); | |
| 3213 | |
| 3214 /* Songname menu */ | |
| 3215 | |
| 3216 check_set(mainwin_songname_menu, "/Autoscroll Songname", cfg.autoscroll); | |
| 3217 check_set(mainwin_songname_menu, "/Stop After Current Song", cfg.stopaftersong); | |
| 3218 | |
| 3219 /* Playback menu */ | |
| 3220 | |
| 3221 check_set(mainwin_play_menu, "/Repeat", cfg.repeat); | |
| 3222 check_set(mainwin_play_menu, "/Shuffle", cfg.shuffle); | |
| 3223 check_set(mainwin_play_menu, "/No Playlist Advance", cfg.no_playlist_advance); | |
| 3224 | |
| 3225 /* Visualization menu */ | |
| 3226 | |
| 3227 check_set(mainwin_vis_menu, | |
| 3228 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_VIS_MODE + | |
| 3229 cfg.vis_type].path, TRUE); | |
| 3230 check_set(mainwin_vis_menu, | |
| 3231 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_MODE + | |
| 3232 cfg.analyzer_mode].path, TRUE); | |
| 3233 check_set(mainwin_vis_menu, | |
| 3234 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_TYPE + | |
| 3235 cfg.analyzer_type].path, TRUE); | |
| 3236 check_set(mainwin_vis_menu, | |
| 3237 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_PEAKS]. | |
| 3238 path, cfg.analyzer_peaks); | |
| 3239 check_set(mainwin_vis_menu, | |
| 3240 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_SCOPE_MODE + | |
| 3241 cfg.scope_mode].path, TRUE); | |
| 3242 check_set(mainwin_vis_menu, | |
| 3243 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_WSHADEVU_MODE + | |
| 3244 cfg.vu_mode].path, TRUE); | |
| 3245 check_set(mainwin_vis_menu, | |
| 3246 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_REFRESH_RATE + | |
| 3247 cfg.vis_refresh].path, TRUE); | |
| 3248 check_set(mainwin_vis_menu, | |
| 3249 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_AFALLOFF + | |
| 3250 cfg.analyzer_falloff].path, TRUE); | |
| 3251 check_set(mainwin_vis_menu, | |
| 3252 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_PFALLOFF + | |
| 3253 cfg.peaks_falloff].path, TRUE); | |
| 3254 } | |
| 3255 | |
| 3256 static void | |
| 3257 mainwin_create_widgets(void) | |
| 3258 { | |
| 3259 mainwin_menubtn = | |
| 3260 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 6, 3, 9, 9, | |
| 3261 0, 0, 0, 9, mainwin_menubtn_cb, SKIN_TITLEBAR); | |
| 3262 mainwin_menubtn->pb_allow_draw = FALSE; | |
| 3263 mainwin_minimize = | |
| 3264 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 244, 3, 9, | |
| 3265 9, 9, 0, 9, 9, mainwin_minimize_cb, SKIN_TITLEBAR); | |
| 3266 mainwin_minimize->pb_allow_draw = FALSE; | |
| 3267 mainwin_shade = | |
| 3268 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 254, 3, 9, | |
| 3269 9, 0, cfg.player_shaded ? 27 : 18, 9, | |
| 3270 cfg.player_shaded ? 27 : 18, mainwin_shade_toggle, | |
| 3271 SKIN_TITLEBAR); | |
| 3272 mainwin_shade->pb_allow_draw = FALSE; | |
| 3273 mainwin_close = | |
| 3274 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 264, 3, 9, | |
| 3275 9, 18, 0, 18, 9, mainwin_quit_cb, SKIN_TITLEBAR); | |
| 3276 mainwin_close->pb_allow_draw = FALSE; | |
| 3277 | |
| 3278 mainwin_rew = | |
| 3279 create_pbutton_ex(&mainwin_wlist, mainwin_bg, mainwin_gc, 16, 88, 23, | |
| 3280 18, 0, 0, 0, 18, mainwin_rev_pushed, mainwin_rev_release, | |
| 3281 SKIN_CBUTTONS, SKIN_CBUTTONS); | |
| 3282 mainwin_play = | |
| 3283 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 39, 88, 23, | |
| 3284 18, 23, 0, 23, 18, mainwin_play_pushed, SKIN_CBUTTONS); | |
| 3285 mainwin_pause = | |
| 3286 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 62, 88, 23, | |
| 3287 18, 46, 0, 46, 18, bmp_playback_pause, SKIN_CBUTTONS); | |
| 3288 mainwin_stop = | |
| 3289 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 85, 88, 23, | |
| 3290 18, 69, 0, 69, 18, mainwin_stop_pushed, SKIN_CBUTTONS); | |
| 3291 #if 0 | |
| 3292 mainwin_fwd = | |
| 3293 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 108, 88, 22, | |
| 3294 18, 92, 0, 92, 18, playlist_next, SKIN_CBUTTONS); | |
| 3295 #endif | |
| 3296 mainwin_fwd = | |
| 3297 create_pbutton_ex(&mainwin_wlist, mainwin_bg, mainwin_gc, 108, 88, 22, | |
| 3298 18, 92, 0, 92, 18, mainwin_fwd_pushed, mainwin_fwd_release, | |
| 3299 SKIN_CBUTTONS, SKIN_CBUTTONS); | |
| 3300 | |
| 3301 mainwin_eject = | |
| 3302 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 136, 89, 22, | |
| 3303 16, 114, 0, 114, 16, mainwin_eject_pushed, | |
| 3304 SKIN_CBUTTONS); | |
| 3305 | |
| 3306 mainwin_srew = | |
| 3307 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 169, 4, 8, | |
| 3308 7, playlist_prev); | |
| 3309 mainwin_splay = | |
| 3310 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 177, 4, 10, | |
| 3311 7, mainwin_play_pushed); | |
| 3312 mainwin_spause = | |
| 3313 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 187, 4, 10, | |
| 3314 7, bmp_playback_pause); | |
| 3315 mainwin_sstop = | |
| 3316 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 197, 4, 9, | |
| 3317 7, mainwin_stop_pushed); | |
| 3318 mainwin_sfwd = | |
| 3319 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 206, 4, 8, | |
| 3320 7, playlist_next); | |
| 3321 mainwin_seject = | |
| 3322 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 216, 4, 9, | |
| 3323 7, mainwin_eject_pushed); | |
| 3324 | |
| 3325 mainwin_shuffle = | |
| 3326 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 164, 89, 46, | |
| 3327 15, 28, 0, 28, 15, 28, 30, 28, 45, | |
| 3328 mainwin_shuffle_pushed, SKIN_SHUFREP); | |
| 3329 | |
| 3330 mainwin_repeat = | |
| 3331 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 210, 89, 28, | |
| 3332 15, 0, 0, 0, 15, 0, 30, 0, 45, | |
| 3333 mainwin_repeat_pushed, SKIN_SHUFREP); | |
| 3334 | |
| 3335 mainwin_eq = | |
| 3336 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 219, 58, 23, | |
| 3337 12, 0, 61, 46, 61, 0, 73, 46, 73, equalizerwin_show, | |
| 3338 SKIN_SHUFREP); | |
| 3339 tbutton_set_toggled(mainwin_eq, cfg.equalizer_visible); | |
| 3340 mainwin_pl = | |
| 3341 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 242, 58, 23, | |
| 3342 12, 23, 61, 69, 61, 23, 73, 69, 73, | |
| 3343 mainwin_pl_pushed, SKIN_SHUFREP); | |
| 3344 tbutton_set_toggled(mainwin_pl, cfg.playlist_visible); | |
| 3345 | |
| 3346 mainwin_info = | |
| 3347 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 112, 27, | |
| 3348 153, 1, SKIN_TEXT); | |
| 3349 textbox_set_scroll(mainwin_info, cfg.autoscroll); | |
| 3350 textbox_set_xfont(mainwin_info, cfg.mainwin_use_xfont, cfg.mainwin_font); | |
| 3351 | |
| 3352 mainwin_othertext = | |
| 3353 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 112, 43, | |
| 3354 153, 1, SKIN_TEXT); | |
| 3355 | |
| 3356 mainwin_rate_text = | |
| 3357 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 111, 43, 15, | |
| 3358 0, SKIN_TEXT); | |
| 3359 mainwin_freq_text = | |
| 3360 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 156, 43, 10, | |
| 3361 0, SKIN_TEXT); | |
| 3362 | |
| 3363 mainwin_menurow = | |
| 3364 create_menurow(&mainwin_wlist, mainwin_bg, mainwin_gc, 10, 22, 304, | |
| 3365 0, 304, 44, mainwin_mr_change, mainwin_mr_release, | |
| 3366 SKIN_TITLEBAR); | |
| 3367 mainwin_menurow->mr_doublesize_selected = FALSE; | |
| 3368 mainwin_menurow->mr_always_selected = cfg.always_on_top; | |
| 3369 | |
| 3370 mainwin_volume = | |
| 3371 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 107, 57, 68, | |
| 3372 13, 15, 422, 0, 422, 14, 11, 15, 0, 0, 51, | |
| 3373 mainwin_volume_frame_cb, mainwin_volume_motion_cb, | |
| 3374 mainwin_volume_release_cb, SKIN_VOLUME); | |
| 3375 mainwin_balance = | |
| 3376 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 177, 57, 38, | |
| 3377 13, 15, 422, 0, 422, 14, 11, 15, 9, 0, 24, | |
| 3378 mainwin_balance_frame_cb, mainwin_balance_motion_cb, | |
| 3379 mainwin_balance_release_cb, SKIN_BALANCE); | |
| 3380 | |
| 3381 mainwin_monostereo = | |
| 3382 create_monostereo(&mainwin_wlist, mainwin_bg, mainwin_gc, 212, 41, | |
| 3383 SKIN_MONOSTEREO); | |
| 3384 | |
| 3385 mainwin_playstatus = | |
| 3386 create_playstatus(&mainwin_wlist, mainwin_bg, mainwin_gc, 24, 28); | |
| 3387 | |
| 3388 mainwin_minus_num = | |
| 3389 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 36, 26, | |
| 3390 SKIN_NUMBERS); | |
| 3391 widget_hide(WIDGET(mainwin_minus_num)); | |
| 3392 mainwin_10min_num = | |
| 3393 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 48, 26, | |
| 3394 SKIN_NUMBERS); | |
| 3395 widget_hide(WIDGET(mainwin_10min_num)); | |
| 3396 | |
| 3397 mainwin_min_num = | |
| 3398 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 60, 26, | |
| 3399 SKIN_NUMBERS); | |
| 3400 widget_hide(WIDGET(mainwin_min_num)); | |
| 3401 | |
| 3402 mainwin_10sec_num = | |
| 3403 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 78, 26, | |
| 3404 SKIN_NUMBERS); | |
| 3405 widget_hide(WIDGET(mainwin_10sec_num)); | |
| 3406 | |
| 3407 mainwin_sec_num = | |
| 3408 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 90, 26, | |
| 3409 SKIN_NUMBERS); | |
| 3410 widget_hide(WIDGET(mainwin_sec_num)); | |
| 3411 | |
| 3412 mainwin_about = | |
| 3413 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 247, 83, 20, | |
| 3414 25, show_about_window); | |
| 3415 | |
| 3416 mainwin_vis = | |
| 3417 create_vis(&mainwin_wlist, mainwin_bg, mainwin->window, mainwin_gc, | |
| 3418 24, 43, 76); | |
| 3419 mainwin_svis = create_svis(&mainwin_wlist, mainwin_bg, mainwin_gc, 79, 5); | |
| 3420 active_vis = mainwin_vis; | |
| 3421 | |
| 3422 mainwin_position = | |
| 3423 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 16, 72, 248, | |
| 3424 10, 248, 0, 278, 0, 29, 10, 10, 0, 0, 219, NULL, | |
| 3425 mainwin_position_motion_cb, | |
| 3426 mainwin_position_release_cb, SKIN_POSBAR); | |
| 3427 widget_hide(WIDGET(mainwin_position)); | |
| 3428 | |
| 3429 mainwin_sposition = | |
| 3430 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 226, 4, 17, | |
| 3431 7, 17, 36, 17, 36, 3, 7, 36, 0, 1, 13, | |
| 3432 mainwin_spos_frame_cb, mainwin_spos_motion_cb, | |
| 3433 mainwin_spos_release_cb, SKIN_TITLEBAR); | |
| 3434 widget_hide(WIDGET(mainwin_sposition)); | |
| 3435 | |
| 3436 mainwin_stime_min = | |
| 3437 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 130, 4, 15, | |
| 3438 FALSE, SKIN_TEXT); | |
| 3439 mainwin_stime_sec = | |
| 3440 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 147, 4, 10, | |
| 3441 FALSE, SKIN_TEXT); | |
| 3442 | |
| 3443 if (!cfg.player_shaded) { | |
| 3444 widget_hide(WIDGET(mainwin_svis)); | |
| 3445 widget_hide(WIDGET(mainwin_srew)); | |
| 3446 widget_hide(WIDGET(mainwin_splay)); | |
| 3447 widget_hide(WIDGET(mainwin_spause)); | |
| 3448 widget_hide(WIDGET(mainwin_sstop)); | |
| 3449 widget_hide(WIDGET(mainwin_sfwd)); | |
| 3450 widget_hide(WIDGET(mainwin_seject)); | |
| 3451 widget_hide(WIDGET(mainwin_stime_min)); | |
| 3452 widget_hide(WIDGET(mainwin_stime_sec)); | |
| 3453 } | |
| 3454 | |
| 3455 err = gtk_message_dialog_new(GTK_WINDOW(mainwin), GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL, | |
| 3456 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,"Error in Audacious."); | |
| 3457 | |
| 3458 | |
| 3459 gtk_window_set_position(GTK_WINDOW(err), GTK_WIN_POS_CENTER); | |
| 3460 /* Dang well better set an error message or you'll see this */ | |
| 3461 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(err), | |
| 3462 "Boo! Bad stuff! Booga Booga!"); | |
| 3463 | |
| 3464 } | |
| 3465 | |
| 3466 static void | |
| 3467 mainwin_create_window(void) | |
| 3468 { | |
| 3469 gint width, height; | |
| 3470 | |
| 3471 mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
| 3472 gtk_window_set_title(GTK_WINDOW(mainwin), _("Audacious")); | |
| 3473 gtk_window_set_role(GTK_WINDOW(mainwin), "player"); | |
| 3474 gtk_window_set_resizable(GTK_WINDOW(mainwin), FALSE); | |
| 3475 | |
|
1848
c673508130a8
[svn] - replace several occurances of MAINWIN_WIDTH with bmp_active_skin->properties.mainwin_width.
nenolod
parents:
1840
diff
changeset
|
3476 width = bmp_active_skin->properties.mainwin_width; |
| 1809 | 3477 height = cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : bmp_active_skin->properties.mainwin_height; |
| 1653 | 3478 |
| 3479 gtk_widget_set_size_request(mainwin, width, height); | |
| 3480 gtk_widget_set_app_paintable(mainwin, TRUE); | |
| 3481 | |
| 3482 dock_window_list = dock_window_set_decorated(dock_window_list, | |
| 3483 GTK_WINDOW(mainwin), | |
| 3484 cfg.show_wm_decorations); | |
| 3485 | |
| 3486 if (cfg.player_x != -1 && cfg.save_window_position) | |
| 3487 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
| 3488 | |
| 3489 gtk_widget_add_events(mainwin, | |
| 3490 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK | | |
| 3491 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
| 3492 GDK_SCROLL_MASK | GDK_KEY_PRESS_MASK | | |
| 3493 GDK_VISIBILITY_NOTIFY_MASK); | |
| 3494 gtk_widget_realize(mainwin); | |
| 3495 | |
| 3496 util_set_cursor(mainwin); | |
| 3497 | |
| 3498 g_signal_connect(mainwin, "destroy", G_CALLBACK(mainwin_destroy), NULL); | |
| 3499 g_signal_connect(mainwin, "button_press_event", | |
| 3500 G_CALLBACK(mainwin_mouse_button_press), NULL); | |
| 3501 g_signal_connect(mainwin, "scroll_event", | |
| 3502 G_CALLBACK(mainwin_scrolled), NULL); | |
| 3503 g_signal_connect(mainwin, "button_release_event", | |
| 3504 G_CALLBACK(mainwin_mouse_button_release), NULL); | |
| 3505 g_signal_connect(mainwin, "motion_notify_event", | |
| 3506 G_CALLBACK(mainwin_motion), NULL); | |
| 3507 g_signal_connect_after(mainwin, "focus_in_event", | |
| 3508 G_CALLBACK(mainwin_focus_in), NULL); | |
| 3509 g_signal_connect_after(mainwin, "focus_out_event", | |
| 3510 G_CALLBACK(mainwin_focus_out), NULL); | |
| 3511 g_signal_connect(mainwin, "configure_event", | |
| 3512 G_CALLBACK(mainwin_configure), NULL); | |
| 3513 g_signal_connect(mainwin, "style_set", | |
| 3514 G_CALLBACK(mainwin_set_back_pixmap), NULL); | |
| 3515 | |
| 3516 bmp_drag_dest_set(mainwin); | |
| 3517 | |
| 3518 g_signal_connect(mainwin, "key_press_event", | |
| 3519 G_CALLBACK(mainwin_keypress), NULL); | |
| 3520 } | |
| 3521 | |
| 3522 static void | |
| 3523 mainwin_create_menus(void) | |
| 3524 { | |
| 3525 mainwin_general_menu = create_menu(mainwin_general_menu_entries, | |
| 3526 mainwin_general_menu_entries_num, | |
| 3527 mainwin_accel); | |
| 3528 | |
| 3529 mainwin_play_menu = create_menu(mainwin_playback_menu_entries, | |
| 3530 mainwin_playback_menu_entries_num, | |
| 3531 mainwin_accel); | |
| 3532 | |
| 3533 mainwin_view_menu = create_menu(mainwin_view_menu_entries, | |
| 3534 mainwin_view_menu_entries_num, | |
| 3535 mainwin_accel); | |
| 3536 | |
| 3537 mainwin_songname_menu = create_menu(mainwin_songname_menu_entries, | |
| 3538 mainwin_songname_menu_entries_num, | |
| 3539 mainwin_accel); | |
| 3540 | |
| 3541 mainwin_add_menu = create_menu(mainwin_add_menu_entries, | |
| 3542 mainwin_add_menu_entries_num, | |
| 3543 mainwin_accel); | |
| 3544 | |
| 3545 mainwin_vis_menu = create_menu(mainwin_vis_menu_entries, | |
| 3546 mainwin_vis_menu_entries_num, | |
| 3547 mainwin_accel); | |
| 3548 | |
| 3549 make_submenu(mainwin_general_menu, "/View", mainwin_view_menu); | |
| 3550 make_submenu(mainwin_general_menu, "/Playback", mainwin_play_menu); | |
| 3551 make_submenu(mainwin_general_menu, "/Visualization", mainwin_vis_menu); | |
| 3552 | |
| 3553 gtk_window_add_accel_group(GTK_WINDOW(mainwin), mainwin_accel); | |
| 3554 } | |
| 3555 | |
| 3556 void | |
| 3557 mainwin_create(void) | |
| 3558 { | |
| 3559 mainwin_create_window(); | |
| 3560 | |
| 3561 mainwin_accel = gtk_accel_group_new(); | |
| 3562 mainwin_create_menus(); | |
| 3563 | |
| 3564 mainwin_gc = gdk_gc_new(mainwin->window); | |
| 3565 mainwin_bg = gdk_pixmap_new(mainwin->window, | |
|
1848
c673508130a8
[svn] - replace several occurances of MAINWIN_WIDTH with bmp_active_skin->properties.mainwin_width.
nenolod
parents:
1840
diff
changeset
|
3566 bmp_active_skin->properties.mainwin_width, |
|
c673508130a8
[svn] - replace several occurances of MAINWIN_WIDTH with bmp_active_skin->properties.mainwin_width.
nenolod
parents:
1840
diff
changeset
|
3567 bmp_active_skin->properties.mainwin_height, -1); |
| 1653 | 3568 mainwin_set_back_pixmap(); |
| 3569 mainwin_create_widgets(); | |
| 3570 | |
| 3571 vis_set_window(mainwin_vis, mainwin->window); | |
| 3572 } | |
| 3573 | |
| 3574 void | |
| 3575 mainwin_attach_idle_func(void) | |
| 3576 { | |
| 3577 mainwin_timeout_id = g_timeout_add(MAINWIN_UPDATE_INTERVAL, | |
| 3578 mainwin_idle_func, NULL); | |
| 3579 } | |
| 3580 | |
| 3581 static void | |
| 3582 idle_func_update_song_info(gint time) | |
| 3583 { | |
| 3584 gint length, t; | |
| 3585 gchar stime_prefix; | |
| 3586 | |
| 3587 length = playlist_get_current_length(); | |
| 3588 if (bmp_playback_get_playing()) | |
| 3589 playlistwin_set_time(time, length, cfg.timer_mode); | |
| 3590 else | |
| 3591 playlistwin_hide_timer(); | |
| 3592 input_update_vis(time); | |
| 3593 | |
| 3594 if (cfg.timer_mode == TIMER_REMAINING) { | |
| 3595 if (length != -1) { | |
| 3596 number_set_number(mainwin_minus_num, 11); | |
| 3597 t = length - time; | |
| 3598 stime_prefix = '-'; | |
| 3599 } | |
| 3600 else { | |
| 3601 number_set_number(mainwin_minus_num, 10); | |
| 3602 t = time; | |
| 3603 stime_prefix = ' '; | |
| 3604 } | |
| 3605 } | |
| 3606 else { | |
| 3607 number_set_number(mainwin_minus_num, 10); | |
| 3608 t = time; | |
| 3609 stime_prefix = ' '; | |
| 3610 } | |
| 3611 t /= 1000; | |
| 3612 | |
| 3613 /* Show the time in the format HH:MM when we have more than 100 | |
| 3614 * minutes. */ | |
| 3615 if (t >= 100 * 60) | |
| 3616 t /= 60; | |
| 3617 number_set_number(mainwin_10min_num, t / 600); | |
| 3618 number_set_number(mainwin_min_num, (t / 60) % 10); | |
| 3619 number_set_number(mainwin_10sec_num, (t / 10) % 6); | |
| 3620 number_set_number(mainwin_sec_num, t % 10); | |
| 3621 | |
| 3622 if (!mainwin_sposition->hs_pressed) { | |
| 3623 gchar *time_str; | |
| 3624 | |
| 3625 time_str = g_strdup_printf("%c%2.2d", stime_prefix, t / 60); | |
| 3626 textbox_set_text(mainwin_stime_min, time_str); | |
| 3627 g_free(time_str); | |
| 3628 | |
| 3629 time_str = g_strdup_printf("%2.2d", t % 60); | |
| 3630 textbox_set_text(mainwin_stime_sec, time_str); | |
| 3631 g_free(time_str); | |
| 3632 } | |
| 3633 | |
| 3634 time /= 1000; | |
| 3635 length /= 1000; | |
| 3636 if (length > 0) { | |
| 3637 if (time > length) { | |
| 3638 hslider_set_position(mainwin_position, 219); | |
| 3639 hslider_set_position(mainwin_sposition, 13); | |
| 3640 } | |
| 3641 /* update the slider position ONLY if there is not a seek in progress */ | |
| 3642 else if (seek_state == MAINWIN_SEEK_NIL) { | |
| 3643 hslider_set_position(mainwin_position, (time * 219) / length); | |
| 3644 hslider_set_position(mainwin_sposition, | |
| 3645 ((time * 12) / length) + 1); | |
| 3646 } | |
| 3647 } | |
| 3648 else { | |
| 3649 hslider_set_position(mainwin_position, 0); | |
| 3650 hslider_set_position(mainwin_sposition, 1); | |
| 3651 } | |
| 3652 } | |
| 3653 | |
| 3654 static gboolean | |
| 3655 mainwin_idle_func(gpointer data) | |
| 3656 { | |
| 3657 static gint count = 0; | |
| 3658 gint time = 0; | |
| 3659 | |
| 3660 /* run audcore events, then run our own. --nenolod */ | |
| 3661 switch((time = audcore_generic_events())) | |
| 3662 { | |
| 3663 case -2: | |
| 3664 /* no usable output device */ | |
| 3665 GDK_THREADS_ENTER(); | |
| 3666 run_no_output_device_dialog(); | |
| 3667 mainwin_stop_pushed(); | |
| 3668 GDK_THREADS_LEAVE(); | |
| 3669 ev_waiting = FALSE; | |
| 3670 break; | |
| 3671 | |
| 3672 default: | |
| 3673 idle_func_update_song_info(time); | |
| 3674 /* nothing at this time */ | |
| 3675 } | |
| 3676 | |
| 3677 GDK_THREADS_ENTER(); | |
| 3678 | |
| 3679 if (bmp_playback_get_playing()) | |
| 3680 vis_playback_start(); | |
| 3681 else | |
| 3682 vis_playback_stop(); | |
| 3683 | |
| 3684 draw_main_window(mainwin_force_redraw); | |
| 3685 | |
| 3686 if (!count) { | |
| 3687 read_volume(VOLSET_UPDATE); | |
| 3688 count = 10; | |
| 3689 } | |
| 3690 else | |
| 3691 count--; | |
| 3692 | |
| 3693 mainwin_force_redraw = FALSE; | |
| 1821 | 3694 draw_equalizer_window(FALSE); |
| 3695 draw_playlist_window(FALSE); | |
| 1653 | 3696 |
| 3697 if (mainwin_title_text) { | |
| 3698 G_LOCK(mainwin_title); | |
| 3699 gtk_window_set_title(GTK_WINDOW(mainwin), mainwin_title_text); | |
| 3700 g_free(mainwin_title_text); | |
| 3701 mainwin_title_text = NULL; | |
| 3702 G_UNLOCK(mainwin_title); | |
| 3703 | |
| 3704 mainwin_set_info_text(); | |
| 3705 playlistwin_update_list(); | |
| 3706 } | |
| 3707 | |
| 3708 /* tristate buttons seek */ | |
| 3709 if ( seek_state != MAINWIN_SEEK_NIL ) | |
| 3710 { | |
| 3711 GTimeVal now_time; | |
| 3712 GTimeVal delta_time; | |
| 3713 gulong now_dur; | |
| 3714 g_get_current_time(&now_time); | |
| 3715 | |
| 3716 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec; | |
| 3717 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec; | |
| 3718 | |
| 3719 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000)); | |
| 3720 | |
| 3721 if ( now_dur > TRISTATE_THRESHOLD ) | |
| 3722 { | |
| 3723 gint np; | |
| 3724 if (seek_state == MAINWIN_SEEK_REV) | |
| 3725 np = seek_initial_pos - labs((gulong)(now_dur/100)); /* seek back */ | |
| 3726 else | |
| 3727 np = seek_initial_pos + labs((gulong)(now_dur/100)); /* seek forward */ | |
| 3728 | |
| 3729 /* boundaries check */ | |
| 3730 if (np < 0 ) | |
| 3731 np = 0; | |
| 3732 else if ( np > 219 ) | |
| 3733 np = 219; | |
| 3734 | |
| 3735 hslider_set_position( mainwin_position , np ); | |
| 3736 mainwin_position_motion_cb( np ); | |
| 3737 } | |
| 3738 } | |
| 3739 | |
| 3740 GDK_THREADS_LEAVE(); | |
| 3741 | |
| 3742 /* | |
| 3743 if (seek_state == MAINWIN_SEEK_REV) | |
| 3744 bmp_playback_seek(CLAMP(bmp_playback_get_time() - 1000, 0, | |
| 3745 playlist_get_current_length()) / 1000); | |
| 3746 else if (seek_state == MAINWIN_SEEK_FWD) | |
| 3747 bmp_playback_seek(CLAMP(bmp_playback_get_time() + 1000, 0, | |
| 3748 playlist_get_current_length()) / 1000); | |
| 3749 */ | |
| 3750 | |
| 3751 return TRUE; | |
| 3752 } |
