Changeset 124

Show
Ignore:
Timestamp:
04/23/04 10:15:59 (8 years ago)
Author:
conrad
Message:

updated to 0.8.2

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/sweep/ABOUT-NLS

    r7 r124  
    99   If you found this `ABOUT-NLS' file inside a distribution, you may 
    1010assume that the distributed package does use GNU `gettext' internally, 
    11 itself available at your nearest GNU archive site.  But you do *not* 
     11itself available at your nearest GNU archive site.  But you do _not_ 
    1212need to install GNU `gettext' prior to configuring, installing or using 
    1313this package with messages translated. 
     
    2323`intl/VERSION' file, in internationalized packages. 
    2424 
    25 One advise in advance 
    26 ===================== 
     25Quick configuration advice 
     26========================== 
    2727 
    2828   If you want to exploit the full power of internationalization, you 
     
    3535operating system where this package is being installed.  So far, only 
    3636the `gettext' implementation in the GNU C library version 2 provides as 
    37 many features (such as locale alias or message inheritance) as the 
    38 implementation here.  It is also not possible to offer this additional 
    39 functionality on top of a `catgets' implementation.  Future versions of 
    40 GNU `gettext' will very likely convey even more functionality.  So it 
    41 might be a good idea to change to GNU `gettext' as soon as possible. 
    42  
    43    So you need not provide this option if you are using GNU libc 2 or 
     37many features (such as locale alias, message inheritance, automatic 
     38charset conversion or plural form handling) as the implementation here. 
     39It is also not possible to offer this additional functionality on top 
     40of a `catgets' implementation.  Future versions of GNU `gettext' will 
     41very likely convey even more functionality.  So it might be a good idea 
     42to change to GNU `gettext' as soon as possible. 
     43 
     44   So you need _not_ provide this option if you are using GNU libc 2 or 
    4445you have installed a recent copy of the GNU gettext package with the 
    4546included `libintl'. 
     
    5455 
    5556   By default, this package will be installed to allow translation of 
    56 messages.  It will automatically detect whether the system provides 
    57 usable `catgets' (if using this is selected by the installer) or 
    58 `gettext' functions.  If neither is available, the GNU `gettext' own 
     57messages.  It will automatically detect whether the system already 
     58provides the GNU `gettext' functions.  If not, the GNU `gettext' own 
    5959library will be used.  This library is wholly contained within this 
    6060package, usually in the `intl/' subdirectory, so prior installation of 
    61 the GNU `gettext' package is *not* required.  Installers may use 
     61the GNU `gettext' package is _not_ required.  Installers may use 
    6262special options at configuration time for changing the default 
    6363behaviour.  The commands: 
    6464 
    6565     ./configure --with-included-gettext 
    66      ./configure --with-catgets 
    6766     ./configure --disable-nls 
    6867 
    69 will respectively bypass any pre-existing `catgets' or `gettext' to use 
    70 the internationalizing routines provided within this package, enable 
    71 the use of the `catgets' functions (if found on the locale system), or 
    72 else, *totally* disable translation of messages. 
     68will respectively bypass any pre-existing `gettext' to use the 
     69internationalizing routines provided within this package, or else, 
     70_totally_ disable translation of messages. 
    7371 
    7472   When you already have GNU `gettext' installed on your system and run 
     
    8482to prevent auto-detection. 
    8583 
    86    By default the configuration process will not test for the `catgets' 
    87 function and therefore they will not be used.  The reasons are already 
    88 given above: the emulation on top of `catgets' cannot provide all the 
    89 extensions provided by the GNU `gettext' library.  If you nevertheless 
    90 want to use the `catgets' functions use 
    91  
    92      ./configure --with-catgets 
    93  
    94 to enable the test for `catgets' (this causes no harm if `catgets' is 
    95 not available on your system).  If you really select this option we 
    96 would like to hear about the reasons because we cannot think of any 
    97 good one ourself. 
     84   The configuration process will not test for the `catgets' function 
     85and therefore it will not be used.  The reason is that even an 
     86emulation of `gettext' on top of `catgets' could not provide all the 
     87extensions of the GNU `gettext' library. 
    9888 
    9989   Internationalized packages have usually many `po/LL.po' files, where 
     
    111101   As a user, if your language has been installed for this package, you 
    112102only have to set the `LANG' environment variable to the appropriate 
    113 ISO 639 `LL' two-letter code prior to using the programs in the 
    114 package.  For example, let's suppose that you speak German.  At the 
    115 shell prompt, merely execute `setenv LANG de' (in `csh'), 
    116 `export LANG; LANG=de' (in `sh') or `export LANG=de' (in `bash').  This 
    117 can be done from your `.login' or `.profile' file, once and for all. 
    118  
    119    An operating system might already offer message localization for 
    120 many of its programs, while other programs have been installed locally 
    121 with the full capabilities of GNU `gettext'.  Just using `gettext' 
    122 extended syntax for `LANG' would break proper localization of already 
    123 available operating system programs.  In this case, users should set 
    124 both `LANGUAGE' and `LANG' variables in their environment, as programs 
    125 using GNU `gettext' give preference to `LANGUAGE'.  For example, some 
    126 Swedish users would rather read translations in German than English for 
    127 when Swedish is not available.  This is easily accomplished by setting 
    128 `LANGUAGE' to `sv:de' while leaving `LANG' to `sv'. 
     103`LL_CC' combination.  Here `LL' is an ISO 639 two-letter language code, 
     104and `CC' is an ISO 3166 two-letter country code.  For example, let's 
     105suppose that you speak German and live in Germany.  At the shell 
     106prompt, merely execute `setenv LANG de_DE' (in `csh'), 
     107`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). 
     108This can be done from your `.login' or `.profile' file, once and for 
     109all. 
     110 
     111   You might think that the country code specification is redundant. 
     112But in fact, some languages have dialects in different countries.  For 
     113example, `de_AT' is used for Austria, and `pt_BR' for Brazil.  The 
     114country code serves to distinguish the dialects. 
     115 
     116   Not all programs have translations for all languages.  By default, an 
     117English message is shown in place of a nonexistent translation.  If you 
     118understand other languages, you can set up a priority list of languages. 
     119This is done through a different environment variable, called 
     120`LANGUAGE'.  GNU `gettext' gives preference to `LANGUAGE' over `LANG' 
     121for the purpose of message handling, but you still need to have `LANG' 
     122set to the primary language; this is required by other parts of the 
     123system libraries.  For example, some Swedish users who would rather 
     124read translations in German than English for when Swedish is not 
     125available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'. 
     126 
     127   In the `LANGUAGE' environment variable, but not in the `LANG' 
     128environment variable, `LL_CC' combinations can be abbreviated as `LL' 
     129to denote the language's main dialect.  For example, `de' is equivalent 
     130to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' 
     131(Portuguese as spoken in Portugal) in this context. 
    129132 
    130133Translating Teams 
     
    134137people who like their own language and write it well, and who are also 
    135138able to synergize with other translators speaking the same language. 
    136 Each translation team has its own mailing list, courtesy of Linux 
    137 International.  You may reach your translation team at the address 
    138 `LL@li.org', replacing LL by the two-letter ISO 639 code for your 
    139 language.  Language codes are *not* the same as the country codes given 
    140 in ISO 3166.  The following translation teams exist, as of December 
    141 1997: 
    142  
    143      Chinese `zh', Czech `cs', Danish `da', Dutch `nl', English `en', 
    144      Esperanto `eo', Finnish `fi', French `fr', German `de', Hungarian 
    145      `hu', Irish `ga', Italian `it', Indonesian `id', Japanese `ja', 
    146      Korean `ko', Latin `la', Norwegian `no', Persian `fa', Polish 
    147      `pl', Portuguese `pt', Russian `ru', Slovenian `sl', Spanish `es', 
    148      Swedish `sv', and Turkish `tr'. 
    149  
    150 For example, you may reach the Chinese translation team by writing to 
    151 `zh@li.org'. 
    152  
    153    If you'd like to volunteer to *work* at translating messages, you 
     139Each translation team has its own mailing list.  The up-to-date list of 
     140teams can be found at the Free Translation Project's homepage, 
     141`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams" 
     142area. 
     143 
     144   If you'd like to volunteer to _work_ at translating messages, you 
    154145should become a member of the translating team for your own language. 
    155 The subscribing address is *not* the same as the list itself, it has 
     146The subscribing address is _not_ the same as the list itself, it has 
    156147`-request' appended.  For example, speakers of Swedish can send a 
    157148message to `sv-request@li.org', having this message body: 
     
    160151 
    161152   Keep in mind that team members are expected to participate 
    162 *actively* in translations, or at solving translational difficulties, 
     153_actively_ in translations, or at solving translational difficulties, 
    163154rather than merely lurking around.  If your team does not exist yet and 
    164155you want to start one, or if you are unsure about what to do or how to 
     
    174165 
    175166   Languages are not equally supported in all packages.  The following 
    176 matrix shows the current state of internationalization, as of December 
    177 1997.  The matrix shows, in regard of each package, for which languages 
    178 PO files have been submitted to translation coordination. 
    179  
    180      Ready PO files    cs da de en es fi fr it ja ko nl no pl pt ru sl sv 
    181                      .----------------------------------------------------. 
    182      bash            |       []          []          []                   |  3 
    183      bison           |       []          []          []                   |  3 
    184      clisp           |       [] [] []    []                               |  4 
    185      cpio            |       []    []    []       [] []    []             |  6 
    186      diffutils       |       []    []    []                []          [] |  5 
    187      enscript        |       []    [] [] []          []             []    |  6 
    188      fileutils       | []    []    []    []       [] []    [] []    [] [] | 10 
    189      findutils       |       []    []    [] []    [] []    []    []    [] |  9 
    190      flex            |             []    []       []                   [] |  4 
    191      gcal            |       []          []          []    []          [] |  5 
    192      gettext         |    [] []    []    []       [] [] [] [] []    [] [] | 12 
    193      grep            |       []    []    []       [] [] [] []    [] [] [] | 10 
    194      hello           |    [] []    []    []       [] [] [] [] []    [] [] | 11 
    195      id-utils        |       []          []                []             |  3 
    196      indent          |    [] []                   []       []    []       |  5 
    197      libc            |       []    []    []       [] []    []          [] |  7 
    198      m4              |       []          []    []    []          []    [] |  6 
    199      make            |       []    []    []       [] []    []             |  6 
    200      music           |                   []                []             |  2 
    201      ptx             |       []    []    []          [] [] [] []       [] |  8 
    202      recode          |    [] []    []    []          []    [] []    [] [] |  9 
    203      sh-utils        |       []    []    []          [] [] [] []       [] |  8 
    204      sharutils       | []    []    []    []          []                [] |  6 
    205      tar             | []    []          [] []    [] [] [] [] []    [] [] | 11 
    206      texinfo         | []    []          []                               |  3 
    207      textutils       | []    []    []    []       [] [] [] []          [] |  9 
    208      wdiff           | []    []    []    []          [] [] []          [] |  8 
    209                      `----------------------------------------------------' 
    210        17 languages    cs da de en es fi fr it ja ko nl no pl pt ru sl sv 
    211        27 packages      6  4 25  1 18  1 26  2  1 12 20  9 19  7  4  7 17  179 
     167matrix shows the current state of internationalization, as of September 
     1682001.  The matrix shows, in regard of each package, for which languages 
     169PO files have been submitted to translation coordination, with a 
     170translation percentage of at least 50%. 
     171 
     172     Ready PO files    bg cs da de el en eo es et fi fr gl he hr id it ja 
     173                     +----------------------------------------------------+ 
     174     a2ps            |          []             []    []                   | 
     175     bash            |          []       [] []       []                   | 
     176     bfd             |                                                    | 
     177     binutils        |                               []                   | 
     178     bison           |          []          [] []    []                [] | 
     179     clisp           |          []    []    []       []                   | 
     180     cpio            |       [] []          []       [] []                | 
     181     diffutils       |       [] []       [] []       [] []       []       | 
     182     enscript        |          []                   []                   | 
     183     error           |                      []       []                   | 
     184     fetchmail       |                                                    | 
     185     fileutils       |    [] [] [] []       []       [] []             [] | 
     186     findutils       |       [] []          [] []    [] []       [] []    | 
     187     flex            |       []             []       []                   | 
     188     freetype        |                                                    | 
     189     gas             |                                                    | 
     190     gawk            |                               []    []             | 
     191     gcal            |                                                    | 
     192     gcc             |                                                    | 
     193     gettext         |    [] [] [] []       []       [] []       [] [] [] | 
     194     gnupg           |          []       []    []    [] []          [] [] | 
     195     gprof           |                                                    | 
     196     grep            |    []    []       [] [] []    [] []          []    | 
     197     hello           |       [] [] []    [] [] [] [] [] []          [] [] | 
     198     id-utils        |       [] []                   []                   | 
     199     indent          |       [] []             []    [] []                | 
     200     jpilot          |                               []                   | 
     201     kbd             |                                                    | 
     202     ld              |                               []                   | 
     203     libc            |    [] [] [] []       []       [] []             [] | 
     204     lilypond        |                                                 [] | 
     205     lynx            |    [] [] []                                     [] | 
     206     m4              |    [] [] [] []                [] []       []    [] | 
     207     make            |       [] []          []       [] []             [] | 
     208     mysecretdiary   |          []                                        | 
     209     nano            |                      []          []       []       | 
     210     opcodes         |                                                    | 
     211     parted          |          []                      []             [] | 
     212     ptx             |       [] []          [] []    [] []       []       | 
     213     python          |                                                    | 
     214     recode          |       [] [] []    [] []       [] [] []       []    | 
     215     sed             |    [] [] [] []    []    []    [] [] []    [] [] [] | 
     216     sh-utils        |    [] [] [] []       [] []    [] []          [] [] | 
     217     sharutils       |    [] [] [] []       []       [] []             [] | 
     218     sketch          |                                                    | 
     219     soundtracker    |          []          []          []                | 
     220     sp              |                                                    | 
     221     tar             |    [] [] []          [] []    []             [] [] | 
     222     texinfo         |    [] [] []       []          []                [] | 
     223     textutils       |    [] [] [] []       []       [] []             [] | 
     224     util-linux      |    [] []                                           | 
     225     wdiff           |       [] []             []                         | 
     226     wget            |    [] [] [] []       [] []    [] [] []          [] | 
     227                     +----------------------------------------------------+ 
     228                       bg cs da de el en eo es et fi fr gl he hr id it ja 
     229                        0 14 24 32 11  1  8 23 13  1 33 22  4  0  7  9 18 
     230      
     231                       ko lv nb nl nn no pl pt pt_BR ru sk sl sv tr uk zh 
     232                     +----------------------------------------------------+ 
     233     a2ps            |          []                   []    []             |  6 
     234     bash            |                                                    |  4 
     235     bfd             |                                                    |  0 
     236     binutils        |                                                    |  1 
     237     bison           |                               []                   |  6 
     238     clisp           |          []                                        |  5 
     239     cpio            | []       []       []     []   []                   | 10 
     240     diffutils       |                   []          []       [] []       | 11 
     241     enscript        |          []              []   []                   |  5 
     242     error           |                                  []       []       |  4 
     243     fetchmail       |                                                    |  0 
     244     fileutils       | []       []       []     []   [] [] [] [] []       | 17 
     245     findutils       | []       []       []     []   []    [] [] []       | 16 
     246     flex            | []                            []       []          |  6 
     247     freetype        |                                                    |  0 
     248     gas             |                                                    |  0 
     249     gawk            |                                           []       |  3 
     250     gcal            |                                                    |  0 
     251     gcc             |                                                    |  0 
     252     gettext         | []                []     []   []    [] [] []    [] | 18 
     253     gnupg           |                   []                   [] []       | 10 
     254     gprof           |                                                    |  0 
     255     grep            |                   []                [] [] []       | 12 
     256     hello           | [] [] [] []    [] []          [] []    [] [] []    | 22 
     257     id-utils        |          []                   []       []          |  6 
     258     indent          | []       []       []          [] []    [] []       | 12 
     259     jpilot          |                                                    |  1 
     260     kbd             |                                           []       |  1 
     261     ld              |                                                    |  1 
     262     libc            | []    []       [] []     []      []    [] []       | 16 
     263     lilypond        |          []                            []          |  3 
     264     lynx            |          []              []   []       []          |  8 
     265     m4              |          []       []          []       []          | 12 
     266     make            | []       []       []     []   []          []       | 12 
     267     mysecretdiary   |                                                    |  1 
     268     nano            |                                        []          |  4 
     269     opcodes         |                                           []       |  1 
     270     parted          |          []                   []                   |  5 
     271     ptx             |       [] []    [] [] []       []       [] []       | 15 
     272     python          |                                                    |  0 
     273     recode          |                   []          []    [] []          | 13 
     274     sed             |          []              []   [] [] [] [] []       | 19 
     275     sh-utils        |       [] []    [] []     []   [] [] [] [] []    [] | 21 
     276     sharutils       |          []                   []       []          | 11 
     277     sketch          |                                                    |  0 
     278     soundtracker    |                                                    |  3 
     279     sp              |                                                    |  0 
     280     tar             |       []       [] []     []         [] [] []       | 15 
     281     texinfo         |                               []                   |  7 
     282     textutils       |       [] []    [] []     []   [] [] []             | 16 
     283     util-linux      |                          []               []       |  4 
     284     wdiff           |                               [] []    [] []       |  7 
     285     wget            |          []                   [] [] [] [] [] []    | 17 
     286                     +----------------------------------------------------+ 
     287       33 teams        ko lv nb nl nn no pl pt pt_BR ru sk sl sv tr uk zh 
     288       53 domains       9  1  6 20  0  6 17  1  13   25 10 11 23 21  2  2  387 
    212289 
    213290   Some counters in the preceding matrix are higher than the number of 
     
    222299distribution. 
    223300 
    224    If December 1997 seems to be old, you may fetch a more recent copy 
    225 of this `ABOUT-NLS' file on most GNU archive sites. 
    226  
     301   If September 2001 seems to be old, you may fetch a more recent copy 
     302of this `ABOUT-NLS' file on most GNU archive sites.  The most 
     303up-to-date matrix with full percentage details can be found at 
     304`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'. 
     305 
     306Using `gettext' in new packages 
     307=============================== 
     308 
     309   If you are writing a freely available program and want to 
     310internationalize it you are welcome to use GNU `gettext' in your 
     311package.  Of course you have to respect the GNU Library General Public 
     312License which covers the use of the GNU `gettext' library.  This means 
     313in particular that even non-free programs can use `libintl' as a shared 
     314library, whereas only free software can use `libintl' as a static 
     315library or use modified versions of `libintl'. 
     316 
     317   Once the sources are changed appropriately and the setup can handle 
     318to use of `gettext' the only thing missing are the translations.  The 
     319Free Translation Project is also available for packages which are not 
     320developed inside the GNU project.  Therefore the information given above 
     321applies also for every other Free Software Project.  Contact 
     322`translation@iro.umontreal.ca' to make the `.pot' files available to 
     323the translation teams. 
     324 
  • trunk/sweep/AUTHORS

    r123 r124  
    2929        bug fix in save as dialog 
    3030 
     31Erik de Castro Lopo <erikd@zip.com.au> 
     32        libsndfile-1 file import/export, random bugfixes 
     33 
     34Zenaan Harkness <zen@getsystems.com> 
     35        improved handling of volume and pitch sliders 
     36 
    3137Borrowed Code 
    3238============= 
    3339 
    3440Michael Krause <m.krause@tu=harburg.de> 
    35         Basic code for sample=display widget from soundtracker. 
     41        sample-display widget adapted from Soundtracker. 
    3642 
    3743Spencer Kimball and Peter Mattis 
    3844        about_dialog.c adapted from the Gimp. 
     45 
     46Mike Oliphant 
     47        transport buttons, LCD screen and style handling code from Grip 
     48 
     49Christopher Montgomery 
     50        Ogg Vorbis encoding and decoding adapted from example code in 
     51        the Ogg Vorbis source (Copyright (C) 1994-2002 Xiph.Org Foundation) 
     52 
     53Robert Leslie 
     54        MPEG audio decoding adapted from player.c in the mad source 
     55 
     56Jean-Marc Valin 
     57        Speex encoding and decoding adapted from speexenc and speexdec 
    3958 
    4059 
     
    4261============ 
    4362 
     63Dokianakis Fanis <madf@hellug.gr> 
     64        el 
     65 
    4466Mathieu Roy <yeupou@altern.org> 
    45         fr 
     67        fr (Sweep 0.1.x) 
    4668 
    4769Gergely Nagy <mhp@lonyay.edu.hu> 
    48         hu 
     70        hu (Sweep 0.1.x) 
    4971 
    5072Yuri Bongiorno <yurix@tiscalinet.it> 
     
    5476        de 
    5577 
    56 Yuri Victorovich <yuri@tsoft.com> 
     78Alexandre Prokoudine <avp@altlinux.ru> 
     79Yuri Victorovich <yuri@tsoft.com> (Sweep 0.1.x) 
    5780        ru 
    5881 
    5982Radoslaw Korzeniewski <Radoslaw.Korzeniewski@centertel.pl> 
    60         pl 
     83        pl (Sweep 0.1.x) 
     84 
    6185 
    6286Artwork 
    6387======= 
    6488 
     89Mike Oliphant 
     90        Transport button pixmaps (adapted from Grip) 
     91 
    6592Mathieu Roy <yeupou@altern.org> 
    66         Colourful button pixmaps 
     93        Colourful button pixmaps in Sweep 0.1.x 
     94 
     95Conrad Parker <conrad@vergenet.net> 
     96        General pixmaps, Scrubby 
    6797 
    6898 
     
    72102Anand Kumria <akumria@debian.org> 
    73103        Debian packages 
     104 
     105Julio Merino Vidal <jmmv@hispabsd.org> 
     106        NetBSD packages (+ contributed configure and build fixes) 
    74107 
    75108 
  • trunk/sweep/ChangeLog

    r123 r124  
     1Sat Apr 29 02:48:14 EST 2003 Silvia Pfeiffer <silvia@silvia-pfeiffer.de> 
     2 
     3        * driver_alsa.c: deleting double line #include <alsa/asoundlib.h> 
     4        * fixed files in src directory with config.h includes 
     5        * fixed inclusion of licensing info GPL in some src files 
     6        * fixed static string i18n also including _(...) for them 
     7        * added some strings to i18n 
     8 
     9Tue Apr 15 09:43:58 EST 2003 Conrad Parker <conrad@metadecks.org> 
     10 
     11        * driver_alsa.c: changed alsa init to use *_near functions 
     12 
     13Tue Apr  1 18:10:06 EST 2003 Conrad Parker <conrad@metadecks.org> 
     14 
     15        * driver_alsa.c: added endianness patch from Erik de Castro Lopo 
     16        * file_speex.c: added VBR without DTX option for speex-1.0rc3 
     17 
     18Tue Feb 18 06:59:23 EST 2003 Conrad Parker <conrad@metadecks.org> 
     19 
     20        * sample-display.c: added Super_L (new Logo mapping) to scrubbing keys 
     21        * driver_alsa.c: merged in ALSA 0.9 code from Zenaan Harkness 
     22        * driver.c: abstracted out config dialog for both OSS and ALSA 
     23 
     24Tue Feb 11 22:00:36 EST 2003 Conrad Parker <conrad@metadecks.org> 
     25 
     26        * el.po: new file -- Greek translation by Dokianakis Fanis 
     27        * param.c: fixed granularity of sliders in process dialogs 
     28 
     29Thu Feb  6 20:44:05 EST 2003 Conrad Parker <conrad@metadecks.org> 
     30 
     31        * file_speex.c: added stereo handling and skipping of extra headers 
     32 
     33Mon Feb  3 22:33:04 EST 2003 Conrad Parker <conrad@metadecks.org> 
     34 
     35        * edit.c: updated splice_in_eb to use realloc 
     36 
     37Wed Jan 29 23:51:02 EST 2003 Conrad Parker <conrad@metadecks.org> 
     38 
     39        * edit.c: added refcounting to edit buffers 
     40        * edit.c: removed edit_buffer_copy calls in copy and paste insert ops 
     41        * edit.c: switched edit region allocations to mmap temp files 
     42        * file_dialogs.c: modified load to create new for nonexistant files 
     43        * file_dialogs.c: added pathname arg to new dialog 
     44        * main.c: prepended cwd to naked filenames before loading 
     45        * file_sndfile1.c: updated raw error string for recent libsndfile1 
     46 
     47Sat Jan 18 16:49:49 EST 2003 Conrad Parker <conrad@metadecks.org> 
     48 
     49        * added monitoring functionality 
     50        * it.po: updated from Yuri Bongiorno 
     51        * fixed wacky play/play sel keyboard interaction (thx Heimo!) 
     52 
     53Fri Dec 20 17:36:27 EST 2002 Conrad Parker <conrad@metadecks.org> 
     54 
     55        * notes.c, param.c, view.c: pasting preprocessor fixes and note 
     56        cleanups by Erik de Castro Lopo 
     57        * src/Makefile.am: added EXPORT_SYMBOLS_LDFLAGS to sweep_LDFLAGS 
     58        for NetBSD (should be empty string on Solaris) -- by Julio Merino 
     59        * byenergy.c: fixed spelling error (reported by Yuri Bongiorno) 
     60        * fade.c: new file -- fade in and out filters 
     61 
     62Fri Dec  6 14:54:33 EST 2002 Conrad Parker <conrad@metadecks.org> 
     63 
     64        * README.i18n: new file from Silvia Pfeiffer 
     65        * it.po: updated from Yuri Bongiorno 
     66        * byenergy.c: fixed typo "threshholdor" 
     67 
     68Thu Dec  5 14:47:11 EST 2002 Conrad Parker <conrad@metadecks.org> 
     69 
     70        * file_dialogs.c: fixed stupid bug in mp3 extension checking 
     71        * play.c, notes.c: fixed bug in pitched playback 
     72        * callbacks.c, view.c: fixed overzealous setting of playmarker 
     73        on refresh of scrollbar adjustment 
     74        * play.c: fixed preview cut and preroll, moved out of experimental 
     75 
     76Thu Nov 28 14:49:48 EST 2002 Conrad Parker <conrad@metadecks.org> 
     77 
     78        * about_dialogs.c, file_dialogs.c, main.c, preferences.c: applied 
     79        patch from Andre Pang to fix some compile warnings on OS X 
     80        * driver_alsa.c: removed naked #include <alsa/asoundlib.h> 
     81 
     82Wed Nov 27 23:59:00 EST 2002 Conrad Parker <conrad@metadecks.org> 
     83 
     84        * sweep_sample.c: fixed bug in descriptions of selection actions 
     85        * paste_dialogs.c, edit.c: fixed paste_mix and paste_xfade, moved 
     86        out of experimental 
     87        * sample-display.c, sweep_sample.c: added Ctrl-Arrow Left/Right 
     88        to move cursor between selection edges 
     89        * view.c: added remember/zoom to area functionality 
     90        * view.c: included full first word of plugin names in process menu 
     91 
     92Tue Nov 26 12:19:21 EST 2002 Conrad Parker <conrad@metadecks.org> 
     93 
     94        * samplerate.c: updated for libsamplerate-0.0.11 
     95 
     96Mon Nov 25 22:44:26 EST 2002 Conrad Parker <conrad@metadecks.org> 
     97 
     98        * configure.in: moved ALSA build out of experimental 
     99        * driver_alsa.c: updates from Zenaan Harkness 
     100 
     101Sat Nov 23 14:35:33 EST 2002 Conrad Parker <conrad@metadecks.org> 
     102 
     103        * file_dialogs.c: added check of pathname extension before attempting 
     104        load as mp3; workaround inaccurate guessing of mp3 files (raw PCM 
     105        is sometimes guessed as mp3 otherwise) 
     106        * file_speex.c: updated to allow ultra wideband mode (speex-1.0beta3) 
     107        * sw_chooser.c: added 32 kHz (uwb) mode to samplerate chooser 
     108        * samplerate.c: updated for libsamplerate-0.0.9, added quality menu 
     109 
     110Fri Nov  1 23:09:12 EST 2002 Conrad Parker <conrad@metadecks.org> 
     111 
     112        * question_dialogs.c: switched from syserr_r (broken in glibc) to 
     113        g_strerror 
     114 
     115Thu Oct 31 11:07:29 EST 2002 Conrad Parker <conrad@metadecks.org> 
     116 
     117        * channelops.c: removed broken reference to <samplerate.h> 
     118 
     119Wed Oct 30 18:37:01 EST 2002 Conrad Parker <conrad@metadecks.org> 
     120 
     121        * question_dialogs.c: changed syserror_dialog to use strerror_r 
     122        * preferences.c, driver.c: Solaris compile fixes as outlined in 
     123        Sourceforge bug report #625528 
     124        * src/Makefile.am: commented out sweep_LDFLAGS = -Wl,--export as 
     125        requested by #625528; this was originally in place for Solaris 
     126        anyway, please advise if this breaks anything. 
     127 
     128Wed Oct 30 09:45:33 EST 2002 Conrad Parker <conrad@metadecks.org> 
     129 
     130        * file_*.c: added file_method to load functions; fixes a 'save' bug 
     131        * db_ruler.[ch]: new file -- dB ruler 
     132        * view.c, db_ruler.c: vertical zoom 
     133        * chanelsops.c: added channel duplicate ops 
     134 
     135Sun Oct 27 14:28:27 EST 2002 Conrad Parker <conrad@metadecks.org> 
     136 
     137        * channelops.[ch]: new files -- channel operations 
     138        * resample.c: added undo for resampling; moved out of experimental 
     139 
     140Tue Oct 22 23:58:05 EST 2002 Conrad Parker <conrad@metadecks.org> 
     141 
     142        * configure.in: fixed 'other libs' in check for libspeex 
     143        * resample.c: new file -- preliminary support for secret rabbit code 
     144 
     14521 Oct 2002 07:36:38 +1100 Zenaan Harkness <zen@getsystems.com> 
     146 
     147        * view.c: nicer volume & pitch slider adjustments 
     148 
     149Sat Oct 19 03:16:19 EST 2002 Conrad Parker <conrad@metadecks.org> 
     150 
     151        * file_speex.c: new file -- Speex import/export 
     152 
     153Thu Oct 17 16:40:53 EST 2002 Conrad Parker <conrad@metadecks.org> 
     154 
     155        * file_dialogs.c: added "MP3 export unsupported" dialog 
     156 
     157Wed Oct 16 10:16:17 EST 2002 Conrad Parker <conrad@metadecks.org> 
     158 
     159        * sweep_sample.c: added check for IDLE in sample_set_progress_ready() 
     160        * record.c: moved select out of ops_mutex lock 
     161        * head.c, sample-display.c: fixed tracking of record marker 
     162        * main.c: added initial question (new file or load file) 
     163        * question_dialogs.c: added quit_if_no_files stuff 
     164        * file_sndfile[01].c: added try_raw flags 
     165        * play.c: fixed rounding error in mixing files of different rate 
     166 
     167Mon Oct 14 18:58:21 EST 2002 Conrad Parker <conrad@metadecks.org> 
     168 
     169        * sample-display.c: added lock on ops_mutex in draw_data_channel 
     170 
     171Mon Oct 14 00:37:44 EST 2002 Conrad Parker <conrad@metadecks.org> 
     172 
     173        * file_mad.c: new file -- mpeg audio import via libmad 
     174 
     175Thu Oct 10 11:38:24 EST 2002 Conrad Parker <conrad@metadecks.org> 
     176 
     177        * file_sndfile0.c: backported all error checking etc. 
     178 
     179Wed Oct  9 18:14:05 EST 2002 Conrad Parker <conrad@metadecks.org> 
     180 
     181        * configure: filled out ogg vorbis checks, and ov_read_float args 
     182        * file_vorbis.c: put metadata handling in experimental branch, put 
     183          in support for old 3 arg ov_read_float () 
     184 
     185Wed Oct 9 00:29:06 EST 2002 Conrad Parker <conrad@metadecks.org> 
     186 
     187        * sweep_sample.c: prettied up "new file" dialog, added remember 
     188          functionality, added memory size calculation and filename input 
     189        * file_sndfile1.c, file_vorbis.c: moved setting of pathname to 
     190          occur after a successful save only 
     191        * file_sndfile1.c, file_vorbis.c: added sweep_perror()s throughout 
     192        * file_vorbis.c: added stats on file size 
     193        * question_dialogs.c: added pixmap field (suggested by Silvia) 
     194 
     195Tue Oct 8 00:38:13 EST 2002 Conrad Parker <conrad@metadecks.org> 
     196 
     197        * sweep_sample.c: fixed mtime copying in sample_copy 
     198        * question_dialogs.c: added sweep_perror errno info dialog 
     199        * file_sndfile1.c: moved perror reporting to sweep_perror 
     200        * timeouts.c: new file -- thread safe wrapper around gtk_timeout 
     201        * sweep_sample.c, question_dialogs.c: switched tmp_message and 
     202          dialogs to use sweep_timeout to invoke gtk stuff 
     203        * file_dialogs.c: added file access and dir existence checks 
     204        * sw_chooser.[ch]: new files -- widgets for choosing samplerate 
     205          and channels 
     206        * sweep_sample.c, file_sndfile1.c: updated to use sw_chooser 
     207 
     208Sat Oct  5 11:09:07 EST 2002 Conrad Parker <conrad@metadecks.org> 
     209 
     210        * file_vorbis.c: added full vorbis encoding options 
     211        * file_sndfile1.c: added logo etc., turned on DITHER_ON_WRITE 
     212 
     213Wed Oct  2 23:44:34 EST 2002 Conrad Parker <conrad@metadecks.org> 
     214 
     215        * file_vorbis.c: new file -- added Ogg Vorbis import/export 
     216        * file_dialogs.c, sweep_app.h: made file handling method generic 
     217 
     218Sun Sep 29 23:27:02 EST 2002 Conrad Parker <conrad@metadecks.org> 
     219 
     220        * sweep_sample.c: clamped percentage between 0 and 100 
     221        * play.c: fixed bug in starting position of pitched playback 
     222        * file_sndfile[01].c: added entry for samplerate in raw PCM load 
     223 
     224Wed Sep 25 22:42:12 EST 2002 Conrad Parker <conrad@metadecks.org> 
     225 
     226        * sweep_sample.c: added check for files playing to quit dialogs 
     227 
     228Wed Sep 25 17:40:55 EST 2002 Conrad Parker <conrad@metadecks.org> 
     229 
     230        * file_sndfile0.c: updates for libsndfile0 (for purposes of 
     231          backporting -- not recommended and must be explicitly enabled) 
     232        * edit.c: added check for format compatability in paste ops 
     233 
     234Mon Sep 23 23:13:07 EST 2002 Conrad Parker <conrad@metadecks.org> 
     235 
     236        * file_sndfile1.c: fixed percent bug in load/save of very short files 
     237        * view.c: fixed "ruler assumes 44100 samples/sec" (Debian bug #161721) 
     238        * sweep_filter.c: fixed cancelling of SweepFilter plugins 
     239        * ladspameta.c, normalise.c, reverse.c: fixed cancelation of plugins 
     240 
     241Sat Sep 21 21:39:22 EST 2002 Conrad Parker <conrad@metadecks.org> 
     242 
     243        * question_dialogs.c: new file -- dialogs for info and questions, 
     244          with sample locking 
     245        * file_*.c: fixed revert, moved back into non-experimental mainline 
     246        * file_*.c: added monitoring of mtime, and dialogs on save and edit 
     247          if file has changed on disk 
     248        * callbacks.c, view.c: added "are you sure" dialogs when closing or 
     249          quitting with modified files 
     250 
     251Wed Sep 18 22:20:01 EST 2002 Conrad Parker <conrad@metadecks.org> 
     252 
     253        * play.c: made scrubbing independent of nr. channels (scrub_rate) 
     254        * ladspameta.c: fixed segv in handling of mono files and filters 
     255        * callbacks.c: made scrubby stop if space is pressed (so you don't 
     256          lose your position by playback continuing when scrubby is released, 
     257          suggestion from swh) 
     258 
     259Tue Sep 17 21:57:52 EST 2002 Conrad Parker <conrad@metadecks.org> 
     260 
     261        * ladspameta.c: fixed channel de-interleaving/interleaving 
     262        * ladspameta.c: switched to SweepFilter, instantiated separate 
     263          LADSPA_Handle for each iteration & internalised processing loop 
     264        * ladspameta.c: fixed detection of upper and lower bounds 
     265        * param.c: changed step relative to upper and lower bounds 
     266        * ladspameta.c, reverse.c, normalise.c: fixed divide by 0 bug in 
     267          calculating percent for regions shorter than 100(ish) samples 
     268 
     269Wed Sep 11 00:20:36 EST 2002 Conrad Parker <conrad@metadecks.org> 
     270 
     271        * play.c: made scrubbing independent of sample rate (scrub_rate) 
     272        * play.c: fixed reverse scrubbing 
     273        * edit.c, record.c, sweep_filter.c: fixed divide by 0 bug in 
     274          calculating percent for regions shorter than 100 samples 
     275        * edit.c: fixed handling of crop for selections starting at 0 and/or 
     276          ending at nr_frames 
     277        * sweep_undo.c: fixed crash when playing during ALLOC operation 
     278          (eg. crop, paste, cut) -- forced stop of sample playback before op. 
     279 
     280Sun Sep  8 11:25:43 EST 2002 Conrad Parker <conrad@metadecks.org> 
     281 
     282        * configure: fixed unreported failure in libsndfile detection 
     283        * configure: added warning if libsndfile0 detected 
     284        * driver_oss.c: put DEBUG around naked g_print on GETOPTR failure 
     285        * sample-display.c: reverted Scrubby to always play_all, even 
     286          when started within a selection (restricted scrubbing was wierd). 
     287        * callbacks.c: removed old play_{all,sel}_{looped,once}_cb callbacks 
     288        * callbacks.c: changed play callbacks to not stop if the play head 
     289          is already going, ie. just changing the restriction 
     290 
     291Thu Sep  5 21:31:18 EST 2002 Conrad Parker <conrad@metadecks.org> 
     292 
     293        * modified selection modification to invoke scrubbing 
     294 
     295Wed Sep  4 15:05:04 EST 2002 Conrad Parker <conrad@metadecks.org> 
     296 
     297        * fixed bug in save as handling reported by Pauline Mak 
     298 
     299Tue Sep  3 20:19:49 EST 2002 Conrad Parker <conrad@metadecks.org> 
     300 
     301        * changed storing of last load and save directories to use 
     302          preferences functions for persistence 
     303        * added configure summary info for GTK+ and GLib 
     304        * commented out pixmaps inst hook in toplevel Makefile.am 
     305        * added non-failing check for gnome-moz-remote 
     306        * added check for strchr (for NetBSD, from Julio Merino Vidal) 
     307 
     308Mon Sep  2 21:35:57 EST 2002 Conrad Parker <conrad@metadecks.org> 
     309 
     310        * added missing third arg to some ioctls, required for NetBSD 
     311          port (patch from Julio Merino Vidal) 
     312        * fixed configure.in to fail when libtdb is not found 
     313        * added configuration summaries to configure 
     314        * changed --enable-devel to --enable-experimental 
     315 
     316Sun Aug 25 20:18:25 EST 2002 Conrad Parker <conrad@metadecks.org> 
     317 
     318        * added preferences loading/saving (preferences.[ch]) 
     319        * added dependency on libtdb 
     320 
     321Tue Aug 13 02:03:08 EST 2002 Conrad Parker <conrad@metadecks.org> 
     322 
     323        * version 0.5.0 
     324        * Everything has changed. Scrubby has you. 
     325 
    1326Sat May  5 20:51:26 -0500 2001 <ben@slumber.dhs.org> 
    2327 
  • trunk/sweep/Makefile.am

    r84 r124  
    88desktopdir = $(datadir)/gnome/apps/Multimedia 
    99 
    10 icon_DATA = sweep.png 
    11 icondir = $(datadir)/pixmaps 
     10pixmapdir = $(datadir)/pixmaps 
     11pixmap_DATA = sweep.png 
    1212 
    13 EXTRA_DIST = $(desktop_DATA) $(icon_DATA) $(pkgdata_DATA) \ 
    14              sweep.spec README.Solaris README.ALSA acconfig.h 
     13EXTRA_DIST = $(desktop_DATA) $(pkgdata_DATA)  $(pixmap_DATA) \ 
     14             sweep.spec README.Solaris README.ALSA README.i18n acconfig.h TODO 
    1515 
    1616MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config.h.in \ 
     
    2020                       ltmain.sh acinclude.m4 
    2121 
    22 install-data-local: 
    23       @$(NORMAL_INSTALL) 
    24       if test -d $(srcdir)/pixmaps; then \ 
    25         $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/pixmaps; \ 
    26         for pixmap in $(srcdir)/pixmaps/*; do \ 
    27           if test -f $$pixmap; then \ 
    28             $(INSTALL_DATA) $$pixmap $(DESTDIR)$(pkgdatadir)/pixmaps; \ 
    29           fi \ 
    30         done \ 
    31       fi 
     22#install-data-local: 
     23#     @$(NORMAL_INSTALL) 
     24#     if test -d $(srcdir)/pixmaps; then \ 
     25#       $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/pixmaps; \ 
     26#       for pixmap in $(srcdir)/pixmaps/*; do \ 
     27#         if test -f $$pixmap; then \ 
     28#           $(INSTALL_DATA) $$pixmap $(DESTDIR)$(pkgdatadir)/pixmaps; \ 
     29#         fi \ 
     30#       done \ 
     31#     fi 
    3232 
    3333dist-hook: 
  • trunk/sweep/NEWS

    r7 r124  
     1Wed Apr 30 2003 -- Version 0.8.2 
     2-------------------------------- 
     3 
     4This release contains support for ALSA 0.9; this is configurable and could 
     5do with widespread testing. 
     6                                                                                 
     7To build with ALSA support, simply configure with: 
     8                                                                                 
     9        ./configure --enable-alsa 
     10                                                                                 
     11Note that this will build a binary which will work with ALSA only, and 
     12not attempt to use OSS. In future this will be replaced with plugins 
     13for different pcm i/o methods, which should ease binary distribution. 
     14 
     15 
     16Internationalization (i18n) improvements: 
     17 
     18        * a complete audit of untranslateable strings, including 
     19        mis-configured source files and unmarked strings, by 
     20        Silvia Pfeiffer. 
     21 
     22        * a new Greek translation by Dokianakis Fanis 
     23        * a new Russian translation by Alexandre Prokoudine 
     24        * an updated Italian translation by Yuri Bongiorno 
     25        * an updated German translation by Silvia Pfeiffer 
     26 
     27There is a new mailing list: sweep-i18n. List information is at 
     28http://lists.sourceforge.net/lists/listinfo/sweep-i18n 
     29 
     30 
     31Additional changes include: 
     32 
     33        * added VBR without DTX option for Speex 1.0 speech encoding 
     34        * improved accuracy of sliders in processing dialogs 
     35 
     36 
     37Events: 
     38 
     39Conrad will presenting and demoing Sweep at the following upcoming events: 
     40 
     41  Jul 10-13       LinuxTag 2003 (Karlsruhe, Germany) 
     42                  Conference and Linux Audio Dev (LAD) exhibition booth 
     43                  http://www.linuxtag.org/ 
     44         
     45  Jul 31 - Aug 3  UKUUG Linux Developers Conference (Edinburgh, Scotland) 
     46                  http://www.ukuug.org/events/linux2003/ 
     47 
     48Plus, the Call for Participation for the Linux Audio Mini-Conf @ LCA2004 
     49(Jan 12-13 2004, Adelaide, South Australia) is announced: 
     50 
     51    http://www.metadecks.org/events/lca2004/ 
     52 
     53 
     54Thu Feb  6 2003 -- Version 0.8.1 
     55-------------------------------- 
     56 
     57This release contains performance improvements for basic editing operations, 
     58including reduced memory consumption during cut and paste insert. It also 
     59includes support for creation of new files on the command line, updated 
     60handling of raw file loading through libsndfile, and updated support for 
     61voice activity detection and intensity stereo coding features of the Speex 
     62speech codec. 
     63 
     64Sat Jan 18 2003 -- Version 0.8.0 
     65-------------------------------- 
     66 
     67This is the first milestone release for Sweep 1. Please test it thoroughly 
     68for both general sample editing and live performance! For more information, 
     69see http://www.metadecks.org/ . 
     70 
     71New in this release: 
     72 
     73        * a new monitoring subsystem for use in DJing and live performance. 
     74        Users with two sound cards can use headphones for monitoring, to 
     75        prepare mixes and cue samples without disrupting the main output. 
     76 
     77        * A usability bug was fixed in keyboard playback controls 
     78 
     79        * the Italian translation of the user interface was updated by 
     80        Yuri Bongiorno. 
     81 
     82 
     83New at metadecks.org: 
     84 
     85    Notes for the tutorial "Using Sweep: Fun with Scrubby" are now 
     86    available online in HTML, PostScript and PDF formats at: 
     87 
     88        http://www.metadecks.org/software/sweep/tutorials/ 
     89 
     90    This is a brief overview of the tutorial given at linux.conf.au 2003 
     91    in Perth, Australia; the real thing is live and very, very loud. 
     92 
     93 
     94Sat Jan 4 2003 -- Open Sound System's killer app of the month 
     95------------------------------------------------------------- 
     96 
     97Sweep has been selected as the killer app of the month for January 2003 by 
     98Open Sound System (OSS), developers of the most widely used digital audio 
     99architecture for UNIX.  
     100 
     101 
     102Fri Dec 20 2002 -- Version 0.5.13 
     103--------------------------------- 
     104 
     105This release contains build fixes for NetBSD and cleanups by Erik de 
     106Castro Lopo to fix preprocessor pasting warnings. 
     107 
     108It also features new fade in and fade out filters. 
     109 
     110Conrad will be presenting two sessions at linux.conf.au, January 22-25 2003 
     111in Perth, Australia; a tutorial titled "Using Sweep: Fun with Scrubby", and 
     112an overview of Sweep's internals and plugin development. 
     113 
     114 
     115Fri Dec  6 2002 -- Version 0.5.12 
     116--------------------------------- 
     117 
     118New in this release: 
     119 
     120        * an updated Italian translation from Yuri Bongiorno 
     121 
     122        * resample (sample rate conversion): change the sample rate of a 
     123        file, for example from CD format to DAT format, or to any arbitrary 
     124        sample rate. This requires Erik de Castro Lopo's newly released 
     125        libsamplerate, available from http://www.mega-nerd.com/SRC/ 
     126 
     127        * preview cut: hear how the area around the selection will sound 
     128        after the selection is cut out, including the parts between 
     129        selection regions for multi-region selections. 
     130 
     131        * preroll to cursor: play one second of sound leading up to the 
     132        cursor; useful for hearing the cursor position without moving it. 
     133 
     134Bugs were fixed in MP3 loading and pitched playback (using QWERTY keys). 
     135 
     136 
     137Thu Nov 28 2002 -- Version 0.5.11 
     138--------------------------------- 
     139 
     140New features in this release include: 
     141 
     142        * mixing and crossfading paste methods: copy a region from one file 
     143        and mix or fade it into another file or elsewhere in the same file, 
     144        with control of source and destination levels and phase. 
     145 
     146        * navigation shortcuts to move between selection edges: move the 
     147        cursor between the start and end of selection regions, and to the 
     148        next edge of a multi-region selection, with Ctrl + Arrow Left/Right 
     149 
     150        * view memories: assign the viewable area to a number on the numeric 
     151        keypad with Ctrl+<Num>, and zoom back to it later by pressing that 
     152        number. (NB. Num Lock must be on on your keyboard). 
     153 
     154        * support for Speex 1.0beta3 ultra-wideband mode (32kHz). Speex is 
     155        a high quality, patent-free and open source voice codec. 
     156 
     157        * support for full-file application of Secret Rabbit Code 
     158 
     159Additionally, minor bugs were fixed affecting portability of system error 
     160handling and detection of MP3 files. 
     161 
     162 
     163Thu Oct 31 2002 -- Version 0.5.10a 
     164---------------------------------- 
     165 
     166This is an update to 0.5.10 which fixes a compilation error in the default 
     167build. 
     168 
     169Wed Oct 30 2002 -- Version 0.5.10 
     170--------------------------------- 
     171 
     172New features in this release include vertical zoom with a draggable dB scale 
     173and mouse wheel control, and some basic channel operations: Duplicate to 
     174stereo/multichannel, Swap left and right, Remove left/right, Mix down to 
     175mono, and Add/Remove channels. 
     176 
     177This release also includes compile fixes for Solaris, and a bug fix for 
     178first-time file 'save'. 
     179 
     180A new section for screenshots contributed by users was recently added to the 
     181screenshot tour: 
     182 
     183    http://www.metadecks.org/software/sweep/screenshots/ 
     184 
     185 
     186Wed Oct 23 2002 -- Version 0.5.9 
     187-------------------------------- 
     188 
     189Sweep now supports Speex, a special purpose speech codec designed for 
     190efficient Voice over IP (VoIP) and file-based compression. Speex is free, 
     191open and unpatented; more information is available at http://www.speex.org/. 
     192 
     193This release also includes improved handling of the main volume and pitch 
     194sliders, contributed by Zenaan Harkness. 
     195 
     196 
     197Thu Oct 17 2002 -- Version 0.5.8 
     198-------------------------------- 
     199 
     200MP3 import is now supported. Minor bugs have been fixed in rendering of 
     201record position and playback mixing. 
     202 
     203There is a new page of audio demos made with Sweep. These demonstrate the 
     204sounds of Scrubby, a tool which allows vinyl-like manipulation of digital 
     205audio: 
     206 
     207    http://www.metadecks.org/software/sweep/demos.html 
     208 
     209 
     210Fri Oct 11 2002 -- Version 0.5.7 
     211-------------------------------- 
     212 
     213This version includes support for Ogg Vorbis import and export, including 
     214both variable and average bitrate encoding modes. There are many other 
     215user interface updates, including new input controls for sample rates and 
     216channels, and question, information and system error dialogs. 
     217 
     218There is a new Screenshot tour of Sweep, including many screenshots of 
     219the new dialogs and general editing: 
     220 
     221    http://www.metadecks.org/software/sweep/screenshots/ 
     222 
     223 
     224Wed Sep 25 2002 -- Version 0.5.6 and Sweep Demo at SLUG 
     225------------------------------------------------------- 
     226 
     227Changes in this version include monitoring of file modification, "are you 
     228sure" dialogs, file revert, and many minor bug fixes. 
     229 
     230There will be a demo of the latest Sweep features, including live DJing and 
     231experimental music techniques and the Sydney LUG meeting on Sep. 27 2002; 
     232see http://www.slug.org.au/ for details.  
     233 
     234Fri Sep 20 2002 -- Version 0.5.5 
     235-------------------------------- 
     236 
     237Changes since version 0.5.4 include major bugfixes for LADSPA plugin 
     238handling and improvements in scrubbing usability. 
     239 
     240Wed Sep 11 2002 -- Version 0.5.4 
     241-------------------------------- 
     242 
     243Changes since version 0.5.3 (September 5 2002) include bug fixes for 
     244playback during destructive operations and for edits of tiny regions, 
     245and improvements in configuration checks for libsndfile-1.0.0. 
     246 
     247Additionally, scrubbing is now working for reverse playback, and has been 
     248tuned for responsiveness independent of sample rate. 
     249 
     250There is now a web page introducing Scrubby and outlining a few simple  
     251editing and live performance techniques: 
     252 
     253    http://www.metadecks.org/software/sweep/scrub.html 
     254 
     255 
     256Thu Sep  5 2002 -- Version 0.5.3 
     257-------------------------------- 
     258 
     259This release incorporates robust configuration checking to help new users   
     260compile from source. After a long period of quiet development we are now 
     261beginning to roll this out for general public usage, and your testing and 
     262feedback is very welcome! 
     263 
     264Changes since 0.1.1 (October 2000) include interactive scrubbing, recording, 
     265support for LADSPA 1.1 effects plugins and multichannel sound files, 
     266multithreaded background rendering, unlimited undo/redo, mouse wheel zooming, 
     267reverse playback and overall stability and usability improvements. 
     268 
     269Changes since version 0.5.0 (August 12 2002) include preferences saving and 
     270support for libsndfile 1.0.0. 
     271 
     272Changes since version 0.5.1 (August 29 2002) include improved configure 
     273checks and porting fixes. Additionally, Sweep now remembers the last used 
     274file load and save directories between sessions. 
     275 
     276Changes since version 0.5.2 (September 4 2002) include the fixing of a bug 
     277in "save as", and (NEW) audible scrubbing when selecting regions. 
    1278 
    2279Mon, 1 May 2000 
  • trunk/sweep/README

    r7 r124  
    11 
    2 Sweep, a sound wave editor. 
     2SWEEP, a sound wave editor, brought to you by Conrad Parker 
     3----------------------------------------------------------- 
    34 
    4 Copyright (C) 2000 Conrad Parker 
     5Sweep is an audio editor and live playback tool for GNU/Linux, BSD and 
     6compatible systems. It supports many music and voice formats including 
     7WAV, AIFF, Ogg Vorbis, Speex and MP3, with multichannel editing and 
     8LADSPA effects plugins. Inside lives a pesky little virtual stylus called 
     9Scrubby who enjoys mixing around in your files. 
     10 
     11Sweep is designed to be intuitive and to give you full control. It includes 
     12almost everything you would expect in a sound editor, and then some: 
     13 
     14        * precise, vinyl like scrubbing 
     15        * looped, reverse, and pitch-controlled playback 
     16        * playback mixing of unlimited independent tracks 
     17        * monitoring support for use with multiple audio devices 
     18        * looped and reverse recording 
     19        * internationalisation 
     20        * multichannel and 32 bit floating point file support 
     21        * Ogg Vorbis, MP3 and Speex compressed formats 
     22        * sample rate conversion and channel operations 
     23        * LADSPA 1.1 effects support 
     24        * multiple views, discontinuous selections 
     25        * easy keybindings, mouse wheel zooming 
     26        * unlimited undo/redo with fully revertible edit history 
     27        * multithreaded background processing 
     28        * shaded peak/mean waveform rendering, multiple colour schemes 
    529 
    630 
    7 Sweep is an editor for sound samples. It operates on files of various 
    8 formats such as .wav, .aiff and .au, and has multiple undo/redo levels 
    9 and filters. It is Free Software, available under the GNU General 
    10 Public Licence.  
     31Summary of library dependencies: 
     32-------------------------------- 
     33 
     34REQUIRED: 
     35 
     36        * GTK+ 1.2, standard in most distributions and available from: 
     37 
     38            http://www.gtk.org/ 
     39 
     40        * libsndfile-1.0.x, available from: 
     41 
     42            http://www.zip.com.au/~erikd/libsndfile/ 
     43 
     44        * libtdb, available in many distributions or at: 
     45 
     46            http://www.sourceforge.net/projects/tdb 
     47 
     48        * Secret Rabbit Code, aka. libsamplerate, available from: 
     49 
     50            http://www.mega-nerd.com/SRC/ 
     51         
     52OPTIONAL: 
     53 
     54        * Ogg Vorbis libraries (high quality perceptual audio format): 
     55 
     56            http://www.vorbis.com/ 
     57 
     58        * libmad (MPEG audio loading), available from: 
     59 
     60            http://www.mars.org/home/rob/proj/mpeg/ 
     61         
     62        * Speex library (an open speech compression format): 
     63 
     64            http://www.speex.org/ 
     65 
     66See the file INSTALL for building instructions. Generally all that is 
     67required, after the above libraries have been installed, is: 
     68 
     69        ./configure 
     70        make 
     71        make install 
     72 
     73If you are not sure what you need, simply run ./configure and it will probe 
     74your system and provide a reasonably useful summary. 
     75 
     76For information on enabling and disabling optional components, run 
     77./configure --help 
    1178 
    1279Homepage 
     
    2087------------- 
    2188 
    22 There are two mailing lists related to sweep: 
     89There are three mailing lists related to sweep: 
    2390 
    24 sweep-announce.  
     91sweep-announce 
    2592        which contains only announcements about new releases of sweep. 
    2693This is a moderated list.  
    2794 
    28 sweep-devel.  
    29         For general discussion about sweep and development related issues.  
     95sweep-users 
     96        For general discussion about using sweep 
    3097 
    31 Archives of both lists are available on the World Wide Web via the 
     98sweep-devel 
     99        For discussion about sweep development related issues.  
     100 
     101Archives of each list are available on the World Wide Web via the 
    32102Sweep homepage. You can also subscribe or unsubscribe via a web 
    33103interface. 
     
    38108 
    39109        sweep-announce-request@lists.sourceforge.net 
     110  or 
     111        sweep-users-request@lists.sourceforge.net 
    40112  or 
    41113        sweep-devel-request@lists.sourceforge.net 
     
    62134USA. 
    63135 
     136Acknowledgements 
     137---------------- 
     138 
     139Thanks to Pixar Animation Studios and CSIRO Australia for supporting 
     140the development of this project. 
     141 
    64142Contact 
    65143------- 
    66144 
    67 If you have any further queries about Sweep, please contact the 
     145If you have any further queries about Sweep, please contact the main 
    68146author: 
    69147 
  • trunk/sweep/README.ALSA

    r54 r124  
     1Wed Apr 30 2003 
     2--------------- 
     3 
     4Support for ALSA 0.9 is functional and could do with widespread testing. 
     5 
     6To build with alsa support, simply configure with: 
     7 
     8        ./configure --enable-alsa 
     9 
     10Note that this will build a binary which will work with ALSA only, and 
     11not attempt to use OSS. In future this will be replaced with plugins 
     12for different pcm i/o methods, which should ease binary distribution. 
     13 
     14Wed Sep 11 2002 
     15--------------- 
     16 
     17ALSA native support it currently not working; to even attempt to build the 
     18code, you must configure with: 
     19 
     20        ./configure --enable-experimental --enable-alsa 
     21 
     22However, Sweep works fine with ALSA under OSS emulation. 
     23 
    124Sat Oct  7 2000 
     25--------------- 
    226 
    327Support for ALSA (Advanced Linux Sound Architecture) version 0.6.0 was 
  • trunk/sweep/README.Solaris

    r7 r124  
     1Wed Oct 30 2002 
     2--------------- 
     3 
     4Some compile fixes were applied as listed in Sourceforge bug #625528. 
     5Please contact sweep-devel@lists.sf.net if you have any problems building 
     6or running Sweep on Solaris. 
     7 
    18Fri May 12 2000 
     9--------------- 
    210 
    311Solaris audio support was added in sweep version 0.0.9 by Mattias 
     
    1927        displeased with the behaviour, I could outline a way to 
    2028        solve it. 
    21  
  • trunk/sweep/acconfig.h

    r53 r124  
    11#undef ENABLE_NLS 
    22#undef HAVE_CATGETS 
    3 #undef HAVE_LIBAUDIOFILE 
    43#undef HAVE_GETTEXT 
    54#undef HAVE_LC_MESSAGES 
     
    1110#undef PACKAGE_SOURCE_DIR 
    1211 
     12#undef HAVE_MADVISE 
     13 
     14#undef DEVEL_CODE 
     15 
     16#undef HAVE_LIBSNDFILE1 
     17#undef HAVE_OGGVORBIS 
     18#undef OV_READ_FLOAT_THREE_ARGS 
     19#undef HAVE_SPEEX 
     20#undef HAVE_MAD 
     21 
     22#undef HAVE_LIBSAMPLERATE 
     23 
    1324#undef DRIVER_OSS 
    1425#undef DRIVER_ALSA 
  • trunk/sweep/autogen.sh

    r61 r124  
    11#!/bin/sh 
    22 
    3 libtoolize --force && aclocal $ACLOCAL_FLAGS && autoheader && automake --add-missing && autoconf 
     3# autogoat! 
     4# an omnivorous assistant for autotools 
     5
     6#         (__)  
     7#         (oo)  
     8#   /------\/  
     9#  / |    ||    
     10# *  /\---/\  
     11#    ~~   ~~    
     12 
     13# clean function 
     14clean () 
     15
     16  # remove autotools cruft 
     17  rm -f aclocal.m4 configure config.log 
     18  rm -Rf autom4te.cache 
     19  # remove old autotools extra cruft 
     20  rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh 
     21  # remove libtool cruft 
     22  rm -f ltmain.sh libtool ltconfig 
     23
     24 
     25 
     26
     27# option checking 
     28
     29 
     30if test "x$1" = "xclean"; then 
     31  set -x 
     32  clean 
     33  set +x 
     34  exit 0 
     35fi 
     36 
     37 
     38 
     39
     40# check automake version number -- we require >= 1.5 
     41
     42 
     43automake_version="none" 
     44if automake-1.7 --version >/dev/null 2>&1; then 
     45  automake_version="-1.7" 
     46elif automake-1.6 --version >/dev/null 2>&1; then 
     47  automake_version="-1.6" 
     48elif automake-1.5 --version >/dev/null 2>&1; then 
     49  automake_version="-1.5" 
     50elif automake --version > /dev/null 2>&1; then 
     51  automake_version="" 
     52  case "`automake --version | sed -e '1s/[^0-9]*//' -e q`" in 
     53    0|0.*|1|1.[01234]|1.[01234][-.]*) automake_version="none" ;; 
     54    1.5*)                             automake_version="-1.5" ;; 
     55    1.6*)                             automake_version="-1.6" ;; 
     56    1.7*)                             automake_version="-1.7" ;; 
     57    1.8*)                             automake_version="-1.8" ;; 
     58    1.9*)                             automake_version="-1.9" ;; 
     59  esac 
     60fi 
     61 
     62if test "x${automake_version}" = "xnone"; then 
     63  set +x 
     64  echo "you need automake version 1.5 or later" 
     65  exit 1 
     66fi 
     67 
     68automake_version_major=`echo "$automake_version" | cut -d. -f2` 
     69automake_version_minor=`echo "$automake_version" | cut -d. -f3` 
     70 
     71# need at least automake >= 1.5 
     72if test "$automake_version_major" -lt "5"; then 
     73  echo "$0"': this project requires automake >= 1.5.  Please upgrade your version of automake to at least 1.5' 
     74  exit 1 
     75fi 
     76 
     77 
     78
     79# do we need pkg-config? 
     80
     81 
     82if grep -q PKG_CHECK_MODULES configure.*; then 
     83  if ! pkg-config --version > /dev/null 2> /dev/null; then 
     84    cat << EOF 
     85pkg-config is required, but it's not installed or can't be found in your 
     86search path. 
     87 
     88EOF 
     89    # be nice to the user if they have fink! 
     90    if test -d /sw ; then 
     91      cat << EOF 
     92You can install it via Fink with the command: 
     93 
     94 apt-get install pkgconfig 
     95 
     96EOF 
     97    fi 
     98    exit 1 
     99  fi 
     100fi 
     101 
     102 
     103
     104# autogoat bootstrap process 
     105#  
     106 
     107ACLOCAL=${ACLOCAL:-aclocal} 
     108AUTOCONF=${AUTOCONF:-autoconf} 
     109AUTOHEADER=${AUTOHEADER:-autoheader} 
     110AUTOMAKE=${AUTOMAKE:-automake} 
     111 
     112# clean out old cruft 
     113clean 
     114 
     115# add Fink's /sw path to various search directories 
     116if [ -d /sw ]; then 
     117  ACLOCAL="$ACLOCAL -I /sw/share/aclocal" 
     118  FINK_DETECTED=1 
     119fi 
     120 
     121eval "$ACLOCAL" 
     122 
     123# do we need libtool? 
     124if grep -q PROG_LIBTOOL configure.*; then 
     125  # what's libtoolize called? 
     126  if glibtoolize --version > /dev/null 2> /dev/null; then 
     127    LIBTOOLIZE="glibtoolize" 
     128  elif libtoolize --version > /dev/null 2> /dev/null; then 
     129    LIBTOOLIZE="libtoolize" 
     130  fi 
     131 
     132  # check libtool version -- only support 1.4 or 1.5 for now 
     133  if "$LIBTOOLIZE" --version | egrep -q '1\.4|1\.5'; then 
     134    if grep -q AC_LIBLTDL_CONVENIENCE configure.*; then 
     135      "$LIBTOOLIZE" --ltdl --copy --force 
     136    else 
     137      "$LIBTOOLIZE" --copy --force 
     138    fi 
     139  else 
     140    # libtool version is too old :( 
     141    echo "$0: need libtool >= 1.4 installed" 
     142    exit 1 
     143  fi 
     144fi 
     145 
     146eval "$AUTOCONF" 
     147grep -q CONFIG_HEADER configure.* && "$AUTOHEADER" 
     148eval "$AUTOMAKE" --add-missing --copy 
     149 
     150# Print warning message if Fink detected 
     151if test "$FINK_DETECTED" = 1; then 
     152  cat << EOF 
     153 
     154Fink detected; added /sw/share/aclocal to aclocal's include directories. 
     155Make sure you have CPPFLAGS, LDFLAGS and PKG_CONFIG_PATH including Fink's 
     156distribution directories, e.g.: 
     157 
     158 export CPPFLAGS="-I/sw/include \$CPPFLAGS" 
     159 export LDFLAGS="-L/sw/lib \$LDFLAGS" 
     160 export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/sw/lib/pkgconfig:\$PKG_CONFIG_PATH" 
     161 
     162 ./configure 
     163 
     164EOF 
     165fi 
     166 
  • trunk/sweep/configure.in

    r119 r124  
    22 
    33AC_INIT(configure.in) 
    4 AM_INIT_AUTOMAKE(sweep, 0.1.1
    5 AM_CONFIG_HEADER(include/sweep/config.h) 
     4AM_INIT_AUTOMAKE(sweep, 0.8.2
     5AM_CONFIG_HEADER(config.h) 
    66 
    77AC_ISC_POSIX 
     
    1111AM_PROG_LIBTOOL 
    1212 
     13AC_CHECK_PROG(HAVE_GNOME_MOZ_REMOTE, 'gnome-moz-remote', yes, no) 
     14 
     15AC_C_BIGENDIAN 
     16 
     17AC_CHECK_FUNCS(strchr) 
     18AC_CHECK_FUNCS(madvise) 
     19 
     20ALL_LINGUAS="de el fr hu it pl ru en_AU" 
     21AM_GNU_GETTEXT 
     22 
     23dnl Overall configuration success flag 
     24sweep_config_ok=yes 
     25 
     26dnl Default audio handling to build in 
     27sweep_config_driver=none 
     28 
     29dnl 
     30dnl  Configuration option for building of experimental code. 
     31dnl 
     32 
     33ac_enable_experimental=no 
     34AC_ARG_ENABLE(experimental, 
     35     [  --enable-experimental   enable building of experimental code ], 
     36     [ ac_enable_experimental=yes ]) 
     37 
     38if test "x${ac_enable_experimental}" = xyes ; then 
     39    AC_DEFINE(DEVEL_CODE) 
     40fi 
     41 
     42 
     43dnl 
     44dnl  Detect pthreads libraries 
     45dnl 
     46 
    1347PTHREAD_LIBS=error 
    14 AC_CHECK_LIB(pthread, pthread_attr_init, 
    15              PTHREAD_LIBS="-lpthread") 
     48AC_CHECK_LIB(pthread, pthread_attr_init, PTHREAD_LIBS="-lpthread") 
    1649if test "x$PTHREAD_LIBS" = xerror; then 
    17         AC_CHECK_LIB(pthreads, pthread_attr_init, 
    18                 PTHREAD_LIBS="-lpthreads") 
     50        AC_CHECK_LIB(pthreads, pthread_attr_init, PTHREAD_LIBS="-lpthreads") 
    1951fi 
    2052if test "x$PTHREAD_LIBS" = xerror; then 
    21         AC_CHECK_LIB(c_r, pthread_attr_init, 
    22                 PTHREAD_LIBS="-lc_r") 
     53        AC_CHECK_LIB(c_r, pthread_attr_init, PTHREAD_LIBS="-lc_r") 
    2354fi 
    2455if test "x$PTHREAD_LIBS" = xerror; then 
     
    2758AC_SUBST(PTHREAD_LIBS) 
    2859 
    29 dnl Test for GTK 
    30 AM_PATH_GTK(1.2.0, , 
    31             AC_MSG_ERROR(Cannot find GTK: Is gtk-config in path?), 
    32             "gthread") 
    33  
    34 dnl stupid hack to get the gthread stuff into the command lines 
    35 LIBS="$LIBS $GTK_LIBS" 
    36 CFLAGS="$CFLAGS $GTK_CFLAGS" 
    37  
    38 dnl Test for Audiofile library 
    39 AM_PATH_AUDIOFILE(0.1.5, 
    40                   [CFLAGS="$CFLAGS $AUDIOFILE_CFLAGS" 
    41                    LIBS="$LIBS $AUDIOFILE_LIBS" 
    42                    AC_DEFINE(HAVE_LIBAUDIOFILE)]) 
    43  
    44 dnl Test for ALSA - not enabled just because we found it, 
    45 dnl                 but requires explicit enabling 
     60 
     61dnl 
     62dnl  Detect GLib, GTK+ libraries 
     63dnl 
     64 
     65HAVE_GLIB=no 
     66AM_PATH_GLIB(1.2.0, HAVE_GLIB="yes", sweep_config_ok="no") 
     67if test "x$HAVE_GLIB" = xno ; then 
     68  AC_CHECK_LIB(glib, g_list_append, HAVE_GLIB="maybe") 
     69fi 
     70 
     71HAVE_GTK=no 
     72AM_PATH_GTK(1.2.0, HAVE_GTK="yes", sweep_config_ok="no", gthread) 
     73if test "x$HAVE_GTK" = xyes ; then 
     74  CFLAGS="$CFLAGS $GTK_CFLAGS" 
     75else 
     76  AC_CHECK_LIB(gtk, gtk_init, HAVE_GTK="maybe") 
     77fi 
     78 
     79 
     80dnl 
     81dnl  Detect tdb library 
     82dnl 
     83 
     84HAVE_TDB=no 
     85AC_CHECK_LIB(tdb, tdb_open, HAVE_TDB="yes", sweep_config_ok="no") 
     86if test "x$HAVE_TDB" = xyes ; then 
     87  AC_CHECK_HEADERS(tdb.h, , [HAVE_TDB="maybe" sweep_config_ok="no"]) 
     88  TDB_LIBS="-ltdb" 
     89  AC_SUBST(TDB_LIBS) 
     90fi 
     91 
     92 
     93dnl 
     94dnl  Detect libsndfile 1.0 
     95dnl 
     96 
     97LIBSNDFILE_VERSION="???" 
     98 
     99# !!! libsndfile0 backport 
     100 
     101ac_enable_libsndfile0=no 
     102AC_ARG_ENABLE(libsndfile0, 
     103     [  --enable-libsndfile0    enable building against libsndfile version 0], 
     104     [ ac_enable_libsndfile0=yes ]) 
     105 
     106if test "x${ac_enable_libsndfile0}" != xno ; then 
     107 
     108  HAVE_LIBSNDFILE1="ignore" 
     109 
     110  AC_CHECK_LIB(sndfile, sf_open_read, HAVE_LIBSNDFILE0="yes") 
     111  AC_CHECK_LIB(sndfile, sf_command, HAVE_LIBSNDFILE0="yes") 
     112 
     113  if test "x$HAVE_LIBSNDFILE0" = xyes ; then 
     114    SNDFILE_LIBS="-lsndfile" 
     115    AC_SUBST(SNDFILE_LIBS) 
     116    LIBSNDFILE_VERSION="0" 
     117  else 
     118    AC_MSG_ERROR([ 
     119*** 
     120*** You have explicitly enabled to build against libsndfile version 0, 
     121*** but there is no compatible version of libsndfile version 0 installed. 
     122*** 
     123*** To continue this build, you must first install libsndfile version 
     124*** 0.27.0 or 0.28.0. 
     125*** 
     126*** Note that unless you are building against an older system distribution, 
     127*** it is highly recommended that you install and build against 
     128*** libsndfile version 1. 
     129*** 
     130]) 
     131  fi 
     132 
     133else # !!! 
     134 
     135PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.0, 
     136                  HAVE_LIBSNDFILE1="yes", HAVE_LIBSNDFILE1="no") 
     137 
     138if test "x$HAVE_LIBSNDFILE1" = xyes ; then 
     139  AC_DEFINE(HAVE_LIBSNDFILE1) 
     140  AC_SUBST(SNDFILE_LIBS) 
     141  LIBSNDFILE_VERSION="1" 
     142else 
     143  sweep_config_ok="no" 
     144  AC_CHECK_LIB(sndfile, sf_open, HAVE_LIBSNDFILE1="maybe") 
     145  AC_CHECK_LIB(sndfile, sf_open_read, HAVE_LIBSNDFILE0="yes") 
     146fi 
     147 
     148if test "x$HAVE_LIBSNDFILE1" = xmaybe ; then 
     149  AC_CHECK_HEADERS(sndfile.h, HAVE_LIBSNDFILE1="ouch") 
     150  if test "x$HAVE_LIBSNDFILE1" = xouch ; then 
     151    AC_MSG_ERROR([ 
     152*** 
     153*** libsndfile-1.0.0 or greater seems to exist on your system, however 
     154*** the pkg-config tool cannot find its build information. 
     155*** 
     156*** Please set your PKG_CONFIG_PATH environment variable to include the 
     157*** directory in which sndfile.pc was installed. For example, sndfile.pc 
     158*** is installed in /usr/local/lib/pkgconfig by default; if that is the 
     159*** case do: 
     160*** 
     161***     export PKG_CONFIG_PATH="\$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig" 
     162*** 
     163*** then run this ./configure again. If you configured libsndfile with a 
     164*** different --prefix option, replace /usr/local above with that prefix. 
     165*** 
     166]) 
     167  fi 
     168fi 
     169 
     170fi # !!! libsndfile0 backport 
     171 
     172AC_CHECK_SIZEOF(off_t,1) 
     173 
     174 
     175dnl 
     176dnl Detect Ogg 
     177dnl 
     178 
     179HAVE_OGG=no 
     180HAVE_VORBIS=no 
     181HAVE_SPEEX=no 
     182 
     183ac_enable_oggvorbis=yes 
     184AC_ARG_ENABLE(oggvorbis, 
     185     [  --disable-oggvorbis     disable Ogg Vorbis support], 
     186     [ ac_enable_oggvorbis=no ], [ ac_enable_oggvorbis=yes ]) 
     187 
     188ac_enable_speex=yes 
     189AC_ARG_ENABLE(speex, 
     190     [  --disable-speex         disable Speex support], 
     191     [ ac_enable_speex=no ], [ ac_enable_speex=yes ]) 
     192 
     193dnl Both Vorbis and Speex require Ogg, so check for it first either way 
     194if test "x${ac_enable_oggvorbis}" != xno || 
     195   test "x${ac_enable_speex}" != xno ; then 
     196 
     197  XIPH_PATH_OGG(HAVE_OGG="yes", HAVE_OGG="no") 
     198  if test "x$HAVE_OGG" = xno ; then 
     199    AC_CHECK_LIB(ogg, ogg_stream_init, HAVE_OGG="maybe") 
     200  fi 
     201 
     202  AC_SUBST(OGG_LIBS) 
     203fi 
     204 
     205dnl 
     206dnl Detect Vorbis 
     207dnl 
     208dnl LIBS="$LIBS -lm -logg -lvorbis -lvorbisenc -lvorbisfile" 
     209 
     210if test "x$HAVE_OGG" = xyes && test "x${ac_enable_oggvorbis}" != xno ; then 
     211 
     212  XIPH_PATH_VORBIS(HAVE_VORBIS="yes", HAVE_VORBIS="no") 
     213 
     214  dnl This fails for me, so lets try some explicit checks 
     215  if test "x$HAVE_VORBIS" = xno ; then 
     216    AC_MSG_RESULT([ 
     217*** Trying explicit detection of Ogg Vorbis libraries and headers ...]) 
     218    AC_CHECK_LIB(vorbis, vorbis_info_init, HAVE_VORBIS="maybe", , 
     219                 [-lm -logg]) 
     220    AC_CHECK_LIB(vorbisenc, vorbis_encode_init, HAVE_VORBISENC="maybe", , 
     221                 [-lm -logg -lvorbis]) 
     222    AC_CHECK_LIB(vorbisfile, ov_open, HAVE_VORBISFILE="maybe", , 
     223                 [-lm -logg -lvorbis]) 
     224    AC_CHECK_HEADERS([vorbis/codec.h vorbis/vorbisfile.h vorbis/vorbisenc.h], 
     225                     HAVE_VORBIS_HEADERS="yes", HAVE_VORBIS_HEADERS="no") 
     226 
     227    if test "x$HAVE_VORBIS" = xmaybe && test "x$HAVE_VORBISENC" = xmaybe && 
     228       test "x$HAVE_VORBISFILE" = xmaybe && 
     229       test "x$HAVE_VORBIS_HEADERS" = xyes ; then 
     230 
     231       VORBIS_LIBS="-lvorbis -lm" 
     232       VORBISFILE_LIBS="-lvorbisfile" 
     233       VORBISENC_LIBS="-lvorbisenc" 
     234       VORBIS_CFLAGS="" 
     235 
     236       dnl HAVE_VORBIS="maybe" 
     237       HAVE_VORBIS="yes" 
     238    else 
     239       HAVE_VORBIS="no" 
     240    fi 
     241  fi 
     242 
     243  AC_SUBST(VORBIS_LIBS) 
     244  AC_SUBST(VORBISENC_LIBS) 
     245  AC_SUBST(VORBISFILE_LIBS) 
     246 
     247  if test "x$HAVE_VORBIS" = xyes ; then 
     248    AC_DEFINE(HAVE_OGGVORBIS) 
     249 
     250    dnl Test out ov_read_float 
     251    AC_MSG_CHECKING([for deprecated ov_read_float() interface]) 
     252 
     253    ac_save_CFLAGS="$CFLAGS" 
     254    ac_save_LIBS="$LIBS" 
     255    CFLAGS="$CFLAGS $OGG_CFLAGS $VORBIS_CFLAGS" 
     256    LIBS="$LIBS $OGG_LIBS $VORBIS_LIBS $VORBISFILE_LIBS" 
     257 
     258    AC_TRY_COMPILE([#include <vorbis/codec.h> 
     259                    #include <vorbis/vorbisfile.h> ], 
     260                   [OggVorbis_File * vf; float ** pcm; int b; 
     261                    ov_read_float (vf, &pcm, &b);], 
     262                   [ AC_DEFINE(OV_READ_FLOAT_THREE_ARGS) 
     263                     AC_MSG_RESULT(yes) ], 
     264                   [ AC_MSG_RESULT(no) ]) 
     265 
     266    CFLAGS="$ac_save_CFLAGS" 
     267    LIBS="$ac_save_LIBS" 
     268 
     269  else 
     270    sweep_config_ok="no" 
     271  fi 
     272 
     273else 
     274  HAVE_VORBIS=disabled 
     275fi 
     276 
     277dnl 
     278dnl Detect speex 
     279dnl 
     280dnl LIBS="$LIBS -lm -logg -lspeex" 
     281 
     282if test "x$HAVE_OGG" = xyes && test "x${ac_enable_speex}" != xno ; then 
     283 
     284  AC_CHECK_LIB(speex, speex_encoder_init, HAVE_SPEEX="maybe", , [-lm -logg]) 
     285  if test "x$HAVE_SPEEX" = xmaybe; then 
     286    AC_CHECK_HEADER(speex.h, HAVE_SPEEX="yes", HAVE_SPEEX="no") 
     287  fi 
     288  if test "x$HAVE_SPEEX" = xyes ; then 
     289    AC_DEFINE(HAVE_SPEEX) 
     290    SPEEX_LIBS="-lspeex -lm" 
     291    AC_SUBST(SPEEX_LIBS) 
     292  fi 
     293 
     294else 
     295  HAVE_SPEEX=disabled 
     296fi 
     297 
     298 
     299dnl 
     300dnl Detect libmad 
     301dnl 
     302 
     303HAVE_MAD=no 
     304 
     305ac_enable_mad=yes 
     306AC_ARG_ENABLE(mad, 
     307     [  --disable-mad           disable libmad (MPEG audio loading) support], 
     308     [ ac_enable_mad=no ], [ ac_enable_mad=yes ]) 
     309 
     310if test "x${ac_enable_mad}" != xno ; then 
     311  AC_CHECK_LIB(mad, mad_decoder_init, HAVE_MAD="maybe") 
     312 
     313  if test "x$HAVE_MAD" = xmaybe ; then 
     314    AC_CHECK_HEADER(mad.h, HAVE_MAD="yes", HAVE_MAD="no") 
     315  fi 
     316  if test "x$HAVE_MAD" = xyes ; then 
     317    AC_DEFINE(HAVE_MAD) 
     318    MAD_LIBS="-lmad" 
     319    AC_SUBST(MAD_LIBS) 
     320  fi 
     321 
     322else 
     323  HAVE_MAD=disabled 
     324fi 
     325 
     326dnl 
     327dnl Detect secret rabbit code 
     328dnl 
     329 
     330HAVE_LIBSAMPLERATE=no 
     331 
     332ac_enable_src=yes 
     333AC_ARG_ENABLE(src, 
     334     [  --disable-src            enable secret rabbit code (libsamplerate)], 
     335     [ ac_enable_src=no ], [ ac_enable_src=yes]) 
     336 
     337if test "x${ac_enable_src}" != xno ; then 
     338  PKG_CHECK_MODULES(SAMPLERATE, samplerate >= 0.0.9, 
     339                    HAVE_LIBSAMPLERATE="yes", HAVE_LIBSAMPLERATE="no") 
     340 
     341  if test "x$HAVE_LIBSAMPLERATE" = xyes ; then 
     342    AC_DEFINE(HAVE_LIBSAMPLERATE) 
     343    AC_SUBST(SAMPLERATE_LIBS) 
     344  fi 
     345else 
     346  HAVE_LIBSAMPLERATE=disabled 
     347fi 
     348 
     349 
     350dnl 
     351dnl Test for ALSA -- requires explicit enabling 
     352dnl 
     353 
    46354 
    47355ac_enable_alsa=no 
    48356AC_ARG_ENABLE(alsa, 
    49      [ --enable-alsa   enable use of ALSA, and disable use of OSS ], 
     357     [ --enable-alsa           enable use of ALSA, and disable use of OSS ], 
    50358     [ ac_enable_alsa=yes ]) 
    51359 
    52 AC_CHECK_HEADERS(sys/asoundlib.h) 
    53 if test "${ac_cv_header_sys_asoundlib_h}" = "yes" && 
    54    test "${ac_enable_alsa}" != no ; then 
     360if test "x${ac_enable_alsa}" != xno ; then 
     361 
     362  AC_CHECK_HEADERS(alsa/asoundlib.h) 
     363  if test "x${ac_cv_header_alsa_asoundlib_h}" = xyes ; then 
    55364    AC_DEFINE(DRIVER_ALSA) 
    56365    LIBS="$LIBS -lasound" 
     366  fi 
     367 
     368  sweep_config_driver="ALSA" 
    57369fi 
    58370 
    59371dnl Test for OSS 
    60372AC_CHECK_HEADERS(sys/soundcard.h machine/soundcard.h) 
    61 if test "${ac_cv_header_sys_soundcard_h}" = "yes" || \ 
    62     test "${ac_cv_header_machine_soundcard_h}" = "yes"; then 
    63     if test $ac_enable_alsa = no ; then 
    64        AC_DEFINE(DRIVER_OSS) 
    65     fi 
     373if test "x${ac_cv_header_sys_soundcard_h}" = xyes || \ 
     374  test "x${ac_cv_header_machine_soundcard_h}" = xyes; then 
     375  if test "x$ac_enable_alsa" = xno ; then 
     376    AC_DEFINE(DRIVER_OSS) 
     377 
     378    dnl Check for NetBSD's OSS compatability layer 
     379    AC_CHECK_LIB(ossaudio, _oss_ioctl, LIBS="$LIBS -lossaudio") 
     380 
     381    sweep_config_driver="OSS" 
     382  fi 
    66383fi 
    67384 
    68385dnl Test for Solaris audio 
     386case $host in 
     387*-*-solaris*) 
    69388AC_CHECK_HEADERS(sys/audioio.h) 
    70 if test "${ac_cv_header_sys_audioio_h}" = "yes"; then 
     389if test "x${ac_cv_header_sys_audioio_h}" = xyes; then 
    71390    AC_DEFINE(DRIVER_SOLARIS_AUDIO) 
    72 fi 
    73  
    74 dnl Add the languages which your application supports here. 
    75 ALL_LINGUAS="fr hu it de ru pl" 
    76 AM_GNU_GETTEXT 
     391    sweep_config_driver="Solaris" 
     392fi 
     393;; 
     394esac 
     395 
    77396 
    78397dnl Set PACKAGE_LOCALE_DIR in config.h. 
    79 if test "x${prefix}" = "xNONE"; then 
     398if test "x${prefix}" = xNONE; then 
    80399  AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${ac_default_prefix}/${DATADIRNAME}/locale") 
    81400else 
     
    85404dnl Set PACKAGE_DATA_DIR in config.h. 
    86405if test "x${datadir}" = 'x${prefix}/share'; then 
    87   if test "x${prefix}" = "xNONE"; then 
     406  if test "x${prefix}" = xNONE; then 
    88407    AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${ac_default_prefix}/share/${PACKAGE}") 
    89408  else 
     
    97416PACKAGE_PLUGIN_DIR=$libdir/sweep 
    98417AC_SUBST(PACKAGE_PLUGIN_DIR) 
    99 if test "x${prefix}" = "xNONE"; then 
    100   AC_DEFINE_UNQUOTED(PACKAGE_PLUGIN_DIR, "${ac_default_prefix}/lib/${PACKAGE}") 
    101 else 
    102   AC_DEFINE_UNQUOTED(PACKAGE_PLUGIN_DIR, "${prefix}/lib/${PACKAGE}") 
    103 fi 
     418if test "x${prefix}" = xNONE; then 
     419  sweep_plugin_dir="${ac_default_prefix}/lib/${PACKAGE}" 
     420else 
     421  sweep_plugin_dir="${prefix}/lib/${PACKAGE}" 
     422fi 
     423AC_DEFINE_UNQUOTED(PACKAGE_PLUGIN_DIR, "$sweep_plugin_dir") 
    104424 
    105425dnl Set PACKAGE_SOURCE_DIR in config.h. 
     
    109429 
    110430dnl Use -Wall if we have gcc. 
    111 changequote(,)dnl 
    112 if test "x$GCC" = "xyes"; then 
    113   case " $CFLAGS " in 
    114   *[\ \ ]-Wall[\ \      ]*) ;; 
    115   *) CFLAGS="$CFLAGS -Wall" ;; 
    116   esac 
    117 fi 
    118 changequote([,])dnl 
    119  
    120 AC_SUBST(AUDIOFILE_LIB) 
     431dnl changequote(,)dnl 
     432if test "x$ac_cv_prog_gcc" = xyes ; then 
     433  CFLAGS="$CFLAGS -Wall" 
     434fi 
     435dnl changequote([,])dnl 
     436 
     437 
     438dnl 
     439dnl  Configuration tests complete -- provide summary of results. 
     440dnl 
     441 
     442if test $sweep_config_ok = no ; then 
     443 
     444AC_MSG_RESULT([ 
     445************************************************************** 
     446 
     447*** Sweep $VERSION: Automatic configuration FAILED. 
     448 
     449*** The file config.log has full details. 
     450 
     451*** The following required libraries are missing or 
     452*** misconfigured on your system: 
     453]) 
     454 
     455if test "x$HAVE_GLIB" != xyes ; then 
     456  AC_MSG_RESULT([ 
     457*** GLib version 1.2.x, available from  http://www.gtk.org/ 
     458]) 
     459fi 
     460if test "x$HAVE_GLIB" = xmaybe ; then 
     461  AC_MSG_RESULT([ 
     462      Development files missing: The libglib binary seems 
     463      to be installed, but the glib-config program required 
     464      for building programs could not be found. 
     465]) 
     466fi 
     467 
     468if test "x$HAVE_GTK" != xyes ; then 
     469  AC_MSG_RESULT([ 
     470*** GTK+ version 1.2.x, available from  http://www.gtk.org/ 
     471]) 
     472fi 
     473if test "x$HAVE_GTK" = xmaybe ; then 
     474  AC_MSG_RESULT([ 
     475      Development files missing: The libgtk binary seems 
     476      to be installed, but the gtk-config program required 
     477      for building programs could not be found. 
     478]) 
     479fi 
     480 
     481if test "x$HAVE_LIBSNDFILE1" != xyes ; then 
     482  AC_MSG_RESULT([ 
     483*** libsndfile version 1.0.0 or greater, available from 
     484*** http://www.zip.com.au/~erikd/libsndfile/ 
     485]) 
     486fi 
     487if test "x$HAVE_LIBSNDFILE1" = xmaybe ; then 
     488    AC_MSG_RESULT([ 
     489      Development files missing: libsndfile-1.0.0 or greater 
     490      seems to exist on your system, however the header files 
     491      are missing and the pkg-config tool cannot find its build 
     492      information. 
     493]) 
     494fi 
     495if test "x$HAVE_LIBSNDFILE0" = xyes ; then 
     496    AC_MSG_RESULT([ 
     497      Incorrect version: Your system appears to have an old 
     498      version of libsndfile (below 1.0.0) installed. 
     499]) 
     500fi 
     501 
     502if test "x$HAVE_VORBIS" != xyes ; then 
     503    AC_MSG_RESULT([ 
     504*** Ogg Vorbis libraries, available from  http://www.xiph.org/ogg/vorbis/ 
     505]) 
     506fi 
     507if test "x$HAVE_VORBIS" = xmaybe ; then 
     508    AC_MSG_RESULT([ 
     509      Development files missing: The libogg, libvorbis, libvorbisenc and 
     510      libvorbisfile library binaries seem to be installed, but building of 
     511      a test program failed. 
     512]) 
     513fi  
     514if test "x$HAVE_VORBIS" != xyes ; then 
     515    AC_MSG_RESULT([ 
     516*** Or, to build a version of Sweep without Ogg Vorbis support, do: 
     517*** 
     518***         ./configure --disable-oggvorbis 
     519]) 
     520fi 
     521 
     522if test "x$HAVE_TDB" != xyes ; then 
     523  AC_MSG_RESULT([ 
     524*** The Trivial Database library (tdb), available from 
     525*** http://www.sourceforge.net/projects/tdb/ 
     526]) 
     527fi 
     528if test "x$HAVE_TDB" = xmaybe ; then 
     529  AC_MSG_RESULT([ 
     530      Development files missing: libtdb seems to be installed, but 
     531      the tdb.h header file could not be found. 
     532]) 
     533fi 
     534 
     535if test "x$HAVE_GLIB" = xmaybe || test "x$HAVE_GTK" = xmaybe || 
     536   test "x$HAVE_LIBSNDFILE1" = xmaybe || test "x$HAVE_TDB" = xmaybe || 
     537   test "x$HAVE_OGG" = xmaybe || test "x$HAVE_VORBIS" = xmaybe ; then 
     538  AC_MSG_RESULT([ 
     539*** HOW TO FIX "development files missing": you have probably 
     540*** installed the library package from your distribution. You 
     541*** must also install the library's "development" package. 
     542]) 
     543fi 
     544 
     545AC_MSG_RESULT([ 
     546*** If you install the required libraries from source, you 
     547*** need to inform the dynamic linker of their location. If 
     548*** you install them in a system-wide directory such as 
     549*** /usr/local (the default), you must ensure that 
     550*** /usr/local/lib is listed in /etc/ld.so.conf, then run 
     551*** ldconfig to update the dynamic linking system. 
     552*** Alternatively, you can set your LD_LIBRARY_PATH environment 
     553*** variable to include the library installation directory. 
     554]) 
     555 
     556 
     557AC_MSG_RESULT([ 
     558************************************************************** 
     559]) 
     560 
     561AC_MSG_ERROR([ 
     562*** 
     563*** After fixing the above problems, you must run ./configure again. 
     564*** 
     565]) 
     566 
     567else 
    121568 
    122569AC_OUTPUT([ 
     
    128575plugins/echo/Makefile 
    129576plugins/normalise/Makefile 
     577plugins/fade/Makefile 
    130578plugins/reverse/Makefile 
    131579plugins/ladspa/Makefile 
     
    133581plugins/example/Makefile 
    134582doc/Makefile 
     583pixmaps/Makefile 
    135584intl/Makefile 
    136585po/Makefile.in 
    137586]) 
    138587 
     588AC_MSG_RESULT([ 
     589  ************************************************************ 
     590 * Sweep $VERSION:  Automatic configuration OK. 
     591** 
     592**  Configuration summary: 
     593** 
     594**     Experimental code: ....... ${ac_enable_experimental} 
     595**     Audio device handling: ... $sweep_config_driver 
     596**     PCM: libsndfile version .. $LIBSNDFILE_VERSION 
     597**     Ogg Vorbis support: ...... $HAVE_VORBIS 
     598**     MPEG (MP3) loading: ...... $HAVE_MAD 
     599**     Speex support: ........... $HAVE_SPEEX 
     600**     Secret Rabbit Code: ...... $HAVE_LIBSAMPLERATE 
     601**     Translations: ............ $ALL_LINGUAS 
     602** 
     603**  Installation directories: 
     604** 
     605**     Program: ................. ${prefix}/bin 
     606**     Plugins: ................. $sweep_plugin_dir 
     607** 
     608************************************************************** 
     609** 
     610**  Type 'make' to compile Sweep. 
     611** 
     612**  Type 'make install' to install Sweep. Plugins will not be 
     613**  accessible until you have done this. 
     614**   
     615**  Have fun with Scrubby! 
     616 * 
     617  ************************************************************ 
     618]) 
     619 
     620fi 
  • trunk/sweep/doc/sweep.1

    r7 r124  
    1 .TH SWEEP 1 "21 Apr 2000" Version 0.
     1.TH SWEEP 1 "21 Apr 2000" Version 0.5.
    22.SH NAME 
    33Sweep - a sound wave editor 
  • trunk/sweep/include/sweep/Makefile.am

    r57 r124  
    44 
    55sweepinclude_HEADERS = \ 
    6         config.h \ 
    76        sweep_version.h \ 
    87        sweep_i18n.h \ 
  • trunk/sweep/include/sweep/sweep.h

    r57 r124  
    2222#define __SWEEP_H__ 
    2323 
    24 #include <sweep/config.h> 
    25  
    2624#include <sweep/sweep_version.h> 
    2725#include <sweep/sweep_i18n.h> 
  • trunk/sweep/include/sweep/sweep_filter.h

    r57 r124  
    3131                          gpointer custom_data); 
    3232 
    33 typedef sw_sounddata * (*SweepFilter) (sw_sounddata * sounddata, 
    34                                        sw_param_set pset, 
    35                                        gpointer custom_data); 
    36  
    3733sw_op_instance * 
    3834perform_filter_op (sw_sample * sample, char * desc, SweepFilter func, 
  • trunk/sweep/include/sweep/sweep_i18n.h

    r57 r124  
    2929#  undef _ 
    3030#  define _(String) dgettext (PACKAGE, String) 
     31 
     32#  define gettext_noop(String) String 
     33#  define N_(String) gettext_noop(String) 
     34 
     35/* 
    3136#  ifdef gettext_noop 
    3237#    define N_(String) gettext_noop (String) 
    3338#  else 
    34 #    define N_(String) (String
     39#    define N_(String) ("NOT TRANSLATED"
    3540#  endif 
     41*/ 
     42 
    3643#else 
    3744#  define textdomain(String) (String) 
     
    4047#  define dcgettext(Domain,Message,Type) (Message) 
    4148#  define bindtextdomain(Domain,Directory) (Domain) 
     49 
     50#ifdef DEVEL_CODE 
     51#  define _(String) ("UNTRANSLATED") 
     52#  define N_(String) ("UNTRANSLATED") 
     53#else 
    4254#  define _(String) (String) 
    4355#  define N_(String) (String) 
    4456#endif 
    4557 
     58#endif 
     59 
    4660#endif /* __I18N_H__ */ 
  • trunk/sweep/include/sweep/sweep_sample.h

    r57 r124  
    2525 
    2626sw_sample * 
    27 sample_new_empty(char * directory, char * filename, 
    28                       gint nr_channels, gint sample_rate, gint sample_length); 
     27sample_new_empty(char * pathname, gint nr_channels, gint sample_rate, 
     28                 gint sample_length); 
    2929 
    3030sw_sample * 
     
    3434sample_destroy (sw_sample * s); 
    3535 
     36sw_sounddata * 
     37sample_get_sounddata (sw_sample * s); 
     38 
    3639void 
    37 sample_set_pathname (sw_sample * s, char * directory, char * filename); 
     40sample_set_file_format (sw_sample * s, sw_file_format_t file_format); 
     41 
     42void 
     43sample_set_pathname (sw_sample * s, char * pathname); 
     44 
     45GList * 
     46sample_bank_list_names (void); 
     47 
     48sw_sample * 
     49sample_bank_find_byname (const gchar * name); 
     50 
     51gboolean 
     52sample_bank_contains (sw_sample *s); 
    3853 
    3954void 
     
    5368 
    5469void 
    55 sample_set_playmarker (sw_sample * s, int offset); 
     70sample_set_edit_state (sw_sample * s, sw_edit_state edit_state); 
     71 
     72void 
     73sample_set_edit_mode (sw_sample * s, sw_edit_mode edit_mode); 
     74 
     75void 
     76sample_refresh_playmode (sw_sample * s); 
     77 
     78void 
     79sample_set_previewing (sw_sample * s, gboolean previewing); 
     80 
     81void 
     82sample_set_stop_offset (sw_sample * s); 
     83 
     84void 
     85sample_set_playmarker (sw_sample * s, sw_framecount_t offset, 
     86                       gboolean by_user); 
     87 
     88void 
     89sample_set_rec_marker (sw_sample * s, sw_framecount_t offset); 
     90 
     91void 
     92sample_set_scrubbing (sw_sample * s, gboolean scrubbing); 
     93 
     94void 
     95sample_set_looping (sw_sample * s, gboolean looping); 
     96 
     97void 
     98sample_set_playrev (sw_sample * s, gboolean reverse); 
     99 
     100void 
     101sample_set_mute (sw_sample * s, gboolean mute); 
     102 
     103void 
     104sample_set_color (sw_sample * s, gint color); 
     105 
     106void 
     107sample_set_progress_text (sw_sample * s, gchar * text); 
     108 
     109void 
     110sample_set_progress_percent (sw_sample * s, gint percent); 
     111 
     112void 
     113sample_refresh_progress_percent (sw_sample * s); 
     114 
     115int 
     116sample_set_progress_ready (sw_sample * s); 
     117 
     118void 
     119sample_set_tmp_message (sw_sample * s, const char * fmt, ...); 
    56120 
    57121/* 
     
    70134 
    71135/* Selection handling */ 
     136 
     137gboolean 
     138sample_offset_in_sel (sw_sample * s, sw_framecount_t offset); 
    72139 
    73140guint 
     
    106173sample_selection_select_none (sw_sample * s); 
    107174 
     175void 
     176sample_selection_halve (sw_sample * s); 
     177 
     178void 
     179sample_selection_double (sw_sample * s); 
     180 
     181void 
     182sample_selection_shift_left (sw_sample * s); 
     183 
     184void 
     185sample_selection_shift_right (sw_sample * s); 
     186 
     187/* info dialog */ 
     188void 
     189sample_show_info_dialog (sw_sample * sample); 
     190 
     191 
    108192#endif /* __SWEEP_SAMPLE_H__ */ 
  • trunk/sweep/include/sweep/sweep_selection.h

    r57 r124  
    2828sel_copy (sw_sel * sel); 
    2929 
     30GList * 
     31sels_add_selection (GList * sels, sw_sel * sel); 
     32 
     33GList * 
     34sels_add_selection_1 (GList * sels, sw_framecount_t start, sw_framecount_t end); 
     35 
    3036/* 
    3137 * sel_cmp (s1, s2) 
     
    4551sels_copy (GList * sels); 
    4652 
     53/* 
     54 * sels_invert (sels, nr_frames) 
     55 * 
     56 * inverts sels in place 
     57 */ 
     58GList * 
     59sels_invert (GList * sels, sw_framecount_t nr_frames); 
     60 
    4761sw_op_instance * 
    48 perform_selection_op (sw_sample * s, char * desc, SweepModify func, 
     62perform_selection_op (sw_sample * s, char * desc, SweepFilter func, 
    4963                      sw_param_set pset, gpointer custom_data); 
    5064 
  • trunk/sweep/include/sweep/sweep_sounddata.h

    r57 r124  
    6464sounddata_selection_nr_frames (sw_sounddata * sounddata); 
    6565 
     66gint 
     67sounddata_selection_width (sw_sounddata * sounddata); 
     68 
    6669void 
    6770sounddata_selection_translate (sw_sounddata * sounddata, gint delta); 
     71 
     72void 
     73sounddata_selection_scale (sw_sounddata * sounddata, gfloat scale); 
    6874 
    6975/* 
  • trunk/sweep/include/sweep/sweep_types.h

    r58 r124  
    2424#include <glib.h> 
    2525#include <gdk/gdktypes.h>  /* XXX: for GdkModifierType */ 
     26#include <gtk/gtk.h> /* XXX: for info_clist widget */ 
     27 
     28#include <sys/types.h> 
     29 
     30/* 
     31#include <config.h> 
     32*/ 
    2633 
    2734/* 
     
    4552 
    4653/* Frame Counts */ 
    47 typedef gint sw_framecount_t; 
     54#if 0 
     55 
     56#if (SIZEOF_OFF_T == 8)  
     57/* For libsndfile version 1 */ 
     58typedef off_t sw_framecount_t; 
     59#else 
     60typedef int sw_framecount_t; 
     61#endif 
     62 
     63#else 
     64 
     65typedef int sw_framecount_t; 
     66#define FRAMECOUNT_MAX INT_MAX 
     67 
     68#endif 
    4869 
    4970 
     
    85106 
    86107struct _sw_sounddata { 
     108  int refcount; 
     109 
    87110  sw_format * format; 
    88111  sw_framecount_t nr_frames;    /* nr frames */ 
     
    96119#define SW_DIR_LEN 256 
    97120 
    98 /* 
    99  * sw_sample 
    100  */ 
    101 struct _sw_sample { 
    102   sw_sounddata * sounddata; 
    103   GList * views; 
    104  
    105   gchar * filename; 
    106   gchar directory[SW_DIR_LEN]; 
    107  
    108   GList * registered_ops; 
    109   GList * current_undo; 
    110   GList * current_redo; 
    111  
    112   sw_sel * tmp_sel; /* Temporary selection, used while selecting */ 
    113   gint playmarker_tag; /* gtk_timeout tag for playmarkers */ 
    114 }; 
     121 
     122typedef enum { 
     123  SWEEP_EDIT_MODE_READY, 
     124  SWEEP_EDIT_MODE_META, /* modifying metadata: sels etc. */ 
     125  SWEEP_EDIT_MODE_FILTER, 
     126  SWEEP_EDIT_MODE_ALLOC, 
     127} sw_edit_mode; 
     128 
     129typedef enum { 
     130  SWEEP_EDIT_STATE_IDLE, 
     131  SWEEP_EDIT_STATE_PENDING, 
     132  SWEEP_EDIT_STATE_BUSY, 
     133  SWEEP_EDIT_STATE_DONE, 
     134  SWEEP_EDIT_STATE_CANCEL, 
     135} sw_edit_state; 
     136 
     137typedef enum { 
     138  SWEEP_TRANSPORT_STOP, 
     139  SWEEP_TRANSPORT_PLAY, 
     140  SWEEP_TRANSPORT_PLAY_SEL, 
     141} sw_transport_type; 
     142 
     143/* File formats */ 
     144typedef enum { 
     145  SWEEP_FILE_FORMAT_NONE=0, 
     146  SWEEP_FILE_FORMAT_BY_EXTENSION=0, 
     147  SWEEP_FILE_FORMAT_RAW, 
     148  SWEEP_FILE_FORMAT_WAV, 
     149  SWEEP_FILE_FORMAT_AIFF, 
     150  SWEEP_FILE_FORMAT_AU, 
     151  SWEEP_FILE_FORMAT_PAF, 
     152  SWEEP_FILE_FORMAT_SVX, 
     153  SWEEP_FILE_FORMAT_IRCAM, 
     154  SWEEP_FILE_FORMAT_VOC, 
     155  SWEEP_FILE_FORMAT_MAX 
     156} sw_file_format_t; 
     157 
    115158 
    116159typedef struct _sw_edit_region sw_edit_region; 
     
    131174  sw_format * format; 
    132175  GList * regions; 
     176  gint refcount; 
    133177}; 
    134178 
     
    137181typedef void (*SweepCallback) (sw_sample * sample, gpointer data); 
    138182 
     183 
    139184typedef struct _sw_operation sw_operation; 
    140185typedef struct _sw_op_instance sw_op_instance; 
    141186 
    142187struct _sw_operation { 
     188  sw_edit_mode edit_mode; 
     189  SweepCallback _do_; 
     190  SweepFunction purge_do; 
    143191  SweepCallback undo; 
    144192  SweepFunction purge_undo; 
     
    148196 
    149197struct _sw_op_instance { 
     198  sw_sample * sample; 
    150199  char * description; 
    151200  sw_operation * op; 
     201  gpointer do_data; 
    152202  gpointer undo_data; 
    153203  gpointer redo_data; 
     
    410460}; 
    411461 
    412 typedef void (*SweepModify) (sw_sample * sample, sw_param_set pset, 
    413                              gpointer custom_data); 
     462typedef sw_sample * (*SweepFilter) (sw_sample * sample, 
     463                                    sw_param_set pset, 
     464                                    gpointer custom_data); 
     465 
    414466 
    415467#endif  /* __SWEEP_TYPES_H__ */ 
  • trunk/sweep/include/sweep/sweep_undo.h

    r57 r124  
    2424#include "sweep_types.h" 
    2525 
     26gint 
     27update_edit_progress (gpointer data); 
     28 
    2629sw_op_instance * 
    27 sw_op_instance_new (char * desc, sw_operation * op); 
     30sw_op_instance_new (sw_sample * sample, char * description, 
     31                    sw_operation * operation); 
     32 
     33void 
     34schedule_operation (sw_sample * sample, char * description, 
     35                    sw_operation * operation, void * do_data); 
    2836 
    2937void 
    3038register_operation (sw_sample * s, sw_op_instance * inst); 
     39 
     40void 
     41trim_registered_ops (sw_sample * s, int length); 
    3142 
    3243void 
     
    3647redo_current (sw_sample * s); 
    3748 
     49void 
     50revert_op (sw_sample * sample, GList * op_gl); 
     51 
     52void 
     53set_active_op (sw_sample * s, sw_op_instance * inst); 
     54 
     55void 
     56cancel_active_op (sw_sample * s); 
    3857 
    3958/* Stock undo functions */ 
     
    5675redo_by_replace (replace_data * r); 
    5776#endif 
     77 
     78typedef struct _sounddata_replace_data sounddata_replace_data; 
     79 
     80struct _sounddata_replace_data { 
     81  sw_sample * sample; 
     82  sw_sounddata * old_sounddata; 
     83  sw_sounddata * new_sounddata; 
     84}; 
     85 
     86sounddata_replace_data * 
     87sounddata_replace_data_new (sw_sample * sample, 
     88                            sw_sounddata * old_sounddata, 
     89                            sw_sounddata * new_sounddata); 
     90 
     91void 
     92sounddata_replace_data_destroy (sounddata_replace_data * sr); 
     93 
     94void 
     95undo_by_sounddata_replace (sw_sample * s, sounddata_replace_data * sr); 
     96 
     97void 
     98redo_by_sounddata_replace (sw_sample * s, sounddata_replace_data * sr); 
     99 
    58100 
    59101typedef struct _paste_over_data paste_over_data; 
     
    83125  sw_sample * sample; 
    84126  sw_edit_buffer * eb; 
     127  GList * sels; /* Previous sels of sounddata */ 
    85128}; 
    86129 
    87130splice_data * 
    88 splice_data_new (sw_edit_buffer * eb); 
     131splice_data_new (sw_edit_buffer * eb, GList * sels); 
    89132 
    90133void 
     
    103146redo_by_splice_in (sw_sample * s, splice_data * sp); 
    104147 
     148void 
     149undo_by_splice_over (sw_sample * s, splice_data * sp); 
     150 
     151void 
     152redo_by_splice_over (sw_sample * s, splice_data * sp); 
     153 
     154void 
     155undo_by_crop_in (sw_sample * s, splice_data * sp); 
     156 
     157void 
     158redo_by_crop_out (sw_sample * s, splice_data * sp); 
    105159 
    106160#endif /* __SWEEP_UNDO_H__ */ 
  • trunk/sweep/include/sweep/sweep_version.h

    r57 r124  
    2525 * The current version of Sweep's native plugin interface. 
    2626 * 
    27  * Increment this when breaking binary compatability. 
     27 * See the Sweep Plugin Writer's Guide for information about the meaning 
     28 * of these and when to change each. 
    2829 */ 
    2930#define SWEEP_PLUGIN_API_MAJOR 1 
    3031 
    31 #define SWEEP_PLUGIN_API_MINOR 0 
     32#define SWEEP_PLUGIN_API_MINOR 1 
    3233 
    3334#define SWEEP_PLUGIN_API_REVISION 0 
  • trunk/sweep/install-sh

    r7 r124  
    110110        exit 1 
    111111else 
    112         true 
     112        : 
    113113fi 
    114114 
     
    121121                chmodcmd="" 
    122122        else 
    123                 instcmd=mkdir 
     123                instcmd=$mkdirprog 
    124124        fi 
    125125else 
     
    129129# if $src (and thus $dsttmp) contains '*'. 
    130130 
    131         if [ -f $src -o -d $src
    132         then 
    133                 true 
     131        if [ -f "$src" ] || [ -d "$src"
     132        then 
     133                : 
    134134        else 
    135135                echo "install:  $src does not exist" 
     
    142142                exit 1 
    143143        else 
    144                 true 
     144                : 
    145145        fi 
    146146 
     
    152152                dst="$dst"/`basename $src` 
    153153        else 
    154                 true 
     154                : 
    155155        fi 
    156156fi 
     
    164164# Skip lots of stat calls in the usual case. 
    165165if [ ! -d "$dstdir" ]; then 
    166 defaultIFS='    
    167 
     166defaultIFS=' 
     167       
    168168IFS="${IFS-${defaultIFS}}" 
    169169 
     
    184184                $mkdirprog "${pathcomp}" 
    185185        else 
    186                 true 
     186                : 
    187187        fi 
    188188 
     
    195195        $doit $instcmd $dst && 
    196196 
    197         if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && 
    198         if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && 
    199         if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && 
    200         if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi 
     197        if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi && 
     198        if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi && 
     199        if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi && 
     200        if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi 
    201201else 
    202202 
     
    217217                dstfile=`basename $dst` 
    218218        else 
    219                 true 
     219                : 
    220220        fi 
    221221 
     
    236236# errors from the above "$doit $instcmd $src $dsttmp" command. 
    237237 
    238         if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && 
    239         if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && 
    240         if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && 
    241         if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && 
     238        if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi && 
     239        if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi && 
     240        if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi && 
     241        if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi && 
    242242 
    243243# Now rename the file to the real destination. 
  • trunk/sweep/intl/ChangeLog

    r7 r124  
    1 1998-04-29  Ulrich Drepper  <drepper@cygnus.com
     12001-09-13  GNU  <bug-gnu-utils@gnu.org
    22 
    3         * intl/localealias.c (read_alias_file): Use unsigned char for 
    4         local variables.  Remove unused variable tp. 
    5         * intl/l10nflist.c (_nl_normalize_codeset): Use unsigned char * 
    6         for type of codeset.  For loosing Solaris systems. 
    7         * intl/loadinfo.h: Adapt prototype of _nl_normalize_codeset. 
    8         * intl/bindtextdom.c (BINDTEXTDOMAIN): Don't define local variable 
    9         len if not needed. 
    10         Patches by Jim Meyering. 
     3        * Version 0.10.40 released. 
    114 
    12 1998-04-28  Ulrich Drepper  <drepper@cygnus.com> 
    13  
    14         * loadmsgcat.c (_nl_load_domain): Don't assign the element use_mmap if 
    15         mmap is not supported. 
    16  
    17         * hash-string.h: Don't include <values.h>. 
    18  
    19 1998-04-27  Ulrich Drepper  <drepper@cygnus.com> 
    20  
    21         * textdomain.c: Use strdup is available. 
    22  
    23         * localealias.c: Define HAVE_MEMPCPY so that we can use this 
    24         function.  Define and use semapahores to protect modfication of 
    25         global objects when compiling for glibc.  Add code to allow 
    26         freeing alias table. 
    27  
    28         * l10nflist.c: Don't assume stpcpy not being a macro. 
    29  
    30         * gettextP.h: Define internal_function macri if not already done. 
    31         Use glibc byte-swap macros instead of defining SWAP when compiled 
    32         for glibc. 
    33         (struct loaded_domain): Add elements to allow unloading. 
    34  
    35         * Makefile.in (distclean): Don't remove libintl.h here. 
    36  
    37         * bindtextdomain.c: Carry over changes from glibc.  Use strdup if 
    38         available. 
    39  
    40         * dcgettext.c: Don't assume stpcpy not being a macro.  Mark internal 
    41         functions.  Add memory freeing code for glibc. 
    42  
    43         * dgettext.c: Update copyright. 
    44  
    45         * explodename.c: Include stdlib.h and string.h only if they exist. 
    46         Use strings.h eventually. 
    47  
    48         * finddomain.c: Mark internal functions.  Use strdup if available. 
    49         Add memory freeing code for glibc. 
    50  
    51 1997-10-10 20:00  Ulrich Drepper  <drepper@cygnus.com> 
    52  
    53         * libgettext.h: Fix dummy textdomain and bindtextdomain macros. 
    54         They should return reasonable values. 
    55         Reported by Tom Tromey <tromey@cygnus.com>. 
    56  
    57 1997-09-16 03:33  Ulrich Drepper  <drepper@cygnus.com> 
    58  
    59         * libgettext.h: Define PARAMS also to `args' if __cplusplus is defined. 
    60         * intlh.inst.in: Likewise. 
    61         Reported by Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>. 
    62  
    63         * libintl.glibc: Update from current glibc version. 
    64  
    65 1997-09-06 02:10  Ulrich Drepper  <drepper@cygnus.com> 
    66  
    67         * intlh.inst.in: Reformat copyright. 
    68  
    69 1997-08-19 15:22  Ulrich Drepper  <drepper@cygnus.com> 
    70  
    71         * dcgettext.c (DCGETTEXT): Remove wrong comment. 
    72  
    73 1997-08-16 00:13  Ulrich Drepper  <drepper@cygnus.com> 
    74  
    75         * Makefile.in (install-data): Don't change directory to install. 
    76  
    77 1997-08-01 14:30  Ulrich Drepper  <drepper@cygnus.com> 
    78  
    79         * cat-compat.c: Fix copyright. 
    80  
    81         * localealias.c: Don't define strchr unless !HAVE_STRCHR. 
    82  
    83         * loadmsgcat.c: Update copyright.  Fix typos. 
    84  
    85         * l10nflist.c: Don't define strchr unless !HAVE_STRCHR. 
    86         (_nl_make_l10nflist): Handle sponsor and revision correctly. 
    87  
    88         * gettext.c: Update copyright. 
    89         * gettext.h: Likewise. 
    90         * hash-string.h: Likewise. 
    91  
    92         * finddomain.c: Remoave dead code.  Define strchr only if 
    93         !HAVE_STRCHR. 
    94  
    95         * explodename.c: Include <sys/types.h>. 
    96  
    97         * explodename.c: Reformat copyright text. 
    98         (_nl_explode_name): Fix typo. 
    99  
    100         * dcgettext.c: Define and use __set_errno. 
    101         (guess_category_value): Don't use setlocale if HAVE_LC_MESSAGES is 
    102         not defined. 
    103  
    104         * bindtextdom.c: Pretty printing. 
    105  
    106 1997-05-01 02:25  Ulrich Drepper  <drepper@cygnus.com> 
    107  
    108         * dcgettext.c (guess_category_value): Don't depend on 
    109         HAVE_LC_MESSAGES.  We don't need the macro here. 
    110         Patch by Bruno Haible <haible@ilog.fr>. 
    111  
    112         * cat-compat.c (textdomain): DoN't refer to HAVE_SETLOCALE_NULL 
    113         macro.  Instead use HAVE_LOCALE_NULL and define it when using 
    114         glibc, as in dcgettext.c. 
    115         Patch by Bruno Haible <haible@ilog.fr>. 
    116  
    117         * Makefile.in (CPPFLAGS): New variable.  Reported by Franc,ois 
    118         Pinard. 
    119  
    120 Mon Mar 10 06:51:17 1997  Ulrich Drepper  <drepper@cygnus.com> 
    121  
    122         * Makefile.in: Implement handling of libtool. 
    123  
    124         * gettextP.h: Change data structures for use of generic lowlevel 
    125         i18n file handling. 
    126  
    127 Wed Dec  4 20:21:18 1996  Ulrich Drepper  <drepper@cygnus.com> 
    128  
    129         * textdomain.c: Put parentheses around arguments of memcpy macro 
    130         definition. 
    131         * localealias.c: Likewise. 
    132         * l10nflist.c: Likewise. 
    133         * finddomain.c: Likewise. 
    134         * bindtextdom.c: Likewise. 
    135         Reported by Thomas Esken. 
    136  
    137 Mon Nov 25 22:57:51 1996  Ulrich Drepper  <drepper@cygnus.com> 
    138  
    139         * textdomain.c: Move definition of `memcpy` macro to right 
    140         position. 
    141  
    142 Fri Nov 22 04:01:58 1996  Ulrich Drepper  <drepper@cygnus.com> 
    143  
    144         * finddomain.c [!HAVE_STRING_H && !_LIBC]: Define memcpy using 
    145         bcopy if not already defined.  Reported by Thomas Esken. 
    146         * bindtextdom.c: Likewise. 
    147         * l10nflist.c: Likewise. 
    148         * localealias.c: Likewise. 
    149         * textdomain.c: Likewise. 
    150  
    151 Tue Oct 29 11:10:27 1996  Ulrich Drepper  <drepper@cygnus.com> 
    152  
    153         * Makefile.in (libdir): Change to use exec_prefix instead of 
    154         prefix.  Reported by Knut-HÃ¥vardAksnes <etokna@eto.ericsson.se>. 
    155  
    156 Sat Aug 31 03:07:09 1996  Ulrich Drepper  <drepper@cygnus.com> 
    157  
    158         * l10nflist.c (_nl_normalize_codeset): We convert to lower case, 
    159         so don't prepend uppercase `ISO' for only numeric arg. 
    160  
    161 Fri Jul 19 00:15:46 1996  Ulrich Drepper  <drepper@cygnus.com> 
    162  
    163         * l10nflist.c: Move inclusion of argz.h, ctype.h, stdlib.h after 
    164         definition of _GNU_SOURCE.  Patch by Roland McGrath. 
    165  
    166         * Makefile.in (uninstall): Fix another bug with `for' loop and 
    167         empty arguments.  Patch by Jim Meyering.  Correct name os 
    168         uninstalled files: no intl- prefix anymore. 
    169  
    170         * Makefile.in (install-data): Again work around shells which 
    171         cannot handle mpty for list.  Reported by Jim Meyering. 
    172  
    173 Sat Jul 13 18:11:35 1996  Ulrich Drepper  <drepper@cygnus.com> 
    174  
    175         * Makefile.in (install): Split goal.  Now depend on install-exec 
    176         and install-data. 
    177         (install-exec, install-data): New goals.  Created from former 
    178         install goal. 
    179         Reported by Karl Berry. 
    180  
    181 Sat Jun 22 04:58:14 1996  Ulrich Drepper  <drepper@cygnus.com> 
    182  
    183         * Makefile.in (MKINSTALLDIRS): New variable.  Path to 
    184         mkinstalldirs script. 
    185         (install): use MKINSTALLDIRS variable or if the script is not present 
    186         try to find it in the $top_scrdir). 
    187  
    188 Wed Jun 19 02:56:56 1996  Ulrich Drepper  <drepper@cygnus.com> 
    189  
    190         * l10nflist.c: Linux libc *partly* includes the argz_* functions. 
    191         Grr.  Work around by renaming the static version and use macros 
    192         for renaming. 
    193  
    194 Tue Jun 18 20:11:17 1996  Ulrich Drepper  <drepper@cygnus.com> 
    195  
    196         * l10nflist.c: Correct presence test macros of __argz_* functions. 
    197  
    198         * l10nflist.c: Include <argz.h> based on test of it instead when 
    199         __argz_* functions are available. 
    200         Reported by Andreas Schwab. 
    201  
    202 Thu Jun 13 15:17:44 1996  Ulrich Drepper  <drepper@cygnus.com> 
    203  
    204         * explodename.c, l10nflist.c: Define NULL for dumb systems. 
    205  
    206 Tue Jun 11 17:05:13 1996  Ulrich Drepper  <drepper@cygnus.com> 
    207  
    208         * intlh.inst.in, libgettext.h (dcgettext): Rename local variable 
    209         result to __result to prevent name clash. 
    210  
    211         * l10nflist.c, localealias.c, dcgettext.c: Define _GNU_SOURCE to 
    212         get prototype for stpcpy and strcasecmp. 
    213  
    214         * intlh.inst.in, libgettext.h: Move declaration of 
    215         `_nl_msg_cat_cntr' outside __extension__ block to prevent warning 
    216         from gcc's -Wnested-extern option. 
    217  
    218 Fri Jun  7 01:58:00 1996  Ulrich Drepper  <drepper@cygnus.com> 
    219  
    220         * Makefile.in (install): Remove comment. 
    221  
    222 Thu Jun  6 17:28:17 1996  Ulrich Drepper  <drepper@cygnus.com> 
    223  
    224         * Makefile.in (install): Work around for another Buglix stupidity. 
    225         Always use an `else' close for `if's.  Reported by Nelson Beebe. 
    226  
    227         * Makefile.in (intlh.inst): Correct typo in phony rule. 
    228         Reported by Nelson Beebe. 
    229  
    230 Thu Jun  6 01:49:52 1996  Ulrich Drepper  <drepper@cygnus.com> 
    231  
    232         * dcgettext.c (read_alias_file): Rename variable alloca_list to 
    233         block_list as the macro calls assume. 
    234         Patch by Eric Backus. 
    235  
    236         * localealias.c [!HAVE_ALLOCA]: Define alloca as macro using 
    237         malloc. 
    238         (read_alias_file): Rename varriabe alloca_list to block_list as the 
    239         macro calls assume. 
    240         Patch by Eric Backus. 
    241  
    242         * l10nflist.c: Correct conditional for <argz.h> inclusion. 
    243         Reported by Roland McGrath. 
    244  
    245         * Makefile.in (all): Depend on all-@USE_INCLUDED_LIBINTL@, not 
    246         all-@USE_NLS@. 
    247  
    248         * Makefile.in (install): intlh.inst comes from local dir, not 
    249         $(srcdir). 
    250  
    251         * Makefile.in (intlh.inst): Special handling of this goal.  If 
    252         used in gettext, this is really a rul to construct this file.  If 
    253         used in any other package it is defined as a .PHONY rule with 
    254         empty body. 
    255  
    256         * finddomain.c: Extract locale file information handling into 
    257         l10nfile.c.  Rename local stpcpy__ function to stpcpy. 
    258  
    259         * dcgettext.c (stpcpy): Add local definition. 
    260  
    261         * l10nflist.c: Solve some portability problems.  Patches partly by 
    262         Thomas Esken.  Add local definition of stpcpy. 
    263  
    264 Tue Jun  4 02:47:49 1996  Ulrich Drepper  <drepper@cygnus.com> 
    265  
    266         * intlh.inst.in: Don't depend including <locale.h> on 
    267         HAVE_LOCALE_H.  Instead configure must rewrite this fiile 
    268         depending on the result of the configure run. 
    269  
    270         * Makefile.in (install): libintl.inst is now called intlh.inst. 
    271         Add rules for updating intlh.inst from intlh.inst.in. 
    272  
    273         * libintl.inst: Renamed to intlh.inst.in. 
    274  
    275         * localealias.c, dcgettext.c [__GNUC__]: Define HAVE_ALLOCA to 1 
    276         because gcc has __buitlin_alloca. 
    277         Reported by Roland McGrath. 
    278  
    279 Mon Jun  3 00:32:16 1996  Ulrich Drepper  <drepper@cygnus.com> 
    280  
    281         * Makefile.in (installcheck): New goal to fulfill needs of 
    282         automake's distcheck. 
    283  
    284         * Makefile.in (install): Reorder commands so that VERSION is 
    285         found. 
    286  
    287         * Makefile.in (gettextsrcdir): Now use subdirectory intl/ in 
    288         @datadir@/gettext. 
    289         (COMSRCS): Add l10nfile.c. 
    290         (OBJECTS): Add l10nfile.o. 
    291         (DISTFILES): Rename to DISTFILE.normal.  Remove $(DISTFILES.common). 
    292         (DISTFILE.gettext): Remove $(DISTFILES.common). 
    293         (all-gettext): Remove goal. 
    294         (install): If $(PACKAGE) = gettext install, otherwose do nothing.  No 
    295         package but gettext itself should install libintl.h + headers. 
    296         (dist): Extend goal to work for gettext, too. 
    297         (dist-gettext): Remove goal. 
    298  
    299         * dcgettext.c [!HAVE_ALLOCA]: Define macro alloca by using malloc. 
    300  
    301 Sun Jun  2 17:33:06 1996  Ulrich Drepper  <drepper@cygnus.com> 
    302  
    303         * loadmsgcat.c (_nl_load_domain): Parameter is now comes from 
    304         find_l10nfile. 
    305  
    306 Sat Jun  1 02:23:03 1996  Ulrich Drepper  <drepper@cygnus.com> 
    307  
    308         * l10nflist.c (__argz_next): Add definition. 
    309  
    310         * dcgettext.c [!HAVE_ALLOCA]: Add code for handling missing alloca 
    311         code.  Use new l10nfile handling. 
    312  
    313         * localealias.c [!HAVE_ALLOCA]: Add code for handling missing 
    314         alloca code. 
    315  
    316         * l10nflist.c: Initial revision. 
    317  
    318 Tue Apr  2 18:51:18 1996  Ulrich Drepper  <drepper@myware> 
    319  
    320         * Makefile.in (all-gettext): New goal.  Same as all-yes. 
    321  
    322 Thu Mar 28 23:01:22 1996  Karl Eichwalder  <ke@ke.central.de> 
    323  
    324         * Makefile.in (gettextsrcdir): Define using @datadir@. 
    325  
    326 Tue Mar 26 12:39:14 1996  Ulrich Drepper  <drepper@myware> 
    327  
    328         * finddomain.c: Include <ctype.h>.  Reported by Roland McGrath. 
    329  
    330 Sat Mar 23 02:00:35 1996  Ulrich Drepper  <drepper@myware> 
    331  
    332         * finddomain.c (stpcpy): Rename to stpcpy__ to prevent clashing 
    333         with external declaration. 
    334  
    335 Sat Mar  2 00:47:09 1996  Ulrich Drepper  <drepper@myware> 
    336  
    337         * Makefile.in (all-no): Rename from all_no. 
    338  
    339 Sat Feb 17 00:25:59 1996  Ulrich Drepper  <drepper@myware> 
    340  
    341         * gettextP.h [loaded_domain]: Array `successor' must now contain up 
    342         to 63 elements (because of codeset name normalization). 
    343  
    344         * finddomain.c: Implement codeset name normalization. 
    345  
    346 Thu Feb 15 04:39:09 1996  Ulrich Drepper  <drepper@myware> 
    347  
    348         * Makefile.in (all): Define to `all-@USE_NLS@'. 
    349         (all-yes, all_no): New goals.  `all-no' is noop, `all-yes' 
    350         is former all. 
    351  
    352 Mon Jan 15 21:46:01 1996  Howard Gayle  <howard@hal.com> 
    353  
    354         * localealias.c (alias_compare): Increment string pointers in loop 
    355         of strcasecmp replacement. 
    356  
    357 Fri Dec 29 21:16:34 1995  Ulrich Drepper  <drepper@myware> 
    358  
    359         * Makefile.in (install-src): Who commented this goal out ? :-) 
    360  
    361 Fri Dec 29 15:08:16 1995  Ulrich Drepper  <drepper@myware> 
    362  
    363         * dcgettext.c (DCGETTEXT): Save `errno'.  Failing system calls 
    364         should not effect it because a missing catalog is no error. 
    365         Reported by Harald K<o:>nig <koenig@tat.physik.uni-tuebingen.de>. 
    366  
    367 Tue Dec 19 22:09:13 1995  Ulrich Drepper  <drepper@myware> 
    368  
    369         * Makefile.in (Makefile): Explicitly use $(SHELL) for running 
    370         shell scripts. 
    371  
    372 Fri Dec 15 17:34:59 1995  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de> 
    373  
    374         * Makefile.in (install-src): Only install library and header when 
    375         we use the own implementation.  Don't do it when using the 
    376         system's gettext or catgets functions. 
    377  
    378         * dcgettext.c (find_msg): Must not swap domain->hash_size here. 
    379  
    380 Sat Dec  9 16:24:37 1995  Ulrich Drepper  <drepper@myware> 
    381  
    382         * localealias.c, libintl.inst, libgettext.h, hash-string.h, 
    383         gettextP.h, finddomain.c, dcgettext.c, cat-compat.c: 
    384         Use PARAMS instead of __P.  Suggested by Roland McGrath. 
    385  
    386 Tue Dec  5 11:39:14 1995  Larry Schwimmer  <rosebud@cyclone.stanford.edu> 
    387  
    388         * libgettext.h: Use `#if !defined (_LIBINTL_H)' instead of `#if 
    389         !_LIBINTL_H' because Solaris defines _LIBINTL_H as empty. 
    390  
    391 Mon Dec  4 15:42:07 1995  Ulrich Drepper  <drepper@myware> 
    392  
    393         * Makefile.in (install-src): 
    394         Install libintl.inst instead of libintl.h.install. 
    395  
    396 Sat Dec  2 22:51:38 1995  Marcus Daniels  <marcus@sysc.pdx.edu> 
    397  
    398         * cat-compat.c (textdomain): 
    399         Reverse order in which files are tried you load.  First 
    400         try local file, when this failed absolute path. 
    401  
    402 Wed Nov 29 02:03:53 1995  Nelson H. F. Beebe  <beebe@math.utah.edu> 
    403  
    404         * cat-compat.c (bindtextdomain): Add missing { }. 
    405  
    406 Sun Nov 26 18:21:41 1995  Ulrich Drepper  <drepper@myware> 
    407  
    408         * libintl.inst: Add missing __P definition.  Reported by Nelson Beebe. 
    409  
    410         * Makefile.in: 
    411         Add dummy `all' and `dvi' goals.  Reported by Tom Tromey. 
    412  
    413 Sat Nov 25 16:12:01 1995  Franc,ois Pinard  <pinard@iro.umontreal.ca> 
    414  
    415         * hash-string.h: Capitalize arguments of macros. 
    416  
    417 Sat Nov 25 12:01:36 1995  Ulrich Drepper  <drepper@myware> 
    418  
    419         * Makefile.in (DISTFILES): Prevent files names longer than 13 
    420         characters.  libintl.h.glibc->libintl.glibc, 
    421         libintl.h.install->libintl.inst.  Reported by Joshua R. Poulson. 
    422  
    423 Sat Nov 25 11:31:12 1995  Eric Backus  <ericb@lsid.hp.com> 
    424  
    425         * dcgettext.c: Fix bug in preprocessor conditionals. 
    426  
    427 Sat Nov 25 02:35:27 1995  Nelson H. F. Beebe  <beebe@math.utah.edu> 
    428  
    429         * libgettext.h: Solaris cc does not understand 
    430          #if !SYMBOL1 && !SYMBOL2.  Sad but true. 
    431  
    432 Thu Nov 23 16:22:14 1995  Ulrich Drepper  <drepper@myware> 
    433  
    434         * hash-string.h (hash_string): 
    435         Fix for machine with >32 bit `unsigned long's. 
    436  
    437         * dcgettext.c (DCGETTEXT): 
    438         Fix horrible bug in loop for alternative translation. 
    439  
    440 Thu Nov 23 01:45:29 1995  Ulrich Drepper  <drepper@myware> 
    441  
    442         * po2tbl.sed.in, linux-msg.sed, xopen-msg.sed: 
    443         Some further simplifications in message number generation. 
    444  
    445 Mon Nov 20 21:08:43 1995  Ulrich Drepper  <drepper@myware> 
    446  
    447         * libintl.h.glibc: Use __const instead of const in prototypes. 
    448  
    449         * Makefile.in (install-src): 
    450         Install libintl.h.install instead of libintl.h.  This 
    451         is a stripped-down version.  Suggested by Peter Miller. 
    452  
    453         * libintl.h.install, libintl.h.glibc: Initial revision. 
    454  
    455         * localealias.c (_nl_expand_alias, read_alias_file): 
    456         Protect prototypes in type casts by __P. 
    457  
    458 Tue Nov 14 16:43:58 1995  Ulrich Drepper  <drepper@myware> 
    459  
    460         * hash-string.h: Correct prototype for hash_string. 
    461  
    462 Sun Nov 12 12:42:30 1995  Ulrich Drepper  <drepper@myware> 
    463  
    464         * hash-string.h (hash_string): Add prototype. 
    465  
    466         * gettextP.h: Fix copyright. 
    467         (SWAP): Add prototype. 
    468  
    469 Wed Nov  8 22:56:33 1995  Ulrich Drepper  <drepper@myware> 
    470  
    471         * localealias.c (read_alias_file): Forgot sizeof. 
    472         Avoid calling *printf function.  This introduces a big overhead. 
    473         Patch by Roland McGrath. 
    474  
    475 Tue Nov  7 14:21:08 1995  Ulrich Drepper  <drepper@myware> 
    476  
    477         * finddomain.c, cat-compat.c: Wrong indentation in #if for stpcpy. 
    478  
    479         * finddomain.c (stpcpy): 
    480         Define substitution function local.  The macro was to flaky. 
    481  
    482         * cat-compat.c: Fix typo. 
    483  
    484         * xopen-msg.sed, linux-msg.sed: 
    485         While bringing message number to right place only accept digits. 
    486  
    487         * linux-msg.sed, xopen-msg.sed: Now that the counter does not have 
    488         leading 0s we don't need to remove them.  Reported by Marcus 
    489         Daniels. 
    490  
    491         * Makefile.in (../po/cat-id-tbl.o): Use $(top_srdir) in 
    492         dependency.  Reported by Marcus Daniels. 
    493  
    494         * cat-compat.c: (stpcpy) [!_LIBC && !HAVE_STPCPY]: Define replacement. 
    495         Generally cleanup using #if instead of #ifndef. 
    496  
    497         * Makefile.in: Correct typos in comment.  By Franc,ois Pinard. 
    498  
    499 Mon Nov  6 00:27:02 1995  Ulrich Drepper  <drepper@myware> 
    500  
    501         * Makefile.in (install-src): Don't install libintl.h and libintl.a 
    502         if we use an available gettext implementation. 
    503  
    504 Sun Nov  5 22:02:08 1995  Ulrich Drepper  <drepper@myware> 
    505  
    506         * libgettext.h: Fix typo: HAVE_CATGETTS -> HAVE_CATGETS.  Reported 
    507         by Franc,ois Pinard. 
    508  
    509         * libgettext.h: Use #if instead of #ifdef/#ifndef. 
    510  
    511         * finddomain.c: 
    512         Comments describing what has to be done should start with FIXME. 
    513  
    514 Sun Nov  5 19:38:01 1995  Ulrich Drepper  <drepper@myware> 
    515  
    516         * Makefile.in (DISTFILES): Split.  Use DISTFILES with normal meaning. 
    517         DISTFILES.common names the files common to both dist goals. 
    518         DISTFILES.gettext are the files only distributed in GNU gettext. 
    519  
    520 Sun Nov  5 17:32:54 1995  Ulrich Drepper  <drepper@myware> 
    521  
    522         * dcgettext.c (DCGETTEXT): Correct searching in derived locales. 
    523         This was necessary since a change in _nl_find_msg several weeks 
    524         ago.  I really don't know this is still not fixed. 
    525  
    526 Sun Nov  5 12:43:12 1995  Ulrich Drepper  <drepper@myware> 
    527  
    528         * loadmsgcat.c (_nl_load_domain): Test for FILENAME == NULL.  This 
    529         might mark a special condition. 
    530  
    531         * finddomain.c (make_entry_rec): Don't make illegal entry as decided. 
    532  
    533         * Makefile.in (dist): Suppress error message when ln failed. 
    534         Get files from $(srcdir) explicitly. 
    535  
    536         * libgettext.h (gettext_const): Rename to gettext_noop. 
    537  
    538 Fri Nov  3 07:36:50 1995  Ulrich Drepper  <drepper@myware> 
    539  
    540         * finddomain.c (make_entry_rec): 
    541         Protect against wrong locale names by testing mask. 
    542  
    543         * libgettext.h (gettext_const): Add macro definition. 
    544         Capitalize macro arguments. 
    545  
    546 Thu Nov  2 23:15:51 1995  Ulrich Drepper  <drepper@myware> 
    547  
    548         * finddomain.c (_nl_find_domain): 
    549         Test for pointer != NULL before accessing value. 
    550         Reported by Tom Tromey. 
    551  
    552         * gettext.c (NULL): 
    553         Define as (void*)0 instad of 0.  Reported by Franc,ois Pinard. 
    554  
    555 Mon Oct 30 21:28:52 1995  Ulrich Drepper  <drepper@myware> 
    556  
    557         * po2tbl.sed.in: Serious typo bug fixed by Jim Meyering. 
    558  
    559 Sat Oct 28 23:20:47 1995  Ulrich Drepper  <drepper@myware> 
    560  
    561         * libgettext.h: Disable dcgettext optimization for Solaris 2.3. 
    562  
    563         * localealias.c (alias_compare): 
    564         Peter Miller reported that tolower in some systems is 
    565         even dumber than I thought.  Protect call by `isupper'. 
    566  
    567 Fri Oct 27 22:22:51 1995  Ulrich Drepper  <drepper@myware> 
    568  
    569         * Makefile.in (libdir, includedir): New variables. 
    570         (install-src): Install libintl.a and libintl.h in correct dirs. 
    571  
    572 Fri Oct 27 22:07:29 1995  Ulrich Drepper  <drepper@myware> 
    573  
    574         * Makefile.in (SOURCES): Fix typo: intrl.compat.c -> intl-compat.c. 
    575  
    576         * po2tbl.sed.in: Patch for buggy SEDs by Christian von Roques. 
    577  
    578         * localealias.c: 
    579         Fix typo and superflous test.  Reported by Christian von Roques. 
    580  
    581 Fri Oct  6 11:52:05 1995  Ulrich Drepper  <drepper@myware> 
    582  
    583         * finddomain.c (_nl_find_domain): 
    584         Correct some remainder from the pre-CEN syntax.  Now 
    585         we don't have a constant number of successors anymore. 
    586  
    587 Wed Sep 27 21:41:13 1995  Ulrich Drepper  <drepper@myware> 
    588  
    589         * Makefile.in (DISTFILES): Add libintl.h.glibc. 
    590  
    591         * Makefile.in (dist-libc): Add goal for packing sources for glibc. 
    592         (COMSRCS, COMHDRS): Splitted to separate sources shared with glibc. 
    593  
    594         * loadmsgcat.c: Forget to continue #if line. 
    595  
    596         * localealias.c: 
    597         [_LIBC]: Rename strcasecmp to __strcasecmp to keep ANSI C name 
    598         space clean. 
    599  
    600         * dcgettext.c, finddomain.c: Better comment to last change. 
    601  
    602         * loadmsgcat.c: 
    603         [_LIBC]: Rename fstat, open, close, read, mmap, and munmap to 
    604         __fstat, __open, __close, __read, __mmap, and __munmap resp 
    605         to keep ANSI C name space clean. 
    606  
    607         * finddomain.c: 
    608         [_LIBC]: Rename stpcpy to __stpcpy to keep ANSI C name space clean. 
    609  
    610         * dcgettext.c: 
    611         [_LIBC]: Rename getced and stpcpy to __getcwd and __stpcpy resp to 
    612         keep ANSI C name space clean. 
    613  
    614         * libgettext.h: 
    615         Include sys/types.h for those old SysV systems out there. 
    616         Reported by Francesco Potorti`. 
    617  
    618         * loadmsgcat.c (use_mmap): Define if compiled for glibc. 
    619  
    620         * bindtextdom.c: Include all those standard headers 
    621         unconditionally if _LIBC is defined. 
    622  
    623         * finddomain.c: Fix 2 times defiend -> defined. 
    624  
    625         * textdomain.c: Include libintl.h instead of libgettext.h when 
    626         compiling for glibc.  Include all those standard headers 
    627         unconditionally if _LIBC is defined. 
    628  
    629         * localealias.c, loadmsgcat.c: Prepare to be compiled in glibc. 
    630  
    631         * gettext.c: 
    632         Include libintl.h instead of libgettext.h when compiling for glibc. 
    633         Get NULL from stddef.h if we compile for glibc. 
    634  
    635         * finddomain.c: Include libintl.h instead of libgettext.h when 
    636         compiling for glibc.  Include all those standard headers 
    637         unconditionally if _LIBC is defined. 
    638  
    639         * dcgettext.c: Include all those standard headers unconditionally 
    640         if _LIBC is defined. 
    641  
    642         * dgettext.c: If compiled in glibc include libintl.h instead of 
    643         libgettext.h. 
    644         (locale.h): Don't rely on HAVE_LOCALE_H when compiling for glibc. 
    645  
    646         * dcgettext.c: If compiled in glibc include libintl.h instead of 
    647         libgettext.h. 
    648         (getcwd): Don't rely on HAVE_GETCWD when compiling for glibc. 
    649  
    650         * bindtextdom.c: 
    651         If compiled in glibc include libintl.h instead of libgettext.h. 
    652  
    653 Mon Sep 25 22:23:06 1995  Ulrich Drepper  <drepper@myware> 
    654  
    655         * localealias.c (_nl_expand_alias): Don't call bsearch if NMAP <= 0. 
    656         Reported by Marcus Daniels. 
    657  
    658         * cat-compat.c (bindtextdomain): 
    659         String used in putenv must not be recycled. 
    660         Reported by Marcus Daniels. 
    661  
    662         * libgettext.h (__USE_GNU_GETTEXT): 
    663         Additional symbol to signal that we use GNU gettext 
    664         library. 
    665  
    666         * cat-compat.c (bindtextdomain): 
    667         Fix bug with the strange stpcpy replacement. 
    668         Reported by Nelson Beebe. 
    669  
    670 Sat Sep 23 08:23:51 1995  Ulrich Drepper  <drepper@myware> 
    671  
    672         * cat-compat.c: Include <string.h> for stpcpy prototype. 
    673  
    674         * localealias.c (read_alias_file): 
    675         While expand strdup code temporary variable `cp' hided 
    676         higher level variable with same name.  Rename to `tp'. 
    677  
    678         * textdomain.c (textdomain): 
    679         Avoid warning by using temporary variable in strdup code. 
    680  
    681         * finddomain.c (_nl_find_domain): Remove unused variable `application'. 
    682  
    683 Thu Sep 21 15:51:44 1995  Ulrich Drepper  <drepper@myware> 
    684  
    685         * localealias.c (alias_compare): 
    686         Use strcasecmp() only if available.  Else use 
    687         implementation in place. 
    688  
    689         * intl-compat.c: 
    690         Wrapper functions now call *__ functions instead of __*. 
    691  
    692         * libgettext.h: Declare prototypes for *__ functions instead for __*. 
    693  
    694         * cat-compat.c, loadmsgcat.c: 
    695         Don't use xmalloc, xstrdup, and stpcpy.  These functions are not part 
    696         of the standard libc and so prevent libintl.a from being used 
    697         standalone. 
    698  
    699         * bindtextdom.c: 
    700         Don't use xmalloc, xstrdup, and stpcpy.  These functions are not part 
    701         of the standard libc and so prevent libintl.a from being used 
    702         standalone. 
    703         Rename to bindtextdomain__ if not used in GNU C Library. 
    704  
    705         * dgettext.c: 
    706         Rename function to dgettext__ if not used in GNU C Library. 
    707  
    708         * gettext.c: 
    709         Don't use xmalloc, xstrdup, and stpcpy.  These functions are not part 
    710         of the standard libc and so prevent libintl.a from being used 
    711         standalone. 
    712         Functions now called gettext__ if not used in GNU C Library. 
    713  
    714         * dcgettext.c, localealias.c, textdomain.c, finddomain.c: 
    715         Don't use xmalloc, xstrdup, and stpcpy.  These functions are not part 
    716         of the standard libc and so prevent libintl.a from being used 
    717         standalone. 
    718  
    719 Sun Sep 17 23:14:49 1995  Ulrich Drepper  <drepper@myware> 
    720  
    721         * finddomain.c: Correct some bugs in handling of CEN standard 
    722         locale definitions. 
    723  
    724 Thu Sep  7 01:49:28 1995  Ulrich Drepper  <drepper@myware> 
    725  
    726         * finddomain.c: Implement CEN syntax. 
    727  
    728         * gettextP.h (loaded_domain): Extend number of successors to 31. 
    729  
    730 Sat Aug 19 19:25:29 1995  Ulrich Drepper  <drepper@myware> 
    731  
    732         * Makefile.in (aliaspath): Remove path to X11 locale dir. 
    733  
    734         * Makefile.in: Make install-src depend on install.  This helps 
    735         gettext to install the sources and other packages can use the 
    736         install goal. 
    737  
    738 Sat Aug 19 15:19:33 1995  Ulrich Drepper  <drepper@myware> 
    739  
    740         * Makefile.in (uninstall): Remove stuff installed by install-src. 
    741  
    742 Tue Aug 15 13:13:53 1995  Ulrich Drepper  <drepper@myware> 
    743  
    744         * VERSION.in: Initial revision. 
    745  
    746         * Makefile.in (DISTFILES): 
    747         Add VERSION file.  This is not necessary for gettext, but 
    748         for other packages using this library. 
    749  
    750 Tue Aug 15 06:16:44 1995  Ulrich Drepper  <drepper@myware> 
    751  
    752         * gettextP.h (_nl_find_domain): 
    753         New prototype after changing search strategy. 
    754  
    755         * finddomain.c (_nl_find_domain): 
    756         We now try only to find a specified catalog.  Fall back to other 
    757         catalogs listed in the locale list is now done in __dcgettext. 
    758  
    759         * dcgettext.c (__dcgettext): 
    760         Now we provide message fall back even to different languages. 
    761         I.e. if a message is not available in one language all the other 
    762         in the locale list a tried.  Formerly fall back was only possible 
    763         within one language.  Implemented by moving one loop from 
    764         _nl_find_domain to here. 
    765  
    766 Mon Aug 14 23:45:50 1995  Ulrich Drepper  <drepper@myware> 
    767  
    768         * Makefile.in (gettextsrcdir): 
    769         Directory where source of GNU gettext library are made 
    770         available. 
    771         (INSTALL, INSTALL_DATA): Programs used for installing sources. 
    772         (gettext-src): New.  Rule to install GNU gettext sources for use in 
    773         gettextize shell script. 
    774  
    775 Sun Aug 13 14:40:48 1995  Ulrich Drepper  <drepper@myware> 
    776  
    777         * loadmsgcat.c (_nl_load_domain): 
    778         Use mmap for loading only when munmap function is 
    779         also available. 
    780  
    781         * Makefile.in (install): Depend on `all' goal. 
    782  
    783 Wed Aug  9 11:04:33 1995  Ulrich Drepper  <drepper@myware> 
    784  
    785         * localealias.c (read_alias_file): 
    786         Do not overwrite '\n' when terminating alias value string. 
    787  
    788         * localealias.c (read_alias_file): 
    789         Handle long lines.  Ignore the rest not fitting in 
    790         the buffer after the initial `fgets' call. 
    791  
    792 Wed Aug  9 00:54:29 1995  Ulrich Drepper  <drepper@myware> 
    793  
    794         * gettextP.h (_nl_load_domain): 
    795         Add prototype, replacing prototype for _nl_load_msg_cat. 
    796  
    797         * finddomain.c (_nl_find_domain): 
    798         Remove unneeded variable filename and filename_len. 
    799         (expand_alias): Remove prototype because functions does not 
    800         exist anymore. 
    801  
    802         * localealias.c (read_alias_file): 
    803         Change type of fname_len parameter to int. 
    804         (xmalloc): Add prototype. 
    805  
    806         * loadmsgcat.c: Better prototypes for xmalloc. 
    807  
    808 Tue Aug  8 22:30:39 1995  Ulrich Drepper  <drepper@myware> 
    809  
    810         * finddomain.c (_nl_find_domain): 
    811         Allow alias name to be constructed from the four components. 
    812  
    813         * Makefile.in (aliaspath): New variable.  Set to preliminary value. 
    814         (SOURCES): Add localealias.c. 
    815         (OBJECTS): Add localealias.o. 
    816  
    817         * gettextP.h: Add prototype for _nl_expand_alias. 
    818  
    819         * finddomain.c: Aliasing handled in intl/localealias.c. 
    820  
    821         * localealias.c: Aliasing for locale names. 
    822  
    823         * bindtextdom.c: Better prototypes for xmalloc and xstrdup. 
    824  
    825 Mon Aug  7 23:47:42 1995  Ulrich Drepper  <drepper@myware> 
    826  
    827         * Makefile.in (DISTFILES): gettext.perl is now found in misc/. 
    828  
    829         * cat-compat.c (bindtextdomain): 
    830         Correct implementation.  dirname parameter was not used. 
    831         Reported by Marcus Daniels. 
    832  
    833         * gettextP.h (loaded_domain): 
    834         New fields `successor' and `decided' for oo, lazy 
    835         message handling implementation. 
    836  
    837         * dcgettext.c: 
    838         Adopt for oo, lazy message handliing. 
    839         Now we can inherit translations from less specific locales. 
    840         (find_msg): New function. 
    841  
    842         * loadmsgcat.c, finddomain.c: 
    843         Complete rewrite.  Implement oo, lazy message handling :-). 
    844         We now have an additional environment variable `LANGUAGE' with 
    845         a higher priority than LC_ALL for the LC_MESSAGE locale. 
    846         Here we can set a colon separated list of specifications each 
    847         of the form `language[_territory[.codeset]][@modifier]'. 
    848  
    849 Sat Aug  5 09:55:42 1995  Ulrich Drepper  <drepper@myware> 
    850  
    851         * finddomain.c (unistd.h): 
    852         Include to get _PC_PATH_MAX defined on system having it. 
    853  
    854 Fri Aug  4 22:42:00 1995  Ulrich Drepper  <drepper@myware> 
    855  
    856         * finddomain.c (stpcpy): Include prototype. 
    857  
    858         * Makefile.in (dist): Remove `copying instead' message. 
    859  
    860 Wed Aug  2 18:52:03 1995  Ulrich Drepper  <drepper@myware> 
    861  
    862         * Makefile.in (ID, TAGS): Do not use $^. 
    863  
    864 Tue Aug  1 20:07:11 1995  Ulrich Drepper  <drepper@myware> 
    865  
    866         * Makefile.in (TAGS, ID): Use $^ as command argument. 
    867         (TAGS): Give etags -o option t write to current directory, 
    868         not $(srcdir). 
    869         (ID): Use $(srcdir) instead os $(top_srcdir)/src. 
    870         (distclean): Remove ID. 
    871  
    872 Sun Jul 30 11:51:46 1995  Ulrich Drepper  <drepper@myware> 
    873  
    874         * Makefile.in (gnulocaledir): 
    875         New variable, always using share/ for data directory. 
    876         (DEFS): Add GNULOCALEDIR, used in finddomain.c. 
    877  
    878         * finddomain.c (_nl_default_dirname): 
    879         Set to GNULOCALEDIR, because it always has to point 
    880         to the directory where GNU gettext Library writes it to. 
    881  
    882         * intl-compat.c (textdomain, bindtextdomain): 
    883         Undefine macros before function definition. 
    884  
    885 Sat Jul 22 01:10:02 1995  Ulrich Drepper  <drepper@myware> 
    886  
    887         * libgettext.h (_LIBINTL_H): 
    888         Protect definition in case where this file is included as 
    889         libgettext.h on Solaris machines.  Add comment about this. 
    890  
    891 Wed Jul 19 02:36:42 1995  Ulrich Drepper  <drepper@myware> 
    892  
    893         * intl-compat.c (textdomain): Correct typo. 
    894  
    895 Wed Jul 19 01:51:35 1995  Ulrich Drepper  <drepper@myware> 
    896  
    897         * dcgettext.c (dcgettext): Function now called __dcgettext. 
    898  
    899         * dgettext.c (dgettext): Now called __dgettext and calls 
    900         __dcgettext. 
    901  
    902         * gettext.c (gettext): 
    903         Function now called __gettext and calls __dgettext. 
    904  
    905         * textdomain.c (textdomain): Function now called __textdomain. 
    906  
    907         * bindtextdom.c (bindtextdomain): Function now called 
    908         __bindtextdomain. 
    909  
    910         * intl-compat.c: Initial revision. 
    911  
    912         * Makefile.in (SOURCES): Add intl-compat.c. 
    913         (OBJECTS): We always compile the GNU gettext library functions. 
    914         OBJECTS contains all objects but cat-compat.o, ../po/cat-if-tbl.o, 
    915         and intl-compat.o. 
    916         (GETTOBJS): Contains now only intl-compat.o. 
    917  
    918         * libgettext.h: 
    919         Re-include protection matches dualistic character of libgettext.h. 
    920         For all functions in GNU gettext library define __ counter part. 
    921  
    922         * finddomain.c (strchr): Define as index if not found in C library. 
    923         (_nl_find_domain): For relative paths paste / in between. 
    924  
    925 Tue Jul 18 16:37:45 1995  Ulrich Drepper  <drepper@myware> 
    926  
    927         * loadmsgcat.c, finddomain.c: Add inclusion of sys/types.h. 
    928  
    929         * xopen-msg.sed: Fix bug with `msgstr ""' lines. 
    930         A little bit better comments. 
    931  
    932 Tue Jul 18 01:18:27 1995  Ulrich Drepper  <drepper@myware> 
    933  
    934         * Makefile.in: 
    935         po-mode.el, makelinks, combine-sh are now found in ../misc. 
    936  
    937         * po-mode.el, makelinks, combine-sh, elisp-comp: 
    938         Moved to ../misc/. 
    939  
    940         * libgettext.h, gettextP.h, gettext.h: Uniform test for __STDC__. 
    941  
    942 Sun Jul 16 22:33:02 1995  Ulrich Drepper  <drepper@myware> 
    943  
    944         * Makefile.in (INSTALL, INSTALL_DATA): New variables. 
    945         (install-data, uninstall): Install/uninstall .elc file. 
    946  
    947         * po-mode.el (Installation comment): 
    948         Add .pox as possible extension of .po files. 
    949  
    950 Sun Jul 16 13:23:27 1995  Ulrich Drepper  <drepper@myware> 
    951  
    952         * elisp-comp: Complete new version by Franc,ois: This does not 
    953         fail when not compiling in the source directory. 
    954  
    955 Sun Jul 16 00:12:17 1995  Ulrich Drepper  <drepper@myware> 
    956  
    957         * Makefile.in (../po/cat-id-tbl.o): 
    958         Use $(MAKE) instead of make for recursive make. 
    959  
    960         * Makefile.in (.el.elc): Use $(SHELL) instead of /bin/sh. 
    961         (install-exec): Add missing dummy goal. 
    962         (install-data, uninstall): @ in multi-line shell command at 
    963         beginning, not in front of echo.  Reported by Eric Backus. 
    964  
    965 Sat Jul 15 00:21:28 1995  Ulrich Drepper  <drepper@myware> 
    966  
    967         * Makefile.in (DISTFILES): 
    968         Rename libgettext.perl to gettext.perl to fit in 14 chars 
    969         file systems. 
    970  
    971         * gettext.perl: 
    972         Rename to gettext.perl to fit in 14 chars file systems. 
    973  
    974 Thu Jul 13 23:17:20 1995  Ulrich Drepper  <drepper@myware> 
    975  
    976         * cat-compat.c: If !STDC_HEADERS try to include malloc.h. 
    977  
    978 Thu Jul 13 20:55:02 1995  Ulrich Drepper  <drepper@myware> 
    979  
    980         * po2tbl.sed.in: Pretty printing. 
    981  
    982         * linux-msg.sed, xopen-msg.sed: 
    983         Correct bugs with handling substitute flags in branches. 
    984  
    985         * hash-string.h (hash_string): 
    986         Old K&R compilers don't under stand `unsigned char'. 
    987  
    988         * gettext.h (nls_uint32): 
    989         Some old K&R compilers (eg HP) don't understand `unsigned int'. 
    990  
    991         * cat-compat.c (msg_to_cat_id): De-ANSI-fy prototypes. 
    992  
    993 Thu Jul 13 01:34:33 1995  Ulrich Drepper  <drepper@myware> 
    994  
    995         * Makefile.in (ELCFILES): New variable. 
    996         (DISTFILES): Add elisp-comp. 
    997         Add implicit rule for .el -> .elc compilation. 
    998         (install-data): install $ELCFILES 
    999         (clean): renamed po-to-tbl and po-to-msg to po2tbl and po2msg resp. 
    1000  
    1001         * elisp-comp: Initial revision 
    1002  
    1003 Wed Jul 12 16:14:52 1995  Ulrich Drepper  <drepper@myware> 
    1004  
    1005         * Makefile.in: 
    1006         cat-id-tbl.c is now found in po/.  This enables us to use an identical 
    1007         intl/ directory in all packages. 
    1008  
    1009         * dcgettext.c (dcgettext): hashing does not work for table size <= 2. 
    1010  
    1011         * textdomain.c: fix typo (#if def -> #if defined) 
    1012  
    1013 Tue Jul 11 18:44:43 1995  Ulrich Drepper  <drepper@myware> 
    1014  
    1015         * Makefile.in (stamp-cat-id): use top_srcdir to address source files 
    1016         (DISTFILES,distclean): move tupdate.perl to src/ 
    1017  
    1018         * po-to-tbl.sed.in: 
    1019         add additional jump to clear change flag to recognize multiline strings 
    1020  
    1021 Tue Jul 11 01:32:50 1995  Ulrich Drepper  <drepper@myware> 
    1022  
    1023         * textdomain.c: Protect inclusion of stdlib.h and string.h. 
    1024  
    1025         * loadmsgcat.c: Protect inclusion of stdlib.h. 
    1026  
    1027         * libgettext.h: Protect inclusion of locale.h. 
    1028         Allow use in C++ programs. 
    1029         Define NULL is not happened already. 
    1030  
    1031         * Makefile.in (DISTFILES): ship po-to-tbl.sed.in instead of 
    1032         po-to-tbl.sed. 
    1033         (distclean): remove po-to-tbl.sed and tupdate.perl. 
    1034  
    1035         * tupdate.perl.in: Substitute Perl path even in exec line. 
    1036         Don't include entries without translation from old .po file. 
    1037  
    1038 Tue Jul  4 00:41:51 1995  Ulrich Drepper  <drepper@myware> 
    1039  
    1040         * tupdate.perl.in: use "Updated: " in msgid "". 
    1041  
    1042         * cat-compat.c: Fix typo (LOCALDIR -> LOCALEDIR). 
    1043         Define getenv if !__STDC__. 
    1044  
    1045         * bindtextdom.c: Protect stdlib.h and string.h inclusion. 
    1046         Define free if !__STDC__. 
    1047  
    1048         * finddomain.c: Change DEF_MSG_DOM_DIR to LOCALEDIR. 
    1049         Define free if !__STDC__. 
    1050  
    1051         * cat-compat.c: Change DEF_MSG_DOM_DIR to LOCALEDIR. 
    1052  
    1053 Mon Jul  3 23:56:30 1995  Ulrich Drepper  <drepper@myware> 
    1054  
    1055         * Makefile.in: Use LOCALEDIR instead of DEF_MSG_DOM_DIR. 
    1056         Remove unneeded $(srcdir) from Makefile.in dependency. 
    1057  
    1058         * makelinks: Add copyright and short description. 
    1059  
    1060         * po-mode.el: Last version for 0.7. 
    1061  
    1062         * tupdate.perl.in: Fix die message. 
    1063  
    1064         * dcgettext.c: Protect include of string.h. 
    1065  
    1066         * gettext.c: Protect include of stdlib.h and further tries to get NULL. 
    1067  
    1068         * finddomain.c: Some corrections in includes. 
    1069  
    1070         * Makefile.in (INCLUDES): Prune list correct path to Makefile.in. 
    1071  
    1072         * po-to-tbl.sed: Adopt for new .po file format. 
    1073  
    1074         * linux-msg.sed, xopen-msg.sed: Adopt for new .po file format. 
    1075  
    1076 Sun Jul  2 23:55:03 1995  Ulrich Drepper  <drepper@myware> 
    1077  
    1078         * tupdate.perl.in: Complete rewrite for new .po file format. 
    1079  
    1080 Sun Jul  2 02:06:50 1995  Ulrich Drepper  <drepper@myware> 
    1081  
    1082         * First official release.  This directory contains all the code 
    1083         needed to internationalize own packages.  It provides functions 
    1084         which allow to use the X/Open catgets function with an interface 
    1085         like the Uniforum gettext function.  For system which does not 
    1086         have neither of those a complete implementation is provided. 
  • trunk/sweep/intl/Makefile.in

    r84 r124  
    11# Makefile for directory with message catalog handling in GNU NLS Utilities. 
    2 # Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. 
     2# Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. 
    33# 
    4 # This program is free software; you can redistribute it and/or modify 
    5 # it under the terms of the GNU General Public License as published by 
    6 # the Free Software Foundation; either version 2, or (at your option) 
     4# This program is free software; you can redistribute it and/or modify it 
     5# under the terms of the GNU Library General Public License as published 
     6# by the Free Software Foundation; either version 2, or (at your option) 
    77# any later version. 
    88# 
    99# This program is distributed in the hope that it will be useful, 
    1010# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    12 # GNU General Public License for more details. 
     11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     12# Library General Public License for more details. 
    1313# 
    14 # You should have received a copy of the GNU General Public License 
    15 # along with this program; if not, write to the Free Software 
    16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
     14# You should have received a copy of the GNU Library General Public 
     15# License along with this program; if not, write to the Free Software 
     16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     17# USA. 
    1718 
    1819PACKAGE = @PACKAGE@ 
     
    2930exec_prefix = @exec_prefix@ 
    3031transform = @program_transform_name@ 
    31 libdir = $(exec_prefix)/lib 
    32 includedir = $(prefix)/include 
    33 datadir = $(prefix)/@DATADIRNAME
     32libdir = @libdir@ 
     33includedir = @includedir@ 
     34datadir = @datadir
    3435localedir = $(datadir)/locale 
    35 gnulocaledir = $(prefix)/share/locale 
    36 gettextsrcdir = @datadir@/gettext/intl 
    37 aliaspath = $(localedir):. 
     36gettextsrcdir = $(datadir)/gettext/intl 
     37aliaspath = $(localedir) 
    3838subdir = intl 
    3939 
     
    4141INSTALL_DATA = @INSTALL_DATA@ 
    4242MKINSTALLDIRS = @MKINSTALLDIRS@ 
    43  
    44 l = @l@ 
     43mkinstalldirs = $(SHELL) `case "$(MKINSTALLDIRS)" in /*) echo "$(MKINSTALLDIRS)" ;; *) echo "$(top_builddir)/$(MKINSTALLDIRS)" ;; esac` 
     44 
     45l = @INTL_LIBTOOL_SUFFIX_PREFIX@ 
    4546 
    4647AR = ar 
     
    4849LIBTOOL = @LIBTOOL@ 
    4950RANLIB = @RANLIB@ 
    50  
    51 DEFS = -DLOCALEDIR=\"$(localedir)\" -DGNULOCALEDIR=\"$(gnulocaledir)\" \ 
    52 -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" @DEFS@ 
     51YACC = @INTLBISON@ -y -d 
     52YFLAGS = --name-prefix=__gettext 
     53 
     54DEFS = -DLOCALEDIR=\"$(localedir)\" -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \ 
     55-DLIBDIR=\"$(libdir)\" @DEFS@ 
    5356CPPFLAGS = @CPPFLAGS@ 
    5457CFLAGS = @CFLAGS@ 
     
    5760COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) 
    5861 
    59 HEADERS = $(COMHDRS) libgettext.h loadinfo.h 
     62HEADERS = $(COMHDRS) libgnuintl.h libgettext.h loadinfo.h 
    6063COMHDRS = gettext.h gettextP.h hash-string.h 
    61 SOURCES = $(COMSRCS) intl-compat.c cat-compat.c 
     64SOURCES = $(COMSRCS) intl-compat.c 
    6265COMSRCS = bindtextdom.c dcgettext.c dgettext.c gettext.c \ 
    6366finddomain.c loadmsgcat.c localealias.c textdomain.c l10nflist.c \ 
    64 explodename.c 
     67explodename.c dcigettext.c dcngettext.c dngettext.c ngettext.c plural.y \ 
     68localcharset.c 
    6569OBJECTS = @INTLOBJS@ bindtextdom.$lo dcgettext.$lo dgettext.$lo gettext.$lo \ 
    6670finddomain.$lo loadmsgcat.$lo localealias.$lo textdomain.$lo l10nflist.$lo \ 
    67 explodename.$lo 
    68 CATOBJS = cat-compat.$lo ../po/cat-id-tbl.$lo 
     71explodename.$lo dcigettext.$lo dcngettext.$lo dngettext.$lo ngettext.$lo \ 
     72plural.$lo localcharset.$lo 
    6973GETTOBJS = intl-compat.$lo 
    70 DISTFILES.common = ChangeLog Makefile.in linux-msg.sed po2tbl.sed.in \ 
    71 xopen-msg.sed $(HEADERS) $(SOURCES) 
     74DISTFILES.common = Makefile.in \ 
     75config.charset locale.alias ref-add.sin ref-del.sin $(HEADERS) $(SOURCES) 
     76DISTFILES.generated = plural.c 
    7277DISTFILES.normal = VERSION 
    73 DISTFILES.gettext = libintl.glibc intlh.inst.in 
     78DISTFILES.gettext = COPYING.LIB-2 COPYING.LIB-2.1 libintl.glibc 
     79DISTFILES.obsolete = xopen-msg.sed linux-msg.sed po2tbl.sed.in cat-compat.c 
     80 
     81# Libtool's library version information for libintl. 
     82# Before making a gettext release, the gettext maintainer must change this 
     83# according to the libtool documentation, section "Library interface versions". 
     84# Maintainers of other packages that include the intl directory must *not* 
     85# change these values. 
     86LTV_CURRENT=1 
     87LTV_REVISION=1 
     88LTV_AGE=0 
    7489 
    7590.SUFFIXES: 
    76 .SUFFIXES: .c .o .lo 
     91.SUFFIXES: .c .y .o .lo .sin .sed 
    7792.c.o: 
    7893        $(COMPILE) $< 
     
    8095        $(LIBTOOL) --mode=compile $(COMPILE) $< 
    8196 
    82 INCLUDES = -I.. -I. -I$(top_srcdir)/intl -I$(top_srcdir)/include/sweep -I$(top_srcdir)/lib 
     97.y.c: 
     98        $(YACC) $(YFLAGS) --output $@ $< 
     99        rm -f $*.h 
     100 
     101.sin.sed: 
     102        sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $< > t-$@ 
     103        mv t-$@ $@ 
     104 
     105INCLUDES = -I.. -I. -I$(top_srcdir)/intl 
    83106 
    84107all: all-@USE_INCLUDED_LIBINTL@ 
    85  
    86 all-yes: libintl.$la intlh.inst 
    87 all-no: 
    88  
    89 libintl.a: $(OBJECTS) 
     108all-yes: libintl.$la libintl.h charset.alias ref-add.sed ref-del.sed 
     109all-no: all-no-@BUILD_INCLUDED_LIBINTL@ 
     110all-no-yes: libgnuintl.$la 
     111all-no-no: 
     112 
     113libintl.a libgnuintl.a: $(OBJECTS) 
    90114        rm -f $@ 
    91115        $(AR) cru $@ $(OBJECTS) 
    92116        $(RANLIB) $@ 
    93117 
    94 libintl.la: $(OBJECTS) 
    95         $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(OBJECTS) \ 
    96                    -version-info 1:0 -rpath $(libdir) 
    97  
    98 ../po/cat-id-tbl.$lo: ../po/cat-id-tbl.c $(top_srcdir)/po/$(PACKAGE).pot 
    99         cd ../po && $(MAKE) cat-id-tbl.$lo 
     118libintl.la libgnuintl.la: $(OBJECTS) 
     119        $(LIBTOOL) --mode=link \ 
     120          $(CC) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) $(LDFLAGS) -o $@ \ 
     121          $(OBJECTS) @LIBICONV@ \ 
     122          -version-info $(LTV_CURRENT):$(LTV_REVISION):$(LTV_AGE) \ 
     123          -rpath $(libdir) \ 
     124          -no-undefined 
     125 
     126libintl.h: libgnuintl.h 
     127        cp $(srcdir)/libgnuintl.h libintl.h 
     128 
     129charset.alias: config.charset 
     130        $(SHELL) $(srcdir)/config.charset '@host@' > t-$@ 
     131        mv t-$@ $@ 
    100132 
    101133check: all 
     
    105137 
    106138# We must not install the libintl.h/libintl.a files if we are on a 
    107 # system which has the gettext() function in its C library or in a 
    108 # separate library or use the catgets interface.  A special case is 
    109 # where configure found a previously installed GNU gettext library. 
     139# system which has the GNU gettext() function in its C library or in a 
     140# separate library. 
    110141# If you want to use the one which comes with this version of the 
    111142# package, you have to use `configure --with-included-gettext'. 
     
    114145        if test "$(PACKAGE)" = "gettext" \ 
    115146           && test '@INTLOBJS@' = '$(GETTOBJS)'; then \ 
    116           if test -r $(MKINSTALLDIRS); then \ 
    117             $(MKINSTALLDIRS) $(libdir) $(includedir); \ 
     147          $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \ 
     148          $(INSTALL_DATA) libintl.h $(DESTDIR)$(includedir)/libintl.h; \ 
     149          $(LIBTOOL) --mode=install \ 
     150            $(INSTALL_DATA) libintl.$la $(DESTDIR)$(libdir)/libintl.$la; \ 
     151        else \ 
     152          : ; \ 
     153        fi 
     154        if test '@USE_INCLUDED_LIBINTL@' = yes; then \ 
     155          $(mkinstalldirs) $(DESTDIR)$(libdir); \ 
     156          temp=$(DESTDIR)$(libdir)/t-charset.alias; \ 
     157          dest=$(DESTDIR)$(libdir)/charset.alias; \ 
     158          if test -f $(DESTDIR)$(libdir)/charset.alias; then \ 
     159            orig=$(DESTDIR)$(libdir)/charset.alias; \ 
     160            sed -f ref-add.sed $$orig > $$temp; \ 
     161            $(INSTALL_DATA) $$temp $$dest; \ 
     162            rm -f $$temp; \ 
    118163          else \ 
    119             $(top_srcdir)/mkinstalldirs $(libdir) $(includedir); \ 
     164            if test @GLIBC21@ = no; then \ 
     165              orig=charset.alias; \ 
     166              sed -f ref-add.sed $$orig > $$temp; \ 
     167              $(INSTALL_DATA) $$temp $$dest; \ 
     168              rm -f $$temp; \ 
     169            fi; \ 
    120170          fi; \ 
    121           $(INSTALL_DATA) intlh.inst $(includedir)/libintl.h; \ 
    122           $(INSTALL_DATA) libintl.a $(libdir)/libintl.a; \ 
     171          $(mkinstalldirs) $(DESTDIR)$(localedir); \ 
     172          test -f $(DESTDIR)$(localedir)/locale.alias \ 
     173            && orig=$(DESTDIR)$(localedir)/locale.alias \ 
     174            || orig=$(srcdir)/locale.alias; \ 
     175          temp=$(DESTDIR)$(localedir)/t-locale.alias; \ 
     176          dest=$(DESTDIR)$(localedir)/locale.alias; \ 
     177          sed -f ref-add.sed $$orig > $$temp; \ 
     178          $(INSTALL_DATA) $$temp $$dest; \ 
     179          rm -f $$temp; \ 
    123180        else \ 
    124181          : ; \ 
     
    126183install-data: all 
    127184        if test "$(PACKAGE)" = "gettext"; then \ 
    128           if test -r $(MKINSTALLDIRS); then \ 
    129             $(MKINSTALLDIRS) $(gettextsrcdir); \ 
    130           else \ 
    131             $(top_srcdir)/mkinstalldirs $(gettextsrcdir); \ 
    132           fi; \ 
    133           $(INSTALL_DATA) VERSION $(gettextsrcdir)/VERSION; \ 
    134           dists="$(DISTFILES.common)"; \ 
     185          $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \ 
     186          $(INSTALL_DATA) VERSION $(DESTDIR)$(gettextsrcdir)/VERSION; \ 
     187          $(INSTALL_DATA) ChangeLog.inst $(DESTDIR)$(gettextsrcdir)/ChangeLog; \ 
     188          dists="COPYING.LIB-2 COPYING.LIB-2.1 $(DISTFILES.common)"; \ 
    135189          for file in $$dists; do \ 
    136             $(INSTALL_DATA) $(srcdir)/$$file $(gettextsrcdir)/$$file; \ 
     190            $(INSTALL_DATA) $(srcdir)/$$file \ 
     191                            $(DESTDIR)$(gettextsrcdir)/$$file; \ 
     192          done; \ 
     193          chmod a+x $(DESTDIR)$(gettextsrcdir)/config.charset; \ 
     194          dists="$(DISTFILES.generated)"; \ 
     195          for file in $$dists; do \ 
     196            if test -f $$file; then dir=.; else dir=$(srcdir); fi; \ 
     197            $(INSTALL_DATA) $$dir/$$file \ 
     198                            $(DESTDIR)$(gettextsrcdir)/$$file; \ 
     199          done; \ 
     200          dists="$(DISTFILES.obsolete)"; \ 
     201          for file in $$dists; do \ 
     202            rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ 
    137203          done; \ 
    138204        else \ 
     
    144210 
    145211uninstall: 
    146         dists="$(DISTFILES.common)"; \ 
    147         for file in $$dists; do \ 
    148           rm -f $(gettextsrcdir)/$$file; \ 
    149         done 
     212        if test "$(PACKAGE)" = "gettext" \ 
     213           && test '@INTLOBJS@' = '$(GETTOBJS)'; then \ 
     214          rm -f $(DESTDIR)$(includedir)/libintl.h; \ 
     215          $(LIBTOOL) --mode=uninstall \ 
     216            rm -f $(DESTDIR)$(libdir)/libintl.$la; \ 
     217        else \ 
     218          : ; \ 
     219        fi 
     220        if test '@USE_INCLUDED_LIBINTL@' = yes; then \ 
     221          if test -f $(DESTDIR)$(libdir)/charset.alias; then \ 
     222            temp=$(DESTDIR)$(libdir)/t-charset.alias; \ 
     223            dest=$(DESTDIR)$(libdir)/charset.alias; \ 
     224            sed -f ref-del.sed $$dest > $$temp; \ 
     225            if grep '^# Packages using this file: $$' $$temp > /dev/null; then \ 
     226              rm -f $$dest; \ 
     227            else \ 
     228              $(INSTALL_DATA) $$temp $$dest; \ 
     229            fi; \ 
     230            rm -f $$temp; \ 
     231          fi; \ 
     232          if test -f $(DESTDIR)$(localedir)/locale.alias; then \ 
     233            temp=$(DESTDIR)$(localedir)/t-locale.alias; \ 
     234            dest=$(DESTDIR)$(localedir)/locale.alias; \ 
     235            sed -f ref-del.sed $$dest > $$temp; \ 
     236            if grep '^# Packages using this file: $$' $$temp > /dev/null; then \ 
     237              rm -f $$dest; \ 
     238            else \ 
     239              $(INSTALL_DATA) $$temp $$dest; \ 
     240            fi; \ 
     241            rm -f $$temp; \ 
     242          fi; \ 
     243        else \ 
     244          : ; \ 
     245        fi 
     246        if test "$(PACKAGE)" = "gettext"; then \ 
     247          for file in VERSION ChangeLog COPYING.LIB-2 COPYING.LIB-2.1 $(DISTFILES.common) $(DISTFILES.generated); do \ 
     248            rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ 
     249          done; \ 
     250        else \ 
     251          : ; \ 
     252        fi 
    150253 
    151254info dvi: 
    152255 
    153 $(OBJECTS): ../include/sweep/config.h libgettext.h 
     256$(OBJECTS): ../config.h libgnuintl.h 
    154257bindtextdom.$lo finddomain.$lo loadmsgcat.$lo: gettextP.h gettext.h loadinfo.h 
    155258dcgettext.$lo: gettextP.h gettext.h hash-string.h loadinfo.h 
     
    167270 
    168271mostlyclean: 
    169         rm -f *.a *.o *.lo core core.* 
     272        rm -f *.a *.la *.o *.lo core core.* 
     273        rm -f libintl.h charset.alias ref-add.sed ref-del.sed 
     274        rm -f -r .libs _libs 
    170275 
    171276clean: mostlyclean 
    172277 
    173278distclean: clean 
    174         rm -f Makefile ID TAGS po2msg.sed po2tbl.sed 
     279        rm -f Makefile ID TAGS 
     280        if test "$(PACKAGE)" = gettext; then \ 
     281          rm -f ChangeLog.inst $(DISTFILES.normal); \ 
     282        else \ 
     283          : ; \ 
     284        fi 
    175285 
    176286maintainer-clean: distclean 
     
    182292# other files which should not be distributed in other packages. 
    183293distdir = ../$(PACKAGE)-$(VERSION)/$(subdir) 
    184 dist distdir: Makefile $(DISTFILES) 
     294dist distdir: Makefile 
    185295        if test "$(PACKAGE)" = gettext; then \ 
    186296          additional="$(DISTFILES.gettext)"; \ 
     
    188298          additional="$(DISTFILES.normal)"; \ 
    189299        fi; \ 
    190         for file in $(DISTFILES.common) $$additional; do \ 
    191           ln $(srcdir)/$$file $(distdir) 2> /dev/null \ 
    192             || cp -p $(srcdir)/$$file $(distdir); \ 
     300        $(MAKE) $(DISTFILES.common) $(DISTFILES.generated) $$additional; \ 
     301        for file in ChangeLog $(DISTFILES.common) $(DISTFILES.generated) $$additional; do \ 
     302          if test -f $$file; then dir=.; else dir=$(srcdir); fi; \ 
     303          ln $$dir/$$file $(distdir) 2> /dev/null \ 
     304            || cp -p $$dir/$$file $(distdir); \ 
    193305        done 
    194  
    195 dist-libc: 
    196         tar zcvf intl-glibc.tar.gz $(COMSRCS) $(COMHDRS) libintl.h.glibc 
    197306 
    198307Makefile: Makefile.in ../config.status 
     
    200309          && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status 
    201310 
    202 # The dependency for intlh.inst is different in gettext and all other 
    203 # packages.  Because we cannot you GNU make features we have to solve 
    204 # the problem while rewriting Makefile.in. 
    205 @GT_YES@intlh.inst: intlh.inst.in ../config.status 
    206 @GT_YES@        cd .. \ 
    207 @GT_YES@        && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \ 
    208 @GT_YES@          $(SHELL) ./config.status 
    209 @GT_NO@.PHONY: intlh.inst 
    210 @GT_NO@intlh.inst: 
    211  
    212311# Tell versions [3.59,3.63) of GNU make not to export all variables. 
    213312# Otherwise a system limit (for SysV at least) may be exceeded. 
  • trunk/sweep/intl/VERSION

    r7 r124  
    1 GNU gettext library from gettext-0.10.35 
     1GNU gettext library from gettext-0.10.40 
  • trunk/sweep/intl/bindtextdom.c

    r7 r124  
    11/* Implementation of the bindtextdomain(3) function 
    2    Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 
    3  
    4    This program is free software; you can redistribute it and/or modify 
    5    it under the terms of the GNU General Public License as published by 
    6    the Free Software Foundation; either version 2, or (at your option) 
     2   Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. 
     3 
     4   This program is free software; you can redistribute it and/or modify it 
     5   under the terms of the GNU Library General Public License as published 
     6   by the Free Software Foundation; either version 2, or (at your option) 
    77   any later version. 
    88 
    99   This program is distributed in the hope that it will be useful, 
    1010   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    12    GNU General Public License for more details. 
    13  
    14    You should have received a copy of the GNU General Public License 
    15    along with this program; if not, write to the Free Software Foundation, 
    16    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
     11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     12   Library General Public License for more details. 
     13 
     14   You should have received a copy of the GNU Library General Public 
     15   License along with this program; if not, write to the Free Software 
     16   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     17   USA.  */ 
    1718 
    1819#ifdef HAVE_CONFIG_H 
     
    2021#endif 
    2122 
    22 #if defined STDC_HEADERS || defined _LIBC 
    23 # include <stdlib.h> 
    24 #else 
    25 # ifdef HAVE_MALLOC_H 
    26 #  include <malloc.h> 
    27 # else 
    28 void free (); 
    29 # endif 
    30 #endif 
    31  
    32 #if defined HAVE_STRING_H || defined _LIBC 
    33 # include <string.h> 
    34 #else 
    35 # include <strings.h> 
    36 # ifndef memcpy 
    37 #  define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) 
    38 # endif 
    39 #endif 
     23#include <stddef.h> 
     24#include <stdlib.h> 
     25#include <string.h> 
    4026 
    4127#ifdef _LIBC 
    4228# include <libintl.h> 
    4329#else 
    44 # include "libgettext.h" 
    45 #endif 
    46 #include "gettext.h" 
     30# include "libgnuintl.h" 
     31#endif 
    4732#include "gettextP.h" 
     33 
     34#ifdef _LIBC 
     35/* We have to handle multi-threaded applications.  */ 
     36# include <bits/libc-lock.h> 
     37#else 
     38/* Provide dummy implementation if this is outside glibc.  */ 
     39# define __libc_rwlock_define(CLASS, NAME) 
     40# define __libc_rwlock_wrlock(NAME) 
     41# define __libc_rwlock_unlock(NAME) 
     42#endif 
     43 
     44/* The internal variables in the standalone libintl.a must have different 
     45   names than the internal variables in GNU libc, otherwise programs 
     46   using libintl.a cannot be linked statically.  */ 
     47#if !defined _LIBC 
     48# define _nl_default_dirname _nl_default_dirname__ 
     49# define _nl_domain_bindings _nl_domain_bindings__ 
     50#endif 
     51 
     52/* Some compilers, like SunOS4 cc, don't have offsetof in <stddef.h>.  */ 
     53#ifndef offsetof 
     54# define offsetof(type,ident) ((size_t)&(((type*)0)->ident)) 
     55#endif 
    4856 
    4957/* @@ end of prolog @@ */ 
     
    5462/* List with bindings of specific domains.  */ 
    5563extern struct binding *_nl_domain_bindings; 
     64 
     65/* Lock variable to protect the global data in the gettext implementation.  */ 
     66__libc_rwlock_define (extern, _nl_state_lock) 
    5667 
    5768 
     
    6273#ifdef _LIBC 
    6374# define BINDTEXTDOMAIN __bindtextdomain 
     75# define BIND_TEXTDOMAIN_CODESET __bind_textdomain_codeset 
    6476# ifndef strdup 
    6577#  define strdup(str) __strdup (str) 
     
    6779#else 
    6880# define BINDTEXTDOMAIN bindtextdomain__ 
    69 #endif 
     81# define BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset__ 
     82#endif 
     83 
     84/* Prototypes for local functions.  */ 
     85static void set_binding_values PARAMS ((const char *domainname, 
     86                                        const char **dirnamep, 
     87                                        const char **codesetp)); 
     88      
     89/* Specifies the directory name *DIRNAMEP and the output codeset *CODESETP 
     90   to be used for the DOMAINNAME message catalog. 
     91   If *DIRNAMEP or *CODESETP is NULL, the corresponding attribute is not 
     92   modified, only the current value is returned. 
     93   If DIRNAMEP or CODESETP is NULL, the corresponding attribute is neither 
     94   modified nor returned.  */ 
     95static void 
     96set_binding_values (domainname, dirnamep, codesetp) 
     97     const char *domainname; 
     98     const char **dirnamep; 
     99     const char **codesetp; 
     100
     101  struct binding *binding; 
     102  int modified; 
     103 
     104  /* Some sanity checks.  */ 
     105  if (domainname == NULL || domainname[0] == '\0') 
     106    { 
     107      if (dirnamep) 
     108        *dirnamep = NULL; 
     109      if (codesetp) 
     110        *codesetp = NULL; 
     111      return; 
     112    } 
     113 
     114  __libc_rwlock_wrlock (_nl_state_lock); 
     115 
     116  modified = 0; 
     117 
     118  for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next) 
     119    { 
     120      int compare = strcmp (domainname, binding->domainname); 
     121      if (compare == 0) 
     122        /* We found it!  */ 
     123        break; 
     124      if (compare < 0) 
     125        { 
     126          /* It is not in the list.  */ 
     127          binding = NULL; 
     128          break; 
     129        } 
     130    } 
     131 
     132  if (binding != NULL) 
     133    { 
     134      if (dirnamep) 
     135        { 
     136          const char *dirname = *dirnamep; 
     137 
     138          if (dirname == NULL) 
     139            /* The current binding has be to returned.  */ 
     140            *dirnamep = binding->dirname; 
     141          else 
     142            { 
     143              /* The domain is already bound.  If the new value and the old 
     144                 one are equal we simply do nothing.  Otherwise replace the 
     145                 old binding.  */ 
     146              char *result = binding->dirname; 
     147              if (strcmp (dirname, result) != 0) 
     148                { 
     149                  if (strcmp (dirname, _nl_default_dirname) == 0) 
     150                    result = (char *) _nl_default_dirname; 
     151                  else 
     152                    { 
     153#if defined _LIBC || defined HAVE_STRDUP 
     154                      result = strdup (dirname); 
     155#else 
     156                      size_t len = strlen (dirname) + 1; 
     157                      result = (char *) malloc (len); 
     158                      if (__builtin_expect (result != NULL, 1)) 
     159                        memcpy (result, dirname, len); 
     160#endif 
     161                    } 
     162 
     163                  if (__builtin_expect (result != NULL, 1)) 
     164                    { 
     165                      if (binding->dirname != _nl_default_dirname) 
     166                        free (binding->dirname); 
     167 
     168                      binding->dirname = result; 
     169                      modified = 1; 
     170                    } 
     171                } 
     172              *dirnamep = result; 
     173            } 
     174        } 
     175 
     176      if (codesetp) 
     177        { 
     178          const char *codeset = *codesetp; 
     179 
     180          if (codeset == NULL) 
     181            /* The current binding has be to returned.  */ 
     182            *codesetp = binding->codeset; 
     183          else 
     184            { 
     185              /* The domain is already bound.  If the new value and the old 
     186                 one are equal we simply do nothing.  Otherwise replace the 
     187                 old binding.  */ 
     188              char *result = binding->codeset; 
     189              if (result == NULL || strcmp (codeset, result) != 0) 
     190                { 
     191#if defined _LIBC || defined HAVE_STRDUP 
     192                  result = strdup (codeset); 
     193#else 
     194                  size_t len = strlen (codeset) + 1; 
     195                  result = (char *) malloc (len); 
     196                  if (__builtin_expect (result != NULL, 1)) 
     197                    memcpy (result, codeset, len); 
     198#endif 
     199 
     200                  if (__builtin_expect (result != NULL, 1)) 
     201                    { 
     202                      if (binding->codeset != NULL) 
     203                        free (binding->codeset); 
     204 
     205                      binding->codeset = result; 
     206                      binding->codeset_cntr++; 
     207                      modified = 1; 
     208                    } 
     209                } 
     210              *codesetp = result; 
     211            } 
     212        } 
     213    } 
     214  else if ((dirnamep == NULL || *dirnamep == NULL) 
     215           && (codesetp == NULL || *codesetp == NULL)) 
     216    { 
     217      /* Simply return the default values.  */ 
     218      if (dirnamep) 
     219        *dirnamep = _nl_default_dirname; 
     220      if (codesetp) 
     221        *codesetp = NULL; 
     222    } 
     223  else 
     224    { 
     225      /* We have to create a new binding.  */ 
     226      size_t len = strlen (domainname) + 1; 
     227      struct binding *new_binding = 
     228        (struct binding *) malloc (offsetof (struct binding, domainname) + len); 
     229 
     230      if (__builtin_expect (new_binding == NULL, 0)) 
     231        goto failed; 
     232 
     233      memcpy (new_binding->domainname, domainname, len); 
     234 
     235      if (dirnamep) 
     236        { 
     237          const char *dirname = *dirnamep; 
     238 
     239          if (dirname == NULL) 
     240            /* The default value.  */ 
     241            dirname = _nl_default_dirname; 
     242          else 
     243            { 
     244              if (strcmp (dirname, _nl_default_dirname) == 0) 
     245                dirname = _nl_default_dirname; 
     246              else 
     247                { 
     248                  char *result; 
     249#if defined _LIBC || defined HAVE_STRDUP 
     250                  result = strdup (dirname); 
     251                  if (__builtin_expect (result == NULL, 0)) 
     252                    goto failed_dirname; 
     253#else 
     254                  size_t len = strlen (dirname) + 1; 
     255                  result = (char *) malloc (len); 
     256                  if (__builtin_expect (result == NULL, 0)) 
     257                    goto failed_dirname; 
     258                  memcpy (result, dirname, len); 
     259#endif 
     260                  dirname = result; 
     261                } 
     262            } 
     263          *dirnamep = dirname; 
     264          new_binding->dirname = (char *) dirname; 
     265        } 
     266      else 
     267        /* The default value.  */ 
     268        new_binding->dirname = (char *) _nl_default_dirname; 
     269 
     270      new_binding->codeset_cntr = 0; 
     271 
     272      if (codesetp) 
     273        { 
     274          const char *codeset = *codesetp; 
     275 
     276          if (codeset != NULL) 
     277            { 
     278              char *result; 
     279 
     280#if defined _LIBC || defined HAVE_STRDUP 
     281              result = strdup (codeset); 
     282              if (__builtin_expect (result == NULL, 0)) 
     283                goto failed_codeset; 
     284#else 
     285              size_t len = strlen (codeset) + 1; 
     286              result = (char *) malloc (len); 
     287              if (__builtin_expect (result == NULL, 0)) 
     288                goto failed_codeset; 
     289              memcpy (result, codeset, len); 
     290#endif 
     291              codeset = result; 
     292              new_binding->codeset_cntr++; 
     293            } 
     294          *codesetp = codeset; 
     295          new_binding->codeset = (char *) codeset; 
     296        } 
     297      else 
     298        new_binding->codeset = NULL; 
     299 
     300      /* Now enqueue it.  */ 
     301      if (_nl_domain_bindings == NULL 
     302          || strcmp (domainname, _nl_domain_bindings->domainname) < 0) 
     303        { 
     304          new_binding->next = _nl_domain_bindings; 
     305          _nl_domain_bindings = new_binding; 
     306        } 
     307      else 
     308        { 
     309          binding = _nl_domain_bindings; 
     310          while (binding->next != NULL 
     311                 && strcmp (domainname, binding->next->domainname) > 0) 
     312            binding = binding->next; 
     313 
     314          new_binding->next = binding->next; 
     315          binding->next = new_binding; 
     316        } 
     317 
     318      modified = 1; 
     319 
     320      /* Here we deal with memory allocation failures.  */ 
     321      if (0) 
     322        { 
     323        failed_codeset: 
     324          if (new_binding->dirname != _nl_default_dirname) 
     325            free (new_binding->dirname); 
     326        failed_dirname: 
     327          free (new_binding); 
     328        failed: 
     329          if (dirnamep) 
     330            *dirnamep = NULL; 
     331          if (codesetp) 
     332            *codesetp = NULL; 
     333        } 
     334    } 
     335 
     336  /* If we modified any binding, we flush the caches.  */ 
     337  if (modified) 
     338    ++_nl_msg_cat_cntr; 
     339 
     340  __libc_rwlock_unlock (_nl_state_lock); 
     341
    70342 
    71343/* Specify that the DOMAINNAME message catalog will be found 
     
    76348     const char *dirname; 
    77349{ 
    78   struct binding *binding; 
    79  
    80   /* Some sanity checks.  */ 
    81   if (domainname == NULL || domainname[0] == '\0') 
    82     return NULL; 
    83  
    84   for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next) 
    85     { 
    86       int compare = strcmp (domainname, binding->domainname); 
    87       if (compare == 0) 
    88         /* We found it!  */ 
    89         break; 
    90       if (compare < 0) 
    91         { 
    92           /* It is not in the list.  */ 
    93           binding = NULL; 
    94           break; 
    95         } 
    96     } 
    97  
    98   if (dirname == NULL) 
    99     /* The current binding has be to returned.  */ 
    100     return binding == NULL ? (char *) _nl_default_dirname : binding->dirname; 
    101  
    102   if (binding != NULL) 
    103     { 
    104       /* The domain is already bound.  If the new value and the old 
    105          one are equal we simply do nothing.  Otherwise replace the 
    106          old binding.  */ 
    107       if (strcmp (dirname, binding->dirname) != 0) 
    108         { 
    109           char *new_dirname; 
    110  
    111           if (strcmp (dirname, _nl_default_dirname) == 0) 
    112             new_dirname = (char *) _nl_default_dirname; 
    113           else 
    114             { 
    115 #if defined _LIBC || defined HAVE_STRDUP 
    116               new_dirname = strdup (dirname); 
    117               if (new_dirname == NULL) 
    118                 return NULL; 
    119 #else 
    120               size_t len = strlen (dirname) + 1; 
    121               new_dirname = (char *) malloc (len); 
    122               if (new_dirname == NULL) 
    123                 return NULL; 
    124  
    125               memcpy (new_dirname, dirname, len); 
    126 #endif 
    127             } 
    128  
    129           if (binding->dirname != _nl_default_dirname) 
    130             free (binding->dirname); 
    131  
    132           binding->dirname = new_dirname; 
    133         } 
    134     } 
    135   else 
    136     { 
    137       /* We have to create a new binding.  */ 
    138 #if !defined _LIBC && !defined HAVE_STRDUP 
    139       size_t len; 
    140 #endif 
    141       struct binding *new_binding = 
    142         (struct binding *) malloc (sizeof (*new_binding)); 
    143  
    144       if (new_binding == NULL) 
    145         return NULL; 
    146  
    147 #if defined _LIBC || defined HAVE_STRDUP 
    148       new_binding->domainname = strdup (domainname); 
    149       if (new_binding->domainname == NULL) 
    150         return NULL; 
    151 #else 
    152       len = strlen (domainname) + 1; 
    153       new_binding->domainname = (char *) malloc (len); 
    154       if (new_binding->domainname == NULL) 
    155         return NULL; 
    156       memcpy (new_binding->domainname, domainname, len); 
    157 #endif 
    158  
    159       if (strcmp (dirname, _nl_default_dirname) == 0) 
    160         new_binding->dirname = (char *) _nl_default_dirname; 
    161       else 
    162         { 
    163 #if defined _LIBC || defined HAVE_STRDUP 
    164           new_binding->dirname = strdup (dirname); 
    165           if (new_binding->dirname == NULL) 
    166             return NULL; 
    167 #else 
    168           len = strlen (dirname) + 1; 
    169           new_binding->dirname = (char *) malloc (len); 
    170           if (new_binding->dirname == NULL) 
    171             return NULL; 
    172           memcpy (new_binding->dirname, dirname, len); 
    173 #endif 
    174         } 
    175  
    176       /* Now enqueue it.  */ 
    177       if (_nl_domain_bindings == NULL 
    178           || strcmp (domainname, _nl_domain_bindings->domainname) < 0) 
    179         { 
    180           new_binding->next = _nl_domain_bindings; 
    181           _nl_domain_bindings = new_binding; 
    182         } 
    183       else 
    184         { 
    185           binding = _nl_domain_bindings; 
    186           while (binding->next != NULL 
    187                  && strcmp (domainname, binding->next->domainname) > 0) 
    188             binding = binding->next; 
    189  
    190           new_binding->next = binding->next; 
    191           binding->next = new_binding; 
    192         } 
    193  
    194       binding = new_binding; 
    195     } 
    196  
    197   return binding->dirname; 
     350  set_binding_values (domainname, &dirname, NULL); 
     351  return (char *) dirname; 
    198352} 
    199353 
     354/* Specify the character encoding in which the messages from the 
     355   DOMAINNAME message catalog will be returned.  */ 
     356char * 
     357BIND_TEXTDOMAIN_CODESET (domainname, codeset) 
     358     const char *domainname; 
     359     const char *codeset; 
     360{ 
     361  set_binding_values (domainname, NULL, &codeset); 
     362  return (char *) codeset; 
     363} 
     364 
    200365#ifdef _LIBC 
    201 /* Alias for function name in GNU C Library.  */ 
     366/* Aliases for function names in GNU C Library.  */ 
    202367weak_alias (__bindtextdomain, bindtextdomain); 
    203 #endif 
     368weak_alias (__bind_textdomain_codeset, bind_textdomain_codeset); 
     369#endif 
  • trunk/sweep/intl/dcgettext.c

    r7 r124  
    11/* Implementation of the dcgettext(3) function. 
    2    Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 
     2   Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. 
    33 
    4    This program is free software; you can redistribute it and/or modify 
    5    it under the terms of the GNU General Public License as published by 
    6    the Free Software Foundation; either version 2, or (at your option) 
     4   This program is free software; you can redistribute it and/or modify it 
     5   under the terms of the GNU Library General Public License as published 
     6   by the Free Software Foundation; either version 2, or (at your option) 
    77   any later version. 
    88 
    99   This program is distributed in the hope that it will be useful, 
    1010   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    12    GNU General Public License for more details. 
     11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     12   Library General Public License for more details. 
    1313 
    14    You should have received a copy of the GNU General Public License 
    15    along with this program; if not, write to the Free Software Foundation, 
    16    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
     14   You should have received a copy of the GNU Library General Public 
     15   License along with this program; if not, write to the Free Software 
     16   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     17   USA.  */ 
    1718 
    1819#ifdef HAVE_CONFIG_H 
     
    2021#endif 
    2122 
    22 #include <sys/types.h> 
    23  
    24 #if defined __GNUC__ && !defined C_ALLOCA 
    25 # define alloca __builtin_alloca 
    26 # define HAVE_ALLOCA 1 
    27 #else 
    28 # if (defined HAVE_ALLOCA_H || defined _LIBC) && !defined C_ALLOCA 
    29 #  include <alloca.h> 
    30 # else 
    31 #  ifdef _AIX 
    32  #pragma alloca 
    33 #  else 
    34 #   ifndef alloca 
    35 char *alloca (); 
    36 #   endif 
    37 #  endif 
    38 # endif 
    39 #endif 
    40  
    41 #include <errno.h> 
    42 #ifndef errno 
    43 extern int errno; 
    44 #endif 
    45 #ifndef __set_errno 
    46 # define __set_errno(val) errno = (val) 
    47 #endif 
    48  
    49 #if defined STDC_HEADERS || defined _LIBC 
    50 # include <stdlib.h> 
    51 #else 
    52 char *getenv (); 
    53 # ifdef HAVE_MALLOC_H 
    54 #  include <malloc.h> 
    55 # else 
    56 void free (); 
    57 # endif 
    58 #endif 
    59  
    60 #if defined HAVE_STRING_H || defined _LIBC 
    61 # ifndef _GNU_SOURCE 
    62 #  define _GNU_SOURCE   1 
    63 # endif 
    64 # include <string.h> 
    65 #else 
    66 # include <strings.h> 
    67 #endif 
    68 #if !HAVE_STRCHR && !defined _LIBC 
    69 # ifndef strchr 
    70 #  define strchr index 
    71 # endif 
    72 #endif 
    73  
    74 #if defined HAVE_UNISTD_H || defined _LIBC 
    75 # include <unistd.h> 
    76 #endif 
    77  
    78 #include "gettext.h" 
    7923#include "gettextP.h" 
    8024#ifdef _LIBC 
    8125# include <libintl.h> 
    8226#else 
    83 # include "libgettext.h" 
     27# include "libgnuintl.h" 
    8428#endif 
    85 #include "hash-string.h" 
    8629 
    8730/* @@ end of prolog @@ */ 
    88  
    89 #ifdef _LIBC 
    90 /* Rename the non ANSI C functions.  This is required by the standard 
    91    because some ANSI C functions will require linking with this object 
    92    file and the name space must not be polluted.  */ 
    93 # define getcwd __getcwd 
    94 # ifndef stpcpy 
    95 #  define stpcpy __stpcpy 
    96 # endif 
    97 #else 
    98 # if !defined HAVE_GETCWD 
    99 char *getwd (); 
    100 #  define getcwd(buf, max) getwd (buf) 
    101 # else 
    102 char *getcwd (); 
    103 # endif 
    104 # ifndef HAVE_STPCPY 
    105 static char *stpcpy PARAMS ((char *dest, const char *src)); 
    106 # endif 
    107 #endif 
    108  
    109 /* Amount to increase buffer size by in each try.  */ 
    110 #define PATH_INCR 32 
    111  
    112 /* The following is from pathmax.h.  */ 
    113 /* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define 
    114    PATH_MAX but might cause redefinition warnings when sys/param.h is 
    115    later included (as on MORE/BSD 4.3).  */ 
    116 #if defined(_POSIX_VERSION) || (defined(HAVE_LIMITS_H) && !defined(__GNUC__)) 
    117 # include <limits.h> 
    118 #endif 
    119  
    120 #ifndef _POSIX_PATH_MAX 
    121 # define _POSIX_PATH_MAX 255 
    122 #endif 
    123  
    124 #if !defined(PATH_MAX) && defined(_PC_PATH_MAX) 
    125 # define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf ("/", _PC_PATH_MAX)) 
    126 #endif 
    127  
    128 /* Don't include sys/param.h if it already has been.  */ 
    129 #if defined(HAVE_SYS_PARAM_H) && !defined(PATH_MAX) && !defined(MAXPATHLEN) 
    130 # include <sys/param.h> 
    131 #endif 
    132  
    133 #if !defined(PATH_MAX) && defined(MAXPATHLEN) 
    134 # define PATH_MAX MAXPATHLEN 
    135 #endif 
    136  
    137 #ifndef PATH_MAX 
    138 # define PATH_MAX _POSIX_PATH_MAX 
    139 #endif 
    140  
    141 /* XPG3 defines the result of `setlocale (category, NULL)' as: 
    142    ``Directs `setlocale()' to query `category' and return the current 
    143      setting of `local'.'' 
    144    However it does not specify the exact format.  And even worse: POSIX 
    145    defines this not at all.  So we can use this feature only on selected 
    146    system (e.g. those using GNU C Library).  */ 
    147 #ifdef _LIBC 
    148 # define HAVE_LOCALE_NULL 
    149 #endif 
    150  
    151 /* Name of the default domain used for gettext(3) prior any call to 
    152    textdomain(3).  The default value for this is "messages".  */ 
    153 const char _nl_default_default_domain[] = "messages"; 
    154  
    155 /* Value used as the default domain for gettext(3).  */ 
    156 const char *_nl_current_default_domain = _nl_default_default_domain; 
    157  
    158 /* Contains the default location of the message catalogs.  */ 
    159 const char _nl_default_dirname[] = GNULOCALEDIR; 
    160  
    161 /* List with bindings of specific domains created by bindtextdomain() 
    162    calls.  */ 
    163 struct binding *_nl_domain_bindings; 
    164  
    165 /* Prototypes for local functions.  */ 
    166 static char *find_msg PARAMS ((struct loaded_l10nfile *domain_file, 
    167                                const char *msgid)) internal_function; 
    168 static const char *category_to_name PARAMS ((int category)) internal_function; 
    169 static const char *guess_category_value PARAMS ((int category, 
    170                                                  const char *categoryname)) 
    171      internal_function; 
    172  
    173  
    174 /* For those loosing systems which don't have `alloca' we have to add 
    175    some additional code emulating it.  */ 
    176 #ifdef HAVE_ALLOCA 
    177 /* Nothing has to be done.  */ 
    178 # define ADD_BLOCK(list, address) /* nothing */ 
    179 # define FREE_BLOCKS(list) /* nothing */ 
    180 #else 
    181 struct block_list 
    182 { 
    183   void *address; 
    184   struct block_list *next; 
    185 }; 
    186 # define ADD_BLOCK(list, addr)                                                \ 
    187   do {                                                                        \ 
    188     struct block_list *newp = (struct block_list *) malloc (sizeof (*newp));  \ 
    189     /* If we cannot get a free block we cannot add the new element to         \ 
    190        the list.  */                                                          \ 
    191     if (newp != NULL) {                                                       \ 
    192       newp->address = (addr);                                                 \ 
    193       newp->next = (list);                                                    \ 
    194       (list) = newp;                                                          \ 
    195     }                                                                         \ 
    196   } while (0) 
    197 # define FREE_BLOCKS(list)                                                    \ 
    198   do {                                                                        \ 
    199     while (list != NULL) {                                                    \ 
    200       struct block_list *old = list;                                          \ 
    201       list = list->next;                                                      \ 
    202       free (old);                                                             \ 
    203     }                                                                         \ 
    204   } while (0) 
    205 # undef alloca 
    206 # define alloca(size) (malloc (size)) 
    207 #endif  /* have alloca */ 
    208  
    20931 
    21032/* Names for the libintl functions are a problem.  They must not clash 
     
    21436#ifdef _LIBC 
    21537# define DCGETTEXT __dcgettext 
     38# define DCIGETTEXT __dcigettext 
    21639#else 
    21740# define DCGETTEXT dcgettext__ 
    218 #endif 
    219  
    220 /* Checking whether the binaries runs SUID must be done and glibc provides 
    221    easier methods therefore we make a difference here.  */ 
    222 #ifdef _LIBC 
    223 # define ENABLE_SECURE __libc_enable_secure 
    224 # define DETERMINE_SECURE 
    225 #else 
    226 static int enable_secure; 
    227 # define ENABLE_SECURE (enable_secure == 1) 
    228 # define DETERMINE_SECURE \ 
    229   if (enable_secure == 0)                                                     \ 
    230     {                                                                         \ 
    231       if (getuid () != geteuid () || getgid () != getegid ())                 \ 
    232         enable_secure = 1;                                                    \ 
    233       else                                                                    \ 
    234         enable_secure = -1;                                                   \ 
    235     } 
     41# define DCIGETTEXT dcigettext__ 
    23642#endif 
    23743 
     
    24450     int category; 
    24551{ 
    246 #ifndef HAVE_ALLOCA 
    247   struct block_list *block_list = NULL; 
    248 #endif 
    249   struct loaded_l10nfile *domain; 
    250   struct binding *binding; 
    251   const char *categoryname; 
    252   const char *categoryvalue; 
    253   char *dirname, *xdomainname; 
    254   char *single_locale; 
    255   char *retval; 
    256   int saved_errno = errno; 
    257  
    258   /* If no real MSGID is given return NULL.  */ 
    259   if (msgid == NULL) 
    260     return NULL; 
    261  
    262   /* See whether this is a SUID binary or not.  */ 
    263   DETERMINE_SECURE; 
    264  
    265   /* If DOMAINNAME is NULL, we are interested in the default domain.  If 
    266      CATEGORY is not LC_MESSAGES this might not make much sense but the 
    267      definition left this undefined.  */ 
    268   if (domainname == NULL) 
    269     domainname = _nl_current_default_domain; 
    270  
    271   /* First find matching binding.  */ 
    272   for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next) 
    273     { 
    274       int compare = strcmp (domainname, binding->domainname); 
    275       if (compare == 0) 
    276         /* We found it!  */ 
    277         break; 
    278       if (compare < 0) 
    279         { 
    280           /* It is not in the list.  */ 
    281           binding = NULL; 
    282           break; 
    283         } 
    284     } 
    285  
    286   if (binding == NULL) 
    287     dirname = (char *) _nl_default_dirname; 
    288   else if (binding->dirname[0] == '/') 
    289     dirname = binding->dirname; 
    290   else 
    291     { 
    292       /* We have a relative path.  Make it absolute now.  */ 
    293       size_t dirname_len = strlen (binding->dirname) + 1; 
    294       size_t path_max; 
    295       char *ret; 
    296  
    297       path_max = (unsigned int) PATH_MAX; 
    298       path_max += 2;            /* The getcwd docs say to do this.  */ 
    299  
    300       dirname = (char *) alloca (path_max + dirname_len); 
    301       ADD_BLOCK (block_list, dirname); 
    302  
    303       __set_errno (0); 
    304       while ((ret = getcwd (dirname, path_max)) == NULL && errno == ERANGE) 
    305         { 
    306           path_max += PATH_INCR; 
    307           dirname = (char *) alloca (path_max + dirname_len); 
    308           ADD_BLOCK (block_list, dirname); 
    309           __set_errno (0); 
    310         } 
    311  
    312       if (ret == NULL) 
    313         { 
    314           /* We cannot get the current working directory.  Don't signal an 
    315              error but simply return the default string.  */ 
    316           FREE_BLOCKS (block_list); 
    317           __set_errno (saved_errno); 
    318           return (char *) msgid; 
    319         } 
    320  
    321       stpcpy (stpcpy (strchr (dirname, '\0'), "/"), binding->dirname); 
    322     } 
    323  
    324   /* Now determine the symbolic name of CATEGORY and its value.  */ 
    325   categoryname = category_to_name (category); 
    326   categoryvalue = guess_category_value (category, categoryname); 
    327  
    328   xdomainname = (char *) alloca (strlen (categoryname) 
    329                                  + strlen (domainname) + 5); 
    330   ADD_BLOCK (block_list, xdomainname); 
    331  
    332   stpcpy (stpcpy (stpcpy (stpcpy (xdomainname, categoryname), "/"), 
    333                   domainname), 
    334           ".mo"); 
    335  
    336   /* Creating working area.  */ 
    337   single_locale = (char *) alloca (strlen (categoryvalue) + 1); 
    338   ADD_BLOCK (block_list, single_locale); 
    339  
    340  
    341   /* Search for the given string.  This is a loop because we perhaps 
    342      got an ordered list of languages to consider for the translation.  */ 
    343   while (1) 
    344     { 
    345       /* Make CATEGORYVALUE point to the next element of the list.  */ 
    346       while (categoryvalue[0] != '\0' && categoryvalue[0] == ':') 
    347         ++categoryvalue; 
    348       if (categoryvalue[0] == '\0') 
    349         { 
    350           /* The whole contents of CATEGORYVALUE has been searched but 
    351              no valid entry has been found.  We solve this situation 
    352              by implicitly appending a "C" entry, i.e. no translation 
    353              will take place.  */ 
    354           single_locale[0] = 'C'; 
    355           single_locale[1] = '\0'; 
    356         } 
    357       else 
    358         { 
    359           char *cp = single_locale; 
    360           while (categoryvalue[0] != '\0' && categoryvalue[0] != ':') 
    361             *cp++ = *categoryvalue++; 
    362           *cp = '\0'; 
    363  
    364           /* When this is a SUID binary we must not allow accessing files 
    365              outside the dedicated directories.  */ 
    366           if (ENABLE_SECURE 
    367               && (memchr (single_locale, '/', 
    368                           _nl_find_language (single_locale) - single_locale) 
    369                   != NULL)) 
    370             /* Ingore this entry.  */ 
    371             continue; 
    372         } 
    373  
    374       /* If the current locale value is C (or POSIX) we don't load a 
    375          domain.  Return the MSGID.  */ 
    376       if (strcmp (single_locale, "C") == 0 
    377           || strcmp (single_locale, "POSIX") == 0) 
    378         { 
    379           FREE_BLOCKS (block_list); 
    380           __set_errno (saved_errno); 
    381           return (char *) msgid; 
    382         } 
    383  
    384  
    385       /* Find structure describing the message catalog matching the 
    386          DOMAINNAME and CATEGORY.  */ 
    387       domain = _nl_find_domain (dirname, single_locale, xdomainname); 
    388  
    389       if (domain != NULL) 
    390         { 
    391           retval = find_msg (domain, msgid); 
    392  
    393           if (retval == NULL) 
    394             { 
    395               int cnt; 
    396  
    397               for (cnt = 0; domain->successor[cnt] != NULL; ++cnt) 
    398                 { 
    399                   retval = find_msg (domain->successor[cnt], msgid); 
    400  
    401                   if (retval != NULL) 
    402                     break; 
    403                 } 
    404             } 
    405  
    406           if (retval != NULL) 
    407             { 
    408               FREE_BLOCKS (block_list); 
    409               __set_errno (saved_errno); 
    410               return retval; 
    411             } 
    412         } 
    413     } 
    414   /* NOTREACHED */ 
     52  return DCIGETTEXT (domainname, msgid, NULL, 0, 0, category); 
    41553} 
    41654 
     
    41957weak_alias (__dcgettext, dcgettext); 
    42058#endif 
    421  
    422  
    423 static char * 
    424 internal_function 
    425 find_msg (domain_file, msgid) 
    426      struct loaded_l10nfile *domain_file; 
    427      const char *msgid; 
    428 { 
    429   size_t act = 0; 
    430   size_t top, bottom; 
    431   struct loaded_domain *domain; 
    432  
    433   if (domain_file->decided == 0) 
    434     _nl_load_domain (domain_file); 
    435  
    436   if (domain_file->data == NULL) 
    437     return NULL; 
    438  
    439   domain = (struct loaded_domain *) domain_file->data; 
    440  
    441   /* Locate the MSGID and its translation.  */ 
    442   if (domain->hash_size > 2 && domain->hash_tab != NULL) 
    443     { 
    444       /* Use the hashing table.  */ 
    445       nls_uint32 len = strlen (msgid); 
    446       nls_uint32 hash_val = hash_string (msgid); 
    447       nls_uint32 idx = hash_val % domain->hash_size; 
    448       nls_uint32 incr = 1 + (hash_val % (domain->hash_size - 2)); 
    449       nls_uint32 nstr = W (domain->must_swap, domain->hash_tab[idx]); 
    450  
    451       if (nstr == 0) 
    452         /* Hash table entry is empty.  */ 
    453         return NULL; 
    454  
    455       if (W (domain->must_swap, domain->orig_tab[nstr - 1].length) == len 
    456           && strcmp (msgid, 
    457                      domain->data + W (domain->must_swap, 
    458                                        domain->orig_tab[nstr - 1].offset)) == 0) 
    459         return (char *) domain->data + W (domain->must_swap, 
    460                                           domain->trans_tab[nstr - 1].offset); 
    461  
    462       while (1) 
    463         { 
    464           if (idx >= domain->hash_size - incr) 
    465             idx -= domain->hash_size - incr; 
    466           else 
    467             idx += incr; 
    468  
    469           nstr = W (domain->must_swap, domain->hash_tab[idx]); 
    470           if (nstr == 0) 
    471             /* Hash table entry is empty.  */ 
    472             return NULL; 
    473  
    474           if (W (domain->must_swap, domain->orig_tab[nstr - 1].length) == len 
    475               && strcmp (msgid, 
    476                          domain->data + W (domain->must_swap, 
    477                                            domain->orig_tab[nstr - 1].offset)) 
    478                  == 0) 
    479             return (char *) domain->data 
    480               + W (domain->must_swap, domain->trans_tab[nstr - 1].offset); 
    481         } 
    482       /* NOTREACHED */ 
    483     } 
    484  
    485   /* Now we try the default method:  binary search in the sorted 
    486      array of messages.  */ 
    487   bottom = 0; 
    488   top = domain->nstrings; 
    489   while (bottom < top) 
    490     { 
    491       int cmp_val; 
    492  
    493       act = (bottom + top) / 2; 
    494       cmp_val = strcmp (msgid, domain->data 
    495                                + W (domain->must_swap, 
    496                                     domain->orig_tab[act].offset)); 
    497       if (cmp_val < 0) 
    498         top = act; 
    499       else if (cmp_val > 0) 
    500         bottom = act + 1; 
    501       else 
    502         break; 
    503     } 
    504  
    505   /* If an translation is found return this.  */ 
    506   return bottom >= top ? NULL : (char *) domain->data 
    507                                 + W (domain->must_swap, 
    508                                      domain->trans_tab[act].offset); 
    509 } 
    510  
    511  
    512 /* Return string representation of locale CATEGORY.  */ 
    513 static const char * 
    514 internal_function 
    515 category_to_name (category) 
    516      int category; 
    517 { 
    518   const char *retval; 
    519  
    520   switch (category) 
    521   { 
    522 #ifdef LC_COLLATE 
    523   case LC_COLLATE: 
    524     retval = "LC_COLLATE"; 
    525     break; 
    526 #endif 
    527 #ifdef LC_CTYPE 
    528   case LC_CTYPE: 
    529     retval = "LC_CTYPE"; 
    530     break; 
    531 #endif 
    532 #ifdef LC_MONETARY 
    533   case LC_MONETARY: 
    534     retval = "LC_MONETARY"; 
    535     break; 
    536 #endif 
    537 #ifdef LC_NUMERIC 
    538   case LC_NUMERIC: 
    539     retval = "LC_NUMERIC"; 
    540     break; 
    541 #endif 
    542 #ifdef LC_TIME 
    543   case LC_TIME: 
    544     retval = "LC_TIME"; 
    545     break; 
    546 #endif 
    547 #ifdef LC_MESSAGES 
    548   case LC_MESSAGES: 
    549     retval = "LC_MESSAGES"; 
    550     break; 
    551 #endif 
    552 #ifdef LC_RESPONSE 
    553   case LC_RESPONSE: 
    554     retval = "LC_RESPONSE"; 
    555     break; 
    556 #endif 
    557 #ifdef LC_ALL 
    558   case LC_ALL: 
    559     /* This might not make sense but is perhaps better than any other 
    560        value.  */ 
    561     retval = "LC_ALL"; 
    562     break; 
    563 #endif 
    564   default: 
    565     /* If you have a better idea for a default value let me know.  */ 
    566     retval = "LC_XXX"; 
    567   } 
    568  
    569   return retval; 
    570 } 
    571  
    572 /* Guess value of current locale from value of the environment variables.  */ 
    573 static const char * 
    574 internal_function 
    575 guess_category_value (category, categoryname) 
    576      int category; 
    577      const char *categoryname; 
    578 { 
    579   const char *retval; 
    580  
    581   /* The highest priority value is the `LANGUAGE' environment 
    582      variable.  This is a GNU extension.  */ 
    583   retval = getenv ("LANGUAGE"); 
    584   if (retval != NULL && retval[0] != '\0') 
    585     return retval; 
    586  
    587   /* `LANGUAGE' is not set.  So we have to proceed with the POSIX 
    588      methods of looking to `LC_ALL', `LC_xxx', and `LANG'.  On some 
    589      systems this can be done by the `setlocale' function itself.  */ 
    590 #if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL 
    591   return setlocale (category, NULL); 
    592 #else 
    593   /* Setting of LC_ALL overwrites all other.  */ 
    594   retval = getenv ("LC_ALL"); 
    595   if (retval != NULL && retval[0] != '\0') 
    596     return retval; 
    597  
    598   /* Next comes the name of the desired category.  */ 
    599   retval = getenv (categoryname); 
    600   if (retval != NULL && retval[0] != '\0') 
    601     return retval; 
    602  
    603   /* Last possibility is the LANG environment variable.  */ 
    604   retval = getenv ("LANG"); 
    605   if (retval != NULL && retval[0] != '\0') 
    606     return retval; 
    607  
    608   /* We use C as the default domain.  POSIX says this is implementation 
    609      defined.  */ 
    610   return "C"; 
    611 #endif 
    612 } 
    613  
    614 /* @@ begin of epilog @@ */ 
    615  
    616 /* We don't want libintl.a to depend on any other library.  So we 
    617    avoid the non-standard function stpcpy.  In GNU C Library this 
    618    function is available, though.  Also allow the symbol HAVE_STPCPY 
    619    to be defined.  */ 
    620 #if !_LIBC && !HAVE_STPCPY 
    621 static char * 
    622 stpcpy (dest, src) 
    623      char *dest; 
    624      const char *src; 
    625 { 
    626   while ((*dest++ = *src++) != '\0') 
    627     /* Do nothing. */ ; 
    628   return dest - 1; 
    629 } 
    630 #endif 
    631  
    632  
    633 #ifdef _LIBC 
    634 /* If we want to free all resources we have to do some work at 
    635    program's end.  */ 
    636 static void __attribute__ ((unused)) 
    637 free_mem (void) 
    638 { 
    639   struct binding *runp; 
    640  
    641   for (runp = _nl_domain_bindings; runp != NULL; runp = runp->next) 
    642     { 
    643       free (runp->domainname); 
    644       if (runp->dirname != _nl_default_dirname) 
    645         /* Yes, this is a pointer comparison.  */ 
    646         free (runp->dirname); 
    647     } 
    648  
    649   if (_nl_current_default_domain != _nl_default_default_domain) 
    650     /* Yes, again a pointer comparison.  */ 
    651     free ((char *) _nl_current_default_domain); 
    652 } 
    653  
    654 text_set_element (__libc_subfreeres, free_mem); 
    655 #endif 
  • trunk/sweep/intl/dgettext.c

    r7 r124  
    1 /* Implementation of the dgettext(3) function 
    2    Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. 
     1/* Implementation of the dgettext(3) function. 
     2   Copyright (C) 1995-1997, 2000, 2001 Free Software Foundation, Inc. 
    33 
    4    This program is free software; you can redistribute it and/or modify 
    5    it under the terms of the GNU General Public License as published by 
    6    the Free Software Foundation; either version 2, or (at your option) 
     4   This program is free software; you can redistribute it and/or modify it 
     5   under the terms of the GNU Library General Public License as published 
     6   by the Free Software Foundation; either version 2, or (at your option) 
    77   any later version. 
    88 
    99   This program is distributed in the hope that it will be useful, 
    1010   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    12    GNU General Public License for more details. 
     11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     12   Library General Public License for more details. 
    1313 
    14    You should have received a copy of the GNU General Public License 
    15    along with this program; if not, write to the Free Software Foundation, 
    16    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
     14   You should have received a copy of the GNU Library General Public 
     15   License along with this program; if not, write to the Free Software 
     16   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     17   USA.  */ 
    1718 
    1819#ifdef HAVE_CONFIG_H 
     
    2021#endif 
    2122 
    22 #if defined HAVE_LOCALE_H || defined _LIBC 
    23 # include <locale.h> 
    24 #endif 
     23#include <locale.h> 
    2524 
     25#include "gettextP.h" 
    2626#ifdef _LIBC 
    2727# include <libintl.h> 
    2828#else 
    29 # include "libgettext.h" 
     29# include "libgnuintl.h" 
    3030#endif 
    3131 
  • trunk/sweep/intl/explodename.c

    r7 r124  
    1 /* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 
     1/* Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. 
    22   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. 
    33 
    4    This program is free software; you can redistribute it and/or modify 
    5    it under the terms of the GNU General Public License as published by 
    6    the Free Software Foundation; either version 2, or (at your option) 
     4   This program is free software; you can redistribute it and/or modify it 
     5   under the terms of the GNU Library General Public License as published 
     6   by the Free Software Foundation; either version 2, or (at your option) 
    77   any later version. 
    88 
    99   This program is distributed in the hope that it will be useful, 
    1010   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    12    GNU General Public License for more details. 
     11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     12   Library General Public License for more details. 
    1313 
    14    You should have received a copy of the GNU General Public License 
    15    along with this program; if not, write to the Free Software Foundation, 
    16    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
     14   You should have received a copy of the GNU Library General Public 
     15   License along with this program; if not, write to the Free Software 
     16   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     17   USA.  */ 
    1718 
    1819#ifdef HAVE_CONFIG_H 
     
    2021#endif 
    2122 
    22 #if defined STDC_HEADERS || defined _LIBC 
    23 # include <stdlib.h> 
    24 #endif 
    25  
    26 #if defined HAVE_STRING_H || defined _LIBC 
    27 # include <string.h> 
    28 #else 
    29 # include <strings.h> 
    30 #endif 
     23#include <stdlib.h> 
     24#include <string.h> 
    3125#include <sys/types.h> 
    3226 
  • trunk/sweep/intl/finddomain.c

    r7 r124  
    11/* Handle list of needed message catalogs 
    2    Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 
    3    Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. 
     2   Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. 
     3   Written by Ulrich Drepper <drepper@gnu.org>, 1995. 
    44 
    5    This program is free software; you can redistribute it and/or modify 
    6    it under the terms of the GNU General Public License as published by 
    7    the Free Software Foundation; either version 2, or (at your option) 
     5   This program is free software; you can redistribute it and/or modify it 
     6   under the terms of the GNU Library General Public License as published 
     7   by the Free Software Foundation; either version 2, or (at your option) 
    88   any later version. 
    99 
    1010   This program is distributed in the hope that it will be useful, 
    1111   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    13    GNU General Public License for more details. 
     12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     13   Library General Public License for more details. 
    1414 
    15    You should have received a copy of the GNU General Public License 
    16    along with this program; if not, write to the Free Software Foundation, 
    17    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
     15   You should have received a copy of the GNU Library General Public 
     16   License along with this program; if not, write to the Free Software 
     17   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     18   USA.  */ 
    1819 
    1920#ifdef HAVE_CONFIG_H 
     
    2122#endif 
    2223 
    23 #include <ctype.h> 
    24 #include <errno.h> 
    2524#include <stdio.h> 
    2625#include <sys/types.h> 
    27  
    28 #if defined STDC_HEADERS || defined _LIBC 
    29 # include <stdlib.h> 
    30 #else 
    31 # ifdef HAVE_MALLOC_H 
    32 #  include <malloc.h> 
    33 # else 
    34 void free (); 
    35 # endif 
    36 #endif 
    37  
    38 #if defined HAVE_STRING_H || defined _LIBC 
    39 # include <string.h> 
    40 #else 
    41 # include <strings.h> 
    42 # ifndef memcpy 
    43 #  define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) 
    44 # endif 
    45 #endif 
    46 #if !HAVE_STRCHR && !defined _LIBC 
    47 # ifndef strchr 
    48 #  define strchr index 
    49 # endif 
    50 #endif 
     26#include <stdlib.h> 
     27#include <string.h> 
    5128 
    5229#if defined HAVE_UNISTD_H || defined _LIBC 
     
    5431#endif 
    5532 
    56 #include "gettext.h" 
    5733#include "gettextP.h" 
    5834#ifdef _LIBC 
    5935# include <libintl.h> 
    6036#else 
    61 # include "libgettext.h" 
     37# include "libgnuintl.h" 
    6238#endif 
    6339 
     
    7248struct loaded_l10nfile * 
    7349internal_function 
    74 _nl_find_domain (dirname, locale, domainname
     50_nl_find_domain (dirname, locale, domainname, domainbinding
    7551     const char *dirname; 
    7652     char *locale; 
    7753     const char *domainname; 
     54     struct binding *domainbinding; 
    7855{ 
    7956  struct loaded_l10nfile *retval; 
     
    12198 
    12299      if (retval->decided == 0) 
    123         _nl_load_domain (retval); 
     100        _nl_load_domain (retval, domainbinding); 
    124101 
    125102      if (retval->data != NULL) 
     
    129106        { 
    130107          if (retval->successor[cnt]->decided == 0) 
    131             _nl_load_domain (retval->successor[cnt]); 
     108            _nl_load_domain (retval->successor[cnt], domainbinding); 
    132109 
    133110          if (retval->successor[cnt]->data != NULL) 
     
    176153 
    177154  if (retval->decided == 0) 
    178     _nl_load_domain (retval); 
     155    _nl_load_domain (retval, domainbinding); 
    179156  if (retval->data == NULL) 
    180157    { 
     
    183160        { 
    184161          if (retval->successor[cnt]->decided == 0) 
    185             _nl_load_domain (retval->successor[cnt]); 
     162            _nl_load_domain (retval->successor[cnt], domainbinding); 
    186163          if (retval->successor[cnt]->data != NULL) 
    187164            break; 
     
    192169  if (alias_value != NULL) 
    193170    free (locale); 
     171 
     172  /* The space for normalized_codeset is dynamically allocated.  Free it.  */ 
     173  if (mask & XPG_NORM_CODESET) 
     174    free ((void *) normalized_codeset); 
    194175 
    195176  return retval; 
     
    209190        _nl_unload_domain ((struct loaded_domain *) runp->data); 
    210191      runp = runp->next; 
     192      free ((char *) here->filename); 
    211193      free (here); 
    212194    } 
  • trunk/sweep/intl/gettext.c

    r7 r124  
    11/* Implementation of gettext(3) function. 
    2    Copyright (C) 1995, 1997 Free Software Foundation, Inc. 
     2   Copyright (C) 1995, 1997, 2000, 2001 Free Software Foundation, Inc. 
    33 
    4    This program is free software; you can redistribute it and/or modify 
    5    it under the terms of the GNU General Public License as published by 
    6    the Free Software Foundation; either version 2, or (at your option) 
     4   This program is free software; you can redistribute it and/or modify it 
     5   under the terms of the GNU Library General Public License as published 
     6   by the Free Software Foundation; either version 2, or (at your option) 
    77   any later version. 
    88 
    99   This program is distributed in the hope that it will be useful, 
    1010   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    12    GNU General Public License for more details. 
     11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     12   Library General Public License for more details. 
    1313 
    14    You should have received a copy of the GNU General Public License 
    15    along with this program; if not, write to the Free Software Foundation, 
    16    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
     14   You should have received a copy of the GNU Library General Public 
     15   License along with this program; if not, write to the Free Software 
     16   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     17   USA.  */ 
    1718 
    1819#ifdef HAVE_CONFIG_H 
     
    2425# include <stddef.h> 
    2526#else 
    26 # ifdef STDC_HEADERS 
    27 #  include <stdlib.h>           /* Just for NULL.  */ 
    28 # else 
    29 #  ifdef HAVE_STRING_H 
    30 #   include <string.h> 
    31 #  else 
    32 #   define NULL ((void *) 0) 
    33 #  endif 
    34 # endif 
     27# include <stdlib.h>            /* Just for NULL.  */ 
    3528#endif 
    3629 
     30#include "gettextP.h" 
    3731#ifdef _LIBC 
    3832# include <libintl.h> 
    3933#else 
    40 # include "libgettext.h" 
     34# include "libgnuintl.h" 
    4135#endif 
    4236 
     
    4943#ifdef _LIBC 
    5044# define GETTEXT __gettext 
    51 # define DGETTEXT __dgettext 
     45# define DCGETTEXT __dcgettext 
    5246#else 
    5347# define GETTEXT gettext__ 
    54 # define DGETTEXT dgettext__ 
     48# define DCGETTEXT dcgettext__ 
    5549#endif 
    5650 
     
    6256     const char *msgid; 
    6357{ 
    64   return DGETTEXT (NULL, msgid); 
     58  return DCGETTEXT (NULL, msgid, LC_MESSAGES); 
    6559} 
    6660 
  • trunk/sweep/intl/gettext.h

    r7 r124  
    1 /* Internal header for GNU gettext internationalization functions
    2    Copyright (C) 1995, 1997 Free Software Foundation, Inc. 
     1/* Description of GNU message catalog format: general file layout
     2   Copyright (C) 1995, 1997, 2000, 2001 Free Software Foundation, Inc. 
    33 
    4    This program is free software; you can redistribute it and/or modify 
    5    it under the terms of the GNU General Public License as published by 
    6    the Free Software Foundation; either version 2, or (at your option) 
     4   This program is free software; you can redistribute it and/or modify it 
     5   under the terms of the GNU Library General Public License as published 
     6   by the Free Software Foundation; either version 2, or (at your option) 
    77   any later version. 
    88 
    99   This program is distributed in the hope that it will be useful, 
    1010   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    12    GNU General Public License for more details. 
     11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     12   Library General Public License for more details. 
    1313 
    1414   You should have received a copy of the GNU Library General Public 
    15    License along with the GNU C Library; see the file COPYING.LIB.  If not, 
    16    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330
    17    Boston, MA 02111-1307, USA.  */ 
     15   License along with this program; if not, write to the Free Software 
     16   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307
     17   USA.  */ 
    1818 
    1919#ifndef _GETTEXT_H 
    2020#define _GETTEXT_H 1 
    21  
    22 #include <stdio.h> 
    2321 
    2422#if HAVE_LIMITS_H || _LIBC 
     
    3836   to determine an unsigned integral type that is 32 bits wide.  An 
    3937   alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but 
    40    doing that would require that the configure script compile and *run* 
    41    the resulting executable.  Locally running cross-compiled executables 
    42    is usually not possible.  */ 
     38   as of version autoconf-2.13, the AC_CHECK_SIZEOF macro doesn't work 
     39   when cross-compiling.  */ 
    4340 
    4441#if __STDC__ 
  • trunk/sweep/intl/gettextP.h

    r7 r124  
    1 /* Header describing internals of gettext library 
    2    Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 
    3    Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. 
    4  
    5    This program is free software; you can redistribute it and/or modify 
    6    it under the terms of the GNU General Public License as published by 
    7    the Free Software Foundation; either version 2, or (at your option) 
     1/* Header describing internals of libintl library. 
     2   Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. 
     3   Written by Ulrich Drepper <drepper@cygnus.com>, 1995. 
     4 
     5   This program is free software; you can redistribute it and/or modify it 
     6   under the terms of the GNU Library General Public License as published 
     7   by the Free Software Foundation; either version 2, or (at your option) 
    88   any later version. 
    99 
    1010   This program is distributed in the hope that it will be useful, 
    1111   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    13    GNU General Public License for more details. 
    14  
    15    You should have received a copy of the GNU General Public License 
    16    along with this program; if not, write to the Free Software Foundation, 
    17    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
     12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     13   Library General Public License for more details. 
     14 
     15   You should have received a copy of the GNU Library General Public 
     16   License along with this program; if not, write to the Free Software 
     17   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     18   USA.  */ 
    1819 
    1920#ifndef _GETTEXTP_H 
    2021#define _GETTEXTP_H 
    2122 
     23#include <stddef.h>             /* Get size_t.  */ 
     24 
     25#ifdef _LIBC 
     26# include "../iconv/gconv_int.h" 
     27#else 
     28# if HAVE_ICONV 
     29#  include <iconv.h> 
     30# endif 
     31#endif 
     32 
    2233#include "loadinfo.h" 
     34 
     35#include "gettext.h"            /* Get nls_uint32.  */ 
    2336 
    2437/* @@ end of prolog @@ */ 
     
    3649#endif 
    3750 
     51/* Tell the compiler when a conditional or integer expression is 
     52   almost always true or almost always false.  */ 
     53#ifndef HAVE_BUILTIN_EXPECT 
     54# define __builtin_expect(expr, val) (expr) 
     55#endif 
     56 
    3857#ifndef W 
    3958# define W(flag, data) ((flag) ? SWAP (data) : (data)) 
     
    4564# define SWAP(i) bswap_32 (i) 
    4665#else 
    47 static nls_uint32 SWAP PARAMS ((nls_uint32 i)); 
    48  
    4966static inline nls_uint32 
    5067SWAP (i) 
     
    5673 
    5774 
     75/* This is the representation of the expressions to determine the 
     76   plural form.  */ 
     77struct expression 
     78{ 
     79  int nargs;                    /* Number of arguments.  */ 
     80  enum operator 
     81  { 
     82    /* Without arguments:  */ 
     83    var,                        /* The variable "n".  */ 
     84    num,                        /* Decimal number.  */ 
     85    /* Unary operators:  */ 
     86    lnot,                       /* Logical NOT.  */ 
     87    /* Binary operators:  */ 
     88    mult,                       /* Multiplication.  */ 
     89    divide,                     /* Division.  */ 
     90    module,                     /* Module operation.  */ 
     91    plus,                       /* Addition.  */ 
     92    minus,                      /* Subtraction.  */ 
     93    less_than,                  /* Comparison.  */ 
     94    greater_than,               /* Comparison.  */ 
     95    less_or_equal,              /* Comparison.  */ 
     96    greater_or_equal,           /* Comparison.  */ 
     97    equal,                      /* Comparision for equality.  */ 
     98    not_equal,                  /* Comparision for inequality.  */ 
     99    land,                       /* Logical AND.  */ 
     100    lor,                        /* Logical OR.  */ 
     101    /* Ternary operators:  */ 
     102    qmop                        /* Question mark operator.  */ 
     103  } operation; 
     104  union 
     105  { 
     106    unsigned long int num;      /* Number value for `num'.  */ 
     107    struct expression *args[3]; /* Up to three arguments.  */ 
     108  } val; 
     109}; 
     110 
     111/* This is the data structure to pass information to the parser and get 
     112   the result in a thread-safe way.  */ 
     113struct parse_args 
     114{ 
     115  const char *cp; 
     116  struct expression *res; 
     117}; 
     118 
     119 
     120/* The representation of an opened message catalog.  */ 
    58121struct loaded_domain 
    59122{ 
     
    67130  nls_uint32 hash_size; 
    68131  nls_uint32 *hash_tab; 
    69 }; 
    70  
     132  int codeset_cntr; 
     133#ifdef _LIBC 
     134  __gconv_t conv; 
     135#else 
     136# if HAVE_ICONV 
     137  iconv_t conv; 
     138# endif 
     139#endif 
     140  char **conv_tab; 
     141 
     142  struct expression *plural; 
     143  unsigned long int nplurals; 
     144}; 
     145 
     146/* We want to allocate a string at the end of the struct.  But ISO C 
     147   doesn't allow zero sized arrays.  */ 
     148#ifdef __GNUC__ 
     149# define ZERO 0 
     150#else 
     151# define ZERO 1 
     152#endif 
     153 
     154/* A set of settings bound to a message domain.  Used to store settings 
     155   from bindtextdomain() and bind_textdomain_codeset().  */ 
    71156struct binding 
    72157{ 
    73158  struct binding *next; 
    74   char *domainname; 
    75159  char *dirname; 
    76 }; 
     160  int codeset_cntr;     /* Incremented each time codeset changes.  */ 
     161  char *codeset; 
     162  char domainname[ZERO]; 
     163}; 
     164 
     165/* A counter which is incremented each time some previous translations 
     166   become invalid. 
     167   This variable is part of the external ABI of the GNU libintl.  */ 
     168extern int _nl_msg_cat_cntr; 
    77169 
    78170struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname, 
    79171                                                 char *__locale, 
    80                                                  const char *__domainname)) 
    81      internal_function; 
    82 void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain)) 
     172                                                 const char *__domainname, 
     173                                              struct binding *__domainbinding)) 
     174     internal_function; 
     175void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain, 
     176                              struct binding *__domainbinding)) 
    83177     internal_function; 
    84178void _nl_unload_domain PARAMS ((struct loaded_domain *__domain)) 
    85179     internal_function; 
     180const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile *__domain_file, 
     181                                          struct loaded_domain *__domain, 
     182                                          struct binding *__domainbinding)) 
     183     internal_function; 
     184void _nl_free_domain_conv PARAMS ((struct loaded_domain *__domain)) 
     185     internal_function; 
     186 
     187char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file, 
     188                            struct binding *domainbinding, 
     189                            const char *msgid, size_t *lengthp)) 
     190     internal_function; 
     191 
     192#ifdef _LIBC 
     193extern char *__gettext PARAMS ((const char *__msgid)); 
     194extern char *__dgettext PARAMS ((const char *__domainname, 
     195                                 const char *__msgid)); 
     196extern char *__dcgettext PARAMS ((const char *__domainname, 
     197                                  const char *__msgid, int __category)); 
     198extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2, 
     199                                 unsigned long int __n)); 
     200extern char *__dngettext PARAMS ((const char *__domainname, 
     201                                  const char *__msgid1, const char *__msgid2, 
     202                                  unsigned long int n)); 
     203extern char *__dcngettext PARAMS ((const char *__domainname, 
     204                                   const char *__msgid1, const char *__msgid2, 
     205                                   unsigned long int __n, int __category)); 
     206extern char *__dcigettext PARAMS ((const char *__domainname, 
     207                                   const char *__msgid1, const char *__msgid2, 
     208                                   int __plural, unsigned long int __n, 
     209                                   int __category)); 
     210extern char *__textdomain PARAMS ((const char *__domainname)); 
     211extern char *__bindtextdomain PARAMS ((const char *__domainname, 
     212                                       const char *__dirname)); 
     213extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname, 
     214                                                const char *__codeset)); 
     215#else 
     216extern char *gettext__ PARAMS ((const char *__msgid)); 
     217extern char *dgettext__ PARAMS ((const char *__domainname, 
     218                                 const char *__msgid)); 
     219extern char *dcgettext__ PARAMS ((const char *__domainname, 
     220                                  const char *__msgid, int __category)); 
     221extern char *ngettext__ PARAMS ((const char *__msgid1, const char *__msgid2, 
     222                                 unsigned long int __n)); 
     223extern char *dngettext__ PARAMS ((const char *__domainname, 
     224                                  const char *__msgid1, const char *__msgid2, 
     225                                  unsigned long int __n)); 
     226extern char *dcngettext__ PARAMS ((const char *__domainname, 
     227                                   const char *__msgid1, const char *__msgid2, 
     228                                   unsigned long int __n, int __category)); 
     229extern char *dcigettext__ PARAMS ((const char *__domainname, 
     230                                   const char *__msgid1, const char *__msgid2, 
     231                                   int __plural, unsigned long int __n, 
     232                                   int __category)); 
     233extern char *textdomain__ PARAMS ((const char *__domainname)); 
     234extern char *bindtextdomain__ PARAMS ((const char *__domainname, 
     235                                       const char *__dirname)); 
     236extern char *bind_textdomain_codeset__ PARAMS ((const char *__domainname, 
     237                                                const char *__codeset)); 
     238#endif 
     239 
     240#ifdef _LIBC 
     241extern void __gettext_free_exp PARAMS ((struct expression *exp)) 
     242     internal_function; 
     243extern int __gettextparse PARAMS ((void *arg)); 
     244#else 
     245extern void gettext_free_exp__ PARAMS ((struct expression *exp)) 
     246     internal_function; 
     247extern int gettextparse__ PARAMS ((void *arg)); 
     248#endif 
    86249 
    87250/* @@ begin of epilog @@ */ 
  • trunk/sweep/intl/hash-string.h

    r7 r124  
    1 /* Implements a string hashing function. 
    2    Copyright (C) 1995, 1997 Free Software Foundation, Inc. 
     1/* Description of GNU message catalog format: string hashing function. 
     2   Copyright (C) 1995, 1997, 1998, 2000, 2001 Free Software Foundation, Inc. 
    33 
    4    This program is free software; you can redistribute it and/or modify 
    5    it under the terms of the GNU General Public License as published by 
    6    the Free Software Foundation; either version 2, or (at your option) 
     4   This program is free software; you can redistribute it and/or modify it 
     5   under the terms of the GNU Library General Public License as published 
     6   by the Free Software Foundation; either version 2, or (at your option) 
    77   any later version. 
    88 
    99   This program is distributed in the hope that it will be useful, 
    1010   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    12    GNU General Public License for more details. 
     11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     12   Library General Public License for more details. 
    1313 
    1414   You should have received a copy of the GNU Library General Public 
    15    License along with the GNU C Library; see the file COPYING.LIB.  If not, 
    16    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330
    17    Boston, MA 02111-1307, USA.  */ 
     15   License along with this program; if not, write to the Free Software 
     16   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307
     17   USA.  */ 
    1818 
    1919/* @@ end of prolog @@ */ 
  • trunk/sweep/intl/intl-compat.c

    r7 r124  
    11/* intl-compat.c - Stub functions to call gettext functions from GNU gettext 
    22   Library. 
    3    Copyright (C) 1995 Software Foundation, Inc. 
     3   Copyright (C) 1995, 2000, 2001 Software Foundation, Inc. 
    44 
    5 This program is free software; you can redistribute it and/or modify 
    6 it under the terms of the GNU General Public License as published by 
    7 the Free Software Foundation; either version 2, or (at your option) 
    8 any later version. 
     5   This program is free software; you can redistribute it and/or modify it 
     6   under the terms of the GNU Library General Public License as published 
     7   by the Free Software Foundation; either version 2, or (at your option) 
     8   any later version. 
    99 
    10 This program is distributed in the hope that it will be useful, 
    11 but WITHOUT ANY WARRANTY; without even the implied warranty of 
    12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    13 GNU General Public License for more details. 
     10   This program is distributed in the hope that it will be useful, 
     11   but WITHOUT ANY WARRANTY; without even the implied warranty of 
     12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     13   Library General Public License for more details. 
    1414 
    15 You should have received a copy of the GNU General Public License 
    16 along with this program; if not, write to the Free Software 
    17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
     15   You should have received a copy of the GNU Library General Public 
     16   License along with this program; if not, write to the Free Software 
     17   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     18   USA.  */ 
    1819 
    1920#ifdef HAVE_CONFIG_H 
     
    2122#endif 
    2223 
    23 #include "libgettext.h" 
     24#include "libgnuintl.h" 
     25#include "gettextP.h" 
    2426 
    2527/* @@ end of prolog @@ */ 
     28 
     29/* This file redirects the gettext functions (without prefix or suffix) to 
     30   those defined in the included GNU gettext library (with "__" suffix). 
     31   It is compiled into libintl when the included GNU gettext library is 
     32   configured --with-included-gettext. 
     33 
     34   This redirection works also in the case that the system C library or 
     35   the system libintl library contain gettext/textdomain/... functions. 
     36   If it didn't, we would need to add preprocessor level redirections to 
     37   libgnuintl.h of the following form: 
     38 
     39#    define gettext gettext__ 
     40#    define dgettext dgettext__ 
     41#    define dcgettext dcgettext__ 
     42#    define ngettext ngettext__ 
     43#    define dngettext dngettext__ 
     44#    define dcngettext dcngettext__ 
     45#    define textdomain textdomain__ 
     46#    define bindtextdomain bindtextdomain__ 
     47#    define bind_textdomain_codeset bind_textdomain_codeset__ 
     48 
     49   How does this redirection work? There are two cases. 
     50   A. When libintl.a is linked into an executable, it works because 
     51      functions defined in the executable always override functions in 
     52      the shared libraries. 
     53   B. When libintl.so is used, it works because 
     54      1. those systems defining gettext/textdomain/... in the C library 
     55         (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer) are 
     56         ELF systems and define these symbols as weak, thus explicitly 
     57         letting other shared libraries override it. 
     58      2. those systems defining gettext/textdomain/... in a standalone 
     59         libintl.so library (namely, Solaris 2.3 and newer) have this 
     60         shared library in /usr/lib, and the linker will search /usr/lib 
     61         *after* the directory where the GNU gettext library is installed. 
     62 
     63   A third case, namely when libintl.a is linked into a shared library 
     64   whose name is not libintl.so, is not supported. In this case, on 
     65   Solaris, when -lintl precedes the linker option for the shared library 
     66   containing GNU gettext, the system's gettext would indeed override 
     67   the GNU gettext. Anyone doing this kind of stuff must be clever enough 
     68   to 1. compile libintl.a with -fPIC, 2. remove -lintl from his linker 
     69   command line.  */ 
    2670 
    2771 
     
    2973#undef dgettext 
    3074#undef dcgettext 
     75#undef ngettext 
     76#undef dngettext 
     77#undef dcngettext 
    3178#undef textdomain 
    3279#undef bindtextdomain 
     80#undef bind_textdomain_codeset 
    3381 
    3482 
    3583char * 
    36 bindtextdomain (domainname, dirname) 
     84gettext (msgid) 
     85     const char *msgid; 
     86
     87  return gettext__ (msgid); 
     88
     89 
     90 
     91char * 
     92dgettext (domainname, msgid) 
    3793     const char *domainname; 
    38      const char *dirname
     94     const char *msgid
    3995{ 
    40   return bindtextdomain__ (domainname, dirname); 
     96  return dgettext__ (domainname, msgid); 
    4197} 
    4298 
     
    53109 
    54110char * 
    55 dgettext (domainname, msgid) 
    56      const char *domainname; 
    57      const char *msgid; 
     111ngettext (msgid1, msgid2, n) 
     112     const char *msgid1; 
     113     const char *msgid2; 
     114     unsigned long int n; 
    58115{ 
    59   return dgettext__ (domainname, msgid); 
     116  return ngettext__ (msgid1, msgid2, n); 
    60117} 
    61118 
    62119 
    63120char * 
    64 gettext (msgid) 
    65      const char *msgid; 
     121dngettext (domainname, msgid1, msgid2, n) 
     122     const char *domainname; 
     123     const char *msgid1; 
     124     const char *msgid2; 
     125     unsigned long int n; 
    66126{ 
    67   return gettext__ (msgid); 
     127  return dngettext__ (domainname, msgid1, msgid2, n); 
     128
     129 
     130 
     131char * 
     132dcngettext (domainname, msgid1, msgid2, n, category) 
     133     const char *domainname; 
     134     const char *msgid1; 
     135     const char *msgid2; 
     136     unsigned long int n; 
     137     int category; 
     138
     139  return dcngettext__ (domainname, msgid1, msgid2, n, category); 
    68140} 
    69141 
     
    75147  return textdomain__ (domainname); 
    76148} 
     149 
     150 
     151char * 
     152bindtextdomain (domainname, dirname) 
     153     const char *domainname; 
     154     const char *dirname; 
     155{ 
     156  return bindtextdomain__ (domainname, dirname); 
     157} 
     158 
     159 
     160char * 
     161bind_textdomain_codeset (domainname, codeset) 
     162     const char *domainname; 
     163     const char *codeset; 
     164{ 
     165  return bind_textdomain_codeset__ (domainname, codeset); 
     166} 
  • trunk/sweep/intl/l10nflist.c

    r7 r124  
    1 /* Handle list of needed message catalogs 
    2    Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. 
     1/* Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. 
    32   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. 
    43 
    5    This program is free software; you can redistribute it and/or modify 
    6    it under the terms of the GNU General Public License as published by 
    7    the Free Software Foundation; either version 2, or (at your option) 
     4   This program is free software; you can redistribute it and/or modify it 
     5   under the terms of the GNU Library General Public License as published 
     6   by the Free Software Foundation; either version 2, or (at your option) 
    87   any later version. 
    98 
    109   This program is distributed in the hope that it will be useful, 
    1110   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    13    GNU General Public License for more details. 
    14  
    15    You should have received a copy of the GNU General Public License 
    16    along with this program; if not, write to the Free Software Foundation, 
    17    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
     11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     12   Library General Public License for more details. 
     13 
     14   You should have received a copy of the GNU Library General Public 
     15   License along with this program; if not, write to the Free Software 
     16   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     17   USA.  */ 
     18 
     19/* Tell glibc's <string.h> to provide a prototype for stpcpy(). 
     20   This must come before <config.h> because <config.h> may include 
     21   <features.h>, and once <features.h> has been included, it's too late.  */ 
     22#ifndef _GNU_SOURCE 
     23# define _GNU_SOURCE    1 
     24#endif 
    1825 
    1926#ifdef HAVE_CONFIG_H 
     
    2128#endif 
    2229 
    23  
    24 #if defined HAVE_STRING_H || defined _LIBC 
    25 # ifndef _GNU_SOURCE 
    26 #  define _GNU_SOURCE   1 
    27 # endif 
    28 # include <string.h> 
    29 #else 
    30 # include <strings.h> 
    31 # ifndef memcpy 
    32 #  define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) 
    33 # endif 
    34 #endif 
     30#include <string.h> 
    3531#if !HAVE_STRCHR && !defined _LIBC 
    3632# ifndef strchr 
     
    4440#include <ctype.h> 
    4541#include <sys/types.h> 
    46  
    47 #if defined STDC_HEADERS || defined _LIBC 
    48 # include <stdlib.h> 
    49 #endif 
     42#include <stdlib.h> 
    5043 
    5144#include "loadinfo.h" 
     
    225218  /* Construct file name.  */ 
    226219  memcpy (abs_filename, dirlist, dirlist_len); 
    227   __argz_stringify (abs_filename, dirlist_len, ':'); 
     220  __argz_stringify (abs_filename, dirlist_len, PATH_SEPARATOR); 
    228221  cp = abs_filename + (dirlist_len - 1); 
    229222  *cp++ = '/'; 
     
    350343/* Normalize codeset name.  There is no standard for the codeset 
    351344   names.  Normalization allows the user to use any of the common 
    352    names.  */ 
     345   names.  The return value is dynamically allocated and has to be 
     346   freed by the caller.  */ 
    353347const char * 
    354348_nl_normalize_codeset (codeset, name_len) 
  • trunk/sweep/intl/libgettext.h

    r7 r124  
    1 /* Message catalogs for internationalization
    2    Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 
     1/* Convenience header for conditional use of GNU <libintl.h>
     2   Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. 
    33 
    4    This program is free software; you can redistribute it and/or modify 
    5    it under the terms of the GNU General Public License as published by 
    6    the Free Software Foundation; either version 2, or (at your option) 
     4   This program is free software; you can redistribute it and/or modify it 
     5   under the terms of the GNU Library General Public License as published 
     6   by the Free Software Foundation; either version 2, or (at your option) 
    77   any later version. 
    88 
    99   This program is distributed in the hope that it will be useful, 
    1010   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    12    GNU General Public License for more details. 
     11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     12   Library General Public License for more details. 
    1313 
    14    You should have received a copy of the GNU General Public License 
    15    along with this program; if not, write to the Free Software Foundation, 
    16    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
     14   You should have received a copy of the GNU Library General Public 
     15   License along with this program; if not, write to the Free Software 
     16   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     17   USA.  */ 
    1718 
    18 /* Because on some systems (e.g. Solaris) we sometimes have to include 
    19    the systems libintl.h as well as this file we have more complex 
    20    include protection above.  But the systems header might perhaps also 
    21    define _LIBINTL_H and therefore we have to protect the definition here.  */ 
     19#ifndef _LIBGETTEXT_H 
     20#define _LIBGETTEXT_H 1 
    2221 
    23 #if !defined _LIBINTL_H || !defined _LIBGETTEXT_H 
    24 #ifndef _LIBINTL_H 
    25 # define _LIBINTL_H     1 
    26 #endif 
    27 #define _LIBGETTEXT_H   1 
    28  
    29 /* We define an additional symbol to signal that we use the GNU 
    30    implementation of gettext.  */ 
    31 #define __USE_GNU_GETTEXT 1 
    32  
    33 #include <sys/types.h> 
    34  
    35 #if HAVE_LOCALE_H 
    36 # include <locale.h> 
    37 #endif 
    38  
    39  
    40 #ifdef __cplusplus 
    41 extern "C" { 
    42 #endif 
    43  
    44 /* @@ end of prolog @@ */ 
    45  
    46 #ifndef PARAMS 
    47 # if __STDC__ || defined __cplusplus 
    48 #  define PARAMS(args) args 
    49 # else 
    50 #  define PARAMS(args) () 
    51 # endif 
    52 #endif 
    53  
    54 #ifndef NULL 
    55 # if !defined __cplusplus || defined __GNUC__ 
    56 #  define NULL ((void *) 0) 
    57 # else 
    58 #  define NULL (0) 
    59 # endif 
    60 #endif 
    61  
    62 #if !HAVE_LC_MESSAGES 
    63 /* This value determines the behaviour of the gettext() and dgettext() 
    64    function.  But some system does not have this defined.  Define it 
    65    to a default value.  */ 
    66 # define LC_MESSAGES (-1) 
    67 #endif 
    68  
    69  
    70 /* Declarations for gettext-using-catgets interface.  Derived from 
    71    Jim Meyering's libintl.h.  */ 
    72 struct _msg_ent 
    73 
    74   const char *_msg; 
    75   int _msg_number; 
    76 }; 
    77  
    78  
    79 #if HAVE_CATGETS 
    80 /* These two variables are defined in the automatically by po-to-tbl.sed 
    81    generated file `cat-id-tbl.c'.  */ 
    82 extern const struct _msg_ent _msg_tbl[]; 
    83 extern int _msg_tbl_length; 
    84 #endif 
    85  
    86  
    87 /* For automatical extraction of messages sometimes no real 
    88    translation is needed.  Instead the string itself is the result.  */ 
    89 #define gettext_noop(Str) (Str) 
    90  
    91 /* Look up MSGID in the current default message catalog for the current 
    92    LC_MESSAGES locale.  If not found, returns MSGID itself (the default 
    93    text).  */ 
    94 extern char *gettext PARAMS ((const char *__msgid)); 
    95 extern char *gettext__ PARAMS ((const char *__msgid)); 
    96  
    97 /* Look up MSGID in the DOMAINNAME message catalog for the current 
    98    LC_MESSAGES locale.  */ 
    99 extern char *dgettext PARAMS ((const char *__domainname, const char *__msgid)); 
    100 extern char *dgettext__ PARAMS ((const char *__domainname, 
    101                                  const char *__msgid)); 
    102  
    103 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY 
    104    locale.  */ 
    105 extern char *dcgettext PARAMS ((const char *__domainname, const char *__msgid, 
    106                                 int __category)); 
    107 extern char *dcgettext__ PARAMS ((const char *__domainname, 
    108                                   const char *__msgid, int __category)); 
    109  
    110  
    111 /* Set the current default message catalog to DOMAINNAME. 
    112    If DOMAINNAME is null, return the current default. 
    113    If DOMAINNAME is "", reset to the default of "messages".  */ 
    114 extern char *textdomain PARAMS ((const char *__domainname)); 
    115 extern char *textdomain__ PARAMS ((const char *__domainname)); 
    116  
    117 /* Specify that the DOMAINNAME message catalog will be found 
    118    in DIRNAME rather than in the system locale data base.  */ 
    119 extern char *bindtextdomain PARAMS ((const char *__domainname, 
    120                                   const char *__dirname)); 
    121 extern char *bindtextdomain__ PARAMS ((const char *__domainname, 
    122                                     const char *__dirname)); 
    123  
     22/* NLS can be disabled through the configure --disable-nls option.  */ 
    12423#if ENABLE_NLS 
    12524 
    126 /* Solaris 2.3 has the gettext function but dcgettext is missing. 
    127    So we omit this optimization for Solaris 2.3.  BTW, Solaris 2.4 
    128    has dcgettext.  */ 
    129 # if !HAVE_CATGETS && (!HAVE_GETTEXT || HAVE_DCGETTEXT) 
    130  
    131 #  define gettext(Msgid)                                                      \ 
    132      dgettext (NULL, Msgid) 
    133  
    134 #  define dgettext(Domainname, Msgid)                                         \ 
    135      dcgettext (Domainname, Msgid, LC_MESSAGES) 
    136  
    137 #  if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ >= 7 
    138 /* This global variable is defined in loadmsgcat.c.  We need a sign, 
    139    whether a new catalog was loaded, which can be associated with all 
    140    translations.  */ 
    141 extern int _nl_msg_cat_cntr; 
    142  
    143 #   define dcgettext(Domainname, Msgid, Category)                             \ 
    144   (__extension__                                                              \ 
    145    ({                                                                         \ 
    146      char *__result;                                                          \ 
    147      if (__builtin_constant_p (Msgid))                                        \ 
    148        {                                                                      \ 
    149          static char *__translation__;                                        \ 
    150          static int __catalog_counter__;                                      \ 
    151          if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr)    \ 
    152            {                                                                  \ 
    153              __translation__ =                                                \ 
    154                dcgettext__ (Domainname, Msgid, Category);                     \ 
    155              __catalog_counter__ = _nl_msg_cat_cntr;                          \ 
    156            }                                                                  \ 
    157          __result = __translation__;                                          \ 
    158        }                                                                      \ 
    159      else                                                                     \ 
    160        __result = dcgettext__ (Domainname, Msgid, Category);                  \ 
    161      __result;                                                                \ 
    162     })) 
    163 #  endif 
    164 # endif 
     25/* Get declarations of GNU message catalog functions.  */ 
     26# include <libintl.h> 
    16527 
    16628#else 
     
    16931# define dgettext(Domainname, Msgid) (Msgid) 
    17032# define dcgettext(Domainname, Msgid, Category) (Msgid) 
    171 # define textdomain(Domainname) ((char *) Domainname) 
    172 # define bindtextdomain(Domainname, Dirname) ((char *) Dirname) 
     33# define ngettext(Msgid1, Msgid2, N) \ 
     34    ((N) == 1 ? (char *) (Msgid1) : (char *) (Msgid2)) 
     35# define dngettext(Domainname, Msgid1, Msgid2, N) \ 
     36    ((N) == 1 ? (char *) (Msgid1) : (char *) (Msgid2)) 
     37# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ 
     38    ((N) == 1 ? (char *) (Msgid1) : (char *) (Msgid2)) 
     39# define textdomain(Domainname) ((char *) (Domainname)) 
     40# define bindtextdomain(Domainname, Dirname) ((char *) (Dirname)) 
     41# define bind_textdomain_codeset(Domainname, Codeset) ((char *) (Codeset)) 
    17342 
    17443#endif 
    17544 
    176 /* @@ begin of epilog @@ */ 
     45/* For automatical extraction of messages sometimes no real 
     46   translation is needed.  Instead the string itself is the result.  */ 
     47#define gettext_noop(Str) (Str) 
    17748 
    178 #ifdef __cplusplus 
    179 
    180 #endif 
    181  
    182 #endif 
     49#endif /* _LIBGETTEXT_H */ 
  • trunk/sweep/intl/loadinfo.h

    r7 r124  
    1 /* Copyright (C) 1996, 1997 Free Software Foundation, Inc. 
     1/* Copyright (C) 1996-1999, 2000, 2001 Free Software Foundation, Inc. 
    22   This file is part of the GNU C Library. 
    33   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. 
    44 
    5    This program is free software; you can redistribute it and/or modify 
    6    it under the terms of the GNU General Public License as published by 
    7    the Free Software Foundation; either version 2, or (at your option) 
     5   This program is free software; you can redistribute it and/or modify it 
     6   under the terms of the GNU Library General Public License as published 
     7   by the Free Software Foundation; either version 2, or (at your option) 
    88   any later version. 
    99 
    1010   This program is distributed in the hope that it will be useful, 
    1111   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    13    GNU General Public License for more details. 
     12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     13   Library General Public License for more details. 
    1414 
    15    You should have received a copy of the GNU General Public License 
    16    along with this program; if not, write to the Free Software Foundation, 
    17    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
     15   You should have received a copy of the GNU Library General Public 
     16   License along with this program; if not, write to the Free Software 
     17   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     18   USA.  */ 
     19 
     20#ifndef _LOADINFO_H 
     21#define _LOADINFO_H     1 
    1822 
    1923#ifndef PARAMS 
     
    2327#  define PARAMS(args) () 
    2428# endif 
     29#endif 
     30 
     31#ifndef internal_function 
     32# define internal_function 
     33#endif 
     34 
     35/* Tell the compiler when a conditional or integer expression is 
     36   almost always true or almost always false.  */ 
     37#ifndef HAVE_BUILTIN_EXPECT 
     38# define __builtin_expect(expr, val) (expr) 
     39#endif 
     40 
     41/* Separator in PATH like lists of pathnames.  */ 
     42#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__ 
     43  /* Win32, OS/2, DOS */ 
     44# define PATH_SEPARATOR ';' 
     45#else 
     46  /* Unix */ 
     47# define PATH_SEPARATOR ':' 
    2548#endif 
    2649 
     
    5174 
    5275 
     76/* Normalize codeset name.  There is no standard for the codeset 
     77   names.  Normalization allows the user to use any of the common 
     78   names.  The return value is dynamically allocated and has to be 
     79   freed by the caller.  */ 
    5380extern const char *_nl_normalize_codeset PARAMS ((const char *codeset, 
    5481                                                  size_t name_len)); 
     
    6794extern const char *_nl_expand_alias PARAMS ((const char *name)); 
    6895 
     96/* normalized_codeset is dynamically allocated and has to be freed by 
     97   the caller.  */ 
    6998extern int _nl_explode_name PARAMS ((char *name, const char **language, 
    7099                                     const char **modifier, 
     
    77106 
    78107extern char *_nl_find_language PARAMS ((const char *name)); 
     108 
     109#endif  /* loadinfo.h */ 
  • trunk/sweep/intl/loadmsgcat.c

    r7 r124  
    11/* Load needed message catalogs. 
    2    Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 
    3  
    4    This program is free software; you can redistribute it and/or modify 
    5    it under the terms of the GNU General Public License as published by 
    6    the Free Software Foundation; either version 2, or (at your option) 
     2   Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. 
     3 
     4   This program is free software; you can redistribute it and/or modify it 
     5   under the terms of the GNU Library General Public License as published 
     6   by the Free Software Foundation; either version 2, or (at your option) 
    77   any later version. 
    88 
    99   This program is distributed in the hope that it will be useful, 
    1010   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    12    GNU General Public License for more details. 
    13  
    14    You should have received a copy of the GNU General Public License 
    15    along with this program; if not, write to the Free Software Foundation, 
    16    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
     11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     12   Library General Public License for more details. 
     13 
     14   You should have received a copy of the GNU Library General Public 
     15   License along with this program; if not, write to the Free Software 
     16   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     17   USA.  */ 
     18 
     19/* Tell glibc's <string.h> to provide a prototype for mempcpy(). 
     20   This must come before <config.h> because <config.h> may include 
     21   <features.h>, and once <features.h> has been included, it's too late.  */ 
     22#ifndef _GNU_SOURCE 
     23# define _GNU_SOURCE    1 
     24#endif 
    1725 
    1826#ifdef HAVE_CONFIG_H 
     
    2028#endif 
    2129 
     30#include <ctype.h> 
     31#include <errno.h> 
    2232#include <fcntl.h> 
    2333#include <sys/types.h> 
    2434#include <sys/stat.h> 
    2535 
    26 #if defined STDC_HEADERS || defined _LIBC 
    27 # include <stdlib.h> 
    28 #endif 
     36#ifdef __GNUC__ 
     37# define alloca __builtin_alloca 
     38# define HAVE_ALLOCA 1 
     39#else 
     40# if defined HAVE_ALLOCA_H || defined _LIBC 
     41#  include <alloca.h> 
     42# else 
     43#  ifdef _AIX 
     44 #pragma alloca 
     45#  else 
     46#   ifndef alloca 
     47char *alloca (); 
     48#   endif 
     49#  endif 
     50# endif 
     51#endif 
     52 
     53#include <stdlib.h> 
     54#include <string.h> 
    2955 
    3056#if defined HAVE_UNISTD_H || defined _LIBC 
    3157# include <unistd.h> 
     58#endif 
     59 
     60#ifdef _LIBC 
     61# include <langinfo.h> 
     62# include <locale.h> 
    3263#endif 
    3364 
     
    4374#include "gettext.h" 
    4475#include "gettextP.h" 
     76 
     77#ifdef _LIBC 
     78# include "../locale/localeinfo.h" 
     79#endif 
    4580 
    4681/* @@ end of prolog @@ */ 
     
    5792#endif 
    5893 
     94/* Names for the libintl functions are a problem.  They must not clash 
     95   with existing names and they should follow ANSI C.  But this source 
     96   code is also used in GNU C Library where the names have a __ 
     97   prefix.  So we have to make a difference here.  */ 
     98#ifdef _LIBC 
     99# define PLURAL_PARSE __gettextparse 
     100#else 
     101# define PLURAL_PARSE gettextparse__ 
     102#endif 
     103 
     104/* For those losing systems which don't have `alloca' we have to add 
     105   some additional code emulating it.  */ 
     106#ifdef HAVE_ALLOCA 
     107# define freea(p) /* nothing */ 
     108#else 
     109# define alloca(n) malloc (n) 
     110# define freea(p) free (p) 
     111#endif 
     112 
     113/* For systems that distinguish between text and binary I/O. 
     114   O_BINARY is usually declared in <fcntl.h>. */ 
     115#if !defined O_BINARY && defined _O_BINARY 
     116  /* For MSC-compatible compilers.  */ 
     117# define O_BINARY _O_BINARY 
     118# define O_TEXT _O_TEXT 
     119#endif 
     120#ifdef __BEOS__ 
     121  /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect.  */ 
     122# undef O_BINARY 
     123# undef O_TEXT 
     124#endif 
     125/* On reasonable systems, binary I/O is the default.  */ 
     126#ifndef O_BINARY 
     127# define O_BINARY 0 
     128#endif 
     129 
    59130/* We need a sign, whether a new catalog was loaded, which can be associated 
    60131   with all translations.  This is important if the translations are 
    61132   cached by one of GCC's features.  */ 
    62 int _nl_msg_cat_cntr = 0; 
    63  
     133int _nl_msg_cat_cntr; 
     134 
     135#if (defined __GNUC__ && !defined __APPLE_CC__) \ 
     136    || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) 
     137 
     138/* These structs are the constant expression for the germanic plural 
     139   form determination.  It represents the expression  "n != 1".  */ 
     140static const struct expression plvar = 
     141
     142  .nargs = 0, 
     143  .operation = var, 
     144}; 
     145static const struct expression plone = 
     146
     147  .nargs = 0, 
     148  .operation = num, 
     149  .val = 
     150  { 
     151    .num = 1 
     152  } 
     153}; 
     154static struct expression germanic_plural = 
     155
     156  .nargs = 2, 
     157  .operation = not_equal, 
     158  .val = 
     159  { 
     160    .args = 
     161    { 
     162      [0] = (struct expression *) &plvar, 
     163      [1] = (struct expression *) &plone 
     164    } 
     165  } 
     166}; 
     167 
     168# define INIT_GERMANIC_PLURAL() 
     169 
     170#else 
     171 
     172/* For compilers without support for ISO C 99 struct/union initializers: 
     173   Initialization at run-time.  */ 
     174 
     175static struct expression plvar; 
     176static struct expression plone; 
     177static struct expression germanic_plural; 
     178 
     179static void 
     180init_germanic_plural () 
     181
     182  if (plone.val.num == 0) 
     183    { 
     184      plvar.nargs = 0; 
     185      plvar.operation = var; 
     186 
     187      plone.nargs = 0; 
     188      plone.operation = num; 
     189      plone.val.num = 1; 
     190 
     191      germanic_plural.nargs = 2; 
     192      germanic_plural.operation = not_equal; 
     193      germanic_plural.val.args[0] = &plvar; 
     194      germanic_plural.val.args[1] = &plone; 
     195    } 
     196
     197 
     198# define INIT_GERMANIC_PLURAL() init_germanic_plural () 
     199 
     200#endif 
     201 
     202 
     203/* Initialize the codeset dependent parts of an opened message catalog. 
     204   Return the header entry.  */ 
     205const char * 
     206internal_function 
     207_nl_init_domain_conv (domain_file, domain, domainbinding) 
     208     struct loaded_l10nfile *domain_file; 
     209     struct loaded_domain *domain; 
     210     struct binding *domainbinding; 
     211
     212  /* Find out about the character set the file is encoded with. 
     213     This can be found (in textual form) in the entry "".  If this 
     214     entry does not exist or if this does not contain the `charset=' 
     215     information, we will assume the charset matches the one the 
     216     current locale and we don't have to perform any conversion.  */ 
     217  char *nullentry; 
     218  size_t nullentrylen; 
     219 
     220  /* Preinitialize fields, to avoid recursion during _nl_find_msg.  */ 
     221  domain->codeset_cntr = 
     222    (domainbinding != NULL ? domainbinding->codeset_cntr : 0); 
     223#ifdef _LIBC 
     224  domain->conv = (__gconv_t) -1; 
     225#else 
     226# if HAVE_ICONV 
     227  domain->conv = (iconv_t) -1; 
     228# endif 
     229#endif 
     230  domain->conv_tab = NULL; 
     231 
     232  /* Get the header entry.  */ 
     233  nullentry = _nl_find_msg (domain_file, domainbinding, "", &nullentrylen); 
     234 
     235  if (nullentry != NULL) 
     236    { 
     237#if defined _LIBC || HAVE_ICONV 
     238      const char *charsetstr; 
     239 
     240      charsetstr = strstr (nullentry, "charset="); 
     241      if (charsetstr != NULL) 
     242        { 
     243          size_t len; 
     244          char *charset; 
     245          const char *outcharset; 
     246 
     247          charsetstr += strlen ("charset="); 
     248          len = strcspn (charsetstr, " \t\n"); 
     249 
     250          charset = (char *) alloca (len + 1); 
     251# if defined _LIBC || HAVE_MEMPCPY 
     252          *((char *) mempcpy (charset, charsetstr, len)) = '\0'; 
     253# else 
     254          memcpy (charset, charsetstr, len); 
     255          charset[len] = '\0'; 
     256# endif 
     257 
     258          /* The output charset should normally be determined by the 
     259             locale.  But sometimes the locale is not used or not correctly 
     260             set up, so we provide a possibility for the user to override 
     261             this.  Moreover, the value specified through 
     262             bind_textdomain_codeset overrides both.  */ 
     263          if (domainbinding != NULL && domainbinding->codeset != NULL) 
     264            outcharset = domainbinding->codeset; 
     265          else 
     266            { 
     267              outcharset = getenv ("OUTPUT_CHARSET"); 
     268              if (outcharset == NULL || outcharset[0] == '\0') 
     269                { 
     270# ifdef _LIBC 
     271                  outcharset = (*_nl_current[LC_CTYPE])->values[_NL_ITEM_INDEX (CODESET)].string; 
     272# else 
     273#  if HAVE_ICONV 
     274                  extern const char *locale_charset (void); 
     275                  outcharset = locale_charset (); 
     276#  endif 
     277# endif 
     278                } 
     279            } 
     280 
     281# ifdef _LIBC 
     282          /* We always want to use transliteration.  */ 
     283          outcharset = norm_add_slashes (outcharset, "TRANSLIT"); 
     284          charset = norm_add_slashes (charset, NULL); 
     285          if (__gconv_open (outcharset, charset, &domain->conv, 
     286                            GCONV_AVOID_NOCONV) 
     287              != __GCONV_OK) 
     288            domain->conv = (__gconv_t) -1; 
     289# else 
     290#  if HAVE_ICONV 
     291          /* When using GNU libiconv, we want to use transliteration.  */ 
     292#   if _LIBICONV_VERSION >= 0x0105 
     293          len = strlen (outcharset); 
     294          { 
     295            char *tmp = (char *) alloca (len + 10 + 1); 
     296            memcpy (tmp, outcharset, len); 
     297            memcpy (tmp + len, "//TRANSLIT", 10 + 1); 
     298            outcharset = tmp; 
     299          } 
     300#   endif 
     301          domain->conv = iconv_open (outcharset, charset); 
     302#   if _LIBICONV_VERSION >= 0x0105 
     303          freea (outcharset); 
     304#   endif 
     305#  endif 
     306# endif 
     307 
     308          freea (charset); 
     309        } 
     310#endif /* _LIBC || HAVE_ICONV */ 
     311    } 
     312 
     313  return nullentry; 
     314
     315 
     316/* Frees the codeset dependent parts of an opened message catalog.  */ 
     317void 
     318internal_function 
     319_nl_free_domain_conv (domain) 
     320     struct loaded_domain *domain; 
     321
     322  if (domain->conv_tab != NULL && domain->conv_tab != (char **) -1) 
     323    free (domain->conv_tab); 
     324 
     325#ifdef _LIBC 
     326  if (domain->conv != (__gconv_t) -1) 
     327    __gconv_close (domain->conv); 
     328#else 
     329# if HAVE_ICONV 
     330  if (domain->conv != (iconv_t) -1) 
     331    iconv_close (domain->conv); 
     332# endif 
     333#endif 
     334
    64335 
    65336/* Load the message catalogs specified by FILENAME.  If it is no valid 
     
    67338void 
    68339internal_function 
    69 _nl_load_domain (domain_file
     340_nl_load_domain (domain_file, domainbinding
    70341     struct loaded_l10nfile *domain_file; 
     342     struct binding *domainbinding; 
    71343{ 
    72344  int fd; 
    73345  size_t size; 
     346#ifdef _LIBC 
     347  struct stat64 st; 
     348#else 
    74349  struct stat st; 
     350#endif 
    75351  struct mo_file_header *data = (struct mo_file_header *) -1; 
    76352  int use_mmap = 0; 
    77353  struct loaded_domain *domain; 
     354  const char *nullentry; 
    78355 
    79356  domain_file->decided = 1; 
    80357  domain_file->data = NULL; 
     358 
     359  /* Note that it would be useless to store domainbinding in domain_file 
     360     because domainbinding might be == NULL now but != NULL later (after 
     361     a call to bind_textdomain_codeset).  */ 
    81362 
    82363  /* If the record does not represent a valid locale the FILENAME 
     
    88369 
    89370  /* Try to open the addressed file.  */ 
    90   fd = open (domain_file->filename, O_RDONLY); 
     371  fd = open (domain_file->filename, O_RDONLY | O_BINARY); 
    91372  if (fd == -1) 
    92373    return; 
    93374 
    94375  /* We must know about the size of the file.  */ 
    95   if (fstat (fd, &st) != 0 
    96       || (size = (size_t) st.st_size) != st.st_size 
    97       || size < sizeof (struct mo_file_header)) 
     376  if ( 
     377#ifdef _LIBC 
     378      __builtin_expect (fstat64 (fd, &st) != 0, 0) 
     379#else 
     380      __builtin_expect (fstat (fd, &st) != 0, 0) 
     381#endif 
     382      || __builtin_expect ((size = (size_t) st.st_size) != st.st_size, 0) 
     383      || __builtin_expect (size < sizeof (struct mo_file_header), 0)) 
    98384    { 
    99385      /* Something went wrong.  */ 
     
    108394                                         MAP_PRIVATE, fd, 0); 
    109395 
    110   if (data != (struct mo_file_header *) -1
     396  if (__builtin_expect (data != (struct mo_file_header *) -1, 1)
    111397    { 
    112398      /* mmap() call was successful.  */ 
     
    132418        { 
    133419          long int nb = (long int) read (fd, read_ptr, to_read); 
    134           if (nb == -1
     420          if (nb <= 0
    135421            { 
     422#ifdef EINTR 
     423              if (nb == -1 && errno == EINTR) 
     424                continue; 
     425#endif 
    136426              close (fd); 
    137427              return; 
    138428            } 
    139  
    140429          read_ptr += nb; 
    141430          to_read -= nb; 
     
    148437  /* Using the magic number we can test whether it really is a message 
    149438     catalog file.  */ 
    150   if (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED) 
     439  if (__builtin_expect (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED, 
     440                        0)) 
    151441    { 
    152442      /* The magic number is wrong: not a message catalog file.  */ 
     
    160450    } 
    161451 
    162   domain_file->data 
    163     = (struct loaded_domain *) malloc (sizeof (struct loaded_domain)); 
    164   if (domain_file->data == NULL) 
     452  domain = (struct loaded_domain *) malloc (sizeof (struct loaded_domain)); 
     453  if (domain == NULL) 
    165454    return; 
    166  
    167   domain = (struct loaded_domain *) domain_file->data; 
     455  domain_file->data = domain; 
     456 
    168457  domain->data = (char *) data; 
    169458  domain->use_mmap = use_mmap; 
     
    197486    } 
    198487 
    199   /* Show that one domain is changed.  This might make some cached 
    200      translations invalid.  */ 
    201   ++_nl_msg_cat_cntr; 
     488  /* Now initialize the character set converter from the character set 
     489     the file is encoded with (found in the header entry) to the domain's 
     490     specified character set or the locale's character set.  */ 
     491  nullentry = _nl_init_domain_conv (domain_file, domain, domainbinding); 
     492 
     493  /* Also look for a plural specification.  */ 
     494  if (nullentry != NULL) 
     495    { 
     496      const char *plural; 
     497      const char *nplurals; 
     498 
     499      plural = strstr (nullentry, "plural="); 
     500      nplurals = strstr (nullentry, "nplurals="); 
     501      if (plural == NULL || nplurals == NULL) 
     502        goto no_plural; 
     503      else 
     504        { 
     505          /* First get the number.  */ 
     506          char *endp; 
     507          unsigned long int n; 
     508          struct parse_args args; 
     509 
     510          nplurals += 9; 
     511          while (*nplurals != '\0' && isspace (*nplurals)) 
     512            ++nplurals; 
     513#if defined HAVE_STRTOUL || defined _LIBC 
     514          n = strtoul (nplurals, &endp, 10); 
     515#else 
     516          for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++) 
     517            n = n * 10 + (*endp - '0'); 
     518#endif 
     519          domain->nplurals = n; 
     520          if (nplurals == endp) 
     521            goto no_plural; 
     522 
     523          /* Due to the restrictions bison imposes onto the interface of the 
     524             scanner function we have to put the input string and the result 
     525             passed up from the parser into the same structure which address 
     526             is passed down to the parser.  */ 
     527          plural += 7; 
     528          args.cp = plural; 
     529          if (PLURAL_PARSE (&args) != 0) 
     530            goto no_plural; 
     531          domain->plural = args.res; 
     532        } 
     533    } 
     534  else 
     535    { 
     536      /* By default we are using the Germanic form: singular form only 
     537         for `one', the plural form otherwise.  Yes, this is also what 
     538         English is using since English is a Germanic language.  */ 
     539    no_plural: 
     540      INIT_GERMANIC_PLURAL (); 
     541      domain->plural = &germanic_plural; 
     542      domain->nplurals = 2; 
     543    } 
    202544} 
    203545 
     
    209551     struct loaded_domain *domain; 
    210552{ 
    211 #ifdef _POSIX_MAPPED_FILES 
     553  if (domain->plural != &germanic_plural) 
     554    __gettext_free_exp (domain->plural); 
     555 
     556  _nl_free_domain_conv (domain); 
     557 
     558# ifdef _POSIX_MAPPED_FILES 
    212559  if (domain->use_mmap) 
    213560    munmap ((caddr_t) domain->data, domain->mmap_size); 
    214561  else 
    215 #endif        /* _POSIX_MAPPED_FILES */ 
     562# endif       /* _POSIX_MAPPED_FILES */ 
    216563    free ((void *) domain->data); 
    217564 
  • trunk/sweep/intl/localealias.c

    r7 r124  
    11/* Handle aliases for locale names. 
    2    Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 
    3    Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. 
    4  
    5    This program is free software; you can redistribute it and/or modify 
    6    it under the terms of the GNU General Public License as published by 
    7    the Free Software Foundation; either version 2, or (at your option) 
     2   Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. 
     3 
     4   This program is free software; you can redistribute it and/or modify it 
     5   under the terms of the GNU Library General Public License as published 
     6   by the Free Software Foundation; either version 2, or (at your option) 
    87   any later version. 
    98 
    109   This program is distributed in the hope that it will be useful, 
    1110   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    13    GNU General Public License for more details. 
    14  
    15    You should have received a copy of the GNU General Public License 
    16    along with this program; if not, write to the Free Software Foundation, 
    17    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
     11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     12   Library General Public License for more details. 
     13 
     14   You should have received a copy of the GNU Library General Public 
     15   License along with this program; if not, write to the Free Software 
     16   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     17   USA.  */ 
     18 
     19/* Tell glibc's <string.h> to provide a prototype for mempcpy(). 
     20   This must come before <config.h> because <config.h> may include 
     21   <features.h>, and once <features.h> has been included, it's too late.  */ 
     22#ifndef _GNU_SOURCE 
     23# define _GNU_SOURCE    1 
     24#endif 
    1825 
    1926#ifdef HAVE_CONFIG_H 
     
    4249#endif 
    4350 
    44 #if defined STDC_HEADERS || defined _LIBC 
    45 # include <stdlib.h> 
    46 #else 
    47 char *getenv (); 
    48 # ifdef HAVE_MALLOC_H 
    49 #  include <malloc.h> 
    50 # else 
    51 void free (); 
    52 # endif 
    53 #endif 
    54  
    55 #if defined HAVE_STRING_H || defined _LIBC 
    56 # ifndef _GNU_SOURCE 
    57 #  define _GNU_SOURCE   1 
    58 # endif 
    59 # include <string.h> 
    60 #else 
    61 # include <strings.h> 
    62 # ifndef memcpy 
    63 #  define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) 
    64 # endif 
    65 #endif 
     51#include <stdlib.h> 
     52 
     53#include <string.h> 
    6654#if !HAVE_STRCHR && !defined _LIBC 
    6755# ifndef strchr 
     
    7058#endif 
    7159 
    72 #include "gettext.h" 
    7360#include "gettextP.h" 
    7461 
     
    9683#endif 
    9784 
    98 /* For those loosing systems which don't have `alloca' we have to add 
     85/* For those losing systems which don't have `alloca' we have to add 
    9986   some additional code emulating it.  */ 
    10087#ifdef HAVE_ALLOCA 
    101 /* Nothing has to be done.  */ 
    102 # define ADD_BLOCK(list, address) /* nothing */ 
    103 # define FREE_BLOCKS(list) /* nothing */ 
     88# define freea(p) /* nothing */ 
    10489#else 
    105 struct block_list 
    106 
    107   void *address; 
    108   struct block_list *next; 
    109 }; 
    110 # define ADD_BLOCK(list, addr)                                                \ 
    111   do {                                                                        \ 
    112     struct block_list *newp = (struct block_list *) malloc (sizeof (*newp));  \ 
    113     /* If we cannot get a free block we cannot add the new element to         \ 
    114        the list.  */                                                          \ 
    115     if (newp != NULL) {                                                       \ 
    116       newp->address = (addr);                                                 \ 
    117       newp->next = (list);                                                    \ 
    118       (list) = newp;                                                          \ 
    119     }                                                                         \ 
    120   } while (0) 
    121 # define FREE_BLOCKS(list)                                                    \ 
    122   do {                                                                        \ 
    123     while (list != NULL) {                                                    \ 
    124       struct block_list *old = list;                                          \ 
    125       list = list->next;                                                      \ 
    126       free (old);                                                             \ 
    127     }                                                                         \ 
    128   } while (0) 
    129 # undef alloca 
    130 # define alloca(size) (malloc (size)) 
    131 #endif  /* have alloca */ 
     90# define alloca(n) malloc (n) 
     91# define freea(p) free (p) 
     92#endif 
    13293 
    13394#if defined _LIBC_REENTRANT || defined HAVE_FGETS_UNLOCKED 
     
    148109 
    149110 
    150 static char *string_space = NULL
    151 static size_t string_space_act = 0
    152 static size_t string_space_max = 0
     111static char *string_space
     112static size_t string_space_act
     113static size_t string_space_max
    153114static struct alias_map *map; 
    154 static size_t nmap = 0
    155 static size_t maxmap = 0
     115static size_t nmap
     116static size_t maxmap
    156117 
    157118 
     
    159120static size_t read_alias_file PARAMS ((const char *fname, int fname_len)) 
    160121     internal_function; 
    161 static void extend_alias_table PARAMS ((void)); 
     122static int extend_alias_table PARAMS ((void)); 
    162123static int alias_compare PARAMS ((const struct alias_map *map1, 
    163124                                  const struct alias_map *map2)); 
     
    205166          const char *start; 
    206167 
    207           while (locale_alias_path[0] == ':'
     168          while (locale_alias_path[0] == PATH_SEPARATOR
    208169            ++locale_alias_path; 
    209170          start = locale_alias_path; 
    210171 
    211           while (locale_alias_path[0] != '\0' && locale_alias_path[0] != ':') 
     172          while (locale_alias_path[0] != '\0' 
     173                 && locale_alias_path[0] != PATH_SEPARATOR) 
    212174            ++locale_alias_path; 
    213175 
     
    232194     int fname_len; 
    233195{ 
    234 #ifndef HAVE_ALLOCA 
    235   struct block_list *block_list = NULL; 
    236 #endif 
    237196  FILE *fp; 
    238197  char *full_fname; 
     
    241200 
    242201  full_fname = (char *) alloca (fname_len + sizeof aliasfile); 
    243   ADD_BLOCK (block_list, full_fname); 
    244202#ifdef HAVE_MEMPCPY 
    245203  mempcpy (mempcpy (full_fname, fname, fname_len), 
     
    251209 
    252210  fp = fopen (full_fname, "r"); 
     211  freea (full_fname); 
    253212  if (fp == NULL) 
    254     { 
    255       FREE_BLOCKS (block_list); 
    256       return 0; 
    257     } 
     213    return 0; 
    258214 
    259215  added = 0; 
     
    327283 
    328284              if (nmap >= maxmap) 
    329                 extend_alias_table (); 
     285                if (__builtin_expect (extend_alias_table (), 0)) 
     286                  return added; 
    330287 
    331288              alias_len = strlen (alias) + 1; 
     
    340297                  char *new_pool = (char *) realloc (string_space, new_size); 
    341298                  if (new_pool == NULL) 
     299                    return added; 
     300 
     301                  if (__builtin_expect (string_space != new_pool, 0)) 
    342302                    { 
    343                       FREE_BLOCKS (block_list); 
    344                       return added; 
     303                      size_t i; 
     304 
     305                      for (i = 0; i < nmap; i++) 
     306                        { 
     307                          map[i].alias += new_pool - string_space; 
     308                          map[i].value += new_pool - string_space; 
     309                        } 
    345310                    } 
     311 
    346312                  string_space = new_pool; 
    347313                  string_space_max = new_size; 
     
    370336           (int (*) PARAMS ((const void *, const void *))) alias_compare); 
    371337 
    372   FREE_BLOCKS (block_list); 
    373338  return added; 
    374339} 
    375340 
    376341 
    377 static void 
     342static int 
    378343extend_alias_table () 
    379344{ 
     
    386351  if (new_map == NULL) 
    387352    /* Simply don't extend: we don't have any more core.  */ 
    388     return
     353    return -1
    389354 
    390355  map = new_map; 
    391356  maxmap = new_size; 
     357  return 0; 
    392358} 
    393359 
  • trunk/sweep/intl/textdomain.c

    r7 r124  
    11/* Implementation of the textdomain(3) function. 
    2    Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 
    3    Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. 
     2   Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. 
    43 
    5    This program is free software; you can redistribute it and/or modify 
    6    it under the terms of the GNU General Public License as published by 
    7    the Free Software Foundation; either version 2, or (at your option) 
     4   This program is free software; you can redistribute it and/or modify it 
     5   under the terms of the GNU Library General Public License as published 
     6   by the Free Software Foundation; either version 2, or (at your option) 
    87   any later version. 
    98 
    109   This program is distributed in the hope that it will be useful, 
    1110   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    13    GNU General Public License for more details. 
     11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     12   Library General Public License for more details. 
    1413 
    15    You should have received a copy of the GNU General Public License 
    16    along with this program; if not, write to the Free Software Foundation, 
    17    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
     14   You should have received a copy of the GNU Library General Public 
     15   License along with this program; if not, write to the Free Software 
     16   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
     17   USA.  */ 
    1818 
    1919#ifdef HAVE_CONFIG_H 
     
    2121#endif 
    2222 
    23 #if defined STDC_HEADERS || defined _LIBC 
    24 # include <stdlib.h> 
    25 #endif 
    26  
    27 #if defined STDC_HEADERS || defined HAVE_STRING_H || defined _LIBC 
    28 # include <string.h> 
    29 #else 
    30 # include <strings.h> 
    31 # ifndef memcpy 
    32 #  define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) 
    33 # endif 
    34 #endif 
     23#include <stdlib.h> 
     24#include <string.h> 
    3525 
    3626#ifdef _LIBC 
    3727# include <libintl.h> 
    3828#else 
    39 # include "libgettext.h" 
     29# include "libgnuintl.h" 
     30#endif 
     31#include "gettextP.h" 
     32 
     33#ifdef _LIBC 
     34/* We have to handle multi-threaded applications.  */ 
     35# include <bits/libc-lock.h> 
     36#else 
     37/* Provide dummy implementation if this is outside glibc.  */ 
     38# define __libc_rwlock_define(CLASS, NAME) 
     39# define __libc_rwlock_wrlock(NAME) 
     40# define __libc_rwlock_unlock(NAME) 
     41#endif 
     42 
     43/* The internal variables in the standalone libintl.a must have different 
     44   names than the internal variables in GNU libc, otherwise programs 
     45   using libintl.a cannot be linked statically.  */ 
     46#if !defined _LIBC 
     47# define _nl_default_default_domain _nl_default_default_domain__ 
     48# define _nl_current_default_domain _nl_current_default_domain__ 
    4049#endif 
    4150 
     
    6271#endif 
    6372 
     73/* Lock variable to protect the global data in the gettext implementation.  */ 
     74__libc_rwlock_define (extern, _nl_state_lock) 
     75 
    6476/* Set the current default message catalog to DOMAINNAME. 
    6577   If DOMAINNAME is null, return the current default. 
     
    6981     const char *domainname; 
    7082{ 
    71   char *old; 
     83  char *new_domain; 
     84  char *old_domain; 
    7285 
    7386  /* A NULL pointer requests the current setting.  */ 
     
    7588    return (char *) _nl_current_default_domain; 
    7689 
    77   old = (char *) _nl_current_default_domain; 
     90  __libc_rwlock_wrlock (_nl_state_lock); 
     91 
     92  old_domain = (char *) _nl_current_default_domain; 
    7893 
    7994  /* If domain name is the null string set to default domain "messages".  */ 
    8095  if (domainname[0] == '\0' 
    8196      || strcmp (domainname, _nl_default_default_domain) == 0) 
    82     _nl_current_default_domain = _nl_default_default_domain; 
     97    { 
     98      _nl_current_default_domain = _nl_default_default_domain; 
     99      new_domain = (char *) _nl_current_default_domain; 
     100    } 
     101  else if (strcmp (domainname, old_domain) == 0) 
     102    /* This can happen and people will use it to signal that some 
     103       environment variable changed.  */ 
     104    new_domain = old_domain; 
    83105  else 
    84106    { 
     
    87109         are out of core.  */ 
    88110#if defined _LIBC || defined HAVE_STRDUP 
    89       _nl_current_default_domain = strdup (domainname); 
     111      new_domain = strdup (domainname); 
    90112#else 
    91113      size_t len = strlen (domainname) + 1; 
    92       char *cp = (char *) malloc (len); 
    93       if (cp != NULL) 
    94         memcpy (cp, domainname, len); 
    95       _nl_current_default_domain = cp; 
     114      new_domain = (char *) malloc (len); 
     115      if (new_domain != NULL) 
     116        memcpy (new_domain, domainname, len); 
    96117#endif 
     118 
     119      if (new_domain != NULL) 
     120        _nl_current_default_domain = new_domain; 
    97121    } 
    98122 
    99   if (old != _nl_default_default_domain) 
    100     free (old); 
     123  /* We use this possibility to signal a change of the loaded catalogs 
     124     since this is most likely the case and there is no other easy we 
     125     to do it.  Do it only when the call was successful.  */ 
     126  if (new_domain != NULL) 
     127    { 
     128      ++_nl_msg_cat_cntr; 
    101129 
    102   return (char *) _nl_current_default_domain; 
     130      if (old_domain != new_domain && old_domain != _nl_default_default_domain) 
     131        free (old_domain); 
     132    } 
     133 
     134  __libc_rwlock_unlock (_nl_state_lock); 
     135 
     136  return new_domain; 
    103137} 
    104138 
  • trunk/sweep/missing

    r7 r124  
    11#! /bin/sh 
    22# Common stub for a few missing GNU programs while installing. 
    3 # Copyright (C) 1996, 1997 Free Software Foundation, Inc. 
    4 # Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996. 
     3# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc. 
     4# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 
    55 
    66# This program is free software; you can redistribute it and/or modify 
     
    1919# 02111-1307, USA. 
    2020 
     21# As a special exception to the GNU General Public License, if you 
     22# distribute this file as part of a program that contains a 
     23# configuration script generated by Autoconf, you may include it under 
     24# the same distribution terms that you use for the rest of that program. 
     25 
    2126if test $# -eq 0; then 
    2227  echo 1>&2 "Try \`$0 --help' for more information" 
     
    2429fi 
    2530 
     31run=: 
     32 
     33# In the cases where this matters, `missing' is being run in the 
     34# srcdir already. 
     35if test -f configure.ac; then 
     36  configure_ac=configure.ac 
     37else 
     38  configure_ac=configure.in 
     39fi 
     40 
     41case "$1" in 
     42--run) 
     43  # Try to run requested program, and just exit if it succeeds. 
     44  run= 
     45  shift 
     46  "$@" && exit 0 
     47  ;; 
     48esac 
     49 
     50# If it does not exist, or fails to run (possibly an outdated version), 
     51# try to emulate it. 
    2652case "$1" in 
    2753 
     
    3662  -h, --help      display this help and exit 
    3763  -v, --version   output version information and exit 
     64  --run           try to run the given command, and emulate it if it fails 
    3865 
    3966Supported PROGRAM values: 
     
    4471  bison        create \`y.tab.[ch]', if possible, from existing .[ch] 
    4572  flex         create \`lex.yy.c', if possible, from existing .c 
     73  help2man     touch the output file 
    4674  lex          create \`lex.yy.c', if possible, from existing .c 
    4775  makeinfo     touch the output file 
     76  tar          try tar, gnutar, gtar, then tar without non-portable flags 
    4877  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]" 
    4978    ;; 
    5079 
    5180  -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 
    52     echo "missing - GNU libit 0.0
     81    echo "missing 0.4 - GNU automake
    5382    ;; 
    5483 
     
    5988    ;; 
    6089 
    61   aclocal) 
    62     echo 1>&2 "\ 
    63 WARNING: \`$1' is missing on your system.  You should only need it if 
    64          you modified \`acinclude.m4' or \`configure.in'.  You might want 
     90  aclocal*) 
     91    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 
     92       # We have it, but it failed. 
     93       exit 1 
     94    fi 
     95 
     96    echo 1>&2 "\ 
     97WARNING: \`$1' is missing on your system.  You should only need it if 
     98         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want 
    6599         to install the \`Automake' and \`Perl' packages.  Grab them from 
    66100         any GNU archive site." 
     
    69103 
    70104  autoconf) 
    71     echo 1>&2 "\ 
    72 WARNING: \`$1' is missing on your system.  You should only need it if 
    73          you modified \`configure.in'.  You might want to install the 
     105    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 
     106       # We have it, but it failed. 
     107       exit 1 
     108    fi 
     109 
     110    echo 1>&2 "\ 
     111WARNING: \`$1' is missing on your system.  You should only need it if 
     112         you modified \`${configure_ac}'.  You might want to install the 
    74113         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU 
    75114         archive site." 
     
    78117 
    79118  autoheader) 
    80     echo 1>&2 "\ 
    81 WARNING: \`$1' is missing on your system.  You should only need it if 
    82          you modified \`acconfig.h' or \`configure.in'.  You might want 
     119    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 
     120       # We have it, but it failed. 
     121       exit 1 
     122    fi 
     123 
     124    echo 1>&2 "\ 
     125WARNING: \`$1' is missing on your system.  You should only need it if 
     126         you modified \`acconfig.h' or \`${configure_ac}'.  You might want 
    83127         to install the \`Autoconf' and \`GNU m4' packages.  Grab them 
    84128         from any GNU archive site." 
    85     files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in
     129    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}
    86130    test -z "$files" && files="config.h" 
    87131    touch_files= 
     
    96140    ;; 
    97141 
    98   automake) 
    99     echo 1>&2 "\ 
    100 WARNING: \`$1' is missing on your system.  You should only need it if 
    101          you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. 
     142  automake*) 
     143    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 
     144       # We have it, but it failed. 
     145       exit 1 
     146    fi 
     147 
     148    echo 1>&2 "\ 
     149WARNING: \`$1' is missing on your system.  You should only need it if 
     150         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. 
    102151         You might want to install the \`Automake' and \`Perl' packages. 
    103152         Grab them from any GNU archive site." 
     
    105154           sed 's/\.am$/.in/' | 
    106155           while read f; do touch "$f"; done 
     156    ;; 
     157 
     158  autom4te) 
     159    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 
     160       # We have it, but it failed. 
     161       exit 1 
     162    fi 
     163 
     164    echo 1>&2 "\ 
     165WARNING: \`$1' is needed, and you do not seem to have it handy on your 
     166         system.  You might have modified some files without having the 
     167         proper tools for further handling them. 
     168         You can get \`$1Help2man' as part of \`Autoconf' from any GNU 
     169         archive site." 
     170 
     171    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` 
     172    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` 
     173    if test -f "$file"; then 
     174        touch $file 
     175    else 
     176        test -z "$file" || exec >$file 
     177        echo "#! /bin/sh" 
     178        echo "# Created by GNU Automake missing as a replacement of" 
     179        echo "#  $ $@" 
     180        echo "exit 0" 
     181        chmod +x $file 
     182        exit 1 
     183    fi 
    107184    ;; 
    108185 
     
    160237    ;; 
    161238 
     239  help2man) 
     240    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 
     241       # We have it, but it failed. 
     242       exit 1 
     243    fi 
     244 
     245    echo 1>&2 "\ 
     246WARNING: \`$1' is missing on your system.  You should only need it if 
     247         you modified a dependency of a manual page.  You may need the 
     248         \`Help2man' package in order for those modifications to take 
     249         effect.  You can get \`Help2man' from any GNU archive site." 
     250 
     251    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` 
     252    if test -z "$file"; then 
     253        file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` 
     254    fi 
     255    if [ -f "$file" ]; then 
     256        touch $file 
     257    else 
     258        test -z "$file" || exec >$file 
     259        echo ".ab help2man is required to generate this page" 
     260        exit 1 
     261    fi 
     262    ;; 
     263 
    162264  makeinfo) 
     265    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then 
     266       # We have makeinfo, but it failed. 
     267       exit 1 
     268    fi 
     269 
    163270    echo 1>&2 "\ 
    164271WARNING: \`$1' is missing on your system.  You should only need it if 
     
    176283    ;; 
    177284 
     285  tar) 
     286    shift 
     287    if test -n "$run"; then 
     288      echo 1>&2 "ERROR: \`tar' requires --run" 
     289      exit 1 
     290    fi 
     291 
     292    # We have already tried tar in the generic part. 
     293    # Look for gnutar/gtar before invocation to avoid ugly error 
     294    # messages. 
     295    if (gnutar --version > /dev/null 2>&1); then 
     296       gnutar "$@" && exit 0 
     297    fi 
     298    if (gtar --version > /dev/null 2>&1); then 
     299       gtar "$@" && exit 0 
     300    fi 
     301    firstarg="$1" 
     302    if shift; then 
     303        case "$firstarg" in 
     304        *o*) 
     305            firstarg=`echo "$firstarg" | sed s/o//` 
     306            tar "$firstarg" "$@" && exit 0 
     307            ;; 
     308        esac 
     309        case "$firstarg" in 
     310        *h*) 
     311            firstarg=`echo "$firstarg" | sed s/h//` 
     312            tar "$firstarg" "$@" && exit 0 
     313            ;; 
     314        esac 
     315    fi 
     316 
     317    echo 1>&2 "\ 
     318WARNING: I can't seem to be able to run \`tar' with the given arguments. 
     319         You may want to install GNU tar or Free paxutils, or check the 
     320         command line arguments." 
     321    exit 1 
     322    ;; 
     323 
    178324  *) 
    179325    echo 1>&2 "\ 
  • trunk/sweep/mkinstalldirs

    r7 r124  
    55# Public domain 
    66 
    7 # $Id$ 
     7errstatus=0 
     8dirmode="" 
    89 
    9 errstatus=0 
     10usage="\ 
     11Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." 
     12 
     13# process command line arguments 
     14while test $# -gt 0 ; do 
     15   case "${1}" in 
     16     -h | --help | --h* )                       # -h for help 
     17        echo "${usage}" 1>&2; exit 0 ;; 
     18     -m )                                       # -m PERM arg 
     19        shift 
     20        test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } 
     21        dirmode="${1}" 
     22        shift ;; 
     23     -- ) shift; break ;;                       # stop option processing 
     24     -* ) echo "${usage}" 1>&2; exit 1 ;;       # unknown option 
     25     * )  break ;;                              # first non-opt arg 
     26   esac 
     27done 
     28 
     29for file 
     30do 
     31  if test -d "$file"; then 
     32    shift 
     33  else 
     34    break 
     35  fi 
     36done 
     37 
     38case $# in 
     390) exit 0 ;; 
     40esac 
     41 
     42case $dirmode in 
     43'') 
     44  if mkdir -p -- . 2>/dev/null; then 
     45    echo "mkdir -p -- $*" 
     46    exec mkdir -p -- "$@" 
     47  fi ;; 
     48*) 
     49  if mkdir -m "$dirmode" -p -- . 2>/dev/null; then 
     50    echo "mkdir -m $dirmode -p -- $*" 
     51    exec mkdir -m "$dirmode" -p -- "$@" 
     52  fi ;; 
     53esac 
    1054 
    1155for file 
     
    2367 
    2468     if test ! -d "$pathcomp"; then 
    25         echo "mkdir $pathcomp" 
     69       echo "mkdir $pathcomp" 
    2670 
    27         mkdir "$pathcomp" || lasterr=$? 
     71       mkdir "$pathcomp" || lasterr=$? 
    2872 
    29         if test ! -d "$pathcomp"; then 
    30           errstatus=$lasterr 
    31         fi 
     73        if test ! -d "$pathcomp"; then 
     74          errstatus=$lasterr 
     75        else 
     76          if test ! -z "$dirmode"; then 
     77             echo "chmod $dirmode $pathcomp" 
     78 
     79             lasterr="" 
     80             chmod "$dirmode" "$pathcomp" || lasterr=$? 
     81 
     82             if test ! -z "$lasterr"; then 
     83               errstatus=$lasterr 
     84             fi 
     85          fi 
     86        fi 
    3287     fi 
    3388 
     
    3893exit $errstatus 
    3994 
     95# Local Variables: 
     96# mode: shell-script 
     97# sh-indentation: 3 
     98# End: 
    4099# mkinstalldirs ends here 
  • trunk/sweep/plugins/Makefile.am

    r84 r124  
    11## Process this file with automake to produce Makefile.in 
    22 
    3 SUBDIRS = example byenergy echo normalise reverse ladspa 
     3SUBDIRS = example byenergy echo fade normalise reverse ladspa 
  • trunk/sweep/plugins/byenergy/byenergy.c

    r80 r124  
    5757  { 
    5858    N_("Select regions above threshold"), 
    59     N_("Whether to select those regions lying above a given threshhold
     59    N_("Whether to select those regions lying above a given threshold
    6060       "or below it."), 
    6161    SWEEP_TYPE_BOOL, 
     
    112112  gfloat max_interruption_f = pset[4].f; 
    113113 
     114  sw_sounddata * sounddata; 
    114115  sw_audio_t * d; 
    115116  glong window, win_s; 
     
    120121  sw_audio_intermediate_t di, energy, max_energy=0, factor=1.0; 
    121122 
    122   window = (glong)(resolution * (gfloat)s->sounddata->format->rate); 
    123   length = s->sounddata->nr_frames; 
    124   min_duration = (glong)(min_duration_f * (gfloat)s->sounddata->format->rate); 
     123  sounddata = sample_get_sounddata (s); 
     124 
     125  window = (glong)(resolution * (gfloat)sounddata->format->rate); 
     126  length = sounddata->nr_frames; 
     127  min_duration = (glong)(min_duration_f * (gfloat)sounddata->format->rate); 
    125128 
    126129  /* check (end-1 - (start+1)) > 0 */ 
    127130  min_duration = MAX(2*window, min_duration); 
    128   max_interruption = (glong)(max_interruption_f * (gfloat)s->sounddata->format->rate); 
    129  
    130   d = (sw_audio_t *)s->sounddata->data; 
    131  
    132   sounddata_lock_selection (s->sounddata); 
    133  
    134   sounddata_clear_selection (s->sounddata); 
     131  max_interruption = (glong)(max_interruption_f * (gfloat)sounddata->format->rate); 
     132 
     133  d = (sw_audio_t *)sounddata->data; 
     134 
     135  sounddata_lock_selection (sounddata); 
     136 
     137  sounddata_clear_selection (sounddata); 
    135138 
    136139  /* Find max for normalisation */ 
    137140 
    138   length = s->sounddata->nr_frames; 
     141  length = sounddata->nr_frames; 
    139142  doff = 0; 
    140143  while (length > 0) { 
    141144    energy = 0; 
    142145 
    143     win_s = frames_to_samples (s->sounddata->format, MIN(length, window)); 
     146    win_s = frames_to_samples (sounddata->format, MIN(length, window)); 
    144147 
    145148    /* calculate avg. for this window */ 
     
    166169  threshold *= (gfloat)max_energy; 
    167170 
    168   length = s->sounddata->nr_frames; 
     171  length = sounddata->nr_frames; 
    169172  doff = 0; 
    170173  while (length > 0) { 
    171174    energy = 0; 
    172175 
    173     win_s = frames_to_samples (s->sounddata->format, MIN(length, window)); 
     176    win_s = frames_to_samples (sounddata->format, MIN(length, window)); 
    174177 
    175178    /* calculate RMS energy for this window */ 
     
    198201      if (loc - end > max_interruption) { 
    199202        if (end - start > min_duration) { 
    200           sounddata_add_selection_1 (s->sounddata, start+1, end-1); 
     203          sounddata_add_selection_1 (sounddata, start+1, end-1); 
    201204        } 
    202205        end = start = -1; 
     
    211214  if (start != -1) { 
    212215    if (end - start > min_duration) { 
    213       sounddata_add_selection_1 (s->sounddata, start, end); 
    214     } 
    215   } 
    216  
    217   if (s->sounddata->sels == NULL) { 
    218     sample_stop_marching_ants(s); 
    219   } 
    220  
    221   sounddata_unlock_selection (s->sounddata); 
     216      sounddata_add_selection_1 (sounddata, start, end); 
     217    } 
     218  } 
     219 
     220  sounddata_unlock_selection (sounddata); 
    222221} 
    223222 
     
    227226  return 
    228227    perform_selection_op (sample, _("Select by energy"), 
    229                           (SweepModify)select_by_energy, pset, NULL); 
     228                          (SweepFilter)select_by_energy, pset, NULL); 
    230229} 
    231230 
     
    233232  N_("Select by energy"), 
    234233  N_("Select loud or quiet regions"), 
    235   "Conrad Parker", 
    236   "Copyright (C) 2000", 
     234  "C. Parker, S. Pfeiffer", 
     235  "Copyright (C) 2000 CSIRO Australia", 
    237236  "http://sweep.sourceforge.net/plugins/byenergy", 
    238237  "Filters/Select by energy", /* identifier */ 
  • trunk/sweep/plugins/example/Makefile.am

    r96 r124  
    99# lib to stop it from actually being installed. 
    1010# 
    11 lib_LTLIBRARIES = libexample.la 
    12 #noinst_LTLIBRARIES = libexample.la 
     11#lib_LTLIBRARIES = libexample.la 
     12noinst_LTLIBRARIES = libexample.la 
    1313 
    1414libexample_la_SOURCES = example.c 
  • trunk/sweep/plugins/ladspa/ladspa.h

    r13 r124  
    11/* ladspa.h 
    22 
    3    Version 1. Copyright 2000 Richard W.E. Furse, Paul Barton-Davis, 
    4    Stefan Westerfeld. */ 
     3   Linux Audio Developer's Simple Plugin API Version 1.1[provisional, 
     4   LGPL].  Copyright (C) 2000-2002 Richard W.E. Furse, Paul 
     5   Barton-Davis, Stefan Westerfeld. 
     6    
     7   This library is free software; you can redistribute it and/or 
     8   modify it under the terms of the GNU Lesser General Public License 
     9   as published by the Free Software Foundation; either version 2.1 of 
     10   the License, or (at your option) any later version. 
     11    
     12   This library is distributed in the hope that it will be useful, but 
     13   WITHOUT ANY WARRANTY; without even the implied warranty of 
     14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
     15   Lesser General Public License for more details. 
     16    
     17   You should have received a copy of the GNU Lesser General Public 
     18   License along with this library; if not, write to the Free Software 
     19   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 
     20   USA. */ 
    521 
    622#ifndef LADSPA_INCLUDED 
     
    2137   them dynamically (`plug') into a range of these packages (`hosts'). 
    2238   It should be possible for any host and any plugin to communicate 
    23    completely through this interface. The LADSPA plugin API is free to 
    24    use. 
     39   completely through this interface. 
    2540 
    2641   This API is deliberately short and simple. To achieve compatibility 
     
    5873   is used to communicate audio samples and control values. It is 
    5974   assumed that the plugin will work sensibly given any numeric input 
    60    value although it may have a preferred range (see hints below). */ 
     75   value although it may have a preferred range (see hints below).  
     76 
     77   For audio it is generally assumed that 1.0f is the `0dB' reference 
     78   amplitude and is a `normal' signal level. */ 
    6179 
    6280typedef float LADSPA_Data; 
     
    184202   specified then the value of LowerBound should be multiplied by the 
    185203   sample rate. */ 
    186 #define LADSPA_HINT_BOUNDED_BELOW 0x1 
     204#define LADSPA_HINT_BOUNDED_BELOW   0x1 
    187205 
    188206/* Hint LADSPA_HINT_BOUNDED_ABOVE indicates that the UpperBound field 
     
    192210   specified then the value of UpperBound should be multiplied by the 
    193211   sample rate. */ 
    194 #define LADSPA_HINT_BOUNDED_ABOVE 0x2 
     212#define LADSPA_HINT_BOUNDED_ABOVE   0x2 
    195213 
    196214/* Hint LADSPA_HINT_TOGGLED indicates that the data item should be 
     
    198216   be considered `off' or `false,' and data above zero should be 
    199217   considered `on' or `true.' LADSPA_HINT_TOGGLED may not be used in 
    200    conjunction with any other hint. */ 
    201 #define LADSPA_HINT_TOGGLED       0x4 
     218   conjunction with any other hint except LADSPA_HINT_DEFAULT_0 or 
     219   LADSPA_HINT_DEFAULT_1. */ 
     220#define LADSPA_HINT_TOGGLED         0x4 
    202221 
    203222/* Hint LADSPA_HINT_SAMPLE_RATE indicates that any bounds specified 
     
    207226   with LowerBound = 0 and UpperBound = 0.5. Hosts that support bounds 
    208227   at all must support this hint to retain meaning. */ 
    209 #define LADSPA_HINT_SAMPLE_RATE   0x8 
     228#define LADSPA_HINT_SAMPLE_RATE     0x8 
    210229 
    211230/* Hint LADSPA_HINT_LOGARITHMIC indicates that it is likely that the 
    212231   user will find it more intuitive to view values using a logarithmic 
    213232   scale. This is particularly useful for frequencies and gains. */ 
    214 #define LADSPA_HINT_LOGARITHMIC   0x10 
     233#define LADSPA_HINT_LOGARITHMIC     0x10 
    215234 
    216235/* Hint LADSPA_HINT_INTEGER indicates that a user interface would 
     
    220239   instance, the integer set {0,1,2,3} might be described as [-0.1, 
    221240   3.1]. */ 
    222 #define LADSPA_HINT_INTEGER       0x20 
     241#define LADSPA_HINT_INTEGER         0x20 
     242 
     243/* The various LADSPA_HINT_HAS_DEFAULT_* hints indicate a `normal' 
     244   value for the port that is sensible as a default. For instance, 
     245   this value is suitable for use as an initial value in a user 
     246   interface or as a value the host might assign to a control port 
     247   when the user has not provided one. Defaults are encoded using a 
     248   mask so only one default may be specified for a port. Some of the 
     249   hints make use of lower and upper bounds, in which case the 
     250   relevant bound or bounds must be available and 
     251   LADSPA_HINT_SAMPLE_RATE must be applied as usual. The resulting 
     252   default must be rounded if LADSPA_HINT_INTEGER is present. Default 
     253   values were introduced in LADSPA v1.1. */ 
     254#define LADSPA_HINT_DEFAULT_MASK    0x3C0 
     255 
     256/* This default values indicates that no default is provided. */ 
     257#define LADSPA_HINT_DEFAULT_NONE    0x0 
     258 
     259/* This default hint indicates that the suggested lower bound for the 
     260   port should be used. */ 
     261#define LADSPA_HINT_DEFAULT_MINIMUM 0x40 
     262 
     263/* This default hint indicates that a low value between the suggested 
     264   lower and upper bounds should be chosen. For ports with 
     265   LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.75 + 
     266   log(upper) * 0.25). Otherwise, this should be (lower * 0.75 + upper 
     267   * 0.25). */ 
     268#define LADSPA_HINT_DEFAULT_LOW     0x80 
     269 
     270/* This default hint indicates that a middle value between the 
     271   suggested lower and upper bounds should be chosen. For ports with 
     272   LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.5 + 
     273   log(upper) * 0.5). Otherwise, this should be (lower * 0.5 + upper * 
     274   0.5). */ 
     275#define LADSPA_HINT_DEFAULT_MIDDLE  0xC0 
     276 
     277/* This default hint indicates that a high value between the suggested 
     278   lower and upper bounds should be chosen. For ports with 
     279   LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.25 + 
     280   log(upper) * 0.75). Otherwise, this should be (lower * 0.25 + upper 
     281   * 0.75). */ 
     282#define LADSPA_HINT_DEFAULT_HIGH    0x100 
     283 
     284/* This default hint indicates that the suggested upper bound for the 
     285   port should be used. */ 
     286#define LADSPA_HINT_DEFAULT_MAXIMUM 0x140 
     287 
     288/* This default hint indicates that the number 0 should be used. Note 
     289   that this default may be used in conjunction with 
     290   LADSPA_HINT_TOGGLED. */ 
     291#define LADSPA_HINT_DEFAULT_0       0x200 
     292 
     293/* This default hint indicates that the number 1 should be used. Note 
     294   that this default may be used in conjunction with 
     295   LADSPA_HINT_TOGGLED. */ 
     296#define LADSPA_HINT_DEFAULT_1       0x240 
     297 
     298/* This default hint indicates that the number 100 should be used. */ 
     299#define LADSPA_HINT_DEFAULT_100     0x280 
     300 
     301/* This default hint indicates that the Hz frequency of `concert A' 
     302   should be used. This will be 440 unless the host uses an unusual 
     303   tuning convention, in which case it may be within a few Hz. */ 
     304#define LADSPA_HINT_DEFAULT_440     0x2C0 
    223305 
    224306#define LADSPA_IS_HINT_BOUNDED_BELOW(x) ((x) & LADSPA_HINT_BOUNDED_BELOW) 
     
    228310#define LADSPA_IS_HINT_LOGARITHMIC(x)   ((x) & LADSPA_HINT_LOGARITHMIC) 
    229311#define LADSPA_IS_HINT_INTEGER(x)       ((x) & LADSPA_HINT_INTEGER) 
     312 
     313#define LADSPA_IS_HINT_HAS_DEFAULT(x)   ((x) & LADSPA_HINT_DEFAULT_MASK) 
     314#define LADSPA_IS_HINT_DEFAULT_MINIMUM(x)  (((x) & LADSPA_HINT_DEFAULT_MASK)  \ 
     315                                         == LADSPA_HINT_DEFAULT_MINIMUM) 
     316#define LADSPA_IS_HINT_DEFAULT_LOW(x)      (((x) & LADSPA_HINT_DEFAULT_MASK)  \ 
     317                                         == LADSPA_HINT_DEFAULT_LOW) 
     318#define LADSPA_IS_HINT_DEFAULT_MIDDLE(x)   (((x) & LADSPA_HINT_DEFAULT_MASK)  \ 
     319                                         == LADSPA_HINT_DEFAULT_MIDDLE) 
     320#define LADSPA_IS_HINT_DEFAULT_HIGH(x)     (((x) & LADSPA_HINT_DEFAULT_MASK)  \ 
     321                                         == LADSPA_HINT_DEFAULT_HIGH) 
     322#define LADSPA_IS_HINT_DEFAULT_MAXIMUM(x)  (((x) & LADSPA_HINT_DEFAULT_MASK)  \ 
     323                                         == LADSPA_HINT_DEFAULT_MAXIMUM) 
     324#define LADSPA_IS_HINT_DEFAULT_0(x)        (((x) & LADSPA_HINT_DEFAULT_MASK)  \ 
     325                                         == LADSPA_HINT_DEFAULT_0) 
     326#define LADSPA_IS_HINT_DEFAULT_1(x)        (((x) & LADSPA_HINT_DEFAULT_MASK)  \ 
     327                                         == LADSPA_HINT_DEFAULT_1) 
     328#define LADSPA_IS_HINT_DEFAULT_100(x)      (((x) & LADSPA_HINT_DEFAULT_MASK)  \ 
     329                                         == LADSPA_HINT_DEFAULT_100) 
     330#define LADSPA_IS_HINT_DEFAULT_440(x)      (((x) & LADSPA_HINT_DEFAULT_MASK)  \ 
     331                                         == LADSPA_HINT_DEFAULT_440) 
    230332 
    231333typedef struct _LADSPA_PortRangeHint { 
     
    490592 
    491593#ifdef __cplusplus 
    492 }; 
     594} 
    493595#endif 
    494596 
  • trunk/sweep/plugins/ladspa/ladspameta.c

    r58 r124  
    3939 
    4040#include <sweep/sweep.h> 
     41#include "../src/sweep_app.h" 
    4142 
    4243#include "ladspa.h" 
     
    115116 
    116117  if (LADSPA_IS_HINT_BOUNDED_BELOW(prhd)) 
    117     ret &= SW_RANGE_LOWER_BOUND_VALID; 
     118    ret |= SW_RANGE_LOWER_BOUND_VALID; 
    118119  if (LADSPA_IS_HINT_BOUNDED_ABOVE(prhd)) 
    119     ret &= SW_RANGE_UPPER_BOUND_VALID; 
     120    ret |= SW_RANGE_UPPER_BOUND_VALID; 
    120121 
    121122  return ret; 
     
    123124 
    124125static sw_param_range * 
    125 convert_constraint (const LADSPA_PortRangeHint * prh) 
     126convert_constraint ( /* sw_format * format, */ 
     127                    const LADSPA_PortRangeHint * prh) 
    126128{ 
    127129  sw_param_range * pr; 
    128130  LADSPA_PortRangeHintDescriptor prhd = prh->HintDescriptor; 
     131  LADSPA_Data lower, upper; 
    129132 
    130133  if (LADSPA_IS_HINT_TOGGLED(prhd)) 
     
    135138  pr->valid_mask = get_valid_mask (prhd); 
    136139 
     140  lower = prh->LowerBound; 
     141  upper = prh->UpperBound; 
     142 
     143  if LADSPA_IS_HINT_SAMPLE_RATE (prhd) { 
     144#if 0 
     145    lower *= format->rate; 
     146    upper *= format->rate; 
     147#else 
     148    lower *= 44100; 
     149    upper *= 44100; 
     150#endif 
     151  } 
     152 
    137153  if (LADSPA_IS_HINT_INTEGER(prhd)) { 
    138154    if (LADSPA_IS_HINT_BOUNDED_BELOW(prhd)) 
    139       pr->lower.i = (sw_int)prh->LowerBound
     155      pr->lower.i = (sw_int)lower
    140156    if (LADSPA_IS_HINT_BOUNDED_ABOVE(prhd)) 
    141       pr->upper.i = (sw_int)prh->UpperBound
     157      pr->upper.i = (sw_int)upper
    142158  } else { 
    143159    if (LADSPA_IS_HINT_BOUNDED_BELOW(prhd)) 
    144       pr->lower.f = (sw_float)prh->LowerBound
     160      pr->lower.f = (sw_float)lower
    145161    if (LADSPA_IS_HINT_BOUNDED_ABOVE(prhd)) 
    146       pr->upper.f = (sw_float)prh->UpperBound
     162      pr->upper.f = (sw_float)upper
    147163  } 
    148164 
     
    171187} 
    172188 
     189static sw_param 
     190convert_default (sw_format * format, const LADSPA_PortRangeHint * prh) 
     191{ 
     192  LADSPA_PortRangeHintDescriptor prhd = prh->HintDescriptor; 
     193  LADSPA_Data lower, upper; 
     194  gboolean bounded = FALSE; 
     195  sw_float def = 0.0; 
     196  sw_param param; 
     197 
     198  /* Cache whether or not this port is bounded */ 
     199  bounded = LADSPA_IS_HINT_BOUNDED_BELOW (prhd) && 
     200    LADSPA_IS_HINT_BOUNDED_ABOVE (prhd); 
     201 
     202  lower = prh->LowerBound; 
     203  upper = prh->UpperBound; 
     204 
     205  if LADSPA_IS_HINT_SAMPLE_RATE (prhd) { 
     206    lower *= format->rate; 
     207    upper *= format->rate; 
     208  } 
     209 
     210  /* Determine default value, as sw_float */ 
     211 
     212  if (!LADSPA_IS_HINT_HAS_DEFAULT (prhd)) { 
     213    def = 0.0; 
     214  } else if (LADSPA_IS_HINT_DEFAULT_MINIMUM (prhd)) { 
     215    def = prh->LowerBound; 
     216  } else if (bounded && LADSPA_IS_HINT_DEFAULT_LOW (prhd)) { 
     217    if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) { 
     218      def = exp(log(lower) * 0.75 + log(upper) * 0.25); 
     219    } else { 
     220      def = lower * 0.75 + upper * 0.25; 
     221    } 
     222  } else if (bounded && LADSPA_IS_HINT_DEFAULT_MIDDLE (prhd)) { 
     223    if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) { 
     224      exp(log(lower) * 0.5 + log(upper) * 0.5); 
     225    } else { 
     226      def = lower * 0.5 + upper * 0.5; 
     227    } 
     228  } else if (bounded && LADSPA_IS_HINT_DEFAULT_HIGH (prhd)) { 
     229    if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) { 
     230      exp(log(lower) * 0.25 + log(upper) * 0.75); 
     231    } else { 
     232      def = lower * 0.25 + upper * 0.75; 
     233    } 
     234  } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM (prhd)) { 
     235    def = prh->UpperBound; 
     236  } else if (LADSPA_IS_HINT_DEFAULT_0 (prhd)) { 
     237    def = 0.0; 
     238  } else if (LADSPA_IS_HINT_DEFAULT_1 (prhd)) { 
     239    def = 1.0; 
     240  } else if (LADSPA_IS_HINT_DEFAULT_100 (prhd)) { 
     241    def = 100.0; 
     242  } else if (LADSPA_IS_HINT_DEFAULT_440 (prhd)) { 
     243    def = 440.0; 
     244  } else { 
     245    def = 0.0; 
     246  } 
     247 
     248  /* Convert to sw_param type */ 
     249 
     250  if (LADSPA_IS_HINT_TOGGLED (prhd)) { 
     251    param.b = (sw_bool)def; 
     252  } else if (LADSPA_IS_HINT_INTEGER (prhd)) { 
     253    param.i = (sw_int)def; 
     254  } else { 
     255    param.f = (sw_float)def; 
     256  } 
     257 
     258  return param; 
     259} 
     260 
    173261static void 
    174 ladspa_meta_apply_region (gpointer pcmdata, sw_format * format, 
    175                           gint nr_frames, 
    176                           sw_param_set pset, gpointer custom_data) 
     262ladspa_meta_suggest (sw_sample * sample, sw_param_set pset, 
     263                     gpointer custom_data) 
     264
     265  sw_sounddata * sounddata; 
     266  lm_custom * lm = (lm_custom *)custom_data; 
     267  const LADSPA_Descriptor * d = lm->d; 
     268 
     269  LADSPA_PortDescriptor pd; 
     270  int i, pset_i = 0; 
     271 
     272  sounddata = sample_get_sounddata (sample); 
     273 
     274  for (i=0; i < d->PortCount; i++) { 
     275    pd = d->PortDescriptors[i]; 
     276    if (LADSPA_IS_CONTROL_INPUT(pd)) { 
     277      pset[pset_i] = convert_default (sounddata->format, 
     278                                      &d->PortRangeHints[i]); 
     279      pset_i++; 
     280    } 
     281  } 
     282 
     283
     284 
     285#define BLOCK_SIZE 1024 
     286 
     287static sw_sample * 
     288ladspa_meta_apply_filter (sw_sample * sample, sw_param_set pset, 
     289                          gpointer custom_data) 
    177290{ 
    178291  lm_custom * lm = (lm_custom *)custom_data; 
     
    180293  sw_param_spec * param_specs = lm->param_specs; 
    181294 
    182   LADSPA_Handle * handle; 
     295  sw_sounddata * sounddata; 
     296  sw_format * format; 
     297  sw_framecount_t op_total, run_total; 
     298  sw_framecount_t offset, remaining, n; 
     299 
     300  GList * gl; 
     301  sw_sel * sel; 
     302 
     303  gpointer pcmdata; 
     304 
     305  /* The number of times the plugin will be run; ie. if the number of 
     306   * channels in the input pcmdata is greater than the number of 
     307   * audio ports on the ladspa plugin, the plugin will be run 
     308   * multiple times until enough output channels have been calculated. 
     309   */ 
     310  gint nr_handles; 
     311 
     312  LADSPA_Handle ** handles; 
    183313  LADSPA_Data ** input_buffers, ** output_buffers; 
    184   LADSPA_Data * mono_input_buffer=NULL
     314  LADSPA_Data * mono_input_buffers[1], * mono_output_buffers[1]
    185315  LADSPA_Data * p; 
    186316  LADSPA_Data * control_inputs; 
     
    189319  glong length_b; 
    190320  gulong port_i; /* counter for iterating over ports */ 
    191   gint i, j, n; 
    192  
    193   /* The number of times the plugin will be run; ie. if the number of 
    194    * channels in the input pcmdata is greater than the number of 
    195    * audio ports on the ladspa plugin, the plugin will be run 
    196    * multiple times until enough output channels have been calculated. 
    197    */ 
    198   gint iterations; 
     321  gint h, i, j, c; 
    199322 
    200323  /* Enumerate the numbers of each type of port on the ladspa plugin */ 
     
    206329 
    207330  /* The number of audio channels to be processed */ 
    208   gint nr_channels = format->channels
     331  gint nr_channels
    209332 
    210333  /* The number of input and output buffers to use */ 
     
    214337  gint ibi=0, obi=0; 
    215338 
    216  
    217   /* instantiate the ladspa plugin */ 
    218   handle = d->instantiate (d, (long)format->rate); 
     339  gboolean active = TRUE; 
     340 
     341  g_return_val_if_fail (d != NULL, NULL); 
     342 
     343  sounddata = sample_get_sounddata (sample); 
     344  format = sounddata->format; 
     345  nr_channels = format->channels; 
     346 
     347  op_total = sounddata_selection_nr_frames (sounddata) / 100; 
     348  if (op_total == 0) op_total = 1; 
     349  run_total = 0; 
    219350 
    220351  /* Cache how many of each type of port this ladspa plugin has */ 
     
    243374  g_assert (nr_ao > 0); 
    244375 
    245   iterations = (gint) ceil(((double)nr_channels) / ((double)nr_ao)); 
     376  nr_handles = (gint) ceil(((double)nr_channels) / ((double)nr_ao)); 
    246377 
    247378  /* Numbers of input and output buffers: ensure 
    248379   * nr_i >= nr_channels && nr_o >= nr_channels 
    249380   */ 
    250   nr_i = iterations * nr_ai; 
    251   nr_o = iterations * nr_ao; 
     381  nr_i = nr_handles * nr_ai; 
     382  nr_o = nr_handles * nr_ao; 
     383 
     384  /* Create all input and output buffers */ 
    252385 
    253386  if ((nr_channels == 1) && (nr_ai == 1) && (nr_ao >= 1)) { 
     
    257390     */ 
    258391 
    259     /* Copy PCM data if this ladspa plugin cannot work inplace */ 
     392    /* Create an input buffer if this ladspa plugin cannot work inplace */ 
    260393    if (LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 
    261       length_b = frames_to_bytes (format, nr_frames); 
    262       mono_input_buffer = g_malloc (length_b); 
    263       input_buffers = &mono_input_buffer; 
     394      length_b = frames_to_bytes (format, BLOCK_SIZE); 
     395      mono_input_buffers[0] = g_malloc (length_b); 
    264396    } else { 
    265       input_buffers = (LADSPA_Data **)&pcmdata; 
    266     } 
    267      
    268     output_buffers = (LADSPA_Data **)&pcmdata; 
     397      /* Input directly from sample data; mark as NULL */ 
     398      mono_input_buffers[0] = NULL; 
     399    } 
     400    input_buffers = mono_input_buffers; 
     401 
     402    /* Always output directly into the sample data; mark as NULL */ 
     403    mono_output_buffers[0] = NULL; 
     404    output_buffers = mono_output_buffers; 
    269405 
    270406  } else { 
    271     length_b = LADSPA_frames_to_bytes (nr_frames); 
     407    length_b = LADSPA_frames_to_bytes (BLOCK_SIZE); 
    272408 
    273409    /* Allocate zeroed input buffers; these will remain zeroed 
     
    302438  } 
    303439 
    304   /* Copy data into input buffers */ 
    305   if (nr_channels == 1) { 
    306     if (!LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 
    307       length_b = frames_to_bytes (format, nr_frames); 
    308       memcpy (input_buffers[0], pcmdata, length_b); 
    309     } /* else we're processing in-place, so we haven't needed to set 
    310        * up a separate input buffer; input_buffers[0] actually 
    311        * points to pcmdata hence we don't do any copying here. 
    312        */ 
    313   } else { 
    314     /* de-interleave multichannel data */ 
    315  
    316     p = (LADSPA_Data *)pcmdata; 
    317  
    318     for (n=0; n < nr_channels; n++) { 
    319       for (i=0; i < nr_frames; i++) { 
    320         input_buffers[n][i] = *p++; 
    321       } 
    322     } 
     440  /* instantiate the ladspa plugin */ 
     441  handles = g_malloc (sizeof (LADSPA_Handle *) * nr_handles); 
     442  for (h = 0; h < nr_handles; h++) { 
     443    handles[h] = d->instantiate (d, (long)format->rate); 
    323444  } 
    324445 
     
    350471        break; 
    351472      } 
    352       d->connect_port (handle, port_i, &control_inputs[j]); 
     473 
     474      for (h = 0; h < nr_handles; h++) { 
     475        d->connect_port (handles[h], port_i, &control_inputs[j]); 
     476      } 
     477 
    353478      j++; 
    354479    } 
    355480    if (LADSPA_IS_CONTROL_OUTPUT(pd)) { 
    356       d->connect_port (handle, port_i, &dummy_control_output); 
    357     } 
    358   } 
    359  
    360   /* run the plugin as many times as necessary */ 
    361   while (iterations--) { 
    362  
    363     /* connect input and output audio buffers to the 
    364      * audio ports of the ladspa plugin */ 
    365     for (port_i=0; port_i < d->PortCount; port_i++) { 
    366       pd = d->PortDescriptors[(int)port_i]; 
    367       if (LADSPA_IS_AUDIO_INPUT(pd)) { 
    368         d->connect_port (handle, port_i, input_buffers[ibi++]); 
    369       } 
    370       if (LADSPA_IS_AUDIO_OUTPUT(pd)) { 
    371         d->connect_port (handle, port_i, output_buffers[obi++]); 
    372       } 
    373     } 
    374  
    375     /* activate the ladspa plugin */ 
    376     if (d->activate) 
    377       d->activate (handle); 
    378  
    379     /* run the ladspa plugin */ 
    380     d->run (handle, nr_frames); 
    381  
    382     /* deactivate the ladspa plugin */ 
    383     if (d->deactivate) 
    384       d->deactivate (handle); 
    385   } 
    386  
    387   /* re-interleave data */ 
    388   if (nr_channels > 1) { 
    389     p = (LADSPA_Data *)pcmdata; 
    390  
    391     for (n=0; n < nr_channels; n++) { 
    392       for (i=0; i < nr_frames; i++) { 
    393         *p++ = output_buffers[n][i]; 
    394       } 
     481      for (h = 0; h < nr_handles; h++) { 
     482        d->connect_port (handles[h], port_i, &dummy_control_output); 
     483      } 
     484    } 
     485  } 
     486 
     487  /* activate the ladspa plugin */ 
     488  if (d->activate) { 
     489    for (h = 0; h < nr_handles; h++) { 
     490      d->activate (handles[h]); 
     491    } 
     492  } 
     493 
     494  /* run the plugin on selection regions */ 
     495  for (gl = sounddata->sels; active && gl; gl = gl->next) { 
     496    sel = (sw_sel *)gl->data; 
     497 
     498    offset = 0; 
     499    remaining = sel->sel_end - sel->sel_start; 
     500 
     501    while (active && remaining > 0) { 
     502      g_mutex_lock (sample->ops_mutex); 
     503 
     504      if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 
     505        active = FALSE; 
     506      } else { /* cancel */ 
     507        pcmdata = sounddata->data + 
     508          frames_to_bytes (format, sel->sel_start + offset); 
     509 
     510        n = MIN(remaining, BLOCK_SIZE); 
     511 
     512        /* Copy data into input buffers */ 
     513        if (nr_channels == 1) { 
     514          if (LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 
     515            length_b = frames_to_bytes (format, n); 
     516            memcpy (input_buffers[0], pcmdata, length_b); 
     517          } else { 
     518            /* we're processing in-place, so we haven't needed to set 
     519             * up a separate input buffer; input_buffers[0] actually 
     520             * points to pcmdata hence we don't do any copying here. 
     521             */ 
     522            input_buffers[0] = (LADSPA_Data *)pcmdata; 
     523          } 
     524           
     525          output_buffers[0] = (LADSPA_Data *)pcmdata; 
     526           
     527        } else { 
     528          /* de-interleave multichannel data */ 
     529           
     530          p = (LADSPA_Data *)pcmdata; 
     531           
     532          for (i=0; i < n; i++) { 
     533            for (c=0; c < nr_channels; c++) { 
     534              input_buffers[c][i] = *p++; 
     535            } 
     536          } 
     537        } 
     538 
     539        g_assert (input_buffers[0] != NULL); 
     540        g_assert (output_buffers[0] != NULL); 
     541 
     542        /* connect input and output audio buffers to the 
     543         * audio ports of the ladspa plugin */ 
     544        ibi = 0; obi = 0; 
     545        for (h = 0; h < nr_handles; h++) { 
     546          for (port_i=0; port_i < d->PortCount; port_i++) { 
     547            pd = d->PortDescriptors[(int)port_i]; 
     548            if (LADSPA_IS_AUDIO_INPUT(pd)) { 
     549              d->connect_port (handles[h], port_i, input_buffers[ibi++]); 
     550            } 
     551            if (LADSPA_IS_AUDIO_OUTPUT(pd)) { 
     552              d->connect_port (handles[h], port_i, output_buffers[obi++]); 
     553            } 
     554          } 
     555        } 
     556 
     557        /* run the ladspa plugin */ 
     558        for (h = 0; h < nr_handles; h++) { 
     559          d->run (handles[h], n); 
     560        } 
     561 
     562        /* re-interleave data */ 
     563        if (nr_channels > 1) { 
     564          p = (LADSPA_Data *)pcmdata; 
     565           
     566          for (i=0; i < n; i++) { 
     567            for (c=0; c < nr_channels; c++) { 
     568              *p++ = output_buffers[c][i]; 
     569            } 
     570          } 
     571        } 
     572         
     573        remaining -= n; 
     574        offset += n; 
     575 
     576        run_total += n; 
     577        sample_set_progress_percent (sample, run_total / op_total); 
     578      } 
     579 
     580      g_mutex_unlock (sample->ops_mutex); 
     581    } 
     582  } 
     583 
     584  /* deactivate the ladspa plugin */ 
     585  if (d->deactivate) { 
     586    for (h = 0; h < nr_handles; h++) { 
     587      d->deactivate (handles[h]); 
    395588    } 
    396589  } 
    397590 
    398591  /* let the ladspa plugin clean up after itself */ 
    399   if (d->cleanup) 
    400     d->cleanup (handle); 
    401  
     592  if (d->cleanup) { 
     593    for (h = 0; h < nr_handles; h++) { 
     594      d->cleanup (handles[h]); 
     595    } 
     596  } 
     597 
     598  /* free the array of handles */ 
     599  g_free (handles); 
     600   
    402601  /* free the input and output buffers */ 
    403602  if (control_inputs) g_free (control_inputs); 
    404  
     603   
    405604  if ((nr_channels == 1) && (nr_ai == 1) && (nr_ao >= 1)) { 
    406605    if (LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 
    407       g_free (mono_input_buffer); 
     606      g_free (mono_input_buffers[0]); 
    408607    } 
    409608  } else { 
    410  
     609     
    411610    /* free the output buffers */ 
    412611    for (i=0; i < nr_o; i++) { 
     
    430629    g_free (input_buffers);   
    431630  } 
     631 
     632  return sample; 
    432633} 
    433634 
     
    440641 
    441642  return 
    442     perform_filter_region_op (sample, (char *)d->Name, 
    443                              (SweepFilterRegion)ladspa_meta_apply_region
    444                              pset, custom_data); 
     643    perform_filter_op (sample, (char *)d->Name, 
     644                       (SweepFilter)ladspa_meta_apply_filter
     645                      pset, custom_data); 
    445646} 
    446647 
     
    479680 
    480681      proc = g_malloc0 (sizeof (*proc)); 
    481       proc->name = d->Name; 
    482       proc->author = d->Maker; 
    483       proc->copyright = d->Copyright; 
     682      proc->name = (gchar *)d->Name; 
     683      proc->author = (gchar *)d->Maker; 
     684      proc->copyright = (gchar *)d->Copyright; 
    484685 
    485686      nr_params=0; 
     
    499700        pd = d->PortDescriptors[j]; 
    500701        if (LADSPA_IS_CONTROL_INPUT(pd)) { 
    501           proc->param_specs[k].name = d->PortNames[j]; 
    502           proc->param_specs[k].desc = d->PortNames[j]; 
     702          proc->param_specs[k].name = (gchar *)d->PortNames[j]; 
     703          proc->param_specs[k].desc = (gchar *)d->PortNames[j]; 
    503704          proc->param_specs[k].type = 
    504705            convert_type (d->PortRangeHints[j].HintDescriptor); 
     
    515716      } 
    516717 
     718      proc->suggest = ladspa_meta_suggest; 
     719 
    517720      proc->apply = ladspa_meta_apply; 
    518721 
  • trunk/sweep/src/Makefile.am

    r83 r124  
    44        -I$(top_srcdir)/intl \ 
    55        -I$(top_srcdir)/include \ 
    6         @GTK_CFLAGS@ \ 
    7         @AUDIOFILE_CFLAGS@ 
     6        @SNDFILE_CFLAGS@ \ 
     7        @OGG_CFLAGS@ @VORBIS_CFLAGS@ \ 
     8        @SAMPLERATE_CFLAGS@ 
    89 
    910bin_PROGRAMS = sweep 
     
    1314        main.c \ 
    1415        about_dialog.c about_dialog.h \ 
     16        callbacks.c callbacks.h \ 
     17        channelops.c channelops.h \ 
     18        cursors.c cursors.h \ 
     19        db_ruler.c db_ruler.h \ 
     20        db_slider.c db_slider.h \ 
     21        driver.c driver.h \ 
     22        driver_alsa.c \ 
     23        driver_oss.c \ 
     24        driver_solaris.c \ 
     25        edit.c edit.h \ 
    1526        file_dialogs.c file_dialogs.h \ 
    16         file_ops.c file_ops.h \ 
     27        file_sndfile.h \ 
     28        file_sndfile0.c \ 
     29        file_sndfile1.c \ 
     30        file_mad.c \ 
     31        file_speex.c \ 
     32        file_vorbis.c \ 
    1733        format.c format.h \ 
     34        head.c head.h \ 
    1835        interface.c interface.h \ 
    19         callbacks.c callbacks.h \ 
    20         cursors.c cursors.h \ 
    21         driver.c driver.h \ 
    22         edit.c edit.h \ 
     36        levelmeter.c levelmeter.h \ 
    2337        notes.c notes.h \ 
    2438        param.c param.h \ 
     39        paste_dialogs.c paste_dialogs.h \ 
     40        pcmio.h \ 
     41        pixmaps.h \ 
     42        play.c play.h \ 
    2543        plugin.c plugin.h \ 
     44        preferences.c preferences.h \ 
    2645        print.c print.h \ 
     46        question_dialogs.c question_dialogs.h \ 
     47        record.c record.h \ 
    2748        sample-display.c sample-display.h \ 
     49        samplerate.c \ 
     50        sw_chooser.c sw_chooser.h \ 
    2851        sweep_filter.c \ 
    2952        sweep_sample.c sample.h \ 
     
    3356        sweep_undo.c \ 
    3457        time_ruler.c time_ruler.h \ 
     58        timeouts.c \ 
     59        undo_dialog.c undo_dialog.h \ 
    3560        view.c view.h \ 
    36         pixmaps.h \ 
    37         view_pixmaps.h \ 
    38         horiz.xpm horiz_plus.xpm 
     61        view_pixmaps.h 
    3962 
    40 sweep_LDADD = @GTK_LIBS@ @AUDIOFILE_LIB@ $(INTLLIBS) $(PTHREAD_LIBS) 
     63sweep_LDADD = @GTK_LIBS@ $(INTLLIBS) $(PTHREAD_LIBS) $(TDB_LIBS) \ 
     64        $(SNDFILE_LIBS) \ 
     65        $(OGG_LIBS) $(VORBIS_LIBS) $(VORBISFILE_LIBS) $(VORBISENC_LIBS) \ 
     66        $(MAD_LIBS) $(SPEEX_LIBS) \ 
     67        $(SAMPLERATE_LIBS) 
    4168 
     69sweep_LDFLAGS = ${EXPORT_SYMBOLS_LDFLAGS} 
  • trunk/sweep/src/about_dialog.c

    r57 r124  
    2525#include <stdio.h> 
    2626#include <stdlib.h> 
     27#include <string.h> 
    2728#include <time.h> 
    2829 
     
    5354#endif 
    5455 
     56static void 
     57sweep_homepage (GtkWidget * widget, gpointer data) 
     58{ 
     59  system ("gnome-moz-remote http://sweep.sourceforge.net/"); 
     60} 
     61 
    5562void 
    5663about_dialog_create() 
     
    6471#define BUF_LEN 64 
    6572  gchar buf[BUF_LEN]; 
     73  GtkWidget * button; 
    6674 
    6775  if (!about_dialog) { 
     
    123131    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); 
    124132    gtk_widget_show(label); 
     133#endif 
    125134 
    126135    gtk_widget_pop_style(); 
    127136 
     137#if 0 
    128138    alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); 
    129139    gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0); 
     
    135145#endif 
    136146 
     147    button = gtk_button_new_with_label ("http://sweep.sourceforge.net/"); 
     148    gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, TRUE, 0); 
     149    gtk_widget_show (button); 
     150    gtk_signal_connect (GTK_OBJECT(button), "clicked", 
     151                        GTK_SIGNAL_FUNC(sweep_homepage), NULL); 
    137152  } 
    138153  if (!GTK_WIDGET_VISIBLE(about_dialog)) { 
  • trunk/sweep/src/callbacks.c

    r98 r124  
    2525#include <stdio.h> 
    2626#include <string.h> 
     27#include <stdlib.h> 
    2728 
    2829#include <gtk/gtk.h> 
     
    3031#include "callbacks.h" 
    3132 
     33#include <sweep/sweep_i18n.h> 
    3234#include <sweep/sweep_types.h> 
    3335#include <sweep/sweep_undo.h> 
    3436#include <sweep/sweep_sample.h> 
     37#include <sweep/sweep_typeconvert.h> 
    3538 
    3639#include "sample.h" 
    3740#include "interface.h" 
    3841#include "edit.h" 
     42#include "head.h" 
    3943#include "sample-display.h" 
     44#include "play.h" 
    4045#include "driver.h" 
    41  
    42 extern gint current_tool; 
     46#include "undo_dialog.h" 
     47#include "paste_dialogs.h" 
     48#include "print.h" 
     49#include "record.h" 
    4350 
    4451/* 
     
    5562 * where DEFAULT_MIN_ZOOM is defined in view.c 
    5663 */ 
    57 #define DEFAULT_ZOOM 1.2 
    58  
     64#define DEFAULT_ZOOM 2.0 
     65 
     66#define ZOOM_FRAMERATE 10 
    5967 
    6068/* Sample creation */ 
     
    6371sample_new_empty_cb (GtkWidget * widget, gpointer data) 
    6472{ 
    65   sw_sample * s; 
    66   char * directory, * filename; 
    67   gint nr_channels; 
    68   gint sample_rate; 
    69   gint sample_length; 
    70   sw_view * v; 
    71  
    72   directory = NULL;  /* XXX: Why is this code so poxy? */ 
    73   filename = NULL; 
    74   nr_channels = 2; 
    75   sample_rate = 44100; 
    76   sample_length = 2048; 
    77  
    78   s = sample_new_empty(directory, 
    79                        filename, 
    80                        nr_channels, 
    81                        sample_rate, 
    82                        sample_length); 
    83    
    84   v = view_new_all (s, 1.0); 
    85   sample_add_view (s, v); 
    86  
    87   sample_bank_add(s); 
     73  sw_view * view = (sw_view *)data; 
     74 
     75  if (view == NULL) { 
     76    create_sample_new_dialog_defaults (NULL); 
     77  } else { 
     78    create_sample_new_dialog_like (view->sample); 
     79  } 
    8880} 
    8981 
     
    10193   
    10294  ns = sample_new_copy(s); 
     95 
     96  while (ns->color == s->color) { 
     97    ns->color = (random()) % VIEW_COLOR_MAX; 
     98  } 
     99 
    103100  v = view_new_all (ns, 1.0); 
    104101  sample_add_view (ns, v); 
     
    107104} 
    108105 
     106/* Generic repeater */ 
     107 
     108static void 
     109view_init_repeater (sw_view * view, GtkFunction function, gpointer data) 
     110{ 
     111  function (data); 
     112 
     113  if (view->repeater_tag <= 0) { 
     114    view->repeater_tag = gtk_timeout_add ((guint32)1000/ZOOM_FRAMERATE, 
     115                                          function, data); 
     116  } 
     117} 
     118 
     119void 
     120repeater_released_cb (GtkWidget * widget, gpointer data) 
     121{ 
     122  sw_view * view = (sw_view *)data; 
     123 
     124  if (view->repeater_tag > 0) { 
     125    gtk_timeout_remove (view->repeater_tag); 
     126    view->repeater_tag = 0; 
     127  } 
     128} 
    109129 
    110130/* View */ 
     
    124144 
    125145void 
     146view_new_cb (GtkWidget * widget, gpointer data) 
     147{ 
     148  SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     149  sw_sample * s; 
     150  sw_view * view, * v; 
     151 
     152  v = sd->view; 
     153  s = v->sample; 
     154 
     155  view = view_new (s, v->start, v->end, s->play_head->gain); 
     156 
     157  sample_add_view (s, view); 
     158} 
     159 
     160void 
    126161view_close_cb (GtkWidget * widget, gpointer data) 
    127162{ 
     
    137172exit_cb (GtkWidget * widget, gpointer data) 
    138173{ 
    139   stop_playback(); 
    140   gtk_main_quit(); 
     174  sweep_quit (); 
    141175} 
    142176 
     
    145179set_tool_cb (GtkWidget * widget, gpointer data) 
    146180{ 
     181#if 0 
    147182  gint tool = (gint)data; 
    148183 
    149   current_tool = tool; 
     184  /*  current_tool = tool;*/ 
     185#endif 
     186  g_print ("NOOOOOOOOOOOOOO global current_tool\n"); 
     187
     188 
     189void 
     190view_set_tool_cb (GtkWidget * widget, gpointer data) 
     191
     192  sw_view * view = (sw_view *)data; 
     193  sw_tool_t tool; 
     194 
     195  tool = (sw_tool_t) 
     196    GPOINTER_TO_INT(gtk_object_get_user_data (GTK_OBJECT(widget))); 
     197 
     198  view->current_tool = tool; 
     199 
     200  view_refresh_tool_buttons (view); 
    150201} 
    151202 
    152203/* Zooming */ 
    153204 
     205static gboolean 
     206zoom_in_step (gpointer data) 
     207{ 
     208  sw_view * view = (sw_view *)data; 
     209 
     210  view_zoom_in (view, DEFAULT_ZOOM); 
     211 
     212  return TRUE; 
     213} 
     214 
    154215void 
    155216zoom_in_cb (GtkWidget * widget, gpointer data) 
    156217{ 
     218  sw_view * view = (sw_view *)data; 
     219  view_zoom_in (view, DEFAULT_ZOOM); 
     220} 
     221 
     222static gboolean 
     223zoom_out_step (gpointer data) 
     224{ 
     225  sw_view * view = (sw_view *)data; 
     226 
     227  view_zoom_out (view, DEFAULT_ZOOM); 
     228 
     229  return TRUE; 
     230} 
     231 
     232void 
     233zoom_out_cb (GtkWidget * widget, gpointer data) 
     234{ 
     235  sw_view * view = (sw_view *)data; 
     236  view_zoom_out (view, DEFAULT_ZOOM); 
     237} 
     238 
     239 
     240void 
     241zoom_in_pressed_cb (GtkWidget * widget, gpointer data) 
     242{ 
     243  sw_view * view = (sw_view *)data; 
     244 
     245  view_zoom_in (view, DEFAULT_ZOOM); 
     246  view_init_repeater (view, (GtkFunction)zoom_in_step, data); 
     247} 
     248 
     249void 
     250zoom_out_pressed_cb (GtkWidget * widget, gpointer data) 
     251{ 
     252  sw_view * view = (sw_view *)data; 
     253 
     254  view_zoom_out (view, DEFAULT_ZOOM); 
     255  view_init_repeater (view, (GtkFunction)zoom_out_step, data); 
     256} 
     257 
     258void 
     259zoom_to_sel_cb (GtkWidget * widget, gpointer data) 
     260{ 
    157261  SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    158262  sw_view * v = sd->view; 
    159263 
    160   view_zoom_in (v, DEFAULT_ZOOM); 
    161 } 
    162  
    163 void 
    164 zoom_out_cb (GtkWidget * widget, gpointer data) 
     264  view_zoom_to_sel (v); 
     265} 
     266 
     267void 
     268zoom_left_cb (GtkWidget * widget, gpointer data) 
    165269{ 
    166270  SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    167271  sw_view * v = sd->view; 
    168272 
    169   view_zoom_out (v, DEFAULT_ZOOM); 
    170 } 
    171  
    172 void 
    173 zoom_to_sel_cb (GtkWidget * widget, gpointer data) 
     273  view_zoom_left (v); 
     274} 
     275 
     276void 
     277zoom_right_cb (GtkWidget * widget, gpointer data) 
    174278{ 
    175279  SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    176280  sw_view * v = sd->view; 
    177281 
    178   view_zoom_to_sel (v); 
    179 } 
    180  
    181 void 
    182 zoom_left_cb (GtkWidget * widget, gpointer data) 
    183 { 
    184   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    185   sw_view * v = sd->view; 
    186  
    187   view_zoom_left (v); 
    188 } 
    189  
    190 void 
    191 zoom_right_cb (GtkWidget * widget, gpointer data) 
    192 { 
    193   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    194   sw_view * v = sd->view; 
    195  
    196282  view_zoom_right (v); 
    197283} 
     
    200286zoom_all_cb (GtkWidget * widget, gpointer data) 
    201287{ 
    202   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    203   sw_view * v = sd->view; 
     288  sw_view * v = (sw_view *)data; 
    204289 
    205290  view_zoom_all (v); 
     
    224309{ 
    225310  SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    226   sw_sample * s; 
    227  
    228   s = sd->view->sample; 
    229  
    230   view_set_ends(sd->view, 0, (sd->width) * 4096); 
     311  sw_view * view = sd->view; 
     312 
     313  view_zoom_normal (view); 
    231314} 
    232315 
     
    235318{ 
    236319  SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    237   sw_sample * s; 
    238  
    239   s = sd->view->sample; 
    240  
    241   view_set_ends(sd->view, 0, sd->width); 
     320 
     321  view_zoom_length (sd->view, sd->width); 
     322  view_center_on (sd->view, sd->view->sample->user_offset); 
     323
     324 
     325void 
     326zoom_center_cb (GtkWidget * widget, gpointer data) 
     327
     328  SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     329 
     330  view_center_on (sd->view, sd->view->sample->user_offset); 
     331
     332 
     333void 
     334zoom_combo_changed_cb (GtkWidget * widget, gpointer data) 
     335
     336  sw_view * view = (sw_view *)data; 
     337  gchar * text; 
     338  sw_time_t zoom_time; 
     339  sw_framecount_t zoom_length; 
     340 
     341  text = gtk_entry_get_text (GTK_ENTRY(widget)); 
     342 
     343  if (!strcmp (text, "All")) { 
     344    view_zoom_all (view); 
     345  } else { 
     346    zoom_time = (sw_time_t)strtime_to_seconds (text); 
     347    if (zoom_time != -1.0) { 
     348      zoom_length = 
     349        time_to_frames (view->sample->sounddata->format, zoom_time); 
     350 
     351      view_zoom_length (view, zoom_length); 
     352       
     353      /* Work around a bug, probably in gtkcombo, whereby all the other 
     354       * widgets sometimes lost input after choosing a zoom */ 
     355      gtk_widget_grab_focus (view->display); 
     356    } 
     357  } 
     358
     359 
     360/* Device config */ 
     361 
     362void 
     363device_config_cb (GtkWidget * widget, gpointer data) 
     364
     365  device_config (); 
     366
     367 
     368/* Sample */ 
     369 
     370void 
     371sample_set_color_cb (GtkWidget * widget, gpointer data) 
     372
     373  sw_view * view = (sw_view *) data; 
     374  gint color; 
     375 
     376  color = GPOINTER_TO_INT(gtk_object_get_user_data (GTK_OBJECT(widget))); 
     377  sample_set_color (view->sample, color); 
    242378} 
    243379 
     
    245381 
    246382void 
     383follow_toggled_cb (GtkWidget * widget, gpointer data) 
     384{ 
     385  sw_view * view = (sw_view *) data; 
     386  gboolean active; 
     387 
     388  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     389  view_set_following (view, active); 
     390} 
     391 
     392void 
     393follow_toggle_cb (GtkWidget * widget, gpointer data) 
     394{ 
     395  sw_view * view = (sw_view *)data; 
     396  view_set_following (view, !view->following); 
     397} 
     398 
     399void 
     400loop_toggled_cb (GtkWidget * widget, gpointer data) 
     401{ 
     402  sw_view * view = (sw_view *) data; 
     403  gboolean active; 
     404 
     405  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     406  sample_set_looping (view->sample, active); 
     407} 
     408 
     409void 
     410loop_toggle_cb (GtkWidget * widget, gpointer data) 
     411{ 
     412  sw_view * view = (sw_view *)data; 
     413  sample_set_looping (view->sample, !view->sample->play_head->looping); 
     414} 
     415 
     416void 
     417playrev_toggled_cb (GtkWidget * widget, gpointer data) 
     418{ 
     419  sw_view * view = (sw_view *) data; 
     420  gboolean active; 
     421 
     422  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     423  sample_set_playrev (view->sample, active); 
     424} 
     425 
     426void 
     427playrev_toggle_cb (GtkWidget * widget, gpointer data) 
     428{ 
     429  sw_view * view = (sw_view *)data; 
     430  sample_set_playrev (view->sample, !view->sample->play_head->reverse); 
     431} 
     432 
     433void 
     434mute_toggled_cb (GtkWidget * widget, gpointer data) 
     435{ 
     436  sw_view * view = (sw_view *) data; 
     437  gboolean active; 
     438 
     439  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     440  sample_set_mute (view->sample, active); 
     441} 
     442 
     443void 
     444mute_toggle_cb (GtkWidget * widget, gpointer data) 
     445{ 
     446  sw_view * view = (sw_view *)data; 
     447  sample_set_mute (view->sample, !view->sample->play_head->mute); 
     448} 
     449 
     450void 
     451monitor_toggled_cb (GtkWidget * widget, gpointer data) 
     452{ 
     453  sw_view * view = (sw_view *) data; 
     454  gboolean active; 
     455 
     456  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     457  sample_set_monitor (view->sample, active); 
     458} 
     459 
     460void 
     461monitor_toggle_cb (GtkWidget * widget, gpointer data) 
     462{ 
     463  sw_view * view = (sw_view *)data; 
     464  sample_set_monitor (view->sample, !view->sample->play_head->monitor); 
     465} 
     466 
     467void 
     468play_view_button_cb (GtkWidget * widget, gpointer data) 
     469{ 
     470  sw_view * view = (sw_view *) data; 
     471  sw_head * head = view->sample->play_head; 
     472  gboolean was_restricted = head->restricted; 
     473 
     474  head_set_rate (head, 1.0); 
     475  /*  head_set_restricted (head, FALSE);*/ 
     476 
     477  if (head->going && (head->scrubbing || !was_restricted)) { 
     478    pause_playback_cb (widget, data); 
     479  } else { 
     480    play_view_all (view); 
     481  } 
     482} 
     483 
     484void 
    247485play_view_cb (GtkWidget * widget, gpointer data) 
    248486{ 
    249   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    250   sw_view * v; 
    251  
    252   v = sd->view; 
    253  
    254   play_view_all (v); 
    255 
    256  
    257 void 
    258 play_view_all_loop_cb (GtkWidget * widget, gpointer data) 
    259 
    260   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    261   sw_view * v; 
    262  
    263   v = sd->view; 
    264  
    265   play_view_all_loop (v); 
     487  sw_view * view = (sw_view *) data; 
     488  sw_head * head = view->sample->play_head; 
     489 
     490  head_set_rate (head, 1.0); 
     491  /*  head_set_restricted (head, FALSE);*/ 
     492 
     493  if (head->going) { 
     494    pause_playback_cb (widget, data); 
     495  } else { 
     496    play_view_all (view); 
     497  } 
     498
     499 
     500void 
     501play_view_sel_button_cb (GtkWidget * widget, gpointer data) 
     502
     503  sw_view * view = (sw_view *) data; 
     504  sw_head * head = view->sample->play_head; 
     505  gboolean was_restricted = head->restricted; 
     506 
     507  if (view->sample->sounddata->sels == NULL) { 
     508    play_view_cb (widget, data); 
     509    return; 
     510  } 
     511 
     512  head_set_rate (head, 1.0); 
     513  /*  head_set_restricted (head, TRUE);*/ 
     514 
     515  if (head->going && (head->scrubbing || was_restricted)) { 
     516    pause_playback_cb (widget, data); 
     517  } else { 
     518    play_view_sel (view); 
     519  } 
    266520} 
    267521 
     
    269523play_view_sel_cb (GtkWidget * widget, gpointer data) 
    270524{ 
    271   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    272   sw_view * v; 
    273  
    274   v = sd->view; 
    275  
    276   play_view_sel (v); 
    277 
    278  
    279 void 
    280 play_view_sel_loop_cb (GtkWidget * widget, gpointer data) 
    281 
    282   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    283   sw_view * v; 
    284  
    285   v = sd->view; 
    286  
    287   play_view_sel_loop (v); 
     525  sw_view * view = (sw_view *) data; 
     526  sw_head * head = view->sample->play_head; 
     527 
     528  if (view->sample->sounddata->sels == NULL) { 
     529    play_view_cb (widget, data); 
     530    return; 
     531  } 
     532 
     533  head_set_rate (head, 1.0); 
     534  /*  head_set_restricted (head, TRUE);*/ 
     535 
     536  if (head->going) { 
     537    pause_playback_cb (widget, data); 
     538  } else { 
     539    play_view_sel (view); 
     540  } 
     541
     542 
     543void 
     544pause_playback_cb (GtkWidget * widget, gpointer data) 
     545
     546  sw_view * view = (sw_view *)data; 
     547 
     548  pause_playback (view->sample); 
    288549} 
    289550 
     
    291552stop_playback_cb (GtkWidget * widget, gpointer data) 
    292553{ 
    293   stop_playback (); 
     554  sw_view * view = (sw_view *)data; 
     555 
     556  stop_playback (view->sample); 
     557
     558 
     559void 
     560preview_cut_cb (GtkWidget * widget, gpointer data) 
     561
     562  sw_view * view = (sw_view *) data; 
     563 
     564  sample_refresh_playmode (view->sample); 
     565 
     566  if (view->sample->sounddata->sels != NULL) { 
     567    play_preview_cut (view); 
     568  } else { 
     569    play_preroll (view); 
     570  } 
     571
     572 
     573void 
     574preroll_cb (GtkWidget * widget, gpointer data) 
     575
     576  sw_view * view = (sw_view *) data; 
     577 
     578  sample_refresh_playmode (view->sample); 
     579   
     580  play_preroll (view); 
     581
     582 
     583/* Record */ 
     584 
     585void 
     586show_rec_dialog_cb (GtkWidget * widget, gpointer data) 
     587
     588  sw_view * view = (sw_view *)data; 
     589 
     590  rec_dialog_create (view->sample); 
     591
     592 
     593/* Transport */ 
     594 
     595static gboolean 
     596rewind_step (gpointer data) 
     597
     598  sw_sample * sample = (sw_sample *)data; 
     599  gint step; 
     600 
     601  step = sample->sounddata->format->rate; /* 1 second */ 
     602  sample_set_playmarker (sample, sample->user_offset - step, TRUE); 
     603 
     604  return TRUE; 
     605
     606 
     607static gboolean 
     608ffwd_step (gpointer data) 
     609
     610  sw_sample * sample = (sw_sample *)data; 
     611  gint step; 
     612 
     613  step = sample->sounddata->format->rate; /* 1 second */ 
     614  sample_set_playmarker (sample, sample->user_offset + step, TRUE); 
     615 
     616  return TRUE; 
     617
     618 
     619void 
     620page_back_cb (GtkWidget * widget, gpointer data) 
     621
     622  sw_view * view = (sw_view *)data; 
     623  sw_sample * sample = view->sample; 
     624  gint step; 
     625 
     626  step = MIN(sample->sounddata->format->rate, (view->end - view->start)); 
     627  sample_set_playmarker (sample, sample->user_offset - step, TRUE); 
     628
     629 
     630void 
     631page_fwd_cb (GtkWidget * widget, gpointer data) 
     632
     633  sw_view * view = (sw_view *)data; 
     634  sw_sample * sample = view->sample; 
     635  gint step; 
     636 
     637  step = MIN(sample->sounddata->format->rate, (view->end - view->start)); 
     638  sample_set_playmarker (sample, sample->user_offset + step, TRUE); 
     639
     640 
     641void 
     642rewind_pressed_cb (GtkWidget * widget, gpointer data) 
     643
     644  sw_view * view = (sw_view *)data; 
     645  sw_sample * sample = view->sample; 
     646 
     647  view_init_repeater (view, (GtkFunction)rewind_step, sample); 
     648
     649 
     650void 
     651ffwd_pressed_cb (GtkWidget * widget, gpointer data) 
     652
     653  sw_view * view = (sw_view *)data; 
     654  sw_sample * sample = view->sample; 
     655 
     656  view_init_repeater (view, (GtkFunction)ffwd_step, sample); 
     657
     658 
     659void 
     660goto_start_cb (GtkWidget * widget, gpointer data) 
     661
     662  sw_view * view = (sw_view *)data; 
     663  sw_sample * sample = view->sample; 
     664 
     665  sample_set_scrubbing (sample, FALSE); 
     666  sample_set_playmarker (sample, 0, TRUE); 
     667
     668 
     669void 
     670goto_start_of_view_cb (GtkWidget * widget, gpointer data) 
     671
     672  sw_view * view = (sw_view *)data; 
     673  sw_sample * sample = view->sample; 
     674 
     675  sample_set_scrubbing (sample, FALSE); 
     676  sample_set_playmarker (sample, view->start, TRUE); 
     677
     678 
     679void 
     680goto_end_of_view_cb (GtkWidget * widget, gpointer data) 
     681
     682  sw_view * view = (sw_view *)data; 
     683  sw_sample * sample = view->sample; 
     684 
     685  sample_set_scrubbing (sample, FALSE); 
     686  sample_set_playmarker (sample, view->end, TRUE); 
     687
     688 
     689void 
     690goto_end_cb (GtkWidget * widget, gpointer data) 
     691
     692  sw_view * view = (sw_view *)data; 
     693  sw_sample * sample = view->sample; 
     694 
     695  sample_set_scrubbing (sample, FALSE); 
     696  sample_set_playmarker (sample, sample->sounddata->nr_frames, TRUE); 
    294697} 
    295698 
     
    333736} 
    334737 
     738void 
     739adj_value_changed_cb (GtkWidget * widget, gpointer data) 
     740{ 
     741  sw_view * v = (sw_view *)data; 
     742  SampleDisplay * sd = SAMPLE_DISPLAY(v->display); 
     743  GtkAdjustment * adj = GTK_ADJUSTMENT(v->adj); 
     744 
     745  if (!v->sample->play_head->going || !v->following) { 
     746 
     747    gtk_signal_handler_block_by_data (GTK_OBJECT(sd), v); 
     748    sample_display_set_window(sd, 
     749                              (gint)adj->value, 
     750                              (gint)(adj->value + adj->page_size)); 
     751    gtk_signal_handler_unblock_by_data (GTK_OBJECT(sd), v); 
     752  } 
     753 
     754  if (v->following) { 
     755    if (v->sample->user_offset < adj->value || 
     756        v->sample->user_offset > adj->value + adj->page_size) 
     757      sample_set_playmarker (v->sample, adj->value + adj->page_size/2, TRUE); 
     758  } 
     759 
     760  view_refresh_hruler (v);   
     761} 
    335762 
    336763/* Selection */ 
     
    342769 
    343770  sample_selection_invert (sd->view->sample); 
    344  
    345   sample_refresh_views (sd->view->sample); 
    346771} 
    347772 
     
    352777 
    353778  sample_selection_select_all (sd->view->sample); 
    354  
    355   sample_refresh_views (sd->view->sample); 
    356779} 
    357780 
     
    362785 
    363786  sample_selection_select_none (sd->view->sample); 
    364  
    365   sample_refresh_views (sd->view->sample); 
    366 
    367  
     787
     788 
     789void 
     790selection_halve_cb (GtkWidget * widget, gpointer data) 
     791
     792  SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     793 
     794  sample_selection_halve (sd->view->sample); 
     795
     796 
     797void 
     798selection_double_cb (GtkWidget * widget, gpointer data) 
     799
     800  SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     801 
     802  sample_selection_double (sd->view->sample); 
     803
     804 
     805void 
     806select_shift_left_cb (GtkWidget * widget, gpointer data) 
     807
     808  SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     809 
     810  sample_selection_shift_left (sd->view->sample); 
     811
     812 
     813void 
     814select_shift_right_cb (GtkWidget * widget, gpointer data) 
     815
     816  SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     817 
     818  sample_selection_shift_right (sd->view->sample); 
     819
    368820 
    369821/* Undo / Redo */ 
    370822 
    371823void 
     824show_undo_dialog_cb (GtkWidget * widget, gpointer data) 
     825{ 
     826  sw_view * view = (sw_view *)data; 
     827 
     828  undo_dialog_create (view->sample); 
     829} 
     830 
     831void 
    372832undo_cb (GtkWidget * widget, gpointer data) 
    373833{ 
    374   SampleDisplay * sd = SAMPLE_DISPLAY(data)
    375  
    376   undo_current (sd->view->sample); 
     834  sw_view * view = (sw_view *)data
     835 
     836  undo_current (view->sample); 
    377837} 
    378838 
     
    380840redo_cb (GtkWidget * widget, gpointer data) 
    381841{ 
    382   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    383  
    384   redo_current (sd->view->sample); 
    385 
    386  
     842  sw_view * view = (sw_view *)data; 
     843 
     844  redo_current (view->sample); 
     845
     846 
     847void 
     848cancel_cb (GtkWidget * widget, gpointer data) 
     849
     850  sw_view * view = (sw_view *)data; 
     851 
     852  cancel_active_op (view->sample); 
     853
    387854 
    388855/* Edit */ 
     
    391858copy_cb (GtkWidget * widget, gpointer data) 
    392859{ 
    393   SampleDisplay * sd = SAMPLE_DISPLAY(data)
    394   sw_sample * s = sd->view->sample; 
     860  sw_view * view = (sw_view *)data
     861  sw_sample * s = view->sample; 
    395862 
    396863  do_copy (s); 
     
    400867cut_cb (GtkWidget * widget, gpointer data) 
    401868{ 
    402   SampleDisplay * sd = SAMPLE_DISPLAY(data)
    403   sw_sample * s = sd->view->sample; 
     869  sw_view * view = (sw_view *)data
     870  sw_sample * s = view->sample; 
    404871 
    405872  do_cut (s); 
     
    409876clear_cb (GtkWidget * widget, gpointer data) 
    410877{ 
    411   SampleDisplay * sd = SAMPLE_DISPLAY(data)
    412   sw_sample * s = sd->view->sample; 
     878  sw_view * view = (sw_view *)data
     879  sw_sample * s = view->sample; 
    413880 
    414881  do_clear (s); 
     
    418885delete_cb (GtkWidget * widget, gpointer data) 
    419886{ 
    420   SampleDisplay * sd = SAMPLE_DISPLAY(data)
    421   sw_sample * s = sd->view->sample; 
     887  sw_view * view = (sw_view *)data
     888  sw_sample * s = view->sample; 
    422889 
    423890  do_delete (s); 
     
    425892 
    426893void 
     894crop_cb (GtkWidget * widget, gpointer data) 
     895{ 
     896  sw_view * view = (sw_view *)data; 
     897  sw_sample * s = view->sample; 
     898 
     899  do_crop (s); 
     900} 
     901 
     902void 
    427903paste_cb (GtkWidget * widget, gpointer data) 
    428904{ 
    429   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    430   sw_sample * s = sd->view->sample; 
    431  
    432   do_paste_at (s); 
     905  sw_view * view = (sw_view *)data; 
     906  sw_sample * s = view->sample; 
     907 
     908  do_paste_insert (s); 
     909
     910 
     911void 
     912paste_mix_cb (GtkWidget * widget, gpointer data) 
     913
     914  sw_view * view = (sw_view *)data; 
     915  sw_sample * s = view->sample; 
     916 
     917  if (clipboard_width() > 0) { 
     918    create_paste_mix_dialog (s); 
     919  } else { 
     920    sample_set_tmp_message (s, _("Clipboard empty")); 
     921  } 
     922
     923 
     924void 
     925paste_xfade_cb (GtkWidget * widget, gpointer data) 
     926
     927  sw_view * view = (sw_view *)data; 
     928  sw_sample * s = view->sample; 
     929 
     930  if (clipboard_width() > 0) { 
     931    create_paste_xfade_dialog (s); 
     932  } else { 
     933    sample_set_tmp_message (s, _("Clipboard empty")); 
     934  } 
    433935} 
    434936 
     
    436938paste_as_new_cb (GtkWidget * widget, gpointer data) 
    437939{ 
    438   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    439940  sw_sample * s; 
    440941  sw_view * v; 
    441942 
    442   do_paste_as_new (sd->view->sample, &s); 
    443  
     943  s = do_paste_as_new (); 
     944   
    444945  if (s) { 
    445946    v = view_new_all (s, 1.0); 
    446947    sample_add_view (s, v); 
    447   } 
    448 
    449  
     948    sample_bank_add (s); 
     949  } 
     950
     951 
     952void 
     953show_info_dialog_cb (GtkWidget * widget, gpointer data) 
     954
     955  sw_view * view = (sw_view *)data; 
     956 
     957  sample_show_info_dialog (view->sample); 
     958
  • trunk/sweep/src/callbacks.h

    r98 r124  
    3434 
    3535void 
     36view_new_cb (GtkWidget * widget, gpointer data); 
     37 
     38void 
    3639view_close_cb (GtkWidget * widget, gpointer data); 
    3740 
     
    4346 
    4447void 
     48view_set_tool_cb (GtkWidget * widget, gpointer data); 
     49 
     50void 
     51repeater_released_cb (GtkWidget * widget, gpointer data); 
     52 
     53void 
    4554zoom_in_cb (GtkWidget * widget, gpointer data); 
    4655 
     
    4958 
    5059void 
     60zoom_in_pressed_cb (GtkWidget * widget, gpointer data); 
     61 
     62void 
     63zoom_out_pressed_cb (GtkWidget * widget, gpointer data); 
     64 
     65void 
    5166zoom_to_sel_cb (GtkWidget * widget, gpointer data); 
    5267 
     
    7085 
    7186void 
     87zoom_center_cb (GtkWidget * widget, gpointer data); 
     88 
     89void 
     90zoom_combo_changed_cb (GtkWidget * widget, gpointer data); 
     91 
     92void 
     93sample_set_color_cb (GtkWidget * widget, gpointer data); 
     94 
     95void 
     96device_config_cb (GtkWidget * widget, gpointer data); 
     97 
     98void 
     99follow_toggled_cb (GtkWidget * widget, gpointer data); 
     100 
     101void 
     102follow_toggle_cb (GtkWidget * widget, gpointer data); 
     103 
     104void 
     105loop_toggled_cb (GtkWidget * widget, gpointer data); 
     106 
     107void 
     108loop_toggle_cb (GtkWidget * widget, gpointer data); 
     109 
     110void 
     111playrev_toggled_cb (GtkWidget * widget, gpointer data); 
     112 
     113void 
     114playrev_toggle_cb (GtkWidget * widget, gpointer data); 
     115 
     116void 
     117mute_toggled_cb (GtkWidget * widget, gpointer data); 
     118 
     119void 
     120mute_toggle_cb (GtkWidget * widget, gpointer data); 
     121 
     122void 
     123monitor_toggled_cb (GtkWidget * widget, gpointer data); 
     124 
     125void 
     126monitor_toggle_cb (GtkWidget * widget, gpointer data); 
     127 
     128void 
     129play_view_button_cb (GtkWidget * widget, gpointer data); 
     130 
     131void 
     132play_view_sel_button_cb (GtkWidget * widget, gpointer data); 
     133 
     134void 
    72135play_view_cb (GtkWidget * widget, gpointer data); 
    73136 
    74137void 
     138play_view_all_once_cb (GtkWidget * widget, gpointer data); 
     139 
     140void 
    75141play_view_all_loop_cb (GtkWidget * widget, gpointer data); 
    76142 
     
    79145 
    80146void 
     147play_view_sel_once_cb (GtkWidget * widget, gpointer data); 
     148 
     149void 
    81150play_view_sel_loop_cb (GtkWidget * widget, gpointer data); 
    82151 
    83152void 
     153pause_playback_cb (GtkWidget * widget, gpointer data); 
     154 
     155void 
    84156stop_playback_cb (GtkWidget * widget, gpointer data); 
    85157 
    86158void 
     159preview_cut_cb (GtkWidget * widget, gpointer data); 
     160 
     161void 
     162preroll_cb (GtkWidget * widget, gpointer data); 
     163 
     164void 
     165show_rec_dialog_cb (GtkWidget * widget, gpointer data); 
     166 
     167void 
     168page_back_cb (GtkWidget * widget, gpointer data); 
     169 
     170void 
     171page_fwd_cb (GtkWidget * widget, gpointer data); 
     172 
     173void 
     174rewind_pressed_cb (GtkWidget * widget, gpointer data); 
     175 
     176void 
     177ffwd_pressed_cb (GtkWidget * widget, gpointer data); 
     178 
     179void 
     180goto_start_cb (GtkWidget * widget, gpointer data); 
     181 
     182void 
     183goto_start_of_view_cb (GtkWidget * widget, gpointer data); 
     184 
     185void 
     186goto_end_of_view_cb (GtkWidget * widget, gpointer data); 
     187 
     188void 
     189goto_end_cb (GtkWidget * widget, gpointer data); 
     190 
     191void 
    87192sd_sel_changed_cb (GtkWidget * widget); 
    88193 
     
    94199 
    95200void 
     201adj_value_changed_cb (GtkWidget * widget, gpointer data); 
     202 
     203void 
    96204select_invert_cb (GtkWidget * widget, gpointer data); 
    97205 
     
    103211 
    104212void 
     213selection_halve_cb (GtkWidget * widget, gpointer data); 
     214 
     215void 
     216selection_double_cb (GtkWidget * widget, gpointer data); 
     217 
     218void 
     219select_shift_left_cb (GtkWidget * widget, gpointer data); 
     220 
     221void 
     222select_shift_right_cb (GtkWidget * widget, gpointer data); 
     223 
     224void 
     225show_undo_dialog_cb (GtkWidget * widget, gpointer data); 
     226 
     227void 
    105228undo_cb (GtkWidget * widget, gpointer data); 
    106229 
     
    109232 
    110233void 
     234cancel_cb (GtkWidget * widget, gpointer data); 
     235 
     236void 
    111237copy_cb (GtkWidget * widget, gpointer data); 
    112238 
     
    121247 
    122248void 
     249crop_cb (GtkWidget * widget, gpointer data); 
     250 
     251void 
    123252paste_cb (GtkWidget * widget, gpointer data); 
    124253 
    125254void 
     255paste_mix_cb (GtkWidget * widget, gpointer data); 
     256 
     257void 
     258paste_xfade_cb (GtkWidget * widget, gpointer data); 
     259 
     260void 
    126261paste_as_new_cb (GtkWidget * widget, gpointer data); 
    127262 
     
    132267normalise_cb (GtkWidget * widget, gpointer data); 
    133268 
     269void 
     270show_info_dialog_cb (GtkWidget * widget, gpointer data); 
     271 
    134272#endif /* __CALLBACKS_H__ */ 
  • trunk/sweep/src/cursors.c

    r7 r124  
    1919 */ 
    2020 
     21#ifdef HAVE_CONFIG_H 
     22#  include <config.h> 
     23#endif 
     24 
    2125#include <stdio.h> 
    2226#include <gtk/gtk.h> 
     27 
     28#include "cursors.h" 
     29 
     30/* static cursor definitions */ 
     31#include "../pixmaps/horiz.xpm" 
     32#include "../pixmaps/horiz_plus.xpm" 
     33#include "../pixmaps/horiz_minus.xpm" 
     34 
     35#include "../pixmaps/hand.xbm" 
     36#include "../pixmaps/hand_mask.xbm" 
     37#include "../pixmaps/needle.xbm" 
     38#include "../pixmaps/needle_mask.xbm" 
     39#include "../pixmaps/zoom_in.xbm" 
     40#include "../pixmaps/zoom_in_mask.xbm" 
     41#include "../pixmaps/zoom_out.xbm" 
     42#include "../pixmaps/zoom_out_mask.xbm" 
     43 
     44GdkCursor * sweep_cursors[SWEEP_CURSOR_MAX]; 
     45 
    2346 
    2447void 
     
    6487  *mask = gdk_bitmap_create_from_data (NULL, mask_buffer, 32, 32); 
    6588} 
     89 
     90void 
     91init_cursors (void) 
     92{ 
     93  GdkBitmap * bitmap; 
     94  GdkBitmap * mask; 
     95  GdkColor white = {0, 0xffff, 0xffff, 0xffff}; 
     96  GdkColor black = {0, 0x0000, 0x0000, 0x0000}; 
     97 
     98  sweep_cursors[SWEEP_CURSOR_CROSSHAIR] = gdk_cursor_new (GDK_XTERM); 
     99  /*  sweep_cursors[SWEEP_CURSOR_MOVE] = gdk_cursor_new (GDK_FLEUR);*/ 
     100  sweep_cursors[SWEEP_CURSOR_PENCIL] = gdk_cursor_new (GDK_PENCIL); 
     101  sweep_cursors[SWEEP_CURSOR_NOISE] = gdk_cursor_new (GDK_SPRAYCAN); 
     102 
     103  create_bitmap_and_mask_from_xpm (&bitmap, &mask, horiz_xpm); 
     104   
     105  sweep_cursors[SWEEP_CURSOR_HORIZ] = 
     106    gdk_cursor_new_from_pixmap (bitmap, mask, &white, &black, 8, 8); 
     107 
     108  create_bitmap_and_mask_from_xpm (&bitmap, &mask, horiz_plus_xpm); 
     109   
     110  sweep_cursors[SWEEP_CURSOR_HORIZ_PLUS] = 
     111    gdk_cursor_new_from_pixmap (bitmap, mask, &white, &black, 8, 8); 
     112 
     113  create_bitmap_and_mask_from_xpm (&bitmap, &mask, horiz_minus_xpm); 
     114   
     115  sweep_cursors[SWEEP_CURSOR_HORIZ_MINUS] = 
     116    gdk_cursor_new_from_pixmap (bitmap, mask, &white, &black, 8, 8); 
     117 
     118  bitmap = 
     119    gdk_bitmap_create_from_data (NULL, zoom_in_bits, 
     120                                 zoom_in_width, zoom_in_height); 
     121  mask = 
     122    gdk_bitmap_create_from_data (NULL, zoom_in_mask_bits, 
     123                                 zoom_in_mask_width, zoom_in_mask_height); 
     124 
     125  sweep_cursors[SWEEP_CURSOR_ZOOM_IN] = 
     126    gdk_cursor_new_from_pixmap (bitmap, mask, &white, &black, 
     127                                zoom_in_x_hot, zoom_in_y_hot); 
     128 
     129  bitmap = 
     130    gdk_bitmap_create_from_data (NULL, zoom_out_bits, 
     131                                 zoom_out_width, zoom_out_height); 
     132  mask = 
     133    gdk_bitmap_create_from_data (NULL, zoom_out_mask_bits, 
     134                                 zoom_out_mask_width, zoom_out_mask_height); 
     135 
     136  sweep_cursors[SWEEP_CURSOR_ZOOM_OUT] = 
     137    gdk_cursor_new_from_pixmap (bitmap, mask, &white, &black, 
     138                                zoom_out_x_hot, zoom_out_y_hot); 
     139 
     140  bitmap = 
     141    gdk_bitmap_create_from_data (NULL, needle_bits, 
     142                                 needle_width, needle_height); 
     143  mask = 
     144    gdk_bitmap_create_from_data (NULL, needle_mask_bits, 
     145                                 needle_mask_width, needle_mask_height); 
     146 
     147  sweep_cursors[SWEEP_CURSOR_NEEDLE] = 
     148    gdk_cursor_new_from_pixmap (bitmap, mask, &white, &black, 
     149                                needle_x_hot, needle_y_hot); 
     150 
     151 
     152  bitmap = 
     153    gdk_bitmap_create_from_data (NULL, hand_bits, 
     154                                 hand_width, hand_height); 
     155  mask = 
     156    gdk_bitmap_create_from_data (NULL, hand_mask_bits, 
     157                                 hand_mask_width, hand_mask_height); 
     158 
     159  sweep_cursors[SWEEP_CURSOR_MOVE] = 
     160    gdk_cursor_new_from_pixmap (bitmap, mask, &black, &white, 
     161                                hand_x_hot, hand_y_hot); 
     162 
     163 
     164} 
  • trunk/sweep/src/cursors.h

    r7 r124  
    2222#define __CURSORS_H__ 
    2323 
     24enum { 
     25  SWEEP_CURSOR_CROSSHAIR, 
     26  SWEEP_CURSOR_MOVE, 
     27  SWEEP_CURSOR_HORIZ, 
     28  SWEEP_CURSOR_HORIZ_PLUS, 
     29  SWEEP_CURSOR_HORIZ_MINUS, 
     30  SWEEP_CURSOR_ZOOM_IN, 
     31  SWEEP_CURSOR_ZOOM_OUT, 
     32  SWEEP_CURSOR_NEEDLE, 
     33  SWEEP_CURSOR_PENCIL, 
     34  SWEEP_CURSOR_NOISE, 
     35  SWEEP_CURSOR_MAX 
     36}; 
     37 
    2438void 
    2539create_bitmap_and_mask_from_xpm (GdkBitmap ** bitmap, 
     
    2741                                 gchar ** xpm); 
    2842 
     43void 
     44init_cursors (void); 
     45 
    2946#endif 
  • trunk/sweep/src/driver.c

    r106 r124  
    3535#include <pthread.h> 
    3636 
     37#include <gtk/gtk.h> 
     38#include <sweep/sweep_i18n.h> 
     39 
    3740#include <sweep/sweep_types.h> 
    3841#include <sweep/sweep_sample.h> 
     
    4043#include "driver.h" 
    4144 
    42 #ifdef DRIVER_OSS 
    43 #include <sys/soundcard.h> 
    44 #define DEV_DSP "/dev/dsp" 
    45 #endif 
    46  
    47 #ifdef DRIVER_SOLARIS_AUDIO 
    48 #include <sys/audioio.h> 
    49 #include <stropts.h> 
    50 #include <sys/conf.h> 
    51 #define DEV_DSP "/dev/audio" 
    52 #endif 
    53  
    54 #ifdef DRIVER_ALSA 
    55 #include <sys/asoundlib.h> 
    56 static snd_pcm_t *pcm_handle; 
    57 #define ALSA_PCM_NAME "sweep" 
    58 #endif 
    59  
    60 #define PLAYBACK_SCALE (32768 / SW_AUDIO_T_MAX) 
    61 #define PBUF_SIZE 256 
    62  
    63 static int dev_dsp = -1; 
    64  
    65 static sw_sample * playing = NULL; 
    66 static pthread_t player_thread; 
    67  
    68 static int playoffset = -1; 
    69  
    70 /* 
    71  * update_playmarker () 
    72  * 
    73  * Update the position of the playback marker line for the sample 
    74  * being played. 
    75  * 
    76  * gtk_idle will keep calling this function as long as this sample is 
    77  * playing, unless otherwise stopped. 
    78  */ 
    79 static gint 
    80 update_playmarker (gpointer data) 
    81 
    82   sw_sample * s = (sw_sample *)data; 
    83  
    84   if (s == playing) { 
    85     sample_set_playmarker (s, playoffset); 
    86     return TRUE; 
    87   } else { 
    88     sample_set_playmarker (s, -1); 
    89     return FALSE; 
     45extern sw_driver * driver_alsa; 
     46extern sw_driver * driver_oss; 
     47extern sw_driver * driver_solaris; 
     48 
     49extern GMutex * play_mutex; 
     50 
     51/* preferred driver */ 
     52static sw_driver _driver_null = { 
     53  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL 
     54}; 
     55 
     56static sw_driver * pref = &_driver_null; 
     57 
     58#include "preferences.h" 
     59#include "pcmio.h" 
     60 
     61char * 
     62pcmio_get_default_main_dev (void) 
     63
     64  GList * names = NULL, * gl; 
     65 
     66  if (pref->get_names) 
     67    names = pref->get_names (); 
     68 
     69  if ((gl = names) != NULL) { 
     70    return (char *)gl->data; 
    9071  } 
    91 
    92  
    93 static void 
    94 start_playmarker (sw_sample * s) 
    95 
    96   s->playmarker_tag = 
    97     gtk_timeout_add ((guint32)100, 
    98                      (GtkFunction)update_playmarker, 
    99                      (gpointer)s); 
    100 
    101  
    102 static void 
    103 stop_playmarker (sw_sample * s) 
    104 
    105   if (s->playmarker_tag > 0) 
    106     gtk_timeout_remove (s->playmarker_tag); 
    107   s->playmarker_tag = 0; 
    108   sample_set_playmarker (s, -1); 
    109 
    110  
    111 static int 
    112 open_dev_dsp (void) 
    113 
    114 #if defined(DRIVER_OSS) || defined(DRIVER_SOLARIS_AUDIO) 
    115   if((dev_dsp = open(DEV_DSP, O_WRONLY|O_NDELAY, 0)) == -1) { 
    116     perror ("sweep: unable to open device " DEV_DSP); 
    117     return -1; /* XXX: Flag error */ 
    118   } 
    119  
    120   return dev_dsp; 
    121 #elif defined(DRIVER_ALSA) 
    122   int err; 
    123   char *alsa_pcm_name; 
    124   if ((alsa_pcm_name = getenv ("SWEEP_ALSA_PCM")) == 0) { 
    125         alsa_pcm_name = ALSA_PCM_NAME; 
    126   } 
    127   if ((err = snd_pcm_open(&pcm_handle, alsa_pcm_name, 
    128                         SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0) { 
    129     fprintf (stderr, "sweep: unable to open ALSA device %s (%s)\n", 
    130            alsa_pcm_name, snd_strerror (err)); 
    131     return -1; /* XXX: Flag error */ 
    132   } 
    133   dev_dsp = snd_pcm_poll_descriptor (pcm_handle); 
    134 #else 
    135   fprintf(stderr, "Warning: No audio device configured\n"); 
    136   return -1; 
    137 #endif 
    138   return 0; 
    139 
    140  
    141 static void 
    142 setup_dev_dsp (sw_sample * s) 
    143 
    144 #ifdef DRIVER_OSS 
    145   int mask, format, stereo, frequency; 
    146  
    147   if(ioctl(dev_dsp, SNDCTL_DSP_GETFMTS, &mask) == -1)  { 
    148     perror("OSS: error getting format masks"); 
    149     close(dev_dsp); 
    150     return; /* XXX: Flag error */ 
    151   } 
    152  
    153   if(mask&AFMT_U16_LE) { 
    154     format=AFMT_U16_LE; 
    155   } 
    156   if(mask&AFMT_U16_BE) { 
    157     format=AFMT_U16_BE; 
    158   } 
    159   if(mask&AFMT_S16_BE) { 
    160     format=AFMT_S16_BE; 
    161   } 
    162   if(mask&AFMT_U16_LE) { 
    163     format=AFMT_U16_LE; 
    164   } 
    165   if(mask&AFMT_S16_LE) { 
    166     format=AFMT_S16_LE; 
    167   } 
    168  
    169   if (ioctl(dev_dsp, SNDCTL_DSP_SETFMT, &format) == -1) { 
    170     perror("OSS: Unable to set format"); 
    171     exit(-1); 
    172     } 
    173  
    174   stereo = s->sounddata->format->channels - 1; 
    175   if(ioctl(dev_dsp, SNDCTL_DSP_STEREO, &stereo) == -1 ) { 
    176     perror("OSS: Unable to set channels"); 
    177   } 
    178  
    179   frequency = s->sounddata->format->rate; 
    180   if(ioctl(dev_dsp, SNDCTL_DSP_SPEED, &frequency) == -1 ) { 
    181     perror("OSS: Unable to set playback frequency"); 
    182   } 
    183 #elif defined(DRIVER_SOLARIS_AUDIO) 
    184  
    185   audio_info_t info; 
    186   AUDIO_INITINFO(&info); 
    187   info.play.precision = 16;     /* cs4231 doesn't handle 16-bit linear PCM */ 
    188   info.play.encoding = AUDIO_ENCODING_LINEAR; 
    189   info.play.channels = s->sounddata->format->channels; 
    190   info.play.sample_rate = s->sounddata->format->rate; 
    191   if(ioctl(dev_dsp, AUDIO_SETINFO, &info) < 0) 
    192       perror("Unable to configure audio device"); 
    193 #elif defined(DRIVER_ALSA) 
    194   snd_pcm_params_t params; 
    195   snd_pcm_params_info_t params_info; 
    196   int err = 0; 
    197  
    198   memset (&params, 0, sizeof(params)); 
    199   memset (&params_info, 0, sizeof(params_info)); 
    200  
    201   if (snd_pcm_params_info (pcm_handle, &params_info) < 0) { 
    202         fprintf(stderr, "cannot get audio interface parameters (%s)\n", 
    203                 snd_strerror(err)); 
    204           return; 
    205   } 
    206  
    207   if (params_info.formats & SND_PCM_FMT_S16_LE) { 
    208     params.format.sfmt = SND_PCM_SFMT_S16_LE; 
    209   } else { 
    210     fprintf (stderr, "audio interface does not support " 
    211              "linear 16 bit little endian samples\n"); 
    212     return; 
    213   } 
    214  
    215   switch (s->sounddata->format->rate) { 
    216   case 44100: 
    217         if (params_info.rates & SND_PCM_RATE_44100) { 
    218                 params.format.rate = 44100; 
    219         } else { 
    220                 fprintf (stderr, "audio interface does not support " 
    221                          "44.1kHz sample rate (0x%x)\n", 
    222                          params_info.rates); 
    223                 return; 
    224         } 
    225         break; 
    226  
    227   case 48000: 
    228         if (params_info.rates & SND_PCM_RATE_48000) { 
    229                 params.format.rate = 48000; 
    230         } else { 
    231                 fprintf (stderr, "audio interface does not support " 
    232                          "48kHz sample rate\n"); 
    233                 return; 
    234         } 
    235         break; 
    236  
    237   default: 
    238         fprintf (stderr, "audio interface does not support " 
    239                  "a sample rate of %d\n", 
    240                  s->sounddata->format->rate); 
    241         return; 
    242   } 
    243  
    244   if (s->sounddata->format->channels < params_info.min_channels || 
    245       s->sounddata->format->channels > params_info.max_channels) { 
    246       fprintf (stderr, "audio interface does not support %d channels\n", 
    247              s->sounddata->format->channels); 
    248       return; 
    249   } 
    250   params.format.channels = s->sounddata->format->channels; 
    251   params.ready_mode = SND_PCM_READY_FRAGMENT; 
    252   params.start_mode = SND_PCM_START_DATA; 
    253   params.xrun_mode = SND_PCM_XRUN_FRAGMENT; 
    254   params.frag_size = PBUF_SIZE / params.format.channels; 
    255   params.avail_min = params.frag_size; 
    256   // params.buffer_size = 3 * params.frag_size; 
    257  
    258   if ((err = snd_pcm_params (pcm_handle, &params)) < 0) { 
    259         fprintf (stderr, "audio interface could not be configured " 
    260                  "with the specified parameters\n"); 
    261         return; 
    262   } 
    263  
    264   if (snd_pcm_prepare (pcm_handle) < 0) { 
    265         fprintf (stderr, "audio interface could not be prepared " 
    266                  "for playback\n"); 
    267         return; 
    268   } 
    269 #endif 
    270 
    271  
    272 static void 
    273 reset_dev_dsp (void) 
    274 
    275 #ifdef DRIVER_OSS 
    276   if(ioctl (dev_dsp, SNDCTL_DSP_RESET) == -1) { 
    277     perror ("OSS: error resetting " DEV_DSP); 
    278   } 
    279 #endif 
    280 
    281  
    282 static void 
    283 flush_dev_dsp (void) 
    284 
    285 #ifdef DRIVER_SOLARIS_AUDIO 
    286   if (ioctl(dev_dsp, I_FLUSH, FLUSHW) == -1) 
    287     perror("I_FLUSH"); 
    288 #endif 
    289 
    290  
    291 static void 
    292 drain_dev_dsp (void) 
    293 
    294 #ifdef DRIVER_OSS 
    295   if(ioctl (dev_dsp, SNDCTL_DSP_POST) == -1) { 
    296     perror ("OSS: POST error on " DEV_DSP); 
    297   } 
    298 #endif 
    299  
    300 #ifdef DRIVER_SOLARIS_AUDIO 
    301   if(ioctl(dev_dsp, AUDIO_DRAIN, 0) == -1) 
    302       perror("AUDIO_DRAIN"); 
    303 #endif 
    304  
    305 #ifdef DRIVER_ALSA 
    306   if (snd_pcm_drop (pcm_handle) < 0) { 
    307         fprintf (stderr, "audio interface could not be stopped\n"); 
    308         return; 
    309   } 
    310   if (snd_pcm_prepare (pcm_handle) < 0) { 
    311         fprintf (stderr, "audio interface could not be re-prepared\n"); 
    312         return; 
    313   } 
    314 #endif 
    315  
    316 
    317  
    318 /* 
    319  * WAIT_FOR_PLAYING 
    320  * 
    321  * This busy waits until 'playing' is set to NULL.. 
    322  * This is done to retain control of the dev_dsp device 
    323  * so that it can be reset to "immediately" 
    324  * stop playback when interrupted. 
    325  */ 
    326 #define WAIT_FOR_PLAYING \ 
    327   while (playing) usleep (100000) 
    328  
    329 static void 
    330 close_dev_dsp (void) 
    331 
    332 #if defined(DRIVER_OSS) || defined(DRIVER_SOLARIS_AUDIO) 
    333   close (dev_dsp); 
    334 #elif defined(DRIVER_ALSA) 
    335   snd_pcm_close (pcm_handle); 
    336 #endif 
    337   dev_dsp = -1; 
    338 
    339  
    340 static void 
    341 play_view(sw_view * view, sw_framecount_t start, sw_framecount_t end, gfloat relpitch) 
    342 
    343   sw_sample * s = view->sample; 
    344   fd_set fds; 
    345   ssize_t n = 0; 
    346   sw_audio_t * d; 
    347   gint16 pbuf[PBUF_SIZE]; 
    348   gint sbytes, channels; 
    349   gdouble po = 0.0, p, endf; 
    350   gint i=0, si=0; 
    351  
    352   d = (sw_audio_t *)s->sounddata->data; 
    353  
    354   sbytes = 2; 
    355   
    356   channels = s->sounddata->format->channels; 
    357  
    358   playoffset = start; 
    359   po = (gdouble)(start); 
    360   endf = (gdouble)(end); 
    361  
    362   while ((po <= endf) && playing) { 
    363     FD_ZERO (&fds); 
    364     FD_SET (dev_dsp, &fds); 
    365      
    366     if (select (dev_dsp+1, NULL, &fds, NULL, NULL) == 0); 
    367  
    368     memset (pbuf, 0, sizeof (pbuf)); 
    369  
    370     switch (channels) { 
    371     case 1: 
    372       for (i = 0; i < PBUF_SIZE; i++) { 
    373         si = (int)floor(po); 
    374         p = po - (gdouble)si; 
    375         ((gint16 *)pbuf)[i] = 
    376           (gint16)(PLAYBACK_SCALE * view->vol * 
    377                    (d[si] * p + d[si+channels] * (1 - p))); 
    378         po += relpitch; 
    379         if (po > endf) break; 
    380       } 
    381        
    382       break; 
    383     case 2: 
    384       for (i = 0; i < PBUF_SIZE; i++) { 
    385         si = (int)floor(po); 
    386         p = po - (gdouble)si; 
    387         si *= 2; 
    388         ((gint16 *)pbuf)[i] = 
    389           (gint16)(PLAYBACK_SCALE * view->vol * 
    390                    (d[si] * p + d[si+channels] * (1 - p))); 
    391         i++; si++; 
    392         ((gint16 *)pbuf)[i] = 
    393           (gint16)(PLAYBACK_SCALE * view->vol * 
    394                    (d[si] * p + d[si+channels] * (1 - p))); 
    395         po += relpitch; 
    396         if (po > endf) break; 
    397       } 
    398        
    399       break; 
    400     } 
    401  
    402     /* Only write if still playing */ 
    403     if (playing) { 
    404 #if defined(DRIVER_OSS) || defined(DRIVER_SOLARIS_AUDIO) 
    405       n = write (dev_dsp, pbuf, i*sbytes); 
    406 #elif defined(DRIVER_ALSA) 
    407       n = snd_pcm_write (pcm_handle, pbuf, PBUF_SIZE/channels); 
    408 #endif 
    409     } 
    410  
    411     playoffset += (int)(n * relpitch / (sbytes * channels)); 
    412   } 
    413 
    414  
    415 static void 
    416 pva (sw_view * view) 
    417 
    418   sw_sample * s = view->sample; 
    419  
    420   setup_dev_dsp (s); 
    421  
    422   play_view (view, 0, s->sounddata->nr_frames, 1.0); 
    423  
    424   drain_dev_dsp (); 
    425  
    426   stop_playmarker (s); 
    427  
    428   WAIT_FOR_PLAYING; 
    429  
    430   reset_dev_dsp (); 
    431   close_dev_dsp (); 
    432 
    433  
    434 void 
    435 play_view_all (sw_view * view) 
    436 
    437   sw_sample * s = view->sample; 
    438  
    439   stop_playback (); 
    440  
    441   playing = s; 
    442   if (open_dev_dsp () >= 0) { 
    443     pthread_create (&player_thread, NULL, (void *) (*pva), view); 
    444     start_playmarker (s); 
    445   } 
    446 
    447  
    448 void 
    449 pval (sw_view * view) 
    450 
    451   sw_sample * s = view->sample; 
    452  
    453   setup_dev_dsp (s); 
    454  
    455   while (playing) 
    456     play_view (view, 0, s->sounddata->nr_frames, 1.0); 
    457  
    458   reset_dev_dsp (); 
    459   close_dev_dsp (); 
    460 
    461  
    462 void 
    463 play_view_all_loop (sw_view * view) 
    464 
    465   sw_sample * s = view->sample; 
    466  
    467   stop_playback (); 
    468  
    469   playing = s; 
    470   if (open_dev_dsp () >= 0) { 
    471     pthread_create (&player_thread, NULL, (void *) (*pval), view); 
    472     start_playmarker (s); 
    473   } 
    474 
    475  
    476 static void 
    477 pvs (sw_view * view) 
    478 
    479   sw_sample * s = view->sample; 
    480   GList * gl, * gl_next; 
    481   sw_sel * sel; 
    482   sw_framecount_t start, end; 
    483  
    484   setup_dev_dsp (s); 
    485  
    486   for (gl = s->sounddata->sels; gl; ) { 
    487  
    488     /* Hold sels_mutex for as little time as possible */ 
    489     g_mutex_lock (s->sounddata->sels_mutex); 
    490  
    491     /* if gl is no longer in sels, break out */ 
    492     if (g_list_position (s->sounddata->sels, gl) == -1) { 
    493       g_mutex_unlock (s->sounddata->sels_mutex); 
    494       break; 
    495     } 
    496  
    497     sel = (sw_sel *)gl->data; 
    498     start = sel->sel_start; 
    499     end = sel->sel_end; 
    500     gl_next = gl->next; 
    501  
    502     g_mutex_unlock (s->sounddata->sels_mutex); 
    503  
    504     play_view (view, start, end, 1.0); 
    505  
    506     gl = gl_next; 
    507   } 
    508    
    509   drain_dev_dsp (); 
    510  
    511   stop_playmarker (s); 
    512  
    513   WAIT_FOR_PLAYING;  
    514  
    515   reset_dev_dsp (); 
    516   close_dev_dsp (); 
    517 
    518  
    519 void 
    520 play_view_sel (sw_view * view) 
    521 
    522   sw_sample * s = view->sample; 
    523  
    524   stop_playback (); 
    525  
    526   playing = s; 
    527   if (open_dev_dsp () >= 0) { 
    528     pthread_create (&player_thread, NULL, (void *) (*pvs), view); 
    529     start_playmarker (s); 
    530   } 
    531 
    532  
    533 static void 
    534 pvsl (sw_view * view) 
    535 
    536   sw_sample * s = view->sample; 
    537   GList * gl, * gl_next; 
    538   sw_sel * sel; 
    539   sw_framecount_t start, end; 
    540  
    541   setup_dev_dsp (s); 
    542  
    543   while (playing) { 
    544  
    545     for (gl = s->sounddata->sels; gl; ) { 
    546        
    547       /* Hold sels_mutex for as little time as possible */ 
    548       g_mutex_lock (s->sounddata->sels_mutex); 
    549  
    550       /* if gl is no longer in sels, break out */ 
    551       if (g_list_position (s->sounddata->sels, gl) == -1) { 
    552         g_mutex_unlock (s->sounddata->sels_mutex); 
    553         break; 
    554       } 
    555  
    556       sel = (sw_sel *)gl->data; 
    557       start = sel->sel_start; 
    558       end = sel->sel_end; 
    559       gl_next = gl->next; 
    560        
    561       g_mutex_unlock (s->sounddata->sels_mutex); 
    562        
    563       play_view (view, start, end, 1.0); 
    564        
    565       gl = gl_next; 
     72 
     73  return NULL; 
     74
     75 
     76char * 
     77pcmio_get_default_monitor_dev (void) 
     78
     79  GList * names = NULL, * gl; 
     80 
     81  if (pref->get_names) 
     82    names = pref->get_names (); 
     83 
     84  if ((gl = names) != NULL) { 
     85    if ((gl = gl->next) != NULL) { 
     86      return (char *)gl->data; 
    56687    } 
    56788  } 
    56889 
    569   reset_dev_dsp (); 
    570  
    571   close_dev_dsp (); 
     90  return NULL; 
     91
     92 
     93char * 
     94pcmio_get_main_dev (void) 
     95
     96  char * main_dev; 
     97 
     98  main_dev = prefs_get_string (DEV_KEY); 
     99 
     100  if (main_dev == NULL) return pcmio_get_default_main_dev(); 
     101   
     102  return main_dev; 
     103
     104 
     105char * 
     106pcmio_get_monitor_dev (void) 
     107
     108  char * monitor_dev; 
     109 
     110  monitor_dev = prefs_get_string (MONITOR_DEV_KEY); 
     111 
     112  if (monitor_dev == NULL) return pcmio_get_default_monitor_dev (); 
     113   
     114  return monitor_dev; 
     115
     116 
     117gboolean 
     118pcmio_get_use_monitor (void) 
     119
     120  int * use_monitor; 
     121 
     122  use_monitor = prefs_get_int (USE_MONITOR_KEY); 
     123 
     124  if (use_monitor == NULL) return DEFAULT_USE_MONITOR; 
     125  else return (*use_monitor != 0); 
     126
     127 
     128int 
     129pcmio_get_log_frags (void) 
     130
     131  int * log_frags; 
     132 
     133  log_frags = prefs_get_int (LOG_FRAGS_KEY); 
     134 
     135  if (log_frags == NULL) return DEFAULT_LOG_FRAGS; 
     136  else return (*log_frags); 
     137
     138 
     139extern GtkStyle * style_bw; 
     140static GtkWidget * dialog = NULL; 
     141static GtkWidget * main_combo; 
     142static GtkWidget * monitor_combo; 
     143static GtkObject * adj; 
     144 
     145 
     146static gboolean 
     147monitor_checked (GtkWidget * dialog) 
     148
     149  GtkWidget * monitor_chb; 
     150 
     151  monitor_chb = 
     152    GTK_WIDGET(gtk_object_get_data (GTK_OBJECT(dialog), "monitor_chb")); 
     153 
     154  return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (monitor_chb)); 
     155
     156 
     157static void 
     158config_dev_dsp_dialog_ok_cb (GtkWidget * widget, gpointer data) 
     159
     160  GtkWidget * dialog = GTK_WIDGET (data); 
     161  GtkAdjustment * adj; 
     162  char * main_dev, * monitor_dev; 
     163 
     164  adj = gtk_object_get_data (GTK_OBJECT(dialog), "buff_adj"); 
     165 
     166  prefs_set_int (LOG_FRAGS_KEY, adj->value); 
     167 
     168  main_dev = 
     169    gtk_entry_get_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry)); 
     170 
     171  prefs_set_string (DEV_KEY, main_dev); 
     172 
     173  if (monitor_checked (dialog)) { 
     174    monitor_dev = 
     175      gtk_entry_get_text (GTK_ENTRY(GTK_COMBO(monitor_combo)->entry));  
     176    prefs_set_string (MONITOR_DEV_KEY, monitor_dev); 
     177 
     178    prefs_set_int (USE_MONITOR_KEY, 1); 
     179  } else { 
     180    prefs_set_int (USE_MONITOR_KEY, 0); 
     181  } 
     182 
     183  gtk_widget_hide (dialog); 
     184
     185 
     186static void 
     187config_dev_dsp_dialog_cancel_cb (GtkWidget * widget, gpointer data) 
     188
     189  GtkWidget * dialog; 
     190 
     191  dialog = gtk_widget_get_toplevel (widget); 
     192  gtk_widget_hide (dialog); 
     193
     194 
     195static void 
     196update_ok_button (GtkWidget * widget, gpointer data) 
     197
     198  GtkWidget * dialog = GTK_WIDGET(data); 
     199  GtkWidget * ok_button; 
     200  gchar * main_devname, * monitor_devname; 
     201  gboolean ok = FALSE; 
     202 
     203  ok_button = 
     204    GTK_WIDGET(gtk_object_get_data (GTK_OBJECT(dialog), "ok_button")); 
     205 
     206  if (monitor_checked (dialog)) { 
     207    main_devname = 
     208      gtk_entry_get_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry)); 
     209    monitor_devname = 
     210      gtk_entry_get_text (GTK_ENTRY(GTK_COMBO(monitor_combo)->entry)); 
     211 
     212    ok = (strcmp (main_devname, monitor_devname) != 0); 
     213  } else { 
     214    ok = TRUE; 
     215  } 
     216 
     217  gtk_widget_set_sensitive (ok_button, ok); 
     218
     219 
     220static void 
     221set_monitor_widgets (GtkWidget * dialog, gboolean use_monitor) 
     222
     223  GtkWidget * monitor_chb, * monitor_widget, * swap; 
     224 
     225  monitor_chb = 
     226    GTK_WIDGET(gtk_object_get_data (GTK_OBJECT(dialog), "monitor_chb")); 
     227  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(monitor_chb), use_monitor); 
     228 
     229  monitor_widget = gtk_object_get_data (GTK_OBJECT(dialog), "monitor_widget"); 
     230  gtk_widget_set_sensitive (monitor_widget, use_monitor); 
     231 
     232  swap = gtk_object_get_data (GTK_OBJECT(dialog), "swap"); 
     233  gtk_widget_set_sensitive (swap, use_monitor); 
     234 
     235
     236 
     237static void 
     238set_buff_adj (GtkWidget * dialog, gint logfrags) 
     239
     240  GtkAdjustment * adj; 
     241 
     242  adj = gtk_object_get_data (GTK_OBJECT(dialog), "buff_adj"); 
     243  gtk_adjustment_set_value (adj, logfrags); 
     244
     245 
     246static void 
     247pcmio_devname_swap_cb (GtkWidget * widget, gpointer data) 
     248
     249  GtkWidget * dialog = GTK_WIDGET (data); 
     250  char * main_dev, * monitor_dev; 
     251 
     252  main_dev = 
     253    g_strdup (gtk_entry_get_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry))); 
     254  monitor_dev = gtk_entry_get_text (GTK_ENTRY(GTK_COMBO(monitor_combo)->entry)); 
     255 
     256  gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry), monitor_dev); 
     257  gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(monitor_combo)->entry), main_dev); 
     258 
     259  g_free (main_dev); 
     260 
     261  set_monitor_widgets (dialog, pcmio_get_use_monitor()); 
     262 
     263  update_ok_button (widget, data); 
     264
     265 
     266static void 
     267pcmio_devname_reset_cb (GtkWidget * widget, gpointer data) 
     268
     269  GtkWidget * dialog = GTK_WIDGET (data); 
     270  char * main_dev, * monitor_dev; 
     271 
     272  main_dev = pcmio_get_main_dev (); 
     273  monitor_dev = pcmio_get_monitor_dev (); 
     274 
     275  gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry), main_dev); 
     276  gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(monitor_combo)->entry), monitor_dev); 
     277 
     278  set_monitor_widgets (dialog, pcmio_get_use_monitor()); 
     279 
     280  update_ok_button (widget, data); 
     281
     282 
     283static void 
     284pcmio_devname_default_cb (GtkWidget * widget, gpointer data) 
     285
     286  GtkWidget * dialog = GTK_WIDGET (data); 
     287  char * name; 
     288 
     289  if ((name = pcmio_get_default_main_dev ()) != NULL) { 
     290    gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry), name); 
     291  } 
     292 
     293  if ((name = pcmio_get_default_monitor_dev ()) != NULL) { 
     294    gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(monitor_combo)->entry), name); 
     295  } 
     296 
     297  set_monitor_widgets (dialog, DEFAULT_USE_MONITOR); 
     298 
     299  update_ok_button (widget, data); 
     300
     301 
     302static void 
     303monitor_enable_cb (GtkWidget * widget, gpointer data) 
     304
     305  GtkWidget * dialog = GTK_WIDGET (data); 
     306  gboolean active; 
     307 
     308  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     309 
     310  set_monitor_widgets (dialog, active); 
     311
     312 
     313static void 
     314pcmio_buffering_reset_cb (GtkWidget * widget, gpointer data) 
     315
     316  GtkWidget * dialog = GTK_WIDGET (data); 
     317 
     318  set_buff_adj (dialog, pcmio_get_log_frags()); 
     319
     320 
     321static void 
     322pcmio_buffering_default_cb (GtkWidget * widget, gpointer data) 
     323
     324  GtkWidget * dialog = GTK_WIDGET (data); 
     325 
     326  set_buff_adj (dialog, DEFAULT_LOG_FRAGS); 
     327
     328 
     329static GtkWidget * 
     330create_devices_combo (void) 
     331
     332  GtkWidget * combo; 
     333  GList * cbitems = NULL; 
     334 
     335  if (pref->get_names) 
     336    cbitems = pref->get_names(); 
     337   
     338  combo = gtk_combo_new (); 
     339   
     340  gtk_combo_set_popdown_strings (GTK_COMBO(combo), cbitems); 
     341 
     342  return combo; 
    572343} 
    573344 
    574345void 
    575 play_view_sel_loop (sw_view * view) 
    576 
    577   sw_sample * s = view->sample; 
    578   stop_playback (); 
    579  
    580   playing = s; 
    581   if (open_dev_dsp () >= 0) { 
    582     pthread_create (&player_thread, NULL, (void *) (*pvsl), view); 
    583     start_playmarker (s); 
     346device_config (void) 
     347
     348  GtkWidget * ebox; 
     349  GtkWidget * notebook; 
     350  GtkWidget * separator; 
     351  GtkWidget * hbox, * hbox2; 
     352  GtkWidget * vbox; 
     353  GtkWidget * label; 
     354  GtkWidget * checkbutton; 
     355  GtkWidget * hscale; 
     356  GtkWidget * ok_button; 
     357  GtkWidget * button; 
     358 
     359  GtkTooltips * tooltips; 
     360 
     361  if (dialog == NULL) { 
     362 
     363    dialog = gtk_dialog_new (); 
     364    gtk_window_set_title (GTK_WINDOW(dialog), _("Sweep: audio device configuration")); 
     365    gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE); 
     366 
     367    /* OK */ 
     368 
     369    ok_button = gtk_button_new_with_label (_("OK")); 
     370    GTK_WIDGET_SET_FLAGS (GTK_WIDGET (ok_button), GTK_CAN_DEFAULT); 
     371    gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->action_area), ok_button, 
     372                        TRUE, TRUE, 0); 
     373    gtk_widget_show (ok_button); 
     374    gtk_signal_connect (GTK_OBJECT(ok_button), "clicked", 
     375                        GTK_SIGNAL_FUNC (config_dev_dsp_dialog_ok_cb), 
     376                        dialog); 
     377 
     378    gtk_object_set_data (GTK_OBJECT (dialog), "ok_button", ok_button); 
     379 
     380    /* Cancel */ 
     381 
     382    button = gtk_button_new_with_label (_("Cancel")); 
     383    GTK_WIDGET_SET_FLAGS (GTK_WIDGET (button), GTK_CAN_DEFAULT); 
     384    gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->action_area), button, 
     385                        TRUE, TRUE, 0); 
     386    gtk_widget_show (button); 
     387    gtk_signal_connect (GTK_OBJECT(button), "clicked", 
     388                        GTK_SIGNAL_FUNC (config_dev_dsp_dialog_cancel_cb), 
     389                        NULL); 
     390 
     391    gtk_widget_grab_default (ok_button); 
     392 
     393 
     394    ebox = gtk_event_box_new (); 
     395    gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), ebox, 
     396                        TRUE, TRUE, 0); 
     397    gtk_widget_set_style (ebox, style_bw); 
     398    gtk_widget_show (ebox); 
     399 
     400    vbox = gtk_vbox_new (FALSE, 0); 
     401    gtk_container_add (GTK_CONTAINER(ebox), vbox); 
     402    gtk_widget_show (vbox); 
     403 
     404    /* Changes ... info */ 
     405    label = gtk_label_new (_("Changes to device settings will take effect on" 
     406                             " next playback.")); 
     407    gtk_box_pack_start (GTK_BOX(vbox), label, TRUE, TRUE, 8); 
     408    gtk_widget_show (label); 
     409 
     410 
     411    /* Notebook */ 
     412 
     413    notebook = gtk_notebook_new (); 
     414    gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook, 
     415                        TRUE, TRUE, 4); 
     416    gtk_widget_show (notebook); 
     417 
     418    /* Device name */ 
     419    label = gtk_label_new (_("Device name")); 
     420    vbox = gtk_vbox_new (FALSE, 0); 
     421    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label); 
     422    gtk_container_set_border_width (GTK_CONTAINER(vbox), 4); 
     423    gtk_widget_show (vbox); 
     424 
     425    label = gtk_label_new (_("Set the main device for playback and recording")); 
     426    gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 4); 
     427    gtk_widget_show (label); 
     428 
     429    /* Main output */  
     430    hbox = gtk_hbox_new (FALSE, 8); 
     431    gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, TRUE, 8); 
     432    gtk_container_set_border_width (GTK_CONTAINER(hbox), 12); 
     433    gtk_widget_show (hbox); 
     434       
     435    label = gtk_label_new (_("Main device:")); 
     436    gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0); 
     437    gtk_widget_show (label); 
     438       
     439    main_combo = create_devices_combo (); 
     440    gtk_box_pack_start (GTK_BOX(hbox), main_combo, TRUE, TRUE, 0); 
     441    gtk_widget_show (main_combo); 
     442 
     443    gtk_signal_connect (GTK_OBJECT(GTK_COMBO(main_combo)->entry), "changed", 
     444                        GTK_SIGNAL_FUNC(update_ok_button), dialog); 
     445 
     446    gtk_object_set_data (GTK_OBJECT (dialog), "main_combo", main_combo); 
     447 
     448#if 0 
     449    button = gtk_button_new_with_label (_("Default")); 
     450    gtk_box_pack_start (GTK_BOX(hbox), button, FALSE, FALSE, 0); 
     451    gtk_widget_show (button); 
     452    gtk_signal_connect (GTK_OBJECT(button), "clicked", 
     453                        GTK_SIGNAL_FUNC(default_devicename_cb), NULL); 
     454#endif 
     455 
     456    separator = gtk_hseparator_new (); 
     457    gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 8); 
     458    gtk_widget_show (separator); 
     459 
     460    /* Monitor */ 
     461    checkbutton = 
     462      gtk_check_button_new_with_label (_("Use a different device for monitoring")); 
     463    gtk_box_pack_start (GTK_BOX(vbox), checkbutton, FALSE, FALSE, 4); 
     464    gtk_widget_show (checkbutton); 
     465 
     466    gtk_signal_connect (GTK_OBJECT(checkbutton), "toggled", 
     467                        GTK_SIGNAL_FUNC(update_ok_button), dialog); 
     468 
     469    hbox = gtk_hbox_new (FALSE, 8); 
     470    gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, TRUE, 8); 
     471    gtk_container_set_border_width (GTK_CONTAINER(hbox), 12); 
     472    gtk_widget_show (hbox); 
     473       
     474    label = gtk_label_new (_("Monitor output:")); 
     475    gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0); 
     476    gtk_widget_show (label); 
     477 
     478    monitor_combo = create_devices_combo (); 
     479    gtk_box_pack_start (GTK_BOX(hbox), monitor_combo, TRUE, TRUE, 0); 
     480    gtk_widget_show (monitor_combo); 
     481 
     482    gtk_signal_connect (GTK_OBJECT(GTK_COMBO(monitor_combo)->entry), "changed", 
     483                        GTK_SIGNAL_FUNC(update_ok_button), dialog); 
     484 
     485    gtk_signal_connect (GTK_OBJECT(checkbutton), "toggled", 
     486                        GTK_SIGNAL_FUNC(monitor_enable_cb), dialog); 
     487 
     488    gtk_object_set_data (GTK_OBJECT (dialog), "monitor_chb", checkbutton); 
     489    gtk_object_set_data (GTK_OBJECT (dialog), "monitor_widget", hbox); 
     490 
     491 
     492    /* Swap / Remember / Reset device names*/ 
     493 
     494    hbox = gtk_hbox_new (FALSE, 4); 
     495    gtk_box_pack_end (GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 
     496    gtk_container_set_border_width (GTK_CONTAINER(hbox), 12); 
     497    gtk_widget_show (hbox); 
     498 
     499    button = gtk_button_new_with_label (_("Swap")); 
     500    gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 4); 
     501    gtk_signal_connect (GTK_OBJECT(button), "clicked", 
     502                        GTK_SIGNAL_FUNC(pcmio_devname_swap_cb), dialog); 
     503    gtk_widget_show (button); 
     504 
     505    tooltips = gtk_tooltips_new (); 
     506    gtk_tooltips_set_tip (tooltips, button, 
     507                          _("Swap main and monitor devices."), 
     508                          NULL); 
     509 
     510    gtk_object_set_data (GTK_OBJECT (dialog), "swap", button); 
     511 
     512    hbox2 = gtk_hbox_new (TRUE, 4); 
     513    gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, TRUE, 0); 
     514    gtk_widget_show (hbox2); 
     515 
     516    button = gtk_button_new_with_label (_("Reset")); 
     517    gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, TRUE, 4); 
     518    gtk_signal_connect (GTK_OBJECT(button), "clicked", 
     519                        GTK_SIGNAL_FUNC(pcmio_devname_reset_cb), dialog); 
     520    gtk_widget_show (button); 
     521 
     522    tooltips = gtk_tooltips_new (); 
     523    gtk_tooltips_set_tip (tooltips, button, 
     524                          _("Reset to the last remembered device names."), 
     525                          NULL); 
     526 
     527    /* Call the reset callback now to set remembered options */ 
     528    pcmio_devname_reset_cb (button, dialog); 
     529 
     530    button = gtk_button_new_with_label (_("Defaults")); 
     531    gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, TRUE, 4); 
     532    gtk_signal_connect (GTK_OBJECT(button), "clicked", 
     533                        GTK_SIGNAL_FUNC(pcmio_devname_default_cb), dialog); 
     534    gtk_widget_show (button); 
     535 
     536    tooltips = gtk_tooltips_new (); 
     537    gtk_tooltips_set_tip (tooltips, button, 
     538                          _("Set to default device names."), 
     539                          NULL); 
     540 
     541 
     542    separator = gtk_hseparator_new (); 
     543    gtk_box_pack_end (GTK_BOX (vbox), separator, FALSE, FALSE, 8); 
     544    gtk_widget_show (separator); 
     545 
     546 
     547    /* Buffering */ 
     548 
     549    label = gtk_label_new (_("Device buffering")); 
     550    vbox = gtk_vbox_new (FALSE, 0); 
     551    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label); 
     552    gtk_container_set_border_width (GTK_CONTAINER(vbox), 4); 
     553    gtk_widget_show (vbox); 
     554 
     555    hbox = gtk_hbox_new (FALSE, 8); 
     556    gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 8); 
     557    gtk_widget_show (hbox); 
     558 
     559    label = gtk_label_new (_("Low latency /\nMore dropouts")); 
     560    gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 8); 
     561    gtk_widget_show (label); 
     562 
     563    adj = gtk_adjustment_new (pcmio_get_log_frags (), /* value */ 
     564                              LOG_FRAGS_MIN, /* lower */ 
     565                              LOG_FRAGS_MAX+1, /* upper */ 
     566                              1, /* step incr */ 
     567                              1, /* page incr */ 
     568                              1  /* page size */ 
     569                              ); 
     570 
     571    gtk_object_set_data (GTK_OBJECT(dialog), "buff_adj", adj); 
     572 
     573    hscale = gtk_hscale_new (GTK_ADJUSTMENT(adj)); 
     574    gtk_box_pack_start (GTK_BOX(hbox), hscale, TRUE, TRUE, 4); 
     575    gtk_scale_set_draw_value (GTK_SCALE(hscale), TRUE); 
     576    gtk_scale_set_digits (GTK_SCALE(hscale), 0); 
     577    gtk_range_set_update_policy (GTK_RANGE(hscale), GTK_UPDATE_CONTINUOUS); 
     578    gtk_widget_set_usize (hscale, 160, -1); 
     579    gtk_widget_show (hscale); 
     580 
     581    label = gtk_label_new (_("High latency /\nFewer dropouts")); 
     582    gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 8); 
     583    gtk_widget_show (label); 
     584 
     585    label = gtk_label_new (_("Varying this slider controls the lag between " 
     586                             "cursor movements and playback. This is " 
     587                             "particularly noticeable when \"scrubbing\" " 
     588                             "during playback.\n\nLower values improve " 
     589                             "responsiveness but may degrade audio quality " 
     590                             "on heavily-loaded systems.")); 
     591    gtk_label_set_line_wrap (GTK_LABEL(label), TRUE); 
     592    gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 8); 
     593    gtk_widget_show (label); 
     594 
     595    /* Remember / Reset device buffering */ 
     596 
     597    hbox = gtk_hbox_new (FALSE, 4); 
     598    gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 
     599    gtk_container_set_border_width (GTK_CONTAINER(hbox), 12); 
     600    gtk_widget_show (hbox); 
     601 
     602#if 0 
     603    checkbutton = 
     604      gtk_check_button_new_with_label (_("Remember these options")); 
     605    gtk_box_pack_start (GTK_BOX (hbox), checkbutton, TRUE, TRUE, 0); 
     606    gtk_widget_show (checkbutton); 
     607 
     608    gtk_object_set_data (GTK_OBJECT (dialog), "rem_options_chb", checkbutton); 
     609 
     610    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbutton), TRUE); 
     611#endif 
     612 
     613    hbox2 = gtk_hbox_new (TRUE, 4); 
     614    gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, TRUE, 0); 
     615    gtk_widget_show (hbox2); 
     616 
     617    button = gtk_button_new_with_label (_("Reset")); 
     618    gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, TRUE, 4); 
     619    gtk_signal_connect (GTK_OBJECT(button), "clicked", 
     620                        GTK_SIGNAL_FUNC(pcmio_buffering_reset_cb), dialog); 
     621    gtk_widget_show (button); 
     622 
     623    tooltips = gtk_tooltips_new (); 
     624    gtk_tooltips_set_tip (tooltips, button, 
     625                          _("Reset to the last remembered device buffering."), 
     626                          NULL); 
     627 
     628    /* Call the reset callback now to set remembered options */ 
     629    pcmio_buffering_reset_cb (button, dialog); 
     630 
     631    button = gtk_button_new_with_label (_("Default")); 
     632    gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, TRUE, 4); 
     633    gtk_signal_connect (GTK_OBJECT(button), "clicked", 
     634                        GTK_SIGNAL_FUNC(pcmio_buffering_default_cb), dialog); 
     635    gtk_widget_show (button); 
     636 
     637    tooltips = gtk_tooltips_new (); 
     638    gtk_tooltips_set_tip (tooltips, button, 
     639                          _("Set to default device buffering."), 
     640                          NULL); 
    584641  } 
    585 
    586  
    587 typedef struct _pvap_data pvap_data; 
    588 struct _pvap_data { 
    589   sw_view * view; 
    590   gfloat pitch; 
    591 }; 
    592  
    593 static void 
    594 pvap (pvap_data * p) 
    595 
    596   sw_sample * s = p->view->sample; 
    597  
    598   setup_dev_dsp (s); 
    599  
    600   play_view (p->view, 0, s->sounddata->nr_frames, p->pitch); 
    601  
    602   drain_dev_dsp (); 
    603  
    604   stop_playmarker (s); 
    605  
    606   WAIT_FOR_PLAYING; 
    607  
    608   reset_dev_dsp (); 
    609   close_dev_dsp (); 
    610  
    611   g_free (p); 
     642 
     643  gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry), 
     644                      pcmio_get_main_dev ()); 
     645 
     646  gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(monitor_combo)->entry), 
     647                      pcmio_get_monitor_dev ()); 
     648 
     649  gtk_adjustment_set_value (GTK_ADJUSTMENT(adj), pcmio_get_log_frags ()); 
     650 
     651  if (!GTK_WIDGET_VISIBLE(dialog)) { 
     652    gtk_widget_show(dialog); 
     653  } else { 
     654    gdk_window_raise(dialog->window); 
     655  } 
     656
     657 
     658sw_handle * 
     659device_open (int cueing, int flags) 
     660
     661  if (pref->open) 
     662    return pref->open (cueing, flags); 
     663  else 
     664    return NULL; 
    612665} 
    613666 
    614667void 
    615 play_view_all_pitch (sw_view * view, gfloat pitch) 
    616 
    617   sw_sample * s = view->sample; 
    618   pvap_data * p; 
    619  
    620   p = g_malloc (sizeof (*p)); 
    621   p->view = view; 
    622   p->pitch = pitch; 
    623  
    624   stop_playback (); 
    625  
    626   playing = s; 
    627   if (open_dev_dsp () >= 0) { 
    628     pthread_create (&player_thread, NULL, (void *) (*pvap), p); 
    629     start_playmarker (s); 
    630   } 
     668device_setup (sw_handle * handle, sw_format * format) 
     669
     670  if (pref->setup) 
     671    pref->setup (handle, format); 
     672
     673 
     674int 
     675device_wait (sw_handle * handle) 
     676
     677  if (pref->wait) 
     678    return pref->wait (handle); 
     679  else 
     680    return 0; 
     681
     682 
     683ssize_t 
     684device_read (sw_handle * handle, sw_audio_t * buf, size_t count) 
     685
     686  if (pref->read) 
     687    return pref->read (handle, buf, count); 
     688  else 
     689    return -1; 
     690
     691 
     692ssize_t 
     693device_write (sw_handle * handle, sw_audio_t * buf, size_t count, 
     694              sw_framecount_t offset) 
     695
     696#ifdef DEBUG 
     697  printf ("device_write: %d from %d\n", count, offset); 
     698#endif 
     699 
     700  if (pref->write) 
     701    return pref->write (handle, buf, count, offset); 
     702  else 
     703    return -1; 
     704
     705 
     706sw_framecount_t 
     707device_offset (sw_handle * handle) 
     708
     709  if (pref->offset) 
     710    return pref->offset (handle); 
     711  else 
     712    return -1; 
    631713} 
    632714 
    633715void 
    634 stop_playback (void) 
    635 
    636   if (!playing) return; 
    637  
    638   playing = NULL; 
    639  
    640   flush_dev_dsp (); 
    641  
    642   pthread_join (player_thread, NULL); 
     716device_reset (sw_handle * handle) 
     717
     718  if (pref->reset) 
     719    pref->reset (handle); 
    643720} 
    644721 
    645722void 
    646 sample_stop_playback (sw_sample * sample) 
    647 
    648   if (playing == sample) stop_playback(); 
    649 
     723device_flush (sw_handle * handle) 
     724
     725  if (pref->flush) 
     726    pref->flush (handle); 
     727
     728 
     729void 
     730device_drain (sw_handle * handle) 
     731
     732  if (pref->drain) 
     733    pref->drain (handle); 
     734
     735 
     736void 
     737device_close (sw_handle * handle) 
     738
     739  if (pref->close) 
     740    pref->close (handle); 
     741 
     742  handle->driver_fd = -1; 
     743
     744 
     745void 
     746init_devices (void) 
     747
     748#if defined(DRIVER_ALSA) 
     749  pref = driver_alsa; 
     750#elif defined(DRIVER_OSS) 
     751  pref = driver_oss; 
     752#elif defined(DRIVER_SOLARIS_AUDIO) 
     753  pref = driver_solaris; 
     754#endif 
     755 
     756  play_mutex = g_mutex_new (); 
     757
  • trunk/sweep/src/driver.h

    r28 r124  
    1919 */ 
    2020 
    21 #ifndef __DRIVER_OSS_H__ 
    22 #define __DRIVER_OSS_H__ 
     21#ifndef __DRIVER_H__ 
     22#define __DRIVER_H__ 
     23 
     24#include <unistd.h> 
    2325 
    2426#include "sweep_app.h" 
    2527 
    26 void 
    27 play_view_all (sw_view * view); 
     28#define PBUF_SIZE 256 
     29 
     30typedef struct _sw_handle sw_handle; 
     31typedef struct _sw_driver sw_driver; 
     32 
     33struct _sw_handle { 
     34  int driver_flags; 
     35  int driver_fd; 
     36  int driver_channels; 
     37  int driver_rate; 
     38  void * custom_data; 
     39}; 
     40 
     41struct _sw_driver { 
     42  GList * (*get_names) (void); 
     43  sw_handle * (*open) (int cueing, int flags); 
     44  void (*setup) (sw_handle * handle, sw_format * format); 
     45  int (*wait) (sw_handle * handle); 
     46  ssize_t (*read) (sw_handle * handle, sw_audio_t * buf, size_t count); 
     47  ssize_t (*write) (sw_handle * handle, sw_audio_t * buf, size_t count, 
     48                    sw_framecount_t offset); 
     49  sw_framecount_t (*offset) (sw_handle * handle); 
     50  void (*reset) (sw_handle * handle); 
     51  void (*flush) (sw_handle * handle); 
     52  void (*drain) (sw_handle * handle); 
     53  void (*close) (sw_handle * handle); 
     54}; 
    2855 
    2956void 
    30 play_view_all_loop (sw_view * view); 
     57device_config (void); 
     58 
     59sw_handle * 
     60device_open (int cueing, int flags); 
    3161 
    3262void 
    33 play_view_sel (sw_view * view); 
     63device_setup (sw_handle * handle, sw_format * format); 
     64 
     65int 
     66device_wait (sw_handle * handle); 
     67 
     68/* 
     69 * For recording, ie. reading pcm data from the device. 
     70 */ 
     71ssize_t 
     72device_read (sw_handle * handle, sw_audio_t * buf, size_t count); 
     73 
     74ssize_t 
     75device_write (sw_handle * handle, sw_audio_t * buf, size_t count, 
     76              sw_framecount_t offset); 
     77 
     78/* As far as I'm aware the method 
     79 * used to monitor latency in OSS and Solaris etc. is different to that which 
     80 * ALSA uses, and different again from JACK and PortAudio. 
     81 *  
     82 * Basically, when the device is written to, the driver is also told what the 
     83 * offset into the file is for that bit of sound. 
     84 *  
     85 * Then, when the GUI thread goes to draw the cursor, it asks the driver 
     86 * what the offset of the sound that's currently coming out of the speaker is 
     87 * and draws it there (which may be a little behind or ahead of where the 
     88 * user is scrubbing) -- hence the sound and the vision are kept in sync. 
     89 *  
     90 * However, this is all currently disabled, and going to change, as its not 
     91 * properly monitoring the latency of multiple files being played 
     92 * simultaneously; plus it may have to change with respect to ALSA and JACK and 
     93 * PortAudio. So for now, just return -1. 
     94 */ 
     95sw_framecount_t 
     96device_offset (sw_handle * handle); 
     97 
     98/* 
     99 * Reset should stop the device immediately (ie. not bother emptying the 
     100 * buffers, simply stop making any sound). The other half of what the RESET 
     101 * ioctl does in OSS is put the device back into an initialised state where 
     102 * it can accept new parameters, but sweep's not actually making use of that. 
     103 */ 
     104void 
     105device_reset (sw_handle * handle); 
    34106 
    35107void 
    36 play_view_sel_loop (sw_view * view); 
     108device_flush (sw_handle * handle); 
     109 
     110/* 
     111 * Drain empties the buffers out, ie. plays out any data that's been written 
     112 * (otherwise you often lose the last bit of sound when closing the device). 
     113 */ 
     114void 
     115device_drain (sw_handle * handle); 
    37116 
    38117void 
    39 play_view_all_pitch (sw_view * view, gfloat pitch); 
     118device_close (sw_handle * handle); 
    40119 
    41120void 
    42 stop_playback (void); 
     121init_devices (void); 
    43122 
    44123void 
    45 sample_stop_playback (sw_sample * sample)
     124stop_playback (sw_sample * s)
    46125 
    47 #endif /* __DRIVER_OSS_H__ */ 
     126#endif /* __DRIVER_H__ */ 
  • trunk/sweep/src/edit.c

    r57 r124  
    1919 */ 
    2020 
     21#ifdef HAVE_CONFIG_H 
     22#  include <config.h> 
     23#endif 
     24 
    2125#include <stdio.h> 
    2226#include <string.h> 
    2327 
     28#include <unistd.h> 
     29#include <sys/mman.h> 
     30#include <sys/types.h> 
     31#include <sys/stat.h> 
     32#include <fcntl.h> 
     33 
     34#include <sweep/sweep_i18n.h> 
    2435#include <sweep/sweep_types.h> 
    2536#include <sweep/sweep_typeconvert.h> 
     
    2738#include <sweep/sweep_sounddata.h> 
    2839#include <sweep/sweep_sample.h> 
    29  
     40#include <sweep/sweep_selection.h> 
     41 
     42#include "sweep_app.h" 
    3043#include "edit.h" 
    3144#include "format.h" 
     
    3447sw_edit_buffer * ebuf = NULL; 
    3548 
     49void * 
     50sweep_large_alloc_data (size_t len, void * data, int prot) 
     51{ 
     52  void * ptr; 
     53 
     54#if HAVE_MMAP 
     55  FILE * f; 
     56  int fd; 
     57 
     58  if ((f = tmpfile ()) == NULL) { 
     59    perror ("tmpfile failed in sweep_large_alloc_data"); 
     60    return NULL; 
     61  } 
     62 
     63  if (fwrite (data, len, 1, f) != 1) { 
     64    perror ("short fwrite in sweep_large_alloc_data"); 
     65    return NULL; 
     66  } 
     67 
     68  if (fseek (f, 0, SEEK_SET) == -1) { 
     69    perror ("fseek failed in sweep_large_alloc_data"); 
     70    return NULL; 
     71  } 
     72 
     73  if ((fd = fileno (f)) == -1) { 
     74    perror ("fileno failed in sweep_large_alloc_data"); 
     75    return NULL; 
     76  } 
     77 
     78  if ((ptr = mmap (NULL, len, prot, MAP_PRIVATE, fd, 0)) == MAP_FAILED) { 
     79    perror ("mmap failed in sweep_large_alloc_data"); 
     80    return NULL; 
     81  } 
     82#else 
     83  ptr = g_malloc (len); 
     84 
     85  memcpy (ptr, data, len); 
     86#endif 
     87 
     88  return ptr; 
     89} 
     90 
     91void * 
     92sweep_large_alloc_zero (size_t len, int prot) 
     93{ 
     94  void * ptr; 
     95 
     96#if HAVE_MMAP 
     97  int fd; 
     98 
     99  if ((fd = open ("/dev/zero", O_RDWR)) == -1) { 
     100    perror ("open failed in sweep_large_alloc_zero"); 
     101    return NULL; 
     102  } 
     103 
     104  if (lseek (fd, len+1, SEEK_SET) == (off_t)-1) { 
     105    perror ("lseek failed in sweep_large_alloc_zero"); 
     106    return NULL; 
     107  } 
     108 
     109  if (write (fd, "", 1) == -1) { 
     110    perror ("write failed in sweep_large_alloc_zero"); 
     111    return NULL; 
     112  } 
     113 
     114  if (lseek (fd, 0, SEEK_SET) == (off_t)-1) { 
     115    perror ("lseek failed in sweep_large_alloc_zero"); 
     116    return NULL; 
     117  } 
     118 
     119  if ((ptr = mmap (NULL, len, prot, MAP_PRIVATE, fd, 0)) == MAP_FAILED) { 
     120    perror ("mmap failed in sweep_large_alloc_zero"); 
     121    return NULL; 
     122  } 
     123#else 
     124  ptr = g_malloc0 (len); 
     125#endif 
     126 
     127  return ptr; 
     128} 
     129 
     130void 
     131sweep_large_free (void * ptr, size_t len) 
     132{ 
     133#if HAVE_MMAP 
     134  if (munmap (ptr, len) == -1) 
     135    perror ("munmap failed in sweep_large_free()"); 
     136#else 
     137  g_free (ptr); 
     138#endif 
     139} 
     140 
    36141static sw_edit_region * 
    37 edit_region_new (sw_format * format, sw_framecount_t start, sw_framecount_t end, gpointer data) 
     142edit_region_new (sw_format * format, sw_framecount_t start, 
     143                 sw_framecount_t end, gpointer data) 
    38144{ 
    39145  sw_edit_region * er; 
     
    46152 
    47153  len = frames_to_bytes (format, end-start); 
    48   er->data = g_malloc (len); 
    49  
    50   memcpy (er->data, data, len); 
     154  er->data = sweep_large_alloc_data (len, data, PROT_READ); 
    51155 
    52156  return er; 
     
    54158 
    55159static sw_edit_region * 
    56 edit_region_new0 (sw_format * format, sw_framecount_t start, sw_framecount_t end, gpointer data0) 
     160edit_region_new0 (sw_format * format, sw_framecount_t start, 
     161                  sw_framecount_t end, gpointer data0) 
    57162{ 
    58163  sw_framecount_t offset; 
     
    83188  eb->format = format_copy (format); 
    84189  eb->regions = NULL; 
     190  eb->refcount = 1; 
    85191 
    86192  return eb; 
     
    107213} 
    108214 
     215sw_edit_buffer * 
     216edit_buffer_ref (sw_edit_buffer * eb) 
     217{ 
     218  eb->refcount++; 
     219  return eb; 
     220} 
     221 
    109222static void 
    110223edit_buffer_clear (sw_edit_buffer * eb) 
     
    112225  GList * gl; 
    113226  sw_edit_region * er; 
     227  size_t len; 
    114228 
    115229  if (!eb) return; 
    116  
    117   g_free (eb->format); 
    118230 
    119231  for (gl = eb->regions; gl; gl = gl->next) { 
    120232    er = (sw_edit_region *)gl->data; 
    121     g_free (er->data); 
     233    if (er) { 
     234      len = frames_to_bytes (eb->format, er->end - er->start); 
     235      sweep_large_free (er->data, len); 
     236    } 
    122237  } 
    123238  g_list_free (eb->regions); 
     239 
     240  g_free (eb->format); 
    124241 
    125242  eb->format = NULL; 
    126243  eb->regions = NULL; 
     244  eb->refcount = 0; 
    127245} 
    128246 
     
    130248edit_buffer_destroy (sw_edit_buffer * eb) 
    131249{ 
     250  eb->refcount--; 
     251  if (eb->refcount > 0) return; 
     252 
    132253  edit_buffer_clear (eb); 
    133254  g_free (eb); 
     
    139260  if (!ebuf) return; 
    140261 
    141   edit_buffer_clear (ebuf); 
    142   g_free (ebuf); 
     262  edit_buffer_destroy (ebuf); 
     263 
    143264  ebuf = NULL; 
    144265} 
    145266 
    146 static gin
     267static sw_framecount_
    147268edit_buffer_length (sw_edit_buffer * eb) 
    148269{ 
    149270  GList * gl; 
    150271  sw_edit_region * er; 
    151   gint length = 0; 
     272  sw_framecount_t length = 0; 
    152273 
    153274  for (gl = eb->regions; gl; gl = gl->next) { 
     
    160281} 
    161282 
     283static sw_framecount_t 
     284edit_buffer_width (sw_edit_buffer * eb) 
     285{ 
     286  GList * gl; 
     287  sw_edit_region * er; 
     288  sw_framecount_t start, end; 
     289 
     290  if (eb == NULL) return 0; 
     291 
     292  if ((gl = eb->regions) == NULL) return 0; 
     293  er = (sw_edit_region *)gl->data; 
     294  start = er->start; 
     295 
     296  gl = g_list_last (eb->regions); 
     297  er = (sw_edit_region *)gl->data; 
     298  end = er->end; 
     299   
     300  return (end - start); 
     301} 
     302 
     303sw_framecount_t 
     304clipboard_width (void) 
     305{ 
     306  return edit_buffer_width (ebuf); 
     307} 
     308 
    162309static sw_edit_buffer * 
    163 edit_buffer_from_sounddata (sw_sounddata * sounddata
     310edit_buffer_from_sounddata_sels (sw_sounddata * sounddata, GList * sels
    164311{ 
    165312  sw_edit_buffer * eb; 
     
    170317  eb = edit_buffer_new (sounddata->format); 
    171318 
    172   for (gl = sounddata->sels; gl; gl = gl->next) { 
     319  for (gl = sels; gl; gl = gl->next) { 
    173320    sel = (sw_sel *)gl->data; 
    174321 
     
    187334} 
    188335 
     336static sw_edit_buffer * 
     337edit_buffer_from_sounddata (sw_sounddata * sounddata) 
     338{ 
     339  return edit_buffer_from_sounddata_sels (sounddata, sounddata->sels); 
     340} 
     341 
    189342sw_edit_buffer * 
    190343edit_buffer_from_sample (sw_sample * sample) 
    191344{ 
    192345  return edit_buffer_from_sounddata (sample->sounddata); 
     346} 
     347 
     348static GList * 
     349sels_from_edit_buffer_offset (sw_edit_buffer * eb, sw_framecount_t offset) 
     350{ 
     351  GList * gl, * sels = NULL; 
     352  sw_edit_region * er; 
     353  sw_framecount_t start; 
     354 
     355  gl = eb->regions; 
     356  if (!gl) return NULL; 
     357 
     358  er = (sw_edit_region *)gl->data; 
     359  start = er->start; 
     360 
     361  for (gl = eb->regions; gl; gl = gl->next) { 
     362    er = (sw_edit_region *)gl->data; 
     363 
     364    sels = sels_add_selection_1 (sels, er->start - start + offset, 
     365                                 er->end - start + offset); 
     366  } 
     367 
     368  return sels; 
    193369} 
    194370 
     
    207383  if (!gl) return NULL; 
    208384 
    209   start = ((sw_edit_region *)gl->data)->start; 
     385  er = (sw_edit_region *)gl->data; 
     386  start = er->start; 
    210387   
    211388  for (; gl->next; gl = gl->next); 
     
    213390  length = er->end - start; 
    214391 
    215   s = sample_new_empty (NULL, "Untitled", 
     392  s = sample_new_empty (NULL, 
    216393                        eb->format->channels, 
    217394                        eb->format->rate, 
     
    227404    memcpy ((gpointer)(s->sounddata->data + offset), er->data, len); 
    228405 
     406    sounddata_add_selection_1 (s->sounddata, er->start - start, 
     407                               er->end - start); 
     408 
    229409#ifdef DEBUG 
    230410    printf("Adding sample region [%ld - %ld]\n", er->start, er->end); 
     
    235415} 
    236416 
    237 /* returns new sounddata */ 
    238 sw_sounddata * 
    239 splice_out_sel (sw_sounddata * sounddata) 
    240 
     417static void 
     418head_dec_if_within (sw_head * head, sw_framecount_t lower, 
     419                    sw_framecount_t upper, sw_framecount_t amount) 
     420
     421  if (head == NULL) return; 
     422 
     423  g_mutex_lock (head->head_mutex); 
     424 
     425  if (head->stop_offset > lower && head->stop_offset < upper) 
     426    head->stop_offset -= amount; 
     427 
     428  if (head->offset > lower && head->offset < upper) 
     429    head->offset -= amount; 
     430 
     431  g_mutex_unlock (head->head_mutex); 
     432
     433 
     434static void 
     435head_inc_if_gt (sw_head * head, sw_framecount_t lower, sw_framecount_t amount) 
     436
     437  if (head == NULL) return; 
     438 
     439  g_mutex_lock (head->head_mutex); 
     440 
     441  if (head->stop_offset > lower) 
     442    head->stop_offset += amount; 
     443 
     444  if (head->offset > lower) 
     445    head->offset += amount; 
     446 
     447  g_mutex_unlock (head->head_mutex); 
     448
     449 
     450static void 
     451head_set_if_within (sw_head * head, sw_framecount_t lower, 
     452                    sw_framecount_t upper, sw_framecount_t value) 
     453
     454  if (head == NULL) return; 
     455 
     456  g_mutex_lock (head->head_mutex); 
     457 
     458  if (head->stop_offset >= lower && head->stop_offset <= upper) 
     459    head->stop_offset = value; 
     460   
     461  if (head->offset >= lower && head->offset <= upper) 
     462    head->offset = value; 
     463 
     464  g_mutex_unlock (head->head_mutex); 
     465
     466 
     467/* modifies sounddata */ 
     468sw_sample * 
     469splice_out_sel (sw_sample * sample) 
     470
     471  sw_sounddata * sounddata = sample->sounddata; 
    241472  sw_format * f = sounddata->format; 
    242473  gint length; 
    243474  GList * gl; 
    244475  sw_sel * osel, * sel; 
    245   sw_sounddata * out; 
     476  /*sw_sounddata * out;*/ 
    246477  gpointer d; 
    247   sw_framecount_t offset, len; 
     478  sw_framecount_t offset, len, sel_length = 0; 
     479  sw_framecount_t move_length, run_length; 
    248480 
    249481  if (!sounddata->sels) { 
    250482    printf ("Nothing to splice out.\n"); 
    251     return sounddata
     483    return sample
    252484  } 
    253485 
    254486  length = sounddata->nr_frames - sounddata_selection_nr_frames (sounddata); 
     487  run_length = 0; 
    255488 
    256489#ifdef DEBUG 
     
    258491#endif 
    259492 
    260   out = sounddata_new_empty (f->channels, f->rate, length); 
    261  
    262   d = out->data; 
     493  d = sounddata->data; 
     494 
     495  /* XXX: Force splice outs to be atomic wrt. to cancellation. For 
     496   * multi-region selections it would be nicer to build the redo data 
     497   * incrementally, but wtf. 
     498   * Each region's memmove needs to be treated as atomic anyway so the 
     499   * gain isn't so much. 
     500   */ 
     501  g_mutex_lock (sample->ops_mutex); 
    263502 
    264503  gl = sounddata->sels; 
    265504  sel = osel = (sw_sel *)gl->data; 
    266505  if (osel->sel_start > 0) { 
    267     len = frames_to_bytes (f, osel->sel_start); 
    268     memcpy (d, sounddata->data, len); 
     506 
     507    if (sample->user_offset >= sel->sel_start && 
     508        sample->user_offset <= sel->sel_end) { 
     509      sample->user_offset = sel->sel_start - sel_length;; 
     510    } 
     511 
     512    head_set_if_within (sample->play_head, sel->sel_start, sel->sel_end, 
     513                        sel->sel_start - sel_length); 
     514 
     515    head_set_if_within (sample->rec_head, sel->sel_start, sel->sel_end, 
     516                        sel->sel_start - sel_length); 
     517 
     518    sel_length = osel->sel_end - osel->sel_start; 
     519 
     520    move_length = osel->sel_start; 
     521 
     522    len = frames_to_bytes (f, move_length); 
    269523    d += len; 
    270   } 
    271   gl = gl->next; 
    272  
    273   for (; gl; gl = gl->next) { 
     524 
     525    run_length += move_length; 
     526    sample_set_progress_percent (sample, run_length / (length/100)); 
     527  } 
     528  for (gl = gl->next; gl; gl = gl->next) { 
    274529    sel = (sw_sel *)gl->data; 
    275530 
     531    /* Move user offset */ 
     532    if (sample->user_offset > osel->sel_end && 
     533        sample->user_offset < sel->sel_start) { 
     534      sample->user_offset -= sel_length; 
     535    } 
     536 
     537    if (sample->user_offset >= sel->sel_start && 
     538        sample->user_offset <= sel->sel_end) { 
     539      sample->user_offset = sel->sel_start - sel_length;; 
     540    } 
     541 
     542    head_dec_if_within (sample->play_head, osel->sel_end, sel->sel_start, 
     543                        sel_length); 
     544    head_set_if_within (sample->play_head, sel->sel_start, sel->sel_end, 
     545                        sel->sel_start - sel_length); 
     546 
     547    head_dec_if_within (sample->rec_head, osel->sel_end, sel->sel_start, 
     548                        sel_length); 
     549    head_set_if_within (sample->rec_head, sel->sel_start, sel->sel_end, 
     550                        sel->sel_start - sel_length); 
     551 
     552    sel_length += sel->sel_end - sel->sel_start; 
     553 
    276554    offset = frames_to_bytes (f, osel->sel_end); 
    277     len = frames_to_bytes (f, sel->sel_start - osel->sel_end); 
    278     memcpy (d, (gpointer)(sounddata->data + offset), len); 
     555 
     556    move_length = sel->sel_start - osel->sel_end; 
     557    len = frames_to_bytes (f, move_length); 
     558    g_memmove (d, (gpointer)(sounddata->data + offset), len); 
    279559    d += len; 
    280560 
     561    run_length += move_length; 
     562    sample_set_progress_percent (sample, run_length / (length/100)); 
     563 
    281564    osel = sel; 
    282565  } 
     566 
     567  /* Move offsets occuring after last sel */ 
     568  if (sample->user_offset > sel->sel_end) { 
     569    sample->user_offset -= sel_length; 
     570  } 
     571 
     572  head_dec_if_within (sample->play_head, sel->sel_end, FRAMECOUNT_MAX, 
     573                      sel_length); 
     574 
     575  head_dec_if_within (sample->rec_head, sel->sel_end, FRAMECOUNT_MAX, 
     576                      sel_length); 
    283577 
    284578  if (sel->sel_end != sounddata->nr_frames) { 
    285579    offset = frames_to_bytes (f, sel->sel_end); 
    286 #ifdef DEBUG 
    287     printf("Calculated offset %ld [=== %ld]\n", offset, sel->sel_end); 
    288 #endif 
    289  
    290     len = frames_to_bytes (f, sounddata->nr_frames - sel->sel_end); 
    291     memcpy (d, (gpointer)(sounddata->data + offset), len); 
    292   } 
    293  
    294   return out; 
     580 
     581    move_length = sounddata->nr_frames - sel->sel_end; 
     582 
     583    len = frames_to_bytes (f, move_length); 
     584    g_memmove (d, (gpointer)(sounddata->data + offset), len); 
     585 
     586    run_length += move_length; 
     587    sample_set_progress_percent (sample, run_length / (length/100)); 
     588  } 
     589 
     590  d = g_realloc (sounddata->data, frames_to_bytes(f, length)); 
     591  sounddata->data = d; 
     592  sounddata->nr_frames = length; 
     593 
     594  sounddata_clear_selection (sounddata); 
     595 
     596  sample_set_progress_percent (sample, 100); 
     597 
     598  g_mutex_unlock (sample->ops_mutex); 
     599 
     600  return sample; 
    295601} 
    296602 
     
    316622 
    317623/* returns new sounddata */ 
    318 sw_sounddata * 
    319 splice_in_eb (sw_sounddata * sounddata, sw_edit_buffer * eb) 
    320 
     624static sw_sample * 
     625splice_in_eb_data (sw_sample * sample, sw_edit_buffer * eb) 
     626
     627  sw_sounddata * sounddata = sample->sounddata; 
    321628  sw_format * f = sounddata->format; 
    322629  gint length; 
    323630  GList * gl; 
    324631  sw_edit_region * er; 
    325   sw_framecount_t prev_end = 0; 
    326   sw_sounddata * out
     632  sw_framecount_t prev_start = 0; 
     633  sw_framecount_t er_width
    327634  gpointer di, d; 
    328635  sw_framecount_t len; 
    329636 
    330637  if (!eb) { 
     638    return sample; 
     639  } 
     640 
     641  g_mutex_lock (sample->ops_mutex); 
     642 
     643  /* in reverse ... decrementing d, di; just like paste at only crunchy */ 
     644 
     645  length = sounddata->nr_frames + edit_buffer_length (eb); 
     646 
     647  d = g_realloc (sounddata->data, frames_to_bytes (f, length)); 
     648  sounddata->data = d; 
     649 
     650  /* set di to point to the end of the original data */ 
     651  di = d + frames_to_bytes (f, sounddata->nr_frames); 
     652 
     653  /* set d to point to end of newly realloc'd buffer */ 
     654  d += frames_to_bytes (f, length); 
     655 
     656  prev_start = length; 
     657 
     658  gl = g_list_last (eb->regions); 
     659  er = (sw_edit_region *)gl->data; 
     660  if (er->start >= sounddata->nr_frames) { 
     661    len = frames_to_bytes (f, er->end - er->start); 
     662    d -= len; 
     663    memcpy (d, er->data, len); 
     664    prev_start = er->start; 
     665    gl = gl->prev; 
     666  } 
     667 
     668  for (; gl; gl = gl->prev) { 
     669    er = (sw_edit_region *)gl->data; 
     670 
     671    /* Move the sample data in */ 
     672    len = frames_to_bytes (f, prev_start - er->end); 
     673    di -= len; 
     674    d -= len; 
     675    memmove (d, di, len); 
     676 
     677    /* Copy edit_region data in */ 
     678    len = frames_to_bytes (f, er->end - er->start); 
     679    d -= len; 
     680    memcpy (d, er->data, len); 
     681    prev_start = er->start; 
     682  } 
     683 
     684  /* The head of the sounddata remains intact */ 
     685 
     686  /* Move offset markers */ 
     687 
     688  for (gl = eb->regions; gl; gl = gl->next) { 
     689    er = (sw_edit_region *)gl->data; 
     690 
     691    er_width = er->end - er->start; 
     692 
     693    if (sample->user_offset > er->end) 
     694      sample->user_offset += er_width; 
     695 
     696    head_inc_if_gt (sample->play_head, er->end, er_width); 
     697    head_inc_if_gt (sample->rec_head, er->end, er_width); 
     698  } 
     699 
     700  sounddata->nr_frames = length; 
     701 
     702  g_mutex_unlock (sample->ops_mutex); 
     703 
     704  return sample; 
     705} 
     706 
     707/* returns new sounddata */ 
     708sw_sample * 
     709splice_in_eb (sw_sample * sample, sw_edit_buffer * eb) 
     710{ 
     711  splice_in_eb_data (sample, eb); 
     712  sounddata_set_sel_from_eb (sample->sounddata, eb); 
     713 
     714  return sample; 
     715} 
     716 
     717/* modifies sounddata */ 
     718static sw_sounddata * 
     719crop_in_eb_data (sw_sounddata * sounddata, sw_edit_buffer * eb) 
     720{ 
     721  sw_format * f = sounddata->format; 
     722  sw_framecount_t length, byte_length, o_byte_length; 
     723  GList * gl; 
     724  sw_edit_region * er1, * er2, * er; 
     725  sw_framecount_t len1 = 0, len2 = 0; 
     726  sw_framecount_t byte_len1, byte_len2; 
     727  gpointer d; 
     728 
     729  if (!eb) { 
    331730    return sounddata; 
    332731  } 
    333732 
    334   length = sounddata->nr_frames + edit_buffer_length (eb); 
    335  
    336   di = sounddata->data; 
    337  
    338   out = sounddata_new_empty (f->channels, f->rate, length); 
    339  
    340   d = out->data; 
     733  o_byte_length = frames_to_bytes (f, sounddata->nr_frames); 
     734 
     735  gl = eb->regions; 
     736  er1 = (sw_edit_region *)gl->data; 
     737  if (er1->start == 0) { 
     738    len1 = er1->end; 
     739  } 
     740  byte_len1 = frames_to_bytes (f, len1); 
     741 
     742  gl = g_list_last (eb->regions); 
     743  er2 = (sw_edit_region *)gl->data; 
     744  if (er2->end > sounddata->nr_frames) { 
     745    len2 = er2->end - er2->start; 
     746  } 
     747  byte_len2 = frames_to_bytes (f, len2); 
     748 
     749  if (len1 + len2 > 0) { 
     750    length = sounddata->nr_frames + len1 + len2; 
     751    byte_length = frames_to_bytes (f, length); 
     752 
     753    d = g_realloc (sounddata->data, byte_length); 
     754    sounddata->data = d; 
     755    sounddata->nr_frames = length; 
     756 
     757    if (len1 > 0) { 
     758      /* Move middle region in place */ 
     759      memmove ((gpointer)(d + byte_len1), d, o_byte_length); 
     760       
     761      /* Copy (prepend) first region */ 
     762      memcpy (d, er1->data, byte_len1); 
     763    } else { 
     764      /* Overwrite first region in place */ 
     765      gl = eb->regions; 
     766      er = (sw_edit_region *)gl->data; 
     767      memcpy ((gpointer)(d + frames_to_bytes (f, er->start)), 
     768              er->data, frames_to_bytes (f, er->end - er->start)); 
     769    } 
     770     
     771    /* Overwrite with in-between regions */ 
     772    gl = eb->regions; 
     773    for (gl = gl->next; gl && gl->next; gl = gl->next) { 
     774      er = (sw_edit_region *)gl->data; 
     775      memcpy ((gpointer)(d + frames_to_bytes (f, er->start)), 
     776              er->data, frames_to_bytes (f, er->end - er->start)); 
     777    } 
     778     
     779    if (len2 > 0) { 
     780      /* Copy (append) last_region */ 
     781      memcpy ((gpointer)(d + o_byte_length + byte_len1), er2->data, byte_len2); 
     782    } else if (gl) { 
     783      /* Overwrite last region in place */ 
     784      er = (sw_edit_region *)gl->data; 
     785      memcpy ((gpointer)(d + frames_to_bytes (f, er->start)), 
     786              er->data, frames_to_bytes (f, er->end - er->start)); 
     787    } 
     788 
     789  } else { 
     790    d = sounddata->data; 
     791    for (gl = eb->regions; gl; gl = gl->next) { 
     792      er = (sw_edit_region *)gl->data; 
     793      memcpy ((gpointer)(d + frames_to_bytes (f, er->start)), 
     794              er->data, frames_to_bytes (f, er->end - er->start)); 
     795    } 
     796  } 
     797 
     798  return sounddata; 
     799
     800 
     801sw_sample * 
     802crop_in (sw_sample * sample, sw_edit_buffer * eb) 
     803
     804  sw_sounddata * sounddata; 
     805  GList * gl; 
     806  sw_edit_region * er; 
     807  sw_framecount_t delta; 
     808 
     809  crop_in_eb_data (sample->sounddata, eb); 
     810  sounddata = sample->sounddata; 
    341811 
    342812  gl = eb->regions; 
    343813  er = (sw_edit_region *)gl->data; 
    344   if (er->start <= 0) { 
    345     len = frames_to_bytes (f, er->end - er->start); 
    346     memcpy (d, er->data, len); 
    347     d += len; 
    348     prev_end = er->end; 
    349     gl = gl->next; 
    350   } 
    351  
    352   for (; gl; gl = gl->next) { 
    353     er = (sw_edit_region *)gl->data; 
    354  
    355     /* Copy sample data in */ 
    356     len = frames_to_bytes (f, er->start - prev_end); 
    357     memcpy (d, di, len); 
    358     di += len; 
    359     d += len; 
    360  
    361     /* Copy edit_region data in */ 
    362     len = frames_to_bytes (f, er->end - er->start); 
    363     memcpy (d, er->data, len); 
    364     d += len; 
    365  
    366     prev_end = er->end; 
    367   } 
    368  
    369   /* Copy remaining sample data in, if any */ 
    370   if (prev_end < length) { 
    371     len = frames_to_bytes (f, length - prev_end); 
    372     memcpy (d, di, len); 
    373   } 
    374   
    375   sounddata_set_sel_from_eb (out, eb); 
    376   
    377   return out; 
     814  if (er->start == 0) { 
     815    delta = er->end; 
     816 
     817    g_mutex_lock (sounddata->sels_mutex); 
     818    sounddata_selection_translate (sounddata, delta); 
     819    g_mutex_unlock (sounddata->sels_mutex); 
     820 
     821    g_mutex_lock (sample->play_mutex); 
     822    sample->user_offset += delta; 
     823    g_mutex_unlock (sample->play_mutex); 
     824 
     825    g_mutex_lock (sample->play_head->head_mutex); 
     826    sample->play_head->offset += delta; 
     827    sample->play_head->stop_offset += delta; 
     828    g_mutex_unlock (sample->play_head->head_mutex); 
     829 
     830    if (sample->rec_head) { 
     831      g_mutex_lock (sample->rec_head->head_mutex); 
     832      sample->rec_head->offset += delta; 
     833      sample->rec_head->stop_offset += delta; 
     834      g_mutex_unlock (sample->rec_head->head_mutex); 
     835    } 
     836  } 
     837 
     838  return sample; 
    378839} 
    379840 
    380841/* Modifies sounddata */ 
    381 static sw_sounddata * 
    382 edit_clear_sel (sw_sounddata * sounddata) 
    383 
     842static void 
     843edit_clear_sel (sw_sample * sample) 
     844
     845  sw_sounddata * sounddata = sample->sounddata; 
    384846  sw_format * f = sounddata->format; 
    385847  GList * gl; 
    386848  sw_sel * sel; 
    387849  sw_framecount_t offset, len; 
    388  
    389   for (gl = sounddata->sels; gl; gl = gl->next) { 
     850  sw_framecount_t sel_total, run_total; 
     851 
     852  gboolean active = TRUE; 
     853 
     854  sel_total = sounddata_selection_nr_frames (sounddata) / 100; 
     855  if (sel_total == 0) sel_total = 1; 
     856  run_total = 0; 
     857 
     858  for (gl = sounddata->sels; active && gl; gl = gl->next) { 
     859    g_mutex_lock (sample->ops_mutex); 
     860 
     861    if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 
     862      active = FALSE; 
     863    } else { 
     864      sel = (sw_sel *)gl->data; 
     865       
     866      offset = frames_to_bytes (f, sel->sel_start); 
     867      len = frames_to_bytes (f, sel->sel_end - sel->sel_start); 
     868       
     869      memset ((gpointer)(sounddata->data + offset), 0, (size_t)len); 
     870       
     871      run_total += sel->sel_end - sel->sel_start; 
     872      sample_set_progress_percent (sample, run_total / sel_total); 
     873    } 
     874 
     875    g_mutex_unlock (sample->ops_mutex); 
     876  } 
     877
     878 
     879/* modifies sounddata */ 
     880sw_sample * 
     881crop_out (sw_sample * sample) 
     882
     883  sw_sounddata * sounddata = sample->sounddata; 
     884  sw_format * f = sounddata->format; 
     885  sw_framecount_t length; 
     886  GList * gl; 
     887  sw_sel * sel1, * sel2, * osel, * sel; 
     888  /*sw_sounddata * out;*/ 
     889  gpointer d; 
     890  sw_framecount_t offset, len; 
     891  sw_framecount_t byte_length; 
     892 
     893  if (!sounddata->sels) { 
     894    return sample; 
     895  } 
     896 
     897 
     898#ifdef DEBUG 
     899  printf("Splice out: remaining length %d\n", length); 
     900#endif 
     901 
     902 
     903  /* XXX: Force crops to be atomic wrt. to cancellation. For 
     904   * multi-region selections it would be nicer to build the redo data 
     905   * incrementally, but wtf. 
     906   * Each region's memmove needs to be treated as atomic anyway so the 
     907   * gain isn't so much. 
     908   */ 
     909  g_mutex_lock (sample->ops_mutex); 
     910 
     911  gl = sounddata->sels; 
     912  sel1 = (sw_sel *)gl->data; 
     913 
     914  gl = g_list_last (sounddata->sels); 
     915  sel2 = (sw_sel *)gl->data; 
     916 
     917  if (sel1->sel_start <= 0 && sel2->sel_end >= sounddata->nr_frames) { 
     918    d = sounddata->data; 
     919    goto zero_out; 
     920  } 
     921 
     922  sample_set_progress_percent (sample, 13); 
     923 
     924  /* ok, we have something to crop */ 
     925 
     926  length = sounddata_selection_width (sounddata); 
     927  byte_length = frames_to_bytes (f, length); 
     928  d = sounddata->data; 
     929 
     930  if (sel1->sel_start > 0) { 
     931    /* Need to move */ 
     932    offset = frames_to_bytes (f, sel1->sel_start); 
     933    g_memmove (d, (gpointer)(d + offset), byte_length); 
     934  } 
     935 
     936  sample_set_progress_percent (sample, 37); 
     937 
     938  /* Need to shorten */ 
     939  d = g_realloc (sounddata->data, byte_length); 
     940  sounddata->data = d; 
     941  sounddata->nr_frames = length; 
     942 
     943  /* Fix offsets */ 
     944  sample->user_offset -= sel1->sel_start; 
     945  sample->user_offset = CLAMP(sample->user_offset, 0, length); 
     946 
     947  g_mutex_lock (sample->play_head->head_mutex); 
     948 
     949  sample->play_head->offset -= sel1->sel_start; 
     950  sample->play_head->offset = 
     951    CLAMP(sample->play_head->offset, 0, length); 
     952 
     953  sample->play_head->stop_offset -= sel1->sel_start; 
     954  sample->play_head->stop_offset = 
     955    CLAMP(sample->play_head->stop_offset, 0, length); 
     956 
     957  g_mutex_unlock (sample->play_head->head_mutex); 
     958 
     959  if (sample->rec_head) { 
     960    g_mutex_lock (sample->rec_head->head_mutex); 
     961 
     962    sample->rec_head->offset -= sel1->sel_start; 
     963    sample->rec_head->offset = 
     964      CLAMP(sample->rec_head->offset, 0, length); 
     965 
     966    sample->rec_head->stop_offset -= sel1->sel_start; 
     967    sample->rec_head->stop_offset = 
     968      CLAMP(sample->rec_head->stop_offset, 0, length); 
     969 
     970    g_mutex_unlock (sample->rec_head->head_mutex); 
     971  } 
     972 
     973  /* Fix selection */ 
     974  sounddata_selection_translate (sounddata, -(sel1->sel_start)); 
     975 
     976 zero_out: 
     977  /* Zero out data between selections */ 
     978  gl = sounddata->sels; 
     979  osel = (sw_sel *)gl->data; 
     980 
     981  for (gl = gl->next; gl; gl = gl->next) { 
    390982    sel = (sw_sel *)gl->data; 
    391983 
    392     offset = frames_to_bytes (f, sel->sel_start); 
    393     len = frames_to_bytes (f, sel->sel_end - sel->sel_start); 
    394  
    395     memset ((gpointer)(sounddata->data + offset), 0, (size_t)len); 
    396   } 
    397  
    398   return sounddata; 
    399 
    400  
    401 /* New sample */ 
    402 static sw_sounddata * 
    403 paste_at (sw_sounddata * sounddata, sw_edit_buffer * eb) 
    404 
     984    offset = frames_to_bytes (f, osel->sel_end); 
     985    len = frames_to_bytes (f, sel->sel_start) - offset; 
     986    memset ((gpointer)(d + offset), 0, len); 
     987 
     988    osel = sel; 
     989  } 
     990 
     991  sample_set_progress_percent (sample, 100); 
     992 
     993  g_mutex_unlock (sample->ops_mutex); 
     994 
     995  return sample; 
     996
     997 
     998/* modifies sounddata */ 
     999static sw_sample * 
     1000paste_insert (sw_sample * sample, sw_edit_buffer * eb, 
     1001              sw_framecount_t paste_offset) 
     1002
     1003  sw_sounddata * sounddata = sample->sounddata; 
    4051004  sw_format * f = sounddata->format; 
    406   sw_framecount_t paste_point = 0; 
    407   sw_framecount_t paste_offset = 0, len; 
    408   sw_framecount_t length, paste_length; 
     1005  sw_framecount_t paste_delta = 0, len; 
     1006  sw_framecount_t length, paste_length, sel_length = 0; 
    4091007  GList * gl; 
    4101008  sw_edit_region * er; 
    4111009  gpointer d; 
    412   sw_sounddata * out; 
    413  
    414   if (sounddata->sels) { 
    415     paste_point = ((sw_sel *)(sounddata->sels)->data)->sel_start; 
    416     paste_offset = frames_to_bytes (f, paste_point); 
    417   } 
     1010 
     1011  paste_delta = frames_to_bytes (f, paste_offset); 
    4181012 
    4191013  paste_length = edit_buffer_length (eb); 
    420   length = sounddata->nr_frames + paste_length; 
    421  
    422   out = sounddata_new_empty (f->channels, f->rate, length); 
    423  
    424   d = out->data; 
    425  
    426   if (paste_point > 0) { 
    427     len = paste_offset; 
    428     memcpy (d, sounddata->data, len); 
    429     d += len; 
    430   } 
    431  
    432   for (gl = eb->regions; gl; gl = gl->next) { 
     1014  length = MAX(sounddata->nr_frames, paste_offset) + paste_length; 
     1015 
     1016  d = g_realloc (sounddata->data, frames_to_bytes (f, length)); 
     1017  sounddata->data = d; 
     1018 
     1019  d = (gpointer)(sounddata->data + frames_to_bytes(f, length)); 
     1020 
     1021  /* Copy in the tail end of the sounddata */ 
     1022  if (paste_offset < sounddata->nr_frames) { 
     1023    len = frames_to_bytes (f, sounddata->nr_frames) - paste_delta; 
     1024    d -= len; 
     1025    memmove (d, (gpointer)(sounddata->data + paste_delta), len); 
     1026  } 
     1027 
     1028  /* Copy in the contents of the edit buffer */ 
     1029  for (gl = g_list_last(eb->regions); gl; gl = gl->prev) { 
    4331030    er = (sw_edit_region *)gl->data; 
    4341031 
    4351032    len = frames_to_bytes (f, er->end - er->start); 
     1033    sel_length += (er->end - er->start); 
     1034 
     1035    d -= len; 
    4361036    memcpy (d, er->data, len); 
    437     d += len; 
    438   } 
    439  
    440   if (paste_point < sounddata->nr_frames) { 
    441     len = frames_to_bytes (f, sounddata->nr_frames) - paste_offset; 
    442     memcpy (d, (gpointer)(sounddata->data + paste_offset), len); 
    443   } 
    444  
    445   /* 
    446   sounddata_copyin_selection (sounddata, out); 
    447   sounddata_selection_translate (out, paste_point); 
    448   */ 
    449  
    450   sounddata_set_selection_1 (out, paste_point, paste_point + paste_length); 
    451  
    452   return out; 
     1037  } 
     1038 
     1039  /* If paste point is beyond the previous sounddata length, 
     1040     add some silence */ 
     1041  if (paste_offset > sounddata->nr_frames) { 
     1042    len = paste_delta - frames_to_bytes (f, sounddata->nr_frames); 
     1043    d -= len; 
     1044    memset (d, 0, len); 
     1045  } 
     1046 
     1047  /* The head of the sounddata remains intact */ 
     1048 
     1049  /* Select the copied in portion of the sounddata */ 
     1050  sounddata_set_selection_1 (sounddata, paste_offset, 
     1051                             paste_offset + paste_length); 
     1052 
     1053  /* Move offset markers */ 
     1054 
     1055  if (sample->user_offset > paste_offset) 
     1056    sample->user_offset += sel_length; 
     1057 
     1058  if (sample->play_head->offset > paste_offset) 
     1059    sample->play_head->offset += sel_length; 
     1060  if (sample->play_head->stop_offset > paste_offset) 
     1061    sample->play_head->stop_offset += sel_length; 
     1062 
     1063  if (sample->rec_head) { 
     1064    if (sample->rec_head->offset > paste_offset) 
     1065      sample->rec_head->offset += sel_length; 
     1066    if (sample->rec_head->stop_offset > paste_offset) 
     1067      sample->rec_head->stop_offset += sel_length; 
     1068  } 
     1069 
     1070  sounddata->nr_frames = length; 
     1071 
     1072  return sample; 
    4531073} 
    4541074 
     
    4801100} 
    4811101 
     1102/* Modifies sample */ 
     1103static sw_sample * 
     1104paste_mix (sw_sample * sample, sw_edit_buffer * eb, 
     1105           sw_framecount_t paste_offset, gdouble src_gain, gdouble dest_gain) 
     1106{ 
     1107  sw_format * f = sample->sounddata->format; 
     1108  sw_framecount_t length, eb_delta; 
     1109  GList * gl; 
     1110  sw_edit_region * er; 
     1111  sw_audio_t * d, * e; 
     1112  sw_framecount_t offset, remaining, n, i; 
     1113  sw_framecount_t run_total, eb_total; 
     1114  gint percent; 
     1115 
     1116  gboolean active = TRUE; 
     1117 
     1118#ifdef DEBUG 
     1119  g_print ("paste_mix: src_gain %f, dest_gain %f\n", src_gain, dest_gain); 
     1120#endif 
     1121 
     1122  if (eb == NULL || eb->regions == NULL) return sample; 
     1123 
     1124  length = sample->sounddata->nr_frames; 
     1125 
     1126  run_total = 0; 
     1127  eb_total = edit_buffer_length (eb); 
     1128 
     1129  eb_delta = ((sw_edit_region *)eb->regions->data)->start; 
     1130 
     1131  for (gl = eb->regions; active && gl; gl = gl->next) { 
     1132    er = (sw_edit_region *)gl->data; 
     1133 
     1134    if (er->start > length) break; 
     1135     
     1136    d = sample->sounddata->data + 
     1137      frames_to_bytes (f, er->start - eb_delta + paste_offset); 
     1138    e = er->data; 
     1139     
     1140    offset = 0; 
     1141    remaining = MIN(er->end, length) - er->start; 
     1142 
     1143    while (active && remaining > 0) { 
     1144      g_mutex_lock (sample->ops_mutex); 
     1145       
     1146      if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 
     1147        active = FALSE; 
     1148      } else { 
     1149         
     1150        n = MIN(remaining, 1024); 
     1151         
     1152        for (i = 0; i < n * f->channels; i++) { 
     1153          d[i] = d[i] * dest_gain + e[i] * src_gain; 
     1154        } 
     1155         
     1156        remaining -= n; 
     1157        offset += n; 
     1158         
     1159        d += n * f->channels; 
     1160        e += n * f->channels; 
     1161         
     1162        run_total += n; 
     1163        percent = run_total / (eb_total/100); 
     1164        sample_set_progress_percent (sample, percent); 
     1165         
     1166#ifdef DEBUG 
     1167        g_print ("completed %d / %d frames, %d%%\n", run_total, eb_total, 
     1168                 percent); 
     1169#endif 
     1170      } 
     1171       
     1172      g_mutex_unlock (sample->ops_mutex); 
     1173    } 
     1174     
     1175  } 
     1176   
     1177  return sample; 
     1178} 
     1179 
     1180/* Modifies sample */ 
     1181static sw_sample * 
     1182paste_xfade (sw_sample * sample, sw_edit_buffer * eb, 
     1183             sw_framecount_t paste_offset, 
     1184             gdouble src_gain_start, gdouble src_gain_end, 
     1185             gdouble dest_gain_start, gdouble dest_gain_end) 
     1186{ 
     1187  sw_format * f = sample->sounddata->format; 
     1188  sw_framecount_t length, eb_delta; 
     1189  GList * gl; 
     1190  sw_edit_region * er; 
     1191  sw_audio_t * d, * e; 
     1192  sw_framecount_t offset, remaining, n, i, j, k; 
     1193  sw_framecount_t run_total, eb_total; 
     1194  gint percent; 
     1195 
     1196  gdouble src_gain, dest_gain; 
     1197  gdouble src_gain_delta, dest_gain_delta; 
     1198 
     1199  gboolean active = TRUE; 
     1200 
     1201#ifdef DEBUG 
     1202  g_print ("paste_xfade: src: %f -> %f\tdest: %f -> %f\n", 
     1203           src_gain_start, src_gain_end, dest_gain_start, dest_gain_end); 
     1204#endif 
     1205 
     1206  if (eb == NULL || eb->regions == NULL) return sample; 
     1207 
     1208  length = sample->sounddata->nr_frames; 
     1209 
     1210  run_total = 0; 
     1211  eb_total = edit_buffer_length (eb); 
     1212 
     1213  eb_delta = ((sw_edit_region *)eb->regions->data)->start; 
     1214 
     1215  src_gain = src_gain_start; 
     1216  dest_gain = dest_gain_start; 
     1217 
     1218  src_gain_delta = (src_gain_end - src_gain_start) / (gdouble)eb_total; 
     1219  dest_gain_delta = (dest_gain_end - dest_gain_start) / (gdouble)eb_total; 
     1220 
     1221  for (gl = eb->regions; active && gl; gl = gl->next) { 
     1222    er = (sw_edit_region *)gl->data; 
     1223 
     1224    if (er->start > length) break; 
     1225     
     1226    d = sample->sounddata->data + 
     1227      frames_to_bytes (f, er->start - eb_delta + paste_offset); 
     1228    e = er->data; 
     1229     
     1230    offset = 0; 
     1231    remaining = MIN(er->end, length) - er->start; 
     1232 
     1233    while (active && remaining > 0) { 
     1234      g_mutex_lock (sample->ops_mutex); 
     1235       
     1236      if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 
     1237        active = FALSE; 
     1238      } else { 
     1239         
     1240        n = MIN(remaining, 1024); 
     1241 
     1242        k = 0; 
     1243        for (i = 0; i < n; i++) { 
     1244          for (j = 0; j < f->channels; j++) { 
     1245            d[k] = d[k] * dest_gain + e[k] * src_gain; 
     1246            k++; 
     1247          } 
     1248          src_gain += src_gain_delta; 
     1249          dest_gain += dest_gain_delta; 
     1250        } 
     1251         
     1252        remaining -= n; 
     1253        offset += n; 
     1254         
     1255        d += n * f->channels; 
     1256        e += n * f->channels; 
     1257         
     1258        run_total += n; 
     1259        percent = run_total / (eb_total/100); 
     1260        sample_set_progress_percent (sample, percent); 
     1261         
     1262#ifdef DEBUG 
     1263        g_print ("completed %d / %d frames, %d%%\n", run_total, eb_total, 
     1264                 percent); 
     1265#endif 
     1266      } 
     1267       
     1268      g_mutex_unlock (sample->ops_mutex); 
     1269    } 
     1270     
     1271  } 
     1272   
     1273  return sample; 
     1274} 
     1275 
     1276static void 
     1277do_copy_thread (sw_op_instance * inst) 
     1278{ 
     1279  sw_sample * sample = inst->sample; 
     1280 
     1281  if (sample == NULL || sample->sounddata == NULL || 
     1282      sample->sounddata->sels == NULL) goto noop; 
     1283 
     1284  ebuf_clear (); 
     1285 
     1286  ebuf = edit_buffer_from_sample (sample); 
     1287 
     1288  return; 
     1289 
     1290 noop: 
     1291  sample_set_tmp_message (sample, _("No selection to copy")); 
     1292} 
    4821293 
    4831294/* No undo for copy -- is input only */ 
     1295static sw_operation copy_op = { 
     1296  SWEEP_EDIT_MODE_FILTER, 
     1297  (SweepCallback)do_copy_thread, 
     1298  (SweepFunction)NULL, 
     1299  (SweepCallback)NULL, 
     1300  (SweepFunction)NULL, 
     1301  (SweepCallback)NULL, 
     1302  (SweepFunction)NULL, 
     1303}; 
     1304 
    4841305void 
    4851306do_copy (sw_sample * sample) 
    4861307{ 
     1308  schedule_operation (sample, _("Copy"), &copy_op, NULL); 
     1309} 
     1310 
     1311 
     1312static void 
     1313do_cut_thread (sw_op_instance * inst) 
     1314{ 
     1315  sw_sample * sample = inst->sample; 
     1316  sw_edit_buffer * eb; 
     1317 
     1318  if (sample == NULL || sample->sounddata == NULL || 
     1319      sample->sounddata->sels == NULL) goto noop; 
     1320 
     1321  /*  inst = sw_op_instance_new ("Cut", &cut_op);*/ 
     1322 
     1323  eb = edit_buffer_from_sample (sample); 
     1324 
     1325  inst->redo_data = inst->undo_data = splice_data_new (eb, NULL); 
     1326  set_active_op (sample, inst); 
     1327 
    4871328  ebuf_clear (); 
    4881329 
    489   ebuf = edit_buffer_from_sample (sample); 
     1330  /*ebuf = edit_buffer_copy (eb);*/ 
     1331  ebuf = edit_buffer_ref (eb); 
     1332 
     1333  splice_out_sel (sample); 
     1334 
     1335  if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) { 
     1336    register_operation (sample, inst); 
     1337  } 
     1338 
     1339  return; 
     1340 
     1341 noop: 
     1342  sample_set_tmp_message (sample, _("No selection to cut")); 
    4901343} 
    4911344 
    4921345static sw_operation cut_op = { 
    493   /*  OP_FILTER,*/ 
    494   /*  {(SweepFilter *)do_cut},*/ 
     1346  SWEEP_EDIT_MODE_ALLOC, 
     1347  (SweepCallback)do_cut_thread, 
     1348  (SweepFunction)NULL, 
    4951349  (SweepCallback)undo_by_splice_in, 
    4961350  (SweepFunction)splice_data_destroy, 
     
    4991353}; 
    5001354 
    501 sw_op_instance * 
     1355void 
    5021356do_cut (sw_sample * sample) 
    5031357{ 
    504   sw_sounddata * out; 
    505   sw_op_instance * inst; 
    506   sw_edit_buffer * eb; 
    507  
    508   inst = sw_op_instance_new ("Cut", &cut_op); 
    509   eb = edit_buffer_from_sample (sample); 
    510  
    511   ebuf_clear (); 
    512   ebuf = edit_buffer_copy (eb); 
    513  
    514   out = splice_out_sel (sample->sounddata); 
    515  
    516   inst->redo_data = inst->undo_data = 
    517     splice_data_new (eb); 
    518  
    519   sounddata_destroy (sample->sounddata); 
    520   sample->sounddata = out; 
    521  
    522   sample_refresh_views (sample); 
    523  
    524   register_operation (sample, inst); 
    525  
    526   return inst; 
     1358  schedule_operation (sample, _("Cut"), &cut_op, NULL); 
     1359
     1360 
     1361static void 
     1362do_clear_thread (sw_op_instance * inst) 
     1363
     1364  sw_sample * sample = inst->sample; 
     1365  sw_edit_buffer * old_eb; 
     1366  paste_over_data * p; 
     1367 
     1368  if (sample == NULL || sample->sounddata == NULL || 
     1369      sample->sounddata->sels == NULL) goto noop; 
     1370 
     1371  old_eb = edit_buffer_from_sample (sample); 
     1372 
     1373  p = paste_over_data_new (old_eb, old_eb); 
     1374  inst->redo_data = inst->undo_data = p; 
     1375  set_active_op (sample, inst); 
     1376 
     1377  edit_clear_sel (sample); 
     1378 
     1379  if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) { 
     1380    p->new_eb = edit_buffer_from_sample (sample); 
     1381 
     1382    register_operation (sample, inst); 
     1383  } 
     1384 
     1385  return; 
     1386 
     1387 noop: 
     1388  sample_set_tmp_message (sample, _("No selection to clear")); 
    5271389} 
    5281390 
    5291391static sw_operation clear_op = { 
     1392  SWEEP_EDIT_MODE_FILTER, 
     1393  (SweepCallback)do_clear_thread, 
     1394  (SweepFunction)NULL, 
    5301395  (SweepCallback)undo_by_paste_over, 
    5311396  (SweepFunction)paste_over_data_destroy, 
     
    5341399}; 
    5351400 
    536 sw_op_instance * 
     1401void 
    5371402do_clear (sw_sample * sample) 
    5381403{ 
    539   sw_op_instance * inst; 
    540   sw_edit_buffer * old_eb, * new_eb; 
    541  
    542   inst = sw_op_instance_new ("Clear", &clear_op); 
    543   old_eb = edit_buffer_from_sample (sample); 
    544  
    545   edit_clear_sel (sample->sounddata); 
    546   new_eb = edit_buffer_from_sample (sample); 
    547  
    548   inst->redo_data = inst->undo_data = 
    549     paste_over_data_new (old_eb, new_eb); 
    550  
    551   sample_refresh_views (sample); 
    552  
    553   register_operation (sample, inst); 
    554  
    555   return inst; 
     1404  schedule_operation (sample, _("Clear"), &clear_op, NULL); 
     1405
     1406 
     1407static void 
     1408do_delete_thread (sw_op_instance * inst) 
     1409
     1410  sw_sample * sample = inst->sample; 
     1411  sw_edit_buffer * eb; 
     1412 
     1413  if (sample == NULL || sample->sounddata == NULL || 
     1414      sample->sounddata->sels == NULL) goto noop; 
     1415 
     1416  eb = edit_buffer_from_sample (sample); 
     1417 
     1418  inst->redo_data = inst->undo_data = splice_data_new (eb, NULL); 
     1419  set_active_op (sample, inst); 
     1420 
     1421  splice_out_sel (sample); 
     1422 
     1423  if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) { 
     1424    register_operation (sample, inst); 
     1425  } 
     1426 
     1427  return; 
     1428 
     1429 noop: 
     1430  sample_set_tmp_message (sample, _("No selection to delete")); 
    5561431} 
    5571432 
    5581433static sw_operation delete_op = { 
     1434  SWEEP_EDIT_MODE_ALLOC, 
     1435  (SweepCallback)do_delete_thread, 
     1436  (SweepFunction)NULL, 
    5591437  (SweepCallback)undo_by_splice_in, 
    5601438  (SweepFunction)splice_data_destroy, 
     
    5631441}; 
    5641442 
    565 sw_op_instance * 
     1443 
     1444void 
    5661445do_delete (sw_sample * sample) 
    5671446{ 
    568   sw_sounddata * out; 
    569   sw_op_instance * inst; 
     1447  schedule_operation (sample, _("Delete"), &delete_op, NULL); 
     1448
     1449 
     1450static void 
     1451do_crop_thread (sw_op_instance * inst) 
     1452
     1453  sw_sample * sample = inst->sample; 
     1454  GList * sels; 
    5701455  sw_edit_buffer * eb; 
    5711456 
    572   inst = sw_op_instance_new ("Delete", &delete_op); 
    573   eb = edit_buffer_from_sample (sample); 
    574  
    575   out = splice_out_sel (sample->sounddata); 
    576  
    577   inst->redo_data = inst->undo_data = 
    578     splice_data_new (eb); 
    579  
    580   sample->sounddata = out; 
    581   /* delete old */ 
    582  
    583   sample_refresh_views (sample); 
    584  
    585   register_operation (sample, inst); 
    586  
    587   return inst; 
    588 
    589  
     1457  if (sample == NULL || sample->sounddata == NULL || 
     1458      sample->sounddata->sels == NULL) goto noop; 
     1459 
     1460  sels = sels_copy (sample->sounddata->sels); 
     1461  sels = sels_invert (sels, sample->sounddata->nr_frames); 
     1462 
     1463  if (sels == NULL) goto noop; 
     1464 
     1465  eb = edit_buffer_from_sounddata_sels (sample->sounddata, sels); 
     1466 
     1467  /* If there's nothing to crop out, do nothing and register nothing */ 
     1468  if (eb == NULL || eb->regions == NULL) goto noop; 
     1469 
     1470  inst->redo_data = inst->undo_data = splice_data_new (eb, NULL); 
     1471  set_active_op (sample, inst); 
     1472 
     1473  crop_out (sample); 
     1474 
     1475  if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) { 
     1476    register_operation (sample, inst); 
     1477  } 
     1478 
     1479  return; 
     1480 
     1481 noop: 
     1482  sample_set_tmp_message (sample, _("Nothing to crop out")); 
     1483
     1484 
     1485static sw_operation crop_op = { 
     1486  SWEEP_EDIT_MODE_ALLOC, 
     1487  (SweepCallback)do_crop_thread, 
     1488  (SweepFunction)NULL, 
     1489  (SweepCallback)undo_by_crop_in, 
     1490  (SweepFunction)splice_data_destroy, 
     1491  (SweepCallback)redo_by_crop_out, 
     1492  (SweepFunction)splice_data_destroy 
     1493}; 
     1494 
     1495void 
     1496do_crop (sw_sample * sample) 
     1497
     1498  schedule_operation (sample, _("Crop"), &crop_op, NULL); 
     1499
     1500 
     1501#if 0 
    5901502static sw_operation paste_in_op = { 
     1503  SWEEP_EDIT_MODE_ALLOC, 
     1504  (SweepCallback)do_paste_in, 
     1505  (SweepFunction)NULL, 
    5911506  (SweepCallback)undo_by_splice_out, 
    5921507  (SweepFunction)splice_data_destroy, 
     
    5951510}; 
    5961511 
     1512/* XXX: why is this **out ?? */ 
    5971513sw_op_instance * 
    5981514do_paste_in (sw_sample * in, sw_sample ** out) 
     
    6011517  sw_edit_buffer * eb; 
    6021518 
    603   inst = sw_op_instance_new ("Paste in", &paste_in_op); 
    604   eb = edit_buffer_copy (ebuf); 
     1519  if (ebuf == NULL) return NULL; 
     1520 
     1521  inst = sw_op_instance_new (in, "Paste in", &paste_in_op); 
     1522  /*eb = edit_buffer_copy (ebuf);*/ 
     1523  eb = edit_buffer_ref (ebuf); 
    6051524 
    6061525  (*out)->sounddata = splice_in_eb (in->sounddata, ebuf); 
    6071526 
    6081527  inst->redo_data = inst->undo_data = 
    609     splice_data_new (eb); 
     1528    splice_data_new (eb, NULL); 
    6101529 
    6111530  sample_refresh_views (*out); 
     
    6131532  return inst; 
    6141533} 
    615  
    616 static sw_operation paste_at_op = { 
     1534#endif 
     1535 
     1536static void 
     1537do_paste_insert_thread (sw_op_instance * inst) 
     1538
     1539  sw_sample * sample = inst->sample; 
     1540  sw_sounddata * out; 
     1541  sw_edit_buffer * eb1, *eb2; 
     1542 
     1543  if (ebuf == NULL) goto noop; 
     1544 
     1545  if (!format_equal (ebuf->format, sample->sounddata->format)) 
     1546    goto incompatible; 
     1547 
     1548  /*eb1 = edit_buffer_copy (ebuf);*/ 
     1549  eb1 = edit_buffer_ref (ebuf); 
     1550 
     1551  inst->undo_data = splice_data_new (eb1, sample->sounddata->sels); 
     1552  inst->redo_data = NULL; 
     1553  set_active_op (sample, inst); 
     1554 
     1555  paste_insert (sample, ebuf, sample->user_offset); 
     1556 
     1557  if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) { 
     1558    out = sample->sounddata; 
     1559    eb2 = edit_buffer_from_sounddata (out); 
     1560    inst->redo_data = splice_data_new (eb2, NULL); 
     1561 
     1562    register_operation (sample, inst); 
     1563  } 
     1564 
     1565  return; 
     1566 
     1567 noop: 
     1568  sample_set_tmp_message (sample, _("Clipboard empty")); 
     1569  return; 
     1570 
     1571 incompatible: 
     1572  sample_set_tmp_message (sample, _("Clipboard data has incompatible format")); 
     1573  return; 
     1574
     1575 
     1576static sw_operation paste_insert_op = { 
     1577  SWEEP_EDIT_MODE_ALLOC, 
     1578  (SweepCallback)do_paste_insert_thread, 
     1579  (SweepFunction)NULL, 
    6171580  (SweepCallback)undo_by_splice_out, 
    6181581  (SweepFunction)splice_data_destroy, 
     
    6211584}; 
    6221585 
    623 sw_op_instance * 
    624 do_paste_at (sw_sample * sample) 
    625 
     1586 
     1587void 
     1588do_paste_insert (sw_sample * sample) 
     1589
     1590  schedule_operation (sample, _("Paste insert"), &paste_insert_op, NULL); 
     1591
     1592 
     1593typedef struct { 
     1594  gdouble src_gain; 
     1595  gdouble dest_gain; 
     1596} paste_mix_op_data; 
     1597 
     1598static void 
     1599do_paste_mix_thread (sw_op_instance * inst) 
     1600
     1601  sw_sample * sample = inst->sample; 
     1602  paste_mix_op_data * pd = (paste_mix_op_data *)inst->do_data; 
    6261603  sw_sounddata * out; 
    627   sw_op_instance * inst
     1604  GList * old_sels, * sels
    6281605  sw_edit_buffer * eb1, *eb2; 
    629  
    630   inst = sw_op_instance_new ("Paste", &paste_at_op); 
    631   eb1 = edit_buffer_copy (ebuf); 
    632   inst->undo_data = splice_data_new (eb1); 
    633  
    634   out = paste_at (sample->sounddata, ebuf); 
    635   eb2 = edit_buffer_from_sounddata (out); 
    636   inst->redo_data = splice_data_new (eb2); 
    637  
    638   sample->sounddata = out; 
    639   /* delete old sounddata */ 
    640  
    641   sample_refresh_views (sample); 
    642  
    643   register_operation (sample, inst); 
    644  
    645   return inst; 
    646 
    647  
    648  
     1606  gdouble src_gain, dest_gain; 
     1607 
     1608  src_gain = pd->src_gain; 
     1609  dest_gain = pd->dest_gain; 
     1610  g_free (pd); 
     1611 
     1612  if (ebuf == NULL) goto noop; 
     1613 
     1614  if (!format_equal (ebuf->format, sample->sounddata->format)) 
     1615    goto incompatible; 
     1616 
     1617  old_sels = sels_copy (sample->sounddata->sels); 
     1618  sels = sels_from_edit_buffer_offset (ebuf, sample->user_offset); 
     1619  sample_set_selection (sample, sels); 
     1620 
     1621  eb1 = edit_buffer_from_sounddata (sample->sounddata); 
     1622 
     1623  inst->undo_data = splice_data_new (eb1, old_sels); 
     1624  inst->redo_data = NULL; 
     1625  set_active_op (sample, inst); 
     1626 
     1627  paste_mix (sample, ebuf, sample->user_offset, src_gain, dest_gain); 
     1628 
     1629  if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) { 
     1630    out = sample->sounddata; 
     1631    eb2 = edit_buffer_from_sounddata (out); 
     1632    inst->redo_data = splice_data_new (eb2, sels); 
     1633 
     1634    register_operation (sample, inst); 
     1635  } else { 
     1636    sample_set_selection (sample, old_sels); 
     1637  } 
     1638 
     1639  return; 
     1640 
     1641 noop: 
     1642  sample_set_tmp_message (sample, _("Clipboard empty")); 
     1643  return; 
     1644 
     1645 incompatible: 
     1646  sample_set_tmp_message (sample, _("Clipboard data has incompatible format")); 
     1647  return; 
     1648
     1649 
     1650static sw_operation paste_mix_op = { 
     1651  SWEEP_EDIT_MODE_FILTER, 
     1652  (SweepCallback)do_paste_mix_thread, 
     1653  (SweepFunction)NULL, 
     1654  (SweepCallback)undo_by_splice_over, 
     1655  (SweepFunction)splice_data_destroy, 
     1656  (SweepCallback)redo_by_splice_over, 
     1657  (SweepFunction)splice_data_destroy 
     1658}; 
     1659 
     1660void 
     1661do_paste_mix (sw_sample * sample, gdouble src_gain, gdouble dest_gain) 
     1662
     1663  paste_mix_op_data * pd; 
     1664 
     1665  pd = g_malloc (sizeof(paste_mix_op_data)); 
     1666  pd->src_gain = src_gain; 
     1667  pd->dest_gain = dest_gain; 
     1668 
     1669  schedule_operation (sample, _("Paste mix"), &paste_mix_op, pd); 
     1670
     1671 
     1672typedef struct { 
     1673  gdouble src_gain_start; 
     1674  gdouble src_gain_end; 
     1675  gdouble dest_gain_start; 
     1676  gdouble dest_gain_end; 
     1677} paste_xfade_op_data; 
     1678 
     1679static void 
     1680do_paste_xfade_thread (sw_op_instance * inst) 
     1681
     1682  sw_sample * sample = inst->sample; 
     1683  paste_xfade_op_data * pd = (paste_xfade_op_data *)inst->do_data; 
     1684  sw_sounddata * out; 
     1685  GList * old_sels, * sels; 
     1686  sw_edit_buffer * eb1, *eb2; 
     1687  gdouble src_gain_start, src_gain_end, dest_gain_start, dest_gain_end; 
     1688 
     1689  src_gain_start = pd->src_gain_start; 
     1690  src_gain_end = pd->src_gain_end; 
     1691  dest_gain_start = pd->dest_gain_start; 
     1692  dest_gain_end = pd->dest_gain_end; 
     1693  g_free (pd); 
     1694 
     1695  if (ebuf == NULL) goto noop; 
     1696 
     1697  if (!format_equal (ebuf->format, sample->sounddata->format)) 
     1698    goto incompatible; 
     1699 
     1700  old_sels = sels_copy (sample->sounddata->sels); 
     1701  sels = sels_from_edit_buffer_offset (ebuf, sample->user_offset); 
     1702  sample_set_selection (sample, sels); 
     1703 
     1704  eb1 = edit_buffer_from_sounddata (sample->sounddata); 
     1705 
     1706  inst->undo_data = splice_data_new (eb1, old_sels); 
     1707  inst->redo_data = NULL; 
     1708  set_active_op (sample, inst); 
     1709 
     1710  paste_xfade (sample, ebuf, sample->user_offset, src_gain_start, 
     1711               src_gain_end, dest_gain_start, dest_gain_end); 
     1712 
     1713  if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) { 
     1714    out = sample->sounddata; 
     1715    eb2 = edit_buffer_from_sounddata (out); 
     1716    inst->redo_data = splice_data_new (eb2, sels); 
     1717 
     1718    register_operation (sample, inst); 
     1719  } else { 
     1720    sample_set_selection (sample, old_sels); 
     1721  } 
     1722 
     1723  return; 
     1724 
     1725 noop: 
     1726  sample_set_tmp_message (sample, _("Clipboard empty")); 
     1727  return; 
     1728 
     1729 incompatible: 
     1730  sample_set_tmp_message (sample, _("Clipboard data has incompatible format")); 
     1731  return; 
     1732
     1733 
     1734static sw_operation paste_xfade_op = { 
     1735  SWEEP_EDIT_MODE_FILTER, 
     1736  (SweepCallback)do_paste_xfade_thread, 
     1737  (SweepFunction)NULL, 
     1738  (SweepCallback)undo_by_splice_over, 
     1739  (SweepFunction)splice_data_destroy, 
     1740  (SweepCallback)redo_by_splice_over, 
     1741  (SweepFunction)splice_data_destroy 
     1742}; 
     1743 
     1744void 
     1745do_paste_xfade (sw_sample * sample, gdouble src_gain_start, 
     1746                gdouble src_gain_end, gdouble dest_gain_start, 
     1747                gdouble dest_gain_end) 
     1748
     1749  paste_xfade_op_data * pd; 
     1750 
     1751  pd = g_malloc (sizeof(paste_xfade_op_data)); 
     1752  pd->src_gain_start = src_gain_start; 
     1753  pd->src_gain_end = src_gain_end; 
     1754  pd->dest_gain_start = dest_gain_start; 
     1755  pd->dest_gain_end = dest_gain_end; 
     1756 
     1757  schedule_operation (sample, _("Paste xfade"), &paste_xfade_op, pd); 
     1758
     1759 
     1760#if 0 
    6491761static sw_operation paste_over_op = { 
     1762  SWEEP_EDIT_MODE_FILTER, 
     1763  (SweepCallback)NULL, 
     1764  (SweepFunction)NULL, 
    6501765  (SweepCallback)undo_by_paste_over, 
    6511766  (SweepFunction)paste_over_data_destroy, 
     
    6601775  sw_edit_buffer * old_eb, * new_eb; 
    6611776 
    662   inst = sw_op_instance_new ("Paste over", &paste_over_op); 
     1777  if (ebuf == NULL) return NULL; 
     1778 
     1779  inst = sw_op_instance_new (in, "Paste over", &paste_over_op); 
    6631780  old_eb = edit_buffer_from_sample (in); 
    6641781 
     
    6731790  return inst; 
    6741791} 
    675  
    676 void 
    677 do_paste_as_new (sw_sample * in, sw_sample ** out) 
    678 
    679   *out = sample_from_edit_buffer (ebuf); 
    680 
     1792#endif 
     1793 
     1794sw_sample * 
     1795do_paste_as_new (void) 
     1796
     1797  if (ebuf == NULL) return NULL; 
     1798 
     1799  return sample_from_edit_buffer (ebuf); 
     1800
     1801 
  • trunk/sweep/src/edit.h

    r57 r124  
    2424#include <sweep/sweep_types.h> 
    2525 
     26void * 
     27sweep_large_alloc_zero (size_t len, int prot); 
     28 
     29void * 
     30sweep_large_alloc_data (size_t len, void * data, int prot); 
     31 
     32 
     33sw_framecount_t 
     34clipboard_width (void); 
     35 
     36sw_edit_buffer * 
     37edit_buffer_ref (sw_edit_buffer * eb); 
     38 
    2639sw_edit_buffer * 
    2740edit_buffer_from_sample (sw_sample * sample); 
     
    3043edit_buffer_destroy (sw_edit_buffer * eb); 
    3144 
    32 sw_sounddata
    33 splice_out_sel (sw_sounddata * sounddata); 
     45sw_sample
     46splice_out_sel (sw_sample * sample); 
    3447 
    35 sw_sounddata * 
    36 splice_in_eb (sw_sounddata * sounddata, sw_edit_buffer * eb); 
     48sw_sample * 
     49splice_in_eb (sw_sample * sample, sw_edit_buffer * eb); 
     50 
     51sw_sample * 
     52crop_out (sw_sample * sample); 
     53 
     54sw_sample * 
     55crop_in (sw_sample * sample, sw_edit_buffer * eb); 
    3756 
    3857sw_sample * 
     
    4261do_copy (sw_sample * sample); 
    4362 
    44 sw_op_instance * 
     63void 
    4564do_cut (sw_sample * sample); 
    4665 
    47 sw_op_instance * 
     66void 
    4867do_clear (sw_sample * sample); 
    4968 
    50 sw_op_instance * 
     69void 
    5170do_delete (sw_sample * sample); 
     71 
     72void 
     73do_crop (sw_sample * sample); 
    5274 
    5375sw_op_instance * 
    5476do_paste_in (sw_sample * in, sw_sample ** out); 
    5577 
    56 sw_op_instance * 
    57 do_paste_at (sw_sample * sample); 
     78void 
     79do_paste_insert (sw_sample * sample); 
     80 
     81void 
     82do_paste_mix (sw_sample * sample, gdouble src_gain, gdouble dest_gain); 
     83 
     84void 
     85do_paste_xfade (sw_sample * sample, gdouble src_gain_start, 
     86                gdouble src_gain_end, gdouble dest_gain_start, 
     87                gdouble dest_gain_end); 
    5888 
    5989sw_op_instance * 
    6090do_paste_over (sw_sample * in, sw_sample ** out); 
    6191 
     92#if 0 
    6293void 
    6394do_paste_as_new (sw_sample * in, sw_sample ** out); 
    6495 
     96#else 
     97 
     98sw_sample * 
     99do_paste_as_new (void); 
     100 
     101#endif 
     102 
    65103#endif /* __EDIT_H__ */ 
  • trunk/sweep/src/file_dialogs.c

    r121 r124  
    1919 */ 
    2020 
     21#ifdef HAVE_CONFIG_H 
     22#  include <config.h> 
     23#endif 
     24 
    2125#include <stdio.h> 
    2226#include <string.h> 
     27#include <sys/types.h> 
     28#include <sys/stat.h> 
    2329#include <unistd.h> 
     30#include <errno.h> 
     31 
     32#include <gdk/gdkkeysyms.h> 
    2433#include <gtk/gtk.h> 
     34 
     35#include <sndfile.h> 
    2536 
    2637#include <sweep/sweep_types.h> 
    2738#include <sweep/sweep_sample.h> 
    28  
    29 #include "file_ops.h" 
     39#include <sweep/sweep_i18n.h> 
     40 
     41#include "sweep_app.h" 
     42#include "file_sndfile.h" 
    3043#include "sample.h" 
    3144#include "sample-display.h" 
    32  
    33 static gchar* load_current_file = NULL; /* last visited dir for loading */ 
    34 static gchar* save_current_file = NULL; /* last visited dir for saving */ 
     45#include "question_dialogs.h" 
     46#include "preferences.h" 
     47 
     48#define LAST_LOAD_KEY "Last_Load" 
     49#define LAST_SAVE_KEY "Last_Save" 
     50 
     51#ifdef HAVE_OGGVORBIS 
     52extern sw_sample * vorbis_sample_reload (sw_sample * sample); 
     53extern sw_sample * vorbis_sample_load (char * pathname); 
     54extern int vorbis_save_options_dialog (sw_sample * sample, char * pathname); 
     55#endif 
     56 
     57#ifdef HAVE_SPEEX 
     58extern sw_sample * speex_sample_reload (sw_sample * sample); 
     59extern sw_sample * speex_sample_load (char * pathname); 
     60extern int speex_save_options_dialog (sw_sample * sample, char * pathname); 
     61#endif 
     62 
     63#ifdef HAVE_MAD 
     64extern sw_sample * mad_sample_reload (sw_sample * sample); 
     65extern sw_sample * mad_sample_load (char * pathname); 
     66#endif 
     67 
     68void 
     69mp3_unsupported_dialog (void) 
     70
     71  info_dialog_new (_("MP3 export unsupported"), NULL, 
     72                   _("Export to MP3 format cannot legally be supported " 
     73                     "in free software\n" 
     74                     "due to patent licensing restrictions.\n\n" 
     75                     "Please use Ogg Vorbis format instead, which\n" 
     76                     "provides better quality and is free.")); 
     77
     78 
     79/* This source code can compile against both version 0 and version 1 
     80** of libsndfile. 
     81*/ 
     82 
     83typedef struct { 
     84  sw_file_format_t file_format; 
     85  gchar * name; 
     86  gchar * exts; /* comma separated extensions */ 
     87} sw_file_format_desc; 
     88 
     89void 
     90file_guess_method (sw_sample * sample, char * pathname); 
     91 
     92#if ! (defined (SNDFILE_1)) 
     93 
     94static sw_file_format_desc file_formats [] = { 
     95  { 
     96    SWEEP_FILE_FORMAT_RAW, 
     97    N_("Raw PCM (headerless)"), 
     98    "raw", 
     99  }, 
     100  { 
     101    SWEEP_FILE_FORMAT_AIFF, 
     102    "Apple/SGI AIFF,AIFF-C", 
     103    "aiff,aifc" 
     104  }, 
     105  { 
     106    SWEEP_FILE_FORMAT_AU, 
     107    "Sun/NeXT AU", 
     108    "au", 
     109  }, 
     110  { 
     111    SWEEP_FILE_FORMAT_SVX, 
     112    "Amiga IFF,SVX8,SVX16", 
     113    "svx", 
     114  }, 
     115  { 
     116    SWEEP_FILE_FORMAT_PAF, 
     117    "Ensoniq PARIS", 
     118    "paf", 
     119  }, 
     120  { 
     121    SWEEP_FILE_FORMAT_IRCAM, 
     122    "IRCAM/Berkeley/CARL SF", 
     123    "sf", 
     124  }, 
     125  { 
     126    SWEEP_FILE_FORMAT_VOC, 
     127    "Creative Labs VOC", 
     128    "voc", 
     129  }, 
     130  { 
     131    SWEEP_FILE_FORMAT_WAV, 
     132    "Microsoft WAV", 
     133    "wav,riff", 
     134  }, 
     135}; 
     136 
     137#endif 
     138 
     139static gboolean 
     140sweep_dir_exists (char * pathname) 
     141
     142  struct stat statbuf; 
     143 
     144#undef BUF_LEN 
     145#define BUF_LEN 512 
     146  char buf[BUF_LEN]; 
     147 
     148  gchar * dirname; 
     149 
     150  dirname = g_dirname (pathname); 
     151 
     152  if (dirname && strcmp (dirname, "") && stat (dirname, &statbuf) == -1) { 
     153    switch (errno) { 
     154    case ENOENT: 
     155      snprintf (buf, BUF_LEN, _("%s does not exist."), dirname); 
     156      info_dialog_new (_("Directory does not exist"), NULL, buf); 
     157      g_free (dirname); 
     158      return FALSE; 
     159      break; 
     160    default: 
     161      break; 
     162    } 
     163  } 
     164 
     165  /* dirname is either NULL, "" or an existing directory */ 
     166 
     167  return TRUE; 
     168
     169 
     170static gboolean 
     171file_guess_mp3 (char * pathname) 
     172
     173  gchar * ext; 
     174 
     175  ext = strrchr (pathname, '.'); 
     176 
     177  if (ext != NULL) { 
     178    ext++; 
     179    if (!g_strncasecmp (ext, "mp3", 4)) return TRUE; 
     180    if (!g_strncasecmp (ext, "mp2", 4)) return TRUE; 
     181  } 
     182 
     183  return FALSE; 
     184
     185 
     186sw_sample * 
     187sample_reload (sw_sample * sample) 
     188
     189  sw_sample * new_sample = NULL; 
     190 
     191#ifdef HAVE_OGGVORBIS 
     192  new_sample = vorbis_sample_reload (sample); 
     193#endif 
     194 
     195  if (new_sample == NULL) 
     196    new_sample = sndfile_sample_reload (sample, FALSE); 
     197 
     198#ifdef HAVE_SPEEX 
     199  if (new_sample == NULL) 
     200    new_sample = speex_sample_reload (sample); 
     201#endif 
     202 
     203#ifdef HAVE_MAD 
     204  if (new_sample == NULL && file_guess_mp3 (sample->pathname)) 
     205    new_sample = mad_sample_reload (sample); 
     206#endif 
     207 
     208  if (new_sample == NULL) 
     209    new_sample = sndfile_sample_reload (sample, TRUE); 
     210 
     211  return new_sample; 
     212
     213 
     214static sw_sample * 
     215try_sample_load (char * pathname) 
     216
     217  sw_sample * sample = NULL; 
     218 
     219#ifdef HAVE_OGGVORBIS 
     220  sample = vorbis_sample_load (pathname); 
     221#endif 
     222 
     223  if (sample == NULL) 
     224    sample = sndfile_sample_load (pathname, FALSE); 
     225 
     226#ifdef HAVE_SPEEX 
     227  if (sample == NULL) 
     228    sample = speex_sample_load (pathname); 
     229#endif 
     230 
     231#ifdef HAVE_MAD 
     232  if (sample == NULL && file_guess_mp3 (pathname)) 
     233    sample = mad_sample_load (pathname); 
     234#endif 
     235 
     236  if (sample == NULL) 
     237    sample = sndfile_sample_load (pathname, TRUE);   
     238   
     239  return sample; 
     240
     241 
     242sw_sample * 
     243sample_load (char * pathname) 
     244
     245  if (sweep_dir_exists (pathname)) { 
     246    if (strcmp (pathname, "-") == 0) { 
     247      try_sample_load (pathname); 
     248    } else if (access(pathname, R_OK) == -1) { 
     249      switch (errno) { 
     250      case ENOENT: 
     251        create_sample_new_dialog_defaults (pathname); 
     252        /*sweep_perror (errno, pathname);*/ 
     253        break; 
     254      default: 
     255        sweep_perror (errno, _("Unable to read\n%s"), pathname); 
     256        break; 
     257      } 
     258    } else { 
     259      prefs_set_string (LAST_LOAD_KEY, pathname); 
     260       
     261      return try_sample_load (pathname); 
     262    } 
     263  } 
     264 
     265  return NULL; 
     266
     267 
     268static void 
     269sample_load_destroy_cb (GtkWidget * widget, gpointer data) 
     270
     271  sample_bank_remove (NULL); 
     272
    35273 
    36274static void 
    37275sample_load_ok_cb(GtkWidget * widget, gpointer data) 
    38276{ 
    39   sw_sample * s; 
    40   sw_view * v; 
    41277  gchar *dir; 
    42278 
    43279  dir = gtk_file_selection_get_filename(GTK_FILE_SELECTION(data)); 
    44   g_free(load_current_file); 
    45   load_current_file = g_strdup(dir); 
    46  
    47   s = sample_load(dir); 
    48   if(s) { 
    49       v = view_new_all (s, 1.0); 
    50       sample_add_view (s, v); 
    51       sample_bank_add(s); 
    52   } 
     280 
     281  sample_load(dir); 
    53282 
    54283  gtk_widget_destroy(GTK_WIDGET(data)); 
     
    62291 
    63292void 
    64 sample_load_cb(GtkWidget * wiget, gpointer data) 
     293sample_load_cb(GtkWidget * widget, gpointer data) 
    65294{ 
    66295  GtkWidget *filesel; 
    67  
    68   filesel = gtk_file_selection_new("Load Sample"); 
     296  char * load_current_file; 
     297  gint win_width, win_height; 
     298  GtkAccelGroup * accel_group; 
     299 
     300  win_width = gdk_screen_width () / 2; 
     301  win_height = gdk_screen_height () / 2; 
     302 
     303  filesel = gtk_file_selection_new(_("Sweep: Load file")); 
     304  gtk_window_set_position (GTK_WINDOW (filesel), GTK_WIN_POS_CENTER); 
     305  gtk_widget_set_usize (filesel, win_width, win_height); 
     306 
     307  accel_group = gtk_accel_group_new (); 
     308  gtk_window_add_accel_group (GTK_WINDOW(filesel), accel_group); 
     309 
     310  gtk_signal_connect (GTK_OBJECT(filesel), "destroy", 
     311                      GTK_SIGNAL_FUNC(sample_load_destroy_cb), filesel); 
     312 
     313  gtk_accel_group_add (accel_group, GDK_w, GDK_CONTROL_MASK, GDK_NONE, 
     314                       GTK_OBJECT(filesel), "destroy"); 
     315 
     316  load_current_file = prefs_get_string (LAST_LOAD_KEY); 
     317 
    69318  if(load_current_file) { 
    70319      gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel),  
    71320                                      load_current_file); 
     321      free (load_current_file); 
    72322  } 
    73323 
     
    81331} 
    82332 
     333gboolean 
     334sample_mtime_changed (sw_sample * sample) 
     335{ 
     336  struct stat statbuf; 
     337 
     338  /* a last_mtime of 0 indicates that the file is not from disk */ 
     339  if (sample->last_mtime == 0) return FALSE; 
     340 
     341  if (stat (sample->pathname, &statbuf) == -1) { 
     342    sweep_perror (errno, sample->pathname); 
     343    return FALSE; 
     344  } 
     345 
     346  return (sample->last_mtime != statbuf.st_mtime); 
     347} 
     348 
     349void 
     350sample_revert_ok_cb (GtkWidget * widget, gpointer data) 
     351{ 
     352  sw_sample * sample = (sw_sample *)data; 
     353 
     354  sample_reload (sample); 
     355} 
     356 
    83357void 
    84358sample_revert_cb (GtkWidget * widget, gpointer data) 
    85359{ 
    86   SampleDisplay * s = SAMPLE_DISPLAY(data); 
    87   sw_sample * sample, * orig_sample; 
    88   char pathname [SW_DIR_LEN]; 
    89  
    90   sample = s->view->sample; 
    91   snprintf (pathname, SW_DIR_LEN, 
    92             "%s/%s", sample->directory, 
    93             sample->filename); 
    94  
    95   g_print ("Attempting to revert >>%s<<\n", pathname); 
    96  
    97   orig_sample = sample_load (pathname); 
    98  
    99   g_print ("Loaded into %p\n", orig_sample); 
    100  
    101   sample_replace_throughout (sample, orig_sample); 
    102  
    103   sample_refresh_views (orig_sample); 
     360  sw_view * view = (sw_view *)data; 
     361  sw_sample * sample; 
     362#undef BUF_LEN 
     363#define BUF_LEN 512 
     364  char buf[BUF_LEN]; 
     365     
     366  sample = view->sample; 
     367 
     368  snprintf (buf, BUF_LEN, 
     369            _("Are you sure you want to revert %s to\n%s?\n\n" 
     370              "All changes and undo information will be lost."), 
     371            g_basename (sample->pathname), sample->pathname); 
     372 
     373  question_dialog_new (sample, _("Revert file"), buf, 
     374                       _("Revert"), _("Don't revert"), 
     375                       sample_revert_ok_cb, sample, NULL, NULL, 
     376                       SWEEP_EDIT_MODE_ALLOC); 
     377
     378 
     379void 
     380sample_store_and_free_pathname (sw_sample * sample, gchar * pathname) 
     381
     382  prefs_set_string (LAST_SAVE_KEY, pathname); 
     383 
     384  sample_set_pathname (sample, pathname); 
     385 
     386#ifdef DEVEL_CODE 
     387  g_free (pathname); 
     388#endif 
     389
     390 
     391void 
     392file_guess_method (sw_sample * sample, char * pathname) 
     393
     394  int i; 
     395  gchar * ext; 
     396 
     397#if defined (SNDFILE_1) 
     398  SF_FORMAT_INFO  info ; 
     399  int   count ; 
     400#else 
     401  gchar ** exts, **e; 
     402  sw_file_format_desc * desc; 
     403#endif 
     404 
     405  g_assert (sample->file_method == SWEEP_FILE_METHOD_BY_EXTENSION); 
     406 
     407  if (pathname == NULL) goto guess_raw; 
     408 
     409  ext = strrchr (pathname, '.'); 
     410 
     411  if (ext != NULL) { 
     412    ext++; 
     413 
     414#ifdef HAVE_OGGVORBIS 
     415    if (!g_strncasecmp (ext, "ogg", SW_DIR_LEN)) { 
     416      sample->file_method = SWEEP_FILE_METHOD_OGGVORBIS; 
     417      sample->file_format = 0; 
     418      return; 
     419    } 
     420#endif 
     421 
     422#ifdef HAVE_SPEEX 
     423    if (!g_strncasecmp (ext, "spx", SW_DIR_LEN)) { 
     424      sample->file_method = SWEEP_FILE_METHOD_SPEEX; 
     425      sample->file_format = 0; 
     426      return; 
     427    } 
     428#endif 
     429 
     430    /* MP3 has dummy annoying dialog support */ 
     431    if (!g_strncasecmp (ext, "mp3", SW_DIR_LEN)) { 
     432      sample->file_method = SWEEP_FILE_METHOD_MP3; 
     433      sample->file_format = 0; 
     434      return; 
     435    } 
     436 
     437#if defined (SNDFILE_1) 
     438 
     439    sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int)) ; 
     440 
     441    for (i = 0; i <  count ; i++) { 
     442      info.format = i ; 
     443      sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ; 
     444                 
     445      if (!g_strncasecmp (ext, info.extension, SW_DIR_LEN)) { 
     446        sample->file_method = SWEEP_FILE_METHOD_LIBSNDFILE; 
     447        sample->file_format = info.format; 
     448        break; /* NB. this break is essential to ensure that eg. a file 
     449                * ending in ".wav" is guessed as RIFF/WAV not Sphere/NIST, 
     450                * which also may use the ending ".wav"; assuming RIFF/WAV is 
     451                * more common we prefer to use this format when guessing. 
     452                */ 
     453      } 
     454    } 
     455 
     456    /* Catch some common conventions not offered by libsndfile */ 
     457    if (sample->file_method == SWEEP_FILE_METHOD_BY_EXTENSION) { 
     458      if (!g_strncasecmp(ext, "aifc", SW_DIR_LEN) || 
     459          !g_strncasecmp(ext, "aif", SW_DIR_LEN)) { 
     460        sample->file_method = SWEEP_FILE_METHOD_LIBSNDFILE; 
     461        sample->file_format = SF_FORMAT_AIFF; 
     462      } 
     463    } 
     464 
     465#else 
     466 
     467    for (i = 0; i <  sizeof(file_formats)/sizeof(sw_file_format_desc); i++) { 
     468      desc = &file_formats[i]; 
     469      exts = g_strsplit (desc->exts, ",", 16); 
     470      for (e = exts; *e; e++) { 
     471        if (!g_strncasecmp (*e, ext, SW_DIR_LEN)) { 
     472          sample->file_method = SWEEP_FILE_METHOD_LIBSNDFILE; 
     473          sample->file_format = desc->file_format; 
     474        } 
     475      } 
     476      g_strfreev (exts); 
     477    } 
     478 
     479#endif 
     480 
     481  } 
     482 
     483 guess_raw: 
     484   
     485  if (sample->file_method == SWEEP_FILE_METHOD_BY_EXTENSION) { 
     486    sample->file_method = SWEEP_FILE_METHOD_LIBSNDFILE; 
     487#if defined (SNDFILE_1) 
     488    sample->file_format = SF_FORMAT_RAW; 
     489#else 
     490    sample->file_format = SWEEP_FILE_FORMAT_RAW; 
     491#endif 
     492  } 
     493 
     494  return; 
     495}     
     496 
     497typedef struct { 
     498  sw_sample * sample; 
     499  char * pathname; 
     500} save_as_data; 
     501 
     502static void 
     503overwrite_ok_cb (GtkWidget * widget, gpointer data) 
     504
     505  save_as_data * sd = (save_as_data *)data; 
     506  sw_sample * sample = sd->sample; 
     507  char * pathname = sd->pathname; 
     508 
     509  if (sample->file_method == SWEEP_FILE_METHOD_BY_EXTENSION) { 
     510    file_guess_method (sample, pathname); 
     511  } 
     512 
     513  switch (sample->file_method) { 
     514  case SWEEP_FILE_METHOD_LIBSNDFILE: 
     515    sndfile_save_options_dialog (sample, pathname); 
     516    break; 
     517#ifdef HAVE_OGGVORBIS 
     518  case SWEEP_FILE_METHOD_OGGVORBIS: 
     519    vorbis_save_options_dialog (sample, pathname); 
     520    break; 
     521#endif 
     522#ifdef HAVE_SPEEX 
     523  case SWEEP_FILE_METHOD_SPEEX: 
     524    speex_save_options_dialog (sample, pathname); 
     525    break; 
     526#endif 
     527  case SWEEP_FILE_METHOD_MP3: 
     528    mp3_unsupported_dialog (); 
     529    break; 
     530  default: 
     531    g_assert_not_reached (); 
     532    break; 
     533  } 
     534 
     535  g_free (sd); 
     536
     537 
     538static void 
     539overwrite_cancel_cb (GtkWidget * widget, gpointer data) 
     540
     541  save_as_data * sd = (save_as_data *)data; 
     542  gchar * msg; 
     543 
     544  msg = g_strdup_printf (_("Save as %s cancelled"), g_basename (sd->pathname)); 
     545  sample_set_tmp_message (sd->sample, msg); 
     546  g_free (msg); 
     547 
     548  g_free (sd); 
    104549} 
    105550 
     
    107552sample_save_as_ok_cb(GtkWidget * widget, gpointer data) 
    108553{ 
    109   SampleDisplay * s = SAMPLE_DISPLAY(data)
     554  sw_view * view = (sw_view *)data
    110555  sw_sample * sample; 
    111556  GtkWidget * filesel; 
    112   gchar *dn, * fn; 
    113  
    114   sample = s->view->sample; 
     557  gchar * pathname; 
     558  struct stat statbuf; 
     559 
     560  save_as_data * sd; 
     561 
     562#undef BUF_LEN 
     563#define BUF_LEN 512 
     564  char buf[BUF_LEN]; 
     565     
     566  sample = view->sample; 
    115567  filesel = gtk_widget_get_toplevel (widget); 
    116568 
    117   dn = gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel)); 
    118   g_free(save_current_file); 
    119   save_current_file = g_strdup(dn); 
    120  
    121   /* remove filename from dir */ 
    122   fn = strrchr (dn, '/'); 
    123   if (fn) { 
    124     *fn++ = '\0'; 
     569  pathname = 
     570    g_strdup (gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel))); 
     571 
     572  if (!sweep_dir_exists (pathname)) { 
     573    g_free (pathname); 
     574    return; 
     575  } 
     576 
     577  sd = g_malloc (sizeof (save_as_data)); 
     578  sd->sample = sample; 
     579  sd->pathname = pathname; 
     580 
     581  if (stat (pathname, &statbuf) == -1) { 
     582    switch (errno) { 
     583    case ENOENT: 
     584      /* If it doesn't exist, it's ok to save as */ 
     585      overwrite_ok_cb (NULL, sd); 
     586      break; 
     587    default: 
     588      sweep_perror (errno, pathname); 
     589      break; 
     590    } 
    125591  } else { 
    126     fn = dn; 
    127     dn = NULL; 
    128   } 
    129  
    130   sample_set_pathname (sample, dn, fn); 
    131  
    132   sample_save(sample); 
     592    /* file exists */ 
     593    if (access(pathname, W_OK) == -1) { 
     594      sweep_perror (errno, _("You are not allowed to write to\n%s"), pathname); 
     595      g_free (sd); 
     596    } else { 
     597      snprintf (buf, BUF_LEN, _("%s exists. Overwrite?"), pathname); 
     598      question_dialog_new (sample, _("File exists"), buf, 
     599                           _("Overwrite"), _("Don't overwrite"), 
     600                           overwrite_ok_cb, sd, overwrite_cancel_cb, sd, 
     601                           SWEEP_EDIT_MODE_META); 
     602    } 
     603  } 
    133604 
    134605  gtk_widget_destroy(GTK_WIDGET(filesel)); 
     
    141612} 
    142613 
     614static void 
     615file_set_format_cb (GtkWidget * widget, gpointer data) 
     616{ 
     617  sw_sample * sample = (sw_sample *)data; 
     618 
     619  sample->file_method = (sw_file_method_t) 
     620    GPOINTER_TO_INT(gtk_object_get_data (GTK_OBJECT(widget), "method")); 
     621 
     622  sample->file_format = 
     623    GPOINTER_TO_INT(gtk_object_get_data (GTK_OBJECT(widget), "format")); 
     624} 
     625 
     626static GtkWidget * 
     627create_save_menu (sw_sample * sample) 
     628{ 
     629  GtkWidget * menu; 
     630  GtkWidget * menuitem; 
     631  int i; 
     632 
     633#if defined (SNDFILE_1) 
     634  SF_FORMAT_INFO  info ; 
     635  int   count ; 
     636#else 
     637  sw_file_format_desc * desc; 
     638#endif 
     639 
     640  menu = gtk_menu_new (); 
     641 
     642  sample->file_method = SWEEP_FILE_METHOD_BY_EXTENSION; 
     643 
     644  menuitem = gtk_menu_item_new_with_label (_("By extension")); 
     645  gtk_menu_append (GTK_MENU(menu), menuitem); 
     646  gtk_object_set_data (GTK_OBJECT(menuitem), "method", 
     647                       SWEEP_FILE_METHOD_BY_EXTENSION); 
     648  gtk_object_set_data (GTK_OBJECT(menuitem), "format", 0); 
     649  gtk_signal_connect (GTK_OBJECT(menuitem), "activate", 
     650                      GTK_SIGNAL_FUNC(file_set_format_cb), sample); 
     651  gtk_widget_show (menuitem); 
     652 
     653  menuitem = gtk_menu_item_new (); /* Separator */ 
     654  gtk_menu_append (GTK_MENU(menu), menuitem); 
     655  gtk_widget_show (menuitem); 
     656 
     657  /* libsndfile formats */ 
     658 
     659#if defined (SNDFILE_1) 
     660 
     661  sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int)) ; 
     662 
     663  for (i = 0; i < count ; i++) { 
     664    info.format = i ; 
     665    sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ; 
     666 
     667    menuitem = gtk_menu_item_new_with_label (info.name); 
     668    gtk_menu_append (GTK_MENU(menu), menuitem); 
     669    gtk_object_set_data (GTK_OBJECT(menuitem), "method", 
     670                         GINT_TO_POINTER(SWEEP_FILE_METHOD_LIBSNDFILE)); 
     671    gtk_object_set_data (GTK_OBJECT(menuitem), "format", 
     672                         GINT_TO_POINTER(info.format)); 
     673    gtk_signal_connect (GTK_OBJECT(menuitem), "activate", 
     674                        GTK_SIGNAL_FUNC(file_set_format_cb), sample); 
     675    gtk_widget_show (menuitem); 
     676  } 
     677 
     678#else 
     679 
     680  for (i = 0; i < sizeof(file_formats)/sizeof(sw_file_format_desc); i++) { 
     681    desc = &file_formats[i]; 
     682    menuitem = gtk_menu_item_new_with_label (_(desc->name)); 
     683    gtk_menu_append (GTK_MENU(menu), menuitem); 
     684    gtk_object_set_data (GTK_OBJECT(menuitem), "method", 
     685                         GINT_TO_POINTER(SWEEP_FILE_METHOD_LIBSNDFILE)); 
     686    gtk_object_set_data (GTK_OBJECT(menuitem), "format", 
     687                         GINT_TO_POINTER(desc->file_format)); 
     688    gtk_signal_connect (GTK_OBJECT(menuitem), "activate", 
     689                        GTK_SIGNAL_FUNC(file_set_format_cb), sample); 
     690    gtk_widget_show (menuitem); 
     691  } 
     692 
     693#endif 
     694 
     695  menuitem = gtk_menu_item_new (); /* Separator */ 
     696  gtk_menu_append (GTK_MENU(menu), menuitem); 
     697  gtk_widget_show (menuitem); 
     698 
     699#if 1 
     700  /* MP3 (encoding not supported due to patent restrictions) */ 
     701 
     702  menuitem = gtk_menu_item_new_with_label (_("MP3 (Use Ogg Vorbis instead)")); 
     703  gtk_widget_set_sensitive (menuitem, FALSE); 
     704  gtk_menu_append (GTK_MENU(menu), menuitem); 
     705  gtk_widget_show (menuitem); 
     706#endif 
     707 
     708#ifdef HAVE_OGGVORBIS 
     709  /* Ogg Vorbis */ 
     710 
     711  menuitem = gtk_menu_item_new_with_label ("Ogg Vorbis (Xiph.org)"); 
     712  gtk_menu_append (GTK_MENU(menu), menuitem); 
     713  gtk_object_set_data (GTK_OBJECT(menuitem), "method", 
     714                       GINT_TO_POINTER(SWEEP_FILE_METHOD_OGGVORBIS)); 
     715  gtk_object_set_data (GTK_OBJECT(menuitem), "format", 
     716                       GINT_TO_POINTER(0)); 
     717  gtk_signal_connect (GTK_OBJECT(menuitem), "activate", 
     718                      GTK_SIGNAL_FUNC(file_set_format_cb), sample); 
     719  gtk_widget_show (menuitem); 
     720#endif 
     721 
     722#ifdef HAVE_SPEEX 
     723  /* Speex */ 
     724 
     725  menuitem = gtk_menu_item_new_with_label ("Speex (Xiph.org)"); 
     726  gtk_menu_append (GTK_MENU(menu), menuitem); 
     727  gtk_object_set_data (GTK_OBJECT(menuitem), "method", 
     728                       GINT_TO_POINTER(SWEEP_FILE_METHOD_SPEEX)); 
     729  gtk_object_set_data (GTK_OBJECT(menuitem), "format", 
     730                       GINT_TO_POINTER(0)); 
     731  gtk_signal_connect (GTK_OBJECT(menuitem), "activate", 
     732                      GTK_SIGNAL_FUNC(file_set_format_cb), sample); 
     733  gtk_widget_show (menuitem); 
     734#endif 
     735 
     736  return menu; 
     737} 
     738 
    143739void 
    144740sample_save_as_cb(GtkWidget * widget, gpointer data) 
    145741{ 
    146   SampleDisplay * s = SAMPLE_DISPLAY(data)
     742  sw_view * view = (sw_view *)data
    147743  sw_sample * sample; 
    148744  GtkWidget * filesel; 
    149  
    150   sample = s->view->sample; 
    151  
    152   chdir(sample->directory); 
    153  
    154   filesel = gtk_file_selection_new("Save Sample"); 
    155   if(save_current_file) 
     745  GtkWidget * save_options; 
     746  GtkWidget * frame; 
     747  GtkWidget * hbox; 
     748  GtkWidget * label; 
     749  GtkWidget * option_menu; 
     750  GtkWidget * save_menu; 
     751 
     752  char * last_save; 
     753 
     754  gint win_width, win_height; 
     755 
     756  win_width = gdk_screen_width () / 2; 
     757  win_height = gdk_screen_height () / 2; 
     758 
     759  sample = view->sample; 
     760 
     761  filesel = gtk_file_selection_new(_("Sweep: Save file")); 
     762  gtk_window_set_position (GTK_WINDOW (filesel), GTK_WIN_POS_CENTER); 
     763  gtk_widget_set_usize (filesel, win_width, win_height); 
     764 
     765  if (!strcmp (g_dirname (sample->pathname), ".")) { 
     766 
     767    last_save = prefs_get_string (LAST_SAVE_KEY); 
     768 
     769    if(last_save) { 
     770      gchar * last_save_dir = g_dirname (last_save); 
     771      gchar * new_pathname = 
     772        g_strdup_printf ("%s%c%s", 
     773                         last_save_dir, G_DIR_SEPARATOR, sample->pathname); 
     774                                               
    156775      gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel),  
    157                                       save_current_file); 
     776                                      new_pathname); 
     777 
     778      g_free (new_pathname); 
     779      g_free (last_save_dir); 
     780      g_free (last_save); 
     781    } 
     782  } else { 
     783    gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel),  
     784                                    sample->pathname); 
     785  } 
     786 
     787  save_options = gtk_hbox_new (TRUE, 1); 
     788 
     789  frame = gtk_frame_new (_("Save Options")); 
     790  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); 
     791  gtk_box_pack_start (GTK_BOX (save_options), frame, TRUE, TRUE, 4); 
     792   
     793  hbox = gtk_hbox_new (FALSE, 4); 
     794  gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); 
     795  gtk_container_add (GTK_CONTAINER (frame), hbox); 
     796  gtk_widget_show (hbox); 
     797   
     798  label = gtk_label_new (_("Determine File Type:")); 
     799  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); 
     800  gtk_widget_show (label); 
     801   
     802  option_menu = gtk_option_menu_new (); 
     803  gtk_box_pack_start (GTK_BOX (hbox), option_menu, TRUE, TRUE, 0); 
     804  gtk_widget_show (option_menu); 
     805   
     806  save_menu = create_save_menu (sample); 
     807  gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), save_menu); 
     808   
     809  gtk_widget_show (frame); 
     810 
     811  /* pack the containing save_options hbox into the save-dialog */ 
     812  gtk_box_pack_end (GTK_BOX (GTK_FILE_SELECTION (filesel)->main_vbox), 
     813                    save_options, FALSE, FALSE, 0); 
     814 
     815  gtk_widget_show (save_options); 
    158816 
    159817  gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), 
     
    166824} 
    167825 
     826static void 
     827sample_save_ok_cb(GtkWidget * widget, gpointer data) 
     828{ 
     829  sw_view * view = (sw_view *)data; 
     830  sw_sample * sample = view->sample; 
     831 
     832  switch (sample->file_method) { 
     833  case SWEEP_FILE_METHOD_LIBSNDFILE: 
     834    sndfile_sample_save (sample, sample->pathname); 
     835    break; 
     836#ifdef HAVE_OGGVORBIS 
     837  case SWEEP_FILE_METHOD_OGGVORBIS: 
     838    vorbis_save_options_dialog (sample, sample->pathname); 
     839    break; 
     840#endif 
     841#ifdef HAVE_SPEEX 
     842  case SWEEP_FILE_METHOD_SPEEX: 
     843    speex_save_options_dialog (sample, sample->pathname); 
     844    break; 
     845#endif 
     846  case SWEEP_FILE_METHOD_MP3: 
     847    mp3_unsupported_dialog (); 
     848    break; 
     849  default: 
     850#if 0 
     851    g_assert_not_reached (); 
     852#else 
     853    sample_save_as_cb (widget, data); 
     854#endif 
     855    break; 
     856  } 
     857} 
     858 
    168859void 
    169 sample_save_cb(GtkWidget * widget, gpointer data) 
    170 { 
    171   SampleDisplay * s = SAMPLE_DISPLAY(data)
     860sample_save_cb (GtkWidget * widget, gpointer data) 
     861{ 
     862  sw_view * view = (sw_view *)data
    172863  sw_sample * sample; 
    173  
    174   sample = s->view->sample; 
    175  
    176   if (!sample->filename) { 
     864#undef BUF_LEN 
     865#define BUF_LEN 512 
     866  char buf[BUF_LEN]; 
     867     
     868  sample = view->sample; 
     869 
     870  if (sample->last_mtime == 0 || 
     871      sample->file_method == SWEEP_FILE_METHOD_MP3) { 
    177872    sample_save_as_cb (widget, data); 
     873  } else if (sample_mtime_changed (sample)) { 
     874    snprintf (buf, BUF_LEN, 
     875              _("%s\n has changed on disk.\n\n" 
     876                "Are you sure you want to save?"), 
     877              sample->pathname); 
     878     
     879    question_dialog_new (sample, _("File modified"), buf, 
     880                         _("Save"), _("Don't save"), 
     881                         sample_save_ok_cb, view, NULL, NULL, 
     882                         SWEEP_EDIT_MODE_ALLOC); 
    178883  } else { 
    179     sample_save (sample); 
    180   } 
    181 } 
     884    sample_save_ok_cb (widget, view); 
     885  } 
     886} 
  • trunk/sweep/src/file_dialogs.h

    r7 r124  
    2222#define __FILE_DIALOGS_H__ 
    2323 
     24#include <sweep/sweep_types.h> 
     25 
     26void 
     27mp3_unsupported_dialog (void); 
     28 
     29sw_file_format_t 
     30guess_file_format (gchar * pathname); 
     31 
     32gboolean 
     33sample_mtime_changed (sw_sample * sample); 
     34 
     35sw_sample * 
     36sample_load(char * pathname); 
     37 
    2438void 
    2539sample_load_cb(GtkWidget * wiget, gpointer data); 
     40 
     41void 
     42sample_revert_ok_cb (GtkWidget * widget, gpointer data); 
    2643 
    2744void 
     
    3451sample_save_cb(GtkWidget * wiget, gpointer data); 
    3552 
     53void 
     54sample_store_and_free_pathname (sw_sample * sample, gchar * pathname); 
     55 
    3656#endif /* __FILE_DIALOGS_H__ */ 
  • trunk/sweep/src/format.c

    r57 r124  
    1818 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
    1919 */ 
     20 
     21#ifdef HAVE_CONFIG_H 
     22#  include <config.h> 
     23#endif 
    2024 
    2125#include <sweep/sweep_types.h> 
  • trunk/sweep/src/interface.c

    r57 r124  
    3535#include "sweep_app.h" 
    3636 
     37#include "driver.h" 
    3738#include "callbacks.h" 
    3839#include "file_dialogs.h" 
     
    4142#include "pixmaps.h" 
    4243 
    43 static void 
    44 main_destroy_cb (GtkWidget * widget, gpointer data) 
    45 
    46   gtk_main_quit(); 
    47 
     44GtkStyle * style_wb; 
     45GtkStyle * style_bw; 
     46GtkStyle * style_LCD; 
     47GtkStyle * style_light_grey; 
     48GtkStyle * style_green_grey; 
     49GtkStyle * style_red_grey; 
     50GtkStyle * style_dark_grey; 
     51GtkStyle * style_red; 
    4852 
    4953GtkWidget * 
     
    6468  return gtk_pixmap_new (pixmap_data, mask); 
    6569} 
     70 
     71/* 
     72 * create_color (r, g, b) 
     73 * 
     74 * Ripped from grip, Copyright (c) 1998-2002 Mike Oliphant 
     75 */ 
     76GdkColor * 
     77create_color (int red, int green, int blue) 
     78{ 
     79  GdkColor *c; 
     80 
     81  c=(GdkColor *)g_malloc(sizeof(GdkColor)); 
     82  c->red=red; 
     83  c->green=green; 
     84  c->blue=blue; 
     85 
     86  gdk_color_alloc(gdk_colormap_get_system(),c); 
     87 
     88  return c; 
     89} 
     90 
     91static gfloat style_color_mods[5]={0.0,-0.1,0.2,-0.2}; 
     92 
     93/* 
     94 * create_style() 
     95 * 
     96 * Ripped from grip, Copyright (c) 1998-2002 Mike Oliphant 
     97 */ 
     98GtkStyle * 
     99create_style (GdkColor * fg, GdkColor * bg, gboolean do_grade) 
     100{ 
     101  GtkStyle *def; 
     102  GtkStyle *sty; 
     103  int state; 
     104 
     105  def=gtk_widget_get_default_style(); 
     106  sty=gtk_style_copy(def); 
     107 
     108  for(state=0;state<5;state++) { 
     109    if(fg) sty->fg[state]=*fg; 
     110 
     111    if(bg) sty->bg[state]=*bg; 
     112 
     113    if(bg && do_grade) { 
     114      sty->bg[state].red+=sty->bg[state].red*style_color_mods[state]; 
     115      sty->bg[state].green+=sty->bg[state].green*style_color_mods[state]; 
     116      sty->bg[state].blue+=sty->bg[state].blue*style_color_mods[state]; 
     117    } 
     118  } 
     119 
     120  return sty; 
     121} 
     122 
     123void 
     124init_styles (void) 
     125{ 
     126  GdkColor gdkblack; 
     127  GdkColor gdkwhite; 
     128  GdkColor * color_LCD; 
     129  GdkColor * color_light_grey; 
     130  GdkColor * color_green_grey; 
     131  GdkColor * color_red_grey; 
     132  GdkColor * color_dark_grey; 
     133  GdkColor * color_red; 
     134 
     135  gdk_color_white(gdk_colormap_get_system(),&gdkwhite); 
     136  gdk_color_black(gdk_colormap_get_system(),&gdkblack); 
     137   
     138  color_LCD = create_color (33686,38273,29557); 
     139  color_light_grey = create_color (0xaaaa, 0xaaaa, 0xaaaa); 
     140  color_green_grey = create_color (0xaaaa, 0xbbbb, 0xaaaa); 
     141  color_red_grey = create_color (0xd3d3, 0x9898, 0x9898); 
     142  /*  color_dark_grey = create_color (0x4444,0x4444,0x4444);*/ 
     143  color_dark_grey = create_color (0x5555, 0x5555, 0x5555); 
     144  color_red = create_color (0xffff, 0x0000, 0x0000); 
     145 
     146  style_wb = create_style(&gdkwhite,&gdkblack,FALSE); 
     147  style_bw = create_style(&gdkblack,&gdkwhite,FALSE); 
     148  style_LCD = create_style(color_LCD, color_LCD, FALSE); 
     149  style_light_grey = create_style (color_light_grey, color_light_grey, TRUE); 
     150#if 0 
     151  style_green_grey = create_style (color_green_grey, color_green_grey, TRUE); 
     152#else 
     153  style_green_grey = style_light_grey; 
     154#endif 
     155 
     156  style_red_grey = create_style (color_red_grey, color_red_grey, TRUE); 
     157 
     158#if 0 
     159  style_dark_grey = create_style(&gdkwhite, color_dark_grey, TRUE); 
     160#else 
     161  style_dark_grey = style_light_grey; 
     162#endif 
     163 
     164  style_red = create_style (&gdkblack, color_red, FALSE); 
     165} 
     166 
     167GtkWidget * 
     168create_pixmap_button (GtkWidget * widget, gchar ** xpm_data, 
     169                      const gchar * tip_text, GtkStyle * style, 
     170                      sw_toolbar_button_type button_type, 
     171                      GtkSignalFunc clicked, 
     172                      GtkSignalFunc pressed, GtkSignalFunc released, 
     173                      gpointer data) 
     174{ 
     175  GtkWidget * pixmap; 
     176  GtkWidget * button; 
     177  GtkTooltips * tooltips; 
     178 
     179  switch (button_type) { 
     180  case SW_TOOLBAR_TOGGLE_BUTTON: 
     181    button = gtk_toggle_button_new (); 
     182    break; 
     183  case SW_TOOLBAR_RADIO_BUTTON: 
     184    button = gtk_radio_button_new (NULL); 
     185    break; 
     186  case SW_TOOLBAR_BUTTON: 
     187  default: 
     188    button = gtk_button_new (); 
     189    break; 
     190  } 
     191 
     192  if (xpm_data != NULL) { 
     193    pixmap = create_widget_from_xpm (widget, xpm_data); 
     194    gtk_widget_show (pixmap); 
     195    gtk_container_add (GTK_CONTAINER (button), pixmap); 
     196  } 
     197 
     198  if (tip_text != NULL) { 
     199    tooltips = gtk_tooltips_new (); 
     200    gtk_tooltips_set_tip (tooltips, button, tip_text, NULL); 
     201  } 
     202 
     203  if (style != NULL) { 
     204    gtk_widget_set_style (button, style); 
     205  } 
     206 
     207  if (clicked != NULL) { 
     208    gtk_signal_connect (GTK_OBJECT (button), "clicked", 
     209                        GTK_SIGNAL_FUNC(clicked), data); 
     210  } 
     211 
     212  if (pressed != NULL) { 
     213    gtk_signal_connect (GTK_OBJECT(button), "pressed", 
     214                        GTK_SIGNAL_FUNC(pressed), data); 
     215  } 
     216 
     217  if (released != NULL) { 
     218    gtk_signal_connect (GTK_OBJECT(button), "released", 
     219                        GTK_SIGNAL_FUNC(released), data); 
     220  } 
     221 
     222  return button; 
     223} 
     224 
     225 
     226#if 0 
     227static void 
     228main_destroy_cb (GtkWidget * widget, gpointer data) 
     229{ 
     230  gtk_main_quit(); 
     231} 
     232 
    66233 
    67234GtkWidget* 
     
    74241  GtkWidget *handlebox1; 
    75242  GtkWidget *toolbar1; 
    76   GtkWidget *button1,/*  *button2,*/ *button3
     243  GtkWidget *button1, * button
    77244  GtkWidget *pixmap1, *pixmap3; 
    78245  GtkWidget *menu; 
     
    114281  gtk_menu_append (GTK_MENU(menu), menuitem); 
    115282  gtk_signal_connect (GTK_OBJECT(menuitem), "activate", 
    116                       GTK_SIGNAL_FUNC(sample_new_empty_cb), window1); 
     283                      GTK_SIGNAL_FUNC(sample_new_empty_cb), NULL); 
    117284  gtk_widget_show(menuitem); 
    118285  gtk_widget_add_accelerator (menuitem, "activate", accel_group, 
     
    151318  gtk_widget_show(menuitem); 
    152319 
    153  
     320#if 0 
    154321  handlebox1 = gtk_handle_box_new (); 
    155322  gtk_widget_show (handlebox1); 
     
    159326  gtk_widget_show (toolbar1); 
    160327  gtk_container_add (GTK_CONTAINER (handlebox1), toolbar1); 
     328 
     329  /* SELECT */ 
    161330 
    162331  pixmap1 = create_widget_from_xpm (toolbar1, rect_xpm); 
     
    180349 
    181350#if 0 
    182   button2 = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), 
    183                                         GTK_TOOLBAR_CHILD_RADIOBUTTON, 
    184                                         button1, /* Radio group */ 
     351  /* MOVE */ 
     352 
     353  button = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), 
     354                                       GTK_TOOLBAR_CHILD_RADIOBUTTON, 
     355                                       button1, /* Radio group */ 
    185356                                        _("Move"), 
    186                                         _("Move regions in a sample"), 
    187                                         _("With this tool you can move" 
    188                                           " selected regions of a sample."), 
    189                                         NULL, /* icon */ 
    190                                         set_tool_cb, (gpointer)TOOL_MOVE); 
    191   gtk_widget_show (button2); 
    192 #endif 
     357                                       _("Move regions in a sample"), 
     358                                       _("With this tool you can move" 
     359                                         " selected regions of a sample."), 
     360                                       NULL, /* icon */ 
     361                                       set_tool_cb, (gpointer)TOOL_MOVE); 
     362  gtk_widget_show (button); 
     363#endif 
     364 
     365  /* SCRUB */ 
     366 
     367  button = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), 
     368                                       GTK_TOOLBAR_CHILD_RADIOBUTTON, 
     369                                       button1, /* Radio group */ 
     370                                       _("Scrub"), 
     371                                       _("Locate sounds directly"), 
     372                                       _("Place the play marker on a sample." 
     373                                         " Click anywhere in a view to" 
     374                                         " instantly move the playback" 
     375                                         " position to that part of the" 
     376                                         " sample."), 
     377                                       NULL, /* icon */ 
     378                                       set_tool_cb, (gpointer)TOOL_SCRUB); 
     379  gtk_widget_show (button); 
     380 
     381  /* ZOOM */ 
    193382 
    194383  pixmap3 = create_widget_from_xpm (window1, magnify_xpm); 
    195384  gtk_widget_show (pixmap3); 
    196385 
    197   button3 = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), 
    198                                         GTK_TOOLBAR_CHILD_RADIOBUTTON, 
    199                                         button1, /* Radio group */ 
    200                                         _("Zoom"), 
    201                                         _("Zoom in & out"), 
    202                                         _("Zoom in and out of a view. Click" 
    203                                           " anywhere in a view to zoom in on" 
    204                                           " that part of the sample. Hold" 
    205                                           " down shift and click on the view" 
    206                                           " to zoom out."), 
    207                                         pixmap3, /* icon */ 
    208                                         set_tool_cb, (gpointer)TOOL_ZOOM); 
    209   gtk_widget_show (button3); 
     386  button = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), 
     387                                       GTK_TOOLBAR_CHILD_RADIOBUTTON, 
     388                                       button1, /* Radio group */ 
     389                                       _("Zoom"), 
     390                                       _("Zoom in & out"), 
     391                                       _("Zoom in and out of a view. Click" 
     392                                         " anywhere in a view to zoom in on" 
     393                                         " that part of the sample. Hold" 
     394                                         " down shift and click on the view" 
     395                                         " to zoom out."), 
     396                                       pixmap3, /* icon */ 
     397                                       set_tool_cb, (gpointer)TOOL_ZOOM); 
     398  gtk_widget_show (button); 
     399 
     400#if 1 /* These need undos! */ 
     401 
     402  /* PENCIL */ 
     403 
     404  button = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), 
     405                                       GTK_TOOLBAR_CHILD_RADIOBUTTON, 
     406                                       button1, /* Radio group */ 
     407                                       _("Pencil"), 
     408                                       _("Edit PCM sample values"), 
     409                                       _("When zoomed down to individual " 
     410                                         " samples, click to edit"), 
     411                                       NULL, /* icon */ 
     412                                       set_tool_cb, (gpointer)TOOL_PENCIL); 
     413  gtk_widget_show (button); 
     414 
     415  /* NOISE */ 
     416 
     417  button = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), 
     418                                       GTK_TOOLBAR_CHILD_RADIOBUTTON, 
     419                                       button1, /* Radio group */ 
     420                                       _("Noise"), 
     421                                       _("Add noise"), 
     422                                       _("Randomise PCM values"), 
     423                                       NULL, /* icon */ 
     424                                       set_tool_cb, (gpointer)TOOL_NOISE); 
     425  gtk_widget_show (button); 
     426#endif 
     427 
     428#endif /* TOOLBAR */ 
    210429 
    211430  return window1; 
    212431} 
    213432 
     433#endif 
  • trunk/sweep/src/interface.h

    r7 r124  
    2222#define __INTERFACE_H__ 
    2323 
     24#include "sweep_app.h" 
     25 
    2426GtkWidget * 
    2527create_widget_from_xpm (GtkWidget * widget, gchar **xpm_data); 
     28 
     29GdkColor * 
     30create_color (int red, int green, int blue); 
     31 
     32GtkStyle * 
     33create_style (GdkColor * fg, GdkColor * bg, gboolean do_grade); 
     34 
     35void 
     36init_styles (void); 
     37 
     38GtkWidget * 
     39create_pixmap_button (GtkWidget * widget, gchar ** xpm_data, 
     40                      const gchar * tip_text, GtkStyle * style, 
     41                      sw_toolbar_button_type button_type, 
     42                      GtkSignalFunc clicked, 
     43                      GtkSignalFunc pressed, GtkSignalFunc released, 
     44                      gpointer data); 
    2645 
    2746GtkWidget* create_toolbox (void); 
  • trunk/sweep/src/main.c

    r111 r124  
    2525 
    2626#include <stdlib.h> 
     27#include <string.h> 
     28#include <time.h> 
     29 
    2730#include <glib.h> 
    2831#include <gtk/gtk.h> 
     
    3033#include <sweep/sweep_version.h> 
    3134#include <sweep/sweep_i18n.h> 
    32  
    33 #include "file_ops.h" 
     35#include <sweep/sweep_types.h> 
     36 
     37#include "preferences.h" 
     38#include "file_dialogs.h" 
    3439#include "interface.h" 
    3540#include "plugin.h" 
     41#include "cursors.h" 
     42#include "driver.h" 
     43#include "callbacks.h" 
     44#include "question_dialogs.h" 
     45#include "play.h" 
     46 
     47extern void sweep_timeouts_init (void); 
    3648 
    3749/* 
     
    4961{ 
    5062  char * arg = (char *)data; 
     63  gchar * pathname; 
     64 
     65  if (!strncmp (g_dirname (arg), ".", 1)) { 
     66    pathname = g_strdup_printf ("%s/%s", g_get_current_dir(), arg); 
     67  } else { 
     68    pathname = arg; 
     69  } 
    5170  
    52   sample_load_with_view (arg); 
     71  sample_load (pathname); 
    5372 
    5473  return FALSE; 
    5574} 
    5675 
     76#if 0 
     77static gint 
     78initial_sample_new (gpointer data) 
     79{ 
     80  sample_new_empty_cb (NULL, NULL); 
     81 
     82  return FALSE; 
     83} 
     84#endif 
     85 
     86static gint 
     87initial_sample_ask (gpointer data) 
     88{ 
     89  question_dialog_new (NULL, _("Welcome to Sweep"), 
     90                       _("Hello, my name is Scrubby. " 
     91                         "Welcome to Sweep!\n\n" 
     92                         "Would you like to create a new file or " 
     93                         "load an existing file?"), 
     94                       _("Create new file"), _("Load existing file"), 
     95                       sample_new_empty_cb, NULL, sample_load_cb, NULL, 0); 
     96 
     97  return FALSE; 
     98} 
    5799 
    58100/* 
     
    63105{ 
    64106  int i; 
     107#if 0 
    65108  GtkWidget *toolbox; 
     109#endif 
    66110 
    67111  gboolean show_version = FALSE; 
    68112  gboolean show_help = FALSE; 
    69   gboolean show_toolbox = TRUE; 
     113  /*  gboolean show_toolbox = TRUE;*/ 
     114 
     115  gboolean no_files = TRUE; 
    70116 
    71117#ifdef HAVE_PUTENV 
     
    79125 
    80126  gtk_set_locale (); 
     127 
     128#ifdef DEVEL_CODE 
     129  g_print (_("WARNING: Build includes incomplete development code.\n")); 
     130#endif 
     131 
     132#if 0 
     133#if defined (SNDFILE_1) 
     134  if (sizeof (sw_framecount_t) != sizeof (sf_count_t)) { 
     135    puts ("Software was configured incorrectly. Cannot run.\n") ; 
     136        exit (1) ; 
     137        } 
     138#endif 
     139#endif 
     140 
    81141  gtk_init (&argc, &argv); 
    82142 
     
    87147 
    88148  g_thread_init (NULL); 
     149 
     150  /* must be done before gtk_idle_add / gtk_timeout_add */ 
     151  sweep_timeouts_init (); 
    89152 
    90153  for(i = 1; i < argc; i++) { 
     
    97160      show_version = TRUE; 
    98161      argv[i] = NULL; 
     162#if 0 
    99163    } else if (strcmp (argv[i], "--no-toolbox") == 0) { 
    100164      show_toolbox = FALSE; 
    101165      argv[i] = NULL; 
     166#endif 
     167 
     168#ifdef DEVEL_CODE 
     169    } else if (argv[i][0] == '-' && argv[i][1] != '\0') { 
     170      /* check for unknown options, but allow "-" as stdin */ 
     171#else 
    102172    } else if (argv[i][0] == '-') { 
     173      /* check for unknown options */ 
     174#endif 
    103175      show_help = TRUE; 
    104176    } else { 
    105177      gtk_idle_add ((GtkFunction)initial_sample_load, argv[i]); 
     178      no_files = FALSE; 
    106179    } 
    107180  } 
     
    120193    g_print (_("  -v --version             Output version info.\n")); 
    121194    g_print (_("  --display <display>      Use the designated X display.\n")); 
     195#if 0 
    122196    g_print (_("  --no-toolbox             Do not show the toolbox window.\n")); 
     197#endif 
    123198  } 
    124199 
     
    127202  } 
    128203 
     204  srandom ((unsigned int)time(NULL)); 
     205   
     206 
     207  if (no_files) { 
     208    gtk_idle_add ((GtkFunction)initial_sample_ask, NULL); 
     209  } 
     210 
     211  /* initialise preferences */ 
     212  prefs_init (); 
     213 
    129214  /* initialise plugins */ 
    130215  init_plugins (); 
    131216 
     217  /* initialise cursors */ 
     218  init_cursors (); 
     219 
     220  /* initialise styles */ 
     221  init_styles (); 
     222 
     223  /* initialise devices */ 
     224  init_devices (); 
     225 
     226  /* init playback subsystem */ 
     227  init_playback (); 
     228 
     229#if 0 
    132230  if (show_toolbox) { 
    133231    toolbox = create_toolbox (); 
    134232    gtk_widget_show (toolbox); 
    135233  } 
     234#endif 
    136235 
    137236  gtk_main (); 
    138   return 0; 
    139 
    140  
     237 
     238  /* close preferences database */ 
     239  prefs_close (); 
     240 
     241  exit (0); 
     242
     243 
  • trunk/sweep/src/notes.c

    r57 r124  
    2424 
    2525#include <stdio.h> 
     26#include <stdlib.h> 
    2627#include <string.h> 
    2728 
    2829#include <gtk/gtk.h> 
     30#include <gdk/gdkkeysyms.h> 
    2931 
    3032#include "callbacks.h" 
     33 
     34#include <sweep/sweep_i18n.h> 
    3135 
    3236#include <sweep/sweep_types.h> 
     
    3438#include <sweep/sweep_sample.h> 
    3539 
     40#include "head.h" 
    3641#include "interface.h" 
    3742#include "edit.h" 
    3843#include "sample-display.h" 
    39 #include "driver.h" 
     44#include "play.h" 
    4045 
    41 /* 
    42  * This _SHOULD_ be handled more nicely, and dynamically. 
    43  * 
    44  * But ... it isn't. Feel free to fix it :) 
    45  */ 
     46#include "notes.h" 
    4647 
    47 #define PVA(n,p) \ 
    48 void                                                                     \ 
    49 play_view_all_##n##_cb (GtkWidget * widget, gpointer data)               \ 
    50 {                                                                        \ 
    51   SampleDisplay * sd = SAMPLE_DISPLAY(data);                             \ 
    52   sw_view * v = sd->view;                                                \ 
    53                                                                          \ 
    54   play_view_all_pitch (v, ##p##);                                        \ 
     48typedef struct _sw_noteplay sw_noteplay; 
     49 
     50struct _sw_noteplay { 
     51  char name [5]; 
     52  float pitch; 
     53  guint  accel_key; 
     54}; 
     55 
     56static void play_view_note_cb (GtkWidget * widget, gpointer data); 
     57 
     58static sw_noteplay notes [] = 
     59
     60  { N_("C3") , 0.500000, GDK_z }, 
     61  { N_("C#3"), 0.529732, GDK_s }, 
     62  { N_("D3") , 0.561231, GDK_x }, 
     63  { N_("Eb3"), 0.594604, GDK_d }, 
     64  { N_("E3") , 0.629961, GDK_c }, 
     65  { N_("F3") , 0.667420, GDK_v }, 
     66  { N_("F#3"), 0.707107, GDK_g }, 
     67  { N_("G3") , 0.749154, GDK_b }, 
     68  { N_("G#3"), 0.793701, GDK_h }, 
     69  { N_("A3") , 0.793701, GDK_n }, 
     70  { N_("Bb3"), 0.890899, GDK_j }, 
     71  { N_("B3") , 0.943874, GDK_m }, 
     72 
     73  { N_("C4") , 1.000000, GDK_q }, 
     74 
     75  { N_("C#4"), 1.059463, GDK_2 }, 
     76  { N_("D4") , 1.122462, GDK_w }, 
     77  { N_("Eb4"), 1.189207, GDK_3 }, 
     78  { N_("E4") , 1.259921, GDK_e }, 
     79  { N_("F4") , 1.334840, GDK_r }, 
     80  { N_("F#4"), 1.414214, GDK_5 }, 
     81  { N_("G4") , 1.498307, GDK_t }, 
     82  { N_("G#4"), 1.587401, GDK_6 }, 
     83  { N_("A4") , 1.681793, GDK_y }, 
     84  { N_("Bb4"), 1.781797, GDK_7 }, 
     85  { N_("B4") , 1.887749, GDK_u }, 
     86 
     87  { N_("C5") , 2.000000, GDK_i }, 
     88  { N_("C#5"), 2.118926, GDK_9 }, 
     89  { N_("D5") , 2.244924, GDK_o }, 
     90  { N_("D#5"), 2.378414, GDK_0 }, 
     91  { N_("E5") , 2.519842, GDK_p }, 
     92#if 0 
     93  { N_("F5") , 2.669680, GDK_bracketleft }, 
     94  { N_("F#5"), 2.828427, GDK_None }, 
     95  { N_("G5") , 2.996614, GDK_None }, 
     96  { N_("G#5"), 3.174802, GDK_None }, 
     97  { N_("A5") , 3.363586, GDK_None }, 
     98  { N_("Bb5"), 3.563595, GDK_None }, 
     99  { N_("B5") , 3.775497, GDK_None }, 
     100#endif 
     101 
     102} ; 
     103 
     104 
     105void 
     106noteplay_setup (GtkWidget *subsubmenu, sw_view * view, 
     107                GtkAccelGroup *accel_group) 
     108
     109  GtkWidget *menuitem; 
     110  int k; 
     111 
     112  for (k = 0 ; k < sizeof (notes) / sizeof (notes [0]) ; k++) { 
     113    menuitem = gtk_menu_item_new_with_label (_(notes [k].name)); 
     114    gtk_menu_append (GTK_MENU(subsubmenu), menuitem); 
     115    gtk_signal_connect (GTK_OBJECT(menuitem), "activate", 
     116                        GTK_SIGNAL_FUNC(play_view_note_cb), view); 
     117    gtk_widget_show (menuitem); 
     118    gtk_widget_add_accelerator (menuitem, "activate", accel_group, 
     119                                notes [k].accel_key, GDK_NONE, 
     120                                GTK_ACCEL_VISIBLE); 
     121 
     122    gtk_object_set_user_data (GTK_OBJECT(menuitem), 
     123                              GINT_TO_POINTER(k)); 
     124  } 
     125 
     126  return; 
    55127} 
    56128 
    57 PVA(C3,0.5); 
    58 PVA(Cs3,0.529732); 
    59 PVA(D3,0.561231); 
    60 PVA(Ds3,0.594604)
    61 PVA(E3,0.629961)
    62 PVA(F3,0.667420)
    63 PVA(Fs3,0.707107)
    64 PVA(G3,0.749154)
    65 PVA(Gs3,0.793701); 
    66 PVA(A3,0.840896); 
    67 PVA(As3,0.890899); 
    68 PVA(B3,0.943874)
     129static void 
     130play_view_note_cb (GtkWidget * widget, gpointer data) 
     131
     132  sw_view * view = (sw_view*) data
     133  sw_head * head = view->sample->play_head
     134  sw_framecount_t mouse_offset
     135  int k
     136  float pitch
     137   
     138  /* Retrieve the pitch. */ 
     139  k = GPOINTER_TO_INT(gtk_object_get_user_data (GTK_OBJECT(widget))); 
     140  pitch = notes[k].pitch
    69141 
    70 PVA(C4,1.0); 
     142  if (head->going) { 
     143    head_set_rate (head, pitch); 
     144    mouse_offset = 
     145      sample_display_get_mouse_offset (SAMPLE_DISPLAY(view->display)); 
     146    head_set_offset (head, mouse_offset); 
     147  } else { 
     148    play_view_all_pitch (view, pitch); 
     149  } 
    71150 
    72 PVA(Cs4,1.059463); 
    73 PVA(D4,1.122462);  
    74 PVA(Ds4,1.189207); 
    75 PVA(E4,1.259921); 
    76 PVA(F4,1.334840); 
    77 PVA(Fs4,1.414214); 
    78 PVA(G4,1.498307); 
    79 PVA(Gs4,1.587401); 
    80 PVA(A4,1.681793); 
    81 PVA(As4,1.781797); 
    82 PVA(B4,1.887749); 
    83 PVA(C5,2.0); 
    84 PVA(Cs5,2.118926); 
    85 PVA(D5,2.244924); 
    86 PVA(Ds5,2.378414); 
    87 PVA(E5,2.519842); 
    88 PVA(F5,2.669680); 
    89 PVA(Fs5,2.828427); 
    90 PVA(G5,2.996614); 
    91 PVA(Gs5,3.174802); 
    92 PVA(A5,3.363586); 
    93 PVA(As5,3.563595); 
    94 PVA(B5,3.775497); 
     151
     152 
  • trunk/sweep/src/notes.h

    r7 r124  
    1919 */ 
    2020 
    21 #ifndef __NOTES_H___ 
     21#ifndef __NOTES_H__ 
    2222#define __NOTES_H__ 
    2323 
    24 /* 
    25  * This _SHOULD_ be handled more nicely, and dynamically. 
    26  * 
    27  * But ... it isn't. Feel free to fix it :) 
    28  */ 
    29  
    30 #define PVAh(n) \ 
    31 void                                                                     \ 
    32 play_view_all_##n##_cb (GtkWidget * widget, gpointer data) 
    33  
    34 PVAh(C3); 
    35 PVAh(Cs3); 
    36 PVAh(D3); 
    37 PVAh(Ds3); 
    38 PVAh(E3); 
    39 PVAh(F3); 
    40 PVAh(Fs3); 
    41 PVAh(G3); 
    42 PVAh(Gs3); 
    43 PVAh(A3); 
    44 PVAh(As3); 
    45 PVAh(B3); 
    46  
    47 PVAh(C4); 
    48  
    49 PVAh(Cs4); 
    50 PVAh(D4); 
    51 PVAh(Ds4); 
    52 PVAh(E4); 
    53 PVAh(F4); 
    54 PVAh(Fs4); 
    55 PVAh(G4); 
    56 PVAh(Gs4); 
    57 PVAh(A4); 
    58 PVAh(As4); 
    59 PVAh(B4); 
    60 PVAh(C5); 
    61 PVAh(Cs5); 
    62 PVAh(D5); 
    63 PVAh(Ds5); 
    64 PVAh(E5); 
    65 PVAh(F5); 
    66 PVAh(Fs5); 
    67 PVAh(G5); 
    68 PVAh(Gs5); 
    69 PVAh(A5); 
    70 PVAh(As5); 
    71 PVAh(B5); 
     24void noteplay_setup (GtkWidget *subsubmenu, sw_view * view, GtkAccelGroup *accel_group) ; 
    7225 
    7326#endif /* __NOTES_H__ */ 
  • trunk/sweep/src/param.c

    r108 r124  
    1919 */ 
    2020 
     21#ifdef HAVE_CONFIG_H 
     22#  include <config.h> 
     23#endif 
     24 
    2125#include <stdio.h> 
     26#include <string.h> 
     27#include <math.h> 
     28 
    2229#include <sweep/sweep_i18n.h> 
    2330#include <sweep/sweep_types.h> 
    2431#include "sweep_app.h" 
     32#include "interface.h" 
     33 
     34#include "../pixmaps/ladlogo.xpm" 
     35 
     36extern GtkStyle * style_bw; 
    2537 
    2638static gint 
     
    103115  switch (type) { 
    104116  case SWEEP_TYPE_BOOL: 
    105     if (p.b) snprintf (s, n, "TRUE"); 
    106     else snprintf (s, n, "FALSE"); 
     117    if (p.b) snprintf (s, n, _("TRUE")); 
     118    else snprintf (s, n, _("FALSE")); 
    107119    break; 
    108120  case SWEEP_TYPE_INT: 
     
    205217  sw_param_set pset; 
    206218  GtkWidget * window; 
    207   GtkWidget * frame
    208   GtkWidget * vbox
     219  GtkWidget * scrolled
     220  GtkWidget * table
    209221  sw_ps_widget * widgets; 
    210222  GList * plsk_list; 
     
    224236  ps->window = window; 
    225237 
    226   ps->frame = NULL; 
    227   ps->vbox = NULL; 
     238  ps->scrolled = NULL; 
     239  ps->table = NULL; 
    228240 
    229241  ps->widgets = g_malloc (sizeof (sw_ps_widget) * proc->nr_params); 
     
    348360 
    349361static GtkWidget * 
    350 create_param_set_vbox (sw_ps_adjuster * ps) 
     362create_param_set_table (sw_ps_adjuster * ps) 
    351363{ 
    352364  gint i, j; 
     
    363375  gchar buf[BUF_LEN]; 
    364376 
    365   GtkWidget * vbox
     377  GtkWidget * table
    366378  GtkWidget * hbox; 
    367379  GtkWidget * label; 
     
    374386  GtkObject * adj; 
    375387  gfloat value, lower, upper, step_inc, page_inc, page_size; 
    376  
    377   vbox = gtk_vbox_new (FALSE, 2); 
    378  
    379   for (i=0; i < proc->nr_params; i++) { 
    380     hbox = gtk_hbox_new (FALSE, 4); 
    381     gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 0); 
    382     gtk_widget_show (hbox); 
    383      
     388  gint digits = 1; /* nr. of decimal places to show on hscale */ 
     389 
     390  table = gtk_table_new (proc->nr_params, 2, FALSE); 
     391 
     392  for (i=0; i < proc->nr_params; i++) {     
    384393    pspec = &proc->param_specs[i]; 
    385394 
    386395    if (pspec->type == SWEEP_TYPE_BOOL) { 
    387396 
    388       checkbutton = gtk_check_button_new_with_label (pspec->name); 
    389       gtk_box_pack_start (GTK_BOX(hbox), checkbutton, FALSE, TRUE, 0); 
     397      checkbutton = gtk_check_button_new_with_label (_(pspec->name)); 
     398      gtk_table_attach (GTK_TABLE (table), checkbutton, 0, 2, i, i+1, 
     399                        GTK_FILL, GTK_FILL, 0, 0); 
    390400 
    391401      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), 
     
    403413    } else { 
    404414 
    405       label = gtk_label_new (pspec->name); 
    406       gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0); 
     415      hbox = gtk_hbox_new (FALSE, 0); 
     416      gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, i, i+1, 
     417                        GTK_FILL|GTK_SHRINK, GTK_SHRINK, 4, 4); 
     418      gtk_widget_show (hbox); 
     419 
     420      label = gtk_label_new (_(pspec->name)); 
     421      gtk_box_pack_end (GTK_BOX(hbox), label, FALSE, FALSE, 4); 
    407422      gtk_widget_show (label); 
    408423 
     
    410425 
    411426        optionmenu = gtk_option_menu_new (); 
    412         gtk_box_pack_start (GTK_BOX(hbox), optionmenu, FALSE, FALSE, 0); 
     427        gtk_table_attach (GTK_TABLE (table), optionmenu, 1, 2, i, i+1, 
     428                          GTK_FILL|GTK_EXPAND, GTK_SHRINK, 0, 0); 
    413429        gtk_widget_show (optionmenu); 
    414430 
     
    449465#define ADJUSTER_NUMERIC(T, DIGITS) \ 
    450466                                                                           \ 
    451         value = (gfloat) pset[i].##T##;                                    \ 
     467        value = (gfloat) pset[i].T;                                        \ 
    452468                                                                           \ 
    453469        if (pspec->constraint_type == SW_PARAM_CONSTRAINED_NOT) {          \ 
     
    458474                                                                           \ 
    459475        if (valid & SW_RANGE_LOWER_BOUND_VALID) {                          \ 
    460           lower = (gfloat) pspec->constraint.range->lower.##T##;           \ 
     476          lower = (gfloat) pspec->constraint.range->lower.T;               \ 
    461477        } else {                                                           \ 
    462478          lower = G_MINFLOAT;                                              \ 
     
    464480                                                                           \ 
    465481        if (valid & SW_RANGE_UPPER_BOUND_VALID) {                          \ 
    466           upper = (gfloat) pspec->constraint.range->upper.##T##;           \ 
     482          upper = (gfloat) pspec->constraint.range->upper.T;               \ 
    467483        } else {                                                           \ 
    468484          upper = G_MAXFLOAT;                                              \ 
     
    470486                                                                           \ 
    471487        if (valid & SW_RANGE_STEP_VALID) {                                 \ 
    472           step_inc = (gfloat) pspec->constraint.range->step.##T##;         \ 
    473         } else {                                                           \ 
     488          step_inc = (gfloat) pspec->constraint.range->step.T;             \ 
     489        } else if (lower != G_MINFLOAT && upper != G_MAXFLOAT) {           \ 
     490          step_inc = (upper - lower) / 100.0;                              \ 
     491        } else {                                                           \ 
    474492          step_inc = (gfloat) 0.01;                                        \ 
    475493        }                                                                  \ 
    476494        page_inc = step_inc;                                               \ 
    477495        page_size = step_inc;                                              \ 
     496        if (step_inc < 1.0)                                                \ 
     497          digits = - (gint)ceil(log10((double)step_inc));                  \ 
     498        else                                                               \ 
     499          digits = 1;                                                      \ 
    478500                                                                           \ 
    479501        adj = gtk_adjustment_new (value, lower, upper, step_inc,           \ 
     
    482504        if ( (valid & SW_RANGE_LOWER_BOUND_VALID) &&                       \ 
    483505             (valid & SW_RANGE_UPPER_BOUND_VALID)) {                       \ 
     506          GTK_ADJUSTMENT(adj)->upper += step_inc;                          \ 
    484507          num_widget = gtk_hscale_new (GTK_ADJUSTMENT(adj));               \ 
    485           gtk_box_pack_start (GTK_BOX(hbox), num_widget, TRUE, TRUE, 0);   \ 
     508          gtk_scale_set_digits (GTK_SCALE(num_widget), digits);            \ 
     509          gtk_widget_set_usize (num_widget, 75, -1);                       \ 
     510          gtk_table_attach (GTK_TABLE (table), num_widget, 1, 2, i, i+1,   \ 
     511                            GTK_FILL|GTK_EXPAND, GTK_SHRINK, 0, 0);        \ 
    486512        } else {                                                           \ 
    487513          num_widget = gtk_spin_button_new (GTK_ADJUSTMENT(adj),           \ 
     
    493519                                         TRUE);                            \ 
    494520          gtk_widget_set_usize (num_widget, 75, -1);                       \ 
    495           gtk_box_pack_start (GTK_BOX(hbox), num_widget, TRUE, TRUE, 0);   \ 
     521          gtk_table_attach (GTK_TABLE (table), num_widget, 1, 2, i, i+1,   \ 
     522                            GTK_FILL|GTK_EXPAND, GTK_SHRINK, 0, 0);        \ 
    496523        }                                                                  \ 
    497524                                                                           \ 
     
    508535  } 
    509536 
    510   return vbox; 
     537  return table; 
     538 
     539#undef BUF_LEN 
    511540} 
    512541 
     
    519548  sw_ps_adjuster * ps = (sw_ps_adjuster *)data; 
    520549 
    521   GtkWidget * vbox
     550  GtkWidget * table
    522551 
    523552  if (ps->proc->suggest) { 
     
    526555  } 
    527556 
    528   gtk_widget_destroy (ps->vbox); 
    529  
    530   vbox = create_param_set_vbox (ps); 
    531   gtk_container_add (GTK_CONTAINER(ps->frame), vbox); 
    532   gtk_widget_show (vbox); 
    533  
    534   ps->vbox = vbox; 
     557  gtk_widget_destroy (ps->table); 
     558 
     559  table = create_param_set_table (ps); 
     560  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (ps->scrolled), 
     561                                         table); 
     562  gtk_widget_show (table); 
     563 
     564  ps->table = table; 
    535565} 
    536566 
     
    541571  sw_ps_adjuster * ps; 
    542572 
     573  GtkStyle * style; 
     574 
    543575  GtkWidget * window; 
    544576  GtkWidget * main_vbox; 
     577  GtkWidget * pixmap; 
     578  GtkWidget * label; 
     579  GtkWidget * scrolled; 
     580  GtkWidget * ebox; 
     581  GtkWidget * hbox; 
    545582  GtkWidget * vbox; 
    546   GtkWidget * hbox
     583  GtkWidget * table
    547584  GtkWidget * frame; 
    548   GtkWidget * button; 
    549  
    550   window = gtk_window_new (GTK_WINDOW_TOPLEVEL); 
    551   gtk_window_set_title (GTK_WINDOW(window), proc->name); 
     585  GtkWidget * button, * ok_button; 
     586 
     587  /* Place the meta info about the plugin in a text widget (white background) 
     588   *  aligned to the left of the parameter settings by defining _USE_TEXT 
     589   */ 
     590/*#define _USE_TEXT*/ 
     591 
     592#ifdef _USE_TEXT 
     593  GtkWidget * text; 
     594  GdkFont * font; 
     595 
     596#define BUF_LEN 1024 
     597  gchar buf[BUF_LEN]; 
     598  gint n; 
     599 
     600#endif /* _USE_TEXT */ 
     601 
     602  window = gtk_dialog_new (); 
     603  gtk_window_set_title (GTK_WINDOW(window), _(proc->name)); 
     604  /*  gtk_container_border_width (GTK_CONTAINER (window), 8);*/ 
    552605 
    553606  ps = ps_adjuster_new (proc, view, pset, window); 
     
    555608  gtk_signal_connect (GTK_OBJECT(window), "destroy", 
    556609                      GTK_SIGNAL_FUNC(param_set_cancel_cb), ps); 
    557    
     610 
     611#ifdef _USE_TEXT 
     612  hbox = gtk_hbox_new (FALSE, 0); 
     613  gtk_box_pack_start (GTK_BOX (GTK_DIALOG(window)->vbox), hbox, TRUE, TRUE, 0); 
     614  gtk_widget_show (hbox); 
     615 
     616  text = gtk_text_new (NULL, NULL); 
     617  gtk_text_set_editable (GTK_TEXT (text), FALSE); 
     618  gtk_text_set_word_wrap (GTK_TEXT (text), FALSE); 
     619  gtk_widget_set_usize (text, 320, -1); 
     620  gtk_box_pack_start (GTK_BOX (hbox), text, FALSE, FALSE, 0); 
     621  gtk_widget_show (text); 
     622 
    558623  main_vbox = gtk_vbox_new (FALSE, 0); 
    559   gtk_container_add (GTK_CONTAINER(window), main_vbox); 
     624  gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0); 
    560625  gtk_widget_show (main_vbox); 
    561626 
     627  vbox = main_vbox; 
     628 
     629  gtk_text_freeze (GTK_TEXT (text)); 
     630 
     631#else 
     632 
     633  main_vbox = GTK_DIALOG(window)->vbox; 
     634 
     635  ebox = gtk_event_box_new (); 
     636  gtk_box_pack_start (GTK_BOX(main_vbox), ebox, FALSE, FALSE, 0); 
     637  gtk_widget_set_style (ebox, style_bw); 
     638  gtk_widget_show (ebox); 
     639 
    562640  hbox = gtk_hbox_new (FALSE, 0); 
    563   gtk_box_pack_start (GTK_BOX(main_vbox), hbox, FALSE, FALSE, 0); 
     641  gtk_container_add (GTK_CONTAINER(ebox), hbox);   
     642  gtk_container_set_border_width (GTK_CONTAINER(hbox), 4); 
    564643  gtk_widget_show (hbox); 
    565644 
    566   button = gtk_button_new_with_label (_("Suggest")); 
    567   gtk_box_pack_start (GTK_BOX(hbox), button, FALSE, FALSE, 0); 
     645  pixmap = create_widget_from_xpm (window, ladlogo_xpm); 
     646  gtk_box_pack_start (GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); 
     647  gtk_widget_show (pixmap); 
     648 
     649  vbox = gtk_vbox_new (FALSE, 0); 
     650  gtk_box_pack_start (GTK_BOX(hbox), vbox, TRUE, TRUE, 0); 
     651  gtk_widget_show (vbox); 
     652 
     653 
     654#endif 
     655 
     656  if (proc->name != NULL) { 
     657 
     658#ifdef _USE_TEXT 
     659    font = 
     660      gdk_font_load("-Adobe-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*"); 
     661 
     662    n = snprintf (buf, BUF_LEN, "%s\n\n", _(proc->name)); 
     663 
     664    gtk_text_insert (GTK_TEXT (text), font, NULL, NULL, buf, n); 
     665 
     666#else 
     667 
     668    style = gtk_style_new (); 
     669    gdk_font_unref (style->font); 
     670    style->font = 
     671      gdk_font_load("-adobe-helvetica-medium-r-normal-*-*-180-*-*-*-*-*-*"); 
     672    gtk_widget_push_style (style); 
     673 
     674    label = gtk_label_new (_(proc->name)); 
     675    gtk_misc_set_padding (GTK_MISC (label), 10, 10); 
     676    gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 0); 
     677    gtk_widget_show (label); 
     678 
     679    gtk_widget_pop_style (); 
     680 
     681#endif 
     682  } 
     683 
     684#ifdef _USE_TEXT 
     685  n = 0; 
     686 
     687  if (proc->description != NULL) { 
     688    n = snprintf (buf, BUF_LEN, "%s\n\n", _(proc->description)); 
     689  } 
     690 
     691  if (proc->author != NULL) { 
     692    n += snprintf (buf+n, BUF_LEN, "by %s", proc->author); 
     693  } 
     694 
     695  if (proc->copyright != NULL) { 
     696    n += snprintf (buf+n, BUF_LEN, ", %s.\n", proc->copyright); 
     697  } 
     698 
     699  if (proc->url != NULL) { 
     700    n += snprintf (buf+n, BUF_LEN, "\nFor more information see\n%s\n", 
     701                   proc->url); 
     702  } 
     703 
     704  if (n > 0) { 
     705    gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL, buf, n); 
     706  } 
     707 
     708  gtk_text_thaw (GTK_TEXT (text)); 
     709 
     710#else 
     711  if (proc->description != NULL) { 
     712    label = gtk_label_new (_(proc->description)); 
     713    gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 0); 
     714    gtk_widget_show (label); 
     715  } 
     716 
     717  if (proc->author != NULL) { 
     718    label = gtk_label_new (proc->author); 
     719    gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 0); 
     720    gtk_widget_show (label); 
     721  } 
     722 
     723  if (proc->copyright != NULL) { 
     724    label = gtk_label_new (proc->copyright); 
     725    gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 0); 
     726    gtk_widget_show (label); 
     727  } 
     728 
     729  if (proc->url != NULL) { 
     730    label = gtk_label_new (proc->url); 
     731    gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 0); 
     732    gtk_widget_show (label); 
     733  } 
     734#endif 
     735 
     736  hbox = gtk_hbox_new (FALSE, 0); 
     737  gtk_box_pack_start (GTK_BOX(main_vbox), hbox, TRUE, TRUE, 8); 
     738  gtk_widget_show (hbox); 
     739 
     740  frame = gtk_frame_new (_("Parameters")); 
     741  gtk_box_pack_start (GTK_BOX(hbox), frame, TRUE, TRUE, 8); 
     742  gtk_widget_show (frame); 
     743 
     744  vbox = gtk_vbox_new (FALSE, 4); 
     745  gtk_container_add (GTK_CONTAINER (frame), vbox); 
     746  gtk_container_set_border_width (GTK_CONTAINER(vbox), 8); 
     747  gtk_widget_show (vbox); 
     748 
     749  button = gtk_button_new_with_label (_("Defaults")); 
     750  gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, FALSE, 8); 
    568751  gtk_widget_show (button); 
    569752  gtk_signal_connect (GTK_OBJECT(button), "clicked", 
    570753                      GTK_SIGNAL_FUNC (param_set_suggest_cb), ps); 
    571754 
    572   frame = gtk_frame_new (NULL); 
    573   gtk_box_pack_start (GTK_BOX(main_vbox), frame, FALSE, FALSE, 0); 
     755  scrolled = gtk_scrolled_window_new (NULL, NULL); 
     756  gtk_widget_set_usize (scrolled, -1, 240); 
     757  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), 
     758                                  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); 
     759  gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 8); 
     760  gtk_widget_show (scrolled); 
     761 
     762  table = create_param_set_table (ps); 
     763  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled), 
     764                                         table); 
     765  gtk_widget_show (table); 
     766 
     767  ps->scrolled = scrolled; 
     768  ps->table = table; 
     769 
     770#if 0 
     771  frame = gtk_frame_new (_("Preview")); 
     772  gtk_box_pack_start (GTK_BOX(hbox), frame, TRUE, TRUE, 8); 
    574773  gtk_widget_show (frame); 
    575774 
    576   vbox = create_param_set_vbox (ps); 
    577   gtk_container_add (GTK_CONTAINER(frame), vbox); 
     775  vbox = gtk_vbox_new (FALSE, 4); 
     776  gtk_container_add (GTK_CONTAINER (frame), vbox); 
     777  gtk_container_set_border_width (GTK_CONTAINER(vbox), 8); 
    578778  gtk_widget_show (vbox); 
    579  
    580   ps->frame = frame; 
    581   ps->vbox = vbox; 
    582  
    583   hbox = gtk_hbox_new (FALSE, 0); 
    584   gtk_box_pack_start (GTK_BOX(main_vbox), hbox, FALSE, FALSE, 4); 
    585   gtk_widget_show (hbox); 
    586  
    587   button = gtk_button_new_with_label (_("OK")); 
    588   gtk_box_pack_start (GTK_BOX(hbox), button, TRUE, FALSE, 0); 
    589   gtk_widget_show (button); 
    590   gtk_signal_connect (GTK_OBJECT(button), "clicked", 
     779#endif 
     780 
     781  ok_button = gtk_button_new_with_label (_("OK")); 
     782  GTK_WIDGET_SET_FLAGS (GTK_WIDGET (ok_button), GTK_CAN_DEFAULT); 
     783  gtk_box_pack_start (GTK_BOX (GTK_DIALOG(window)->action_area), ok_button, 
     784                      TRUE, TRUE, 0); 
     785  gtk_widget_show (ok_button); 
     786  gtk_signal_connect (GTK_OBJECT(ok_button), "clicked", 
    591787                      GTK_SIGNAL_FUNC (param_set_apply_cb), ps); 
     788   
    592789 
    593790  button = gtk_button_new_with_label (_("Cancel")); 
    594   gtk_box_pack_start (GTK_BOX(hbox), button, TRUE, FALSE, 0); 
     791  GTK_WIDGET_SET_FLAGS (GTK_WIDGET (button), GTK_CAN_DEFAULT); 
     792  gtk_box_pack_start (GTK_BOX (GTK_DIALOG(window)->action_area), button, 
     793                      TRUE, TRUE, 0); 
    595794  gtk_widget_show (button); 
    596795  gtk_signal_connect (GTK_OBJECT(button), "clicked", 
    597796                      GTK_SIGNAL_FUNC (param_set_cancel_cb), ps); 
    598797 
     798  gtk_widget_grab_default (ok_button); 
     799 
    599800  gtk_widget_show (window); 
    600801 
  • trunk/sweep/src/pixmaps.h

    r7 r124  
    1919 */ 
    2020 
    21  
     21#if 0 
    2222static char *rect_xpm [] = 
    2323{ 
     
    183183  "                      ", 
    184184  "                      "}; 
     185#endif 
  • trunk/sweep/src/plugin.c

    r58 r124  
    3333#include <gmodule.h> 
    3434 
     35#include <sweep/sweep_i18n.h> 
    3536#include <sweep/sweep_version.h> 
    3637#include <sweep/sweep_types.h> 
     
    3839 
    3940GList * plugins = NULL; 
     41 
     42static gint 
     43cmp_proc_names (sw_procedure * a, sw_procedure * b) 
     44{ 
     45  return strcmp (_(a->name), _(b->name)); 
     46} 
    4047 
    4148void 
     
    6168    for (gl = m_plugin->plugin_init (); 
    6269         gl; gl = gl->next) { 
    63       plugins = g_list_append (plugins, (sw_procedure *)gl->data); 
     70      plugins = g_list_insert_sorted (plugins, (sw_procedure *)gl->data, 
     71                                      (GCompareFunc)cmp_proc_names); 
    6472    } 
    6573  } 
     
    139147    init_dynamic_plugins (); 
    140148  } 
     149 
     150 
    141151} 
  • trunk/sweep/src/print.c

    r57 r124  
    1919 */ 
    2020 
     21#ifdef HAVE_CONFIG_H 
     22#  include <config.h> 
     23#endif 
     24 
    2125#include <stdio.h> 
    2226#include <string.h> 
     
    2933 * using standard abbreviations (GB, MB, kB, byte[s]) 
    3034 */ 
    31 void 
     35int 
    3236snprint_bytes (gchar * s, gint n, glong nr_bytes) 
    3337{ 
    3438  if (nr_bytes > (1L<<30)) { 
    35     snprintf (s, n, "%0.3f GB", 
    36              (gfloat)nr_bytes / (1024.0 * 1024.0 * 1024.0)); 
     39    return snprintf (s, n, "%0.3f GB", 
     40                    (gfloat)nr_bytes / (1024.0 * 1024.0 * 1024.0)); 
    3741  } else if (nr_bytes > (1L<<20)) { 
    38     snprintf (s, n, "%0.3f MB", 
    39              (gfloat)nr_bytes / (1024.0 * 1024.0)); 
     42    return snprintf (s, n, "%0.3f MB", 
     43                    (gfloat)nr_bytes / (1024.0 * 1024.0)); 
    4044  } else if (nr_bytes > (1L<<10)) { 
    41     snprintf (s, n, "%0.3f kB", 
    42              (gfloat)nr_bytes / (1024.0)); 
     45    return snprintf (s, n, "%0.3f kB", 
     46                    (gfloat)nr_bytes / (1024.0)); 
    4347  } else if (nr_bytes == 1) { 
    44     snprintf (s, n, "1 byte"); 
     48    return snprintf (s, n, "1 byte"); 
    4549  } else { 
    46     snprintf (s, n, "%ld bytes", nr_bytes); 
     50    return snprintf (s, n, "%ld bytes", nr_bytes); 
    4751  } 
    4852} 
     
    5155 * Print a time in the format HH:MM:SS.sss 
    5256 */ 
    53 void 
     57int 
    5458snprint_time (gchar * s, gint n, sw_time_t time) 
    5559{ 
     
    6670  sec = time - ((sw_time_t)hrs * 3600.0)- ((sw_time_t)min * 60.0); 
    6771 
    68   snprintf (s, n, "%s%d:%02d:%02.3f", sign, hrs, min, sec); 
     72  /* XXX: %02.3f workaround */ 
     73  if (sec < 10.0) { 
     74    return snprintf (s, n, "%s%02d:%02d:0%2.3f", sign, hrs, min, sec); 
     75  } else { 
     76    return snprintf (s, n, "%s%02d:%02d:%02.3f", sign, hrs, min, sec); 
     77  } 
    6978} 
    7079 
     
    7281 * Print a time in SMPTE format 
    7382 */ 
    74 void 
     83int 
    7584snprint_time_smpte (gchar * s, gint n, sw_time_t time, gint F) 
    7685{ 
     
    8695 
    8796  if (hrs > 0.0) 
    88     snprintf (s, n, "PT%.0fH%.0fM%.0fS%.0fN%dF", hrs, min, sec, N, F); 
     97    return snprintf (s, n, "PT%.0fH%.0fM%.0fS%.0fN%dF", hrs, min, sec, N, F); 
    8998  else if (min > 0.0) 
    90     snprintf (s, n, "PT%.0fM%.0fS%.0fN%dF", min, sec, N, F); 
     99    return snprintf (s, n, "PT%.0fM%.0fS%.0fN%dF", min, sec, N, F); 
    91100  else if (sec > 0.0) 
    92     snprintf (s, n, "PT%.0fS%.0fN%dF", sec, N, F); 
     101    return snprintf (s, n, "PT%.0fS%.0fN%dF", sec, N, F); 
    93102  else if (N > 0.0) 
    94     snprintf (s, n, "PT%.0fN%dF", N, F); 
     103    return snprintf (s, n, "PT%.0fN%dF", N, F); 
    95104  else 
    96     snprintf (s, n, "P0S"); 
     105    return snprintf (s, n, "P0S"); 
    97106} 
     107 
     108double 
     109strtime_to_seconds (char * str) 
     110{ 
     111  int h=0,m=0, n; 
     112  float s; 
     113  double result; 
     114 
     115  n = sscanf (str, "%d:%d:%f",  &h, &m, &s); 
     116  if (n == 3) { 
     117    goto done; 
     118  } 
     119 
     120  n = sscanf (str, "%d:%f",  &m, &s); 
     121  if (n == 2) { 
     122    h = 0; 
     123    goto done; 
     124  } 
     125 
     126  n = sscanf (str, "%f", &s); 
     127  if (n == 1) { 
     128    h = 0; m = 0; 
     129    goto done; 
     130  } 
     131   
     132  return -1.0; 
     133 
     134done: 
     135 
     136  result = ((h * 3600.0) + (m * 60.0) + s); 
     137 
     138  return result; 
     139} 
  • trunk/sweep/src/print.h

    r57 r124  
    2828 * using standard abbreviations (GB, MB, kB, byte[s]) 
    2929 */ 
    30 void 
     30int 
    3131snprint_bytes (gchar * s, gint n, glong nr_bytes); 
    3232 
     
    3434 * Print a time in the format HH:MM:SS.sss 
    3535 */ 
    36 void 
     36int 
    3737snprint_time (gchar * s, gint n, sw_time_t time); 
    3838 
     
    4040 * Print a time in SMPTE format 
    4141 */ 
    42 void 
     42int 
    4343snprint_time_smpte (gchar * s, gint n, sw_time_t time, gint F); 
    4444 
     45/* 
     46 * Parse a time format string (eg. 1:30:43.34) to a double 
     47 */ 
     48double 
     49strtime_to_seconds (char * str); 
     50 
    4551#endif /* __PRINT_H__ */ 
  • trunk/sweep/src/sample-display.c

    r98 r124  
    2222 */ 
    2323 
     24#ifdef HAVE_CONFIG_H 
     25#  include <config.h> 
     26#endif 
     27 
    2428#include <stdlib.h> 
     29#include <math.h> 
     30#include <time.h> 
    2531 
    2632#include "sample-display.h" 
    2733 
     34#include <gdk/gdkkeysyms.h> 
    2835#include <gtk/gtk.h> 
     36 
     37#include <sweep/sweep_i18n.h> 
    2938 
    3039#include "sweep_app.h" 
    3140#include "sample.h" 
     41#include "head.h" 
    3242#include "cursors.h" 
    33  
    34 /* static cursor definitions */ 
    35 #include "horiz.xpm" 
    36 #include "horiz_plus.xpm" 
    37  
    38  
    39 gint current_tool = TOOL_SELECT; 
     43#include "play.h" 
     44#include "callbacks.h" 
     45#include "edit.h" 
     46#include "undo_dialog.h" 
     47 
     48/*#define DEBUG*/ 
     49 
     50#define DOUBLE_BUFFER 
     51 
     52/*#define ALWAYS_REDRAW_ALL*/ 
     53 
     54/*#define LEGACY_DRAW_MODE*/ 
     55 
     56#define SEL_SCRUBS 
     57 
     58extern GdkCursor * sweep_cursors[]; 
    4059 
    4160/* Maximum number of samples to consider per pixel */ 
     
    5271 
    5372#define XPOS_TO_OFFSET(x) \ 
    54   (s->view->start + PIXEL_TO_OFFSET(x)
     73  CLAMP(s->view->start + PIXEL_TO_OFFSET(x), 0, s->view->sample->sounddata->nr_frames
    5574 
    5675#define SAMPLE_TO_PIXEL(n) \ 
     
    6382 
    6483#define SET_CURSOR(w, c) \ 
    65   gdk_window_set_cursor (##w##->window, SAMPLE_DISPLAY_CLASS(GTK_OBJECT(##w##)->klass)->##c##) 
     84  gdk_window_set_cursor ((w)->window, sweep_cursors[SWEEP_CURSOR_##c]) 
     85 
     86#define YPOS_TO_CHANNEL(y) \ 
     87  (s->view->sample->sounddata->format->channels * y / s->height) 
     88 
     89#define CHANNEL_HEIGHT \ 
     90  (s->height / s->view->sample->sounddata->format->channels) 
     91 
     92#define YPOS_TO_VALUE(y) \ 
     93  ((sw_audio_t)(CHANNEL_HEIGHT/2 - (y - (YPOS_TO_CHANNEL(y) * CHANNEL_HEIGHT)))/(CHANNEL_HEIGHT/2)) 
     94 
     95#if 0 
     96#define YPOS_TO_CHANNEL(y) \ 
     97  (s->view->sample->sounddata->format->channels == 2 ? (y > s->height/2) : 0) 
     98 
     99#define YPOS_TO_VALUE_1(y) \ 
     100  ((sw_audio_t)(s->height/2 - y)/(s->height/2)) 
     101 
     102#define YPOS_TO_VALUE_L(y) \ 
     103  ((sw_audio_t)(s->height/4 - y)/(s->height/4)) 
     104 
     105#define YPOS_TO_VALUE_R(y) \ 
     106  ((sw_audio_t)(3*s->height/4 - y)/(s->height/4)) 
     107 
     108#define YPOS_TO_VALUE_2(y) \ 
     109  (YPOS_TO_CHANNEL(y) ? YPOS_TO_VALUE_R(y) : YPOS_TO_VALUE_L(y)) 
     110#endif 
    66111 
    67112#define MARCH_INTERVAL 300 
     113#define PULSE_INTERVAL 450 
    68114 
    69115extern sw_view * last_tmp_view; 
     
    74120                         */ 
    75121 
    76 #ifdef _MUSHROOM_BROWN 
     122#if 1 
     123 
    77124static const int default_colors[] = { 
    78   114, 114, 98,  /* bg */ 
    79   234, 234, 25,  /* fg */ 
    80   230, 0, 0,     /* mixerpos */ 
    81   40, 40, 0,     /* zero */ 
    82   240, 230, 240, /* sel */ 
    83   255, 255, 255, /* tmp_sel */ 
    84   10, 40, 10,    /* crossing */ 
    85   170, 169, 134, /* minmax */ 
    86   224, 220, 172, /* highlight */ 
    87   43, 42, 33,    /* lowlight */ 
     125  200, 200, 193,  /* bg */ 
     126  199, 203, 158,  /* fg */ 
     127  0, 0xaa, 0, /* play (mask) */ 
     128  220, 230, 255, /* user */ 
     129  100, 100, 100, /* zero */ 
     130  240, 230, 240, /* sel box */ 
     131  110, 110, 100, /* tmp_sel XOR mask */ 
     132#if 1 
     133  108, 115, 134,    /* sel bg */ 
     134#else 
     135  62, 68, 118,  /* sel bg */ 
     136#endif 
     137  166, 166, 154, /* minmax */ 
     138  240, 250, 240, /* highlight */ 
     139  81, 101, 81,   /* lowlight */ 
     140  230, 0, 0,     /* rec */ 
    88141}; 
     142 
    89143#else 
     144 
    90145static const int default_colors[] = { 
    91   182, 178, 182,  /* bg */ 
    92   199, 203, 158,  /* fg */ 
    93   230, 0, 0,     /* mixerpos */ 
    94   40, 40, 0,     /* zero */ 
    95   240, 230, 240, /* sel */ 
    96   255, 255, 255, /* tmp_sel */ 
    97   10, 40, 10,    /* crossing */ 
    98   174, 186, 174, /* minmax */ 
    99   215, 219, 215, /* highlight */ 
     146#if 0 
     147  86, 86, 80,    /* bg */ 
     148#elif 0 
     149  220, 220, 210, /* bg */ 
     150#else 
     151  200, 200, 193,    /* bg */ 
     152#endif 
     153  199, 203, 158, /* fg */ 
     154  20, 230, 0,    /* play */ 
     155  200, 200, 200, /* user */ 
     156  200, 200, 200, /* zero */ 
     157  240, 230, 240, /* sel box */ 
     158  110, 110, 100, /* tmp_sel XOR mask */ 
     159  118, 118, 108, /* sel bg XOR mask */ 
     160  154, 166, 154, /* minmax */ 
     161  219, 219, 211, /* highlight */ 
    100162  81, 101, 81,   /* lowlight */ 
     163  240, 0, 0,     /* rec */ 
    101164}; 
    102165#endif 
    103166 
     167static const int bg_colors[] = { 
     168  250, 250, 237,    /* black bg */ 
     169  200, 200, 193,    /* red bg */ 
     170  147, 147, 140,    /* orange bg */ 
     171  160, 160, 150,    /* yellow bg */ 
     172#if 0 
     173  210, 210, 193,    /* blue bg */ 
     174#else 
     175  250, 250, 237,    /* blue bg */ 
     176#endif 
     177  160, 160, 150,    /* white bg */ 
     178  0, 0, 0,          /* greenscreen bg */ 
     179  60, 70, 170,          /* bluescreen bg */ 
     180}; 
     181 
     182static const int fg_colors[] = { 
     183  80, 80, 60,    /* black fg */ 
     184  220, 80, 40,   /* red fg */ 
     185  220, 170, 120, /* orange fg */ 
     186  199, 203, 158, /* yellow fg */ 
     187  128, 138, 184, /* blue fg */ 
     188  230, 240, 255, /* white fg */ 
     189  0, 220, 0,     /* greenscreen fg */ 
     190  240, 240, 240,     /* bluescreen fg */ 
     191}; 
    104192 
    105193/* Values for s->selecting */ 
     
    109197  SELECTING_SELECTION_END, 
    110198  SELECTING_PAN_WINDOW, 
     199  SELECTING_PLAYMARKER, 
     200  SELECTING_PENCIL, 
     201  SELECTING_NOISE, 
    111202}; 
    112203 
     
    115206  SELECTION_MODE_REPLACE, 
    116207  SELECTION_MODE_INTERSECT, 
     208  SELECTION_MODE_SUBTRACT, 
     209  SELECTION_MODE_MAX 
    117210}; 
    118  
    119211 
    120212enum { 
     
    125217}; 
    126218 
     219static gchar * selection_mode_names[SELECTION_MODE_MAX] = { 
     220  N_(""), /* NONE */ 
     221  N_("New selection"), /* REPLACE */ 
     222  N_("Selection: add/modify region"), /* INTERSECT */ 
     223  N_("Selection: subtract region"), /* SUBTRACT */ 
     224}; 
     225 
    127226#define IS_INITIALIZED(s) (s->view != NULL) 
    128227 
     
    136235sample_display_refresh (SampleDisplay *s) 
    137236{ 
    138   gtk_widget_queue_draw(GTK_WIDGET(s)); 
     237  sw_sample * sample; 
     238 
     239  g_return_if_fail(s != NULL); 
     240  g_return_if_fail(IS_SAMPLE_DISPLAY(s)); 
     241 
     242  if(!IS_INITIALIZED(s)) 
     243    return; 
     244 
     245  sample = s->view->sample; 
     246 
     247  s->old_user_offset_x = s->user_offset_x = 
     248    OFFSET_TO_XPOS(sample->user_offset); 
     249 
     250  s->old_play_offset_x = s->play_offset_x = 
     251    OFFSET_TO_XPOS(sample->play_head->offset); 
     252 
     253  if (sample->rec_head != NULL) { 
     254    s->old_rec_offset_x = s->rec_offset_x = 
     255      OFFSET_TO_XPOS(sample->rec_head->offset); 
     256  } 
     257 
     258  gtk_widget_queue_draw_area (GTK_WIDGET(s), 0, 0, s->width, s->height); 
     259
     260 
     261sw_framecount_t 
     262sample_display_get_mouse_offset (SampleDisplay * s) 
     263
     264  int x, y; 
     265  GdkModifierType state; 
     266 
     267  gdk_window_get_pointer (GTK_WIDGET(s)->window, &x, &y, &state); 
     268 
     269  return XPOS_TO_OFFSET(x); 
    139270} 
    140271 
     
    146277 
    147278  s->view = view; 
    148   s->old_mixerpos = -1; 
    149   s->mixerpos = -1; 
    150          
     279  s->old_user_offset_x = -1; 
     280  s->user_offset_x = -1; 
     281  s->old_play_offset_x = -1; 
     282  s->play_offset_x = -1; 
     283 
    151284  /*  gtk_signal_emit(GTK_OBJECT(s), sample_display_signals[SIG_WINDOW_CHANGED], s->view->start, s->view->start + (s->view->end - s->view->start));*/ 
    152285         
    153 #if 0 
    154   s->old_ss = s->old_se = -1; 
    155 #endif 
    156286  s->selecting = SELECTING_NOTHING; 
    157287  s->selection_mode = SELECTION_MODE_NONE; 
     
    161291 
    162292void 
    163 sample_display_set_playmarker (SampleDisplay *s, 
    164                                int offset) 
    165 
     293sample_display_refresh_user_marker (SampleDisplay *s) 
     294
     295  sw_sample * sample; 
     296  gint x, width; 
     297 
    166298  g_return_if_fail(s != NULL); 
    167299  g_return_if_fail(IS_SAMPLE_DISPLAY(s)); 
     
    170302    return; 
    171303 
    172   if(offset != s->mixerpos) { 
    173     s->mixerpos = offset; 
    174     gtk_widget_queue_draw(GTK_WIDGET(s)); 
    175   } 
    176 
    177  
     304  sample = s->view->sample; 
     305 
     306  s->user_offset_x = OFFSET_TO_XPOS(sample->user_offset); 
     307 
     308  /* paint changed user cursor pos */ 
     309  if (s->old_user_offset_x != s->user_offset_x) { 
     310    x = CLAMP (s->old_user_offset_x - 15, 0, s->width); 
     311    width = MIN (s->width - x, 29); 
     312    gtk_widget_queue_draw_area (GTK_WIDGET(s), x, 0, width, s->height); 
     313  } 
     314   
     315  /* paint cursor */ 
     316  if (s->user_offset_x >= 0 && s->user_offset_x <= s->width) { 
     317    x = CLAMP (s->user_offset_x - 15, 0, s->width); 
     318    width = MIN (s->width - x, 29); 
     319 
     320    gtk_widget_queue_draw_area (GTK_WIDGET(s), x, 0, width, s->height); 
     321 
     322    s->old_user_offset_x = s->user_offset_x; 
     323  } 
     324
     325 
     326void 
     327sample_display_refresh_play_marker (SampleDisplay *s) 
     328
     329  sw_sample * sample; 
     330  sw_head * head; 
     331  gint x, width; 
     332 
     333  g_return_if_fail(s != NULL); 
     334  g_return_if_fail(IS_SAMPLE_DISPLAY(s)); 
     335 
     336  if(!IS_INITIALIZED(s)) 
     337    return; 
     338 
     339  sample = s->view->sample; 
     340  head = sample->play_head; 
     341 
     342  s->play_offset_x = OFFSET_TO_XPOS(head->offset); 
     343 
     344  /* paint play offset */ 
     345  if (s->old_play_offset_x != s->play_offset_x) { 
     346    x = CLAMP (s->old_play_offset_x - 15, 0, s->width); 
     347    width = MIN (s->width - x, 29); 
     348    gtk_widget_queue_draw_area (GTK_WIDGET(s), x, 0, width, s->height); 
     349  } 
     350   
     351  if (s->play_offset_x >= 0 && s->play_offset_x <= s->width) { 
     352    x = CLAMP (s->play_offset_x - 15, 0, s->width); 
     353    width = MIN (s->width - x, 29); 
     354    gtk_widget_queue_draw_area (GTK_WIDGET(s), x, 0, width, s->height); 
     355 
     356    s->old_play_offset_x = s->play_offset_x; 
     357  } 
     358
     359 
     360void 
     361sample_display_refresh_rec_marker (SampleDisplay *s) 
     362
     363  sw_sample * sample; 
     364  sw_head * rec_head; 
     365  gint x, width; 
     366 
     367  g_return_if_fail(s != NULL); 
     368  g_return_if_fail(IS_SAMPLE_DISPLAY(s)); 
     369 
     370  if(!IS_INITIALIZED(s)) 
     371    return; 
     372 
     373  sample = s->view->sample; 
     374  rec_head = sample->rec_head; 
     375 
     376  if (rec_head == NULL) return; 
     377 
     378  s->rec_offset_x = OFFSET_TO_XPOS(rec_head->offset); 
     379 
     380  /* paint rec offset */ 
     381  if (s->old_rec_offset_x != s->rec_offset_x) { 
     382    x = CLAMP (s->old_rec_offset_x - 15, 0, s->width); 
     383    width = MIN (s->width - x, 29); 
     384    gtk_widget_queue_draw_area (GTK_WIDGET(s), x, 0, width, s->height); 
     385  } 
     386   
     387  if (s->rec_offset_x >= 0 && s->rec_offset_x <= s->width) { 
     388    x = CLAMP (s->rec_offset_x - 15, 0, s->width); 
     389    width = MIN (s->width - x, 29); 
     390    gtk_widget_queue_draw_area (GTK_WIDGET(s), x, 0, width, s->height); 
     391 
     392    s->old_rec_offset_x = s->rec_offset_x; 
     393  } 
     394
     395 
     396static void 
     397sample_display_refresh_sels (SampleDisplay * s) 
     398
     399  int x, x2; 
     400  sw_sample * sample; 
     401  GList * gl; 
     402  sw_sel * sel; 
     403 
     404  g_return_if_fail(s != NULL); 
     405  g_return_if_fail(IS_SAMPLE_DISPLAY(s)); 
     406 
     407  if(!IS_INITIALIZED(s)) 
     408    return; 
     409 
     410  sample = s->view->sample; 
     411 
     412  /* paint marching ants */ 
     413     
     414  /* real selection */ 
     415  for (gl = sample->sounddata->sels; gl; gl = gl->next) { 
     416    sel = (sw_sel *)gl->data; 
     417       
     418    x = OFFSET_TO_XPOS(sel->sel_start); 
     419    x2 = OFFSET_TO_XPOS(sel->sel_end); 
     420 
     421    if ((x >= 0) && (x <= s->width)) { 
     422      gtk_widget_queue_draw_area (GTK_WIDGET(s), x, 0, 1, s->height); 
     423    } 
     424    if ((x2 >= 0) && (x2 <= s->width)) { 
     425      gtk_widget_queue_draw_area (GTK_WIDGET(s), x2, 0, 1, s->height); 
     426    } 
     427 
     428    if ((x <= s->width) && (x2 >= 0)) { 
     429      x = CLAMP (x, 0, s->width); 
     430      x2 = CLAMP (x2, 0, s->width); 
     431      gtk_widget_queue_draw_area (GTK_WIDGET(s), x, 0, x2 - x, 1); 
     432      gtk_widget_queue_draw_area (GTK_WIDGET(s), x, s->height - 1, x2 - x, 1); 
     433    } 
     434  } 
     435     
     436  /* temporary selection */ 
     437  sel = sample->tmp_sel; 
     438 
     439  if (sel) { 
     440    x = OFFSET_TO_XPOS(sel->sel_start); 
     441    x2 = OFFSET_TO_XPOS(sel->sel_end); 
     442 
     443    if ((x >= 0) && (x <= s->width)) { 
     444      gtk_widget_queue_draw_area (GTK_WIDGET(s), x, 0, 1, s->height); 
     445    } 
     446    if ((x2 >= 0) && (x2 <= s->width)) { 
     447      gtk_widget_queue_draw_area (GTK_WIDGET(s), x2, 0, 1, s->height); 
     448    } 
     449 
     450    if ((x <= s->width) && (x2 >= 0)) { 
     451      x = CLAMP (x, 0, s->width); 
     452      x2 = CLAMP (x2, 0, s->width); 
     453      gtk_widget_queue_draw_area (GTK_WIDGET(s), x, 0, x2 - x, 1); 
     454      gtk_widget_queue_draw_area (GTK_WIDGET(s), x, s->height - 1, x2 - x, 1); 
     455    } 
     456  } 
     457
     458 
     459void 
     460sample_display_set_cursor (SampleDisplay * s, GdkCursor * cursor) 
     461
     462  gdk_window_set_cursor (GTK_WIDGET(s)->window, cursor); 
     463
     464 
     465void 
     466sample_display_set_default_cursor (SampleDisplay * s) 
     467
     468  GdkCursor * cursor; 
     469 
     470  switch (s->view->current_tool) { 
     471  case TOOL_SELECT: 
     472    cursor = sweep_cursors[SWEEP_CURSOR_CROSSHAIR]; 
     473    break; 
     474  case TOOL_ZOOM: 
     475    cursor = sweep_cursors[SWEEP_CURSOR_ZOOM_IN]; 
     476    break; 
     477  case TOOL_MOVE: 
     478    cursor = sweep_cursors[SWEEP_CURSOR_MOVE]; 
     479    break; 
     480  case TOOL_SCRUB: 
     481    cursor = sweep_cursors[SWEEP_CURSOR_NEEDLE]; 
     482    break; 
     483  case TOOL_PENCIL: 
     484    cursor = sweep_cursors[SWEEP_CURSOR_PENCIL]; 
     485    break; 
     486  case TOOL_NOISE: 
     487    cursor = sweep_cursors[SWEEP_CURSOR_NOISE]; 
     488    break; 
     489  default: 
     490    cursor = NULL; 
     491    break; 
     492  } 
     493 
     494  gdk_window_set_cursor (GTK_WIDGET(s)->window, cursor); 
     495
     496 
     497static void 
     498sample_display_set_intersect_cursor (SampleDisplay * s) 
     499
     500  sw_sample * sample = s->view->sample; 
     501  GtkWidget * widget = GTK_WIDGET(s); 
     502 
     503  /* Check if there are other selection regions. 
     504   * NB. This assumes that tmp_sel has already been 
     505   * set. 
     506   */ 
     507  if (sample_sel_nr_regions(sample) > 0) { 
     508    SET_CURSOR(widget, HORIZ_PLUS); 
     509  } else { 
     510    SET_CURSOR(widget, HORIZ); 
     511  } 
     512
     513 
     514static void 
     515sample_display_set_subtract_cursor (SampleDisplay * s) 
     516
     517  sw_sample * sample = s->view->sample; 
     518  GtkWidget * widget = GTK_WIDGET(s); 
     519 
     520  /* Check if there are other selection regions. 
     521   * NB. This assumes that tmp_sel has already been 
     522   * set. 
     523   */ 
     524  if (sample_sel_nr_regions(sample) > 0) { 
     525    SET_CURSOR(widget, HORIZ_MINUS); 
     526  } else { 
     527    SET_CURSOR(widget, HORIZ); 
     528  } 
     529
    178530 
    179531void 
     
    189541  len = s->view->sample->sounddata->nr_frames; 
    190542  vlen = end - start; 
    191  
    192   g_return_if_fail(end > start); 
    193  
    194   /* Align to middle if entire length of sample is visible */ 
     543   
     544  g_return_if_fail(end >= start); 
     545 
     546 
    195547  if (vlen > len) { 
     548    /* Align to middle if entire length of sample is visible */ 
    196549    start = (len - vlen) / 2; 
    197550    end = start + vlen; 
     551  } else if (vlen == 0 && len > 0) { 
     552    /* Zoom normal if window is zero but there is data; eg. after pasting 
     553     * into an empty buffer */ 
     554    start = 0; 
     555    end = MIN (len, s->width * 1024); 
    198556  } 
    199557 
    200558  s->view->start = start; 
    201559  s->view->end = end; 
     560 
     561  sample_display_refresh_user_marker (s); 
    202562 
    203563  gtk_signal_emit(GTK_OBJECT(s), sample_display_signals[SIG_WINDOW_CHANGED]); 
     
    320680  gint attributes_mask; 
    321681  SampleDisplay *s; 
     682  gint i; 
    322683 
    323684  g_return_if_fail (widget != NULL); 
     
    333694  attributes.wclass = GDK_INPUT_OUTPUT; 
    334695  attributes.window_type = GDK_WINDOW_CHILD; 
     696#if 0 
    335697  attributes.event_mask = gtk_widget_get_events (widget) 
    336698    | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 
    337699    | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK 
    338     | GDK_LEAVE_NOTIFY_MASK; 
     700    | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | 
     701    GDK_FOCUS_CHANGE_MASK | GDK_KEY_PRESS_MASK; 
     702#else 
     703  attributes.event_mask = GDK_ALL_EVENTS_MASK; 
     704#endif 
    339705 
    340706  attributes.visual = gtk_widget_get_visual (widget); 
     
    342708 
    343709  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; 
    344   widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); 
     710  widget->window = gdk_window_new (widget->parent->window, 
     711                                   &attributes, attributes_mask); 
    345712 
    346713  widget->style = gtk_style_attach (widget->style, widget->window); 
     
    357724  gdk_gc_set_foreground(s->zeroline_gc, &SAMPLE_DISPLAY_CLASS(GTK_OBJECT(widget)->klass)->colors[SAMPLE_DISPLAYCOL_ZERO]); 
    358725 
    359   s->mixerpos_gc = gdk_gc_new(widget->window); 
    360   gdk_gc_set_foreground(s->mixerpos_gc, &SAMPLE_DISPLAY_CLASS(GTK_OBJECT(widget)->klass)->colors[SAMPLE_DISPLAYCOL_MIXERPOS]); 
    361  
     726  s->play_gc = gdk_gc_new(widget->window); 
     727  gdk_gc_set_foreground(s->play_gc, &SAMPLE_DISPLAY_CLASS(GTK_OBJECT(widget)->klass)->colors[SAMPLE_DISPLAYCOL_PLAY]); 
     728  gdk_gc_set_function (s->play_gc, GDK_OR_REVERSE); 
     729 
     730  s->user_gc = gdk_gc_new(widget->window); 
     731  gdk_gc_set_foreground(s->user_gc, &SAMPLE_DISPLAY_CLASS(GTK_OBJECT(widget)->klass)->colors[SAMPLE_DISPLAYCOL_PAUSE]); 
     732 
     733  s->rec_gc = gdk_gc_new(widget->window); 
     734  gdk_gc_set_foreground(s->rec_gc, &SAMPLE_DISPLAY_CLASS(GTK_OBJECT(widget)->klass)->colors[SAMPLE_DISPLAYCOL_REC]); 
     735   
    362736  s->sel_gc = gdk_gc_new(widget->window); 
    363737  gdk_gc_set_foreground(s->sel_gc, &SAMPLE_DISPLAY_CLASS(GTK_OBJECT(widget)->klass)->colors[SAMPLE_DISPLAYCOL_SEL]); 
     
    383757  gdk_gc_set_foreground(s->lowlight_gc, &SAMPLE_DISPLAY_CLASS(GTK_OBJECT(widget)->klass)->colors[SAMPLE_DISPLAYCOL_LOWLIGHT]); 
    384758 
     759  for (i = 0; i < VIEW_COLOR_MAX; i++) { 
     760    s->bg_gcs[i] = gdk_gc_new (widget->window); 
     761    gdk_gc_set_foreground(s->bg_gcs[i], &SAMPLE_DISPLAY_CLASS(GTK_OBJECT(widget)->klass)->bg_colors[i]); 
     762 
     763    s->fg_gcs[i] = gdk_gc_new (widget->window); 
     764    gdk_gc_set_foreground(s->fg_gcs[i], &SAMPLE_DISPLAY_CLASS(GTK_OBJECT(widget)->klass)->fg_colors[i]); 
     765  } 
    385766 
    386767  sample_display_init_display(s, attributes.width, attributes.height); 
    387768 
    388   SET_CURSOR(widget, crosshair_cr); 
     769  sample_display_set_default_cursor (s); 
    389770 
    390771  gdk_window_set_user_data (widget->window, widget); 
     
    401782                                  int channel) 
    402783{ 
    403   GdkGC *gc; 
     784  GList * gl; 
     785  GdkGC * gc, * fg_gc; 
     786  sw_sel * sel; 
     787  int x1, x2, y1; 
     788  sw_audio_t vhigh, vlow; 
    404789  sw_audio_intermediate_t totpos, totneg; 
    405790  sw_audio_t d, maxpos, avgpos, minneg, avgneg; 
    406791  sw_audio_t prev_maxpos, prev_minneg; 
    407   sw_framecount_t i, step, nr_pos, nr_neg; 
     792  sw_framecount_t i, step, nr_frames, nr_pos, nr_neg; 
    408793  sw_sample * sample; 
    409794  const int channels = s->view->sample->sounddata->format->channels; 
     
    411796  sample = s->view->sample; 
    412797 
    413   gdk_draw_rectangle(win, s->bg_gc, 
     798  fg_gc = s->fg_gcs[sample->color]; 
     799 
     800  gdk_draw_rectangle(win, s->bg_gcs[sample->color], 
    414801                     TRUE, x, y, width, height); 
    415802 
     803  /* Draw real selection */ 
     804  for (gl = sample->sounddata->sels; gl; gl = gl->next) { 
     805    sel = (sw_sel *)gl->data; 
     806 
     807    x1 = OFFSET_TO_XPOS(sel->sel_start); 
     808    x1 = CLAMP(x1, x, x+width); 
     809 
     810    x2 = OFFSET_TO_XPOS(sel->sel_end); 
     811    x2 = CLAMP(x2, x, x+width); 
     812 
     813    if (x2 - x1 > 1){  
     814      gdk_draw_rectangle (win, s->crossing_gc, TRUE, 
     815                          x1, y, x2 - x1, y + height -1); 
     816    } 
     817  } 
     818 
     819  /* Draw temporary selection */ 
     820  sel = sample->tmp_sel; 
     821 
     822  if (sel) { 
     823    if (sel->sel_start != sel->sel_end) { 
     824      x1 = OFFSET_TO_XPOS(sel->sel_start); 
     825      x1 = CLAMP(x1, x, x+width); 
     826       
     827      x2 = OFFSET_TO_XPOS(sel->sel_end); 
     828      x2 = CLAMP(x2, x, x+width); 
     829       
     830      if (x2 - x1 > 1) { 
     831        gdk_draw_rectangle (win, s->tmp_sel_gc, TRUE, 
     832                            x1, y, x2 - x1, y + height -1); 
     833      } 
     834    } 
     835  } 
     836 
     837  vhigh = s->view->vhigh; 
     838  vlow = s->view->vlow; 
     839 
     840#define YPOS(v) CLAMP(y + height - ((((v) - vlow) * height) \ 
     841                               / (vhigh - vlow)), y, y+height) 
     842 
     843  /* Draw zero and 6db lines */ 
     844  y1 = YPOS(0.5); 
    416845  gdk_draw_line(win, s->zeroline_gc, 
    417                 x, y + height/2, 
    418                 x + width - 1, y + height/2); 
     846                x, y1, x + width - 1, y1); 
     847 
     848  y1 = YPOS(0.0); 
     849  gdk_draw_line(win, s->zeroline_gc, 
     850                x, y1, x + width - 1, y1); 
     851 
     852  y1 = YPOS(-0.5); 
     853  gdk_draw_line(win, s->zeroline_gc, 
     854                x, y1, x + width - 1, y1); 
    419855 
    420856  totpos = totneg = 0.0; 
    421857  maxpos = minneg = prev_maxpos = prev_minneg = 0.0; 
     858 
     859  nr_frames = sample->sounddata->nr_frames; 
     860 
     861  /* 'step' ensures that no more than STEP_MAX values get looked at 
     862   * per pixel */ 
     863  step = MAX (1, PIXEL_TO_OFFSET(1)/STEP_MAX); 
     864 
     865#ifdef LEGACY_DRAW_MODE 
     866  { 
     867    int py, ty; 
     868    sw_audio_t peak; 
     869 
     870    py = y+height/2; 
     871 
     872    while (width >= 0) { 
     873      peak = 0; 
     874      for (i = OFFSET_RANGE(nr_frames, XPOS_TO_OFFSET(x)); 
     875           i < OFFSET_RANGE(nr_frames, XPOS_TO_OFFSET(x+1)); 
     876           i+=step) { 
     877        d = ((sw_audio_t *)sample->sounddata->data)[i*channels + channel]; 
     878        if (fabs(d) > fabs(peak)) peak = d; 
     879      } 
     880 
     881      ty = YPOS(peak); 
     882 
     883      gdk_draw_line (win, fg_gc, x-1, py, x, ty); 
     884 
     885      py = ty; 
     886 
     887      x++; 
     888      width--; 
     889    } 
     890  } 
     891 
     892#else 
     893 
     894  for (i = OFFSET_RANGE (nr_frames, XPOS_TO_OFFSET(x-1)); 
     895       i < OFFSET_RANGE (nr_frames, XPOS_TO_OFFSET(x)); 
     896       i += step) { 
     897    d = ((sw_audio_t *)sample->sounddata->data)[i*channels + channel]; 
     898    if (d >= 0) { 
     899      if (d > prev_maxpos) prev_maxpos = d; 
     900    } else { 
     901      if (d < prev_minneg) prev_minneg = d; 
     902    } 
     903  } 
    422904 
    423905  while(width >= 0) { 
     
    427909    maxpos = minneg = 0; 
    428910 
    429     /* 'step' ensures that no more than STEP_MAX values get looked at 
    430      * per pixel */ 
    431     step = MAX (1, PIXEL_TO_OFFSET(1)/STEP_MAX); 
    432  
    433     for (i = OFFSET_RANGE(sample->sounddata->nr_frames, XPOS_TO_OFFSET(x)); 
    434          i < OFFSET_RANGE(sample->sounddata->nr_frames, XPOS_TO_OFFSET(x+1)); 
     911    /* lock the sounddata against destructive ops to make sure 
     912     * sounddata->data doesn't change under us */ 
     913    g_mutex_lock (sample->ops_mutex); 
     914 
     915    for (i = OFFSET_RANGE(nr_frames, XPOS_TO_OFFSET(x)); 
     916         i < OFFSET_RANGE(nr_frames, XPOS_TO_OFFSET(x+1)); 
    435917         i+=step) { 
    436918      d = ((sw_audio_t *)sample->sounddata->data)[i*channels + channel]; 
     
    445927      } 
    446928    } 
     929 
     930    g_mutex_unlock (sample->ops_mutex); 
    447931     
    448932    if (nr_pos > 0) { 
     
    458942    } 
    459943 
    460 #define YPOS(v) (y + ((((v) - SW_AUDIO_T_MIN) * height) \ 
    461                        / (SW_AUDIO_T_MAX - SW_AUDIO_T_MIN))) 
    462  
    463944    gdk_draw_line(win, s->minmax_gc, 
    464945                  x, YPOS(maxpos), 
     
    474955                  x, YPOS(prev_minneg), 
    475956                  x, YPOS(minneg)); 
    476                
    477  
    478     gdk_draw_line(win, s->fg_gc, 
     957 
     958    gdk_draw_line(win, fg_gc, 
    479959                  x, YPOS(avgpos), 
    480960                  x, YPOS(avgneg)); 
     
    486966    width--; 
    487967  } 
     968#endif 
    488969 
    489970} 
    490971 
    491972static void 
    492 sample_display_draw_data (GdkDrawable *win, 
    493                           const SampleDisplay *s, 
    494                           int x, 
    495                           int width) 
     973sample_display_draw_data (GdkDrawable *win, const SampleDisplay *s, 
     974                          int x, int width) 
    496975{ 
    497976  const int sh = s->height; 
    498   int start_x, end_x
     977  int start_x, end_x, i, cy, cheight, cerr
    499978  const int channels = s->view->sample->sounddata->format->channels; 
    500979 
    501   if(width == 0) 
     980  if (width == 0) 
    502981    return; 
    503982 
     
    505984  g_return_if_fail(x + width <= s->width); 
    506985 
    507 #if 0 
     986#ifdef DEBUG 
    508987  g_print("draw_data: view %u --> %u, drawing x=%d, width=%d\n", 
    509988          s->view->start, s->view->end, x, width); 
     
    5481027  } 
    5491028 
    550   if (channels == 1) { 
    551     sample_display_draw_data_channel (win, s, x, 0, width, sh, 0); 
    552   } else if (channels == 2) { 
     1029#if 0 
     1030  cheight = (sh+3)/channels; 
     1031  cerr = (sh+3) - (channels * cheight); 
     1032  if (cerr == channels - 1) { 
     1033    cheight++; 
     1034    cerr = 0; 
     1035  } 
     1036  cy = 0; 
     1037#else 
     1038  cheight = sh / channels; 
     1039  cerr = sh - (channels * cheight); 
     1040  if (cerr == channels - 1) { 
     1041    cheight++; 
     1042    cerr = 0; 
     1043  } 
     1044  cy = 0; 
     1045#endif 
     1046 
     1047  for (i = 0; i < channels; i++) { 
     1048    if (i >= 0) { 
     1049      gtk_style_apply_default_background (GTK_WIDGET(s)->style, win, 
     1050                                          TRUE, GTK_STATE_NORMAL, NULL, 
     1051                                          x, cy, width, 1); 
     1052      cy += 1; 
     1053 
     1054#if 0 
     1055      if (i == channels/2) { 
     1056        gtk_style_apply_default_background (GTK_WIDGET(s)->style, win, 
     1057                                            TRUE, GTK_STATE_NORMAL, NULL, 
     1058                                            x, cy, width, cerr); 
     1059        cy += cerr; 
     1060      } 
     1061#endif 
     1062    } 
     1063 
     1064    sample_display_draw_data_channel (win, s, 
     1065                                      x, cy, width, cheight-2, i); 
     1066    cy += cheight-2; 
    5531067 
    5541068    gtk_style_apply_default_background (GTK_WIDGET(s)->style, win, 
    555                                         TRUE, GTK_STATE_NORMAL, 
    556                                         NULL, 
    557                                         x, (sh/2)-1, 
    558                                         width, 3); 
    559  
    560     sample_display_draw_data_channel (win, s, 
    561                                       x, 0, 
    562                                       width, (sh/2)-1, 0); 
    563     sample_display_draw_data_channel (win, s, 
    564                                       x, sh-((sh/2)-1), 
    565                                       width, (sh/2)-1, 1); 
    566  
     1069                                        TRUE, GTK_STATE_NORMAL, NULL, 
     1070                                        x, cy, width, 1); 
     1071    cy += 1; 
     1072 
     1073  } 
     1074 
     1075  if (cy < sh) { 
     1076    gtk_style_apply_default_background (GTK_WIDGET(s)->style, win, 
     1077                                        TRUE, GTK_STATE_NORMAL, NULL, 
     1078                                        x, cy, width, sh-cy); 
    5671079  } 
    5681080 
     
    5911103  cy2 = ((sw_audio_t *)sample->sounddata->data)[OFFSET_RANGE(sample->sounddata->nr_frames, XPOS_TO_OFFSET(x)) + cx2]; 
    5921104   
    593   gdk_draw_line(s->backing_pixmap, s->crossing_gc, 
     1105  gdk_draw_line(win, s->crossing_gc, 
    5941106                x - cx1, (((cy1 + 1.0) * sh) / 2.0), 
    5951107                x + cx2, (((cy2 + 1.0) * sh) / 2.0)); 
     
    6181130  dash_offset %= 8; 
    6191131 
    620   gtk_widget_queue_draw (GTK_WIDGET(s)); 
     1132  sample_display_refresh_sels (s); 
    6211133 
    6221134  return TRUE; 
    6231135} 
    6241136 
    625 void 
    626 sample_display_start_marching_ants (SampleDisplay * s) 
    627 
     1137static void 
     1138sd_start_marching_ants_timeout (SampleDisplay * s) 
     1139
     1140  if (s->marching_tag > 0) 
     1141    gtk_timeout_remove (s->marching_tag); 
     1142 
    6281143  s->marching_tag = gtk_timeout_add (MARCH_INTERVAL, 
    6291144                                     (GtkFunction)sd_march_ants, 
     
    6321147 
    6331148void 
    634 sample_display_stop_marching_ants (SampleDisplay * s) 
     1149sample_display_start_marching_ants (SampleDisplay * s) 
     1150
     1151  sd_start_marching_ants_timeout (s); 
     1152  s->marching = TRUE; 
     1153
     1154 
     1155static void 
     1156sd_stop_marching_ants_timeout (SampleDisplay * s) 
    6351157{ 
    6361158  if (s->marching_tag > 0) 
     
    6381160 
    6391161  s->marching_tag = 0; 
     1162} 
     1163 
     1164void 
     1165sample_display_stop_marching_ants (SampleDisplay * s) 
     1166{ 
     1167  sd_stop_marching_ants_timeout (s); 
     1168  s->marching = FALSE; 
    6401169} 
    6411170 
     
    7041233 
    7051234    x = OFFSET_TO_XPOS(sel->sel_start); 
     1235    x2 = OFFSET_TO_XPOS(sel->sel_end); 
     1236 
     1237    if (x > x_max) break; 
     1238    if (x2 < x_min) continue; 
     1239 
    7061240    l_end = (x >= x_min) && (x <= x_max); 
     1241    x = CLAMP (x, x_min, x_max); 
    7071242     
    708     x2 = OFFSET_TO_XPOS(sel->sel_end); 
    7091243    r_end = (x2 >= x_min) && (x2 <= x_max); 
     1244    x2 = CLAMP (x2, x_min, x_max); 
    7101245     
    7111246    /* draw the selection */ 
    712     sample_display_draw_sel_box(s->backing_pixmap, s->sel_gc, 
     1247    sample_display_draw_sel_box(win, s->sel_gc, 
    7131248                                s, x, x2 - x - 1, 
    7141249                                l_end, r_end /* draw_ends */); 
     
    7231258    x = OFFSET_TO_XPOS(sel->sel_start); 
    7241259    l_end = (x >= x_min) && (x <= x_max); 
    725    
     1260    x = CLAMP (x, x_min, x_max); 
     1261 
    7261262    x2 = OFFSET_TO_XPOS(sel->sel_end); 
    7271263    r_end = (x2 >= x_min) && (x2 <= x_max); 
    728    
     1264    x2 = CLAMP (x2, x_min, x_max); 
     1265 
    7291266    /* draw the selection */ 
    730     sample_display_draw_sel_box(s->backing_pixmap, s->tmp_sel_gc, 
     1267    sample_display_draw_sel_box(win, s->tmp_sel_gc, 
    7311268                                s, x, x2 - x - 1, 
    7321269                                l_end, r_end /* draw_ends */); 
     
    7351272 
    7361273 
    737 /*** PLAY MARKER ***/ 
     1274/*** PLAY MARKER, CURSOR ***/ 
    7381275 
    7391276#if 0 
     
    7771314#endif /* _{start,end}offset_to_xpos */ 
    7781315 
     1316static gint 
     1317sd_pulse_cursor (gpointer data) 
     1318{ 
     1319  SampleDisplay * s = (SampleDisplay *)data; 
     1320 
     1321  if (s->pulse) 
     1322    gdk_gc_set_function (s->user_gc, GDK_NOOP); 
     1323  else 
     1324    gdk_gc_set_function (s->user_gc, GDK_COPY); 
     1325 
     1326  s->pulse = (!s->pulse); 
     1327 
     1328  sample_display_refresh_user_marker (s); 
     1329 
     1330  return TRUE; 
     1331} 
     1332 
     1333void 
     1334sample_display_start_cursor_pulse (SampleDisplay * s) 
     1335{ 
     1336  gdk_gc_set_function (s->user_gc, GDK_NOOP); 
     1337 
     1338  sample_display_refresh_user_marker (s); 
     1339 
     1340  s->pulsing_tag = gtk_timeout_add (PULSE_INTERVAL, 
     1341                                    (GtkFunction)sd_pulse_cursor, s); 
     1342} 
     1343 
     1344void 
     1345sample_display_stop_cursor_pulse (SampleDisplay * s) 
     1346{ 
     1347  if (s->pulsing_tag > 0) 
     1348    gtk_timeout_remove (s->pulsing_tag); 
     1349 
     1350  s->pulsing_tag = 0; 
     1351 
     1352  gdk_gc_set_function (s->user_gc, GDK_COPY); 
     1353 
     1354  sample_display_refresh_user_marker (s); 
     1355} 
     1356 
    7791357static void 
    780 sample_display_do_marker_line (GdkDrawable *win, 
    781                                GdkGC *gc, 
    782                                SampleDisplay *s, 
    783                                int endoffset, 
    784                                int offset, 
    785                                int x_min, 
    786                                int x_max) 
    787 
    788   int x; 
    789  
    790   if(offset >= s->view->start && offset <= s->view->end) { 
     1358sample_display_draw_user_offset (GdkDrawable * win, GdkGC * gc, 
     1359                                 SampleDisplay * s, int x, 
     1360                                 int x_min, int x_max) 
     1361
     1362  GdkPoint poly[4]; 
     1363  gboolean fill; 
     1364 
     1365  if(x >= x_min && x <= x_max) { 
     1366    gdk_draw_line(win, s->zeroline_gc, 
     1367                  x-2, 0,  
     1368                  x-2, s->height); 
     1369 
     1370    gdk_draw_line(win, gc, 
     1371                  x-1, 0,  
     1372                  x-1, s->height); 
     1373    gdk_draw_line(win, gc, 
     1374                  x+1, 0,  
     1375                  x+1, s->height); 
     1376 
     1377    gdk_draw_line(win, s->zeroline_gc, 
     1378                  x+2, 0,  
     1379                  x+2, s->height); 
     1380 
     1381 
     1382 
     1383    if (!s->view->sample->play_head->going) { 
     1384      fill = !s->view->sample->play_head->mute; 
     1385 
     1386      if (x < 20) { 
     1387        poly[0].x = 11; 
     1388        poly[1].x = 11; 
     1389        poly[2].x = 14; 
     1390        poly[3].x = 14; 
     1391      } else { 
     1392        poly[0].x = x - 8; 
     1393        poly[1].x = x - 8; 
     1394        poly[2].x = x - 5; 
     1395        poly[3].x = x - 5; 
     1396      } 
     1397 
     1398      poly[0].y = 4; 
     1399      poly[1].y = 14; 
     1400      poly[2].y = 14; 
     1401      poly[3].y = 4; 
     1402 
     1403      gdk_draw_polygon (win, gc, fill, poly, 4); 
     1404      gdk_draw_polygon (win, s->zeroline_gc, FALSE, poly, 4); 
     1405 
     1406      poly[0].x -= 5; 
     1407      poly[1].x -= 5; 
     1408      poly[2].x -= 5; 
     1409      poly[3].x -= 5; 
     1410 
     1411      gdk_draw_polygon (win, gc, fill, poly, 4); 
     1412      gdk_draw_polygon (win, s->zeroline_gc, FALSE, poly, 4); 
     1413    } 
     1414  } 
     1415
     1416 
     1417static void 
     1418sample_display_draw_play_offset (GdkDrawable * win, GdkGC * gc, 
     1419                                 SampleDisplay * s, int x, 
     1420                                 int x_min, int x_max) 
     1421
     1422  sw_sample * sample; 
     1423  GdkPoint poly[4]; 
     1424  sw_head * head; 
     1425 
     1426  if(x >= x_min && x <= x_max) { 
     1427    gdk_draw_rectangle(win, gc, TRUE, 
     1428                       x-1, 0,  
     1429                       3, s->height); 
     1430 
     1431    sample = s->view->sample; 
     1432    head = sample->play_head; 
     1433 
     1434    if (head->going) { 
     1435      if (x < 20) { 
     1436        if (head->reverse) { 
     1437          poly[0].x = 14; 
     1438          poly[1].x = 14; 
     1439          poly[2].x = 6; 
     1440        } else { 
     1441          poly[0].x = 6; 
     1442          poly[1].x = 6; 
     1443          poly[2].x = 14; 
     1444        } 
     1445      } else { 
     1446        if (head->reverse) { 
     1447          poly[0].x = x - 5; 
     1448          poly[1].x = x - 5; 
     1449          poly[2].x = x - 13; 
     1450        } else { 
     1451          poly[0].x = x - 13; 
     1452          poly[1].x = x - 13; 
     1453          poly[2].x = x - 5; 
     1454        } 
     1455      } 
     1456 
     1457      poly[0].y = 4; 
     1458      poly[1].y = 14; 
     1459      poly[2].y = 9; 
     1460       
     1461      gdk_draw_polygon (win, gc, !head->mute, poly, 3); 
     1462      gdk_draw_polygon (win, s->zeroline_gc, FALSE, poly, 3); 
     1463    } 
     1464  } 
     1465
     1466 
     1467static void 
     1468sample_display_draw_rec_offset (GdkDrawable * win, GdkGC * gc, 
     1469                                SampleDisplay * s, int x, 
     1470                                int x_min, int x_max) 
     1471
     1472  sw_sample * sample; 
     1473 
     1474  if(x >= x_min && x <= x_max) { 
    7911475#if 0 
    792     if(!endoffset) 
    793       x = sample_display_startoffset_to_xpos(s, offset); 
    794     else 
    795       x = sample_display_endoffset_to_xpos(s, offset); 
    796 #endif 
    797     x = OFFSET_TO_XPOS (offset); 
    798  
    799     if(x >= x_min && x < x_max) { 
    800       gdk_draw_line(win, gc, 
    801                     x, 0,  
    802                     x, s->height); 
    803     } 
    804   } 
    805 
    806  
    807  
    808 /*** DRAW_MAIN ***/ 
     1476    gdk_draw_rectangle(win, gc, TRUE, 
     1477                       x-1, 0,  
     1478                       3, s->height); 
     1479#endif 
     1480 
     1481    gdk_draw_line(win, s->zeroline_gc, 
     1482                  x-2, 0,  
     1483                  x-2, s->height); 
     1484#if 1 
     1485    gdk_draw_line(win, gc, 
     1486                  x-1, 0,  
     1487                  x-1, s->height); 
     1488    gdk_draw_line(win, gc, 
     1489                  x+1, 0,  
     1490                  x+1, s->height); 
     1491#endif 
     1492 
     1493    gdk_draw_line(win, s->zeroline_gc, 
     1494                  x+2, 0,  
     1495                  x+2, s->height); 
     1496 
     1497    sample = s->view->sample; 
     1498 
     1499    if (x < 20) x = 19; 
     1500    gdk_draw_arc (win, gc, TRUE, x-14, 15, 8, 8, 0, 360 * 64); 
     1501    gdk_draw_arc (win, s->zeroline_gc, FALSE, x-14, 15, 8, 8, 0, 360 * 64); 
     1502 
     1503  } 
     1504
     1505 
     1506 
     1507/*** DRAW ***/ 
    8091508 
    8101509static void 
    811 sample_display_draw_main (GtkWidget *widget, 
    812                           GdkRectangle *area) 
     1510sample_display_draw (GtkWidget *widget, GdkRectangle *area) 
    8131511{ 
    8141512  SampleDisplay *s = SAMPLE_DISPLAY(widget); 
    815  
    816   g_return_if_fail(area->x >= 0); 
     1513  sw_sample * sample = s->view->sample; 
     1514  GdkDrawable * drawable; 
     1515 
     1516  /*  g_return_if_fail(area->x >= 0);*/ 
     1517  if (area->x < 0) return; 
     1518  if (area->y < 0) return; 
    8171519 
    8181520  if(area->width == 0) 
     
    8211523  if(area->x + area->width > s->width) 
    8221524    return; 
     1525 
     1526#ifdef DEBUG 
     1527    g_print ("sample_display_draw: (%d, %d) [%d, %d]\n", 
     1528             area->x, area->y, area->width, area->height); 
     1529#endif 
    8231530 
    8241531  if(!IS_INITIALIZED(s)) { 
    8251532    gtk_style_apply_default_background (GTK_WIDGET(s)->style, widget->window, 
    8261533                                        TRUE, GTK_STATE_NORMAL, 
    827                                         NULL, 
     1534                                        NULL, 0, 0, s->width, s->height); 
     1535#if 0 
    8281536                                        area->x, area->y, 
    8291537                                        area->width, area->height); 
     1538#endif 
    8301539  } else { 
    8311540    const int x_min = area->x; 
    8321541    const int x_max = area->x + area->width; 
    8331542 
     1543#ifdef DOUBLE_BUFFER 
     1544    drawable = s->backing_pixmap; 
     1545#else 
     1546    drawable = widget->window; 
     1547#endif 
     1548 
    8341549    /* draw the sample graph */ 
    835     sample_display_draw_data(s->backing_pixmap, s, x_min, x_max - x_min); 
    836  
    837     sample_display_draw_sel (s->backing_pixmap, s, x_min, x_max); 
    838        
    839     if(s->mixerpos != -1) { 
    840       sample_display_do_marker_line(s->backing_pixmap, s->mixerpos_gc, 
    841                                     s, 
    842                                     0, s->mixerpos, x_min, x_max); 
    843  
    844     } 
    845  
     1550    sample_display_draw_data(drawable, s, x_min, x_max - x_min); 
     1551 
     1552    /* draw the selection bounds */ 
     1553    sample_display_draw_sel (drawable, s, x_min, x_max); 
     1554 
     1555 
     1556    /* draw the offset cursors */ 
     1557 
     1558    if(!sample->play_head->going) { 
     1559      /* Draw user offset */ 
     1560      sample_display_draw_user_offset (drawable, s->user_gc, 
     1561                                       s, s->user_offset_x, 
     1562                                       x_min, x_max); 
     1563    } else { 
     1564#if 1 
     1565      /* Draw play offset */ 
     1566      sample_display_draw_play_offset (drawable, s->play_gc, 
     1567                                       s, s->play_offset_x, 
     1568                                       x_min, x_max); 
     1569#endif 
     1570      /* Draw user offset */ 
     1571      sample_display_draw_user_offset (drawable, s->user_gc, 
     1572                                       s, s->user_offset_x, 
     1573                                       x_min, x_max); 
     1574 
     1575    } 
     1576 
     1577    /* Draw rec offset */ 
     1578    if (sample->rec_head /*&& sample->rec_head->transport_mode != SWEEP_TRANSPORT_STOP*/ ) { 
     1579      sample_display_draw_rec_offset (drawable, s->rec_gc, 
     1580                                      s, s->rec_offset_x, 
     1581                                      x_min, x_max); 
     1582    } 
     1583 
     1584#if 0 
     1585    /* Draw focus indicator */ 
     1586    if (GTK_WIDGET_HAS_FOCUS(widget)) { 
     1587      /* ??? */ 
     1588    } 
     1589#endif 
     1590 
     1591#ifdef DOUBLE_BUFFER 
    8461592    gdk_draw_pixmap(widget->window, s->fg_gc, s->backing_pixmap, 
    847                     area->x, area->y, 
    848                     area->x, area->y, 
    849                     area->width, area->height); 
    850  
    851   } 
    852 
    853  
    854 static void 
    855 sample_display_draw (GtkWidget *widget, 
    856                      GdkRectangle *area) 
    857 
    858 #if 0 
    859   SampleDisplay *s = SAMPLE_DISPLAY(widget); 
    860   GdkRectangle area2 = { 0, 0, 0, s->height }; 
    861   int i, x; 
    862   const int x_min = area->x; 
    863   const int x_max = area->x + area->width; 
    864 #endif 
    865  
    866   sample_display_draw_main(widget, area); 
    867   return; 
    868  
    869 #if 0 
    870   if(s->complete_redraw) { 
    871     s->complete_redraw = 0; 
    872     sample_display_draw_main(widget, area); 
    873     return; 
    874   } 
    875  
    876   if(s->view->sample->sel_start != s->old_ss || s->view->sample->sel_end != s->old_se) { 
    877     if(s->view->sample->sel_start == -1 || s->old_ss == -1) { 
    878       sample_display_draw_main(widget, area); 
    879     } else { 
    880       if(s->view->sample->sel_start < s->old_ss) { 
    881         /* repaint left additional side */ 
    882         x = sample_display_startoffset_to_xpos(s, s->view->sample->sel_start); 
    883         area2.x = MIN(x_max, MAX(x_min, x)); 
    884         x = sample_display_startoffset_to_xpos(s, s->old_ss); 
    885         area2.width = MIN(x_max, MAX(x_min, x+2)) - area2.x; 
    886       } else { 
    887         /* repaint left removed side */ 
    888         x = sample_display_startoffset_to_xpos(s, s->old_ss); 
    889         area2.x = MIN(x_max, MAX(x_min, x)); 
    890         x = sample_display_startoffset_to_xpos(s, s->view->sample->sel_start); 
    891         area2.width = MIN(x_max, MAX(x_min, x)) - area2.x; 
    892       } 
    893       sample_display_draw_main(widget, &area2); 
    894  
    895       if(s->view->sample->sel_end < s->old_se) { 
    896         /* repaint right removed side */ 
    897         x = sample_display_endoffset_to_xpos(s, s->view->sample->sel_end); 
    898         area2.x = MIN(x_max, MAX(x_min, x)); 
    899         x = sample_display_endoffset_to_xpos(s, s->old_se); 
    900         area2.width = MIN(x_max, MAX(x_min, x+1)) - area2.x; 
    901       } else { 
    902         /* repaint right additional side */ 
    903         x = sample_display_endoffset_to_xpos(s, s->old_se); 
    904         area2.x = MIN(x_max, MAX(x_min, x-2)); 
    905         x = sample_display_endoffset_to_xpos(s, s->view->sample->sel_end); 
    906         area2.width = MIN(x_max, MAX(x_min, x)) - area2.x; 
    907       } 
    908       sample_display_draw_main(widget, &area2); 
    909     } 
    910  
    911     s->old_ss = s->view->sample->sel_start; 
    912     s->old_se = s->view->sample->sel_end; 
    913   } 
    914  
    915   if(s->mixerpos != s->old_mixerpos) { 
    916     for(i = 0; i < 2; i++) { 
    917       if(s->old_mixerpos >= s->view->start && 
    918          s->old_mixerpos < s->view->start + (s->view->end - s->view->start)) { 
    919         x = sample_display_startoffset_to_xpos(s, s->old_mixerpos); 
    920         area2.x = MIN(x_max - 1, MAX(x_min, x - 3)); 
    921         area2.width = 7; 
    922         sample_display_draw_main(widget, &area2); 
    923       } 
    924       s->old_mixerpos = s->mixerpos; 
    925     } 
    926   } 
    927 #endif 
    928  
    929 
    930  
     1593                    area->x, area->y, 
     1594                    area->x, area->y, 
     1595                    area->width, area->height); 
     1596#endif 
     1597  } 
     1598
    9311599 
    9321600/*** EVENT HANDLERS ***/ 
     1601 
    9331602 
    9341603static gint 
     
    9361605                       GdkEventExpose *event) 
    9371606{ 
    938   sample_display_draw_main(widget, &event->area); 
     1607  SampleDisplay * s = (SampleDisplay *)widget; 
     1608  GdkRectangle * a; 
     1609 
     1610  a = &event->area; 
     1611 
     1612#ifdef DEBUG 
     1613  g_print ("received expose event for (%d, %d) [%d, %d]; %d follow\n", 
     1614           a->x, a->y, a->width, a->height, event->count); 
     1615#endif 
     1616 
     1617 
     1618#ifdef DOUBLE_BUFFER 
     1619  gdk_draw_pixmap(widget->window, s->fg_gc, s->backing_pixmap, 
     1620                  a->x, a->y, 
     1621                  a->x, a->y, 
     1622                  a->width, a->height); 
     1623#else 
     1624  gtk_widget_queue_draw_area (GTK_WIDGET(s), a->x, a->y, a->width, a->height); 
     1625 
     1626  area.x = a->x; 
     1627  area.y = a->y; 
     1628  area.width = a->width; 
     1629  area.height = a->height; 
     1630 
     1631  gtk_widget_draw (widget, &area); 
     1632#endif 
     1633 
    9391634  return FALSE; 
    9401635} 
    9411636 
     1637static gint 
     1638sample_display_scroll_left (gpointer data) 
     1639{ 
     1640  SampleDisplay * s = (SampleDisplay *)data; 
     1641  int new_win_start, win_length; 
     1642   
     1643  win_length = s->view->end - s->view->start; 
     1644  new_win_start = s->view->start - win_length/8; 
     1645   
     1646  new_win_start = CLAMP(new_win_start, 0, 
     1647                        s->view->sample->sounddata->nr_frames - 
     1648                        (s->view->end - s->view->start)); 
     1649   
     1650  if(new_win_start != s->view->start) { 
     1651    sample_display_set_window (s, 
     1652                               new_win_start, 
     1653                               new_win_start + win_length); 
     1654  } 
     1655 
     1656  s->view->sample->tmp_sel->sel_start = new_win_start; 
     1657 
     1658  return (new_win_start > 0); 
     1659} 
     1660 
     1661static gint 
     1662sample_display_scroll_right (gpointer data) 
     1663{ 
     1664  SampleDisplay * s = (SampleDisplay *)data; 
     1665  int new_win_start, win_length; 
     1666   
     1667  win_length = s->view->end - s->view->start; 
     1668  new_win_start = s->view->start + win_length/8; 
     1669   
     1670  new_win_start = CLAMP(new_win_start, 0, 
     1671                        s->view->sample->sounddata->nr_frames - 
     1672                        (s->view->end - s->view->start)); 
     1673   
     1674  if(new_win_start != s->view->start) { 
     1675    sample_display_set_window (s, 
     1676                               new_win_start, 
     1677                               new_win_start + win_length); 
     1678  } 
     1679 
     1680  s->view->sample->tmp_sel->sel_end = s->view->end; 
     1681 
     1682  return (new_win_start >= (s->view->end - win_length)); 
     1683} 
     1684 
    9421685static void 
    943 sample_display_handle_motion (SampleDisplay *s, 
     1686sample_display_handle_playmarker_motion (SampleDisplay * s, int x, int y) 
     1687
     1688  sw_sample * sample; 
     1689  sw_framecount_t offset; 
     1690 
     1691  sample = s->view->sample; 
     1692  offset = XPOS_TO_OFFSET(x); 
     1693 
     1694  sample_set_playmarker (sample, offset, TRUE); 
     1695
     1696 
     1697void 
     1698sample_display_clear_sel (SampleDisplay * s) 
     1699
     1700  sample_clear_tmp_sel (s->view->sample); 
     1701  s->selecting = SELECTING_NOTHING; 
     1702  s->selection_mode = SELECTION_MODE_NONE; 
     1703  sample_display_set_default_cursor (s); 
     1704  sample_clear_tmp_message (s->view->sample); 
     1705  gtk_signal_emit(GTK_OBJECT(s), 
     1706                  sample_display_signals[SIG_SELECTION_CHANGED]); 
     1707
     1708 
     1709static void 
     1710sample_display_handle_sel_motion (SampleDisplay *s, 
    9441711                              int x, 
    9451712                              int y, 
     
    9481715  sw_sample * sample; 
    9491716  sw_sel * sel; 
    950   int ol, or
     1717  int o
    9511718  int ss, se; 
    952  
    953   /* ignore non select motion on button 1 for now */ 
    954   if (current_tool != TOOL_SELECT) return; 
     1719  gboolean scroll_left = FALSE, scroll_right = FALSE; 
     1720 
     1721  if (s->view->current_tool != TOOL_SELECT) return; 
    9551722 
    9561723  if(!s->selecting) 
     
    9651732  sample = s->view->sample; 
    9661733 
     1734  if (sample->edit_mode != SWEEP_EDIT_MODE_READY) { 
     1735    sample_display_clear_sel (s); 
     1736    return; 
     1737  } 
     1738 
     1739  o = XPOS_TO_OFFSET(x); 
     1740 
     1741#ifdef DEBUG 
     1742  if (o < 0) { 
     1743    g_print ("OI! setting an offset < 0!\n"); 
     1744  } 
     1745#endif 
     1746 
     1747  if (!sample->play_head->going) { 
     1748    sample_set_playmarker (sample, o, TRUE); 
     1749  } 
     1750 
    9671751  sel = sample->tmp_sel; 
    9681752 
     
    9701754  se = sel->sel_end; 
    9711755 
    972   /* XXX: Could scroll here ... which should be hooked up to a timeout */ 
    973   if(x < 0) 
     1756  if(x < 0) { 
     1757    scroll_left = TRUE; 
    9741758    x = 0; 
    975   else if(x >= s->width) 
     1759  } else if(x >= s->width - 1) { 
     1760    scroll_right = TRUE; 
    9761761    x = s->width - 1; 
    977  
    978   /* Set: ol to the offset of the current mouse position x 
    979    * Set: or to the next useful value: if we're zoomed in beyond 
    980    *         dot-for-sample, then the next sample value; 
    981    *         otherwise the offset corresponding to the next pixel x+1. 
    982    */ 
    983   ol = XPOS_TO_OFFSET(x); 
    984   if((s->view->end - s->view->start) < s->width) { 
    985     or = XPOS_TO_OFFSET(x) + 1; 
     1762  } 
     1763 
     1764  if (just_clicked) { 
     1765    ss = o; 
     1766    se = o+1; 
    9861767  } else { 
    987     or = XPOS_TO_OFFSET(x + 1); 
    988   } 
    989  
    990   if (ol < 0 || ol >= s->view->sample->sounddata->nr_frames) return; 
    991   if (or < 0 || or >= s->view->sample->sounddata->nr_frames) return; 
    992 #if 0 
    993   g_return_if_fail(ol >= 0 && ol < s->view->sample->sounddata->nr_frames); 
    994   g_return_if_fail(or > 0 && or <= s->view->sample->sounddata->nr_frames); 
    995 #endif 
    996  
    997   g_return_if_fail(ol < or); 
    998  
    999   switch(s->selecting) { 
    1000   case SELECTING_SELECTION_START: 
    1001     if(just_clicked) { 
    1002 #if 0 
    1003       if(ss != -1 && ol < se) { 
    1004         ss = ol; 
     1768    switch (s->selecting) { 
     1769    case SELECTING_SELECTION_START: 
     1770      if (o < se) { 
     1771        ss = o; 
    10051772      } else { 
    1006 #endif 
    1007         ss = ol; 
    1008         se = ol + 1; 
    1009 #if 0 
    1010       } 
    1011 #endif 
    1012     } else { 
    1013       if(ol < se) { 
    1014         ss = ol; 
    1015       } else { /* swap start,end */ 
    1016         ss = se - 1; 
    1017         se = or; 
    1018         s->selecting = SELECTING_SELECTION_END; 
    1019       } 
    1020     } 
    1021     break; 
    1022   case SELECTING_SELECTION_END: 
    1023     if(just_clicked) { 
    1024       if(ss != -1 && or > ss) { 
    1025         se = or; 
     1773        if (o != ss+1) ss = se; 
     1774        se = o; 
     1775        s->selecting = SELECTING_SELECTION_END;      } 
     1776      break; 
     1777    case SELECTING_SELECTION_END: 
     1778      if (o > ss) { 
     1779        se = o; 
    10261780      } else { 
    1027         ss = or - 1; 
    1028         se = or; 
    1029       } 
    1030     } else { 
    1031       if(or > ss) { 
    1032         se = or; 
    1033       } else { /* swap end,start */ 
    1034         se = ss + 1; 
    1035         ss = ol; 
     1781        if (o != se-1) se = ss; 
     1782        ss = o; 
    10361783        s->selecting = SELECTING_SELECTION_START; 
    10371784      } 
    1038     } 
    1039     break; 
    1040   default: 
    1041     g_assert_not_reached()
    1042     break; 
     1785      break; 
     1786    default: 
     1787      g_assert_not_reached (); 
     1788      break
     1789    } 
    10431790  } 
    10441791 
     
    10491796                    sample_display_signals[SIG_SELECTION_CHANGED]); 
    10501797  } 
     1798 
     1799  if (scroll_left && s->scroll_left_tag == 0) { 
     1800    if (s->scroll_right_tag != 0) { 
     1801      gtk_timeout_remove (s->scroll_right_tag); 
     1802      s->scroll_right_tag = 0; 
     1803    } 
     1804 
     1805    s->scroll_left_tag = gtk_timeout_add (100, sample_display_scroll_left, 
     1806                                          (gpointer)s); 
     1807 
     1808  } else if (scroll_right && s->scroll_right_tag == 0) { 
     1809    if (s->scroll_left_tag != 0) { 
     1810      gtk_timeout_remove (s->scroll_left_tag); 
     1811      s->scroll_left_tag = 0; 
     1812    } 
     1813 
     1814    s->scroll_right_tag = gtk_timeout_add (100, sample_display_scroll_right, 
     1815                                           (gpointer)s); 
     1816 
     1817  } else if (!scroll_right && !scroll_left) { 
     1818    if (s->scroll_right_tag != 0) { 
     1819      gtk_timeout_remove (s->scroll_right_tag); 
     1820      s->scroll_right_tag = 0; 
     1821    } 
     1822    if (s->scroll_left_tag != 0) { 
     1823      gtk_timeout_remove (s->scroll_left_tag); 
     1824      s->scroll_left_tag = 0; 
     1825    } 
     1826  } 
    10511827} 
    10521828 
    10531829/* Handle middle mousebutton display window panning */ 
    10541830static void 
    1055 sample_display_handle_motion_2 (SampleDisplay *s, 
    1056                                 int x, 
    1057                                 int y) 
    1058 
    1059   int new_win_start = 
    1060     s->selecting_wins0 + (s->selecting_x0 - x) * 
    1061     (s->view->end - s->view->start) / s->width; 
     1831sample_display_handle_move_motion (SampleDisplay *s, int x, int y) 
     1832
     1833  sw_sample * sample = s->view->sample; 
     1834  sw_framecount_t vlen, offset_xpos, new_offset; 
     1835  int new_win_start; 
     1836 
     1837  vlen = s->view->end - s->view->start; 
     1838 
     1839  offset_xpos = OFFSET_TO_XPOS(sample->user_offset); 
     1840 
     1841  new_win_start = 
     1842    s->selecting_wins0 + (s->selecting_x0 - x) * vlen / s->width; 
    10621843 
    10631844  new_win_start = CLAMP(new_win_start, 0, 
    1064                         s->view->sample->sounddata->nr_frames - 
    1065                         (s->view->end - s->view->start)); 
     1845                        sample->sounddata->nr_frames - vlen); 
     1846 
     1847  new_offset = new_win_start + offset_xpos * vlen / s->width; 
     1848   
     1849  sample_set_scrubbing (sample, TRUE); 
     1850  sample_set_playmarker (sample, new_offset, TRUE); 
    10661851 
    10671852  if(new_win_start != s->view->start) { 
    10681853    sample_display_set_window (s, 
    10691854                               new_win_start, 
    1070                                new_win_start + 
    1071                                (s->view->end - s->view->start)); 
    1072   } 
    1073 
    1074  
    1075 void 
    1076 sample_display_clear_sel (SampleDisplay * s) 
    1077 
    1078   GtkWidget * widget = GTK_WIDGET(s); 
    1079  
    1080   sample_clear_tmp_sel (s->view->sample); 
    1081   s->selecting = SELECTING_NOTHING; 
    1082   s->selection_mode = SELECTION_MODE_NONE; 
    1083   SET_CURSOR(widget, crosshair_cr); 
    1084   gtk_signal_emit(GTK_OBJECT(s), 
    1085                   sample_display_signals[SIG_SELECTION_CHANGED]); 
     1855                               new_win_start + vlen); 
     1856  } 
    10861857} 
    10871858 
    10881859static void 
    1089 sample_display_set_intersect_cursor (SampleDisplay * s) 
    1090 
    1091   sw_sample * sample = s->view->sample; 
    1092   GtkWidget * widget = GTK_WIDGET(s); 
    1093  
    1094   /* Check if there are other selection regions. 
    1095    * NB. This assumes that tmp_sel has already been 
    1096    * set. 
    1097    */ 
    1098   if (sample_sel_nr_regions(sample) > 0) { 
    1099     SET_CURSOR(widget, horiz_plus_cr); 
     1860sample_display_handle_pencil_motion (SampleDisplay * s, int x, int y) 
     1861
     1862  sw_sample * sample; 
     1863  sw_framecount_t offset; 
     1864  int channel, channels; 
     1865  sw_audio_t value; 
     1866  sw_audio_t * sampledata; 
     1867 
     1868  offset = XPOS_TO_OFFSET(x); 
     1869 
     1870  if (offset < s->view->start || offset > s->view->end) return; 
     1871 
     1872  sample = s->view->sample; 
     1873  sampledata = (sw_audio_t *)sample->sounddata->data; 
     1874  channels = sample->sounddata->format->channels; 
     1875 
     1876  y = CLAMP (y, 0, s->height); 
     1877 
     1878  channel = YPOS_TO_CHANNEL(y); 
     1879  value = YPOS_TO_VALUE(y); 
     1880  sampledata[offset*channels + channel] = value; 
     1881 
     1882#if 0 
     1883  if (sample->sounddata->format->channels == 1) { 
     1884    value = YPOS_TO_VALUE_1(y); 
     1885    sampledata[offset] = value; 
    11001886  } else { 
    1101     SET_CURSOR(widget, horiz_cr); 
    1102   } 
     1887    channel = YPOS_TO_CHANNEL(y); 
     1888    value = YPOS_TO_VALUE_2(y); 
     1889    sampledata[offset*2 + channel] = value; 
     1890  } 
     1891#endif 
     1892 
     1893  sample_refresh_views (sample); 
     1894
     1895 
     1896static void 
     1897sample_display_handle_noise_motion (SampleDisplay * s, int x, int y) 
     1898
     1899  sw_sample * sample; 
     1900  sw_framecount_t offset; 
     1901  int channel; 
     1902  sw_audio_t value, oldvalue; 
     1903  sw_audio_t * sampledata; 
     1904 
     1905  offset = XPOS_TO_OFFSET(x); 
     1906 
     1907  if (offset < s->view->start || offset > s->view->end) return; 
     1908 
     1909  sample = s->view->sample; 
     1910  sampledata = (sw_audio_t *)sample->sounddata->data; 
     1911 
     1912  y = CLAMP (y, 0, s->height); 
     1913 
     1914  value = 2.0 * (random() - RAND_MAX/2) / (sw_audio_t)RAND_MAX; 
     1915 
     1916  if (sample->sounddata->format->channels == 1) { 
     1917    oldvalue = sampledata[offset]; 
     1918  } else { 
     1919    channel = YPOS_TO_CHANNEL(y); 
     1920    offset = offset*2 + channel; 
     1921    oldvalue = sampledata[offset]; 
     1922  } 
     1923 
     1924  sampledata[offset] = CLAMP(oldvalue * 0.8 + value * 0.2, 
     1925                             SW_AUDIO_T_MIN, SW_AUDIO_T_MAX); 
     1926 
     1927  sample_refresh_views (sample); 
     1928
     1929 
     1930static void 
     1931sample_display_handle_sel_button_press (SampleDisplay * s, int x, int y, 
     1932                                        GdkModifierType state) 
     1933
     1934  sw_sample * sample; 
     1935  GList * gl; 
     1936  sw_sel * sel, * tmp_sel = NULL; 
     1937  int xss, xse; 
     1938  int min_xs; 
     1939  gboolean just_clicked = TRUE; 
     1940 
     1941  sample = s->view->sample; 
     1942 
     1943  if (sample->edit_mode != SWEEP_EDIT_MODE_READY) { 
     1944    sample_display_clear_sel (s); 
     1945    return; 
     1946  } 
     1947 
     1948  for (gl = sample->sounddata->sels; gl; gl = gl->next) { 
     1949 
     1950    /* If the cursor is near the current start or end of 
     1951     * the selection, move that. 
     1952     */ 
     1953 
     1954    sel = (sw_sel *)gl->data; 
     1955           
     1956    xss = OFFSET_TO_XPOS(sel->sel_start); 
     1957    xse = OFFSET_TO_XPOS(sel->sel_end); 
     1958           
     1959    if(abs(x-xss) < 5) { 
     1960      sample_set_tmp_sel (sample, s->view, sel); 
     1961      s->selecting = SELECTING_SELECTION_START; 
     1962      s->selection_mode = SELECTION_MODE_INTERSECT; 
     1963      sample_display_set_intersect_cursor (s); 
     1964      just_clicked = FALSE; 
     1965      goto motion; 
     1966    } else if(abs(x-xse) < 5) { 
     1967      sample_set_tmp_sel (sample, s->view, sel); 
     1968      s->selecting = SELECTING_SELECTION_END; 
     1969      s->selection_mode = SELECTION_MODE_INTERSECT; 
     1970      sample_display_set_intersect_cursor (s); 
     1971      just_clicked = FALSE; 
     1972      goto motion; 
     1973    } 
     1974  } 
     1975 
     1976  /* If shift is held down, move the closest selection edge to the mouse */ 
     1977 
     1978  if ((state & GDK_SHIFT_MASK) && (sample->sounddata->sels != NULL)) { 
     1979    min_xs = G_MAXINT; 
     1980 
     1981    for (gl = sample->sounddata->sels; gl; gl = gl->next) { 
     1982      sel = (sw_sel *)gl->data; 
     1983       
     1984      xss = OFFSET_TO_XPOS(sel->sel_start); 
     1985      xse = OFFSET_TO_XPOS(sel->sel_end); 
     1986 
     1987      if (abs(x-xss) > min_xs) break; 
     1988 
     1989      tmp_sel = sel; 
     1990 
     1991      min_xs = abs(x-xss); 
     1992 
     1993      s->selecting = SELECTING_SELECTION_START; 
     1994 
     1995      if (abs(x-xse) > min_xs) break; 
     1996 
     1997      min_xs = abs(x-xse); 
     1998 
     1999      s->selecting = SELECTING_SELECTION_END; 
     2000    } 
     2001 
     2002    sample_set_tmp_sel (sample, s->view, tmp_sel); 
     2003    s->selection_mode = SELECTION_MODE_INTERSECT; 
     2004    sample_display_set_intersect_cursor (s); 
     2005    just_clicked = FALSE; 
     2006    goto motion; 
     2007  } 
     2008 
     2009  /* Otherwise, start a new selection region. */ 
     2010         
     2011  sample_set_tmp_sel_1(sample, s->view, 
     2012                       XPOS_TO_OFFSET(x), 
     2013                       XPOS_TO_OFFSET(x)+1); 
     2014         
     2015  s->selecting = SELECTING_SELECTION_END; 
     2016 
     2017  if(state & GDK_CONTROL_MASK) { 
     2018    s->selection_mode = SELECTION_MODE_INTERSECT; 
     2019    sample_display_set_intersect_cursor (s); 
     2020  } else if (state & GDK_MOD1_MASK) /* how to get ALT? */{ 
     2021    s->selection_mode = SELECTION_MODE_SUBTRACT; 
     2022    sample_display_set_subtract_cursor (s); 
     2023  } else { 
     2024    s->selection_mode = SELECTION_MODE_REPLACE; 
     2025    SET_CURSOR(GTK_WIDGET(s), HORIZ); 
     2026  } 
     2027 
     2028  just_clicked = TRUE; 
     2029 
     2030 motion: 
     2031 
     2032  sample_set_tmp_message (sample, _(selection_mode_names[s->selection_mode])); 
     2033  sample_set_progress_ready (sample); 
     2034 
     2035  sample_display_handle_sel_motion (s, x, y, just_clicked); 
     2036
     2037 
     2038static gint 
     2039sample_display_on_playmarker (SampleDisplay * s, gint x, gint y) 
     2040
     2041  gint xp = OFFSET_TO_XPOS(s->view->sample->user_offset); 
     2042 
     2043  if (abs(x-xp) < 5 || ((abs(x-xp) < 15) && (y < 17))) 
     2044    return TRUE; 
     2045   
     2046  return FALSE; 
     2047
     2048 
     2049static gint 
     2050sample_display_on_sel (SampleDisplay * s, gint x, gint y) 
     2051
     2052  GList * gl; 
     2053  sw_sel * sel; 
     2054  int xss, xse; 
     2055 
     2056  for (gl = s->view->sample->sounddata->sels; gl; gl = gl->next) { 
     2057    sel = (sw_sel *)gl->data; 
     2058 
     2059    xss = OFFSET_TO_XPOS(sel->sel_start); 
     2060    xse = OFFSET_TO_XPOS(sel->sel_end); 
     2061 
     2062    if(abs(x-xss) < 5 || abs(x-xse) < 5) 
     2063      return TRUE;     
     2064  } 
     2065 
     2066  return FALSE; 
    11032067} 
    11042068 
     
    11092073  SampleDisplay *s; 
    11102074  GdkModifierType state; 
    1111   GList * gl; 
    1112   sw_sel * sel; 
    11132075  sw_sample * sample; 
    11142076  int x, y; 
    1115   int xss, xse; 
    11162077  int o; 
    11172078 
     
    11252086    return TRUE; 
    11262087 
     2088  gtk_widget_grab_focus (widget); 
     2089 
    11272090  sample = s->view->sample; 
    11282091 
     
    11302093  if (event->button == 4) { 
    11312094    /* mouse wheel up */ 
    1132     view_volume_increase (s->view); 
     2095    view_zoom_in (s->view, 2.0); 
    11332096    return TRUE; 
    11342097  } else if (event->button == 5) { 
    11352098    /* mouse wheel down */ 
    1136     view_volume_decrease (s->view); 
     2099    view_zoom_out (s->view, 2.0); 
    11372100    return TRUE; 
    11382101  } 
    11392102 
    1140   /* Cancel the current operation if a different button is pressed. */ 
    1141   if(s->selecting && event->button != last_button) { 
     2103  if (s->meta_down && s->view->current_tool == TOOL_SCRUB && 
     2104      s->selecting == SELECTING_PLAYMARKER) { 
     2105    gdk_window_get_pointer (event->window, &x, &y, &state); 
     2106    sample_display_handle_playmarker_motion (s, x, y); 
     2107  } else if(s->selecting && event->button != last_button) { 
     2108    /* Cancel the current operation if a different button is pressed. */ 
    11422109    sample_display_clear_sel (s); 
    11432110  } else if (last_tmp_view && last_tmp_view != s->view && 
     
    11542121        return TRUE; 
    11552122 
    1156       switch (current_tool) { 
     2123      switch (s->view->current_tool) { 
     2124      case TOOL_SCRUB: 
     2125        s->selecting = SELECTING_PLAYMARKER; 
     2126        SET_CURSOR(widget, NEEDLE); 
     2127        sample_set_scrubbing (s->view->sample, TRUE); 
     2128        if (sample->play_head->going) { 
     2129          head_set_restricted (sample->play_head, FALSE); 
     2130          sample_refresh_playmode (sample); 
     2131        } else { 
     2132          play_view_all (s->view); 
     2133        } 
     2134        sample_display_handle_playmarker_motion (s, x, y); 
     2135        return TRUE; 
     2136        break; 
    11572137      case TOOL_SELECT: 
    1158  
    1159         for (gl = sample->sounddata->sels; gl; gl = gl->next) { 
    1160           sel = (sw_sel *)gl->data; 
    1161            
    1162           xss = OFFSET_TO_XPOS(sel->sel_start); 
    1163           xse = OFFSET_TO_XPOS(sel->sel_end); 
    1164            
    1165           /* If the cursor is near the current start or end of 
    1166            * the selection, move that. 
    1167            */ 
    1168           if(abs(x-xss) < 3) { 
    1169             sample_set_tmp_sel (sample, s->view, sel); 
    1170             s->selecting = SELECTING_SELECTION_START; 
    1171             s->selection_mode = SELECTION_MODE_INTERSECT; 
    1172             sample_display_set_intersect_cursor (s); 
    1173             sample_display_handle_motion(s, x, y, FALSE); 
    1174             return TRUE; 
    1175           } else if(abs(x-xse) < 3) { 
    1176             sample_set_tmp_sel (sample, s->view, sel); 
    1177             s->selecting = SELECTING_SELECTION_END; 
    1178             s->selection_mode = SELECTION_MODE_INTERSECT; 
    1179             sample_display_set_intersect_cursor (s); 
    1180             sample_display_handle_motion(s, x, y, FALSE); 
    1181             return TRUE; 
    1182           } 
     2138        /* If the cursor is near a sel, move that */ 
     2139        if (sample_display_on_sel (s, x, y)) { 
     2140          sample_display_handle_sel_button_press (s, x, y, state); 
     2141#if 0 
     2142        } else if (sample_display_on_playmarker (s, x, y)) { 
     2143          /* If the cursor is near the play marker, move that */ 
     2144          s->selecting = SELECTING_PLAYMARKER; 
     2145          SET_CURSOR(widget, NEEDLE); 
     2146#ifndef SEL_SCRUBS 
     2147          sample_set_scrubbing (sample, TRUE); 
     2148          sample_display_handle_playmarker_motion (s, x, y); 
     2149#endif 
     2150#endif 
     2151        } else { 
     2152          sample_display_handle_sel_button_press (s, x, y, state); 
    11832153        } 
    1184          
    1185         /* Otherwise, start a new selection. */ 
    1186          
    1187         sample_set_tmp_sel_1(sample, s->view, 
    1188                              XPOS_TO_OFFSET(x), 
    1189                              XPOS_TO_OFFSET(x)+1); 
    1190          
    1191         s->selecting = SELECTING_SELECTION_START; 
    1192          
    1193         if(state & GDK_SHIFT_MASK) { 
    1194           s->selection_mode = SELECTION_MODE_INTERSECT; 
    1195           sample_display_set_intersect_cursor (s); 
     2154#ifdef SEL_SCRUBS 
     2155        /* scrub along the changing selection edge, unless we're already 
     2156         * playing. NB. the play_head->scrubbing state is used by the 
     2157         * motion and release callbacks here to determine whether or not 
     2158         * to scrub the moving edge, and whether or not to stop playback 
     2159         * upon release. */ 
     2160        if (sample->play_head->going) { 
     2161          sample_set_scrubbing (sample, FALSE); 
     2162          sample_refresh_playmode (sample); 
    11962163        } else { 
    1197           s->selection_mode = SELECTION_MODE_REPLACE; 
    1198           SET_CURSOR(widget, horiz_cr); 
     2164          /*sample_set_monitor (sample, TRUE);*/ 
     2165          sample_set_scrubbing (sample, TRUE); 
     2166          play_view_all (s->view); 
     2167          sample_display_handle_playmarker_motion (s, x, y); 
    11992168        } 
    1200          
    1201         sample_display_handle_motion(s, x, y, TRUE); 
     2169#endif 
    12022170        break; 
    1203  
    12042171      case TOOL_ZOOM: 
    12052172        o = XPOS_TO_OFFSET(x); 
     
    12102177          view_zoom_in (s->view, 2.0); 
    12112178        } 
    1212         return TRUE; 
    1213          
    12142179        break; 
    1215  
     2180      case TOOL_PENCIL: 
     2181        s->selecting = SELECTING_PENCIL; 
     2182        sample_display_handle_pencil_motion (s, x, y); 
     2183        break; 
     2184      case TOOL_NOISE: 
     2185        s->selecting = SELECTING_NOISE; 
     2186        sample_display_handle_noise_motion (s, x, y); 
     2187        break; 
    12162188      default: 
    12172189        break; 
     
    12222194      gdk_window_get_pointer (event->window, &s->selecting_x0, NULL, NULL); 
    12232195      s->selecting_wins0 = s->view->start; 
    1224       SET_CURSOR(widget, move_cr); 
     2196      SET_CURSOR(widget, MOVE); 
     2197      sample_set_scrubbing (s->view->sample, TRUE); 
    12252198    } else if(last_button == 3) { 
    12262199      if(s->view && s->view->menu) { 
    1227         gtk_menu_popup(GTK_MENU(s->view->menu), 
    1228                        NULL, NULL, NULL, 
    1229                        NULL, 3, event->time); 
     2200        view_popup_context_menu (s->view, 3, event->time); 
    12302201      } 
    12312202    } 
     
    12392210{ 
    12402211  sw_sample * sample = s->view->sample; 
    1241    
    1242   if (!(s->selecting == SELECTING_SELECTION_START || 
    1243         s->selecting == SELECTING_SELECTION_END)) { 
    1244     return; 
    1245   } 
     2212  sw_sel * t; 
     2213 
    12462214  s->selecting = SELECTING_NOTHING; 
    12472215 
    1248   if(s->selection_mode == SELECTION_MODE_REPLACE) { 
    1249     sample_selection_replace_with_tmp_sel (sample); 
     2216  if (s->scroll_right_tag != 0) { 
     2217    gtk_timeout_remove (s->scroll_right_tag); 
     2218    s->scroll_right_tag = 0; 
     2219  } 
     2220  if (s->scroll_left_tag != 0) { 
     2221    gtk_timeout_remove (s->scroll_left_tag); 
     2222    s->scroll_left_tag = 0; 
     2223  } 
     2224 
     2225  t = sample->tmp_sel; 
     2226 
     2227  if (t->sel_end == (t->sel_start + 1)) { 
     2228    if (!sample->play_head->going) { 
     2229      sample_set_playmarker (sample, t->sel_start, TRUE); 
     2230    } 
     2231    sample_clear_tmp_sel (sample); 
    12502232  } else { 
    1251     sample_selection_insert_tmp_sel (sample); 
    1252   } 
    1253   s->selection_mode = SELECTION_MODE_NONE; 
    1254  
    1255   gtk_signal_emit(GTK_OBJECT(s), 
    1256                   sample_display_signals[SIG_SELECTION_CHANGED]); 
     2233 
     2234    if (s->selecting == SELECTING_SELECTION_START) { 
     2235      sample_set_playmarker (sample, t->sel_start, TRUE); 
     2236    } else if (s->selecting == SELECTING_SELECTION_END) { 
     2237      sample_set_playmarker (sample, t->sel_end, TRUE); 
     2238    } 
     2239 
     2240    if(s->selection_mode == SELECTION_MODE_REPLACE) { 
     2241      sample_selection_replace_with_tmp_sel (sample); 
     2242    } else if (s->selection_mode == SELECTION_MODE_SUBTRACT) { 
     2243      sample_selection_subtract_tmp_sel (sample);  
     2244    } else { 
     2245      sample_selection_insert_tmp_sel (sample); 
     2246    } 
     2247    s->selection_mode = SELECTION_MODE_NONE; 
     2248 
     2249    gtk_signal_emit(GTK_OBJECT(s), 
     2250                    sample_display_signals[SIG_SELECTION_CHANGED]); 
     2251  } 
    12572252} 
    12582253 
     
    12622257{ 
    12632258  SampleDisplay *s; 
     2259#ifdef SEL_SCRUBS 
     2260  GdkModifierType state; 
     2261  int x, y; 
     2262#endif 
    12642263 
    12652264  g_return_val_if_fail (widget != NULL, FALSE); 
     
    12692268  s = SAMPLE_DISPLAY(widget); 
    12702269 
    1271   switch (current_tool) { 
     2270  switch (s->view->current_tool) { 
    12722271  case TOOL_SELECT: 
    12732272     
     
    12762275     */ 
    12772276    if (s->selecting && event->button == last_button) { 
    1278       sample_display_sink_tmp_sel (s); 
     2277      switch (s->selecting) { 
     2278      case SELECTING_SELECTION_START: 
     2279      case SELECTING_SELECTION_END: 
     2280        sample_display_sink_tmp_sel (s); 
     2281        break; 
     2282      default: 
     2283        break; 
     2284      } 
    12792285    } 
    12802286     
     
    12872293    } 
    12882294 
     2295#ifdef SEL_SCRUBS 
     2296    if (s->view->sample->play_head->scrubbing) { 
     2297      gdk_window_get_pointer (event->window, &x, &y, &state); 
     2298      pause_playback (s->view->sample); 
     2299      sample_display_handle_playmarker_motion (s, x, y); 
     2300    } 
     2301#endif 
     2302 
     2303    break; 
     2304  case TOOL_SCRUB: 
     2305    if (s->meta_down) return TRUE; 
    12892306    break; 
    12902307  case TOOL_MOVE: 
     
    12962313  } 
    12972314 
    1298   SET_CURSOR(widget, crosshair_cr); 
     2315  if (s->meta_down && s->selecting == SELECTING_PLAYMARKER) 
     2316    return TRUE; 
     2317 
     2318  s->selecting = SELECTING_NOTHING; 
     2319 
     2320  sample_set_scrubbing (s->view->sample, FALSE); 
     2321 
     2322  sample_display_set_default_cursor (s); 
    12992323     
    1300   return FALSE; 
    1301 } 
    1302  
    1303 static gint 
    1304 sample_display_on_sel (SampleDisplay * s, gint x, gint y) 
    1305 { 
    1306   GList * gl; 
    1307   sw_sel * sel; 
    1308   int xss, xse; 
    1309  
    1310   for (gl = s->view->sample->sounddata->sels; gl; gl = gl->next) { 
    1311     sel = (sw_sel *)gl->data; 
    1312  
    1313     xss = OFFSET_TO_XPOS(sel->sel_start); 
    1314     xse = OFFSET_TO_XPOS(sel->sel_end); 
    1315  
    1316     if(abs(x-xss) < 3 || abs(x-xse) < 3) 
    1317       return TRUE;     
    1318   } 
    1319  
    13202324  return FALSE; 
    13212325} 
     
    13492353                  sample_display_signals[SIG_MOUSE_OFFSET_CHANGED]); 
    13502354 
    1351   if(!s->selecting) { 
    1352     if (current_tool == TOOL_SELECT && sample_display_on_sel (s, x, y)) { 
    1353       SET_CURSOR(widget, horiz_cr); 
     2355  if (s->selecting) { 
     2356    if (s->meta_down && s->selecting == SELECTING_PLAYMARKER) { 
     2357      sample_display_handle_playmarker_motion (s, x, y); 
     2358    } else if((state & GDK_BUTTON1_MASK) && last_button == 1) { 
     2359      switch (s->selecting) { 
     2360      case SELECTING_PLAYMARKER: 
     2361        sample_display_handle_playmarker_motion (s, x, y); 
     2362        break; 
     2363      case SELECTING_PENCIL: 
     2364        sample_display_handle_pencil_motion (s, x, y); 
     2365        break; 
     2366      case SELECTING_NOISE: 
     2367        sample_display_handle_noise_motion (s, x, y); 
     2368        break; 
     2369      default: 
     2370        sample_display_handle_sel_motion(s, x, y, 0); 
     2371#ifdef SEL_SCRUBS 
     2372        if (s->view->sample->play_head->scrubbing) { 
     2373          sample_display_handle_playmarker_motion (s, x, y); 
     2374        } 
     2375#endif 
     2376        break; 
     2377      } 
     2378    } else if((state & GDK_BUTTON2_MASK) && last_button == 2) { 
     2379      sample_display_handle_move_motion (s, x, y); 
    13542380    } else { 
     2381      /*    sample_display_clear_sel (s);*/ 
     2382      if (s->selecting == SELECTING_SELECTION_START || 
     2383          s->selecting == SELECTING_SELECTION_END) { 
     2384        /* XXX: Need to sink_tmp_sel here instead for consistency ???  
     2385         *  It seems to be clearing fast tmp_sels now, but at least not 
     2386         * leaving them lying around.*/ 
     2387        sample_display_sink_tmp_sel (s); 
     2388 
     2389        sample_display_set_default_cursor (s); 
     2390      } 
     2391    } 
     2392 
     2393  } else { 
     2394    if (s->view->current_tool == TOOL_SELECT && 
     2395        sample_display_on_sel (s, x, y)) { 
     2396      SET_CURSOR(widget, HORIZ); 
     2397    } else if (s->view->current_tool == TOOL_SELECT && 
     2398               sample_display_on_playmarker (s, x, y)) { 
     2399      SET_CURSOR(widget, NEEDLE); 
     2400    } else { 
     2401 
    13552402      if (o > 0 && o < s->view->sample->sounddata->nr_frames) 
    1356         SET_CURSOR(widget, crosshair_cr); 
     2403        sample_display_set_default_cursor (SAMPLE_DISPLAY(widget)); 
    13572404      else 
    13582405        gdk_window_set_cursor (widget->window, NULL); 
     
    13682415    } 
    13692416#endif 
    1370  
    1371     return FALSE; 
    1372   } 
    1373  
    1374   if((state & GDK_BUTTON1_MASK) && last_button == 1) { 
    1375     sample_display_handle_motion(s, x, y, 0); 
    1376   } else if((state & GDK_BUTTON2_MASK) && last_button == 2) { 
    1377     sample_display_handle_motion_2(s, x, y); 
    1378   } else { 
    1379     /*    sample_display_clear_sel (s);*/ 
    1380     sample_display_sink_tmp_sel (s); 
    1381     /* XXX: Need to sink_tmp_sel here instead for consistency ???  
    1382      *  It seems to be clearing fast tmp_sels now, but at least not 
    1383      * leaving them lying around.*/ 
    13842417  } 
    13852418     
    13862419  return FALSE; 
     2420} 
     2421 
     2422static gint 
     2423sample_display_enter_notify (GtkWidget *widget, 
     2424                             GdkEventCrossing *event) 
     2425{ 
     2426  gtk_widget_grab_focus (widget); 
     2427  return TRUE; 
    13872428} 
    13882429 
     
    14012442} 
    14022443 
     2444static gint 
     2445sample_display_focus_in (GtkWidget * widget, GdkEventFocus * event) 
     2446{ 
     2447  SampleDisplay * s; 
     2448 
     2449  g_return_val_if_fail (widget != NULL, FALSE); 
     2450  g_return_val_if_fail (IS_SAMPLE_DISPLAY(widget), FALSE); 
     2451 
     2452  GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); 
     2453  gtk_widget_draw_focus (widget); 
     2454 
     2455  s = SAMPLE_DISPLAY(widget); 
     2456 
     2457  if (s->marching) { 
     2458    sd_start_marching_ants_timeout (s); 
     2459  } 
     2460 
     2461  sample_display_start_cursor_pulse (s); 
     2462 
     2463  undo_dialog_set_sample (s->view->sample); 
     2464 
     2465  return FALSE; 
     2466} 
     2467 
     2468static gint 
     2469sample_display_focus_out (GtkWidget * widget, GdkEventFocus * event) 
     2470{ 
     2471  SampleDisplay * s; 
     2472 
     2473  g_return_val_if_fail (widget != NULL, FALSE); 
     2474  g_return_val_if_fail (IS_SAMPLE_DISPLAY(widget), FALSE); 
     2475 
     2476  GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); 
     2477  gtk_widget_draw_focus (widget); 
     2478 
     2479  s = SAMPLE_DISPLAY(widget); 
     2480 
     2481  sd_stop_marching_ants_timeout (s); 
     2482 
     2483  sample_display_stop_cursor_pulse (s); 
     2484 
     2485  return FALSE;   
     2486} 
     2487 
     2488static gint 
     2489sample_display_key_press (GtkWidget * widget, GdkEventKey * event) 
     2490{ 
     2491  SampleDisplay * s = SAMPLE_DISPLAY(widget); 
     2492  sw_view * view = s->view; 
     2493  sw_sample * sample; 
     2494  sw_framecount_t vlen, move_delta = 0, sel_t; 
     2495  GList * gl; 
     2496  sw_sel * sel; 
     2497  int x, y, xss, xse; 
     2498 
     2499  sample = view->sample; 
     2500  vlen = view->end - view->start; 
     2501 
     2502  /*g_print ("key 0x%X pressed\n", event->keyval);*/ 
     2503 
     2504  switch (event->keyval) { 
     2505  case GDK_Meta_L: 
     2506  case GDK_Super_L: 
     2507  case GDK_Multi_key: 
     2508    if (sample->edit_mode == SWEEP_EDIT_MODE_ALLOC) break; 
     2509 
     2510    s->meta_down = TRUE; 
     2511 
     2512    if (s->selecting == SELECTING_NOTHING) { 
     2513      s->selecting = SELECTING_PLAYMARKER; 
     2514      SET_CURSOR(widget, NEEDLE); 
     2515      sample_set_scrubbing (sample, TRUE); 
     2516    } 
     2517 
     2518    if (s->selecting == SELECTING_PLAYMARKER) { 
     2519      gdk_window_get_pointer (widget->window, &x, &y, NULL); 
     2520      sample_display_handle_playmarker_motion (s, x, y); 
     2521      if (!sample->play_head->going) { 
     2522        play_view_all (s->view); 
     2523      } 
     2524    } 
     2525 
     2526    return TRUE; 
     2527    break; 
     2528  case GDK_Menu: 
     2529    if(view->menu) { 
     2530      gtk_menu_popup(GTK_MENU(view->menu), 
     2531                     NULL, NULL, NULL, 
     2532                     NULL, 3, event->time); 
     2533    } 
     2534    return TRUE; 
     2535    break; 
     2536  case GDK_BackSpace: 
     2537    if (sample->edit_mode == SWEEP_EDIT_MODE_READY) 
     2538      do_clear (sample); 
     2539    return TRUE; 
     2540    break; 
     2541  case GDK_Delete: 
     2542    if (sample->edit_mode == SWEEP_EDIT_MODE_READY) 
     2543      do_delete (sample); 
     2544    return TRUE; 
     2545    break; 
     2546  case GDK_less: 
     2547    if (sample->edit_mode == SWEEP_EDIT_MODE_READY) 
     2548      select_shift_left_cb (widget, s); 
     2549    return TRUE; 
     2550  case GDK_greater: 
     2551    if (sample->edit_mode == SWEEP_EDIT_MODE_READY) 
     2552      select_shift_right_cb (widget, s); 
     2553    return TRUE; 
     2554  case GDK_Up: 
     2555  case GDK_KP_Up: 
     2556    if (event->state & GDK_CONTROL_MASK) { 
     2557      zoom_1to1_cb (GTK_WIDGET(s), s); 
     2558    } else if (event->state & GDK_SHIFT_MASK) { 
     2559      view_vzoom_in (view, 1.2); 
     2560    } else { 
     2561      view_zoom_in (view, 2.0); 
     2562    } 
     2563    return TRUE; 
     2564    break; 
     2565  case GDK_Down: 
     2566  case GDK_KP_Down: 
     2567    if (event->state & GDK_CONTROL_MASK) { 
     2568      zoom_norm_cb (GTK_WIDGET(s), s); 
     2569    } else if (event->state & GDK_SHIFT_MASK) { 
     2570      view_vzoom_out (view, 1.2); 
     2571    } else { 
     2572      view_zoom_out (view, 2.0); 
     2573    } 
     2574    return TRUE; 
     2575    break; 
     2576  case GDK_Left: 
     2577  case GDK_KP_Left: 
     2578    move_delta = MIN(-1,  -vlen/s->width); 
     2579    if (event->state & GDK_CONTROL_MASK) { 
     2580      if (!(event->state & GDK_SHIFT_MASK)) { 
     2581        sample_set_offset_next_bound_left (sample); 
     2582        return TRUE; 
     2583      } 
     2584      move_delta *= 10; 
     2585    } 
     2586    break; 
     2587  case GDK_Right: 
     2588  case GDK_KP_Right: 
     2589    move_delta = MAX(1,  vlen/s->width); 
     2590    if (event->state & GDK_CONTROL_MASK) { 
     2591      if (!(event->state & GDK_SHIFT_MASK)) { 
     2592        sample_set_offset_next_bound_right (sample); 
     2593        return TRUE; 
     2594      } 
     2595      move_delta *= 10; 
     2596    } 
     2597    break; 
     2598  default: /* Random other key pressed */ 
     2599    return FALSE; 
     2600    break; 
     2601  } 
     2602 
     2603  /* Handle movement only from here on */ 
     2604 
     2605  if ((event->state & GDK_SHIFT_MASK) && 
     2606      (sample->edit_mode == SWEEP_EDIT_MODE_READY)) { 
     2607    sel = sample->tmp_sel; 
     2608     
     2609    switch (s->selecting) { 
     2610    case SELECTING_SELECTION_START: 
     2611      sel->sel_start += move_delta; 
     2612      if (sel->sel_start > sel->sel_end) { 
     2613        sel_t = sel->sel_start; 
     2614        sel->sel_start = sel->sel_end; 
     2615        sel->sel_end = sel_t; 
     2616        s->selecting = SELECTING_SELECTION_END; 
     2617      } 
     2618      break; 
     2619    case SELECTING_SELECTION_END: 
     2620      sample->tmp_sel->sel_end += move_delta; 
     2621      if (sel->sel_start > sel->sel_end) { 
     2622        sel_t = sel->sel_start; 
     2623        sel->sel_start = sel->sel_end; 
     2624        sel->sel_end = sel_t; 
     2625        s->selecting = SELECTING_SELECTION_START; 
     2626      } 
     2627      break; 
     2628    default: 
     2629      last_button = 0; 
     2630 
     2631      x = OFFSET_TO_XPOS(sample->user_offset); 
     2632 
     2633      if ((sel = sample->tmp_sel) != NULL) { 
     2634 
     2635        xss = OFFSET_TO_XPOS(sel->sel_start); 
     2636        xse = OFFSET_TO_XPOS(sel->sel_end); 
     2637           
     2638        if(abs(x-xss) < 5) { 
     2639          s->selecting = SELECTING_SELECTION_START; 
     2640          sel->sel_start += move_delta; 
     2641          if (sel->sel_start > sel->sel_end) { 
     2642            sel_t = sel->sel_start; 
     2643            sel->sel_start = sel->sel_end; 
     2644            sel->sel_end = sel_t; 
     2645            s->selecting = SELECTING_SELECTION_END; 
     2646          } 
     2647          break; 
     2648        } else if(abs(x-xse) < 5) {