~ubuntu-branches/ubuntu/hardy/mplayerplug-in/hardy-backports

« back to all changes in this revision

Viewing changes to Source/plugin-ui.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adrien Cunin
  • Date: 2007-05-21 21:16:39 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070521211639-szqlzo6izljq9xa4
Tags: 3.40-4ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
   - debian/{control,mozilla-mplayer.links}: s/iceweasel/firefox/
   - debian/control: s/iceape/mozilla/
   - debian/mozilla-mplayer.links: removed mozilla->iceape symlinks
* Modify Maintainer value to match Debian-Maintainer-Field Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "../pixmaps/ff_up_small.xpm"
29
29
#include "../pixmaps/rew_down_small.xpm"
30
30
#include "../pixmaps/rew_up_small.xpm"
 
31
#include "../pixmaps/volume.xpm"
31
32
#include "../pixmaps/fs_down_small.xpm"
32
33
#include "../pixmaps/fs_up_small.xpm"
33
34
 
44
45
#define LOGO_WIDTH          257
45
46
#define LOGO_HEIGHT          48
46
47
 
47
 
#ifndef HAVE_X11_XPM
48
 
#error libXpm has not been found. Compilation cannot continue
49
 
#endif
50
 
 
51
48
#ifdef X_ENABLED
52
49
unsigned long GetFontAtom(Display * dpy, XFontStruct * fs, char *atomname)
53
50
{
97
94
        italic = XGetAtomName(dpy, GetFontAtom(dpy, fstr, "SLANT"));
98
95
        size = GetFontAtom(dpy, fstr, "PIXEL_SIZE");
99
96
        XFreeFontInfo(NULL, fstr, 0);
100
 
    
 
97
 
101
98
        sprintf(fontname, "-*-%s-%s-%s-*--%d-*",
102
99
                family, bold, italic, (int) size);
103
100
        instance->font = XCreateFontSet(dpy,
137
134
        gdk_pixbuf_new_from_xpm_data((const char **) rew_up_small);
138
135
    instance->pb_sm_rew_down =
139
136
        gdk_pixbuf_new_from_xpm_data((const char **) rew_down_small);
 
137
    instance->pb_sm_vol =
 
138
        gdk_pixbuf_new_from_xpm_data((const char **) volume);
140
139
    instance->pb_sm_fs_up =
141
140
        gdk_pixbuf_new_from_xpm_data((const char **) fs_up_small);
142
141
    instance->pb_sm_fs_down =
175
174
    instance->pb_sm_rew_down =
176
175
        gdk_pixmap_create_from_xpm_d(instance->gtkwidget->window,
177
176
                                     NULL, NULL, rew_down_small);
 
177
    instance->pb_sm_vol =
 
178
        gdk_pixmap_create_from_xpm_d(instance->gtkwidget->window,
 
179
                                     NULL, NULL, volume);
178
180
    instance->pb_sm_fs_up =
179
181
        gdk_pixmap_create_from_xpm_d(instance->gtkwidget->window,
180
182
                                     NULL, NULL, fs_up_small);
812
814
 
813
815
}
814
816
 
815
 
void fs_callback(GtkWidget * widget, GdkEventExpose * event,
816
 
                 nsPluginInstance * instance)
817
 
{
 
817
gboolean vol_callback(GtkWidget * widget, GdkEvent * event,
 
818
                      nsPluginInstance * instance)
 
819
{
 
820
#ifdef GTK2_ENABLED
 
821
    if (event->type == GDK_SCROLL) {
 
822
        if (((GdkEventScroll *) event)->direction == GDK_SCROLL_UP) {
 
823
            instance->VolumeUp();
 
824
        } else {
 
825
            instance->VolumeDown();
 
826
        }
 
827
    }
 
828
#elif GTK1_ENABLED
 
829
    if (event->type == GDK_BUTTON_PRESS) {
 
830
        switch (((GdkEventButton *)event)->button) {
 
831
            case 4 :
 
832
                instance->VolumeUp();
 
833
                break;
 
834
            case 5 :
 
835
                instance->VolumeDown();
 
836
                break;
 
837
        }
 
838
    }
 
839
#endif
 
840
    return FALSE;
 
841
}
 
842
 
 
843
gboolean gtkgui_setvolumetip(void *data)
 
844
{
 
845
    char tiptext[1024];
 
846
    nsPluginInstance *instance;
 
847
 
 
848
    instance = (nsPluginInstance *) data;
 
849
 
 
850
    snprintf(tiptext, 1024, _("Volume %i%%"), instance->volume);
 
851
 
 
852
    if (instance->vol_tooltip != NULL) {
 
853
        gtk_tooltips_set_tip(instance->vol_tooltip,
 
854
                             instance->vol_event_box, tiptext, NULL);
 
855
    }
 
856
 
 
857
    return FALSE;
 
858
}
 
859
 
 
860
 
 
861
gboolean fs_callback(GtkWidget * widget, GdkEventExpose * event,
 
862
                     nsPluginInstance * instance)
 
863
{
 
864
 
 
865
    int fs_state;
 
866
 
818
867
    if (DEBUG)
819
868
        printf("fs_callback clicked\n");
820
869
    if (instance == NULL)
821
 
        return;
 
870
        return FALSE;
 
871
 
822
872
 
823
873
    if (instance->panel_drawn == 0 && instance->controlsvisible == 1)
824
 
        return;
 
874
        return FALSE;
 
875
 
 
876
    fs_state = instance->fullscreen;
825
877
 
826
878
    if (instance->controlsvisible == 1) {
827
879
        if (instance->panel_height > 16)
863
915
        gtk_widget_show(instance->fixed_container);
864
916
        gdk_flush();
865
917
    }
 
918
    // printf("****\nfs_state = %i\nfullscreen = %i\n****\n",fs_state,instance->fullscreen);
 
919
    while (gtk_events_pending())
 
920
        gtk_main_iteration();
 
921
    if (fs_state == 1 && instance->fullscreen == 0) {
 
922
        return TRUE;
 
923
    }
 
924
 
 
925
    return FALSE;
 
926
 
866
927
}
867
928
 
868
929
gboolean keyboard_callback(GtkWidget * widget, GdkEventKey * event,
966
1027
gboolean mediaprogress_callback(GtkWidget * widget, GdkEventButton * event,
967
1028
                                nsPluginInstance * instance)
968
1029
{
969
 
    GtkRequisition *req;
970
1030
    float percent;
971
1031
    float bytepercent;
972
1032
    float seektime;
973
 
 
974
 
    req = (GtkRequisition *) NPN_MemAlloc(sizeof(GtkRequisition));
975
 
    gtk_widget_size_request(widget, req);
976
 
 
977
 
 
978
 
    percent = event->x / req->width;
 
1033
    gint width;
 
1034
    gint height;
 
1035
 
 
1036
#ifdef GTK2_ENABLED    
 
1037
    gdk_drawable_get_size(GDK_DRAWABLE(widget->window),&width,&height);
 
1038
#endif
 
1039
#ifdef GTK1_ENABLED
 
1040
    gdk_window_get_size(widget->window,&width,&height);
 
1041
#endif
 
1042
    percent = event->x / width;
979
1043
 
980
1044
    if (instance->currentnode != NULL) {
981
1045
        if (instance->currentnode->totalbytes != 0) {
991
1055
 
992
1056
 
993
1057
    if (DEBUG) {
994
 
        printf("widget size: %i x %i\n", req->width, req->height);
 
1058
        printf("widget size: %i x %i\n", width, height);
995
1059
        printf("mouse click at %f x %f\n", event->x, event->y);
996
1060
        printf("percent = %f\nseektime = %f\n", percent, seektime);
997
1061
    }
998
1062
    if (seektime > 0)
999
1063
        instance->Seek(seektime);
1000
 
    NPN_MemFree(req);
1001
1064
 
1002
1065
    return TRUE;
1003
1066
}
1095
1158
                gtk_image_new_from_pixbuf(instance->pb_sm_ff_up);
1096
1159
            instance->image_rew =
1097
1160
                gtk_image_new_from_pixbuf(instance->pb_sm_rew_up);
 
1161
            instance->image_vol =
 
1162
                gtk_image_new_from_pixbuf(instance->pb_sm_vol);
1098
1163
            instance->image_fs =
1099
1164
                gtk_image_new_from_pixbuf(instance->pb_sm_fs_up);
1100
1165
#endif
1118
1183
                gtk_pixmap_new(instance->pb_sm_ff_up, NULL);
1119
1184
            instance->image_rew =
1120
1185
                gtk_pixmap_new(instance->pb_sm_rew_up, NULL);
 
1186
            instance->image_vol =
 
1187
                gtk_pixmap_new(instance->pb_sm_vol, NULL);
1121
1188
            instance->image_fs =
1122
1189
                gtk_pixmap_new(instance->pb_sm_fs_up, NULL);
1123
1190
#endif
1316
1383
            gtk_widget_set_size_request(GTK_WIDGET
1317
1384
                                        (instance->mediaprogress_bar),
1318
1385
                                        (win_width -
1319
 
                                         width * multiplier - 20 - width),
1320
 
                                        height - 2);
 
1386
                                         width * multiplier - 20 -
 
1387
                                         (width * 2)), height - 2);
1321
1388
#endif
1322
1389
#ifdef GTK1_ENABLED
1323
1390
            gtk_signal_connect(GTK_OBJECT(instance->mediaprogress_bar),
1327
1394
            gtk_widget_set_usize(GTK_WIDGET
1328
1395
                                 (instance->mediaprogress_bar),
1329
1396
                                 (win_width -
1330
 
                                  width * multiplier - 20 - width),
 
1397
                                  width * multiplier - 20 - (width * 2)),
1331
1398
                                 height - 2);
1332
1399
#endif
1333
1400
            gtk_fixed_put(GTK_FIXED(instance->fixed_container),
1340
1407
            if (instance->mode == NP_EMBED && instance->noembed == 0)
1341
1408
                gtk_widget_hide(GTK_WIDGET(instance->progress_bar));
1342
1409
 
 
1410
            // volume
 
1411
            instance->vol_event_box = gtk_event_box_new();
 
1412
            instance->vol_tooltip = gtk_tooltips_new();
 
1413
            gtk_tooltips_set_tip(instance->vol_tooltip,
 
1414
                                 instance->vol_event_box, _("Volume"),
 
1415
                                 NULL);
 
1416
            gtk_widget_set_events(instance->vol_event_box,
 
1417
                                  GDK_BUTTON_PRESS_MASK);
 
1418
#ifdef GTK2_ENABLED
 
1419
            g_signal_connect(G_OBJECT(instance->vol_event_box),
 
1420
                             "scroll_event",
 
1421
                             G_CALLBACK(vol_callback), instance);
 
1422
            gtk_widget_set_size_request(GTK_WIDGET
 
1423
                                        (instance->vol_event_box), width,
 
1424
                                        height);
 
1425
#endif
 
1426
#ifdef GTK1_ENABLED
 
1427
            gtk_signal_connect(GTK_OBJECT(instance->vol_event_box),
 
1428
                               "button_press_event",
 
1429
                               GTK_SIGNAL_FUNC(vol_callback), instance);
 
1430
            gtk_widget_set_usize(GTK_WIDGET(instance->vol_event_box),
 
1431
                                 width, height);
 
1432
#endif
 
1433
            gtk_container_add(GTK_CONTAINER(instance->vol_event_box),
 
1434
                              instance->image_vol);
 
1435
            if (win_width > 126 || instance->targetplayer == 1) {
 
1436
                gtk_fixed_put(GTK_FIXED(instance->fixed_container),
 
1437
                              instance->vol_event_box,
 
1438
                              win_width - (width * 2),
 
1439
                              win_height - height);
 
1440
                if (instance->showbuttons) {
 
1441
                    gtk_widget_show(instance->image_vol);
 
1442
                    gtk_widget_show(instance->vol_event_box);
 
1443
                }
 
1444
            }
 
1445
 
 
1446
 
1343
1447
            // fullscreen
1344
1448
            instance->fs_event_box = gtk_event_box_new();
1345
1449
            tooltip = gtk_tooltips_new();
1372
1476
                    gtk_widget_show(instance->fs_event_box);
1373
1477
                }
1374
1478
            }
 
1479
 
1375
1480
            gtk_widget_show(instance->fixed_container);
1376
1481
            if (instance->targetplayer == 0)
1377
1482
                gtk_widget_show(instance->gtkwidget);
1487
1592
                                                (instance->
1488
1593
                                                 mediaprogress_bar));
1489
1594
                            instance->showtracker = 0;
1490
 
                            if (gtk_widget_get_parent_window(instance->drawing_area) == NULL) { 
 
1595
                            if (gtk_widget_get_parent_window
 
1596
                                (instance->drawing_area) == NULL) {
1491
1597
                                gtk_fixed_put(GTK_FIXED
1492
1598
                                              (instance->fixed_container),
1493
 
                                              instance->drawing_area, 0, 0);
 
1599
                                              instance->drawing_area, 0,
 
1600
                                              0);
1494
1601
                            }
1495
1602
                        }
1496
1603
                    }
1549
1656
 
1550
1657
                    }
1551
1658
                }
1552
 
                gtk_widget_set_usize(instance->drawing_area,
1553
 
                                     new_width, new_height);
 
1659
                if (new_width > 0 && new_height > 0 ) {
 
1660
                        gtk_widget_set_usize(instance->drawing_area,
 
1661
                                             new_width, new_height);
 
1662
                }
1554
1663
 
1555
1664
                if ((instance->movie_width + 10) >= instance->window_width
1556
1665
                    || (instance->movie_height + 100) >=
1566
1675
                                        (instance->mediaprogress_bar));
1567
1676
 
1568
1677
                } else {
1569
 
                    if (gtk_widget_get_parent_window(instance->drawing_area) == NULL) { 
1570
 
                        gtk_fixed_put(GTK_FIXED
1571
 
                                      (instance->fixed_container),
 
1678
                    if (gtk_widget_get_parent_window
 
1679
                        (instance->drawing_area) == NULL) {
 
1680
                        gtk_fixed_put(GTK_FIXED(instance->fixed_container),
1572
1681
                                      instance->drawing_area, 10, 100);
1573
1682
                    }
1574
1683
                    if (GTK_IS_WIDGET(instance->image))
1579
1688
 
1580
1689
            } else {
1581
1690
                if (instance->targetplayer && instance->showcontrols) {
1582
 
                    gtk_widget_set_usize(instance->drawing_area,
 
1691
                    if (instance->movie_width > 0 && instance->movie_height > 0 )
 
1692
                        gtk_widget_set_usize(instance->drawing_area,
1583
1693
                                         instance->movie_width,
1584
1694
                                         instance->movie_height + 16);
1585
1695
 
1593
1703
                                                 instance->window_height -
1594
1704
                                                 16);
1595
1705
                        } else {
 
1706
                        if (instance->movie_width > 0 && instance->movie_height > 0 )
1596
1707
                            gtk_widget_set_usize(GTK_WIDGET
1597
1708
                                                 (instance->drawing_area),
1598
1709
                                                 instance->movie_width,
1599
1710
                                                 instance->movie_height);
1600
1711
                        }
1601
1712
                    } else {
 
1713
                        if (instance->movie_width > 0 && instance->movie_height > 0 )
1602
1714
                        gtk_widget_set_usize(GTK_WIDGET
1603
1715
                                             (instance->drawing_area),
1604
1716
                                             instance->movie_width,
1973
2085
            }
1974
2086
        } else {
1975
2087
            if (GTK_IS_WIDGET(instance->rew_event_box)) {
1976
 
                gtk_widget_hide(GTK_WIDGET(instance->rew_event_box));
 
2088
                gtk_widget_hide(GTK_WIDGET(instance->rew_event_box));
1977
2089
            }
1978
2090
        }
1979
2091
        gtk_fixed_move(GTK_FIXED(instance->fixed_container),
1998
2110
            }
1999
2111
        } else {
2000
2112
            if (GTK_IS_WIDGET(instance->ff_event_box)) {
2001
 
                gtk_widget_hide(GTK_WIDGET(instance->ff_event_box));
 
2113
                gtk_widget_hide(GTK_WIDGET(instance->ff_event_box));
2002
2114
            }
2003
2115
        }
2004
2116
        gtk_fixed_move(GTK_FIXED(instance->fixed_container),
2005
2117
                       GTK_WIDGET(instance->mediaprogress_bar),
2006
2118
                       (width * multiplier + 10), win_height - height + 2);
2007
2119
        gtk_fixed_move(GTK_FIXED(instance->fixed_container),
 
2120
                       GTK_WIDGET(instance->vol_event_box),
 
2121
                       (win_width - (width * 2)), win_height - height + 2);
 
2122
        gtk_fixed_move(GTK_FIXED(instance->fixed_container),
2008
2123
                       GTK_WIDGET(instance->fs_event_box),
2009
2124
                       (win_width - width), win_height - height + 2);
2010
2125
 
2011
2126
        gtk_widget_show(GTK_WIDGET(instance->mediaprogress_bar));
2012
2127
        gtk_widget_set_usize(GTK_WIDGET(instance->mediaprogress_bar),
2013
 
                             win_width - (width * (multiplier + 1) +
 
2128
                             win_width - (width * (multiplier + 2) +
2014
2129
                                          20), height - 4);
2015
2130
 
2016
2131
    }
2020
2135
gboolean gtkgui_updatefullscreen(void *data)
2021
2136
{
2022
2137
    nsPluginInstance *instance;
 
2138
    int fs_state;
2023
2139
 
2024
2140
    if (DEBUG > 1)
2025
2141
        printf("in updatefullscreen method\n");
2031
2147
    if (instance->mInitialized == FALSE)
2032
2148
        return FALSE;
2033
2149
 
 
2150
    fs_state = instance->fullscreen;
2034
2151
    instance->SetFullscreen(instance->fullscreen);
2035
2152
 
 
2153
    // printf("****\nfs_state = %i\nfullscreen = %i\n****\n",fs_state,instance->fullscreen);
 
2154
    if (fs_state == 1 && instance->fullscreen == 0) {
 
2155
        return TRUE;
 
2156
    }
2036
2157
    return FALSE;
2037
2158
}
2038
2159
 
2199
2320
        filename = getURLFilename(lastplayed->url);
2200
2321
        if (filename) {
2201
2322
            instance->file_selector =
2202
 
                gtk_file_selection_new
2203
 
                (_("Save As..."));
 
2323
                gtk_file_selection_new(_("Save As..."));
2204
2324
 
2205
2325
            gtk_file_selection_set_filename(GTK_FILE_SELECTION
2206
2326
                                            (instance->file_selector),
3052
3172
            } else {
3053
3173
                if (instance->targetplayer == 0)
3054
3174
                    gtk_widget_hide(instance->src_event_box);
3055
 
                n->play = 1;
 
3175
                //n->play = 1;
 
3176
                instance->cancelled = 0;
 
3177
                pthread_mutex_lock(&(instance->playlist_mutex));        // manipulating the playlist, so lock it
 
3178
                n = instance->list;
 
3179
                while (n != NULL) {
 
3180
                    if (n->played == 1)
 
3181
                        n->played = 0;  // reset played flag
 
3182
                    n = n->next;
 
3183
                }
 
3184
                pthread_mutex_unlock(&(instance->playlist_mutex));      // unlock the playlist
3056
3185
                instance->Play();
3057
3186
            }
3058
3187