~ubuntu-branches/ubuntu/saucy/mplayerplug-in/saucy

« back to all changes in this revision

Viewing changes to Source/plugin-ui.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2006-06-27 04:52:18 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060627045218-dx495rr0atvev8nu
Tags: 3.25-7ubuntu1
Resynchronise with Debian (Closes Ubuntu: #33722, #43382, #44639,
#48424).

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
#error libXpm has not been found. Compilation cannot continue
49
49
#endif
50
50
 
 
51
#ifdef X_ENABLED
 
52
unsigned long GetFontAtom(Display * dpy, XFontStruct * fs, char *atomname)
 
53
{
 
54
    unsigned long val;
 
55
    Atom atom = XInternAtom(dpy, atomname, True);
 
56
    XGetFontProperty(fs, atom, &val);
 
57
    return val;
 
58
}
 
59
#endif
 
60
 
51
61
void Initialize(Display * dpy, Drawable d, nsPluginInstance * instance,
52
62
                GC gc)
53
63
{
54
64
#ifdef X_ENABLED
55
65
    Cursor guicursor;
56
66
    XSetWindowAttributes attrs;
 
67
    char **missing_charset_list_return;
 
68
    int missing_charset_count_return;
 
69
    char *def_string_return;
57
70
 
58
71
    XpmCreatePixmapFromData(dpy, d, logo_xpm, &instance->logo,
59
72
                            &instance->logomask, NULL);
69
82
    XpmCreatePixmapFromData(dpy, d, progress_fill_xpm,
70
83
                            &instance->progress_fill,
71
84
                            &instance->progress_fillmask, NULL);
72
 
    instance->font = XQueryFont(dpy, XGContextFromGC(gc));
 
85
 
 
86
    if (!instance->font) {
 
87
        XFontStruct *fstr;
 
88
        char *family;
 
89
        unsigned long size = 14;
 
90
        char *italic;
 
91
        char *bold;
 
92
        char fontname[256];
 
93
 
 
94
        fstr = XQueryFont(dpy, XGContextFromGC(gc));
 
95
        family = XGetAtomName(dpy, GetFontAtom(dpy, fstr, "FAMILY_NAME"));
 
96
        bold = XGetAtomName(dpy, GetFontAtom(dpy, fstr, "WEIGHT_NAME"));
 
97
        italic = XGetAtomName(dpy, GetFontAtom(dpy, fstr, "SLANT"));
 
98
        size = GetFontAtom(dpy, fstr, "PIXEL_SIZE");
 
99
 
 
100
        sprintf(fontname, "-*-%s-%s-%s-*--%d-*",
 
101
                family, bold, italic, (int) size);
 
102
        instance->font = XCreateFontSet(dpy,
 
103
                                        fontname,
 
104
                                        &missing_charset_list_return,
 
105
                                        &missing_charset_count_return,
 
106
                                        &def_string_return);
 
107
    }
 
108
 
73
109
    guicursor = XCreateFontCursor(dpy, XC_watch);
74
110
    attrs.cursor = guicursor;
75
111
    XChangeWindowAttributes(dpy, d, CWCursor, &attrs);
289
325
        Initialize((Display *) instance->display,
290
326
                   (Drawable) instance->window, instance, black_gc);
291
327
    }
292
 
    font_height =
293
 
        instance->font->max_bounds.ascent +
294
 
        instance->font->max_bounds.descent;
295
 
    id_width = XTextWidth(instance->font, id, strlen(id));
 
328
 
 
329
    XFontSetExtents *extent;
 
330
    extent = XExtentsOfFontSet(instance->font);
 
331
    font_height = extent->max_logical_extent.height;
 
332
    id_width = XmbTextEscapement(instance->font, id, strlen(id));
296
333
 
297
334
    if (FullRedraw || instance->window_height <= 80) {
298
335
        XFillRectangle((Display *) instance->display,
313
350
        if (FullRedraw) {
314
351
            DrawLogo((Display *) instance->display,
315
352
                     (Drawable) instance->window, instance, black_gc);
316
 
            XDrawString((Display *) instance->display,
317
 
                        (Drawable) instance->window, black_gc,
318
 
                        instance->window_width - id_width - BORDER,
319
 
                        instance->window_height - font_height, id,
320
 
                        strlen(id));
 
353
            XmbDrawString((Display *) instance->display,
 
354
                          (Drawable) instance->window, instance->font,
 
355
                          black_gc,
 
356
                          instance->window_width - id_width - BORDER,
 
357
                          instance->window_height - font_height, id,
 
358
                          strlen(id));
321
359
        }
322
360
        if ((FullRedraw || PercentRedraw)
323
361
            && instance->window_width > id_width + BORDER * 3 + 100)
336
374
        while (strlen(message) != 0 && loops < 10) {
337
375
            chop = 0;
338
376
            term = 0;
339
 
            while (XTextWidth
 
377
            while (XmbTextEscapement
340
378
                   (instance->font, message,
341
379
                    strlen(message) - chop) + BORDER * 2 >
342
380
                   (int) instance->window_width)
347
385
                chop = strlen(message) - (strchr(message, '\n') - message);
348
386
                term = 1;
349
387
            }
350
 
            XDrawString((Display *) instance->display,
351
 
                        (Drawable) instance->window, black_gc, BORDER,
352
 
                        top, message, strlen(message) - chop);
 
388
            XmbDrawString((Display *) instance->display,
 
389
                          (Drawable) instance->window, instance->font,
 
390
                          black_gc, BORDER, top, message,
 
391
                          strlen(message) - chop);
353
392
            message += strlen(message) - chop + term;
354
393
            top += font_height;
355
394
            loops++;
378
417
                         11, instance->lastpercent);
379
418
 
380
419
    } else {
381
 
        XDrawString((Display *) instance->display,
382
 
                    (Drawable) instance->window, black_gc, BORDER, 15,
383
 
                    message, strlen(message));
 
420
        XmbDrawString((Display *) instance->display,
 
421
                      (Drawable) instance->window, instance->font,
 
422
                      black_gc, BORDER, 15, message, strlen(message));
384
423
    }
385
424
    if (percent != -1)
386
425
        instance->lastpercent = percent;
396
435
void FreeUI(Display * dpy, nsPluginInstance * instance)
397
436
{
398
437
#ifdef X_ENABLED
399
 
    instance->font = NULL;
 
438
    if (instance->font)
 
439
        XFreeFontSet(dpy, instance->font);
400
440
    // Free all the pixmaps used by the GUI
401
441
    if (instance->progress_left)
402
442
        XFreePixmap(dpy, instance->progress_left);
429
469
    instance->progress_rightmask = (Pixmap) NULL;
430
470
    instance->progress_fill = (Pixmap) NULL;
431
471
    instance->progress_fillmask = (Pixmap) NULL;
 
472
    instance->font = (XFontSet) NULL;
432
473
#endif
433
474
}
434
475
 
516
557
            gtk_widget_hide(GTK_WIDGET(instance->drawing_area));
517
558
            gtk_widget_show(GTK_WIDGET(instance->drawing_area));
518
559
        }
519
 
        if (GTK_IS_WIDGET(instance->src_event_box) && instance->targetplayer == 0) {
 
560
        if (GTK_IS_WIDGET(instance->src_event_box)
 
561
            && instance->targetplayer == 0) {
520
562
            gtk_widget_hide(instance->src_event_box);
521
563
        }
522
564
        gdk_flush();
650
692
            g_idle_add(gtkgui_message, instance);
651
693
            gtk_widget_hide(GTK_WIDGET(instance->mediaprogress_bar));
652
694
        }
 
695
        if (instance->showlogo)
 
696
                if (GTK_IS_WIDGET(instance->image))
 
697
                        gtk_widget_show(GTK_WIDGET(instance->image));
 
698
                
 
699
        if (!instance->hidestatus)
 
700
                if (GTK_IS_WIDGET(instance->status))
 
701
                        gtk_widget_show(GTK_WIDGET(instance->status));
 
702
                
653
703
        gdk_flush();
654
704
    }
655
705
    if (widget != NULL)
1012
1062
            instance->panel_height = instance->window_height;
1013
1063
        if (instance->panel_height > 16)
1014
1064
            instance->panel_height = 16;
1015
 
        if (instance->panel_height < 0)
1016
 
            instance->panel_height = 0;
 
1065
        if (instance->panel_height <= 0)
 
1066
            if (instance->showcontrols) {
 
1067
                instance->panel_height = 16;
 
1068
            } else {
 
1069
                instance->panel_height = 0;
 
1070
            }
1017
1071
        if (DEBUG) {
1018
1072
            printf("drawing panel\n height = %i panel= %i\n",
1019
1073
                   win_height, instance->panel_height);
1082
1136
#endif
1083
1137
            multiplier = 0;
1084
1138
            // rewind
1085
 
            if (instance->mmsstream == 0 && win_width > 126) {
 
1139
            if ((instance->mmsstream == 0 && win_width > 126) || instance->targetplayer == 1) {
1086
1140
                instance->rew_event_box = gtk_event_box_new();
1087
1141
                tooltip = gtk_tooltips_new();
1088
1142
                gtk_tooltips_set_tip(tooltip, instance->rew_event_box,
1093
1147
                g_signal_connect(G_OBJECT(instance->rew_event_box),
1094
1148
                                 "button_press_event",
1095
1149
                                 G_CALLBACK(rew_callback), instance);
 
1150
                gtk_widget_set_size_request(GTK_WIDGET
 
1151
                                            (instance->rew_event_box),
 
1152
                                            width, height);
1096
1153
#endif
1097
1154
#ifdef GTK1_ENABLED
1098
1155
                gtk_signal_connect(GTK_OBJECT(instance->rew_event_box),
1099
1156
                                   "button_press_event",
1100
1157
                                   GTK_SIGNAL_FUNC(rew_callback),
1101
1158
                                   instance);
 
1159
                gtk_widget_set_usize(GTK_WIDGET(instance->rew_event_box),
 
1160
                                     width, height);
1102
1161
#endif
1103
1162
                gtk_container_add(GTK_CONTAINER(instance->rew_event_box),
1104
1163
                                  instance->image_rew);
1105
1164
                gtk_fixed_put(GTK_FIXED(instance->fixed_container),
1106
1165
                              instance->rew_event_box,
1107
1166
                              width * multiplier++, win_height - height);
 
1167
 
1108
1168
                if (instance->showbuttons) {
1109
1169
                    gtk_widget_show(instance->image_rew);
1110
1170
                    gtk_widget_show(instance->rew_event_box);
1121
1181
            g_signal_connect(G_OBJECT(instance->play_event_box),
1122
1182
                             "button_press_event",
1123
1183
                             G_CALLBACK(play_callback), instance);
 
1184
            gtk_widget_set_size_request(GTK_WIDGET
 
1185
                                        (instance->play_event_box), width,
 
1186
                                        height);
1124
1187
#endif
1125
1188
#ifdef GTK1_ENABLED
1126
1189
            gtk_signal_connect(GTK_OBJECT(instance->play_event_box),
1127
1190
                               "button_press_event",
1128
1191
                               GTK_SIGNAL_FUNC(play_callback), instance);
 
1192
            gtk_widget_set_usize(GTK_WIDGET(instance->play_event_box),
 
1193
                                 width, height);
1129
1194
#endif
1130
1195
            gtk_container_add(GTK_CONTAINER(instance->play_event_box),
1131
1196
                              instance->image_play);
1147
1212
            g_signal_connect(G_OBJECT(instance->pause_event_box),
1148
1213
                             "button_press_event",
1149
1214
                             G_CALLBACK(pause_callback), instance);
 
1215
            gtk_widget_set_size_request(GTK_WIDGET
 
1216
                                        (instance->pause_event_box), width,
 
1217
                                        height);
1150
1218
#endif
1151
1219
#ifdef GTK1_ENABLED
1152
1220
            gtk_signal_connect(GTK_OBJECT(instance->pause_event_box),
1153
1221
                               "button_press_event",
1154
1222
                               GTK_SIGNAL_FUNC(pause_callback), instance);
 
1223
            gtk_widget_set_usize(GTK_WIDGET(instance->pause_event_box),
 
1224
                                 width, height);
1155
1225
#endif
1156
1226
            gtk_container_add(GTK_CONTAINER(instance->pause_event_box),
1157
1227
                              instance->image_pause);
1158
 
            if (win_width > 126) {
 
1228
            if (win_width > 126 || instance->targetplayer == 1) {
1159
1229
 
1160
1230
                gtk_fixed_put(GTK_FIXED(instance->fixed_container),
1161
1231
                              instance->pause_event_box,
1176
1246
            g_signal_connect(G_OBJECT(instance->stop_event_box),
1177
1247
                             "button_press_event",
1178
1248
                             G_CALLBACK(stop_callback), instance);
 
1249
            gtk_widget_set_size_request(GTK_WIDGET
 
1250
                                        (instance->stop_event_box), width,
 
1251
                                        height);
1179
1252
#endif
1180
1253
#ifdef GTK1_ENABLED
1181
1254
            gtk_signal_connect(GTK_OBJECT(instance->stop_event_box),
1182
1255
                               "button_press_event",
1183
1256
                               GTK_SIGNAL_FUNC(stop_callback), instance);
 
1257
            gtk_widget_set_usize(GTK_WIDGET(instance->stop_event_box),
 
1258
                                 width, height);
1184
1259
#endif
1185
1260
            gtk_container_add(GTK_CONTAINER(instance->stop_event_box),
1186
1261
                              instance->image_stop);
1192
1267
                gtk_widget_show(instance->stop_event_box);
1193
1268
            }
1194
1269
            // fastforward
1195
 
            if (instance->mmsstream == 0 && win_width > 126) {
 
1270
            if ((instance->mmsstream == 0 && win_width > 126) || instance->targetplayer == 1) {
1196
1271
                instance->ff_event_box = gtk_event_box_new();
1197
1272
                tooltip = gtk_tooltips_new();
1198
1273
                gtk_tooltips_set_tip(tooltip, instance->ff_event_box,
1203
1278
                g_signal_connect(G_OBJECT(instance->ff_event_box),
1204
1279
                                 "button_press_event",
1205
1280
                                 G_CALLBACK(ff_callback), instance);
 
1281
                gtk_widget_set_size_request(GTK_WIDGET
 
1282
                                            (instance->ff_event_box),
 
1283
                                            width, height);
1206
1284
#endif
1207
1285
#ifdef GTK1_ENABLED
1208
1286
                gtk_signal_connect(GTK_OBJECT(instance->ff_event_box),
1209
1287
                                   "button_press_event",
1210
1288
                                   GTK_SIGNAL_FUNC(ff_callback), instance);
 
1289
                gtk_widget_set_usize(GTK_WIDGET(instance->ff_event_box),
 
1290
                                     width, height);
1211
1291
#endif
1212
1292
                gtk_container_add(GTK_CONTAINER(instance->ff_event_box),
1213
1293
                                  instance->image_ff);
1219
1299
                    gtk_widget_show(instance->ff_event_box);
1220
1300
                }
1221
1301
            }
1222
 
 
1223
 
            if ((int) (width * multiplier + 10) <
1224
 
                (int) (win_width - 10 - width)) {
1225
 
                instance->mediaprogress_bar =
1226
 
                    GTK_PROGRESS_BAR(gtk_progress_bar_new());
1227
 
                gtk_widget_set_usize(GTK_WIDGET
1228
 
                                     (instance->mediaprogress_bar),
1229
 
                                     (win_width -
1230
 
                                      width * multiplier - 20 - width),
1231
 
                                     height - 2);
1232
 
                gtk_widget_set_events(GTK_WIDGET
1233
 
                                      (instance->mediaprogress_bar),
1234
 
                                      GDK_BUTTON_PRESS_MASK);
 
1302
//          if ((int) (width * multiplier + 10) <
 
1303
//              (int) (win_width - 10 - width)) {
 
1304
            instance->mediaprogress_bar =
 
1305
                GTK_PROGRESS_BAR(gtk_progress_bar_new());
 
1306
            gtk_widget_set_events(GTK_WIDGET
 
1307
                                  (instance->mediaprogress_bar),
 
1308
                                  GDK_BUTTON_PRESS_MASK);
1235
1309
#ifdef GTK2_ENABLED
1236
 
                g_signal_connect(G_OBJECT(instance->mediaprogress_bar),
1237
 
                                 "button_press_event",
1238
 
                                 G_CALLBACK(mediaprogress_callback),
1239
 
                                 instance);
 
1310
            g_signal_connect(G_OBJECT(instance->mediaprogress_bar),
 
1311
                             "button_press_event",
 
1312
                             G_CALLBACK(mediaprogress_callback), instance);
 
1313
            gtk_widget_set_size_request(GTK_WIDGET
 
1314
                                        (instance->mediaprogress_bar),
 
1315
                                        (win_width -
 
1316
                                         width * multiplier - 20 - width),
 
1317
                                        height - 2);
1240
1318
#endif
1241
1319
#ifdef GTK1_ENABLED
1242
 
                gtk_signal_connect(GTK_OBJECT(instance->mediaprogress_bar),
1243
 
                                   "button_press_event",
1244
 
                                   GTK_SIGNAL_FUNC(mediaprogress_callback),
1245
 
                                   instance);
 
1320
            gtk_signal_connect(GTK_OBJECT(instance->mediaprogress_bar),
 
1321
                               "button_press_event",
 
1322
                               GTK_SIGNAL_FUNC(mediaprogress_callback),
 
1323
                               instance);
 
1324
            gtk_widget_set_usize(GTK_WIDGET
 
1325
                                 (instance->mediaprogress_bar),
 
1326
                                 (win_width -
 
1327
                                  width * multiplier - 20 - width),
 
1328
                                 height - 2);
1246
1329
#endif
1247
 
                gtk_fixed_put(GTK_FIXED(instance->fixed_container),
1248
 
                              GTK_WIDGET(instance->mediaprogress_bar),
1249
 
                              (width * multiplier + 10),
1250
 
                              win_height - height + 1);
1251
 
            }
 
1330
            gtk_fixed_put(GTK_FIXED(instance->fixed_container),
 
1331
                          GTK_WIDGET(instance->mediaprogress_bar),
 
1332
                          (width * multiplier + 10),
 
1333
                          win_height - height + 1);
 
1334
            gtk_widget_realize(GTK_WIDGET(instance->mediaprogress_bar));
 
1335
//          }
1252
1336
 
1253
1337
            if (instance->mode == NP_EMBED && instance->noembed == 0)
1254
1338
                gtk_widget_hide(GTK_WIDGET(instance->progress_bar));
1264
1348
            g_signal_connect(G_OBJECT(instance->fs_event_box),
1265
1349
                             "button_press_event",
1266
1350
                             G_CALLBACK(fs_callback), instance);
 
1351
            gtk_widget_set_size_request(GTK_WIDGET(instance->fs_event_box),
 
1352
                                        width, height);
1267
1353
#endif
1268
1354
#ifdef GTK1_ENABLED
1269
1355
            gtk_signal_connect(GTK_OBJECT(instance->fs_event_box),
1270
1356
                               "button_press_event",
1271
1357
                               GTK_SIGNAL_FUNC(fs_callback), instance);
 
1358
            gtk_widget_set_usize(GTK_WIDGET(instance->fs_event_box), width,
 
1359
                                 height);
1272
1360
#endif
1273
1361
            gtk_container_add(GTK_CONTAINER(instance->fs_event_box),
1274
1362
                              instance->image_fs);
1275
 
            if (win_width > 126) {
 
1363
            if (win_width > 126 || instance->targetplayer == 1) {
1276
1364
                gtk_fixed_put(GTK_FIXED(instance->fixed_container),
1277
1365
                              instance->fs_event_box,
1278
1366
                              win_width - width, win_height - height);
1309
1397
    if (instance->status != NULL && instance->lastmessage != NULL)
1310
1398
        if (GTK_IS_LABEL(instance->status))
1311
1399
            gtk_label_set_text(instance->status, instance->lastmessage);        //GTK_LABEL
 
1400
 
 
1401
    if (instance->js_state == JS_STATE_TRANSITIONING) { 
 
1402
        if (GTK_IS_WIDGET(instance->image) && instance->showlogo)
 
1403
            gtk_widget_show(GTK_WIDGET(instance->image));
 
1404
        
 
1405
        if (GTK_IS_WIDGET(instance->status) && (!(instance->hidestatus)))
 
1406
            gtk_widget_show(GTK_WIDGET(instance->status));
 
1407
    }
 
1408
        
1312
1409
    return FALSE;
1313
1410
}
1314
1411
 
1337
1434
                gtk_widget_hide(GTK_WIDGET(instance->progress_bar));
1338
1435
        }
1339
1436
    }
 
1437
 
 
1438
    if (instance->js_state == JS_STATE_TRANSITIONING) { 
 
1439
        if (GTK_IS_WIDGET(instance->image) && instance->showlogo)
 
1440
            gtk_widget_show(GTK_WIDGET(instance->image));
 
1441
        
 
1442
        if (GTK_IS_WIDGET(instance->status) && (!(instance->hidestatus)))
 
1443
            gtk_widget_show(GTK_WIDGET(instance->status));
 
1444
    }
 
1445
 
1340
1446
    return FALSE;
1341
1447
}
1342
1448
 
1343
1449
gboolean gtkgui_resize(void *data)
1344
1450
{
1345
1451
    nsPluginInstance *instance;
 
1452
    int new_width, new_height;
1346
1453
 
1347
1454
    instance = (nsPluginInstance *) data;
1348
1455
    if (instance == NULL)
1350
1457
    if (instance->mInitialized == FALSE)
1351
1458
        return FALSE;
1352
1459
 
 
1460
    new_width = instance->movie_width;
 
1461
    new_height = instance->movie_height;
 
1462
        
1353
1463
    if (DEBUG > 1)
1354
1464
        printf("in resize method\nNew size is %i x %i\n",
1355
1465
               instance->movie_width, instance->movie_height);
1356
1466
    if (instance->drawing_area != NULL) {
1357
1467
        if (GTK_IS_WIDGET(instance->drawing_area)) {
1358
 
            gtk_widget_set_usize(instance->drawing_area,
1359
 
                                 instance->movie_width,
1360
 
                                 instance->movie_height);
1361
1468
            if (GTK_IS_WIDGET(instance->progress_bar))
1362
1469
                gtk_widget_hide(GTK_WIDGET(instance->progress_bar));
1363
 
            if (instance->mode == NP_FULL)
 
1470
            if (instance->mode == NP_FULL) {
1364
1471
                if ((instance->movie_width + 10 >= instance->window_width)
1365
1472
                    || (instance->movie_height + 100 >=
1366
 
                        instance->window_height))
1367
 
                    if (instance->fullscreen == 0)
 
1473
                        instance->window_height)) {
 
1474
                    if (instance->fullscreen == 0) {
1368
1475
                        if (GTK_IS_CONTAINER(instance->fixed_container)) {
 
1476
                            if (GTK_IS_WIDGET(instance->image))
 
1477
                                gtk_widget_hide(GTK_WIDGET(instance->image));
 
1478
                            if (GTK_IS_WIDGET(instance->status))
 
1479
                                gtk_widget_hide(GTK_WIDGET(instance->status));
 
1480
                            if (GTK_IS_WIDGET(instance->mediaprogress_bar))
 
1481
                                gtk_widget_hide(GTK_WIDGET(instance->mediaprogress_bar));
 
1482
                            instance->showtracker = 0;
1369
1483
                            gtk_fixed_put(GTK_FIXED
1370
1484
                                          (instance->fixed_container),
1371
1485
                                          instance->drawing_area, 0, 0);
1372
 
                            gtk_widget_hide(instance->drawing_area);
1373
 
                            gtk_widget_show(instance->drawing_area);
1374
 
                        }
1375
 
 
 
1486
                        }
 
1487
                    }
 
1488
                } 
 
1489
 
 
1490
                if (instance->showcontrols) {
 
1491
                    if (instance->movie_width > instance->window_width
 
1492
                        || instance->movie_height >
 
1493
                        (instance->window_height - 17)) {
 
1494
                        if (instance->movie_width > instance->window_width) {
 
1495
                            new_width = instance->window_width;
 
1496
                            new_height =
 
1497
                                (instance->window_width *
 
1498
                                 (instance->movie_height -
 
1499
                                  17)) / instance->movie_width;
 
1500
                        }
 
1501
 
 
1502
                        if (instance->movie_height >
 
1503
                            (instance->window_height - 17)) {
 
1504
                            new_height = (instance->window_height - 17);
 
1505
                            new_width =
 
1506
                                ((instance->window_height -
 
1507
                                  17) * instance->movie_width) /
 
1508
                                instance->movie_height;
 
1509
                        }
 
1510
 
 
1511
                    } else {
 
1512
                        new_width = instance->movie_width;
 
1513
                        new_height = instance->movie_height;
 
1514
 
 
1515
                    }
 
1516
                } else {
 
1517
                    if (instance->movie_width > instance->window_width
 
1518
                        || instance->movie_height >
 
1519
                        instance->window_height) {
 
1520
                        if (instance->movie_width > instance->window_width) {
 
1521
                            new_width = instance->window_width;
 
1522
                            new_height =
 
1523
                                (instance->window_width *
 
1524
                                 instance->movie_height) /
 
1525
                                instance->movie_width;
 
1526
                        }
 
1527
 
 
1528
                        if (instance->movie_height >
 
1529
                            instance->window_height) {
 
1530
                            new_height = instance->window_height;
 
1531
                            new_width =
 
1532
                                (instance->window_height *
 
1533
                                 instance->movie_width) /
 
1534
                                instance->movie_height;
 
1535
                        }
 
1536
 
 
1537
                    } else {
 
1538
                        new_width = instance->movie_width;
 
1539
                        new_height = instance->movie_height;
 
1540
 
 
1541
                    }
 
1542
                }
 
1543
                gtk_widget_set_usize(instance->drawing_area,
 
1544
                                     new_width, new_height);
 
1545
 
 
1546
                if ((instance->movie_width + 10) >= instance->window_width
 
1547
                    || (instance->movie_height + 100) >=
 
1548
                    instance->window_height) {
 
1549
                    gtk_fixed_put(GTK_FIXED(instance->fixed_container),
 
1550
                                  instance->drawing_area, 0, 0);
 
1551
                    if (GTK_IS_WIDGET(instance->image))
 
1552
                        gtk_widget_hide(GTK_WIDGET(instance->image));
 
1553
                    if (GTK_IS_WIDGET(instance->status))
 
1554
                        gtk_widget_hide(GTK_WIDGET(instance->status));
 
1555
                    if (GTK_IS_WIDGET(instance->mediaprogress_bar))
 
1556
                        gtk_widget_hide(GTK_WIDGET(instance->mediaprogress_bar));
 
1557
 
 
1558
                } else {
 
1559
                    gtk_fixed_put(GTK_FIXED
 
1560
                                  (instance->fixed_container),
 
1561
                                  instance->drawing_area, 10, 100);
 
1562
                    if (GTK_IS_WIDGET(instance->image))
 
1563
                        gtk_widget_show(GTK_WIDGET(instance->image));
 
1564
                    if (GTK_IS_WIDGET(instance->status))
 
1565
                        gtk_widget_show(GTK_WIDGET(instance->status));
 
1566
                }
 
1567
 
 
1568
            } else {
 
1569
                if (instance->targetplayer && instance->showcontrols) {
 
1570
                    gtk_widget_set_usize(instance->drawing_area,
 
1571
                                         instance->movie_width,
 
1572
                                         instance->movie_height + 16 );
 
1573
                
 
1574
                } else {
 
1575
                    if (instance->showcontrols) {
 
1576
                        if (instance->movie_height > (instance->window_height - 16)) {
 
1577
                                gtk_widget_set_size_request(GTK_WIDGET(instance->drawing_area),instance->movie_width,instance->window_height -16);
 
1578
                        } else {
 
1579
                                gtk_widget_set_size_request(GTK_WIDGET(instance->drawing_area),instance->movie_width,instance->movie_height);
 
1580
                        }
 
1581
                    } else {
 
1582
                        gtk_widget_set_size_request(GTK_WIDGET(instance->drawing_area),instance->movie_width,instance->movie_height);
 
1583
                    }
 
1584
 
 
1585
                }
 
1586
 
 
1587
            }
1376
1588
        }
1377
1589
    }
1378
1590
 
1505
1717
        return FALSE;
1506
1718
    if (instance->mInitialized == FALSE)
1507
1719
        return FALSE;
 
1720
 
 
1721
 
1508
1722
    if (instance->mediaprogress_bar != NULL) {
1509
1723
        if (GTK_IS_PROGRESS_BAR(instance->mediaprogress_bar)) {
1510
1724
            if (((int) instance->mediaLength > 0)
1511
1725
                && (instance->mediaPercent <= 100)) {
1512
 
                if (instance->controlsvisible && instance->showtracker)
 
1726
                if (instance->controlsvisible && instance->showtracker) {
1513
1727
                    gtk_widget_show(GTK_WIDGET
1514
1728
                                    (instance->mediaprogress_bar));
1515
 
                gtk_progress_bar_update(instance->mediaprogress_bar,
1516
 
                                        instance->mediaPercent / 100.0);
 
1729
                    gtk_progress_bar_update(instance->mediaprogress_bar,
 
1730
                                            instance->mediaPercent /
 
1731
                                            100.0);
1517
1732
 
1518
1733
#ifdef GTK2_ENABLED
1519
 
                if (((int) instance->mediaTime > 0)
1520
 
                    && (instance->showtime == 1)) {
1521
 
                    seconds = (int) instance->mediaTime;
1522
 
                    if (seconds >= 3600) {
1523
 
                        hour = seconds / 3600;
1524
 
                        seconds = seconds - (hour * 3600);
1525
 
                    }
1526
 
                    if (seconds >= 60) {
1527
 
                        min = seconds / 60;
1528
 
                        seconds = seconds - (min * 60);
1529
 
                    }
1530
 
                    length_seconds = (int) instance->mediaLength;
1531
 
                    if (length_seconds >= 3600) {
1532
 
                        length_hour = length_seconds / 3600;
1533
 
                        length_seconds =
1534
 
                            length_seconds - (length_hour * 3600);
1535
 
                    }
1536
 
                    if (length_seconds >= 60) {
1537
 
                        length_min = length_seconds / 60;
1538
 
                        length_seconds =
1539
 
                            length_seconds - (length_min * 60);
1540
 
                    }
1541
 
                    if (hour == 0 && length_hour == 0) {
1542
 
                        snprintf(display, 30, "%2i:%02i / %2i:%02i", min,
1543
 
                                 (int) seconds, length_min,
1544
 
                                 (int) length_seconds);
 
1734
                    if (((int) instance->mediaTime > 0)
 
1735
                        && (instance->showtime == 1)) {
 
1736
                        seconds = (int) instance->mediaTime;
 
1737
                        if (seconds >= 3600) {
 
1738
                            hour = seconds / 3600;
 
1739
                            seconds = seconds - (hour * 3600);
 
1740
                        }
 
1741
                        if (seconds >= 60) {
 
1742
                            min = seconds / 60;
 
1743
                            seconds = seconds - (min * 60);
 
1744
                        }
 
1745
                        length_seconds = (int) instance->mediaLength;
 
1746
                        if (length_seconds >= 3600) {
 
1747
                            length_hour = length_seconds / 3600;
 
1748
                            length_seconds =
 
1749
                                length_seconds - (length_hour * 3600);
 
1750
                        }
 
1751
                        if (length_seconds >= 60) {
 
1752
                            length_min = length_seconds / 60;
 
1753
                            length_seconds =
 
1754
                                length_seconds - (length_min * 60);
 
1755
                        }
 
1756
                        if (hour == 0 && length_hour == 0) {
 
1757
                            snprintf(display, 30, "%2i:%02i / %2i:%02i",
 
1758
                                     min, (int) seconds, length_min,
 
1759
                                     (int) length_seconds);
 
1760
                        } else {
 
1761
                            snprintf(display, 30,
 
1762
                                     "%i:%02i:%02i / %i:%02i:%02i", hour,
 
1763
                                     min, (int) seconds, length_hour,
 
1764
                                     length_min, (int) length_seconds);
 
1765
                        }
 
1766
 
 
1767
                        gtk_progress_bar_set_text(instance->
 
1768
                                                  mediaprogress_bar,
 
1769
                                                  display);
1545
1770
                    } else {
1546
 
                        snprintf(display, 30,
1547
 
                                 "%i:%02i:%02i / %i:%02i:%02i", hour, min,
1548
 
                                 (int) seconds, length_hour, length_min,
1549
 
                                 (int) length_seconds);
 
1771
                        if (gtk_progress_bar_get_text
 
1772
                            (instance->mediaprogress_bar) != NULL)
 
1773
                            gtk_progress_bar_set_text(instance->
 
1774
                                                      mediaprogress_bar,
 
1775
                                                      NULL);
1550
1776
                    }
1551
 
                    gtk_progress_bar_set_text(instance->mediaprogress_bar,
1552
 
                                              display);
 
1777
#endif
 
1778
 
1553
1779
                } else {
1554
 
                    snprintf(display, 30, "");
1555
 
                    gtk_progress_bar_set_text(instance->mediaprogress_bar,
1556
 
                                              display);
 
1780
                    gtk_widget_hide(GTK_WIDGET
 
1781
                                    (instance->mediaprogress_bar));
1557
1782
                }
1558
 
#endif
1559
 
            
1560
1783
            } else {
1561
 
                gtk_widget_hide(GTK_WIDGET(instance->mediaprogress_bar));
 
1784
                gtk_widget_hide(GTK_WIDGET
 
1785
                                (instance->mediaprogress_bar));
1562
1786
            }
1563
1787
        }
1564
1788
    }
1662
1886
        win_width = instance->movie_width;
1663
1887
    }
1664
1888
 
1665
 
    printf("buttons are at %i x %i\n", win_height, win_width);
 
1889
    if (DEBUG)
 
1890
        printf("buttons are at %i x %i\n", win_height, win_width);
1666
1891
 
1667
1892
    if (instance->panel_drawn == 1) {
1668
1893
        height = 16;
1674
1899
            if (instance->rew_event_box != NULL) {
1675
1900
                if (instance->showcontrols && instance->showbuttons) {
1676
1901
                    gtk_widget_show(GTK_WIDGET(instance->rew_event_box));
1677
 
                    gtk_fixed_move(GTK_FIXED(instance->fixed_container),
 
1902
                    gtk_fixed_move(GTK_FIXED
 
1903
                                   (instance->fixed_container),
1678
1904
                                   GTK_WIDGET(instance->rew_event_box),
1679
1905
                                   width * multiplier++,
1680
1906
                                   win_height - height);
1696
1922
            if (instance->ff_event_box != NULL) {
1697
1923
                if (instance->showcontrols && instance->showbuttons) {
1698
1924
                    gtk_widget_show(GTK_WIDGET(instance->rew_event_box));
1699
 
                    gtk_fixed_move(GTK_FIXED(instance->fixed_container),
 
1925
                    gtk_fixed_move(GTK_FIXED
 
1926
                                   (instance->fixed_container),
1700
1927
                                   GTK_WIDGET(instance->ff_event_box),
1701
1928
                                   width * multiplier++,
1702
1929
                                   win_height - height);
1712
1939
                       GTK_WIDGET(instance->fs_event_box),
1713
1940
                       (win_width - width), win_height - height + 2);
1714
1941
 
 
1942
        gtk_widget_show(GTK_WIDGET(instance->mediaprogress_bar));
1715
1943
        gtk_widget_set_usize(GTK_WIDGET(instance->mediaprogress_bar),
1716
 
                             win_width - (width * (multiplier + 1) + 20),
1717
 
                             height - 4);
 
1944
                             win_width - (width * (multiplier + 1) +
 
1945
                                          20), height - 4);
1718
1946
 
1719
1947
    }
1720
1948
    return FALSE;
1950
2178
 
1951
2179
    instance->cachesize =
1952
2180
        (int) gtk_range_get_value(GTK_RANGE(instance->conf_cachesize));
1953
 
    instance->cache_percent =
1954
 
        (int) gtk_range_get_value(GTK_RANGE(instance->conf_cachepercent));
 
2181
    instance->cache_percent = (int)
 
2182
        gtk_range_get_value(GTK_RANGE(instance->conf_cachepercent));
1955
2183
 
1956
2184
#ifdef GTK24_ENABLED
1957
2185
    if (instance->vo != NULL)
1972
2200
        strdup(gtk_entry_get_text
1973
2201
               (GTK_ENTRY(GTK_BIN(instance->conf_dir)->child)));
1974
2202
#endif
1975
 
    
 
2203
 
1976
2204
    instance->showtime =
1977
2205
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
1978
2206
                                     (instance->conf_showtime));
1997
2225
    instance->enable_ogg =
1998
2226
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
1999
2227
                                     (instance->conf_enable_ogg));
 
2228
    instance->enable_midi =
 
2229
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
2230
                                     (instance->conf_enable_midi));
 
2231
    instance->enable_pls =
 
2232
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
2233
                                     (instance->conf_enable_pls));
2000
2234
    instance->enable_smil =
2001
2235
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
2002
2236
                                     (instance->conf_enable_smil));
2012
2246
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
2013
2247
                                     (instance->conf_rtsptcp));
2014
2248
 
 
2249
    instance->rtsp_use_http =
 
2250
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
2251
                                     (instance->conf_rtsphttp));
 
2252
 
 
2253
    instance->nopauseonhide =
 
2254
        !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
2255
                                      (instance->conf_pauseonhide));
 
2256
 
2015
2257
    gtk_widget_destroy(instance->conf_window);
2016
2258
    instance->conf_window = NULL;
2017
2259
 
2051
2293
        fprintf(output, "enable-mpeg=%i\n", instance->enable_mpeg);
2052
2294
        fprintf(output, "enable-mp3=%i\n", instance->enable_mp3);
2053
2295
        fprintf(output, "enable-ogg=%i\n", instance->enable_ogg);
 
2296
        fprintf(output, "enable-midi=%i\n", instance->enable_midi);
 
2297
        fprintf(output, "enable-pls=%i\n", instance->enable_pls);
2054
2298
        fprintf(output, "enable-smil=%i\n", instance->enable_smil);
2055
2299
        fprintf(output, "enable-helix=%i\n", instance->enable_helix);
2056
2300
        fprintf(output, "nomediacache=%i\n", instance->nomediacache);
 
2301
        fprintf(output, "nopauseonhide=%i\n", instance->nopauseonhide);
2057
2302
        fprintf(output, "rtsp-use-tcp=%i\n", instance->rtsp_use_tcp);
 
2303
        fprintf(output, "rtsp-use-http=%i\n", instance->rtsp_use_http);
2058
2304
 
2059
2305
 
2060
2306
        while (fgets(buffer, sizeof(buffer), input) != NULL) {
2069
2315
            } else if (strncasecmp(buffer, "enable-rm", 9) == 0) {
2070
2316
            } else if (strncasecmp(buffer, "enable-mpeg", 11) == 0) {
2071
2317
            } else if (strncasecmp(buffer, "enable-mp3", 10) == 0) {
 
2318
            } else if (strncasecmp(buffer, "enable-midi", 11) == 0) {
 
2319
            } else if (strncasecmp(buffer, "enable-pls", 10) == 0) {
2072
2320
            } else if (strncasecmp(buffer, "enable-ogg", 10) == 0) {
2073
2321
            } else if (strncasecmp(buffer, "enable-gmp", 10) == 0) {
2074
2322
            } else if (strncasecmp(buffer, "enable-smil", 11) == 0) {
2075
2323
            } else if (strncasecmp(buffer, "enable-helix", 12) == 0) {
2076
2324
            } else if (strncasecmp(buffer, "nomediacache", 12) == 0) {
 
2325
            } else if (strncasecmp(buffer, "nopauseonhide", 13) == 0) {
2077
2326
            } else if (strncasecmp(buffer, "rtsp-use-tcp", 12) == 0) {
 
2327
            } else if (strncasecmp(buffer, "rtsp-use-http", 13) == 0) {
2078
2328
            } else {
2079
2329
                fprintf(output, "%s", buffer);
2080
2330
            }
2119
2369
            fprintf(output, "enable-gmp=%i\n", instance->enable_gmp);
2120
2370
            fprintf(output, "enable-mpeg=%i\n", instance->enable_mpeg);
2121
2371
            fprintf(output, "enable-mp3=%i\n", instance->enable_mp3);
 
2372
            fprintf(output, "enable-midi=%i\n", instance->enable_midi);
 
2373
            fprintf(output, "enable-pls=%i\n", instance->enable_pls);
2122
2374
            fprintf(output, "enable-ogg=%i\n", instance->enable_ogg);
2123
2375
            fprintf(output, "enable-smil=%i\n", instance->enable_smil);
2124
2376
            fprintf(output, "enable-helix=%i\n", instance->enable_helix);
2125
2377
            fprintf(output, "nomediacache=%i\n", instance->nomediacache);
 
2378
            fprintf(output, "nopauseonhide=%i\n", instance->nopauseonhide);
2126
2379
            fprintf(output, "rtsp-use-tcp=%i\n", instance->rtsp_use_tcp);
 
2380
            fprintf(output, "rtsp-use-http=%i\n", instance->rtsp_use_http);
2127
2381
            fclose(output);
2128
2382
            ret = rename(tmp_name, config_name);
2129
2383
            if (ret == -1) {
2174
2428
    gtk_container_add(GTK_CONTAINER(conf_vbox), conf_hbutton_box);
2175
2429
    gtk_container_add(GTK_CONTAINER(instance->conf_window), conf_vbox);
2176
2430
    gtk_window_set_title(GTK_WINDOW(instance->conf_window),
2177
 
                         "mplayerplug-in configuration");
2178
 
    gtk_container_set_border_width(GTK_CONTAINER(instance->conf_window),
2179
 
                                   5);
 
2431
                         _("mplayerplug-in configuration"));
 
2432
    gtk_container_set_border_width(GTK_CONTAINER
 
2433
                                   (instance->conf_window), 5);
2180
2434
    g_signal_connect(GTK_OBJECT(instance->conf_window), "delete_event",
2181
2435
                     GTK_SIGNAL_FUNC(CloseConfigEvent), instance);
2182
2436
 
2188
2442
        gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_vo), "xv");
2189
2443
        if (instance->vo != NULL) {
2190
2444
            if (strcmp(instance->vo, "gl") == 0)
2191
 
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_vo),
2192
 
                                         0);
 
2445
                gtk_combo_box_set_active(GTK_COMBO_BOX
 
2446
                                         (instance->conf_vo), 0);
2193
2447
            if (strcmp(instance->vo, "x11") == 0)
2194
 
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_vo),
2195
 
                                         1);
 
2448
                gtk_combo_box_set_active(GTK_COMBO_BOX
 
2449
                                         (instance->conf_vo), 1);
2196
2450
            if (strcmp(instance->vo, "xv") == 0)
2197
 
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_vo),
2198
 
                                         2);
 
2451
                gtk_combo_box_set_active(GTK_COMBO_BOX
 
2452
                                         (instance->conf_vo), 2);
2199
2453
            if (gtk_combo_box_get_active(GTK_COMBO_BOX(instance->conf_vo))
2200
2454
                == -1) {
2201
 
                gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_vo),
 
2455
                gtk_combo_box_append_text(GTK_COMBO_BOX
 
2456
                                          (instance->conf_vo),
2202
2457
                                          instance->vo);
2203
 
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_vo),
2204
 
                                         3);
 
2458
                gtk_combo_box_set_active(GTK_COMBO_BOX
 
2459
                                         (instance->conf_vo), 3);
2205
2460
            }
2206
2461
        }
2207
2462
    }
2213
2468
        gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao),
2214
2469
                                  "arts");
2215
2470
        gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao), "esd");
 
2471
        gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao),
 
2472
                                  "jack");
2216
2473
        gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao), "oss");
2217
2474
        if (instance->ao != NULL) {
2218
2475
            if (strcmp(instance->ao, "alsa") == 0)
2219
 
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao),
2220
 
                                         0);
 
2476
                gtk_combo_box_set_active(GTK_COMBO_BOX
 
2477
                                         (instance->conf_ao), 0);
2221
2478
            if (strcmp(instance->ao, "arts") == 0)
2222
 
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao),
2223
 
                                         1);
 
2479
                gtk_combo_box_set_active(GTK_COMBO_BOX
 
2480
                                         (instance->conf_ao), 1);
2224
2481
            if (strcmp(instance->ao, "esd") == 0)
2225
 
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao),
2226
 
                                         2);
 
2482
                gtk_combo_box_set_active(GTK_COMBO_BOX
 
2483
                                         (instance->conf_ao), 2);
 
2484
            if (strcmp(instance->ao, "jack") == 0)
 
2485
                gtk_combo_box_set_active(GTK_COMBO_BOX
 
2486
                                         (instance->conf_ao), 3);
2227
2487
            if (strcmp(instance->ao, "oss") == 0)
2228
 
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao),
2229
 
                                         3);
 
2488
                gtk_combo_box_set_active(GTK_COMBO_BOX
 
2489
                                         (instance->conf_ao), 4);
2230
2490
            if (gtk_combo_box_get_active(GTK_COMBO_BOX(instance->conf_ao))
2231
2491
                == -1) {
2232
 
                gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_ao),
 
2492
                gtk_combo_box_append_text(GTK_COMBO_BOX
 
2493
                                          (instance->conf_ao),
2233
2494
                                          instance->ao);
2234
 
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_ao),
2235
 
                                         4);
 
2495
                gtk_combo_box_set_active(GTK_COMBO_BOX
 
2496
                                         (instance->conf_ao), 4);
2236
2497
            }
2237
2498
        }
2238
2499
    }
2243
2504
                                  "$HOME");
2244
2505
        if (instance->download_dir != NULL) {
2245
2506
            if (strcmp(instance->download_dir, "$HOME") == 0)
2246
 
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_dir),
2247
 
                                         0);
 
2507
                gtk_combo_box_set_active(GTK_COMBO_BOX
 
2508
                                         (instance->conf_dir), 0);
2248
2509
            if (gtk_combo_box_get_active(GTK_COMBO_BOX(instance->conf_dir))
2249
2510
                == -1) {
2250
2511
                gtk_combo_box_append_text(GTK_COMBO_BOX
2251
2512
                                          (instance->conf_dir),
2252
2513
                                          instance->download_dir);
2253
 
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_dir),
2254
 
                                         1);
 
2514
                gtk_combo_box_set_active(GTK_COMBO_BOX
 
2515
                                         (instance->conf_dir), 1);
2255
2516
            }
2256
2517
        }
2257
2518
    }
2268
2529
#ifdef GTK24_ENABLED
2269
2530
    conf_label = gtk_label_new(_("Video Output:"));
2270
2531
    gtk_misc_set_alignment(GTK_MISC(conf_label), 0.0, 0.0);
2271
 
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1, 0,
2272
 
                              1);
 
2532
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1,
 
2533
                              0, 1);
2273
2534
    gtk_widget_show(conf_label);
2274
 
    gtk_table_attach_defaults(GTK_TABLE(conf_table), instance->conf_vo, 1,
2275
 
                              2, 0, 1);
 
2535
    gtk_table_attach_defaults(GTK_TABLE(conf_table), instance->conf_vo,
 
2536
                              1, 2, 0, 1);
2276
2537
 
2277
2538
    conf_label = gtk_label_new(_("Audio Output:"));
2278
2539
    gtk_misc_set_alignment(GTK_MISC(conf_label), 0.0, 0.0);
2279
 
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1, 1,
2280
 
                              2);
 
2540
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1,
 
2541
                              1, 2);
2281
2542
    gtk_widget_show(conf_label);
2282
2543
    gtk_misc_set_alignment(GTK_MISC(conf_label), 0.0, 0.0);
2283
 
    gtk_table_attach_defaults(GTK_TABLE(conf_table), instance->conf_ao, 1,
2284
 
                              2, 1, 2);
 
2544
    gtk_table_attach_defaults(GTK_TABLE(conf_table), instance->conf_ao,
 
2545
                              1, 2, 1, 2);
2285
2546
    conf_label = gtk_label_new(_("Save to Location:"));
2286
 
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1, 2,
2287
 
                              3);
 
2547
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1,
 
2548
                              2, 3);
2288
2549
    gtk_widget_show(conf_label);
2289
2550
    gtk_misc_set_alignment(GTK_MISC(conf_label), 0.0, 0.0);
2290
 
    gtk_table_attach_defaults(GTK_TABLE(conf_table), instance->conf_dir, 1,
2291
 
                              2, 2, 3);
 
2551
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2552
                              instance->conf_dir, 1, 2, 2, 3);
2292
2553
#endif
2293
2554
 
2294
2555
    conf_label = gtk_label_new(_("Minimum Cache Size:"));
2295
2556
    gtk_misc_set_alignment(GTK_MISC(conf_label), 0.0, 0.0);
2296
 
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1, 3,
2297
 
                              4);
 
2557
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1,
 
2558
                              3, 4);
2298
2559
    gtk_widget_show(conf_label);
2299
2560
    instance->conf_cachesize = gtk_hscale_new_with_range(0, 32767, 512);
2300
2561
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
2305
2566
 
2306
2567
    conf_label = gtk_label_new(_("Percent of Media to Cache:"));
2307
2568
    gtk_misc_set_alignment(GTK_MISC(conf_label), 0.0, 0.0);
2308
 
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1, 4,
2309
 
                              5);
 
2569
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1,
 
2570
                              4, 5);
2310
2571
    gtk_widget_show(conf_label);
2311
2572
    instance->conf_cachepercent = gtk_hscale_new_with_range(0, 100, 5);
2312
2573
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
2429
2690
                                 instance->enable_ogg);
2430
2691
    gtk_widget_show(instance->conf_enable_ogg);
2431
2692
 
 
2693
    instance->conf_enable_midi =
 
2694
        gtk_check_button_new_with_label(_("Enable MIDI Support"));
 
2695
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2696
                              instance->conf_enable_midi, 1, 2, row,
 
2697
                              row + 1);
 
2698
    row++;
 
2699
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2700
                                 (instance->conf_enable_midi),
 
2701
                                 instance->enable_midi);
 
2702
    gtk_widget_show(instance->conf_enable_midi);
 
2703
 
 
2704
    instance->conf_enable_pls =
 
2705
        gtk_check_button_new_with_label(_("Enable Shoutcast PLS Support"));
 
2706
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2707
                              instance->conf_enable_pls, 1, 2, row,
 
2708
                              row + 1);
 
2709
    row++;
 
2710
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2711
                                 (instance->conf_enable_pls),
 
2712
                                 instance->enable_pls);
 
2713
    gtk_widget_show(instance->conf_enable_pls);
 
2714
 
2432
2715
    instance->conf_nomediacache =
2433
2716
        gtk_check_button_new_with_label(_
2434
2717
                                        ("Play media directly from site (No Caching)"));
2447
2730
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
2448
2731
                              instance->conf_rtsptcp, 1, 2, row, row + 1);
2449
2732
    row++;
2450
 
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(instance->conf_rtsptcp),
 
2733
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2734
                                 (instance->conf_rtsptcp),
2451
2735
                                 instance->rtsp_use_tcp);
2452
2736
    gtk_widget_show(instance->conf_rtsptcp);
2453
2737
 
 
2738
    instance->conf_rtsphttp =
 
2739
        gtk_check_button_new_with_label(_("Use HTTP instead of RTSP"));
 
2740
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2741
                              instance->conf_rtsphttp, 1, 2, row, row + 1);
 
2742
    row++;
 
2743
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2744
                                 (instance->conf_rtsphttp),
 
2745
                                 instance->rtsp_use_http);
 
2746
    gtk_widget_show(instance->conf_rtsphttp);
 
2747
 
 
2748
    instance->conf_pauseonhide =
 
2749
        gtk_check_button_new_with_label(_("Pause Video when hidden"));
 
2750
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2751
                              instance->conf_pauseonhide, 1, 2, row,
 
2752
                              row + 1);
 
2753
    row++;
 
2754
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2755
                                 (instance->conf_pauseonhide),
 
2756
                                 !instance->nopauseonhide);
 
2757
    gtk_widget_show(instance->conf_pauseonhide);
 
2758
 
2454
2759
 
2455
2760
    gtk_container_add(GTK_CONTAINER(conf_hbutton_box), conf_ok);
2456
2761
    gtk_container_add(GTK_CONTAINER(conf_hbutton_box), conf_cancel);
2481
2786
 
2482
2787
    // only pause if video is present, if we have streaming audio we want to keep playing
2483
2788
 
2484
 
    if (event->type == GDK_VISIBILITY_NOTIFY) {
2485
 
 
2486
 
        if (((GdkEventVisibility *) event)->state ==
2487
 
            GDK_VISIBILITY_FULLY_OBSCURED) {
2488
 
            if (instance->paused == 0 && instance->threadsignaled
2489
 
                && instance->nopauseonhide == 0) {
2490
 
 
2491
 
                if (instance->movie_width != 0
2492
 
                    && instance->movie_height != 0) {
2493
 
                    instance->Pause();
2494
 
                    instance->paused_wheninvisible = 1;
2495
 
                }
2496
 
            }
2497
 
 
2498
 
            if (instance->onHiddenCallback != NULL)
2499
 
                NPN_GetURL(instance->mInstance,
2500
 
                           instance->onHiddenCallback, "_self");
2501
 
 
2502
 
        } else {
2503
 
            if (instance->paused_wheninvisible == 1
2504
 
                && instance->threadsignaled
2505
 
                && instance->nopauseonhide == 0) {
2506
 
 
2507
 
                if (instance->movie_width != 0
2508
 
                    && instance->movie_height != 0) {
2509
 
                    instance->Play();
2510
 
                    instance->paused_wheninvisible = 0;
2511
 
                }
2512
 
            }
2513
 
 
2514
 
            if (instance->onVisibleCallback != NULL)
2515
 
                NPN_GetURL(instance->mInstance,
2516
 
                           instance->onVisibleCallback, "_self");
 
2789
    if (instance->cancelled == 0) {
 
2790
 
 
2791
        if (event->type == GDK_VISIBILITY_NOTIFY) {
 
2792
 
 
2793
            if (((GdkEventVisibility *) event)->state ==
 
2794
                GDK_VISIBILITY_FULLY_OBSCURED) {
 
2795
                if (instance->paused == 0 && instance->threadsignaled
 
2796
                    && instance->nopauseonhide == 0) {
 
2797
 
 
2798
                    if (instance->movie_width != 0
 
2799
                        && instance->movie_height != 0) {
 
2800
                        instance->Pause();
 
2801
                        instance->paused_wheninvisible = 1;
 
2802
                    }
 
2803
                }
 
2804
 
 
2805
                if (instance->onHiddenCallback != NULL)
 
2806
                    NPN_GetURL(instance->mInstance,
 
2807
                               instance->onHiddenCallback, "_self");
 
2808
 
 
2809
            } else {
 
2810
                if (instance->paused_wheninvisible == 1
 
2811
                    && instance->threadsignaled
 
2812
                    && instance->nopauseonhide == 0) {
 
2813
 
 
2814
                    if (instance->movie_width != 0
 
2815
                        && instance->movie_height != 0) {
 
2816
                        instance->Play();
 
2817
                        instance->paused_wheninvisible = 0;
 
2818
                    }
 
2819
                }
 
2820
 
 
2821
                if (instance->onVisibleCallback != NULL)
 
2822
                    NPN_GetURL(instance->mInstance,
 
2823
                               instance->onVisibleCallback, "_self");
 
2824
 
 
2825
            }
2517
2826
 
2518
2827
        }
2519
 
 
2520
2828
    }
2521
 
 
2522
2829
    return (FALSE);
2523
2830
 
2524
2831
}
2536
2843
        event_button = (GdkEventButton *) event;
2537
2844
 
2538
2845
        if (event_button->button == 3) {
2539
 
            gtk_menu_popup(instance->popup_menu, NULL, NULL, NULL, NULL,
2540
 
                           event_button->button, event_button->time);
 
2846
            gtk_menu_popup(instance->popup_menu, NULL, NULL, NULL,
 
2847
                           NULL, event_button->button, event_button->time);
2541
2848
            return TRUE;
2542
2849
        }
2543
2850
 
2562
2869
            } else {
2563
2870
                if (instance->targetplayer == 0)
2564
2871
                    gtk_widget_hide(instance->src_event_box);
2565
 
                n->play = 1;
 
2872
                n->play = 1;
2566
2873
                instance->Play();
2567
2874
            }
2568
2875
 
2577
2884
 
2578
2885
}
2579
2886
#endif
 
2887
#endif                          // GTK_ENABLED
2580
2888
 
2581
2889
int srcToButton(char *url, nsPluginInstance * instance)
2582
2890
{
2589
2897
    gchar *command;
2590
2898
    GError *error = NULL;
2591
2899
    int exit_status;
2592
 
    gchar *dirname;
2593
 
    gchar *filename;
 
2900
    gchar *dirname = NULL;
 
2901
    gchar *filename = NULL;
2594
2902
    gboolean result;
2595
2903
    GtkWidget *fixed_button_container;
2596
2904
 
2597
2905
    if (DEBUG)
2598
2906
        printf("In srcToButton\n");
2599
2907
 
2600
 
    // setup tmp directory
2601
 
    dirname =
2602
 
        g_strdup_printf("%s", tempnam("/tmp", "mplayerplug-inXXXXXX"));
2603
 
    filename = g_strdup_printf("%s/00000001.jpg", dirname);
2604
 
 
2605
 
    // run mplayer and try to get the first frame and convert it to a jpeg
2606
 
    command =
2607
 
        g_strdup_printf("mplayer -vo jpeg:outdir=%s -frames 1 %s", dirname,
2608
 
                        url);
2609
 
    if (!g_spawn_command_line_sync
2610
 
        (command, NULL, NULL, &exit_status, &error))
2611
 
        printf("Error when running When running command: %s\n%s\n",
2612
 
               command, error->message);
2613
 
 
2614
 
    if (fexists(filename)) {
2615
 
        instance->pb_src = gdk_pixbuf_new_from_file(filename, &error);
2616
 
    } else {
2617
 
        instance->pb_src =
2618
 
            gdk_pixbuf_new_from_xpm_data((const char **) start);
 
2908
    // try to load the file natively
 
2909
    
 
2910
    instance->pb_src = gdk_pixbuf_new_from_file(url, &error);
 
2911
    
 
2912
    if (instance->pb_src == NULL) {
 
2913
        // setup tmp directory
 
2914
        dirname =
 
2915
            g_strdup_printf("%s", tempnam("/tmp", "mplayerplug-inXXXXXX"));
 
2916
        filename = g_strdup_printf("%s/00000001.jpg", dirname);
 
2917
    
 
2918
        // run mplayer and try to get the first frame and convert it to a jpeg
 
2919
        command =
 
2920
            g_strdup_printf("mplayer -vo jpeg:outdir=%s -frames 1 %s",
 
2921
                            dirname, url);
 
2922
        if (!g_spawn_command_line_sync
 
2923
            (command, NULL, NULL, &exit_status, &error))
 
2924
            printf("Error when running When running command: %s\n%s\n",
 
2925
                   command, error->message);
 
2926
    
 
2927
        if (fexists(filename)) {
 
2928
            error = NULL;
 
2929
            instance->pb_src = gdk_pixbuf_new_from_file(filename, &error);
 
2930
        } else {
 
2931
            instance->pb_src =
 
2932
                gdk_pixbuf_new_from_xpm_data((const char **) start);
 
2933
        }
 
2934
    
2619
2935
    }
 
2936
 
2620
2937
    if (instance->pb_src != NULL) {
2621
2938
        if (instance->targetplayer == 0) {
2622
2939
            instance->src_event_box = gtk_event_box_new();
2629
2946
                             G_CALLBACK(load_href_callback), instance);
2630
2947
            gtk_fixed_put(GTK_FIXED(instance->fixed_container),
2631
2948
                          instance->src_event_box, 0, 0);
 
2949
            gtk_widget_set_size_request(GTK_WIDGET
 
2950
                                        (instance->src_event_box),
 
2951
                                        instance->embed_width,
 
2952
                                        instance->embed_height);
2632
2953
            gtk_widget_show(GTK_WIDGET(instance->image_src));
2633
2954
            gtk_widget_show(instance->src_event_box);
 
2955
            gtk_widget_show(instance->fixed_container);
2634
2956
        } else {
2635
 
            instance->button_window = gtk_window_new(GTK_WINDOW_POPUP);
2636
 
            gtk_widget_set_size_request(instance->button_window,
2637
 
                                        instance->window_width,
2638
 
                                        instance->window_height);
2639
2957
            gtk_widget_add_events(instance->button_window,
2640
2958
                                  GDK_BUTTON_PRESS_MASK);
2641
2959
            gtk_widget_realize(instance->button_window);
2642
2960
            instance->src_event_box = gtk_event_box_new();
2643
2961
            instance->image_src =
2644
2962
                gtk_image_new_from_pixbuf(instance->pb_src);
2645
 
            gtk_container_add(GTK_CONTAINER(instance->src_event_box),
2646
 
                              instance->image_src);
2647
2963
            g_signal_connect(G_OBJECT(instance->src_event_box),
2648
2964
                             "button_press_event",
2649
2965
                             G_CALLBACK(load_href_callback), instance);
 
2966
 
 
2967
            gtk_widget_set_size_request(GTK_WIDGET
 
2968
                                        (instance->src_event_box),
 
2969
                                        instance->embed_width,
 
2970
                                        instance->embed_height);
 
2971
            gtk_container_add(GTK_CONTAINER(instance->src_event_box),
 
2972
                              instance->image_src);
2650
2973
            fixed_button_container = gtk_fixed_new();
 
2974
            gtk_widget_set_size_request(GTK_WIDGET
 
2975
                                        (fixed_button_container),
 
2976
                                        instance->embed_width,
 
2977
                                        instance->embed_height);
2651
2978
            gtk_container_add(GTK_CONTAINER(instance->button_window),
2652
2979
                              fixed_button_container);
2653
2980
            gtk_fixed_put(GTK_FIXED(fixed_button_container),
2656
2983
            gtk_widget_show(instance->src_event_box);
2657
2984
            gtk_widget_show(fixed_button_container);
2658
2985
            gtk_widget_show(instance->button_window);
2659
 
            XReparentWindow(GDK_WINDOW_XDISPLAY
2660
 
                            (instance->button_window->window),
2661
 
                            GDK_WINDOW_XWINDOW(instance->button_window->
2662
 
                                               window), instance->window,
2663
 
                            0, 0);
2664
 
            gtk_widget_map(instance->button_window);
2665
2986
            g_idle_add(gtkgui_draw, instance);
2666
2987
 
2667
2988
        }
2681
3002
#endif
2682
3003
}
2683
3004
 
 
3005
#ifdef GTK_ENABLED
2684
3006
gboolean target_hide_callback(GtkWidget * widget, GdkEvent * event,
2685
3007
                              nsPluginInstance * instance)
2686
3008
{