Mercurial > mplayer.hg
annotate gui/interface.c @ 33686:74fa17c7b9b8
Prefer previously assigned guiInfo.StreamTyp over stream->type.
| author | ib |
|---|---|
| date | Wed, 29 Jun 2011 10:51:22 +0000 |
| parents | ca6c9a80a062 |
| children | f23d139ded5b |
| rev | line source |
|---|---|
| 26458 | 1 /* |
| 2 * This file is part of MPlayer. | |
| 3 * | |
| 4 * MPlayer is free software; you can redistribute it and/or modify | |
| 5 * it under the terms of the GNU General Public License as published by | |
| 6 * the Free Software Foundation; either version 2 of the License, or | |
| 7 * (at your option) any later version. | |
| 8 * | |
| 9 * MPlayer is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 * GNU General Public License for more details. | |
| 13 * | |
| 14 * You should have received a copy of the GNU General Public License along | |
| 15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
| 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 17 */ | |
| 23077 | 18 |
| 19 #include <stdlib.h> | |
| 20 #include <string.h> | |
| 21 | |
| 32984 | 22 #include "interface.h" |
| 23 #include "app.h" | |
| 24 #include "skin/skin.h" | |
| 33556 | 25 #include "ui/gmplayer.h" |
| 26 #include "ui/widgets.h" | |
| 23077 | 27 #include "wm/ws.h" |
| 28 #include "wm/wsxdnd.h" | |
| 29 | |
| 30 #include "access_mpcontext.h" | |
| 32984 | 31 #include "config.h" |
| 23077 | 32 #include "help_mp.h" |
| 32984 | 33 #include "input/input.h" |
| 34 #include "libaf/equalizer.h" | |
| 35 #include "libmpcodecs/dec_audio.h" | |
| 36 #include "libmpcodecs/dec_video.h" | |
| 37 #include "libmpcodecs/vd.h" | |
| 38 #include "libmpcodecs/vf.h" | |
| 33398 | 39 #include "libvo/video_out.h" |
| 32984 | 40 #include "libvo/x11_common.h" |
| 41 #include "mixer.h" | |
| 42 #include "mp_msg.h" | |
| 32032 | 43 #include "mpcommon.h" |
|
30536
39a4dd7ec420
Move GUI-related extern declarations to a GUI header file.
diego
parents:
30535
diff
changeset
|
44 #include "mplayer.h" |
| 32984 | 45 #include "path.h" |
|
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
32461
diff
changeset
|
46 #include "sub/font_load.h" |
| 32467 | 47 #include "sub/sub.h" |
| 23077 | 48 |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
49 #ifdef CONFIG_DVDREAD |
| 23077 | 50 #include "stream/stream_dvd.h" |
| 51 #endif | |
| 52 | |
| 33662 | 53 guiInterface_t guiInfo = { |
| 33664 | 54 .StreamType = STREAMTYPE_DUMMY, |
| 33663 | 55 .MovieWindow = True, |
| 33664 | 56 .Balance = 50.0f |
| 33662 | 57 }; |
| 23077 | 58 |
| 32984 | 59 int guiWinID = -1; |
| 23077 | 60 |
| 32900 | 61 char *skinName; |
| 62 char *skinDirInHome; | |
| 63 char *skinMPlayerDir; | |
| 64 | |
| 32984 | 65 plItem *plCurrent = NULL; |
| 66 plItem *plList = NULL; | |
| 67 plItem *plLastPlayed = NULL; | |
| 68 | |
| 33555 | 69 urlItem *URLList = NULL; |
| 32984 | 70 |
| 71 char *fsHistory[fsPersistant_MaxPos] = { NULL, NULL, NULL, NULL, NULL }; | |
| 72 | |
| 73 float gtkEquChannels[6][10]; | |
| 74 | |
| 33265 | 75 static int initialized; |
| 76 | |
| 32984 | 77 int gstrcmp(const char *a, const char *b) |
| 23077 | 78 { |
| 32984 | 79 if (!a && !b) |
| 80 return 0; | |
| 81 if (!a || !b) | |
| 82 return -1; | |
| 23077 | 83 |
| 32984 | 84 return strcmp(a, b); |
| 23077 | 85 } |
| 86 | |
| 32984 | 87 static int gstrncmp(const char *a, const char *b, int size) |
| 23077 | 88 { |
| 32984 | 89 if (!a && !b) |
| 90 return 0; | |
| 91 if (!a || !b) | |
| 92 return -1; | |
| 93 | |
| 94 return strncmp(a, b, size); | |
| 23077 | 95 } |
| 96 | |
| 32984 | 97 char *gstrdup(const char *str) |
| 23077 | 98 { |
| 32984 | 99 if (!str) |
| 100 return NULL; | |
| 101 | |
| 102 return strdup(str); | |
| 23077 | 103 } |
| 104 | |
| 32984 | 105 char *gstrchr(char *str, int c) |
| 23077 | 106 { |
| 32984 | 107 if (!str) |
| 108 return NULL; | |
| 109 | |
| 110 return strchr(str, c); | |
| 111 } | |
| 112 | |
| 113 void gfree(void **p) | |
| 114 { | |
| 115 free(*p); | |
| 116 *p = NULL; | |
| 23077 | 117 } |
| 118 | |
| 119 /** | |
| 32984 | 120 * \brief This actually creates a new list containing only one element... |
| 23077 | 121 */ |
| 32984 | 122 void gaddlist(char ***list, const char *entry) |
| 23077 | 123 { |
| 32984 | 124 int i; |
| 23077 | 125 |
| 32984 | 126 if (*list) { |
| 127 for (i = 0; (*list)[i]; i++) | |
| 128 free((*list)[i]); | |
| 23077 | 129 |
| 32984 | 130 free(*list); |
| 131 } | |
| 132 | |
| 133 *list = malloc(2 * sizeof(char **)); | |
| 134 (*list)[0] = gstrdup(entry); | |
| 135 (*list)[1] = NULL; | |
| 23077 | 136 } |
| 137 | |
| 138 /** | |
| 32984 | 139 * \brief This replaces a string starting with search by replace. |
| 23077 | 140 * If not found, replace is appended. |
| 141 */ | |
|
30535
016e5fc1dead
GUI: Mark functions that are not used outside their files as static.
diego
parents:
30516
diff
changeset
|
142 static void greplace(char ***list, const char *search, const char *replace) |
| 23077 | 143 { |
| 32984 | 144 int i = 0; |
| 145 int len = (search ? strlen(search) : 0); | |
| 23077 | 146 |
| 32984 | 147 if (*list) { |
| 148 for (i = 0; (*list)[i]; i++) { | |
| 149 if (search && (strncmp((*list)[i], search, len) == 0)) { | |
| 150 free((*list)[i]); | |
| 151 (*list)[i] = gstrdup(replace); | |
| 152 return; | |
| 153 } | |
| 154 } | |
| 23077 | 155 |
| 32984 | 156 *list = realloc(*list, (i + 2) * sizeof(char *)); |
| 157 } else | |
| 158 *list = malloc(2 * sizeof(char *)); | |
| 159 | |
| 160 (*list)[i] = gstrdup(replace); | |
| 161 (*list)[i + 1] = NULL; | |
| 23077 | 162 } |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
163 |
| 32984 | 164 void guiInit(void) |
| 23077 | 165 { |
| 32984 | 166 int i; |
| 23077 | 167 |
| 33530 | 168 mp_msg(MSGT_GPLAYER, MSGL_V, "GUI init.\n"); |
| 169 | |
| 32984 | 170 memset(>kEquChannels, 0, sizeof(gtkEquChannels)); |
| 23077 | 171 |
| 32984 | 172 #ifdef CONFIG_DXR3 |
| 173 if (!gtkDXR3Device) | |
| 174 gtkDXR3Device = strdup("/dev/em8300-0"); | |
| 175 #endif | |
| 32927 | 176 |
| 32984 | 177 if (stream_cache_size > 0) { |
| 178 gtkCacheOn = 1; | |
| 179 gtkCacheSize = stream_cache_size; | |
| 180 } else if (stream_cache_size == 0) | |
| 181 gtkCacheOn = 0; | |
| 182 | |
| 183 if (autosync && (autosync != gtkAutoSync)) { | |
| 184 gtkAutoSyncOn = 1; | |
| 185 gtkAutoSync = autosync; | |
| 186 } | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
187 |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
188 #ifdef CONFIG_ASS |
| 32984 | 189 gtkASS.enabled = ass_enabled; |
| 190 gtkASS.use_margins = ass_use_margins; | |
| 191 gtkASS.top_margin = ass_top_margin; | |
| 192 gtkASS.bottom_margin = ass_bottom_margin; | |
| 23077 | 193 #endif |
| 194 | |
| 32984 | 195 gtkInit(); |
| 196 | |
| 197 // initialize X | |
| 33463 | 198 wsXInit(mDisplay); |
| 32984 | 199 |
| 200 // load skin | |
| 201 | |
| 202 skinDirInHome = get_path("skins"); | |
| 203 skinMPlayerDir = MPLAYER_DATADIR "/skins"; | |
| 204 | |
| 33530 | 205 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[interface] skin directory #1: %s\n", skinDirInHome); |
| 206 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[interface] skin directory #2: %s\n", skinMPlayerDir); | |
| 32984 | 207 |
| 208 if (!skinName) | |
| 209 skinName = strdup("default"); | |
| 210 | |
| 211 i = skinRead(skinName); | |
| 212 | |
| 213 if (i == -1 && strcmp(skinName, "default") != 0) { | |
| 214 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_SKIN_SKINCFG_SelectedSkinNotFound, skinName); | |
| 215 | |
| 216 skinName = strdup("default"); | |
| 217 i = skinRead(skinName); | |
| 218 } | |
| 219 | |
| 220 switch (i) { | |
| 221 case -1: | |
| 33024 | 222 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SKINCFG_SkinNotFound, skinName); |
| 33263 | 223 guiExit(EXIT_ERROR); |
| 23077 | 224 |
| 32984 | 225 case -2: |
| 33025 | 226 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SKINCFG_SkinCfgError, skinName); |
| 33263 | 227 guiExit(EXIT_ERROR); |
| 32984 | 228 } |
| 229 | |
| 230 // initialize windows | |
| 231 | |
| 33555 | 232 mainDrawBuffer = malloc(guiApp.main.Bitmap.ImageSize); |
| 32984 | 233 |
| 33555 | 234 if (!mainDrawBuffer) { |
| 33024 | 235 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB); |
| 33263 | 236 guiExit(EXIT_ERROR); |
| 32984 | 237 } |
| 23077 | 238 |
| 32984 | 239 if (gui_save_pos) { |
|
33218
f0c2a62e3e89
Position windows initially at coordinates given in skin file.
ib
parents:
33053
diff
changeset
|
240 if (gui_main_pos_x != -3) |
| 33555 | 241 guiApp.main.x = gui_main_pos_x; |
|
33218
f0c2a62e3e89
Position windows initially at coordinates given in skin file.
ib
parents:
33053
diff
changeset
|
242 if (gui_main_pos_y != -3) |
| 33555 | 243 guiApp.main.y = gui_main_pos_y; |
|
33218
f0c2a62e3e89
Position windows initially at coordinates given in skin file.
ib
parents:
33053
diff
changeset
|
244 if (gui_sub_pos_x != -3) |
| 33555 | 245 guiApp.sub.x = gui_sub_pos_x; |
|
33218
f0c2a62e3e89
Position windows initially at coordinates given in skin file.
ib
parents:
33053
diff
changeset
|
246 if (gui_sub_pos_y != -3) |
| 33555 | 247 guiApp.sub.y = gui_sub_pos_y; |
| 32984 | 248 } |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
249 |
| 32984 | 250 if (WinID > 0) { |
| 33555 | 251 guiApp.subWindow.Parent = WinID; |
| 252 guiApp.sub.x = 0; | |
| 253 guiApp.sub.y = 0; | |
| 32984 | 254 } |
| 23077 | 255 |
| 32984 | 256 if (guiWinID >= 0) |
| 33555 | 257 guiApp.mainWindow.Parent = guiWinID; |
| 23077 | 258 |
| 33555 | 259 wsCreateWindow(&guiApp.subWindow, guiApp.sub.x, guiApp.sub.y, guiApp.sub.width, guiApp.sub.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, wsShowFrame | wsHideWindow, "MPlayer - Video"); |
| 260 wsDestroyImage(&guiApp.subWindow); | |
| 261 wsCreateImage(&guiApp.subWindow, guiApp.sub.Bitmap.Width, guiApp.sub.Bitmap.Height); | |
| 262 wsXDNDMakeAwareness(&guiApp.subWindow); | |
| 32984 | 263 |
| 33555 | 264 uiMenuInit(); |
| 265 uiPlaybarInit(); | |
| 23077 | 266 |
| 267 // i=wsHideFrame|wsMaxSize|wsHideWindow; | |
| 33555 | 268 // if ( guiApp.mainDecoration ) i=wsShowFrame|wsMaxSize|wsHideWindow; |
| 32984 | 269 i = wsShowFrame | wsMaxSize | wsHideWindow; |
| 33555 | 270 wsCreateWindow(&guiApp.mainWindow, guiApp.main.x, guiApp.main.y, guiApp.main.width, guiApp.main.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, i, "MPlayer"); |
| 271 wsSetShape(&guiApp.mainWindow, guiApp.main.Mask.Image); | |
| 272 wsXDNDMakeAwareness(&guiApp.mainWindow); | |
| 23077 | 273 |
| 33530 | 274 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[interface] screen depth: %d\n", wsDepthOnScreen); |
| 33555 | 275 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[interface] mainWindow ID: 0x%x\n", (int)guiApp.mainWindow.WindowID); |
| 276 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[interface] subWindow ID: 0x%x\n", (int)guiApp.subWindow.WindowID); | |
| 23077 | 277 |
| 33555 | 278 guiApp.mainWindow.ReDraw = (void *)uiMainDraw; |
| 279 guiApp.mainWindow.MouseHandler = uiMainMouseHandle; | |
| 280 guiApp.mainWindow.KeyHandler = uiMainKeyHandle; | |
| 281 guiApp.mainWindow.DandDHandler = uiDandDHandler; | |
| 32984 | 282 |
| 33555 | 283 guiApp.subWindow.ReDraw = (void *)uiSubDraw; |
| 284 guiApp.subWindow.MouseHandler = uiSubMouseHandle; | |
| 285 guiApp.subWindow.KeyHandler = uiMainKeyHandle; | |
| 286 guiApp.subWindow.DandDHandler = uiDandDHandler; | |
| 23077 | 287 |
| 33555 | 288 wsSetBackgroundRGB(&guiApp.subWindow, guiApp.sub.R, guiApp.sub.G, guiApp.sub.B); |
| 289 wsClearWindow(guiApp.subWindow); | |
| 23077 | 290 |
| 33555 | 291 if (guiApp.sub.Bitmap.Image) |
| 292 wsConvert(&guiApp.subWindow, guiApp.sub.Bitmap.Image); | |
| 32984 | 293 |
| 33555 | 294 btnModify(evSetVolume, guiInfo.Volume); |
| 295 btnModify(evSetBalance, guiInfo.Balance); | |
| 296 btnModify(evSetMoviePosition, guiInfo.Position); | |
| 23077 | 297 |
| 33555 | 298 wsSetIcon(wsDisplay, guiApp.mainWindow.WindowID, &guiIcon); |
| 299 wsSetIcon(wsDisplay, guiApp.subWindow.WindowID, &guiIcon); | |
| 32984 | 300 |
| 33555 | 301 if (!guiApp.mainDecoration) |
| 302 wsWindowDecoration(&guiApp.mainWindow, 0); | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
303 |
| 33555 | 304 wsVisibleWindow(&guiApp.mainWindow, wsShowWindow); |
| 23077 | 305 |
| 306 #if 0 | |
| 33555 | 307 wsVisibleWindow(&guiApp.subWindow, wsShowWindow); |
| 32984 | 308 { |
| 309 XEvent xev; | |
| 23077 | 310 |
| 32984 | 311 do |
| 312 XNextEvent(wsDisplay, &xev); | |
| 33555 | 313 while (xev.type != MapNotify || xev.xmap.event != guiApp.subWindow.WindowID); |
| 32984 | 314 |
| 33555 | 315 guiApp.subWindow.Mapped = wsMapped; |
| 32984 | 316 } |
| 317 | |
| 318 if (!fullscreen) | |
| 319 fullscreen = gtkLoadFullscreen; | |
| 23077 | 320 |
| 32984 | 321 if (fullscreen) { |
| 33555 | 322 uiFullScreen(); |
| 32984 | 323 btnModify(evFullScreen, btnPressed); |
| 324 } | |
| 325 #else | |
| 326 if (!fullscreen) | |
| 327 fullscreen = gtkLoadFullscreen; | |
| 328 | |
| 329 if (gtkShowVideoWindow) { | |
| 33555 | 330 wsVisibleWindow(&guiApp.subWindow, wsShowWindow); |
| 32984 | 331 { |
| 332 XEvent xev; | |
| 333 | |
| 334 do | |
| 335 XNextEvent(wsDisplay, &xev); | |
| 33555 | 336 while (xev.type != MapNotify || xev.xmap.event != guiApp.subWindow.WindowID); |
| 32984 | 337 |
| 33555 | 338 guiApp.subWindow.Mapped = wsMapped; |
| 32984 | 339 } |
| 23077 | 340 |
| 32984 | 341 if (fullscreen) { |
| 33555 | 342 uiFullScreen(); |
| 32984 | 343 btnModify(evFullScreen, btnPressed); |
| 344 } | |
| 345 } else { | |
| 346 if (fullscreen) { | |
| 33555 | 347 wsVisibleWindow(&guiApp.subWindow, wsShowWindow); |
| 32984 | 348 { |
| 349 XEvent xev; | |
| 350 | |
| 351 do | |
| 352 XNextEvent(wsDisplay, &xev); | |
| 33555 | 353 while (xev.type != MapNotify || xev.xmap.event != guiApp.subWindow.WindowID); |
| 32984 | 354 |
| 33555 | 355 guiApp.subWindow.Mapped = wsMapped; |
| 32984 | 356 } |
|
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
357 guiInfo.Playing = GUI_PAUSE; // because of !gtkShowVideoWindow... |
| 33630 | 358 uiFullScreen(); // ...guiInfo.Playing is required |
| 33609 | 359 wsVisibleWindow(&guiApp.subWindow, wsHideWindow); |
| 32984 | 360 btnModify(evFullScreen, btnPressed); |
| 361 } | |
| 362 } | |
| 23077 | 363 #endif |
| 32984 | 364 |
|
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
365 guiInfo.Playing = GUI_STOP; |
| 33609 | 366 |
| 33555 | 367 uiSubRender = 1; |
| 32984 | 368 |
| 369 if (plCurrent && !filename) | |
| 33555 | 370 uiSetFileName(plCurrent->path, plCurrent->name, STREAMTYPE_FILE); |
| 32984 | 371 |
| 372 if (subdata) | |
| 33555 | 373 guiSetFilename(guiInfo.Subtitlename, subdata->filename); |
| 32984 | 374 |
| 375 guiLoadFont(); | |
| 33265 | 376 |
| 377 initialized = 1; | |
| 23077 | 378 } |
| 379 | |
| 32984 | 380 void guiDone(void) |
| 23077 | 381 { |
| 33307 | 382 if (initialized) { |
| 33555 | 383 uiMainRender = 0; |
| 32984 | 384 |
| 33308 | 385 if (gui_save_pos) { |
| 33555 | 386 gui_main_pos_x = guiApp.mainWindow.X; |
| 387 gui_main_pos_y = guiApp.mainWindow.Y; | |
| 388 gui_sub_pos_x = guiApp.subWindow.X; | |
| 389 gui_sub_pos_y = guiApp.subWindow.Y; | |
| 33308 | 390 } |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
391 |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
392 #ifdef CONFIG_ASS |
| 33308 | 393 ass_enabled = gtkASS.enabled; |
| 394 ass_use_margins = gtkASS.use_margins; | |
| 395 ass_top_margin = gtkASS.top_margin; | |
| 396 ass_bottom_margin = gtkASS.bottom_margin; | |
| 23077 | 397 #endif |
| 398 | |
| 33308 | 399 cfg_write(); |
| 400 wsXDone(); | |
| 33307 | 401 } |
| 33263 | 402 |
| 33307 | 403 appFreeStruct(); |
| 33542 | 404 free(guiIcon.collection); |
| 33307 | 405 |
| 406 if (gui_conf) { | |
| 407 m_config_free(gui_conf); | |
| 408 gui_conf = NULL; | |
| 409 } | |
| 33530 | 410 |
| 411 mp_msg(MSGT_GPLAYER, MSGL_V, "GUI done.\n"); | |
| 33263 | 412 } |
| 413 | |
| 33309 | 414 void guiExit(enum exit_reason how) |
| 33263 | 415 { |
| 33307 | 416 exit_player_with_rc(how, how >= EXIT_ERROR); |
| 23077 | 417 } |
| 418 | |
| 32984 | 419 void guiLoadFont(void) |
| 23077 | 420 { |
| 27393 | 421 #ifdef CONFIG_FREETYPE |
| 32984 | 422 load_font_ft(vo_image_width, vo_image_height, &vo_font, font_name, osd_font_scale_factor); |
| 23077 | 423 #else |
| 32984 | 424 if (vo_font) { |
| 425 int i; | |
| 426 | |
| 427 free(vo_font->name); | |
| 428 free(vo_font->fpath); | |
| 429 | |
| 430 for (i = 0; i < 16; i++) { | |
| 431 if (vo_font->pic_a[i]) { | |
| 432 free(vo_font->pic_a[i]->bmp); | |
| 433 free(vo_font->pic_a[i]->pal); | |
| 434 } | |
| 435 } | |
| 436 | |
| 437 for (i = 0; i < 16; i++) { | |
| 438 if (vo_font->pic_b[i]) { | |
| 439 free(vo_font->pic_b[i]->bmp); | |
| 440 free(vo_font->pic_b[i]->pal); | |
| 441 } | |
| 442 } | |
| 443 | |
| 444 free(vo_font); | |
| 445 vo_font = NULL; | |
| 446 } | |
| 447 | |
| 448 if (font_name) { | |
| 449 vo_font = read_font_desc(font_name, font_factor, 0); | |
| 450 | |
| 451 if (!vo_font) | |
| 33530 | 452 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadFont, font_name); |
| 32984 | 453 } else { |
| 454 font_name = gstrdup(get_path("font/font.desc")); | |
| 455 vo_font = read_font_desc(font_name, font_factor, 0); | |
| 456 | |
| 457 if (!vo_font) { | |
| 458 gfree((void **)&font_name); | |
| 459 font_name = gstrdup(MPLAYER_DATADIR "/font/font.desc"); | |
| 460 vo_font = read_font_desc(font_name, font_factor, 0); | |
| 461 } | |
| 462 } | |
| 23077 | 463 #endif |
| 464 } | |
| 465 | |
| 32984 | 466 void guiLoadSubtitle(char *name) |
| 23077 | 467 { |
| 33555 | 468 if (guiInfo.Playing == 0) { |
| 469 guiInfo.SubtitleChanged = 1; // what is this for? (mw) | |
| 32984 | 470 return; |
| 23077 | 471 } |
| 32984 | 472 |
| 473 if (subdata) { | |
| 474 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_DeletingSubtitles); | |
| 475 | |
| 476 sub_free(subdata); | |
| 477 subdata = NULL; | |
| 478 vo_sub = NULL; | |
| 479 | |
| 480 if (vo_osd_list) { | |
| 481 int len; | |
| 482 mp_osd_obj_t *osd; | |
| 483 | |
| 484 osd = vo_osd_list; | |
| 485 | |
| 486 while (osd) { | |
| 487 if (osd->type == OSDTYPE_SUBTITLE) | |
| 488 break; | |
| 489 | |
| 490 osd = osd->next; | |
| 491 } | |
| 23077 | 492 |
| 32984 | 493 if (osd && (osd->flags & OSDFLAG_VISIBLE)) { |
| 494 len = osd->stride * (osd->bbox.y2 - osd->bbox.y1); | |
| 495 memset(osd->bitmap_buffer, 0, len); | |
| 496 memset(osd->alpha_buffer, 0, len); | |
| 497 } | |
| 498 } | |
| 499 } | |
| 500 | |
| 501 if (name) { | |
| 502 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_LoadingSubtitles, name); | |
| 503 | |
| 33555 | 504 subdata = sub_read_file(name, guiInfo.FPS); |
| 32984 | 505 |
| 506 if (!subdata) | |
| 33530 | 507 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadSub, name); |
| 32984 | 508 |
| 509 sub_name = (malloc(2 * sizeof(char *))); // when mplayer will be restarted | |
| 510 sub_name[0] = strdup(name); // sub_name[0] will be read | |
| 511 sub_name[1] = NULL; | |
| 512 } | |
| 513 | |
| 514 update_set_of_subtitles(); | |
| 23077 | 515 } |
| 516 | |
| 32984 | 517 static void add_vf(char *str) |
| 23077 | 518 { |
| 32984 | 519 void *p; |
| 520 | |
| 521 if (vf_settings) { | |
| 522 int i = 0; | |
| 523 | |
| 524 while (vf_settings[i].name) { | |
| 525 if (!gstrcmp(vf_settings[i++].name, str)) { | |
| 526 i = -1; | |
| 527 break; | |
| 528 } | |
| 529 } | |
| 530 | |
| 531 if (i != -1) { | |
| 532 p = realloc(vf_settings, (i + 2) * sizeof(m_obj_settings_t)); | |
| 32712 | 533 |
| 32984 | 534 if (!p) |
| 535 return; | |
| 536 | |
| 537 vf_settings = p; | |
| 538 vf_settings[i].name = strdup(str); | |
| 539 vf_settings[i].attribs = NULL; | |
| 540 vf_settings[i + 1].name = NULL; | |
| 541 } | |
| 542 } else { | |
| 543 vf_settings = malloc(2 * sizeof(m_obj_settings_t)); | |
| 544 vf_settings[0].name = strdup(str); | |
| 545 vf_settings[0].attribs = NULL; | |
| 546 vf_settings[1].name = NULL; | |
| 32712 | 547 } |
| 548 | |
| 33530 | 549 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_AddingVideoFilter, str); |
| 23077 | 550 } |
| 551 | |
| 32984 | 552 int guiGetEvent(int type, void *arg) |
| 23077 | 553 { |
| 32984 | 554 mixer_t *mixer = NULL; |
|
33685
ca6c9a80a062
Make assignments to variables in guiGetEvent() only if needed.
ib
parents:
33683
diff
changeset
|
555 stream_t *stream; |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
556 #ifdef CONFIG_DVDREAD |
|
33685
ca6c9a80a062
Make assignments to variables in guiGetEvent() only if needed.
ib
parents:
33683
diff
changeset
|
557 dvd_priv_t *dvdp; |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
558 #endif |
| 23077 | 559 |
| 33555 | 560 if (guiInfo.mpcontext) |
| 561 mixer = mpctx_get_mixer(guiInfo.mpcontext); | |
| 23077 | 562 |
| 32984 | 563 switch (type) { |
| 564 case guiXEvent: | |
| 33555 | 565 guiInfo.event_struct = arg; |
| 33541 | 566 wsEvents(wsDisplay, arg); |
| 23077 | 567 gtkEventHandling(); |
| 568 break; | |
| 32984 | 569 |
| 33611 | 570 case guiSetState: |
| 32984 | 571 |
| 572 switch ((int)arg) { | |
| 33631 | 573 case GUI_STOP: |
| 33614 | 574 case GUI_PLAY: |
| 33555 | 575 // if ( !gtkShowVideoWindow ) wsVisibleWindow( &guiApp.subWindow,wsHideWindow ); |
| 33614 | 576 case GUI_PAUSE: |
| 33631 | 577 guiInfo.Playing = (int)arg; |
| 32984 | 578 break; |
| 579 } | |
| 580 | |
| 33555 | 581 uiState(); |
| 23077 | 582 break; |
| 32984 | 583 |
| 584 case guiSetFileName: | |
| 585 if (arg) | |
| 33555 | 586 guiSetFilename(guiInfo.Filename, arg); |
| 23077 | 587 break; |
| 32984 | 588 |
| 33661 | 589 case guiSetAudio: |
| 32984 | 590 |
| 33661 | 591 guiInfo.AudioChannels = arg ? ((sh_audio_t *)arg)->channels : 0; |
| 32984 | 592 |
| 33679 | 593 if (arg && !guiInfo.sh_video) |
| 33655 | 594 guiInfo.MovieWindow = False; |
| 32984 | 595 |
|
33680
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
596 guiGetEvent(guiSetMixer, NULL); |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
597 |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
598 if (gtkEnableAudioEqualizer) { |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
599 equalizer_t eq; |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
600 int i, j; |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
601 |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
602 for (i = 0; i < 6; i++) { |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
603 for (j = 0; j < 10; j++) { |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
604 eq.channel = i; |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
605 eq.band = j; |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
606 eq.gain = gtkEquChannels[i][j]; |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
607 gtkSet(gtkSetEqualizer, 0, &eq); |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
608 } |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
609 } |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
610 } |
|
9fde6b9e0cc1
Move audio related code from guiSetVideo to guiSetAudio.
ib
parents:
33679
diff
changeset
|
611 |
| 33679 | 612 wsVisibleWindow(&guiApp.subWindow, (guiInfo.MovieWindow ? wsShowWindow : wsHideWindow)); |
| 23077 | 613 break; |
| 32984 | 614 |
| 615 case guiSetContext: | |
| 33555 | 616 guiInfo.mpcontext = arg; |
| 33652 | 617 break; |
| 32984 | 618 |
| 619 case guiSetAfilter: | |
| 33555 | 620 guiInfo.afilter = arg; |
| 32984 | 621 break; |
| 622 | |
|
33653
86819da22c57
Rename guiGetEvent type guiSetVideo guiSetVideoWindow.
ib
parents:
33652
diff
changeset
|
623 case guiSetVideoWindow: |
| 32984 | 624 |
| 33555 | 625 if (!guiApp.subWindow.isFullScreen) { |
| 626 wsResizeWindow(&guiApp.subWindow, vo_dwidth, vo_dheight); | |
| 627 wsMoveWindow(&guiApp.subWindow, True, guiApp.sub.x, guiApp.sub.y); | |
| 32984 | 628 } |
| 629 | |
| 33555 | 630 guiInfo.MovieWidth = vo_dwidth; |
| 631 guiInfo.MovieHeight = vo_dheight; | |
| 32984 | 632 |
| 633 if (guiWinID >= 0) | |
| 33654 | 634 wsMoveWindow(&guiApp.mainWindow, False, 0, vo_dheight); |
| 32984 | 635 |
| 33555 | 636 WinID = guiApp.subWindow.WindowID; |
| 32984 | 637 break; |
| 638 | |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
639 #ifdef CONFIG_DVDREAD |
| 32984 | 640 case guiSetDVD: |
|
33685
ca6c9a80a062
Make assignments to variables in guiGetEvent() only if needed.
ib
parents:
33683
diff
changeset
|
641 dvdp = arg; |
| 33555 | 642 guiInfo.DVD.titles = dvdp->vmg_file->tt_srpt->nr_of_srpts; |
| 643 guiInfo.DVD.chapters = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
| 644 guiInfo.DVD.angles = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
| 645 guiInfo.DVD.nr_of_audio_channels = dvdp->nr_of_channels; | |
| 646 memcpy(guiInfo.DVD.audio_streams, dvdp->audio_streams, sizeof(dvdp->audio_streams)); | |
| 647 guiInfo.DVD.nr_of_subtitles = dvdp->nr_of_subtitles; | |
| 648 memcpy(guiInfo.DVD.subtitles, dvdp->subtitles, sizeof(dvdp->subtitles)); | |
| 649 guiInfo.DVD.current_title = dvd_title + 1; | |
| 650 guiInfo.DVD.current_chapter = dvd_chapter + 1; | |
| 651 guiInfo.DVD.current_angle = dvd_angle + 1; | |
| 652 guiInfo.Track = dvd_title + 1; | |
| 23077 | 653 break; |
| 654 #endif | |
| 32984 | 655 |
| 656 case guiSetStream: | |
| 657 | |
|
33685
ca6c9a80a062
Make assignments to variables in guiGetEvent() only if needed.
ib
parents:
33683
diff
changeset
|
658 stream = arg; |
| 33555 | 659 guiInfo.StreamType = stream->type; |
| 32984 | 660 |
|
33686
74fa17c7b9b8
Prefer previously assigned guiInfo.StreamTyp over stream->type.
ib
parents:
33685
diff
changeset
|
661 switch (guiInfo.StreamType) { |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
662 #ifdef CONFIG_DVDREAD |
| 32984 | 663 case STREAMTYPE_DVD: |
| 33595 | 664 guiGetEvent(guiSetDVD, stream->priv); |
| 32984 | 665 break; |
| 23077 | 666 #endif |
| 32984 | 667 |
|
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
668 #ifdef CONFIG_VCD |
| 32984 | 669 case STREAMTYPE_VCD: |
| 33555 | 670 guiInfo.VCDTracks = 0; |
| 671 stream_control(stream, STREAM_CTRL_GET_NUM_CHAPTERS, &guiInfo.VCDTracks); | |
| 32984 | 672 break; |
| 23077 | 673 #endif |
| 32984 | 674 |
| 675 default: | |
| 676 break; | |
| 677 } | |
| 678 | |
| 679 break; | |
| 680 | |
| 33659 | 681 case guiRunCommand: |
| 32984 | 682 |
| 33659 | 683 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[interface] guiRunCommand: %d\n", (int)arg); |
| 32984 | 684 |
| 685 switch ((int)arg) { | |
| 686 case MP_CMD_QUIT: | |
| 33555 | 687 uiEventHandling(evExit, 0); |
| 32984 | 688 break; |
| 23077 | 689 |
| 32984 | 690 case MP_CMD_VO_FULLSCREEN: |
| 33555 | 691 uiEventHandling(evFullScreen, 0); |
| 32984 | 692 break; |
| 693 } | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
694 |
| 32984 | 695 break; |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
696 |
| 32984 | 697 case guiReDraw: |
| 33555 | 698 uiEventHandling(evRedraw, 0); |
| 32984 | 699 break; |
| 700 | |
| 33670 | 701 case guiSetMixer: |
|
33393
eda1d0125255
Use mixer directly without checking for an audio_out.
reimar
parents:
33392
diff
changeset
|
702 if (mixer) { |
| 32984 | 703 float l, r; |
| 33672 | 704 static float last_balance = -1; |
| 32984 | 705 |
| 706 mixer_getvolume(mixer, &l, &r); | |
| 33672 | 707 |
| 33671 | 708 guiInfo.Volume = FFMAX(l, r); |
| 33672 | 709 btnModify(evSetVolume, guiInfo.Volume); |
| 23077 | 710 |
| 33672 | 711 if (guiInfo.Balance != last_balance) { |
| 33673 | 712 if (guiInfo.Volume) |
| 713 guiInfo.Balance = ((r - l) / guiInfo.Volume + 1.0) * 50.0; | |
| 714 else | |
| 715 guiInfo.Balance = 50.0f; | |
| 32984 | 716 |
| 33673 | 717 last_balance = guiInfo.Balance; |
| 718 btnModify(evSetBalance, guiInfo.Balance); | |
| 33672 | 719 } |
| 32984 | 720 } |
| 721 break; | |
| 722 | |
| 33660 | 723 case guiSetVideo: |
| 32984 | 724 |
| 725 // video | |
| 726 | |
| 33555 | 727 guiInfo.sh_video = arg; |
| 32984 | 728 |
| 729 if (arg) { | |
| 730 sh_video_t *sh = arg; | |
| 33555 | 731 guiInfo.FPS = sh->fps; |
| 32984 | 732 } |
| 733 | |
| 33555 | 734 if (guiInfo.StreamType == STREAMTYPE_STREAM) |
| 32984 | 735 btnSet(evSetMoviePosition, btnDisabled); |
| 736 else | |
| 737 btnSet(evSetMoviePosition, btnReleased); | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
738 |
|
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
739 #ifdef CONFIG_DXR3 |
| 33656 | 740 if (video_driver_list && !gstrcmp(video_driver_list[0], "dxr3") && (((demuxer_t *)mpctx_get_demuxer(guiInfo.mpcontext))->file_format != DEMUXER_TYPE_MPEG_PS) && !gtkVfLAVC) { |
| 32984 | 741 gtkMessageBox(GTK_MB_FATAL, MSGTR_NEEDLAVC); |
|
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33664
diff
changeset
|
742 return False; |
| 32984 | 743 } |
| 23077 | 744 #endif |
| 32984 | 745 |
| 746 break; | |
| 747 | |
| 748 case guiSetDefaults: | |
| 749 | |
| 33555 | 750 // if ( guiInfo.Playing == 1 && guiInfo.FilenameChanged ) |
| 751 if (guiInfo.FilenameChanged) { | |
| 32984 | 752 audio_id = -1; |
| 753 video_id = -1; | |
| 754 dvdsub_id = -1; | |
| 755 vobsub_id = -1; | |
| 756 stream_cache_size = -1; | |
| 757 autosync = 0; | |
| 758 dvd_title = 0; | |
| 759 force_fps = 0; | |
| 760 } | |
| 761 | |
| 33555 | 762 guiInfo.sh_video = NULL; |
| 763 wsPostRedisplay(&guiApp.subWindow); | |
| 32984 | 764 |
| 765 break; | |
| 766 | |
|
33658
3a617d41751a
Rename guiGetEvent type guiSetParameters guiPreparation.
ib
parents:
33657
diff
changeset
|
767 case guiPreparation: |
| 32984 | 768 |
| 769 guiGetEvent(guiSetDefaults, NULL); | |
| 770 | |
| 33555 | 771 switch (guiInfo.StreamType) { |
| 32984 | 772 case STREAMTYPE_PLAYLIST: |
| 773 break; | |
| 774 | |
| 775 #ifdef CONFIG_VCD | |
| 776 case STREAMTYPE_VCD: | |
| 777 { | |
| 778 char tmp[512]; | |
| 779 | |
| 33555 | 780 sprintf(tmp, "vcd://%d", guiInfo.Track + 1); |
| 781 guiSetFilename(guiInfo.Filename, tmp); | |
| 32984 | 782 } |
| 783 break; | |
| 784 #endif | |
| 785 | |
| 786 #ifdef CONFIG_DVDREAD | |
| 787 case STREAMTYPE_DVD: | |
| 788 { | |
| 789 char tmp[512]; | |
| 790 | |
| 33555 | 791 sprintf(tmp, "dvd://%d", guiInfo.Title); |
| 792 guiSetFilename(guiInfo.Filename, tmp); | |
| 32984 | 793 } |
| 794 | |
| 33555 | 795 dvd_chapter = guiInfo.Chapter; |
| 796 dvd_angle = guiInfo.Angle; | |
| 32984 | 797 |
| 798 break; | |
| 799 #endif | |
| 800 } | |
| 801 | |
| 33555 | 802 // if ( guiInfo.StreamType != STREAMTYPE_PLAYLIST ) // Does not make problems anymore! |
| 32984 | 803 { |
| 33555 | 804 if (guiInfo.Filename) |
| 805 filename = gstrdup(guiInfo.Filename); | |
| 32984 | 806 else if (filename) |
| 33555 | 807 guiSetFilename(guiInfo.Filename, filename); |
| 32984 | 808 } |
| 809 | |
| 810 // video opts | |
| 811 | |
| 812 if (!video_driver_list) { | |
| 813 int i = 0; | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
814 |
| 32984 | 815 while (video_out_drivers[i++]) { |
| 816 if (video_out_drivers[i - 1]->control(VOCTRL_GUISUPPORT, NULL) == VO_TRUE) { | |
| 817 gaddlist(&video_driver_list, (char *)video_out_drivers[i - 1]->info->short_name); | |
| 818 break; | |
| 819 } | |
| 820 } | |
| 821 } | |
| 822 | |
| 823 if (!video_driver_list && !video_driver_list[0]) { | |
| 33024 | 824 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_IDFGCVD); |
| 33263 | 825 guiExit(EXIT_ERROR); |
| 32984 | 826 } |
| 827 | |
| 828 { | |
| 829 int i = 0; | |
| 830 | |
| 33655 | 831 guiInfo.MovieWindow = True; |
| 32984 | 832 |
| 833 while (video_out_drivers[i++]) { | |
| 834 if (video_out_drivers[i - 1]->control(VOCTRL_GUISUPPORT, NULL) == VO_TRUE) { | |
| 835 if ((video_driver_list && !gstrcmp(video_driver_list[0], (char *)video_out_drivers[i - 1]->info->short_name)) && (video_out_drivers[i - 1]->control(VOCTRL_GUI_NOWINDOW, NULL) == VO_TRUE)) { | |
| 33655 | 836 guiInfo.MovieWindow = False; |
| 32984 | 837 break; |
| 838 } | |
| 839 } | |
| 840 } | |
| 841 } | |
| 842 | |
| 843 #ifdef CONFIG_DXR3 | |
| 844 if (video_driver_list && !gstrcmp(video_driver_list[0], "dxr3")) | |
| 33555 | 845 if (guiInfo.StreamType != STREAMTYPE_DVD && guiInfo.StreamType != STREAMTYPE_VCD) |
| 32984 | 846 if (gtkVfLAVC) |
| 847 add_vf("lavc"); | |
| 848 #endif | |
| 849 | |
| 850 if (gtkVfPP) | |
| 851 add_vf("pp"); | |
| 852 | |
| 853 // audio opts | |
| 854 | |
| 855 // if ( ao_plugin_cfg.plugin_list ) { free( ao_plugin_cfg.plugin_list ); ao_plugin_cfg.plugin_list=NULL; } | |
| 856 if (gtkAONorm) | |
| 857 greplace(&af_cfg.list, "volnorm", "volnorm"); | |
| 858 | |
| 859 if (gtkEnableAudioEqualizer) | |
| 860 greplace(&af_cfg.list, "equalizer", "equalizer"); | |
| 861 | |
| 862 if (gtkAOExtraStereo) { | |
| 863 char *name; | |
| 864 | |
| 865 name = malloc(12 + 20 + 1); | |
| 866 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
| 867 name[12 + 20] = 0; | |
| 868 greplace(&af_cfg.list, "extrastereo", name); | |
| 869 free(name); | |
| 870 } | |
| 871 | |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
872 #ifdef CONFIG_OSS_AUDIO |
| 32984 | 873 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "oss", 3)) { |
| 874 char *tmp; | |
| 875 | |
| 876 mixer_device = gtkAOOSSMixer; | |
| 877 mixer_channel = gtkAOOSSMixerChannel; | |
| 878 | |
| 879 if (gtkAOOSSDevice) { | |
| 880 tmp = calloc(1, strlen(gtkAOOSSDevice) + 7); | |
| 881 sprintf(tmp, "oss:%s", gtkAOOSSDevice); | |
| 882 } else | |
| 883 tmp = strdup("oss"); | |
| 884 | |
| 885 gaddlist(&audio_driver_list, tmp); | |
| 886 free(tmp); | |
| 887 } | |
| 23077 | 888 #endif |
| 32984 | 889 |
|
27390
9d95dc936e66
Introduce CONFIG_ALSA preprocessor directive for ALSA 0.9 and 1.x.
diego
parents:
27387
diff
changeset
|
890 #ifdef CONFIG_ALSA |
| 32984 | 891 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "alsa", 4)) { |
| 892 char *tmp; | |
| 893 | |
| 894 mixer_device = gtkAOALSAMixer; | |
| 895 mixer_channel = gtkAOALSAMixerChannel; | |
| 896 | |
| 897 if (gtkAOALSADevice) { | |
| 898 tmp = calloc(1, strlen(gtkAOALSADevice) + 14); | |
| 899 sprintf(tmp, "alsa:device=%s", gtkAOALSADevice); | |
| 900 } else | |
| 901 tmp = strdup("alsa"); | |
| 902 | |
| 903 gaddlist(&audio_driver_list, tmp); | |
| 904 free(tmp); | |
| 905 } | |
| 23077 | 906 #endif |
| 32984 | 907 |
|
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
908 #ifdef CONFIG_SDL |
| 32984 | 909 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "sdl", 3)) { |
| 910 char *tmp; | |
| 911 | |
| 912 if (gtkAOSDLDriver) { | |
| 913 tmp = calloc(1, strlen(gtkAOSDLDriver) + 10); | |
| 914 sprintf(tmp, "sdl:%s", gtkAOSDLDriver); | |
| 915 } else | |
| 916 tmp = strdup("sdl"); | |
| 917 | |
| 918 gaddlist(&audio_driver_list, tmp); | |
| 919 free(tmp); | |
| 920 } | |
| 23077 | 921 #endif |
| 32984 | 922 |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
923 #ifdef CONFIG_ESD |
| 32984 | 924 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "esd", 3)) { |
| 925 char *tmp; | |
| 926 | |
| 927 if (gtkAOESDDevice) { | |
| 928 tmp = calloc(1, strlen(gtkAOESDDevice) + 10); | |
| 929 sprintf(tmp, "esd:%s", gtkAOESDDevice); | |
| 930 } else | |
| 931 tmp = strdup("esd"); | |
| 932 | |
| 933 gaddlist(&audio_driver_list, tmp); | |
| 934 free(tmp); | |
| 935 } | |
| 23077 | 936 #endif |
| 32984 | 937 |
| 938 // subtitle | |
| 939 | |
| 33555 | 940 // subdata->filename=gstrdup( guiInfo.Subtitlename ); |
| 32984 | 941 stream_dump_type = 0; |
| 942 | |
| 943 if (gtkSubDumpMPSub) | |
| 944 stream_dump_type = 4; | |
| 945 | |
| 946 if (gtkSubDumpSrt) | |
| 947 stream_dump_type = 6; | |
| 948 | |
| 949 gtkSubDumpMPSub = gtkSubDumpSrt = 0; | |
| 23077 | 950 guiLoadFont(); |
| 951 | |
| 32984 | 952 // misc |
| 953 | |
| 954 if (gtkCacheOn) | |
| 955 stream_cache_size = gtkCacheSize; | |
| 956 | |
| 957 if (gtkAutoSyncOn) | |
| 958 autosync = gtkAutoSync; | |
| 23077 | 959 |
| 33555 | 960 if (guiInfo.AudioFile) |
| 961 audio_stream = gstrdup(guiInfo.AudioFile); | |
| 962 else if (guiInfo.FilenameChanged) | |
| 32984 | 963 gfree((void **)&audio_stream); |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
964 |
| 32984 | 965 // audio_stream = NULL; |
| 966 | |
| 33555 | 967 guiInfo.DiskChanged = 0; |
| 968 guiInfo.FilenameChanged = 0; | |
| 969 guiInfo.NewPlay = 0; | |
| 23077 | 970 |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
971 #ifdef CONFIG_ASS |
| 32984 | 972 ass_enabled = gtkASS.enabled; |
| 973 ass_use_margins = gtkASS.use_margins; | |
| 974 ass_top_margin = gtkASS.top_margin; | |
| 23077 | 975 ass_bottom_margin = gtkASS.bottom_margin; |
| 976 #endif | |
| 977 | |
| 32984 | 978 break; |
| 979 } | |
| 980 | |
|
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33664
diff
changeset
|
981 return True; |
| 23077 | 982 } |
| 983 | |
| 32984 | 984 void guiEventHandling(void) |
| 23077 | 985 { |
| 33655 | 986 if (!guiInfo.Playing || !guiInfo.MovieWindow) |
| 32984 | 987 wsHandleEvents(); |
| 988 | |
| 989 gtkEventHandling(); | |
| 23077 | 990 } |
| 991 | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
992 // --- |
| 32984 | 993 #if defined(MP_DEBUG) && 0 |
| 994 void list(void) | |
| 995 { | |
| 996 plItem *next = plList; | |
| 23077 | 997 |
| 32984 | 998 printf("--- list ---\n"); |
| 23077 | 999 |
| 32984 | 1000 while (next || next->next) { |
| 1001 printf("item: %s/%s\n", next->path, next->name); | |
| 1002 | |
| 1003 if (next->next) | |
| 1004 next = next->next; | |
| 1005 else | |
| 1006 break; | |
| 1007 } | |
| 1008 | |
| 1009 printf("--- end of list ---\n"); | |
| 23077 | 1010 } |
| 1011 #else | |
| 1012 #define list(); | |
| 1013 #endif | |
| 1014 | |
| 32984 | 1015 void *gtkSet(int cmd, float fparam, void *vparam) |
| 23077 | 1016 { |
| 32984 | 1017 equalizer_t *eq = (equalizer_t *)vparam; |
| 1018 plItem *item = (plItem *)vparam; | |
| 33555 | 1019 urlItem *url_item = (urlItem *)vparam; |
| 32984 | 1020 int is_added = True; |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1021 |
| 32984 | 1022 switch (cmd) { |
| 1023 // handle playlist | |
| 1024 | |
| 1025 // add item to playlist | |
| 1026 case gtkAddPlItem: | |
| 23077 | 1027 |
| 32984 | 1028 if (plList) { |
| 1029 plItem *next = plList; | |
| 1030 | |
| 1031 while (next->next) | |
| 1032 // { | |
| 1033 // printf( "%s\n",next->name ); | |
| 1034 next = next->next; | |
| 1035 // } | |
| 1036 | |
| 1037 next->next = item; | |
| 1038 item->prev = next; | |
|
33475
b1bda1dded08
When adding a playlist item, preventively set its next pointer to NULL.
ib
parents:
33473
diff
changeset
|
1039 item->next = NULL; |
| 32984 | 1040 } else { |
| 1041 item->prev = item->next = NULL; | |
| 1042 plCurrent = plList = item; | |
| 1043 } | |
| 1044 | |
| 23077 | 1045 list(); |
| 33053 | 1046 |
| 23077 | 1047 return NULL; |
| 32984 | 1048 |
| 1049 // add item into playlist after current | |
| 1050 case gtkInsertPlItem: | |
| 1051 if (plCurrent) { | |
| 1052 plItem *curr = plCurrent; | |
| 1053 item->next = curr->next; | |
| 1054 | |
| 1055 if (item->next) | |
| 1056 item->next->prev = item; | |
| 1057 | |
| 1058 item->prev = curr; | |
| 1059 curr->next = item; | |
| 1060 plCurrent = plCurrent->next; | |
| 1061 | |
| 1062 return plCurrent; | |
| 1063 } else | |
| 1064 return gtkSet(gtkAddPlItem, 0, (void *)item); | |
| 1065 return NULL; // NOTE TO MYSELF: remove this | |
| 1066 | |
| 33473 | 1067 // get next item from playlist |
| 32984 | 1068 case gtkGetNextPlItem: |
| 1069 if (plCurrent && plCurrent->next) { | |
| 1070 plCurrent = plCurrent->next; | |
| 1071 // if (!plCurrent && plList) | |
| 1072 // { | |
| 1073 // plItem *next = plList; | |
| 1074 // | |
| 1075 // while (next->next) | |
| 1076 // { | |
| 1077 // if (!next->next) break; | |
| 1078 // next = next->next; | |
| 1079 // } | |
| 1080 // | |
| 1081 // plCurrent = next; | |
| 1082 // } | |
| 1083 return plCurrent; | |
| 1084 } | |
| 33053 | 1085 |
| 23077 | 1086 return NULL; |
| 32984 | 1087 |
| 33473 | 1088 // get previous item from playlist |
| 32984 | 1089 case gtkGetPrevPlItem: |
| 1090 if (plCurrent && plCurrent->prev) { | |
| 1091 plCurrent = plCurrent->prev; | |
| 1092 // if ( !plCurrent && plList ) plCurrent=plList; | |
| 1093 return plCurrent; | |
| 1094 } | |
| 33053 | 1095 |
| 23077 | 1096 return NULL; |
| 32984 | 1097 |
| 1098 // set current item | |
| 1099 case gtkSetCurrPlItem: | |
| 1100 plCurrent = item; | |
| 1101 return plCurrent; | |
| 1102 | |
| 1103 // get current item | |
| 1104 case gtkGetCurrPlItem: | |
| 23077 | 1105 return plCurrent; |
| 32984 | 1106 |
| 1107 // delete current item | |
| 1108 case gtkDelCurrPlItem: | |
| 1109 { | |
| 1110 plItem *curr = plCurrent; | |
| 1111 | |
| 1112 if (!curr) | |
| 1113 return NULL; | |
| 23077 | 1114 |
| 32984 | 1115 if (curr->prev) |
| 1116 curr->prev->next = curr->next; | |
| 1117 if (curr->next) | |
| 1118 curr->next->prev = curr->prev; | |
| 1119 if (curr == plList) | |
| 1120 plList = curr->next; | |
| 1121 | |
| 1122 plCurrent = curr->next; | |
| 1123 | |
| 1124 // free it | |
| 1125 free(curr->path); | |
| 1126 free(curr->name); | |
| 1127 free(curr); | |
| 1128 } | |
| 1129 | |
| 33555 | 1130 uiCurr(); // instead of using uiNext && uiPrev |
| 33053 | 1131 |
| 32984 | 1132 return plCurrent; |
| 1133 | |
| 1134 // delete list | |
| 1135 case gtkDelPl: | |
| 1136 { | |
| 1137 plItem *curr = plList; | |
| 1138 plItem *next; | |
| 1139 | |
| 1140 if (!plList) | |
| 1141 return NULL; | |
| 23077 | 1142 |
| 32984 | 1143 if (!curr->next) { |
| 1144 free(curr->path); | |
| 1145 free(curr->name); | |
| 1146 free(curr); | |
| 1147 } else { | |
| 1148 while (curr->next) { | |
| 1149 next = curr->next; | |
| 1150 free(curr->path); | |
| 1151 free(curr->name); | |
| 1152 free(curr); | |
| 1153 curr = next; | |
| 1154 } | |
| 1155 } | |
| 1156 | |
| 1157 plList = NULL; | |
| 1158 plCurrent = NULL; | |
| 1159 } | |
| 33053 | 1160 |
| 23077 | 1161 return NULL; |
| 32984 | 1162 |
| 1163 // handle url | |
| 1164 case gtkAddURLItem: | |
| 1165 if (URLList) { | |
| 33555 | 1166 urlItem *next_url = URLList; |
| 32984 | 1167 is_added = False; |
| 1168 | |
| 1169 while (next_url->next) { | |
| 1170 if (!gstrcmp(next_url->url, url_item->url)) { | |
| 1171 is_added = True; | |
| 1172 break; | |
| 1173 } | |
| 1174 | |
| 1175 next_url = next_url->next; | |
| 1176 } | |
| 1177 | |
| 1178 if (!is_added && gstrcmp(next_url->url, url_item->url)) | |
| 1179 next_url->next = url_item; | |
| 1180 } else { | |
| 1181 url_item->next = NULL; | |
| 1182 URLList = url_item; | |
| 1183 } | |
| 33053 | 1184 |
| 23077 | 1185 return NULL; |
| 32984 | 1186 |
| 1187 // subtitle | |
| 1188 | |
| 27393 | 1189 #ifndef CONFIG_FREETYPE |
| 32984 | 1190 case gtkSetFontFactor: |
| 1191 font_factor = fparam; | |
| 1192 guiLoadFont(); | |
| 1193 return NULL; | |
| 23077 | 1194 #else |
| 32984 | 1195 case gtkSetFontOutLine: |
| 1196 subtitle_font_thickness = (8.0f / 100.0f) * fparam; | |
| 1197 guiLoadFont(); | |
| 1198 return NULL; | |
| 1199 | |
| 1200 case gtkSetFontBlur: | |
| 1201 subtitle_font_radius = (8.0f / 100.0f) * fparam; | |
| 1202 guiLoadFont(); | |
| 1203 return NULL; | |
| 1204 | |
| 1205 case gtkSetFontTextScale: | |
| 1206 text_font_scale_factor = fparam; | |
| 1207 guiLoadFont(); | |
| 1208 return NULL; | |
| 1209 | |
| 1210 case gtkSetFontOSDScale: | |
| 1211 osd_font_scale_factor = fparam; | |
| 1212 guiLoadFont(); | |
| 1213 return NULL; | |
| 1214 | |
| 1215 case gtkSetFontEncoding: | |
| 1216 gfree((void **)&subtitle_font_encoding); | |
| 1217 subtitle_font_encoding = gstrdup((char *)vparam); | |
| 1218 guiLoadFont(); | |
| 1219 return NULL; | |
| 1220 | |
| 1221 case gtkSetFontAutoScale: | |
| 1222 subtitle_autoscale = (int)fparam; | |
| 1223 guiLoadFont(); | |
| 1224 return NULL; | |
| 23077 | 1225 #endif |
| 32984 | 1226 |
| 27393 | 1227 #ifdef CONFIG_ICONV |
| 32984 | 1228 case gtkSetSubEncoding: |
| 1229 gfree((void **)&sub_cp); | |
| 1230 sub_cp = gstrdup((char *)vparam); | |
| 1231 break; | |
| 23077 | 1232 #endif |
| 32984 | 1233 |
| 1234 // misc | |
| 1235 | |
| 1236 case gtkClearStruct: | |
| 1237 | |
| 1238 if ((unsigned int)vparam & guiFilenames) { | |
| 33555 | 1239 gfree((void **)&guiInfo.Filename); |
| 1240 gfree((void **)&guiInfo.Subtitlename); | |
| 1241 gfree((void **)&guiInfo.AudioFile); | |
| 32984 | 1242 gtkSet(gtkDelPl, 0, NULL); |
| 1243 } | |
| 1244 | |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
1245 #ifdef CONFIG_DVDREAD |
| 32984 | 1246 if ((unsigned int)vparam & guiDVD) |
| 33555 | 1247 memset(&guiInfo.DVD, 0, sizeof(guiDVDStruct)); |
| 23077 | 1248 #endif |
| 32984 | 1249 |
|
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
1250 #ifdef CONFIG_VCD |
| 32984 | 1251 if ((unsigned int)vparam & guiVCD) |
| 33555 | 1252 guiInfo.VCDTracks = 0; |
| 23077 | 1253 #endif |
| 32984 | 1254 |
| 1255 return NULL; | |
| 1256 | |
| 1257 case gtkSetExtraStereo: | |
| 1258 gtkAOExtraStereoMul = fparam; | |
| 33555 | 1259 if (guiInfo.afilter) |
| 1260 af_control_any_rev(guiInfo.afilter, AF_CONTROL_ES_MUL | AF_CONTROL_SET, >kAOExtraStereoMul); | |
| 32984 | 1261 return NULL; |
| 1262 | |
| 1263 case gtkSetPanscan: | |
| 1264 { | |
| 1265 mp_cmd_t *mp_cmd; | |
| 1266 | |
| 1267 mp_cmd = calloc(1, sizeof(*mp_cmd)); | |
| 1268 mp_cmd->id = MP_CMD_PANSCAN; | |
| 1269 mp_cmd->name = strdup("panscan"); | |
| 1270 mp_cmd->args[0].v.f = fparam; | |
| 1271 mp_cmd->args[1].v.i = 1; | |
| 1272 mp_input_queue_cmd(mp_cmd); | |
| 1273 } | |
| 33053 | 1274 |
| 23077 | 1275 return NULL; |
| 32984 | 1276 |
| 1277 case gtkSetAutoq: | |
| 1278 auto_quality = (int)fparam; | |
| 1279 return NULL; | |
| 1280 | |
| 1281 // set equalizers | |
| 1282 | |
| 1283 case gtkSetContrast: | |
| 33555 | 1284 if (guiInfo.sh_video) |
| 1285 set_video_colors(guiInfo.sh_video, "contrast", (int)fparam); | |
| 32984 | 1286 return NULL; |
| 1287 | |
| 1288 case gtkSetBrightness: | |
| 33555 | 1289 if (guiInfo.sh_video) |
| 1290 set_video_colors(guiInfo.sh_video, "brightness", (int)fparam); | |
| 32984 | 1291 return NULL; |
| 1292 | |
| 1293 case gtkSetHue: | |
| 33555 | 1294 if (guiInfo.sh_video) |
| 1295 set_video_colors(guiInfo.sh_video, "hue", (int)fparam); | |
| 23077 | 1296 return NULL; |
| 32984 | 1297 |
| 1298 case gtkSetSaturation: | |
| 33555 | 1299 if (guiInfo.sh_video) |
| 1300 set_video_colors(guiInfo.sh_video, "saturation", (int)fparam); | |
| 32984 | 1301 return NULL; |
| 1302 | |
| 1303 case gtkSetEqualizer: | |
| 1304 { | |
| 23077 | 1305 af_control_ext_t tmp; |
| 32984 | 1306 |
| 1307 if (eq) { | |
| 1308 gtkEquChannels[eq->channel][eq->band] = eq->gain; | |
| 1309 tmp.ch = eq->channel; | |
| 1310 tmp.arg = gtkEquChannels[eq->channel]; | |
| 1311 | |
| 33555 | 1312 if (guiInfo.afilter) |
| 1313 af_control_any_rev(guiInfo.afilter, AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); | |
| 32984 | 1314 } else { |
| 1315 int i; | |
| 1316 | |
| 1317 memset(gtkEquChannels, 0, sizeof(gtkEquChannels)); | |
| 1318 | |
| 33555 | 1319 if (guiInfo.afilter) { |
| 32984 | 1320 for (i = 0; i < 6; i++) { |
| 1321 tmp.ch = i; | |
| 1322 tmp.arg = gtkEquChannels[i]; | |
| 33555 | 1323 af_control_any_rev(guiInfo.afilter, AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); |
| 32984 | 1324 } |
| 1325 } | |
| 1326 } | |
| 1327 | |
| 1328 return NULL; | |
| 1329 } | |
| 1330 } | |
| 1331 | |
| 1332 return NULL; | |
| 23077 | 1333 } |
| 1334 | |
| 32984 | 1335 // This function adds/inserts one file into the gui playlist. |
| 1336 static int import_file_into_gui(char *temp, int insert) | |
| 1337 { | |
| 1338 char *filename, *pathname; | |
| 1339 plItem *item; | |
| 23077 | 1340 |
| 32984 | 1341 filename = strdup(mp_basename(temp)); |
| 1342 pathname = strdup(temp); | |
| 1343 | |
| 1344 if (strlen(pathname) - strlen(filename) > 0) | |
| 1345 pathname[strlen(pathname) - strlen(filename) - 1] = 0; // we have some path, so remove / at end | |
| 1346 else | |
| 1347 pathname[strlen(pathname) - strlen(filename)] = 0; | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1348 |
| 33530 | 1349 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[interface] playtree, add: %s/%s\n", pathname, filename); |
| 32984 | 1350 |
| 1351 item = calloc(1, sizeof(plItem)); | |
| 1352 | |
| 1353 if (!item) | |
| 1354 return 0; | |
| 1355 | |
| 1356 item->name = filename; | |
| 1357 item->path = pathname; | |
| 1358 | |
| 1359 if (insert) | |
| 1360 gtkSet(gtkInsertPlItem, 0, (void *)item); // inserts the item after current, and makes current=item | |
| 1361 else | |
| 1362 gtkSet(gtkAddPlItem, 0, (void *)item); | |
| 1363 | |
| 1364 return 1; | |
| 23077 | 1365 } |
| 1366 | |
| 32984 | 1367 // This function imports the initial playtree (based on cmd-line files) |
| 1368 // into the gui playlist by either: | |
| 1369 // - overwriting gui pl (enqueue=0) | |
| 1370 // - appending it to gui pl (enqueue=1) | |
| 1371 int import_initial_playtree_into_gui(play_tree_t *my_playtree, m_config_t *config, int enqueue) | |
| 1372 { | |
| 1373 play_tree_iter_t *my_pt_iter = NULL; | |
| 1374 int result = 0; | |
| 23077 | 1375 |
| 32984 | 1376 if (!enqueue) |
| 1377 gtkSet(gtkDelPl, 0, 0); // delete playlist before "appending" | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1378 |
| 32984 | 1379 if ((my_pt_iter = pt_iter_create(&my_playtree, config))) { |
| 1380 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
| 1381 // add it to end of list | |
| 1382 if (import_file_into_gui(filename, 0)) | |
| 1383 result = 1; | |
| 23077 | 1384 } |
| 1385 | |
| 33555 | 1386 uiCurr(); // update filename |
| 1387 uiGotoTheNext = 1; | |
| 23077 | 1388 |
| 32984 | 1389 if (!enqueue) |
| 33555 | 1390 filename = guiInfo.Filename; // Backward compatibility; if file is specified on commandline, |
| 1391 // gmplayer does directly start in Play-Mode. | |
| 32984 | 1392 else |
| 1393 filename = NULL; | |
| 23077 | 1394 |
| 32984 | 1395 return result; |
| 23077 | 1396 } |
| 1397 | |
| 32984 | 1398 // This function imports and inserts an playtree, that is created "on the fly", |
| 1399 // for example by parsing some MOV-Reference-File; or by loading an playlist | |
| 1400 // with "File Open". | |
| 23077 | 1401 // The file which contained the playlist is thereby replaced with it's contents. |
| 32984 | 1402 int import_playtree_playlist_into_gui(play_tree_t *my_playtree, m_config_t *config) |
| 1403 { | |
| 1404 play_tree_iter_t *my_pt_iter = NULL; | |
| 1405 int result = 0; | |
| 1406 plItem *save; | |
| 23077 | 1407 |
| 32984 | 1408 save = (plItem *)gtkSet(gtkGetCurrPlItem, 0, 0); // save current item |
| 23077 | 1409 |
| 32984 | 1410 if ((my_pt_iter = pt_iter_create(&my_playtree, config))) { |
| 1411 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
| 1412 // insert it into the list and set plCurrent=new item | |
| 1413 if (import_file_into_gui(filename, 1)) | |
| 1414 result = 1; | |
| 1415 | |
| 1416 pt_iter_destroy(&my_pt_iter); | |
| 23077 | 1417 } |
| 1418 | |
| 32984 | 1419 if (save) |
| 1420 gtkSet(gtkSetCurrPlItem, 0, (void *)save); | |
| 1421 else | |
| 1422 gtkSet(gtkSetCurrPlItem, 0, (void *)plList); // go to head, if plList was empty before | |
| 23077 | 1423 |
| 32984 | 1424 if (save && result) |
| 1425 gtkSet(gtkDelCurrPlItem, 0, 0); | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1426 |
| 33555 | 1427 uiCurr(); // update filename |
| 32984 | 1428 filename = NULL; |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1429 |
| 32984 | 1430 return result; |
| 23077 | 1431 } |
| 33023 | 1432 |
| 1433 // NOTE TO MYSELF: This function is nonsense. | |
| 33289 | 1434 // MPlayer should pass messages to the GUI |
| 1435 // which must decide then which message has | |
| 1436 // to be shown (MSGL_FATAL, for example). | |
| 1437 // But with this function it is at least | |
| 1438 // possible to show GUI's very critical or | |
| 1439 // abort messages. | |
| 33023 | 1440 void gmp_msg(int mod, int lev, const char *format, ...) |
| 1441 { | |
| 1442 char msg[512]; | |
| 1443 va_list va; | |
| 1444 | |
| 1445 va_start(va, format); | |
| 1446 vsnprintf(msg, sizeof(msg), format, va); | |
| 1447 va_end(va); | |
| 1448 | |
| 1449 mp_msg(mod, lev, msg); | |
| 1450 | |
| 1451 if (mp_msg_test(mod, lev)) | |
| 1452 gtkMessageBox(GTK_MB_FATAL, msg); | |
| 1453 } |
