+ /* RedrawToolbar */
+ gcv.foreground = BlackPixel( p_display, 0 );
+ gc = XCreateGC( p_display, control, GCForeground, &gcv );
+
+ XFillRectangle( p_display, control, gc,
+ 0, 0, window.width, CONTROL_HEIGHT );
+
+
+ gcv.foreground = WhitePixel( p_display, 0 );
+ XChangeGC( p_display, gc, GCForeground, &gcv );
+
+ /* get media instance */
+ libvlc_exception_t ex;
+ libvlc_exception_init( &ex );
+ p_md = libvlc_playlist_get_media_instance( p_plugin->getVLC(), &ex );
+ libvlc_exception_clear( &ex );
+
+ /* get isplaying */
+ libvlc_exception_init( &ex );
+ i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex );
+ libvlc_exception_clear( &ex );
+
+ /* get mute info */
+ libvlc_exception_init(&ex);
+ b_mute = libvlc_audio_get_mute( p_plugin->getVLC(), &ex );
+ libvlc_exception_clear( &ex );
+
+ /* get movie position in % */
+ if( i_playing == 1 )
+ {
+ libvlc_exception_init( &ex );
+ f_position = libvlc_media_instance_get_position(p_md, &ex)*100;
+ libvlc_exception_clear( &ex );
+ }
+ libvlc_media_instance_release(p_md);
+
+ /* load icons */
+ XpmReadFileToImage( p_display, DATA_PATH "/mozilla/play.xpm",
+ &p_playIcon, NULL, NULL);
+ XpmReadFileToImage( p_display, DATA_PATH "/mozilla/pause.xpm",
+ &p_pauseIcon, NULL, NULL);
+ XpmReadFileToImage( p_display, DATA_PATH "/mozilla/stop.xpm",
+ &p_stopIcon, NULL, NULL );
+ XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_line.xpm",
+ &p_timeline, NULL, NULL);
+ XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_icon.xpm",
+ &p_timeKnob, NULL, NULL);
+ XpmReadFileToImage( p_display, DATA_PATH "/mozilla/fullscreen.xpm",
+ &p_fscreen, NULL, NULL);
+ XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_max.xpm",
+ &p_muteIcon, NULL, NULL);
+ XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_mute.xpm",
+ &p_unmuteIcon, NULL, NULL);
+
+#if 1 /* DEBUG */
+ if( !p_playIcon )
+ {
+ fprintf(stderr, "Error: playImage not found\n");
+ }
+ if( !p_pauseIcon )
+ {
+ fprintf(stderr, "Error: pauseImage not found\n");
+ }
+ if( !p_stopIcon )
+ {
+ fprintf(stderr, "Error: stopImage not found\n");
+ }
+ if( !p_timeline )
+ {
+ fprintf(stderr, "Error: TimeLineImage not found\n");
+ }
+ if( !p_timeKnob )
+ {
+ fprintf(stderr, "Error: TimeIcon not found\n");
+ }
+ if( !p_fscreen )
+ {
+ fprintf(stderr, "Error: FullscreenImage not found\n");
+ }
+ if( !p_muteIcon )
+ {
+ fprintf(stderr, "Error: MuteImage not found\n");
+ }
+ if( !p_unmuteIcon )
+ {
+ fprintf(stderr, "Error: UnMuteImage not found\n");
+ }
+#endif
+
+ /* position icons */
+ if( p_pauseIcon && (i_playing == 1) )
+ {
+ XPutImage( p_display, control, gc, p_pauseIcon, 0, 0, 4, 14,
+ p_pauseIcon->width, p_pauseIcon->height );
+ }
+ else if( p_playIcon )
+ {
+ XPutImage( p_display, control, gc, p_playIcon, 0, 0, 4, 14,
+ p_playIcon->width, p_playIcon->height );
+ }
+
+ if( p_stopIcon )
+ XPutImage( p_display, control, gc, p_stopIcon, 0, 0, 39, 14,
+ p_stopIcon->width, p_stopIcon->height );
+ if( p_fscreen )
+ XPutImage( p_display, control, gc, p_fscreen, 0, 0, 67, 21,
+ p_fscreen->width, p_fscreen->height );
+
+ if( p_unmuteIcon && b_mute )
+ {
+ XPutImage( p_display, control, gc, p_unmuteIcon, 0, 0, 94, 30,
+ p_unmuteIcon->width, p_unmuteIcon->height );
+ }
+ else if( p_muteIcon )
+ {
+ XPutImage( p_display, control, gc, p_muteIcon, 0, 0, 94, 30,
+ p_muteIcon->width, p_muteIcon->height );
+ }
+
+ if( p_timeline )
+ XPutImage( p_display, control, gc, p_timeline, 0, 0, 4, 4,
+ (window.width-8), p_timeline->height );
+ if( p_timeKnob && (f_position > 0) )
+ {
+ f_position = (((float)window.width-8)/100)*f_position;
+ XPutImage( p_display, control, gc, p_timeKnob, 0, 0, (4+f_position), 2,
+ p_timeKnob->width, p_timeKnob->height );
+ }
+
+ /* Cleanup */
+ if( p_playIcon ) XDestroyImage( p_playIcon );
+ if( p_pauseIcon ) XDestroyImage( p_pauseIcon );
+ if( p_stopIcon ) XDestroyImage( p_stopIcon );
+ if( p_timeline ) XDestroyImage( p_timeline );
+ if( p_timeKnob ) XDestroyImage( p_timeKnob );
+ if( p_fscreen ) XDestroyImage( p_fscreen );
+ if( p_muteIcon ) XDestroyImage( p_muteIcon );
+ if( p_unmuteIcon ) XDestroyImage( p_unmuteIcon );
+
+ XFreeGC( p_display, gc );
+}
+
+static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
+{
+ VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
+ const NPWindow& window = p_plugin->getWindow();
+
+ int i_height = window.height;
+ int i_width = window.width;
+ int i_xPos = event->xbutton.x;
+ int i_yPos = event->xbutton.y;
+
+ libvlc_exception_t ex;
+ libvlc_exception_init( &ex );
+ libvlc_media_instance_t *p_md =
+ libvlc_playlist_get_media_instance(p_plugin->getVLC(), &ex);
+ libvlc_exception_clear( &ex );
+
+ /* jump in the movie */
+ if( i_yPos <= (i_height-30) )
+ {
+ vlc_int64_t f_length;
+ libvlc_exception_init( &ex );
+ f_length = libvlc_media_instance_get_length( p_md, &ex ) / 100;
+ libvlc_exception_clear( &ex );
+
+ f_length = (float)f_length *
+ ( ((float)i_xPos-4 ) / ( ((float)i_width-8)/100) );
+
+ libvlc_exception_init( &ex );
+ libvlc_media_instance_set_time( p_md, f_length, &ex );
+ libvlc_exception_clear( &ex );
+ }
+
+ /* play/pause toggle */
+ if( (i_yPos > (i_height-30)) && (i_xPos > 4) && (i_xPos <= 39) )
+ {
+ int i_playing;
+ libvlc_exception_init( &ex );
+ i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex );
+ libvlc_exception_clear( &ex );
+
+ libvlc_exception_init( &ex );
+ if( i_playing == 1 )
+ libvlc_playlist_pause( p_plugin->getVLC(), &ex );
+ else
+ libvlc_playlist_play( p_plugin->getVLC(), -1, 0, NULL, &ex );
+ libvlc_exception_clear( &ex );
+ }
+
+ /* stop */
+ if( (i_yPos > (i_height-30)) && (i_xPos > 39) && (i_xPos < 67) )
+ {
+ libvlc_exception_init( &ex );
+ libvlc_playlist_stop( p_plugin->getVLC(), &ex );
+ libvlc_exception_clear( &ex );
+ }
+
+ /* fullscreen */
+ if( (i_yPos > (i_height-30)) && (i_xPos >= 67) && (i_xPos < 94) )
+ {
+ libvlc_exception_init( &ex );
+ libvlc_set_fullscreen( p_md, 1, &ex );
+ libvlc_exception_clear( &ex );
+ }
+
+ /* mute toggle */
+ if( (i_yPos > (i_height-30)) && (i_xPos >= 94) && (i_xPos < 109))
+ {
+ libvlc_exception_init( &ex );
+ libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex );
+ libvlc_exception_clear( &ex );
+ }
+ libvlc_media_instance_release( p_md );
+
+ Redraw( w, closure, event );