Question

I'm working with a treeview, which contains several columns, also one displaying a pixbuf, if audio is playing or paused. If the user double clicks on one row, audio playback starts and the row needs to be rerendered in order to display the pixbuf icon. I used QueueDraw for this, but that does only work, if the cursor leaves the current row. How can I update the pixbuf directly?

CODE:

protected void trvMainCuesheetRowActivated (object o, RowActivatedArgs args)
    {
        log.debug("trvMainCuesheetRowActivated called");
        TreeIter ti = TreeIter.Zero;
        this.lsCuesheetData.GetIter(out ti,args.Path);
        if (this.lsCuesheetData.GetValue(ti,0) != null)
        {
            Track tCurTrack = (Track)this.lsCuesheetData.GetValue(ti,0);
            if (this.objProgram.getAudioManager().getPlayState() == AudioCuesheetEditor.AudioBackend.PlayState.Stopped)
            {
                this.objProgram.getAudioManager().play(tCurTrack);
                this.refresh();
            }
            else
            {
                if (this.objProgram.getAudioManager().getPlayState() == AudioCuesheetEditor.AudioBackend.PlayState.Playing)
                {
                    this.objProgram.getAudioManager().seek(tCurTrack);
                    this.refresh();
                }
            }
        }
    }


private void renderPlaying(TreeViewColumn _tvcColumn, CellRenderer _crCell, TreeModel _tmModel, TreeIter _tiIter)
    {
        Track tCurTrack = (Track)_tmModel.GetValue (_tiIter, 0);
        //Just display an icon, if we are playing
        if (this.objProgram.getAudioManager().getPlayState() == AudioCuesheetEditor.AudioBackend.PlayState.Playing)
        {
            if (this.objProgram.getAudioManager().getCurrentlyPlayingTrack() == tCurTrack)
            {
                Gdk.Pixbuf icon = this.RenderIcon(Stock.MediaPlay, IconSize.SmallToolbar, null);
                (_crCell as CellRendererPixbuf).Pixbuf = icon;
            } 
            else
            {
                (_crCell as CellRendererPixbuf).Pixbuf = null;
            }
        }
        else
        {
            if (this.objProgram.getAudioManager().getPlayState() == AudioCuesheetEditor.AudioBackend.PlayState.Paused)
            {
                if (this.objProgram.getAudioManager().getCurrentlyPlayingTrack() == tCurTrack)
                {
                    Gdk.Pixbuf icon = this.RenderIcon(Stock.MediaPause, IconSize.SmallToolbar, null);
                    (_crCell as CellRendererPixbuf).Pixbuf = icon;
                }
                else
                {
                    (_crCell as CellRendererPixbuf).Pixbuf = null;
                }
            }
            else
            {
                (_crCell as CellRendererPixbuf).Pixbuf = null;
            }
        }
    }

//Purpose: Function used to refresh the MainWindow depending on new options set.
public void refresh()
{
    //QueueDraw is needed since it fires a signal to cellrenderers to update
    this.trvMainCuesheet.QueueDraw();
    this.sbMainWindow.Visible = this.objProgram.getObjOption().getBShowStatusbar();
    this.mwToolbar.Visible = this.objProgram.getObjOption().getBToolbarVisible();
}

Greetings Sven

Was it helpful?

Solution

Found the error myself.

this.objProgram.getAudioManager().getCurrentlyPlayingTrack()

didn't always return a track, where I expected one, so the renderer worked right. Bug is fixed, thanks anyway ;).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top