~ubuntu-branches/ubuntu/edgy/mplayerplug-in/edgy

« 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-01-01 00:32:37 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060101003237-gdsph207m8ekjv0t
Tags: 3.17-1ubuntu1
* Resynchronise with Debian (partial fix for #2697):
  - debian/control: Build against firefox-dev; adjust Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "../pixmaps/rew_up_small.xpm"
31
31
#include "../pixmaps/fs_down_small.xpm"
32
32
#include "../pixmaps/fs_up_small.xpm"
 
33
 
 
34
// default src button
 
35
#include "../pixmaps/start.xpm"
33
36
#endif
34
37
 
35
38
#define BUTTON_WIDTH    43
469
472
        if (instance->panel_height > 16)
470
473
            instance->panel_height = 16;
471
474
 
 
475
        instance->redrawbuttons = 1;
472
476
        gtk_container_remove(GTK_CONTAINER(instance->play_event_box),
473
477
                             instance->image_play);
474
478
        gtk_container_remove(GTK_CONTAINER(instance->pause_event_box),
508
512
            gtk_widget_show(instance->stop_event_box);
509
513
        }
510
514
        gtk_widget_show(instance->fixed_container);
511
 
        if (instance->drawing_area != NULL)
 
515
        if (instance->drawing_area != NULL) {
 
516
            gtk_widget_hide(GTK_WIDGET(instance->drawing_area));
512
517
            gtk_widget_show(GTK_WIDGET(instance->drawing_area));
513
 
 
 
518
        }
 
519
        if (GTK_IS_WIDGET(instance->src_event_box) && instance->targetplayer == 0) {
 
520
            gtk_widget_hide(instance->src_event_box);
 
521
        }
514
522
        gdk_flush();
515
523
    }
516
524
    if (widget != NULL)
638
646
        gtk_widget_hide(GTK_WIDGET(instance->progress_bar));
639
647
        if (instance->drawing_area != NULL) {
640
648
            gtk_widget_hide(GTK_WIDGET(instance->drawing_area));
641
 
            snprintf(instance->lastmessage, 1024, "Stopped");
 
649
            snprintf(instance->lastmessage, 1024, _("Stopped"));
642
650
            g_idle_add(gtkgui_message, instance);
643
651
            gtk_widget_hide(GTK_WIDGET(instance->mediaprogress_bar));
644
652
        }
846
854
    return FALSE;
847
855
}
848
856
 
 
857
gboolean mouse_callback(GtkWidget * widget, GdkEventButton * event,
 
858
                        nsPluginInstance * instance)
 
859
{
 
860
    char buffer1[1024];
 
861
    char buffer2[1024];
 
862
    char *p;
 
863
 
 
864
    if (DEBUG)
 
865
        printf("In mouse_callback\n");
 
866
    if (event->type == GDK_BUTTON_PRESS) {
 
867
        if (DEBUG)
 
868
            printf("button press # %i\n", event->button);
 
869
        if (event->button == 1) {
 
870
            if (instance->mouseClickCallback != NULL)
 
871
                NPN_GetURL(instance->mInstance,
 
872
                           instance->mouseClickCallback, "_self");
 
873
        }
 
874
        if (instance->mouseDownCallback != NULL) {
 
875
            strlcpy(buffer1, instance->mouseDownCallback, 1024);
 
876
            p = index(buffer1, '(');
 
877
            if (p == NULL) {
 
878
                p = buffer1 + strlen(buffer1);
 
879
            }
 
880
            *p = '\0';
 
881
            snprintf(buffer2, 1024, "%s(%i);", buffer1, event->button);
 
882
            NPN_MemFree(instance->mouseDownCallback);
 
883
            instance->mouseDownCallback =
 
884
                (char *) NPN_MemAlloc(strlen(buffer2));
 
885
            strlcpy(instance->mouseDownCallback, buffer2, strlen(buffer2));
 
886
            NPN_GetURL(instance->mInstance,
 
887
                       instance->mouseDownCallback, "_self");
 
888
        }
 
889
    }
 
890
 
 
891
    if (event->type == GDK_BUTTON_RELEASE) {
 
892
        if (DEBUG)
 
893
            printf("button released # %i\n", event->button);
 
894
        if (instance->mouseUpCallback != NULL) {
 
895
            strlcpy(buffer1, instance->mouseUpCallback, 1024);
 
896
            p = index(buffer1, '(');
 
897
            if (p == NULL) {
 
898
                p = buffer1 + strlen(buffer1);
 
899
            }
 
900
            *p = '\0';
 
901
            snprintf(buffer2, 1024, "%s(%i);", buffer1, event->button);
 
902
            NPN_MemFree(instance->mouseUpCallback);
 
903
            instance->mouseUpCallback =
 
904
                (char *) NPN_MemAlloc(strlen(buffer2));
 
905
            strlcpy(instance->mouseUpCallback, buffer2, strlen(buffer2));
 
906
 
 
907
            NPN_GetURL(instance->mInstance,
 
908
                       instance->mouseUpCallback, "_self");
 
909
        }
 
910
    }
 
911
 
 
912
    return FALSE;
 
913
}
 
914
 
 
915
gboolean mediaprogress_callback(GtkWidget * widget, GdkEventButton * event,
 
916
                                nsPluginInstance * instance)
 
917
{
 
918
    GtkRequisition *req;
 
919
    float percent;
 
920
    float bytepercent;
 
921
    float seektime;
 
922
 
 
923
    req = (GtkRequisition *) NPN_MemAlloc(sizeof(GtkRequisition));
 
924
    gtk_widget_size_request(widget, req);
 
925
 
 
926
 
 
927
    percent = event->x / req->width;
 
928
 
 
929
    if (instance->currentnode != NULL) {
 
930
        if (instance->currentnode->totalbytes != 0) {
 
931
            bytepercent =
 
932
                (float) instance->currentnode->bytes /
 
933
                (float) instance->currentnode->totalbytes;
 
934
            if (percent > bytepercent) {
 
935
                percent = bytepercent - 0.05;
 
936
            }
 
937
        }
 
938
    }
 
939
    seektime = instance->mediaLength * percent;
 
940
 
 
941
 
 
942
    if (DEBUG) {
 
943
        printf("widget size: %i x %i\n", req->width, req->height);
 
944
        printf("mouse click at %f x %f\n", event->x, event->y);
 
945
        printf("percent = %f\nseektime = %f\n", percent, seektime);
 
946
    }
 
947
    if (seektime > 0)
 
948
        instance->Seek(seektime);
 
949
    NPN_MemFree(req);
 
950
 
 
951
    return TRUE;
 
952
}
 
953
 
 
954
 
 
955
gboolean mousenotify_callback(GtkWidget * widget, GdkEventCrossing * event,
 
956
                              nsPluginInstance * instance)
 
957
{
 
958
    if (event->type == GDK_ENTER_NOTIFY) {
 
959
        if (instance->mouseEnterCallback != NULL)
 
960
            NPN_GetURL(instance->mInstance,
 
961
                       instance->mouseEnterCallback, "_self");
 
962
 
 
963
    }
 
964
 
 
965
    if (event->type == GDK_LEAVE_NOTIFY) {
 
966
        if (instance->mouseLeaveCallback != NULL)
 
967
            NPN_GetURL(instance->mInstance,
 
968
                       instance->mouseLeaveCallback, "_self");
 
969
 
 
970
    }
 
971
 
 
972
    return FALSE;
 
973
}
 
974
 
849
975
gboolean gtkgui_draw(void *data)
850
976
{
851
977
    nsPluginInstance *instance;
 
978
    GtkTooltips *tooltip;
852
979
 
853
980
    instance = (nsPluginInstance *) data;
854
981
 
873
1000
        win_width = instance->window_width;
874
1001
    }
875
1002
 
 
1003
    if (instance->targetplayer == 1) {
 
1004
        win_height = instance->movie_height + 16;
 
1005
        win_width = instance->movie_width;
 
1006
        if (instance->showcontrols && instance->movie_height)
 
1007
            instance->panel_height = 16;
 
1008
    }
 
1009
 
876
1010
    if (instance->panel_drawn == 0) {
877
1011
        if (instance->mode == NP_FULL)
878
1012
            instance->panel_height = instance->window_height;
880
1014
            instance->panel_height = 16;
881
1015
        if (instance->panel_height < 0)
882
1016
            instance->panel_height = 0;
883
 
        if (DEBUG > 1) {
 
1017
        if (DEBUG) {
884
1018
            printf("drawing panel\n height = %i panel= %i\n",
885
1019
                   win_height, instance->panel_height);
886
1020
            printf("showbuttons = %i\nshowcontrols = %i\n",
950
1084
            // rewind
951
1085
            if (instance->mmsstream == 0 && win_width > 126) {
952
1086
                instance->rew_event_box = gtk_event_box_new();
 
1087
                tooltip = gtk_tooltips_new();
 
1088
                gtk_tooltips_set_tip(tooltip, instance->rew_event_box,
 
1089
                                     _("Rewind"), NULL);
953
1090
                gtk_widget_set_events(instance->rew_event_box,
954
1091
                                      GDK_BUTTON_PRESS_MASK);
955
1092
#ifdef GTK2_ENABLED
975
1112
            }
976
1113
            // play
977
1114
            instance->play_event_box = gtk_event_box_new();
 
1115
            tooltip = gtk_tooltips_new();
 
1116
            gtk_tooltips_set_tip(tooltip, instance->play_event_box,
 
1117
                                 _("Play"), NULL);
978
1118
            gtk_widget_set_events(instance->play_event_box,
979
1119
                                  GDK_BUTTON_PRESS_MASK);
980
1120
#ifdef GTK2_ENABLED
998
1138
            }
999
1139
            // pause
1000
1140
            instance->pause_event_box = gtk_event_box_new();
 
1141
            tooltip = gtk_tooltips_new();
 
1142
            gtk_tooltips_set_tip(tooltip, instance->pause_event_box,
 
1143
                                 _("Pause"), NULL);
1001
1144
            gtk_widget_set_events(instance->pause_event_box,
1002
1145
                                  GDK_BUTTON_PRESS_MASK);
1003
1146
#ifdef GTK2_ENABLED
1024
1167
            }
1025
1168
            // stop
1026
1169
            instance->stop_event_box = gtk_event_box_new();
 
1170
            tooltip = gtk_tooltips_new();
 
1171
            gtk_tooltips_set_tip(tooltip, instance->stop_event_box,
 
1172
                                 _("Stop"), NULL);
1027
1173
            gtk_widget_set_events(instance->stop_event_box,
1028
1174
                                  GDK_BUTTON_PRESS_MASK);
1029
1175
#ifdef GTK2_ENABLED
1048
1194
            // fastforward
1049
1195
            if (instance->mmsstream == 0 && win_width > 126) {
1050
1196
                instance->ff_event_box = gtk_event_box_new();
 
1197
                tooltip = gtk_tooltips_new();
 
1198
                gtk_tooltips_set_tip(tooltip, instance->ff_event_box,
 
1199
                                     _("Fast Forward"), NULL);
1051
1200
                gtk_widget_set_events(instance->ff_event_box,
1052
1201
                                      GDK_BUTTON_PRESS_MASK);
1053
1202
#ifdef GTK2_ENABLED
1079
1228
                                     (instance->mediaprogress_bar),
1080
1229
                                     (win_width -
1081
1230
                                      width * multiplier - 20 - width),
1082
 
                                     height - 4);
 
1231
                                     height - 2);
 
1232
                gtk_widget_set_events(GTK_WIDGET
 
1233
                                      (instance->mediaprogress_bar),
 
1234
                                      GDK_BUTTON_PRESS_MASK);
 
1235
#ifdef GTK2_ENABLED
 
1236
                g_signal_connect(G_OBJECT(instance->mediaprogress_bar),
 
1237
                                 "button_press_event",
 
1238
                                 G_CALLBACK(mediaprogress_callback),
 
1239
                                 instance);
 
1240
#endif
 
1241
#ifdef GTK1_ENABLED
 
1242
                gtk_signal_connect(GTK_OBJECT(instance->mediaprogress_bar),
 
1243
                                   "button_press_event",
 
1244
                                   GTK_SIGNAL_FUNC(mediaprogress_callback),
 
1245
                                   instance);
 
1246
#endif
1083
1247
                gtk_fixed_put(GTK_FIXED(instance->fixed_container),
1084
1248
                              GTK_WIDGET(instance->mediaprogress_bar),
1085
1249
                              (width * multiplier + 10),
1086
 
                              win_height - height + 2);
 
1250
                              win_height - height + 1);
1087
1251
            }
1088
1252
 
1089
1253
            if (instance->mode == NP_EMBED && instance->noembed == 0)
1091
1255
 
1092
1256
            // fullscreen
1093
1257
            instance->fs_event_box = gtk_event_box_new();
 
1258
            tooltip = gtk_tooltips_new();
 
1259
            gtk_tooltips_set_tip(tooltip, instance->fs_event_box,
 
1260
                                 _("Full Screen"), NULL);
1094
1261
            gtk_widget_set_events(instance->fs_event_box,
1095
1262
                                  GDK_BUTTON_PRESS_MASK);
1096
1263
#ifdef GTK2_ENABLED
1115
1282
                }
1116
1283
            }
1117
1284
            gtk_widget_show(instance->fixed_container);
1118
 
            gtk_widget_show(instance->gtkwidget);
 
1285
            if (instance->targetplayer == 0)
 
1286
                gtk_widget_show(instance->gtkwidget);
1119
1287
 
1120
1288
            instance->controlsvisible = 1;
1121
1289
            instance->panel_drawn = 1;
1159
1327
            if ((instance->percent > 0.0) && (instance->percent < 1.0)) {
1160
1328
                if (instance->movie_height == 0
1161
1329
                    && instance->movie_width == 0)
1162
 
                    gtk_widget_show(GTK_WIDGET(instance->progress_bar));
 
1330
                    if (!(instance->hidestatus))
 
1331
                        gtk_widget_show(GTK_WIDGET
 
1332
                                        (instance->progress_bar));
1163
1333
                gtk_progress_bar_update(instance->progress_bar,
1164
1334
                                        instance->percent);
1165
1335
            }
1195
1365
                    || (instance->movie_height + 100 >=
1196
1366
                        instance->window_height))
1197
1367
                    if (instance->fullscreen == 0)
1198
 
                        if (GTK_IS_CONTAINER(instance->fixed_container))
 
1368
                        if (GTK_IS_CONTAINER(instance->fixed_container)) {
1199
1369
                            gtk_fixed_put(GTK_FIXED
1200
1370
                                          (instance->fixed_container),
1201
1371
                                          instance->drawing_area, 0, 0);
 
1372
                            gtk_widget_hide(instance->drawing_area);
 
1373
                            gtk_widget_show(instance->drawing_area);
 
1374
                        }
 
1375
 
1202
1376
        }
1203
1377
    }
 
1378
 
 
1379
 
 
1380
    if (instance->targetplayer == 1) {
 
1381
#ifdef GTK2_ENABLED
 
1382
        gtk_widget_set_size_request(instance->gtkwidget,
 
1383
                                    instance->movie_width,
 
1384
                                    instance->movie_height);
 
1385
        gtk_widget_set_size_request(instance->drawing_area,
 
1386
                                    instance->movie_width,
 
1387
                                    instance->movie_height);
 
1388
        gtk_window_resize(GTK_WINDOW(instance->gtkwidget),
 
1389
                          instance->movie_width,
 
1390
                          instance->movie_height + 16);
 
1391
#endif
 
1392
#ifdef GTK1_ENABLED
 
1393
        gtk_widget_set_usize(instance->gtkwidget,
 
1394
                             instance->movie_width,
 
1395
                             instance->movie_height + 16);
 
1396
        gtk_widget_set_usize(instance->drawing_area,
 
1397
                             instance->movie_width,
 
1398
                             instance->movie_height + 16);
 
1399
#endif
 
1400
        instance->redrawbuttons = 1;
 
1401
        gtkgui_updatebuttons(data);
 
1402
    }
 
1403
 
1204
1404
    return FALSE;
1205
1405
 
1206
1406
}
1249
1449
    if (instance->js_state != JS_STATE_PLAYING)
1250
1450
        return FALSE;
1251
1451
 
1252
 
    if (!isMms(instance->currentnode->url)) {
 
1452
    if (!isMms(instance->currentnode->url, instance->nomediacache)) {
1253
1453
        pthread_mutex_lock(&(instance->playlist_mutex));
1254
1454
        if (DEBUG > 1)
1255
1455
            printf("Save Enable called retrieved = %i\n",
1293
1493
gboolean gtkgui_drawMediaProgress(void *data)
1294
1494
{
1295
1495
    nsPluginInstance *instance;
 
1496
    int hour = 0, min = 0, length_hour = 0, length_min = 0;
 
1497
    long int seconds, length_seconds;
 
1498
    char display[30];
1296
1499
 
1297
1500
    if (DEBUG > 1)
1298
1501
        printf("in drawMediaProgress method\n");
1304
1507
        return FALSE;
1305
1508
    if (instance->mediaprogress_bar != NULL) {
1306
1509
        if (GTK_IS_PROGRESS_BAR(instance->mediaprogress_bar)) {
1307
 
            if ((instance->mediaPercent > 0)
 
1510
            if (((int) instance->mediaLength > 0)
1308
1511
                && (instance->mediaPercent <= 100)) {
1309
1512
                if (instance->controlsvisible && instance->showtracker)
1310
1513
                    gtk_widget_show(GTK_WIDGET
1311
1514
                                    (instance->mediaprogress_bar));
1312
1515
                gtk_progress_bar_update(instance->mediaprogress_bar,
1313
1516
                                        instance->mediaPercent / 100.0);
 
1517
 
 
1518
#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);
 
1545
                    } 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);
 
1550
                    }
 
1551
                    gtk_progress_bar_set_text(instance->mediaprogress_bar,
 
1552
                                              display);
 
1553
                } else {
 
1554
                    snprintf(display, 30, "");
 
1555
                    gtk_progress_bar_set_text(instance->mediaprogress_bar,
 
1556
                                              display);
 
1557
                }
 
1558
#endif
 
1559
            
1314
1560
            } else {
1315
1561
                gtk_widget_hide(GTK_WIDGET(instance->mediaprogress_bar));
1316
1562
            }
1325
1571
    return FALSE;
1326
1572
}
1327
1573
 
1328
 
gboolean gtkgui_refreshbuttonstate(void *data) 
 
1574
gboolean gtkgui_refreshbuttonstate(void *data)
1329
1575
{
1330
1576
    nsPluginInstance *instance;
1331
1577
 
1332
1578
    if (DEBUG > 1)
1333
1579
        printf("in refreshbuttonstate method\n");
1334
 
 
1335
1580
    instance = (nsPluginInstance *) data;
1336
1581
    if (instance == NULL)
1337
1582
        return FALSE;
1338
1583
    if (instance->mInitialized == FALSE)
1339
1584
        return FALSE;
 
1585
    if (instance->panel_drawn == 1 && instance->controlsvisible) {
 
1586
 
 
1587
        if (instance->mmsstream == 0) {
 
1588
            if (instance->rew_event_box != NULL) {
 
1589
                if (instance->showcontrols && instance->showbuttons
 
1590
                    && instance->controlsvisible) {
 
1591
                    if (instance->redrawbuttons)
 
1592
                        gtk_widget_hide(GTK_WIDGET
 
1593
                                        (instance->rew_event_box));
 
1594
                    gtk_widget_show(GTK_WIDGET(instance->rew_event_box));
 
1595
                }
 
1596
            }
 
1597
        } else {
 
1598
            if (GTK_IS_WIDGET(instance->rew_event_box))
 
1599
                gtk_widget_hide(GTK_WIDGET(instance->rew_event_box));
 
1600
        }
 
1601
        if (instance->mmsstream == 0) {
 
1602
            if (instance->ff_event_box != NULL) {
 
1603
                if (instance->showcontrols && instance->showbuttons
 
1604
                    && instance->controlsvisible) {
 
1605
                    if (instance->redrawbuttons)
 
1606
                        gtk_widget_hide(GTK_WIDGET
 
1607
                                        (instance->ff_event_box));
 
1608
                    gtk_widget_show(GTK_WIDGET(instance->ff_event_box));
 
1609
                }
 
1610
            }
 
1611
        } else {
 
1612
            if (GTK_IS_WIDGET(instance->ff_event_box))
 
1613
                gtk_widget_hide(GTK_WIDGET(instance->ff_event_box));
 
1614
        }
 
1615
        if (instance->showcontrols && instance->showbuttons
 
1616
            && instance->controlsvisible) {
 
1617
            if (instance->redrawbuttons) {
 
1618
                gtk_widget_hide(GTK_WIDGET(instance->play_event_box));
 
1619
                gtk_widget_hide(GTK_WIDGET(instance->pause_event_box));
 
1620
                gtk_widget_hide(GTK_WIDGET(instance->stop_event_box));
 
1621
                gtk_widget_hide(GTK_WIDGET(instance->fs_event_box));
 
1622
            }
 
1623
            gtk_widget_show(GTK_WIDGET(instance->play_event_box));
 
1624
            gtk_widget_show(GTK_WIDGET(instance->pause_event_box));
 
1625
            gtk_widget_show(GTK_WIDGET(instance->stop_event_box));
 
1626
            gtk_widget_show(GTK_WIDGET(instance->fs_event_box));
 
1627
        }
 
1628
    }
 
1629
 
 
1630
    instance->redrawbuttons = 0;
 
1631
//    gtk_widget_queue_draw_area(instance->gtkwidget,0,0,instance->embed_width,instance->embed_height);
1340
1632
 
1341
1633
    return FALSE;
1342
1634
}
1365
1657
        win_width = instance->window_width;
1366
1658
    }
1367
1659
 
 
1660
    if (instance->targetplayer) {
 
1661
        win_height = instance->movie_height + 16;
 
1662
        win_width = instance->movie_width;
 
1663
    }
 
1664
 
 
1665
    printf("buttons are at %i x %i\n", win_height, win_width);
 
1666
 
1368
1667
    if (instance->panel_drawn == 1) {
1369
1668
        height = 16;
1370
1669
        width = 21;
1378
1677
                    gtk_fixed_move(GTK_FIXED(instance->fixed_container),
1379
1678
                                   GTK_WIDGET(instance->rew_event_box),
1380
1679
                                   width * multiplier++,
1381
 
                                   instance->embed_height - height);
 
1680
                                   win_height - height);
1382
1681
                }
1383
1682
            }
1384
1683
        } else {
1628
1927
 
1629
1928
}
1630
1929
 
1631
 
gint CloseConfigEvent(GtkWidget * widget, GdkEvent *event, nsPluginInstance * instance)
 
1930
gint CloseConfigEvent(GtkWidget * widget, GdkEvent * event,
 
1931
                      nsPluginInstance * instance)
1632
1932
{
1633
1933
 
1634
 
    if (GTK_IS_WIDGET(instance->conf_window)) 
 
1934
    if (GTK_IS_WIDGET(instance->conf_window))
1635
1935
        gtk_widget_destroy(instance->conf_window);
1636
1936
    instance->conf_window = NULL;
1637
1937
    return (FALSE);
1653
1953
    instance->cache_percent =
1654
1954
        (int) gtk_range_get_value(GTK_RANGE(instance->conf_cachepercent));
1655
1955
 
 
1956
#ifdef GTK24_ENABLED
1656
1957
    if (instance->vo != NULL)
1657
1958
        free(instance->vo);
1658
1959
    instance->vo =
1670
1971
    instance->download_dir =
1671
1972
        strdup(gtk_entry_get_text
1672
1973
               (GTK_ENTRY(GTK_BIN(instance->conf_dir)->child)));
 
1974
#endif
 
1975
    
 
1976
    instance->showtime =
 
1977
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
1978
                                     (instance->conf_showtime));
 
1979
    instance->enable_wmp =
 
1980
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
1981
                                     (instance->conf_enable_wmp));
 
1982
    instance->enable_qt =
 
1983
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
1984
                                     (instance->conf_enable_qt));
 
1985
    instance->enable_rm =
 
1986
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
1987
                                     (instance->conf_enable_rm));
 
1988
    instance->enable_gmp =
 
1989
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
1990
                                     (instance->conf_enable_gmp));
 
1991
    instance->enable_mpeg =
 
1992
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
1993
                                     (instance->conf_enable_mpeg));
 
1994
    instance->enable_mp3 =
 
1995
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
1996
                                     (instance->conf_enable_mp3));
 
1997
    instance->enable_ogg =
 
1998
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
1999
                                     (instance->conf_enable_ogg));
 
2000
    instance->enable_smil =
 
2001
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
2002
                                     (instance->conf_enable_smil));
 
2003
    instance->enable_helix =
 
2004
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
2005
                                     (instance->conf_enable_helix));
 
2006
 
 
2007
    instance->nomediacache =
 
2008
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
2009
                                     (instance->conf_nomediacache));
 
2010
 
 
2011
    instance->rtsp_use_tcp =
 
2012
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
 
2013
                                     (instance->conf_rtsptcp));
1673
2014
 
1674
2015
    gtk_widget_destroy(instance->conf_window);
1675
2016
    instance->conf_window = NULL;
1702
2043
        fprintf(output, "cache-percent=%i\n", instance->cache_percent);
1703
2044
        if (strlen(instance->download_dir) > 0)
1704
2045
            fprintf(output, "dload-dir=%s\n", instance->download_dir);
 
2046
        fprintf(output, "showtime=%i\n", instance->showtime);
 
2047
        fprintf(output, "enable-wmp=%i\n", instance->enable_wmp);
 
2048
        fprintf(output, "enable-qt=%i\n", instance->enable_qt);
 
2049
        fprintf(output, "enable-rm=%i\n", instance->enable_rm);
 
2050
        fprintf(output, "enable-gmp=%i\n", instance->enable_gmp);
 
2051
        fprintf(output, "enable-mpeg=%i\n", instance->enable_mpeg);
 
2052
        fprintf(output, "enable-mp3=%i\n", instance->enable_mp3);
 
2053
        fprintf(output, "enable-ogg=%i\n", instance->enable_ogg);
 
2054
        fprintf(output, "enable-smil=%i\n", instance->enable_smil);
 
2055
        fprintf(output, "enable-helix=%i\n", instance->enable_helix);
 
2056
        fprintf(output, "nomediacache=%i\n", instance->nomediacache);
 
2057
        fprintf(output, "rtsp-use-tcp=%i\n", instance->rtsp_use_tcp);
 
2058
 
1705
2059
 
1706
2060
        while (fgets(buffer, sizeof(buffer), input) != NULL) {
1707
2061
            if (strncasecmp(buffer, "vo", 2) == 0) {
1709
2063
            } else if (strncasecmp(buffer, "cachesize", 9) == 0) {
1710
2064
            } else if (strncasecmp(buffer, "cache-percent", 13) == 0) {
1711
2065
            } else if (strncasecmp(buffer, "dload-dir", 9) == 0) {
 
2066
            } else if (strncasecmp(buffer, "showtime", 8) == 0) {
 
2067
            } else if (strncasecmp(buffer, "enable-wmp", 10) == 0) {
 
2068
            } else if (strncasecmp(buffer, "enable-qt", 9) == 0) {
 
2069
            } else if (strncasecmp(buffer, "enable-rm", 9) == 0) {
 
2070
            } else if (strncasecmp(buffer, "enable-mpeg", 11) == 0) {
 
2071
            } else if (strncasecmp(buffer, "enable-mp3", 10) == 0) {
 
2072
            } else if (strncasecmp(buffer, "enable-ogg", 10) == 0) {
 
2073
            } else if (strncasecmp(buffer, "enable-gmp", 10) == 0) {
 
2074
            } else if (strncasecmp(buffer, "enable-smil", 11) == 0) {
 
2075
            } else if (strncasecmp(buffer, "enable-helix", 12) == 0) {
 
2076
            } else if (strncasecmp(buffer, "nomediacache", 12) == 0) {
 
2077
            } else if (strncasecmp(buffer, "rtsp-use-tcp", 12) == 0) {
1712
2078
            } else {
1713
2079
                fprintf(output, "%s", buffer);
1714
2080
            }
1746
2112
            fprintf(output, "cache-percent=%i\n", instance->cache_percent);
1747
2113
            if (strlen(instance->download_dir) > 0)
1748
2114
                fprintf(output, "dload-dir=%s\n", instance->download_dir);
 
2115
            fprintf(output, "showtime=%i\n", instance->showtime);
 
2116
            fprintf(output, "enable-wmp=%i\n", instance->enable_wmp);
 
2117
            fprintf(output, "enable-qt=%i\n", instance->enable_qt);
 
2118
            fprintf(output, "enable-rm=%i\n", instance->enable_rm);
 
2119
            fprintf(output, "enable-gmp=%i\n", instance->enable_gmp);
 
2120
            fprintf(output, "enable-mpeg=%i\n", instance->enable_mpeg);
 
2121
            fprintf(output, "enable-mp3=%i\n", instance->enable_mp3);
 
2122
            fprintf(output, "enable-ogg=%i\n", instance->enable_ogg);
 
2123
            fprintf(output, "enable-smil=%i\n", instance->enable_smil);
 
2124
            fprintf(output, "enable-helix=%i\n", instance->enable_helix);
 
2125
            fprintf(output, "nomediacache=%i\n", instance->nomediacache);
 
2126
            fprintf(output, "rtsp-use-tcp=%i\n", instance->rtsp_use_tcp);
1749
2127
            fclose(output);
1750
2128
            ret = rename(tmp_name, config_name);
1751
2129
            if (ret == -1) {
1759
2137
        }
1760
2138
 
1761
2139
    }
 
2140
 
 
2141
    snprintf(buffer, 1000, "%s", getenv("HOME"));
 
2142
    strlcat(buffer, "/.mozilla/pluginreg.dat", 1000);
 
2143
    unlink(buffer);
 
2144
    snprintf(buffer, 1000, "%s", getenv("HOME"));
 
2145
    strlcat(buffer, "/.mozilla/firefox/pluginreg.dat", 1000);
 
2146
    unlink(buffer);
 
2147
    NPN_ReloadPlugins(FALSE);
 
2148
 
1762
2149
    return (FALSE);
1763
2150
}
1764
2151
 
1771
2158
    GtkWidget *conf_cancel;
1772
2159
    GtkWidget *conf_table;
1773
2160
    GtkWidget *conf_label;
1774
 
 
 
2161
    int row = 0;
1775
2162
    if (instance->conf_window != NULL)
1776
2163
        return;
1777
2164
 
1781
2168
 
1782
2169
    conf_vbox = gtk_vbox_new(FALSE, 10);
1783
2170
    conf_hbutton_box = gtk_hbutton_box_new();
1784
 
    conf_table = gtk_table_new(10, 2, FALSE);
 
2171
    conf_table = gtk_table_new(20, 2, FALSE);
1785
2172
 
1786
2173
    gtk_container_add(GTK_CONTAINER(conf_vbox), conf_table);
1787
2174
    gtk_container_add(GTK_CONTAINER(conf_vbox), conf_hbutton_box);
1793
2180
    g_signal_connect(GTK_OBJECT(instance->conf_window), "delete_event",
1794
2181
                     GTK_SIGNAL_FUNC(CloseConfigEvent), instance);
1795
2182
 
 
2183
#ifdef GTK24_ENABLED
1796
2184
    instance->conf_vo = gtk_combo_box_entry_new_text();
1797
2185
    if (instance->conf_vo != NULL) {
 
2186
        gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_vo), "gl");
1798
2187
        gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_vo), "x11");
1799
2188
        gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_vo), "xv");
1800
2189
        if (instance->vo != NULL) {
 
2190
            if (strcmp(instance->vo, "gl") == 0)
 
2191
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_vo),
 
2192
                                         0);
1801
2193
            if (strcmp(instance->vo, "x11") == 0)
1802
2194
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_vo),
1803
 
                                         0);
 
2195
                                         1);
1804
2196
            if (strcmp(instance->vo, "xv") == 0)
1805
2197
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_vo),
1806
 
                                         1);
 
2198
                                         2);
1807
2199
            if (gtk_combo_box_get_active(GTK_COMBO_BOX(instance->conf_vo))
1808
2200
                == -1) {
1809
2201
                gtk_combo_box_append_text(GTK_COMBO_BOX(instance->conf_vo),
1810
2202
                                          instance->vo);
1811
2203
                gtk_combo_box_set_active(GTK_COMBO_BOX(instance->conf_vo),
1812
 
                                         2);
 
2204
                                         3);
1813
2205
            }
1814
2206
        }
1815
2207
    }
1863
2255
            }
1864
2256
        }
1865
2257
    }
 
2258
#endif
1866
2259
 
1867
2260
    conf_ok = gtk_button_new_with_label(_("OK"));
1868
2261
    g_signal_connect(GTK_OBJECT(conf_ok), "clicked",
1870
2263
 
1871
2264
    conf_cancel = gtk_button_new_with_label(_("Cancel"));
1872
2265
    g_signal_connect(GTK_OBJECT(conf_cancel), "clicked",
1873
 
                             GTK_SIGNAL_FUNC(CloseConfig),
1874
 
                             instance);
 
2266
                     GTK_SIGNAL_FUNC(CloseConfig), instance);
1875
2267
 
 
2268
#ifdef GTK24_ENABLED
1876
2269
    conf_label = gtk_label_new(_("Video Output:"));
1877
 
    gtk_misc_set_alignment (GTK_MISC(conf_label), 0.0, 0.0);
 
2270
    gtk_misc_set_alignment(GTK_MISC(conf_label), 0.0, 0.0);
1878
2271
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1, 0,
1879
2272
                              1);
1880
2273
    gtk_widget_show(conf_label);
1881
2274
    gtk_table_attach_defaults(GTK_TABLE(conf_table), instance->conf_vo, 1,
1882
2275
                              2, 0, 1);
 
2276
 
1883
2277
    conf_label = gtk_label_new(_("Audio Output:"));
1884
 
    gtk_misc_set_alignment (GTK_MISC(conf_label), 0.0, 0.0);
 
2278
    gtk_misc_set_alignment(GTK_MISC(conf_label), 0.0, 0.0);
1885
2279
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1, 1,
1886
2280
                              2);
1887
2281
    gtk_widget_show(conf_label);
1888
 
    gtk_misc_set_alignment (GTK_MISC(conf_label), 0.0, 0.0);
 
2282
    gtk_misc_set_alignment(GTK_MISC(conf_label), 0.0, 0.0);
1889
2283
    gtk_table_attach_defaults(GTK_TABLE(conf_table), instance->conf_ao, 1,
1890
2284
                              2, 1, 2);
1891
2285
    conf_label = gtk_label_new(_("Save to Location:"));
1892
2286
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1, 2,
1893
2287
                              3);
1894
2288
    gtk_widget_show(conf_label);
1895
 
    gtk_misc_set_alignment (GTK_MISC(conf_label), 0.0, 0.0);
 
2289
    gtk_misc_set_alignment(GTK_MISC(conf_label), 0.0, 0.0);
1896
2290
    gtk_table_attach_defaults(GTK_TABLE(conf_table), instance->conf_dir, 1,
1897
2291
                              2, 2, 3);
1898
 
 
 
2292
#endif
1899
2293
 
1900
2294
    conf_label = gtk_label_new(_("Minimum Cache Size:"));
1901
 
    gtk_misc_set_alignment (GTK_MISC(conf_label), 0.0, 0.0);
 
2295
    gtk_misc_set_alignment(GTK_MISC(conf_label), 0.0, 0.0);
1902
2296
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1, 3,
1903
2297
                              4);
1904
2298
    gtk_widget_show(conf_label);
1910
2304
    gtk_widget_show(instance->conf_cachesize);
1911
2305
 
1912
2306
    conf_label = gtk_label_new(_("Percent of Media to Cache:"));
1913
 
    gtk_misc_set_alignment (GTK_MISC(conf_label), 0.0, 0.0);
 
2307
    gtk_misc_set_alignment(GTK_MISC(conf_label), 0.0, 0.0);
1914
2308
    gtk_table_attach_defaults(GTK_TABLE(conf_table), conf_label, 0, 1, 4,
1915
2309
                              5);
1916
2310
    gtk_widget_show(conf_label);
1921
2315
                        instance->cache_percent);
1922
2316
    gtk_widget_show(instance->conf_cachepercent);
1923
2317
 
 
2318
    row = 5;
 
2319
    instance->conf_showtime =
 
2320
        gtk_check_button_new_with_label(_("Show time in progress bar"));
 
2321
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2322
                              instance->conf_showtime, 1, 2, row, row + 1);
 
2323
    row++;
 
2324
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2325
                                 (instance->conf_showtime),
 
2326
                                 instance->showtime);
 
2327
    gtk_widget_show(instance->conf_showtime);
 
2328
 
 
2329
    instance->conf_enable_wmp =
 
2330
        gtk_check_button_new_with_label(_
 
2331
                                        ("Enable Windows Media Player Support"));
 
2332
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2333
                              instance->conf_enable_wmp, 1, 2, row,
 
2334
                              row + 1);
 
2335
    row++;
 
2336
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2337
                                 (instance->conf_enable_wmp),
 
2338
                                 instance->enable_wmp);
 
2339
    gtk_widget_show(instance->conf_enable_wmp);
 
2340
 
 
2341
    instance->conf_enable_qt =
 
2342
        gtk_check_button_new_with_label(_("Enable QuickTime Support"));
 
2343
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2344
                              instance->conf_enable_qt, 1, 2, row,
 
2345
                              row + 1);
 
2346
    row++;
 
2347
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2348
                                 (instance->conf_enable_qt),
 
2349
                                 instance->enable_qt);
 
2350
    gtk_widget_show(instance->conf_enable_qt);
 
2351
 
 
2352
    instance->conf_enable_rm =
 
2353
        gtk_check_button_new_with_label(_("Enable RealMedia Support"));
 
2354
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2355
                              instance->conf_enable_rm, 1, 2, row,
 
2356
                              row + 1);
 
2357
    row++;
 
2358
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2359
                                 (instance->conf_enable_rm),
 
2360
                                 instance->enable_rm);
 
2361
    gtk_widget_show(instance->conf_enable_rm);
 
2362
 
 
2363
    instance->conf_enable_smil =
 
2364
        gtk_check_button_new_with_label(_
 
2365
                                        ("Enable SMIL Support (Effects QuickTime and RealMedia)"));
 
2366
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2367
                              instance->conf_enable_smil, 1, 2, row,
 
2368
                              row + 1);
 
2369
    row++;
 
2370
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2371
                                 (instance->conf_enable_smil),
 
2372
                                 instance->enable_smil);
 
2373
    gtk_widget_show(instance->conf_enable_smil);
 
2374
 
 
2375
    instance->conf_enable_helix =
 
2376
        gtk_check_button_new_with_label(_("Enable Helix Emulation"));
 
2377
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2378
                              instance->conf_enable_helix, 1, 2, row,
 
2379
                              row + 1);
 
2380
    row++;
 
2381
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2382
                                 (instance->conf_enable_helix),
 
2383
                                 instance->enable_helix);
 
2384
    gtk_widget_show(instance->conf_enable_helix);
 
2385
 
 
2386
    instance->conf_enable_gmp =
 
2387
        gtk_check_button_new_with_label(_
 
2388
                                        ("Enable Google Media Player Support"));
 
2389
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2390
                              instance->conf_enable_gmp, 1, 2, row,
 
2391
                              row + 1);
 
2392
    row++;
 
2393
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2394
                                 (instance->conf_enable_gmp),
 
2395
                                 instance->enable_gmp);
 
2396
    gtk_widget_show(instance->conf_enable_gmp);
 
2397
 
 
2398
    instance->conf_enable_mpeg =
 
2399
        gtk_check_button_new_with_label(_("Enable MPEG Support"));
 
2400
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2401
                              instance->conf_enable_mpeg, 1, 2, row,
 
2402
                              row + 1);
 
2403
    row++;
 
2404
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2405
                                 (instance->conf_enable_mpeg),
 
2406
                                 instance->enable_mpeg);
 
2407
    gtk_widget_show(instance->conf_enable_mpeg);
 
2408
 
 
2409
    instance->conf_enable_mp3 =
 
2410
        gtk_check_button_new_with_label(_
 
2411
                                        ("Enable MP3 Support (Requires MPEG Support)"));
 
2412
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2413
                              instance->conf_enable_mp3, 1, 2, row,
 
2414
                              row + 1);
 
2415
    row++;
 
2416
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2417
                                 (instance->conf_enable_mp3),
 
2418
                                 instance->enable_mp3);
 
2419
    gtk_widget_show(instance->conf_enable_mp3);
 
2420
 
 
2421
    instance->conf_enable_ogg =
 
2422
        gtk_check_button_new_with_label(_("Enable Ogg Support"));
 
2423
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2424
                              instance->conf_enable_ogg, 1, 2, row,
 
2425
                              row + 1);
 
2426
    row++;
 
2427
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2428
                                 (instance->conf_enable_ogg),
 
2429
                                 instance->enable_ogg);
 
2430
    gtk_widget_show(instance->conf_enable_ogg);
 
2431
 
 
2432
    instance->conf_nomediacache =
 
2433
        gtk_check_button_new_with_label(_
 
2434
                                        ("Play media directly from site (No Caching)"));
 
2435
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2436
                              instance->conf_nomediacache, 1, 2, row,
 
2437
                              row + 1);
 
2438
    row++;
 
2439
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
 
2440
                                 (instance->conf_nomediacache),
 
2441
                                 instance->nomediacache);
 
2442
    gtk_widget_show(instance->conf_nomediacache);
 
2443
 
 
2444
    instance->conf_rtsptcp =
 
2445
        gtk_check_button_new_with_label(_
 
2446
                                        ("Connect to RTSP Media over TCP"));
 
2447
    gtk_table_attach_defaults(GTK_TABLE(conf_table),
 
2448
                              instance->conf_rtsptcp, 1, 2, row, row + 1);
 
2449
    row++;
 
2450
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(instance->conf_rtsptcp),
 
2451
                                 instance->rtsp_use_tcp);
 
2452
    gtk_widget_show(instance->conf_rtsptcp);
 
2453
 
 
2454
 
1924
2455
    gtk_container_add(GTK_CONTAINER(conf_hbutton_box), conf_ok);
1925
2456
    gtk_container_add(GTK_CONTAINER(conf_hbutton_box), conf_cancel);
1926
2457
 
1927
 
 
 
2458
#ifdef GTK24_ENABLED
1928
2459
    if (instance->conf_vo != NULL)
1929
2460
        gtk_widget_show(instance->conf_vo);
1930
2461
    if (instance->conf_ao != NULL)
1931
2462
        gtk_widget_show(instance->conf_ao);
1932
2463
    if (instance->conf_dir != NULL)
1933
2464
        gtk_widget_show(instance->conf_dir);
1934
 
 
 
2465
#endif
1935
2466
    gtk_widget_show(conf_ok);
1936
2467
    gtk_widget_show(conf_cancel);
1937
2468
    gtk_widget_show(conf_table);
1992
2523
 
1993
2524
}
1994
2525
 
1995
 
#endif                          // GTK2_ENABLED
 
2526
gboolean load_href_callback(GtkWidget * widget, GdkEventExpose * event,
 
2527
                            nsPluginInstance * instance)
 
2528
{
 
2529
    Node *n;
 
2530
    GdkEventButton *event_button;
 
2531
 
 
2532
    if (DEBUG)
 
2533
        printf("image clicked\n");
 
2534
 
 
2535
    if (event->type == GDK_BUTTON_PRESS) {
 
2536
        event_button = (GdkEventButton *) event;
 
2537
 
 
2538
        if (event_button->button == 3) {
 
2539
            gtk_menu_popup(instance->popup_menu, NULL, NULL, NULL, NULL,
 
2540
                           event_button->button, event_button->time);
 
2541
            return TRUE;
 
2542
        }
 
2543
 
 
2544
        if (event_button->button == 1) {
 
2545
            n = instance->list;
 
2546
 
 
2547
            while (n != NULL) {
 
2548
                if (strcmp(n->url, instance->href) == 0)
 
2549
                    break;
 
2550
                else
 
2551
                    n = n->next;
 
2552
            }
 
2553
 
 
2554
            if (n == NULL) {
 
2555
                n = newNode();
 
2556
                snprintf(n->url, 1024, "%s", instance->href);
 
2557
                n->frombutton = 1;
 
2558
                addToEnd(instance->td->list, n);
 
2559
                NPN_GetURL(instance->mInstance, instance->href, NULL);
 
2560
                if (instance->targetplayer == 0)
 
2561
                    gtk_widget_hide(instance->src_event_box);
 
2562
            } else {
 
2563
                if (instance->targetplayer == 0)
 
2564
                    gtk_widget_hide(instance->src_event_box);
 
2565
                n->play = 1;
 
2566
                instance->Play();
 
2567
            }
 
2568
 
 
2569
            if (instance->targetplayer == 1)
 
2570
                gtk_widget_show(instance->gtkwidget);
 
2571
 
 
2572
            return TRUE;
 
2573
        }
 
2574
    }
 
2575
 
 
2576
    return FALSE;
 
2577
 
 
2578
}
 
2579
#endif
 
2580
 
 
2581
int srcToButton(char *url, nsPluginInstance * instance)
 
2582
{
 
2583
#ifndef GTK2_ENABLED
 
2584
    return FALSE;
 
2585
#endif
 
2586
 
 
2587
#ifdef GTK2_ENABLED
 
2588
 
 
2589
    gchar *command;
 
2590
    GError *error = NULL;
 
2591
    int exit_status;
 
2592
    gchar *dirname;
 
2593
    gchar *filename;
 
2594
    gboolean result;
 
2595
    GtkWidget *fixed_button_container;
 
2596
 
 
2597
    if (DEBUG)
 
2598
        printf("In srcToButton\n");
 
2599
 
 
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);
 
2619
    }
 
2620
    if (instance->pb_src != NULL) {
 
2621
        if (instance->targetplayer == 0) {
 
2622
            instance->src_event_box = gtk_event_box_new();
 
2623
            instance->image_src =
 
2624
                gtk_image_new_from_pixbuf(instance->pb_src);
 
2625
            gtk_container_add(GTK_CONTAINER(instance->src_event_box),
 
2626
                              instance->image_src);
 
2627
            g_signal_connect(G_OBJECT(instance->src_event_box),
 
2628
                             "button_press_event",
 
2629
                             G_CALLBACK(load_href_callback), instance);
 
2630
            gtk_fixed_put(GTK_FIXED(instance->fixed_container),
 
2631
                          instance->src_event_box, 0, 0);
 
2632
            gtk_widget_show(GTK_WIDGET(instance->image_src));
 
2633
            gtk_widget_show(instance->src_event_box);
 
2634
        } 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
            gtk_widget_add_events(instance->button_window,
 
2640
                                  GDK_BUTTON_PRESS_MASK);
 
2641
            gtk_widget_realize(instance->button_window);
 
2642
            instance->src_event_box = gtk_event_box_new();
 
2643
            instance->image_src =
 
2644
                gtk_image_new_from_pixbuf(instance->pb_src);
 
2645
            gtk_container_add(GTK_CONTAINER(instance->src_event_box),
 
2646
                              instance->image_src);
 
2647
            g_signal_connect(G_OBJECT(instance->src_event_box),
 
2648
                             "button_press_event",
 
2649
                             G_CALLBACK(load_href_callback), instance);
 
2650
            fixed_button_container = gtk_fixed_new();
 
2651
            gtk_container_add(GTK_CONTAINER(instance->button_window),
 
2652
                              fixed_button_container);
 
2653
            gtk_fixed_put(GTK_FIXED(fixed_button_container),
 
2654
                          instance->src_event_box, 0, 0);
 
2655
            gtk_widget_show(GTK_WIDGET(instance->image_src));
 
2656
            gtk_widget_show(instance->src_event_box);
 
2657
            gtk_widget_show(fixed_button_container);
 
2658
            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
            g_idle_add(gtkgui_draw, instance);
 
2666
 
 
2667
        }
 
2668
        result = TRUE;
 
2669
    } else {
 
2670
        if (instance->targetplayer == 1)
 
2671
            gtk_widget_show(instance->gtkwidget);
 
2672
        result = FALSE;
 
2673
    }
 
2674
    remove(filename);
 
2675
    remove(dirname);
 
2676
 
 
2677
    g_free(filename);
 
2678
    g_free(dirname);
 
2679
    return result;
 
2680
 
 
2681
#endif
 
2682
}
 
2683
 
 
2684
gboolean target_hide_callback(GtkWidget * widget, GdkEvent * event,
 
2685
                              nsPluginInstance * instance)
 
2686
{
 
2687
    if (DEBUG)
 
2688
        printf("Hiding gtkwidget, window\n");
 
2689
    gtk_widget_hide(GTK_WIDGET(instance->gtkwidget));
 
2690
    instance->Quit();
 
2691
    return TRUE;
 
2692
}
1996
2693
 
1997
2694
#endif                          // GTK_ENABLED