~ubuntu-branches/ubuntu/karmic/mhwaveedit/karmic

« back to all changes in this revision

Viewing changes to src/document.c

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2008-01-08 22:20:37 UTC
  • mfrom: (2.1.6 hardy)
  • Revision ID: james.westby@ubuntu.com-20080108222037-tsazhckl5vmc8yih
Tags: 1.4.14-2
Added desktop file (Closes: #457849), thanks to Marco Rodrigues

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
enum { VIEW_CHANGED_SIGNAL, SELECTION_CHANGED_SIGNAL, CURSOR_CHANGED_SIGNAL,
38
38
       STATE_CHANGED_SIGNAL, LAST_SIGNAL };
39
 
static gint document_signals[LAST_SIGNAL] = { 0 };
 
39
static guint document_signals[LAST_SIGNAL] = { 0 };
40
40
 
41
41
static GtkObjectClass *parent_class;
42
42
 
297
297
{     
298
298
     off_t ps,pe,pc;
299
299
     
300
 
 
 
300
     g_assert(d != NULL);
301
301
     /* This special if case was introduced to avoid a skipping sound
302
302
      * caused by the cursor not matching the actual playing positon when
303
303
      * pressing the "play" button and you're already playing. This
326
326
 
327
327
void document_play_from_cursor(Document *d, gboolean loopmode, gfloat speed)
328
328
{
 
329
     g_assert(d != NULL);
329
330
     document_play(d,d->cursorpos,d->chunk->length,loopmode,speed);
330
331
}
331
332
 
332
333
void document_play_selection(Document *d, gboolean loopmode, gfloat speed)
333
334
{
 
335
     g_assert(d != NULL);
334
336
     if (d->selstart != d->selend)
335
337
          document_play(d,d->selstart,d->selend,loopmode,speed);
336
338
     else
340
342
void document_stop(Document *d, gboolean do_return)
341
343
{
342
344
     off_t o;
 
345
     g_assert(d != NULL);
343
346
     if (d != playing_document) return;
344
347
     player_stop();
345
348
     if (!do_return) {
516
519
                * If the result is shorter, report the difference as a 
517
520
                * removal at the new selection's right endpoint */
518
521
               if (rlen > plen)
519
 
                    document_update(d, r, d->selstart+plen, rlen-plen);
 
522
                    document_update(d, c, d->selstart+plen, rlen-plen);
520
523
               else
521
 
                    document_update(d, r, d->selstart+rlen, rlen-plen);
 
524
                    document_update(d, c, d->selstart+rlen, rlen-plen);
522
525
               return FALSE;
523
526
          } else
524
527
               return TRUE;
535
538
         (d->selstart==0 && d->selend >= d->chunk->length)) {
536
539
          /* procstart(w); */
537
540
          chunk_parse(d->chunk,proc,allchannels,convert,dither_editing,
538
 
                      d->bar,title);
 
541
                      d->bar,title,0,FALSE);
539
542
          /* procend(w); */
540
543
     } else {
541
544
          c = chunk_get_part(d->chunk,d->selstart,
542
545
                             d->selend - d->selstart);
543
546
          /* procstart(w); */
544
547
          chunk_parse(c,proc,allchannels,convert,dither_editing,
545
 
                      d->bar,title);
 
548
                      d->bar,title,0,FALSE);
546
549
          /* procend(w); */
547
550
          gtk_object_sink(GTK_OBJECT(c));
548
551
     }
555
558
     Chunk *c,*p,*r;
556
559
     off_t u,plen,rlen;
557
560
     /* Decide if we should filter selection or the whole file */
558
 
     if ((d->selstart == d->selend) ||
 
561
     if ((!selection_only) || 
 
562
         (d->selstart == d->selend) ||
559
563
         (d->selstart==0 && d->selend >= d->chunk->length)) {
560
564
          r = proc( d->chunk, d->bar, user_data );
561
565
          if (r) { 
647
651
     document_set_cursor_main(d,cursorpos,FALSE);
648
652
}
649
653
 
 
654
off_t document_nudge_cursor(Document *d, off_t delta)
 
655
{
 
656
     off_t newpos;
 
657
 
 
658
     newpos = d->cursorpos + delta;
 
659
     if(newpos > d->chunk->length)
 
660
     {
 
661
          delta = (d->chunk->length) - (d->cursorpos);
 
662
     } else if(newpos < 0) {
 
663
          delta = - (d->cursorpos);
 
664
     }
 
665
 
 
666
     newpos = d->cursorpos + delta;
 
667
     document_set_cursor(d,newpos);
 
668
 
 
669
     return delta;
 
670
}
 
671
 
650
672
void document_set_followmode(Document *d, gboolean mode)
651
673
{
652
674
     d->followmode = mode;
655
677
void document_set_view(Document *d, off_t viewstart, off_t viewend)
656
678
{
657
679
     off_t o;
658
 
 
 
680
     
659
681
     /* puts("document_set_view"); */
660
682
     if (viewstart > viewend) {
661
683
          o = viewstart;
662
684
          viewstart = viewend;
663
685
          viewend = o;
664
686
     }
665
 
     g_assert(viewstart >= 0 && viewstart < d->chunk->length &&
 
687
     g_assert(viewstart >= 0 && 
 
688
              (viewstart < d->chunk->length || d->chunk->length == 0) &&
666
689
              viewend >= 0 && viewend <= d->chunk->length);
667
690
     if (d->viewstart != viewstart || d->viewend != viewend) {
668
691
          d->viewstart = viewstart;