Changeset 124
- Timestamp:
- 04/23/04 10:15:59 (8 years ago)
- Files:
-
- trunk/sweep/ABOUT-NLS (modified) (10 diffs)
- trunk/sweep/AUTHORS (modified) (4 diffs)
- trunk/sweep/ChangeLog (modified) (1 diff)
- trunk/sweep/Makefile.am (modified) (2 diffs)
- trunk/sweep/NEWS (modified) (1 diff)
- trunk/sweep/README (modified) (4 diffs)
- trunk/sweep/README.ALSA (modified) (1 diff)
- trunk/sweep/README.Solaris (modified) (2 diffs)
- trunk/sweep/README.i18n (added)
- trunk/sweep/TODO (added)
- trunk/sweep/acconfig.h (modified) (2 diffs)
- trunk/sweep/autogen.sh (modified) (1 diff)
- trunk/sweep/configure.in (modified) (8 diffs)
- trunk/sweep/doc/sweep.1 (modified) (1 diff)
- trunk/sweep/include/sweep/Makefile.am (modified) (1 diff)
- trunk/sweep/include/sweep/sweep.h (modified) (1 diff)
- trunk/sweep/include/sweep/sweep_filter.h (modified) (1 diff)
- trunk/sweep/include/sweep/sweep_i18n.h (modified) (2 diffs)
- trunk/sweep/include/sweep/sweep_sample.h (modified) (5 diffs)
- trunk/sweep/include/sweep/sweep_selection.h (modified) (2 diffs)
- trunk/sweep/include/sweep/sweep_sounddata.h (modified) (1 diff)
- trunk/sweep/include/sweep/sweep_types.h (modified) (8 diffs)
- trunk/sweep/include/sweep/sweep_undo.h (modified) (5 diffs)
- trunk/sweep/include/sweep/sweep_version.h (modified) (1 diff)
- trunk/sweep/install-sh (modified) (10 diffs)
- trunk/sweep/intl/ChangeLog (modified) (1 diff)
- trunk/sweep/intl/Makefile.in (modified) (14 diffs)
- trunk/sweep/intl/VERSION (modified) (1 diff)
- trunk/sweep/intl/bindtextdom.c (modified) (6 diffs)
- trunk/sweep/intl/dcgettext.c (modified) (5 diffs)
- trunk/sweep/intl/dgettext.c (modified) (2 diffs)
- trunk/sweep/intl/explodename.c (modified) (2 diffs)
- trunk/sweep/intl/finddomain.c (modified) (10 diffs)
- trunk/sweep/intl/gettext.c (modified) (4 diffs)
- trunk/sweep/intl/gettext.h (modified) (2 diffs)
- trunk/sweep/intl/gettextP.h (modified) (5 diffs)
- trunk/sweep/intl/hash-string.h (modified) (1 diff)
- trunk/sweep/intl/intl-compat.c (modified) (5 diffs)
- trunk/sweep/intl/l10nflist.c (modified) (5 diffs)
- trunk/sweep/intl/libgettext.h (modified) (2 diffs)
- trunk/sweep/intl/loadinfo.h (modified) (5 diffs)
- trunk/sweep/intl/loadmsgcat.c (modified) (12 diffs)
- trunk/sweep/intl/localealias.c (modified) (14 diffs)
- trunk/sweep/intl/textdomain.c (modified) (6 diffs)
- trunk/sweep/missing (modified) (12 diffs)
- trunk/sweep/mkinstalldirs (modified) (3 diffs)
- trunk/sweep/pixmaps (added)
- trunk/sweep/pixmaps/Makefile.am (added)
- trunk/sweep/pixmaps/SRC.xpm (added)
- trunk/sweep/pixmaps/copy.xpm (added)
- trunk/sweep/pixmaps/crop.xpm (added)
- trunk/sweep/pixmaps/cut.xpm (added)
- trunk/sweep/pixmaps/done.xpm (added)
- trunk/sweep/pixmaps/eye.xpm (added)
- trunk/sweep/pixmaps/ff.xpm (added)
- trunk/sweep/pixmaps/hand.xbm (added)
- trunk/sweep/pixmaps/hand_mask.xbm (added)
- trunk/sweep/pixmaps/headphones.xpm (added)
- trunk/sweep/pixmaps/headphones2.xpm (added)
- trunk/sweep/pixmaps/horiz.xpm (added)
- trunk/sweep/pixmaps/horiz_minus.xpm (added)
- trunk/sweep/pixmaps/horiz_plus.xpm (added)
- trunk/sweep/pixmaps/info.xpm (added)
- trunk/sweep/pixmaps/ladlogo.xpm (added)
- trunk/sweep/pixmaps/libsndfile.xpm (added)
- trunk/sweep/pixmaps/loop.xpm (added)
- trunk/sweep/pixmaps/lowleft.xpm (added)
- trunk/sweep/pixmaps/lowright.xpm (added)
- trunk/sweep/pixmaps/mdx.ico (added)
- trunk/sweep/pixmaps/mic.xpm (added)
- trunk/sweep/pixmaps/mouse.xpm (added)
- trunk/sweep/pixmaps/mute.xpm (added)
- trunk/sweep/pixmaps/needle.xbm (added)
- trunk/sweep/pixmaps/needle_mask.xbm (added)
- trunk/sweep/pixmaps/new.xpm (added)
- trunk/sweep/pixmaps/nexttrk.xpm (added)
- trunk/sweep/pixmaps/noloop.xpm (added)
- trunk/sweep/pixmaps/open.xpm (added)
- trunk/sweep/pixmaps/paste.xpm (added)
- trunk/sweep/pixmaps/pastemix.xpm (added)
- trunk/sweep/pixmaps/pastexfade.xpm (added)
- trunk/sweep/pixmaps/pencil.xpm (added)
- trunk/sweep/pixmaps/ping_kanji.xpm (added)
- trunk/sweep/pixmaps/playpaus.xpm (added)
- trunk/sweep/pixmaps/playpsel.xpm (added)
- trunk/sweep/pixmaps/playrev.xpm (added)
- trunk/sweep/pixmaps/prevtrk.xpm (added)
- trunk/sweep/pixmaps/record.xpm (added)
- trunk/sweep/pixmaps/record_dialog.xpm (added)
- trunk/sweep/pixmaps/record_stop.xpm (added)
- trunk/sweep/pixmaps/recpause.xpm (added)
- trunk/sweep/pixmaps/recpausesel.xpm (added)
- trunk/sweep/pixmaps/redo.xpm (added)
- trunk/sweep/pixmaps/rew.xpm (added)
- trunk/sweep/pixmaps/save.xpm (added)
- trunk/sweep/pixmaps/saveas.xpm (added)
- trunk/sweep/pixmaps/scroll.xpm (added)
- trunk/sweep/pixmaps/scrub.xpm (added)
- trunk/sweep/pixmaps/scrubby.xpm (added)
- trunk/sweep/pixmaps/scrubby_system.xpm (added)
- trunk/sweep/pixmaps/select.xpm (added)
- trunk/sweep/pixmaps/spraycan.xpm (added)
- trunk/sweep/pixmaps/stop.xpm (added)
- trunk/sweep/pixmaps/sweep.ico (added)
- trunk/sweep/pixmaps/sweep_kanji.xpm (added)
- trunk/sweep/pixmaps/undo.xpm (added)
- trunk/sweep/pixmaps/upleft.xpm (added)
- trunk/sweep/pixmaps/upright.xpm (added)
- trunk/sweep/pixmaps/vol.xpm (added)
- trunk/sweep/pixmaps/vorbisword2.xpm (added)
- trunk/sweep/pixmaps/white-ogg.xpm (added)
- trunk/sweep/pixmaps/white-xifish.xpm (added)
- trunk/sweep/pixmaps/xifish.xpm (added)
- trunk/sweep/pixmaps/zoom_all.xpm (added)
- trunk/sweep/pixmaps/zoom_in.xbm (added)
- trunk/sweep/pixmaps/zoom_in.xpm (added)
- trunk/sweep/pixmaps/zoom_in_mask.xbm (added)
- trunk/sweep/pixmaps/zoom_out.xbm (added)
- trunk/sweep/pixmaps/zoom_out.xpm (added)
- trunk/sweep/pixmaps/zoom_out_mask.xbm (added)
- trunk/sweep/plugins/Makefile.am (modified) (1 diff)
- trunk/sweep/plugins/byenergy/byenergy.c (modified) (8 diffs)
- trunk/sweep/plugins/example/Makefile.am (modified) (1 diff)
- trunk/sweep/plugins/fade (added)
- trunk/sweep/plugins/fade/Makefile.am (added)
- trunk/sweep/plugins/fade/fade.c (added)
- trunk/sweep/plugins/ladspa/ladspa.h (modified) (10 diffs)
- trunk/sweep/plugins/ladspa/ladspameta.c (modified) (18 diffs)
- trunk/sweep/src/Makefile.am (modified) (3 diffs)
- trunk/sweep/src/about_dialog.c (modified) (5 diffs)
- trunk/sweep/src/callbacks.c (modified) (26 diffs)
- trunk/sweep/src/callbacks.h (modified) (10 diffs)
- trunk/sweep/src/channelops.c (added)
- trunk/sweep/src/channelops.h (added)
- trunk/sweep/src/cursors.c (modified) (2 diffs)
- trunk/sweep/src/cursors.h (modified) (2 diffs)
- trunk/sweep/src/db_ruler.c (added)
- trunk/sweep/src/db_ruler.h (added)
- trunk/sweep/src/db_slider.c (added)
- trunk/sweep/src/db_slider.h (added)
- trunk/sweep/src/driver.c (modified) (2 diffs)
- trunk/sweep/src/driver.h (modified) (1 diff)
- trunk/sweep/src/driver_alsa.c (added)
- trunk/sweep/src/driver_oss.c (added)
- trunk/sweep/src/driver_solaris.c (added)
- trunk/sweep/src/edit.c (modified) (29 diffs)
- trunk/sweep/src/edit.h (modified) (3 diffs)
- trunk/sweep/src/file_dialogs.c (modified) (6 diffs)
- trunk/sweep/src/file_dialogs.h (modified) (2 diffs)
- trunk/sweep/src/file_mad.c (added)
- trunk/sweep/src/file_sndfile.h (added)
- trunk/sweep/src/file_sndfile0.c (added)
- trunk/sweep/src/file_sndfile1.c (added)
- trunk/sweep/src/file_speex.c (added)
- trunk/sweep/src/file_vorbis.c (added)
- trunk/sweep/src/format.c (modified) (1 diff)
- trunk/sweep/src/head.c (added)
- trunk/sweep/src/head.h (added)
- trunk/sweep/src/interface.c (modified) (8 diffs)
- trunk/sweep/src/interface.h (modified) (1 diff)
- trunk/sweep/src/levelmeter.c (added)
- trunk/sweep/src/levelmeter.h (added)
- trunk/sweep/src/main.c (modified) (9 diffs)
- trunk/sweep/src/notes.c (modified) (2 diffs)
- trunk/sweep/src/notes.h (modified) (1 diff)
- trunk/sweep/src/param.c (modified) (20 diffs)
- trunk/sweep/src/paste_dialogs.c (added)
- trunk/sweep/src/paste_dialogs.h (added)
- trunk/sweep/src/pcmio.h (added)
- trunk/sweep/src/pixmaps.h (modified) (2 diffs)
- trunk/sweep/src/play.c (added)
- trunk/sweep/src/play.h (added)
- trunk/sweep/src/plugin.c (modified) (4 diffs)
- trunk/sweep/src/preferences.c (added)
- trunk/sweep/src/preferences.h (added)
- trunk/sweep/src/print.c (modified) (6 diffs)
- trunk/sweep/src/print.h (modified) (3 diffs)
- trunk/sweep/src/question_dialogs.c (added)
- trunk/sweep/src/question_dialogs.h (added)
- trunk/sweep/src/record.c (added)
- trunk/sweep/src/record.h (added)
- trunk/sweep/src/sample-display.c (modified) (60 diffs)
- trunk/sweep/src/sample-display.h (modified) (9 diffs)
- trunk/sweep/src/sample.h (modified) (3 diffs)
- trunk/sweep/src/samplerate.c (added)
- trunk/sweep/src/sw_chooser.c (added)
- trunk/sweep/src/sw_chooser.h (added)
- trunk/sweep/src/sweep_app.h (modified) (3 diffs)
- trunk/sweep/src/sweep_filter.c (modified) (4 diffs)
- trunk/sweep/src/sweep_sample.c (modified) (23 diffs)
- trunk/sweep/src/sweep_selection.c (modified) (7 diffs)
- trunk/sweep/src/sweep_sounddata.c (modified) (10 diffs)
- trunk/sweep/src/sweep_typeconvert.c (modified) (2 diffs)
- trunk/sweep/src/sweep_undo.c (modified) (20 diffs)
- trunk/sweep/src/time_ruler.c (modified) (13 diffs)
- trunk/sweep/src/time_ruler.h (modified) (1 diff)
- trunk/sweep/src/timeouts.c (added)
- trunk/sweep/src/undo_dialog.c (added)
- trunk/sweep/src/undo_dialog.h (added)
- trunk/sweep/src/view.c (modified) (60 diffs)
- trunk/sweep/src/view.h (modified) (5 diffs)
- trunk/sweep/src/view_pixmaps.h (modified) (1 diff)
- trunk/sweep/sweep.desktop (modified) (1 diff)
- trunk/sweep/sweep.png (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/sweep/ABOUT-NLS
r7 r124 9 9 If you found this `ABOUT-NLS' file inside a distribution, you may 10 10 assume that the distributed package does use GNU `gettext' internally, 11 itself available at your nearest GNU archive site. But you do *not*11 itself available at your nearest GNU archive site. But you do _not_ 12 12 need to install GNU `gettext' prior to configuring, installing or using 13 13 this package with messages translated. … … 23 23 `intl/VERSION' file, in internationalized packages. 24 24 25 One advise in advance26 ===================== 25 Quick configuration advice 26 ========================== 27 27 28 28 If you want to exploit the full power of internationalization, you … … 35 35 operating system where this package is being installed. So far, only 36 36 the `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 37 many features (such as locale alias, message inheritance, automatic 38 charset conversion or plural form handling) as the implementation here. 39 It is also not possible to offer this additional functionality on top 40 of a `catgets' implementation. Future versions of GNU `gettext' will 41 very likely convey even more functionality. So it might be a good idea 42 to 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 44 45 you have installed a recent copy of the GNU gettext package with the 45 46 included `libintl'. … … 54 55 55 56 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 57 messages. It will automatically detect whether the system already 58 provides the GNU `gettext' functions. If not, the GNU `gettext' own 59 59 library will be used. This library is wholly contained within this 60 60 package, usually in the `intl/' subdirectory, so prior installation of 61 the GNU `gettext' package is *not*required. Installers may use61 the GNU `gettext' package is _not_ required. Installers may use 62 62 special options at configuration time for changing the default 63 63 behaviour. The commands: 64 64 65 65 ./configure --with-included-gettext 66 ./configure --with-catgets67 66 ./configure --disable-nls 68 67 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. 68 will respectively bypass any pre-existing `gettext' to use the 69 internationalizing routines provided within this package, or else, 70 _totally_ disable translation of messages. 73 71 74 72 When you already have GNU `gettext' installed on your system and run … … 84 82 to prevent auto-detection. 85 83 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 85 and therefore it will not be used. The reason is that even an 86 emulation of `gettext' on top of `catgets' could not provide all the 87 extensions of the GNU `gettext' library. 98 88 99 89 Internationalized packages have usually many `po/LL.po' files, where … … 111 101 As a user, if your language has been installed for this package, you 112 102 only 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, 104 and `CC' is an ISO 3166 two-letter country code. For example, let's 105 suppose that you speak German and live in Germany. At the shell 106 prompt, merely execute `setenv LANG de_DE' (in `csh'), 107 `export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). 108 This can be done from your `.login' or `.profile' file, once and for 109 all. 110 111 You might think that the country code specification is redundant. 112 But in fact, some languages have dialects in different countries. For 113 example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The 114 country code serves to distinguish the dialects. 115 116 Not all programs have translations for all languages. By default, an 117 English message is shown in place of a nonexistent translation. If you 118 understand other languages, you can set up a priority list of languages. 119 This is done through a different environment variable, called 120 `LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG' 121 for the purpose of message handling, but you still need to have `LANG' 122 set to the primary language; this is required by other parts of the 123 system libraries. For example, some Swedish users who would rather 124 read translations in German than English for when Swedish is not 125 available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'. 126 127 In the `LANGUAGE' environment variable, but not in the `LANG' 128 environment variable, `LL_CC' combinations can be abbreviated as `LL' 129 to denote the language's main dialect. For example, `de' is equivalent 130 to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' 131 (Portuguese as spoken in Portugal) in this context. 129 132 130 133 Translating Teams … … 134 137 people who like their own language and write it well, and who are also 135 138 able 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 139 Each translation team has its own mailing list. The up-to-date list of 140 teams can be found at the Free Translation Project's homepage, 141 `http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams" 142 area. 143 144 If you'd like to volunteer to _work_ at translating messages, you 154 145 should become a member of the translating team for your own language. 155 The subscribing address is *not*the same as the list itself, it has146 The subscribing address is _not_ the same as the list itself, it has 156 147 `-request' appended. For example, speakers of Swedish can send a 157 148 message to `sv-request@li.org', having this message body: … … 160 151 161 152 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, 163 154 rather than merely lurking around. If your team does not exist yet and 164 155 you want to start one, or if you are unsure about what to do or how to … … 174 165 175 166 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 167 matrix shows the current state of internationalization, as of September 168 2001. The matrix shows, in regard of each package, for which languages 169 PO files have been submitted to translation coordination, with a 170 translation 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 212 289 213 290 Some counters in the preceding matrix are higher than the number of … … 222 299 distribution. 223 300 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 302 of this `ABOUT-NLS' file on most GNU archive sites. The most 303 up-to-date matrix with full percentage details can be found at 304 `http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'. 305 306 Using `gettext' in new packages 307 =============================== 308 309 If you are writing a freely available program and want to 310 internationalize it you are welcome to use GNU `gettext' in your 311 package. Of course you have to respect the GNU Library General Public 312 License which covers the use of the GNU `gettext' library. This means 313 in particular that even non-free programs can use `libintl' as a shared 314 library, whereas only free software can use `libintl' as a static 315 library or use modified versions of `libintl'. 316 317 Once the sources are changed appropriately and the setup can handle 318 to use of `gettext' the only thing missing are the translations. The 319 Free Translation Project is also available for packages which are not 320 developed inside the GNU project. Therefore the information given above 321 applies also for every other Free Software Project. Contact 322 `translation@iro.umontreal.ca' to make the `.pot' files available to 323 the translation teams. 324 trunk/sweep/AUTHORS
r123 r124 29 29 bug fix in save as dialog 30 30 31 Erik de Castro Lopo <erikd@zip.com.au> 32 libsndfile-1 file import/export, random bugfixes 33 34 Zenaan Harkness <zen@getsystems.com> 35 improved handling of volume and pitch sliders 36 31 37 Borrowed Code 32 38 ============= 33 39 34 40 Michael Krause <m.krause@tu=harburg.de> 35 Basic code for sample=display widget from soundtracker.41 sample-display widget adapted from Soundtracker. 36 42 37 43 Spencer Kimball and Peter Mattis 38 44 about_dialog.c adapted from the Gimp. 45 46 Mike Oliphant 47 transport buttons, LCD screen and style handling code from Grip 48 49 Christopher 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 53 Robert Leslie 54 MPEG audio decoding adapted from player.c in the mad source 55 56 Jean-Marc Valin 57 Speex encoding and decoding adapted from speexenc and speexdec 39 58 40 59 … … 42 61 ============ 43 62 63 Dokianakis Fanis <madf@hellug.gr> 64 el 65 44 66 Mathieu Roy <yeupou@altern.org> 45 fr 67 fr (Sweep 0.1.x) 46 68 47 69 Gergely Nagy <mhp@lonyay.edu.hu> 48 hu 70 hu (Sweep 0.1.x) 49 71 50 72 Yuri Bongiorno <yurix@tiscalinet.it> … … 54 76 de 55 77 56 Yuri Victorovich <yuri@tsoft.com> 78 Alexandre Prokoudine <avp@altlinux.ru> 79 Yuri Victorovich <yuri@tsoft.com> (Sweep 0.1.x) 57 80 ru 58 81 59 82 Radoslaw Korzeniewski <Radoslaw.Korzeniewski@centertel.pl> 60 pl 83 pl (Sweep 0.1.x) 84 61 85 62 86 Artwork 63 87 ======= 64 88 89 Mike Oliphant 90 Transport button pixmaps (adapted from Grip) 91 65 92 Mathieu Roy <yeupou@altern.org> 66 Colourful button pixmaps 93 Colourful button pixmaps in Sweep 0.1.x 94 95 Conrad Parker <conrad@vergenet.net> 96 General pixmaps, Scrubby 67 97 68 98 … … 72 102 Anand Kumria <akumria@debian.org> 73 103 Debian packages 104 105 Julio Merino Vidal <jmmv@hispabsd.org> 106 NetBSD packages (+ contributed configure and build fixes) 74 107 75 108 trunk/sweep/ChangeLog
r123 r124 1 Sat 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 9 Tue 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 13 Tue 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 18 Tue 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 24 Tue 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 29 Thu 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 33 Mon Feb 3 22:33:04 EST 2003 Conrad Parker <conrad@metadecks.org> 34 35 * edit.c: updated splice_in_eb to use realloc 36 37 Wed 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 47 Sat 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 53 Fri 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 62 Fri 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 68 Thu 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 76 Thu 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 82 Wed 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 92 Tue Nov 26 12:19:21 EST 2002 Conrad Parker <conrad@metadecks.org> 93 94 * samplerate.c: updated for libsamplerate-0.0.11 95 96 Mon 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 101 Sat 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 110 Fri 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 115 Thu Oct 31 11:07:29 EST 2002 Conrad Parker <conrad@metadecks.org> 116 117 * channelops.c: removed broken reference to <samplerate.h> 118 119 Wed 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 128 Wed 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 135 Sun 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 140 Tue 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 145 21 Oct 2002 07:36:38 +1100 Zenaan Harkness <zen@getsystems.com> 146 147 * view.c: nicer volume & pitch slider adjustments 148 149 Sat Oct 19 03:16:19 EST 2002 Conrad Parker <conrad@metadecks.org> 150 151 * file_speex.c: new file -- Speex import/export 152 153 Thu Oct 17 16:40:53 EST 2002 Conrad Parker <conrad@metadecks.org> 154 155 * file_dialogs.c: added "MP3 export unsupported" dialog 156 157 Wed 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 167 Mon 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 171 Mon 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 175 Thu Oct 10 11:38:24 EST 2002 Conrad Parker <conrad@metadecks.org> 176 177 * file_sndfile0.c: backported all error checking etc. 178 179 Wed 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 185 Wed 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 195 Tue 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 208 Sat 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 213 Wed 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 218 Sun 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 224 Wed 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 228 Wed 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 234 Mon 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 241 Sat 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 251 Wed 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 259 Tue 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 269 Wed 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 280 Sun 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 291 Thu Sep 5 21:31:18 EST 2002 Conrad Parker <conrad@metadecks.org> 292 293 * modified selection modification to invoke scrubbing 294 295 Wed 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 299 Tue 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 308 Mon 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 316 Sun 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 321 Tue 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 1 326 Sat May 5 20:51:26 -0500 2001 <ben@slumber.dhs.org> 2 327 trunk/sweep/Makefile.am
r84 r124 8 8 desktopdir = $(datadir)/gnome/apps/Multimedia 9 9 10 icon_DATA = sweep.png 11 icondir = $(datadir)/pixmaps 10 pixmapdir = $(datadir)/pixmaps 11 pixmap_DATA = sweep.png 12 12 13 EXTRA_DIST = $(desktop_DATA) $( icon_DATA) $(pkgdata_DATA) \14 sweep.spec README.Solaris README.ALSA acconfig.h13 EXTRA_DIST = $(desktop_DATA) $(pkgdata_DATA) $(pixmap_DATA) \ 14 sweep.spec README.Solaris README.ALSA README.i18n acconfig.h TODO 15 15 16 16 MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config.h.in \ … … 20 20 ltmain.sh acinclude.m4 21 21 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 fi22 #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 32 32 33 33 dist-hook: trunk/sweep/NEWS
r7 r124 1 Wed Apr 30 2003 -- Version 0.8.2 2 -------------------------------- 3 4 This release contains support for ALSA 0.9; this is configurable and could 5 do with widespread testing. 6 7 To build with ALSA support, simply configure with: 8 9 ./configure --enable-alsa 10 11 Note that this will build a binary which will work with ALSA only, and 12 not attempt to use OSS. In future this will be replaced with plugins 13 for different pcm i/o methods, which should ease binary distribution. 14 15 16 Internationalization (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 27 There is a new mailing list: sweep-i18n. List information is at 28 http://lists.sourceforge.net/lists/listinfo/sweep-i18n 29 30 31 Additional 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 37 Events: 38 39 Conrad 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 48 Plus, 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 54 Thu Feb 6 2003 -- Version 0.8.1 55 -------------------------------- 56 57 This release contains performance improvements for basic editing operations, 58 including reduced memory consumption during cut and paste insert. It also 59 includes support for creation of new files on the command line, updated 60 handling of raw file loading through libsndfile, and updated support for 61 voice activity detection and intensity stereo coding features of the Speex 62 speech codec. 63 64 Sat Jan 18 2003 -- Version 0.8.0 65 -------------------------------- 66 67 This is the first milestone release for Sweep 1. Please test it thoroughly 68 for both general sample editing and live performance! For more information, 69 see http://www.metadecks.org/ . 70 71 New 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 83 New 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 94 Sat Jan 4 2003 -- Open Sound System's killer app of the month 95 ------------------------------------------------------------- 96 97 Sweep has been selected as the killer app of the month for January 2003 by 98 Open Sound System (OSS), developers of the most widely used digital audio 99 architecture for UNIX. 100 101 102 Fri Dec 20 2002 -- Version 0.5.13 103 --------------------------------- 104 105 This release contains build fixes for NetBSD and cleanups by Erik de 106 Castro Lopo to fix preprocessor pasting warnings. 107 108 It also features new fade in and fade out filters. 109 110 Conrad will be presenting two sessions at linux.conf.au, January 22-25 2003 111 in Perth, Australia; a tutorial titled "Using Sweep: Fun with Scrubby", and 112 an overview of Sweep's internals and plugin development. 113 114 115 Fri Dec 6 2002 -- Version 0.5.12 116 --------------------------------- 117 118 New 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 134 Bugs were fixed in MP3 loading and pitched playback (using QWERTY keys). 135 136 137 Thu Nov 28 2002 -- Version 0.5.11 138 --------------------------------- 139 140 New 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 159 Additionally, minor bugs were fixed affecting portability of system error 160 handling and detection of MP3 files. 161 162 163 Thu Oct 31 2002 -- Version 0.5.10a 164 ---------------------------------- 165 166 This is an update to 0.5.10 which fixes a compilation error in the default 167 build. 168 169 Wed Oct 30 2002 -- Version 0.5.10 170 --------------------------------- 171 172 New features in this release include vertical zoom with a draggable dB scale 173 and mouse wheel control, and some basic channel operations: Duplicate to 174 stereo/multichannel, Swap left and right, Remove left/right, Mix down to 175 mono, and Add/Remove channels. 176 177 This release also includes compile fixes for Solaris, and a bug fix for 178 first-time file 'save'. 179 180 A new section for screenshots contributed by users was recently added to the 181 screenshot tour: 182 183 http://www.metadecks.org/software/sweep/screenshots/ 184 185 186 Wed Oct 23 2002 -- Version 0.5.9 187 -------------------------------- 188 189 Sweep now supports Speex, a special purpose speech codec designed for 190 efficient Voice over IP (VoIP) and file-based compression. Speex is free, 191 open and unpatented; more information is available at http://www.speex.org/. 192 193 This release also includes improved handling of the main volume and pitch 194 sliders, contributed by Zenaan Harkness. 195 196 197 Thu Oct 17 2002 -- Version 0.5.8 198 -------------------------------- 199 200 MP3 import is now supported. Minor bugs have been fixed in rendering of 201 record position and playback mixing. 202 203 There is a new page of audio demos made with Sweep. These demonstrate the 204 sounds of Scrubby, a tool which allows vinyl-like manipulation of digital 205 audio: 206 207 http://www.metadecks.org/software/sweep/demos.html 208 209 210 Fri Oct 11 2002 -- Version 0.5.7 211 -------------------------------- 212 213 This version includes support for Ogg Vorbis import and export, including 214 both variable and average bitrate encoding modes. There are many other 215 user interface updates, including new input controls for sample rates and 216 channels, and question, information and system error dialogs. 217 218 There is a new Screenshot tour of Sweep, including many screenshots of 219 the new dialogs and general editing: 220 221 http://www.metadecks.org/software/sweep/screenshots/ 222 223 224 Wed Sep 25 2002 -- Version 0.5.6 and Sweep Demo at SLUG 225 ------------------------------------------------------- 226 227 Changes in this version include monitoring of file modification, "are you 228 sure" dialogs, file revert, and many minor bug fixes. 229 230 There will be a demo of the latest Sweep features, including live DJing and 231 experimental music techniques and the Sydney LUG meeting on Sep. 27 2002; 232 see http://www.slug.org.au/ for details. 233 234 Fri Sep 20 2002 -- Version 0.5.5 235 -------------------------------- 236 237 Changes since version 0.5.4 include major bugfixes for LADSPA plugin 238 handling and improvements in scrubbing usability. 239 240 Wed Sep 11 2002 -- Version 0.5.4 241 -------------------------------- 242 243 Changes since version 0.5.3 (September 5 2002) include bug fixes for 244 playback during destructive operations and for edits of tiny regions, 245 and improvements in configuration checks for libsndfile-1.0.0. 246 247 Additionally, scrubbing is now working for reverse playback, and has been 248 tuned for responsiveness independent of sample rate. 249 250 There is now a web page introducing Scrubby and outlining a few simple 251 editing and live performance techniques: 252 253 http://www.metadecks.org/software/sweep/scrub.html 254 255 256 Thu Sep 5 2002 -- Version 0.5.3 257 -------------------------------- 258 259 This release incorporates robust configuration checking to help new users 260 compile from source. After a long period of quiet development we are now 261 beginning to roll this out for general public usage, and your testing and 262 feedback is very welcome! 263 264 Changes since 0.1.1 (October 2000) include interactive scrubbing, recording, 265 support for LADSPA 1.1 effects plugins and multichannel sound files, 266 multithreaded background rendering, unlimited undo/redo, mouse wheel zooming, 267 reverse playback and overall stability and usability improvements. 268 269 Changes since version 0.5.0 (August 12 2002) include preferences saving and 270 support for libsndfile 1.0.0. 271 272 Changes since version 0.5.1 (August 29 2002) include improved configure 273 checks and porting fixes. Additionally, Sweep now remembers the last used 274 file load and save directories between sessions. 275 276 Changes since version 0.5.2 (September 4 2002) include the fixing of a bug 277 in "save as", and (NEW) audible scrubbing when selecting regions. 1 278 2 279 Mon, 1 May 2000 trunk/sweep/README
r7 r124 1 1 2 Sweep, a sound wave editor. 2 SWEEP, a sound wave editor, brought to you by Conrad Parker 3 ----------------------------------------------------------- 3 4 4 Copyright (C) 2000 Conrad Parker 5 Sweep is an audio editor and live playback tool for GNU/Linux, BSD and 6 compatible systems. It supports many music and voice formats including 7 WAV, AIFF, Ogg Vorbis, Speex and MP3, with multichannel editing and 8 LADSPA effects plugins. Inside lives a pesky little virtual stylus called 9 Scrubby who enjoys mixing around in your files. 10 11 Sweep is designed to be intuitive and to give you full control. It includes 12 almost 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 5 29 6 30 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. 31 Summary of library dependencies: 32 -------------------------------- 33 34 REQUIRED: 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 52 OPTIONAL: 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 66 See the file INSTALL for building instructions. Generally all that is 67 required, after the above libraries have been installed, is: 68 69 ./configure 70 make 71 make install 72 73 If you are not sure what you need, simply run ./configure and it will probe 74 your system and provide a reasonably useful summary. 75 76 For information on enabling and disabling optional components, run 77 ./configure --help 11 78 12 79 Homepage … … 20 87 ------------- 21 88 22 There are t womailing lists related to sweep:89 There are three mailing lists related to sweep: 23 90 24 sweep-announce .91 sweep-announce 25 92 which contains only announcements about new releases of sweep. 26 93 This is a moderated list. 27 94 28 sweep- devel.29 For general discussion about sweep and development related issues. 95 sweep-users 96 For general discussion about using sweep 30 97 31 Archives of both lists are available on the World Wide Web via the 98 sweep-devel 99 For discussion about sweep development related issues. 100 101 Archives of each list are available on the World Wide Web via the 32 102 Sweep homepage. You can also subscribe or unsubscribe via a web 33 103 interface. … … 38 108 39 109 sweep-announce-request@lists.sourceforge.net 110 or 111 sweep-users-request@lists.sourceforge.net 40 112 or 41 113 sweep-devel-request@lists.sourceforge.net … … 62 134 USA. 63 135 136 Acknowledgements 137 ---------------- 138 139 Thanks to Pixar Animation Studios and CSIRO Australia for supporting 140 the development of this project. 141 64 142 Contact 65 143 ------- 66 144 67 If you have any further queries about Sweep, please contact the 145 If you have any further queries about Sweep, please contact the main 68 146 author: 69 147 trunk/sweep/README.ALSA
r54 r124 1 Wed Apr 30 2003 2 --------------- 3 4 Support for ALSA 0.9 is functional and could do with widespread testing. 5 6 To build with alsa support, simply configure with: 7 8 ./configure --enable-alsa 9 10 Note that this will build a binary which will work with ALSA only, and 11 not attempt to use OSS. In future this will be replaced with plugins 12 for different pcm i/o methods, which should ease binary distribution. 13 14 Wed Sep 11 2002 15 --------------- 16 17 ALSA native support it currently not working; to even attempt to build the 18 code, you must configure with: 19 20 ./configure --enable-experimental --enable-alsa 21 22 However, Sweep works fine with ALSA under OSS emulation. 23 1 24 Sat Oct 7 2000 25 --------------- 2 26 3 27 Support for ALSA (Advanced Linux Sound Architecture) version 0.6.0 was trunk/sweep/README.Solaris
r7 r124 1 Wed Oct 30 2002 2 --------------- 3 4 Some compile fixes were applied as listed in Sourceforge bug #625528. 5 Please contact sweep-devel@lists.sf.net if you have any problems building 6 or running Sweep on Solaris. 7 1 8 Fri May 12 2000 9 --------------- 2 10 3 11 Solaris audio support was added in sweep version 0.0.9 by Mattias … … 19 27 displeased with the behaviour, I could outline a way to 20 28 solve it. 21 trunk/sweep/acconfig.h
r53 r124 1 1 #undef ENABLE_NLS 2 2 #undef HAVE_CATGETS 3 #undef HAVE_LIBAUDIOFILE4 3 #undef HAVE_GETTEXT 5 4 #undef HAVE_LC_MESSAGES … … 11 10 #undef PACKAGE_SOURCE_DIR 12 11 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 13 24 #undef DRIVER_OSS 14 25 #undef DRIVER_ALSA trunk/sweep/autogen.sh
r61 r124 1 1 #!/bin/sh 2 2 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 14 clean () 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 30 if test "x$1" = "xclean"; then 31 set -x 32 clean 33 set +x 34 exit 0 35 fi 36 37 38 39 # 40 # check automake version number -- we require >= 1.5 41 # 42 43 automake_version="none" 44 if automake-1.7 --version >/dev/null 2>&1; then 45 automake_version="-1.7" 46 elif automake-1.6 --version >/dev/null 2>&1; then 47 automake_version="-1.6" 48 elif automake-1.5 --version >/dev/null 2>&1; then 49 automake_version="-1.5" 50 elif 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 60 fi 61 62 if test "x${automake_version}" = "xnone"; then 63 set +x 64 echo "you need automake version 1.5 or later" 65 exit 1 66 fi 67 68 automake_version_major=`echo "$automake_version" | cut -d. -f2` 69 automake_version_minor=`echo "$automake_version" | cut -d. -f3` 70 71 # need at least automake >= 1.5 72 if 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 75 fi 76 77 78 # 79 # do we need pkg-config? 80 # 81 82 if grep -q PKG_CHECK_MODULES configure.*; then 83 if ! pkg-config --version > /dev/null 2> /dev/null; then 84 cat << EOF 85 pkg-config is required, but it's not installed or can't be found in your 86 search path. 87 88 EOF 89 # be nice to the user if they have fink! 90 if test -d /sw ; then 91 cat << EOF 92 You can install it via Fink with the command: 93 94 apt-get install pkgconfig 95 96 EOF 97 fi 98 exit 1 99 fi 100 fi 101 102 103 # 104 # autogoat bootstrap process 105 # 106 107 ACLOCAL=${ACLOCAL:-aclocal} 108 AUTOCONF=${AUTOCONF:-autoconf} 109 AUTOHEADER=${AUTOHEADER:-autoheader} 110 AUTOMAKE=${AUTOMAKE:-automake} 111 112 # clean out old cruft 113 clean 114 115 # add Fink's /sw path to various search directories 116 if [ -d /sw ]; then 117 ACLOCAL="$ACLOCAL -I /sw/share/aclocal" 118 FINK_DETECTED=1 119 fi 120 121 eval "$ACLOCAL" 122 123 # do we need libtool? 124 if 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 144 fi 145 146 eval "$AUTOCONF" 147 grep -q CONFIG_HEADER configure.* && "$AUTOHEADER" 148 eval "$AUTOMAKE" --add-missing --copy 149 150 # Print warning message if Fink detected 151 if test "$FINK_DETECTED" = 1; then 152 cat << EOF 153 154 Fink detected; added /sw/share/aclocal to aclocal's include directories. 155 Make sure you have CPPFLAGS, LDFLAGS and PKG_CONFIG_PATH including Fink's 156 distribution 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 164 EOF 165 fi 166 trunk/sweep/configure.in
r119 r124 2 2 3 3 AC_INIT(configure.in) 4 AM_INIT_AUTOMAKE(sweep, 0. 1.1)5 AM_CONFIG_HEADER( include/sweep/config.h)4 AM_INIT_AUTOMAKE(sweep, 0.8.2) 5 AM_CONFIG_HEADER(config.h) 6 6 7 7 AC_ISC_POSIX … … 11 11 AM_PROG_LIBTOOL 12 12 13 AC_CHECK_PROG(HAVE_GNOME_MOZ_REMOTE, 'gnome-moz-remote', yes, no) 14 15 AC_C_BIGENDIAN 16 17 AC_CHECK_FUNCS(strchr) 18 AC_CHECK_FUNCS(madvise) 19 20 ALL_LINGUAS="de el fr hu it pl ru en_AU" 21 AM_GNU_GETTEXT 22 23 dnl Overall configuration success flag 24 sweep_config_ok=yes 25 26 dnl Default audio handling to build in 27 sweep_config_driver=none 28 29 dnl 30 dnl Configuration option for building of experimental code. 31 dnl 32 33 ac_enable_experimental=no 34 AC_ARG_ENABLE(experimental, 35 [ --enable-experimental enable building of experimental code ], 36 [ ac_enable_experimental=yes ]) 37 38 if test "x${ac_enable_experimental}" = xyes ; then 39 AC_DEFINE(DEVEL_CODE) 40 fi 41 42 43 dnl 44 dnl Detect pthreads libraries 45 dnl 46 13 47 PTHREAD_LIBS=error 14 AC_CHECK_LIB(pthread, pthread_attr_init, 15 PTHREAD_LIBS="-lpthread") 48 AC_CHECK_LIB(pthread, pthread_attr_init, PTHREAD_LIBS="-lpthread") 16 49 if 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") 19 51 fi 20 52 if 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") 23 54 fi 24 55 if test "x$PTHREAD_LIBS" = xerror; then … … 27 58 AC_SUBST(PTHREAD_LIBS) 28 59 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 61 dnl 62 dnl Detect GLib, GTK+ libraries 63 dnl 64 65 HAVE_GLIB=no 66 AM_PATH_GLIB(1.2.0, HAVE_GLIB="yes", sweep_config_ok="no") 67 if test "x$HAVE_GLIB" = xno ; then 68 AC_CHECK_LIB(glib, g_list_append, HAVE_GLIB="maybe") 69 fi 70 71 HAVE_GTK=no 72 AM_PATH_GTK(1.2.0, HAVE_GTK="yes", sweep_config_ok="no", gthread) 73 if test "x$HAVE_GTK" = xyes ; then 74 CFLAGS="$CFLAGS $GTK_CFLAGS" 75 else 76 AC_CHECK_LIB(gtk, gtk_init, HAVE_GTK="maybe") 77 fi 78 79 80 dnl 81 dnl Detect tdb library 82 dnl 83 84 HAVE_TDB=no 85 AC_CHECK_LIB(tdb, tdb_open, HAVE_TDB="yes", sweep_config_ok="no") 86 if 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) 90 fi 91 92 93 dnl 94 dnl Detect libsndfile 1.0 95 dnl 96 97 LIBSNDFILE_VERSION="???" 98 99 # !!! libsndfile0 backport 100 101 ac_enable_libsndfile0=no 102 AC_ARG_ENABLE(libsndfile0, 103 [ --enable-libsndfile0 enable building against libsndfile version 0], 104 [ ac_enable_libsndfile0=yes ]) 105 106 if 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 133 else # !!! 134 135 PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.0, 136 HAVE_LIBSNDFILE1="yes", HAVE_LIBSNDFILE1="no") 137 138 if test "x$HAVE_LIBSNDFILE1" = xyes ; then 139 AC_DEFINE(HAVE_LIBSNDFILE1) 140 AC_SUBST(SNDFILE_LIBS) 141 LIBSNDFILE_VERSION="1" 142 else 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") 146 fi 147 148 if 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 168 fi 169 170 fi # !!! libsndfile0 backport 171 172 AC_CHECK_SIZEOF(off_t,1) 173 174 175 dnl 176 dnl Detect Ogg 177 dnl 178 179 HAVE_OGG=no 180 HAVE_VORBIS=no 181 HAVE_SPEEX=no 182 183 ac_enable_oggvorbis=yes 184 AC_ARG_ENABLE(oggvorbis, 185 [ --disable-oggvorbis disable Ogg Vorbis support], 186 [ ac_enable_oggvorbis=no ], [ ac_enable_oggvorbis=yes ]) 187 188 ac_enable_speex=yes 189 AC_ARG_ENABLE(speex, 190 [ --disable-speex disable Speex support], 191 [ ac_enable_speex=no ], [ ac_enable_speex=yes ]) 192 193 dnl Both Vorbis and Speex require Ogg, so check for it first either way 194 if 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) 203 fi 204 205 dnl 206 dnl Detect Vorbis 207 dnl 208 dnl LIBS="$LIBS -lm -logg -lvorbis -lvorbisenc -lvorbisfile" 209 210 if 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 273 else 274 HAVE_VORBIS=disabled 275 fi 276 277 dnl 278 dnl Detect speex 279 dnl 280 dnl LIBS="$LIBS -lm -logg -lspeex" 281 282 if 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 294 else 295 HAVE_SPEEX=disabled 296 fi 297 298 299 dnl 300 dnl Detect libmad 301 dnl 302 303 HAVE_MAD=no 304 305 ac_enable_mad=yes 306 AC_ARG_ENABLE(mad, 307 [ --disable-mad disable libmad (MPEG audio loading) support], 308 [ ac_enable_mad=no ], [ ac_enable_mad=yes ]) 309 310 if 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 322 else 323 HAVE_MAD=disabled 324 fi 325 326 dnl 327 dnl Detect secret rabbit code 328 dnl 329 330 HAVE_LIBSAMPLERATE=no 331 332 ac_enable_src=yes 333 AC_ARG_ENABLE(src, 334 [ --disable-src enable secret rabbit code (libsamplerate)], 335 [ ac_enable_src=no ], [ ac_enable_src=yes]) 336 337 if 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 345 else 346 HAVE_LIBSAMPLERATE=disabled 347 fi 348 349 350 dnl 351 dnl Test for ALSA -- requires explicit enabling 352 dnl 353 46 354 47 355 ac_enable_alsa=no 48 356 AC_ARG_ENABLE(alsa, 49 [ --enable-alsaenable use of ALSA, and disable use of OSS ],357 [ --enable-alsa enable use of ALSA, and disable use of OSS ], 50 358 [ ac_enable_alsa=yes ]) 51 359 52 AC_CHECK_HEADERS(sys/asoundlib.h) 53 if test "${ac_cv_header_sys_asoundlib_h}" = "yes" && 54 test "${ac_enable_alsa}" != no ; then 360 if 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 55 364 AC_DEFINE(DRIVER_ALSA) 56 365 LIBS="$LIBS -lasound" 366 fi 367 368 sweep_config_driver="ALSA" 57 369 fi 58 370 59 371 dnl Test for OSS 60 372 AC_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 373 if 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 66 383 fi 67 384 68 385 dnl Test for Solaris audio 386 case $host in 387 *-*-solaris*) 69 388 AC_CHECK_HEADERS(sys/audioio.h) 70 if test " ${ac_cv_header_sys_audioio_h}" = "yes"; then389 if test "x${ac_cv_header_sys_audioio_h}" = xyes; then 71 390 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" 392 fi 393 ;; 394 esac 395 77 396 78 397 dnl Set PACKAGE_LOCALE_DIR in config.h. 79 if test "x${prefix}" = "xNONE"; then398 if test "x${prefix}" = xNONE; then 80 399 AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${ac_default_prefix}/${DATADIRNAME}/locale") 81 400 else … … 85 404 dnl Set PACKAGE_DATA_DIR in config.h. 86 405 if test "x${datadir}" = 'x${prefix}/share'; then 87 if test "x${prefix}" = "xNONE"; then406 if test "x${prefix}" = xNONE; then 88 407 AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${ac_default_prefix}/share/${PACKAGE}") 89 408 else … … 97 416 PACKAGE_PLUGIN_DIR=$libdir/sweep 98 417 AC_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 418 if test "x${prefix}" = xNONE; then 419 sweep_plugin_dir="${ac_default_prefix}/lib/${PACKAGE}" 420 else 421 sweep_plugin_dir="${prefix}/lib/${PACKAGE}" 422 fi 423 AC_DEFINE_UNQUOTED(PACKAGE_PLUGIN_DIR, "$sweep_plugin_dir") 104 424 105 425 dnl Set PACKAGE_SOURCE_DIR in config.h. … … 109 429 110 430 dnl 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) 431 dnl changequote(,)dnl 432 if test "x$ac_cv_prog_gcc" = xyes ; then 433 CFLAGS="$CFLAGS -Wall" 434 fi 435 dnl changequote([,])dnl 436 437 438 dnl 439 dnl Configuration tests complete -- provide summary of results. 440 dnl 441 442 if test $sweep_config_ok = no ; then 443 444 AC_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 455 if test "x$HAVE_GLIB" != xyes ; then 456 AC_MSG_RESULT([ 457 *** GLib version 1.2.x, available from http://www.gtk.org/ 458 ]) 459 fi 460 if 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 ]) 466 fi 467 468 if test "x$HAVE_GTK" != xyes ; then 469 AC_MSG_RESULT([ 470 *** GTK+ version 1.2.x, available from http://www.gtk.org/ 471 ]) 472 fi 473 if 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 ]) 479 fi 480 481 if 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 ]) 486 fi 487 if 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 ]) 494 fi 495 if 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 ]) 500 fi 501 502 if test "x$HAVE_VORBIS" != xyes ; then 503 AC_MSG_RESULT([ 504 *** Ogg Vorbis libraries, available from http://www.xiph.org/ogg/vorbis/ 505 ]) 506 fi 507 if 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 ]) 513 fi 514 if 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 ]) 520 fi 521 522 if 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 ]) 527 fi 528 if 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 ]) 533 fi 534 535 if 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 ]) 543 fi 544 545 AC_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 557 AC_MSG_RESULT([ 558 ************************************************************** 559 ]) 560 561 AC_MSG_ERROR([ 562 *** 563 *** After fixing the above problems, you must run ./configure again. 564 *** 565 ]) 566 567 else 121 568 122 569 AC_OUTPUT([ … … 128 575 plugins/echo/Makefile 129 576 plugins/normalise/Makefile 577 plugins/fade/Makefile 130 578 plugins/reverse/Makefile 131 579 plugins/ladspa/Makefile … … 133 581 plugins/example/Makefile 134 582 doc/Makefile 583 pixmaps/Makefile 135 584 intl/Makefile 136 585 po/Makefile.in 137 586 ]) 138 587 588 AC_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 620 fi trunk/sweep/doc/sweep.1
r7 r124 1 .TH SWEEP 1 "21 Apr 2000" Version 0. 01 .TH SWEEP 1 "21 Apr 2000" Version 0.5.0 2 2 .SH NAME 3 3 Sweep - a sound wave editor trunk/sweep/include/sweep/Makefile.am
r57 r124 4 4 5 5 sweepinclude_HEADERS = \ 6 config.h \7 6 sweep_version.h \ 8 7 sweep_i18n.h \ trunk/sweep/include/sweep/sweep.h
r57 r124 22 22 #define __SWEEP_H__ 23 23 24 #include <sweep/config.h>25 26 24 #include <sweep/sweep_version.h> 27 25 #include <sweep/sweep_i18n.h> trunk/sweep/include/sweep/sweep_filter.h
r57 r124 31 31 gpointer custom_data); 32 32 33 typedef sw_sounddata * (*SweepFilter) (sw_sounddata * sounddata,34 sw_param_set pset,35 gpointer custom_data);36 37 33 sw_op_instance * 38 34 perform_filter_op (sw_sample * sample, char * desc, SweepFilter func, trunk/sweep/include/sweep/sweep_i18n.h
r57 r124 29 29 # undef _ 30 30 # define _(String) dgettext (PACKAGE, String) 31 32 # define gettext_noop(String) String 33 # define N_(String) gettext_noop(String) 34 35 /* 31 36 # ifdef gettext_noop 32 37 # define N_(String) gettext_noop (String) 33 38 # else 34 # define N_(String) ( String)39 # define N_(String) ("NOT TRANSLATED") 35 40 # endif 41 */ 42 36 43 #else 37 44 # define textdomain(String) (String) … … 40 47 # define dcgettext(Domain,Message,Type) (Message) 41 48 # define bindtextdomain(Domain,Directory) (Domain) 49 50 #ifdef DEVEL_CODE 51 # define _(String) ("UNTRANSLATED") 52 # define N_(String) ("UNTRANSLATED") 53 #else 42 54 # define _(String) (String) 43 55 # define N_(String) (String) 44 56 #endif 45 57 58 #endif 59 46 60 #endif /* __I18N_H__ */ trunk/sweep/include/sweep/sweep_sample.h
r57 r124 25 25 26 26 sw_sample * 27 sample_new_empty(char * directory, char * filename,28 gint nr_channels, gint sample_rate,gint sample_length);27 sample_new_empty(char * pathname, gint nr_channels, gint sample_rate, 28 gint sample_length); 29 29 30 30 sw_sample * … … 34 34 sample_destroy (sw_sample * s); 35 35 36 sw_sounddata * 37 sample_get_sounddata (sw_sample * s); 38 36 39 void 37 sample_set_pathname (sw_sample * s, char * directory, char * filename); 40 sample_set_file_format (sw_sample * s, sw_file_format_t file_format); 41 42 void 43 sample_set_pathname (sw_sample * s, char * pathname); 44 45 GList * 46 sample_bank_list_names (void); 47 48 sw_sample * 49 sample_bank_find_byname (const gchar * name); 50 51 gboolean 52 sample_bank_contains (sw_sample *s); 38 53 39 54 void … … 53 68 54 69 void 55 sample_set_playmarker (sw_sample * s, int offset); 70 sample_set_edit_state (sw_sample * s, sw_edit_state edit_state); 71 72 void 73 sample_set_edit_mode (sw_sample * s, sw_edit_mode edit_mode); 74 75 void 76 sample_refresh_playmode (sw_sample * s); 77 78 void 79 sample_set_previewing (sw_sample * s, gboolean previewing); 80 81 void 82 sample_set_stop_offset (sw_sample * s); 83 84 void 85 sample_set_playmarker (sw_sample * s, sw_framecount_t offset, 86 gboolean by_user); 87 88 void 89 sample_set_rec_marker (sw_sample * s, sw_framecount_t offset); 90 91 void 92 sample_set_scrubbing (sw_sample * s, gboolean scrubbing); 93 94 void 95 sample_set_looping (sw_sample * s, gboolean looping); 96 97 void 98 sample_set_playrev (sw_sample * s, gboolean reverse); 99 100 void 101 sample_set_mute (sw_sample * s, gboolean mute); 102 103 void 104 sample_set_color (sw_sample * s, gint color); 105 106 void 107 sample_set_progress_text (sw_sample * s, gchar * text); 108 109 void 110 sample_set_progress_percent (sw_sample * s, gint percent); 111 112 void 113 sample_refresh_progress_percent (sw_sample * s); 114 115 int 116 sample_set_progress_ready (sw_sample * s); 117 118 void 119 sample_set_tmp_message (sw_sample * s, const char * fmt, ...); 56 120 57 121 /* … … 70 134 71 135 /* Selection handling */ 136 137 gboolean 138 sample_offset_in_sel (sw_sample * s, sw_framecount_t offset); 72 139 73 140 guint … … 106 173 sample_selection_select_none (sw_sample * s); 107 174 175 void 176 sample_selection_halve (sw_sample * s); 177 178 void 179 sample_selection_double (sw_sample * s); 180 181 void 182 sample_selection_shift_left (sw_sample * s); 183 184 void 185 sample_selection_shift_right (sw_sample * s); 186 187 /* info dialog */ 188 void 189 sample_show_info_dialog (sw_sample * sample); 190 191 108 192 #endif /* __SWEEP_SAMPLE_H__ */ trunk/sweep/include/sweep/sweep_selection.h
r57 r124 28 28 sel_copy (sw_sel * sel); 29 29 30 GList * 31 sels_add_selection (GList * sels, sw_sel * sel); 32 33 GList * 34 sels_add_selection_1 (GList * sels, sw_framecount_t start, sw_framecount_t end); 35 30 36 /* 31 37 * sel_cmp (s1, s2) … … 45 51 sels_copy (GList * sels); 46 52 53 /* 54 * sels_invert (sels, nr_frames) 55 * 56 * inverts sels in place 57 */ 58 GList * 59 sels_invert (GList * sels, sw_framecount_t nr_frames); 60 47 61 sw_op_instance * 48 perform_selection_op (sw_sample * s, char * desc, Sweep Modifyfunc,62 perform_selection_op (sw_sample * s, char * desc, SweepFilter func, 49 63 sw_param_set pset, gpointer custom_data); 50 64 trunk/sweep/include/sweep/sweep_sounddata.h
r57 r124 64 64 sounddata_selection_nr_frames (sw_sounddata * sounddata); 65 65 66 gint 67 sounddata_selection_width (sw_sounddata * sounddata); 68 66 69 void 67 70 sounddata_selection_translate (sw_sounddata * sounddata, gint delta); 71 72 void 73 sounddata_selection_scale (sw_sounddata * sounddata, gfloat scale); 68 74 69 75 /* trunk/sweep/include/sweep/sweep_types.h
r58 r124 24 24 #include <glib.h> 25 25 #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 */ 26 33 27 34 /* … … 45 52 46 53 /* Frame Counts */ 47 typedef gint sw_framecount_t; 54 #if 0 55 56 #if (SIZEOF_OFF_T == 8) 57 /* For libsndfile version 1 */ 58 typedef off_t sw_framecount_t; 59 #else 60 typedef int sw_framecount_t; 61 #endif 62 63 #else 64 65 typedef int sw_framecount_t; 66 #define FRAMECOUNT_MAX INT_MAX 67 68 #endif 48 69 49 70 … … 85 106 86 107 struct _sw_sounddata { 108 int refcount; 109 87 110 sw_format * format; 88 111 sw_framecount_t nr_frames; /* nr frames */ … … 96 119 #define SW_DIR_LEN 256 97 120 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 122 typedef 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 129 typedef 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 137 typedef enum { 138 SWEEP_TRANSPORT_STOP, 139 SWEEP_TRANSPORT_PLAY, 140 SWEEP_TRANSPORT_PLAY_SEL, 141 } sw_transport_type; 142 143 /* File formats */ 144 typedef 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 115 158 116 159 typedef struct _sw_edit_region sw_edit_region; … … 131 174 sw_format * format; 132 175 GList * regions; 176 gint refcount; 133 177 }; 134 178 … … 137 181 typedef void (*SweepCallback) (sw_sample * sample, gpointer data); 138 182 183 139 184 typedef struct _sw_operation sw_operation; 140 185 typedef struct _sw_op_instance sw_op_instance; 141 186 142 187 struct _sw_operation { 188 sw_edit_mode edit_mode; 189 SweepCallback _do_; 190 SweepFunction purge_do; 143 191 SweepCallback undo; 144 192 SweepFunction purge_undo; … … 148 196 149 197 struct _sw_op_instance { 198 sw_sample * sample; 150 199 char * description; 151 200 sw_operation * op; 201 gpointer do_data; 152 202 gpointer undo_data; 153 203 gpointer redo_data; … … 410 460 }; 411 461 412 typedef void (*SweepModify) (sw_sample * sample, sw_param_set pset, 413 gpointer custom_data); 462 typedef sw_sample * (*SweepFilter) (sw_sample * sample, 463 sw_param_set pset, 464 gpointer custom_data); 465 414 466 415 467 #endif /* __SWEEP_TYPES_H__ */ trunk/sweep/include/sweep/sweep_undo.h
r57 r124 24 24 #include "sweep_types.h" 25 25 26 gint 27 update_edit_progress (gpointer data); 28 26 29 sw_op_instance * 27 sw_op_instance_new (char * desc, sw_operation * op); 30 sw_op_instance_new (sw_sample * sample, char * description, 31 sw_operation * operation); 32 33 void 34 schedule_operation (sw_sample * sample, char * description, 35 sw_operation * operation, void * do_data); 28 36 29 37 void 30 38 register_operation (sw_sample * s, sw_op_instance * inst); 39 40 void 41 trim_registered_ops (sw_sample * s, int length); 31 42 32 43 void … … 36 47 redo_current (sw_sample * s); 37 48 49 void 50 revert_op (sw_sample * sample, GList * op_gl); 51 52 void 53 set_active_op (sw_sample * s, sw_op_instance * inst); 54 55 void 56 cancel_active_op (sw_sample * s); 38 57 39 58 /* Stock undo functions */ … … 56 75 redo_by_replace (replace_data * r); 57 76 #endif 77 78 typedef struct _sounddata_replace_data sounddata_replace_data; 79 80 struct _sounddata_replace_data { 81 sw_sample * sample; 82 sw_sounddata * old_sounddata; 83 sw_sounddata * new_sounddata; 84 }; 85 86 sounddata_replace_data * 87 sounddata_replace_data_new (sw_sample * sample, 88 sw_sounddata * old_sounddata, 89 sw_sounddata * new_sounddata); 90 91 void 92 sounddata_replace_data_destroy (sounddata_replace_data * sr); 93 94 void 95 undo_by_sounddata_replace (sw_sample * s, sounddata_replace_data * sr); 96 97 void 98 redo_by_sounddata_replace (sw_sample * s, sounddata_replace_data * sr); 99 58 100 59 101 typedef struct _paste_over_data paste_over_data; … … 83 125 sw_sample * sample; 84 126 sw_edit_buffer * eb; 127 GList * sels; /* Previous sels of sounddata */ 85 128 }; 86 129 87 130 splice_data * 88 splice_data_new (sw_edit_buffer * eb );131 splice_data_new (sw_edit_buffer * eb, GList * sels); 89 132 90 133 void … … 103 146 redo_by_splice_in (sw_sample * s, splice_data * sp); 104 147 148 void 149 undo_by_splice_over (sw_sample * s, splice_data * sp); 150 151 void 152 redo_by_splice_over (sw_sample * s, splice_data * sp); 153 154 void 155 undo_by_crop_in (sw_sample * s, splice_data * sp); 156 157 void 158 redo_by_crop_out (sw_sample * s, splice_data * sp); 105 159 106 160 #endif /* __SWEEP_UNDO_H__ */ trunk/sweep/include/sweep/sweep_version.h
r57 r124 25 25 * The current version of Sweep's native plugin interface. 26 26 * 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. 28 29 */ 29 30 #define SWEEP_PLUGIN_API_MAJOR 1 30 31 31 #define SWEEP_PLUGIN_API_MINOR 032 #define SWEEP_PLUGIN_API_MINOR 1 32 33 33 34 #define SWEEP_PLUGIN_API_REVISION 0 trunk/sweep/install-sh
r7 r124 110 110 exit 1 111 111 else 112 true112 : 113 113 fi 114 114 … … 121 121 chmodcmd="" 122 122 else 123 instcmd= mkdir123 instcmd=$mkdirprog 124 124 fi 125 125 else … … 129 129 # if $src (and thus $dsttmp) contains '*'. 130 130 131 if [ -f $src -o -d $src]132 then 133 true131 if [ -f "$src" ] || [ -d "$src" ] 132 then 133 : 134 134 else 135 135 echo "install: $src does not exist" … … 142 142 exit 1 143 143 else 144 true144 : 145 145 fi 146 146 … … 152 152 dst="$dst"/`basename $src` 153 153 else 154 true154 : 155 155 fi 156 156 fi … … 164 164 # Skip lots of stat calls in the usual case. 165 165 if [ ! -d "$dstdir" ]; then 166 defaultIFS=' 167 '166 defaultIFS=' 167 ' 168 168 IFS="${IFS-${defaultIFS}}" 169 169 … … 184 184 $mkdirprog "${pathcomp}" 185 185 else 186 true186 : 187 187 fi 188 188 … … 195 195 $doit $instcmd $dst && 196 196 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; fi197 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 201 201 else 202 202 … … 217 217 dstfile=`basename $dst` 218 218 else 219 true219 : 220 220 fi 221 221 … … 236 236 # errors from the above "$doit $instcmd $src $dsttmp" command. 237 237 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 && 242 242 243 243 # Now rename the file to the real destination. trunk/sweep/intl/ChangeLog
r7 r124 1 1998-04-29 Ulrich Drepper <drepper@cygnus.com>1 2001-09-13 GNU <bug-gnu-utils@gnu.org> 2 2 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. 11 4 12 1998-04-28 Ulrich Drepper <drepper@cygnus.com>13 14 * loadmsgcat.c (_nl_load_domain): Don't assign the element use_mmap if15 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 this24 function. Define and use semapahores to protect modfication of25 global objects when compiling for glibc. Add code to allow26 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 compiled32 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 if38 available.39 40 * dcgettext.c: Don't assume stpcpy not being a macro. Mark internal41 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 if93 !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 is102 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 on109 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_NULL113 macro. Instead use HAVE_LOCALE_NULL and define it when using114 glibc, as in dcgettext.c.115 Patch by Bruno Haible <haible@ilog.fr>.116 117 * Makefile.in (CPPFLAGS): New variable. Reported by Franc,ois118 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 lowlevel125 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 macro130 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 right140 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 using145 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 of154 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 after164 definition of _GNU_SOURCE. Patch by Roland McGrath.165 166 * Makefile.in (uninstall): Fix another bug with `for' loop and167 empty arguments. Patch by Jim Meyering. Correct name os168 uninstalled files: no intl- prefix anymore.169 170 * Makefile.in (install-data): Again work around shells which171 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-exec176 and install-data.177 (install-exec, install-data): New goals. Created from former178 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 to184 mkinstalldirs script.185 (install): use MKINSTALLDIRS variable or if the script is not present186 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 macros192 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 when199 __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 variable209 result to __result to prevent name clash.210 211 * l10nflist.c, localealias.c, dcgettext.c: Define _GNU_SOURCE to212 get prototype for stpcpy and strcasecmp.213 214 * intlh.inst.in, libgettext.h: Move declaration of215 `_nl_msg_cat_cntr' outside __extension__ block to prevent warning216 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 to233 block_list as the macro calls assume.234 Patch by Eric Backus.235 236 * localealias.c [!HAVE_ALLOCA]: Define alloca as macro using237 malloc.238 (read_alias_file): Rename varriabe alloca_list to block_list as the239 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@, not246 all-@USE_NLS@.247 248 * Makefile.in (install): intlh.inst comes from local dir, not249 $(srcdir).250 251 * Makefile.in (intlh.inst): Special handling of this goal. If252 used in gettext, this is really a rul to construct this file. If253 used in any other package it is defined as a .PHONY rule with254 empty body.255 256 * finddomain.c: Extract locale file information handling into257 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 by262 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> on267 HAVE_LOCALE_H. Instead configure must rewrite this fiile268 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 1276 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 of282 automake's distcheck.283 284 * Makefile.in (install): Reorder commands so that VERSION is285 found.286 287 * Makefile.in (gettextsrcdir): Now use subdirectory intl/ in288 @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. No295 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 from304 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 alloca311 code. Use new l10nfile handling.312 313 * localealias.c [!HAVE_ALLOCA]: Add code for handling missing314 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 clashing333 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 up342 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 loop355 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 calls364 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 running370 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 when375 we use the own implementation. Don't do it when using the376 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 `#if389 !_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. First400 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 13420 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 understand430 #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. This451 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 have488 leading 0s we don't need to remove them. Reported by Marcus489 Daniels.490 491 * Makefile.in (../po/cat-id-tbl.o): Use $(top_srdir) in492 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.a502 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. Reported507 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 weeks524 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. This529 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 is565 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. Now585 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 name598 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 to604 __fstat, __open, __close, __read, __mmap, and __munmap resp605 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 to612 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 headers621 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 when626 compiling for glibc. Include all those standard headers627 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 when636 compiling for glibc. Include all those standard headers637 unconditionally if _LIBC is defined.638 639 * dcgettext.c: Include all those standard headers unconditionally640 if _LIBC is defined.641 642 * dgettext.c: If compiled in glibc include libintl.h instead of643 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 of647 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 gettext664 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' hided676 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 use687 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 part696 of the standard libc and so prevent libintl.a from being used697 standalone.698 699 * bindtextdom.c:700 Don't use xmalloc, xstrdup, and stpcpy. These functions are not part701 of the standard libc and so prevent libintl.a from being used702 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 part710 of the standard libc and so prevent libintl.a from being used711 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 part716 of the standard libc and so prevent libintl.a from being used717 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 standard722 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 helps735 gettext to install the sources and other packages can use the736 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, but748 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 other757 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 other762 in the locale list a tried. Formerly fall back was only possible763 within one language. Implemented by moving one loop from764 _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 made770 available.771 (INSTALL, INSTALL_DATA): Programs used for installing sources.772 (gettext-src): New. Rule to install GNU gettext sources for use in773 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 is779 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 in790 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 not800 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, lazy835 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' with845 a higher priority than LC_ALL for the LC_MESSAGE locale.846 Here we can set a colon separated list of specifications each847 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 point880 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 as889 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 calls900 __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 called908 __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 not953 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 at963 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 chars969 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 $ELCFILES999 (clean): renamed po-to-tbl and po-to-msg to po2tbl and po2msg resp.1000 1001 * elisp-comp: Initial revision1002 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 identical1007 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 files1016 (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 strings1020 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 of1032 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 code1083 needed to internationalize own packages. It provides functions1084 which allow to use the X/Open catgets function with an interface1085 like the Uniforum gettext function. For system which does not1086 have neither of those a complete implementation is provided.trunk/sweep/intl/Makefile.in
r84 r124 1 1 # Makefile for directory with message catalog handling in GNU NLS Utilities. 2 # Copyright (C) 1995 , 1996, 1997Free Software Foundation, Inc.2 # Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. 3 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 by6 # 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) 7 7 # any later version. 8 8 # 9 9 # This program is distributed in the hope that it will be useful, 10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # GNUGeneral Public License for more details.11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 # Library General Public License for more details. 13 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 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. 17 18 18 19 PACKAGE = @PACKAGE@ … … 29 30 exec_prefix = @exec_prefix@ 30 31 transform = @program_transform_name@ 31 libdir = $(exec_prefix)/lib32 includedir = $(prefix)/include33 datadir = $(prefix)/@DATADIRNAME@32 libdir = @libdir@ 33 includedir = @includedir@ 34 datadir = @datadir@ 34 35 localedir = $(datadir)/locale 35 gnulocaledir = $(prefix)/share/locale 36 gettextsrcdir = @datadir@/gettext/intl 37 aliaspath = $(localedir):. 36 gettextsrcdir = $(datadir)/gettext/intl 37 aliaspath = $(localedir) 38 38 subdir = intl 39 39 … … 41 41 INSTALL_DATA = @INSTALL_DATA@ 42 42 MKINSTALLDIRS = @MKINSTALLDIRS@ 43 44 l = @l@ 43 mkinstalldirs = $(SHELL) `case "$(MKINSTALLDIRS)" in /*) echo "$(MKINSTALLDIRS)" ;; *) echo "$(top_builddir)/$(MKINSTALLDIRS)" ;; esac` 44 45 l = @INTL_LIBTOOL_SUFFIX_PREFIX@ 45 46 46 47 AR = ar … … 48 49 LIBTOOL = @LIBTOOL@ 49 50 RANLIB = @RANLIB@ 50 51 DEFS = -DLOCALEDIR=\"$(localedir)\" -DGNULOCALEDIR=\"$(gnulocaledir)\" \ 52 -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" @DEFS@ 51 YACC = @INTLBISON@ -y -d 52 YFLAGS = --name-prefix=__gettext 53 54 DEFS = -DLOCALEDIR=\"$(localedir)\" -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \ 55 -DLIBDIR=\"$(libdir)\" @DEFS@ 53 56 CPPFLAGS = @CPPFLAGS@ 54 57 CFLAGS = @CFLAGS@ … … 57 60 COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) 58 61 59 HEADERS = $(COMHDRS) libg ettext.h loadinfo.h62 HEADERS = $(COMHDRS) libgnuintl.h libgettext.h loadinfo.h 60 63 COMHDRS = gettext.h gettextP.h hash-string.h 61 SOURCES = $(COMSRCS) intl-compat.c cat-compat.c64 SOURCES = $(COMSRCS) intl-compat.c 62 65 COMSRCS = bindtextdom.c dcgettext.c dgettext.c gettext.c \ 63 66 finddomain.c loadmsgcat.c localealias.c textdomain.c l10nflist.c \ 64 explodename.c 67 explodename.c dcigettext.c dcngettext.c dngettext.c ngettext.c plural.y \ 68 localcharset.c 65 69 OBJECTS = @INTLOBJS@ bindtextdom.$lo dcgettext.$lo dgettext.$lo gettext.$lo \ 66 70 finddomain.$lo loadmsgcat.$lo localealias.$lo textdomain.$lo l10nflist.$lo \ 67 explodename.$lo 68 CATOBJS = cat-compat.$lo ../po/cat-id-tbl.$lo71 explodename.$lo dcigettext.$lo dcngettext.$lo dngettext.$lo ngettext.$lo \ 72 plural.$lo localcharset.$lo 69 73 GETTOBJS = intl-compat.$lo 70 DISTFILES.common = ChangeLog Makefile.in linux-msg.sed po2tbl.sed.in \ 71 xopen-msg.sed $(HEADERS) $(SOURCES) 74 DISTFILES.common = Makefile.in \ 75 config.charset locale.alias ref-add.sin ref-del.sin $(HEADERS) $(SOURCES) 76 DISTFILES.generated = plural.c 72 77 DISTFILES.normal = VERSION 73 DISTFILES.gettext = libintl.glibc intlh.inst.in 78 DISTFILES.gettext = COPYING.LIB-2 COPYING.LIB-2.1 libintl.glibc 79 DISTFILES.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. 86 LTV_CURRENT=1 87 LTV_REVISION=1 88 LTV_AGE=0 74 89 75 90 .SUFFIXES: 76 .SUFFIXES: .c . o .lo91 .SUFFIXES: .c .y .o .lo .sin .sed 77 92 .c.o: 78 93 $(COMPILE) $< … … 80 95 $(LIBTOOL) --mode=compile $(COMPILE) $< 81 96 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 105 INCLUDES = -I.. -I. -I$(top_srcdir)/intl 83 106 84 107 all: all-@USE_INCLUDED_LIBINTL@ 85 86 all-yes: libintl.$la intlh.inst 87 all-no: 88 89 libintl.a: $(OBJECTS) 108 all-yes: libintl.$la libintl.h charset.alias ref-add.sed ref-del.sed 109 all-no: all-no-@BUILD_INCLUDED_LIBINTL@ 110 all-no-yes: libgnuintl.$la 111 all-no-no: 112 113 libintl.a libgnuintl.a: $(OBJECTS) 90 114 rm -f $@ 91 115 $(AR) cru $@ $(OBJECTS) 92 116 $(RANLIB) $@ 93 117 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 118 libintl.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 126 libintl.h: libgnuintl.h 127 cp $(srcdir)/libgnuintl.h libintl.h 128 129 charset.alias: config.charset 130 $(SHELL) $(srcdir)/config.charset '@host@' > t-$@ 131 mv t-$@ $@ 100 132 101 133 check: all … … 105 137 106 138 # 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. 110 141 # If you want to use the one which comes with this version of the 111 142 # package, you have to use `configure --with-included-gettext'. … … 114 145 if test "$(PACKAGE)" = "gettext" \ 115 146 && 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; \ 118 163 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; \ 120 170 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; \ 123 180 else \ 124 181 : ; \ … … 126 183 install-data: all 127 184 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)"; \ 135 189 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; \ 137 203 done; \ 138 204 else \ … … 144 210 145 211 uninstall: 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 150 253 151 254 info dvi: 152 255 153 $(OBJECTS): ../ include/sweep/config.h libgettext.h256 $(OBJECTS): ../config.h libgnuintl.h 154 257 bindtextdom.$lo finddomain.$lo loadmsgcat.$lo: gettextP.h gettext.h loadinfo.h 155 258 dcgettext.$lo: gettextP.h gettext.h hash-string.h loadinfo.h … … 167 270 168 271 mostlyclean: 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 170 275 171 276 clean: mostlyclean 172 277 173 278 distclean: 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 175 285 176 286 maintainer-clean: distclean … … 182 292 # other files which should not be distributed in other packages. 183 293 distdir = ../$(PACKAGE)-$(VERSION)/$(subdir) 184 dist distdir: Makefile $(DISTFILES)294 dist distdir: Makefile 185 295 if test "$(PACKAGE)" = gettext; then \ 186 296 additional="$(DISTFILES.gettext)"; \ … … 188 298 additional="$(DISTFILES.normal)"; \ 189 299 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); \ 193 305 done 194 195 dist-libc:196 tar zcvf intl-glibc.tar.gz $(COMSRCS) $(COMHDRS) libintl.h.glibc197 306 198 307 Makefile: Makefile.in ../config.status … … 200 309 && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status 201 310 202 # The dependency for intlh.inst is different in gettext and all other203 # packages. Because we cannot you GNU make features we have to solve204 # the problem while rewriting Makefile.in.205 @GT_YES@intlh.inst: intlh.inst.in ../config.status206 @GT_YES@ cd .. \207 @GT_YES@ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \208 @GT_YES@ $(SHELL) ./config.status209 @GT_NO@.PHONY: intlh.inst210 @GT_NO@intlh.inst:211 212 311 # Tell versions [3.59,3.63) of GNU make not to export all variables. 213 312 # 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. 351 GNU gettext library from gettext-0.10.40 trunk/sweep/intl/bindtextdom.c
r7 r124 1 1 /* Implementation of the bindtextdomain(3) function 2 Copyright (C) 1995 , 1996, 1997, 1998Free 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 by6 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) 7 7 any later version. 8 8 9 9 This program is distributed in the hope that it will be useful, 10 10 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. */ 17 18 18 19 #ifdef HAVE_CONFIG_H … … 20 21 #endif 21 22 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> 40 26 41 27 #ifdef _LIBC 42 28 # include <libintl.h> 43 29 #else 44 # include "libgettext.h" 45 #endif 46 #include "gettext.h" 30 # include "libgnuintl.h" 31 #endif 47 32 #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 48 56 49 57 /* @@ end of prolog @@ */ … … 54 62 /* List with bindings of specific domains. */ 55 63 extern 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) 56 67 57 68 … … 62 73 #ifdef _LIBC 63 74 # define BINDTEXTDOMAIN __bindtextdomain 75 # define BIND_TEXTDOMAIN_CODESET __bind_textdomain_codeset 64 76 # ifndef strdup 65 77 # define strdup(str) __strdup (str) … … 67 79 #else 68 80 # define BINDTEXTDOMAIN bindtextdomain__ 69 #endif 81 # define BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset__ 82 #endif 83 84 /* Prototypes for local functions. */ 85 static 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. */ 95 static void 96 set_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 } 70 342 71 343 /* Specify that the DOMAINNAME message catalog will be found … … 76 348 const char *dirname; 77 349 { 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; 198 352 } 199 353 354 /* Specify the character encoding in which the messages from the 355 DOMAINNAME message catalog will be returned. */ 356 char * 357 BIND_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 200 365 #ifdef _LIBC 201 /* Alias for function namein GNU C Library. */366 /* Aliases for function names in GNU C Library. */ 202 367 weak_alias (__bindtextdomain, bindtextdomain); 203 #endif 368 weak_alias (__bind_textdomain_codeset, bind_textdomain_codeset); 369 #endif trunk/sweep/intl/dcgettext.c
r7 r124 1 1 /* Implementation of the dcgettext(3) function. 2 Copyright (C) 1995 , 1996, 1997, 1998Free Software Foundation, Inc.2 Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. 3 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 by6 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) 7 7 any later version. 8 8 9 9 This program is distributed in the hope that it will be useful, 10 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNUGeneral Public License for more details.11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 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. */ 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. */ 17 18 18 19 #ifdef HAVE_CONFIG_H … … 20 21 #endif 21 22 22 #include <sys/types.h>23 24 #if defined __GNUC__ && !defined C_ALLOCA25 # define alloca __builtin_alloca26 # define HAVE_ALLOCA 127 #else28 # if (defined HAVE_ALLOCA_H || defined _LIBC) && !defined C_ALLOCA29 # include <alloca.h>30 # else31 # ifdef _AIX32 #pragma alloca33 # else34 # ifndef alloca35 char *alloca ();36 # endif37 # endif38 # endif39 #endif40 41 #include <errno.h>42 #ifndef errno43 extern int errno;44 #endif45 #ifndef __set_errno46 # define __set_errno(val) errno = (val)47 #endif48 49 #if defined STDC_HEADERS || defined _LIBC50 # include <stdlib.h>51 #else52 char *getenv ();53 # ifdef HAVE_MALLOC_H54 # include <malloc.h>55 # else56 void free ();57 # endif58 #endif59 60 #if defined HAVE_STRING_H || defined _LIBC61 # ifndef _GNU_SOURCE62 # define _GNU_SOURCE 163 # endif64 # include <string.h>65 #else66 # include <strings.h>67 #endif68 #if !HAVE_STRCHR && !defined _LIBC69 # ifndef strchr70 # define strchr index71 # endif72 #endif73 74 #if defined HAVE_UNISTD_H || defined _LIBC75 # include <unistd.h>76 #endif77 78 #include "gettext.h"79 23 #include "gettextP.h" 80 24 #ifdef _LIBC 81 25 # include <libintl.h> 82 26 #else 83 # include "libg ettext.h"27 # include "libgnuintl.h" 84 28 #endif 85 #include "hash-string.h"86 29 87 30 /* @@ end of prolog @@ */ 88 89 #ifdef _LIBC90 /* Rename the non ANSI C functions. This is required by the standard91 because some ANSI C functions will require linking with this object92 file and the name space must not be polluted. */93 # define getcwd __getcwd94 # ifndef stpcpy95 # define stpcpy __stpcpy96 # endif97 #else98 # if !defined HAVE_GETCWD99 char *getwd ();100 # define getcwd(buf, max) getwd (buf)101 # else102 char *getcwd ();103 # endif104 # ifndef HAVE_STPCPY105 static char *stpcpy PARAMS ((char *dest, const char *src));106 # endif107 #endif108 109 /* Amount to increase buffer size by in each try. */110 #define PATH_INCR 32111 112 /* The following is from pathmax.h. */113 /* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define114 PATH_MAX but might cause redefinition warnings when sys/param.h is115 later included (as on MORE/BSD 4.3). */116 #if defined(_POSIX_VERSION) || (defined(HAVE_LIMITS_H) && !defined(__GNUC__))117 # include <limits.h>118 #endif119 120 #ifndef _POSIX_PATH_MAX121 # define _POSIX_PATH_MAX 255122 #endif123 124 #if !defined(PATH_MAX) && defined(_PC_PATH_MAX)125 # define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf ("/", _PC_PATH_MAX))126 #endif127 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 #endif132 133 #if !defined(PATH_MAX) && defined(MAXPATHLEN)134 # define PATH_MAX MAXPATHLEN135 #endif136 137 #ifndef PATH_MAX138 # define PATH_MAX _POSIX_PATH_MAX139 #endif140 141 /* XPG3 defines the result of `setlocale (category, NULL)' as:142 ``Directs `setlocale()' to query `category' and return the current143 setting of `local'.''144 However it does not specify the exact format. And even worse: POSIX145 defines this not at all. So we can use this feature only on selected146 system (e.g. those using GNU C Library). */147 #ifdef _LIBC148 # define HAVE_LOCALE_NULL149 #endif150 151 /* Name of the default domain used for gettext(3) prior any call to152 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 add175 some additional code emulating it. */176 #ifdef HAVE_ALLOCA177 /* Nothing has to be done. */178 # define ADD_BLOCK(list, address) /* nothing */179 # define FREE_BLOCKS(list) /* nothing */180 #else181 struct block_list182 {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 alloca206 # define alloca(size) (malloc (size))207 #endif /* have alloca */208 209 31 210 32 /* Names for the libintl functions are a problem. They must not clash … … 214 36 #ifdef _LIBC 215 37 # define DCGETTEXT __dcgettext 38 # define DCIGETTEXT __dcigettext 216 39 #else 217 40 # 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__ 236 42 #endif 237 43 … … 244 50 int category; 245 51 { 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); 415 53 } 416 54 … … 419 57 weak_alias (__dcgettext, dcgettext); 420 58 #endif 421 422 423 static char *424 internal_function425 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) == len456 && 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 else467 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) == len475 && strcmp (msgid,476 domain->data + W (domain->must_swap,477 domain->orig_tab[nstr - 1].offset))478 == 0)479 return (char *) domain->data480 + 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 sorted486 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->data495 + 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 else502 break;503 }504 505 /* If an translation is found return this. */506 return bottom >= top ? NULL : (char *) domain->data507 + 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_function515 category_to_name (category)516 int category;517 {518 const char *retval;519 520 switch (category)521 {522 #ifdef LC_COLLATE523 case LC_COLLATE:524 retval = "LC_COLLATE";525 break;526 #endif527 #ifdef LC_CTYPE528 case LC_CTYPE:529 retval = "LC_CTYPE";530 break;531 #endif532 #ifdef LC_MONETARY533 case LC_MONETARY:534 retval = "LC_MONETARY";535 break;536 #endif537 #ifdef LC_NUMERIC538 case LC_NUMERIC:539 retval = "LC_NUMERIC";540 break;541 #endif542 #ifdef LC_TIME543 case LC_TIME:544 retval = "LC_TIME";545 break;546 #endif547 #ifdef LC_MESSAGES548 case LC_MESSAGES:549 retval = "LC_MESSAGES";550 break;551 #endif552 #ifdef LC_RESPONSE553 case LC_RESPONSE:554 retval = "LC_RESPONSE";555 break;556 #endif557 #ifdef LC_ALL558 case LC_ALL:559 /* This might not make sense but is perhaps better than any other560 value. */561 retval = "LC_ALL";562 break;563 #endif564 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_function575 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' environment582 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 POSIX588 methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some589 systems this can be done by the `setlocale' function itself. */590 #if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL591 return setlocale (category, NULL);592 #else593 /* 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 implementation609 defined. */610 return "C";611 #endif612 }613 614 /* @@ begin of epilog @@ */615 616 /* We don't want libintl.a to depend on any other library. So we617 avoid the non-standard function stpcpy. In GNU C Library this618 function is available, though. Also allow the symbol HAVE_STPCPY619 to be defined. */620 #if !_LIBC && !HAVE_STPCPY621 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 #endif631 632 633 #ifdef _LIBC634 /* If we want to free all resources we have to do some work at635 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 #endiftrunk/sweep/intl/dgettext.c
r7 r124 1 /* Implementation of the dgettext(3) function 2 Copyright (C) 1995 , 1996, 1997Free Software Foundation, Inc.1 /* Implementation of the dgettext(3) function. 2 Copyright (C) 1995-1997, 2000, 2001 Free Software Foundation, Inc. 3 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 by6 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) 7 7 any later version. 8 8 9 9 This program is distributed in the hope that it will be useful, 10 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNUGeneral Public License for more details.11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 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. */ 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. */ 17 18 18 19 #ifdef HAVE_CONFIG_H … … 20 21 #endif 21 22 22 #if defined HAVE_LOCALE_H || defined _LIBC 23 # include <locale.h> 24 #endif 23 #include <locale.h> 25 24 25 #include "gettextP.h" 26 26 #ifdef _LIBC 27 27 # include <libintl.h> 28 28 #else 29 # include "libg ettext.h"29 # include "libgnuintl.h" 30 30 #endif 31 31 trunk/sweep/intl/explodename.c
r7 r124 1 /* Copyright (C) 1995 , 1996, 1997, 1998Free Software Foundation, Inc.1 /* Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. 2 2 Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. 3 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 by6 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) 7 7 any later version. 8 8 9 9 This program is distributed in the hope that it will be useful, 10 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNUGeneral Public License for more details.11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 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. */ 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. */ 17 18 18 19 #ifdef HAVE_CONFIG_H … … 20 21 #endif 21 22 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> 31 25 #include <sys/types.h> 32 26 trunk/sweep/intl/finddomain.c
r7 r124 1 1 /* Handle list of needed message catalogs 2 Copyright (C) 1995 , 1996, 1997, 1998Free 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. 4 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 by7 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) 8 8 any later version. 9 9 10 10 This program is distributed in the hope that it will be useful, 11 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNUGeneral Public License for more details.12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 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. */ 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. */ 18 19 19 20 #ifdef HAVE_CONFIG_H … … 21 22 #endif 22 23 23 #include <ctype.h>24 #include <errno.h>25 24 #include <stdio.h> 26 25 #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> 51 28 52 29 #if defined HAVE_UNISTD_H || defined _LIBC … … 54 31 #endif 55 32 56 #include "gettext.h"57 33 #include "gettextP.h" 58 34 #ifdef _LIBC 59 35 # include <libintl.h> 60 36 #else 61 # include "libg ettext.h"37 # include "libgnuintl.h" 62 38 #endif 63 39 … … 72 48 struct loaded_l10nfile * 73 49 internal_function 74 _nl_find_domain (dirname, locale, domainname )50 _nl_find_domain (dirname, locale, domainname, domainbinding) 75 51 const char *dirname; 76 52 char *locale; 77 53 const char *domainname; 54 struct binding *domainbinding; 78 55 { 79 56 struct loaded_l10nfile *retval; … … 121 98 122 99 if (retval->decided == 0) 123 _nl_load_domain (retval );100 _nl_load_domain (retval, domainbinding); 124 101 125 102 if (retval->data != NULL) … … 129 106 { 130 107 if (retval->successor[cnt]->decided == 0) 131 _nl_load_domain (retval->successor[cnt] );108 _nl_load_domain (retval->successor[cnt], domainbinding); 132 109 133 110 if (retval->successor[cnt]->data != NULL) … … 176 153 177 154 if (retval->decided == 0) 178 _nl_load_domain (retval );155 _nl_load_domain (retval, domainbinding); 179 156 if (retval->data == NULL) 180 157 { … … 183 160 { 184 161 if (retval->successor[cnt]->decided == 0) 185 _nl_load_domain (retval->successor[cnt] );162 _nl_load_domain (retval->successor[cnt], domainbinding); 186 163 if (retval->successor[cnt]->data != NULL) 187 164 break; … … 192 169 if (alias_value != NULL) 193 170 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); 194 175 195 176 return retval; … … 209 190 _nl_unload_domain ((struct loaded_domain *) runp->data); 210 191 runp = runp->next; 192 free ((char *) here->filename); 211 193 free (here); 212 194 } trunk/sweep/intl/gettext.c
r7 r124 1 1 /* 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. 3 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 by6 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) 7 7 any later version. 8 8 9 9 This program is distributed in the hope that it will be useful, 10 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNUGeneral Public License for more details.11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 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. */ 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. */ 17 18 18 19 #ifdef HAVE_CONFIG_H … … 24 25 # include <stddef.h> 25 26 #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. */ 35 28 #endif 36 29 30 #include "gettextP.h" 37 31 #ifdef _LIBC 38 32 # include <libintl.h> 39 33 #else 40 # include "libg ettext.h"34 # include "libgnuintl.h" 41 35 #endif 42 36 … … 49 43 #ifdef _LIBC 50 44 # define GETTEXT __gettext 51 # define D GETTEXT __dgettext45 # define DCGETTEXT __dcgettext 52 46 #else 53 47 # define GETTEXT gettext__ 54 # define D GETTEXT dgettext__48 # define DCGETTEXT dcgettext__ 55 49 #endif 56 50 … … 62 56 const char *msgid; 63 57 { 64 return D GETTEXT (NULL, msgid);58 return DCGETTEXT (NULL, msgid, LC_MESSAGES); 65 59 } 66 60 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. 3 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 by6 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) 7 7 any later version. 8 8 9 9 This program is distributed in the hope that it will be useful, 10 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNUGeneral Public License for more details.11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 13 14 14 You should have received a copy of the GNU Library General Public 15 License along with th e 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. */ 18 18 19 19 #ifndef _GETTEXT_H 20 20 #define _GETTEXT_H 1 21 22 #include <stdio.h>23 21 24 22 #if HAVE_LIMITS_H || _LIBC … … 38 36 to determine an unsigned integral type that is 32 bits wide. An 39 37 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. */ 43 40 44 41 #if __STDC__ trunk/sweep/intl/gettextP.h
r7 r124 1 /* Header describing internals of gettext library2 Copyright (C) 1995 , 1996, 1997, 1998Free 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 by7 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) 8 8 any later version. 9 9 10 10 This program is distributed in the hope that it will be useful, 11 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. 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. */ 18 19 19 20 #ifndef _GETTEXTP_H 20 21 #define _GETTEXTP_H 21 22 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 22 33 #include "loadinfo.h" 34 35 #include "gettext.h" /* Get nls_uint32. */ 23 36 24 37 /* @@ end of prolog @@ */ … … 36 49 #endif 37 50 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 38 57 #ifndef W 39 58 # define W(flag, data) ((flag) ? SWAP (data) : (data)) … … 45 64 # define SWAP(i) bswap_32 (i) 46 65 #else 47 static nls_uint32 SWAP PARAMS ((nls_uint32 i));48 49 66 static inline nls_uint32 50 67 SWAP (i) … … 56 73 57 74 75 /* This is the representation of the expressions to determine the 76 plural form. */ 77 struct 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. */ 113 struct parse_args 114 { 115 const char *cp; 116 struct expression *res; 117 }; 118 119 120 /* The representation of an opened message catalog. */ 58 121 struct loaded_domain 59 122 { … … 67 130 nls_uint32 hash_size; 68 131 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(). */ 71 156 struct binding 72 157 { 73 158 struct binding *next; 74 char *domainname;75 159 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. */ 168 extern int _nl_msg_cat_cntr; 77 169 78 170 struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname, 79 171 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; 175 void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain, 176 struct binding *__domainbinding)) 83 177 internal_function; 84 178 void _nl_unload_domain PARAMS ((struct loaded_domain *__domain)) 85 179 internal_function; 180 const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile *__domain_file, 181 struct loaded_domain *__domain, 182 struct binding *__domainbinding)) 183 internal_function; 184 void _nl_free_domain_conv PARAMS ((struct loaded_domain *__domain)) 185 internal_function; 186 187 char *_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 193 extern char *__gettext PARAMS ((const char *__msgid)); 194 extern char *__dgettext PARAMS ((const char *__domainname, 195 const char *__msgid)); 196 extern char *__dcgettext PARAMS ((const char *__domainname, 197 const char *__msgid, int __category)); 198 extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2, 199 unsigned long int __n)); 200 extern char *__dngettext PARAMS ((const char *__domainname, 201 const char *__msgid1, const char *__msgid2, 202 unsigned long int n)); 203 extern char *__dcngettext PARAMS ((const char *__domainname, 204 const char *__msgid1, const char *__msgid2, 205 unsigned long int __n, int __category)); 206 extern char *__dcigettext PARAMS ((const char *__domainname, 207 const char *__msgid1, const char *__msgid2, 208 int __plural, unsigned long int __n, 209 int __category)); 210 extern char *__textdomain PARAMS ((const char *__domainname)); 211 extern char *__bindtextdomain PARAMS ((const char *__domainname, 212 const char *__dirname)); 213 extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname, 214 const char *__codeset)); 215 #else 216 extern char *gettext__ PARAMS ((const char *__msgid)); 217 extern char *dgettext__ PARAMS ((const char *__domainname, 218 const char *__msgid)); 219 extern char *dcgettext__ PARAMS ((const char *__domainname, 220 const char *__msgid, int __category)); 221 extern char *ngettext__ PARAMS ((const char *__msgid1, const char *__msgid2, 222 unsigned long int __n)); 223 extern char *dngettext__ PARAMS ((const char *__domainname, 224 const char *__msgid1, const char *__msgid2, 225 unsigned long int __n)); 226 extern char *dcngettext__ PARAMS ((const char *__domainname, 227 const char *__msgid1, const char *__msgid2, 228 unsigned long int __n, int __category)); 229 extern char *dcigettext__ PARAMS ((const char *__domainname, 230 const char *__msgid1, const char *__msgid2, 231 int __plural, unsigned long int __n, 232 int __category)); 233 extern char *textdomain__ PARAMS ((const char *__domainname)); 234 extern char *bindtextdomain__ PARAMS ((const char *__domainname, 235 const char *__dirname)); 236 extern char *bind_textdomain_codeset__ PARAMS ((const char *__domainname, 237 const char *__codeset)); 238 #endif 239 240 #ifdef _LIBC 241 extern void __gettext_free_exp PARAMS ((struct expression *exp)) 242 internal_function; 243 extern int __gettextparse PARAMS ((void *arg)); 244 #else 245 extern void gettext_free_exp__ PARAMS ((struct expression *exp)) 246 internal_function; 247 extern int gettextparse__ PARAMS ((void *arg)); 248 #endif 86 249 87 250 /* @@ begin of epilog @@ */ trunk/sweep/intl/hash-string.h
r7 r124 1 /* Implements astring 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. 3 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 by6 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) 7 7 any later version. 8 8 9 9 This program is distributed in the hope that it will be useful, 10 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNUGeneral Public License for more details.11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 13 14 14 You should have received a copy of the GNU Library General Public 15 License along with th e 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. */ 18 18 19 19 /* @@ end of prolog @@ */ trunk/sweep/intl/intl-compat.c
r7 r124 1 1 /* intl-compat.c - Stub functions to call gettext functions from GNU gettext 2 2 Library. 3 Copyright (C) 1995 Software Foundation, Inc.3 Copyright (C) 1995, 2000, 2001 Software Foundation, Inc. 4 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)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. 9 9 10 This program is distributed in the hope that it will be useful,11 but WITHOUT ANY WARRANTY; without even the implied warranty of12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNUGeneral 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. 14 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 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. */ 18 19 19 20 #ifdef HAVE_CONFIG_H … … 21 22 #endif 22 23 23 #include "libgettext.h" 24 #include "libgnuintl.h" 25 #include "gettextP.h" 24 26 25 27 /* @@ 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. */ 26 70 27 71 … … 29 73 #undef dgettext 30 74 #undef dcgettext 75 #undef ngettext 76 #undef dngettext 77 #undef dcngettext 31 78 #undef textdomain 32 79 #undef bindtextdomain 80 #undef bind_textdomain_codeset 33 81 34 82 35 83 char * 36 bindtextdomain (domainname, dirname) 84 gettext (msgid) 85 const char *msgid; 86 { 87 return gettext__ (msgid); 88 } 89 90 91 char * 92 dgettext (domainname, msgid) 37 93 const char *domainname; 38 const char * dirname;94 const char *msgid; 39 95 { 40 return bindtextdomain__ (domainname, dirname);96 return dgettext__ (domainname, msgid); 41 97 } 42 98 … … 53 109 54 110 char * 55 dgettext (domainname, msgid) 56 const char *domainname; 57 const char *msgid; 111 ngettext (msgid1, msgid2, n) 112 const char *msgid1; 113 const char *msgid2; 114 unsigned long int n; 58 115 { 59 return dgettext__ (domainname, msgid);116 return ngettext__ (msgid1, msgid2, n); 60 117 } 61 118 62 119 63 120 char * 64 gettext (msgid) 65 const char *msgid; 121 dngettext (domainname, msgid1, msgid2, n) 122 const char *domainname; 123 const char *msgid1; 124 const char *msgid2; 125 unsigned long int n; 66 126 { 67 return gettext__ (msgid); 127 return dngettext__ (domainname, msgid1, msgid2, n); 128 } 129 130 131 char * 132 dcngettext (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); 68 140 } 69 141 … … 75 147 return textdomain__ (domainname); 76 148 } 149 150 151 char * 152 bindtextdomain (domainname, dirname) 153 const char *domainname; 154 const char *dirname; 155 { 156 return bindtextdomain__ (domainname, dirname); 157 } 158 159 160 char * 161 bind_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. 3 2 Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. 4 3 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 by7 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) 8 7 any later version. 9 8 10 9 This program is distributed in the hope that it will be useful, 11 10 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 18 25 19 26 #ifdef HAVE_CONFIG_H … … 21 28 #endif 22 29 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> 35 31 #if !HAVE_STRCHR && !defined _LIBC 36 32 # ifndef strchr … … 44 40 #include <ctype.h> 45 41 #include <sys/types.h> 46 47 #if defined STDC_HEADERS || defined _LIBC 48 # include <stdlib.h> 49 #endif 42 #include <stdlib.h> 50 43 51 44 #include "loadinfo.h" … … 225 218 /* Construct file name. */ 226 219 memcpy (abs_filename, dirlist, dirlist_len); 227 __argz_stringify (abs_filename, dirlist_len, ':');220 __argz_stringify (abs_filename, dirlist_len, PATH_SEPARATOR); 228 221 cp = abs_filename + (dirlist_len - 1); 229 222 *cp++ = '/'; … … 350 343 /* Normalize codeset name. There is no standard for the codeset 351 344 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. */ 353 347 const char * 354 348 _nl_normalize_codeset (codeset, name_len) trunk/sweep/intl/libgettext.h
r7 r124 1 /* Message catalogs for internationalization.2 Copyright (C) 1995 , 1996, 1997, 1998Free Software Foundation, Inc.1 /* Convenience header for conditional use of GNU <libintl.h>. 2 Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. 3 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 by6 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) 7 7 any later version. 8 8 9 9 This program is distributed in the hope that it will be useful, 10 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNUGeneral Public License for more details.11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 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. */ 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. */ 17 18 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 22 21 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. */ 124 23 #if ENABLE_NLS 125 24 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> 165 27 166 28 #else … … 169 31 # define dgettext(Domainname, Msgid) (Msgid) 170 32 # 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)) 173 42 174 43 #endif 175 44 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) 177 48 178 #ifdef __cplusplus 179 } 180 #endif 181 182 #endif 49 #endif /* _LIBGETTEXT_H */ trunk/sweep/intl/loadinfo.h
r7 r124 1 /* Copyright (C) 1996 , 1997Free Software Foundation, Inc.1 /* Copyright (C) 1996-1999, 2000, 2001 Free Software Foundation, Inc. 2 2 This file is part of the GNU C Library. 3 3 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. 4 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 by7 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) 8 8 any later version. 9 9 10 10 This program is distributed in the hope that it will be useful, 11 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNUGeneral Public License for more details.12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 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. */ 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 18 22 19 23 #ifndef PARAMS … … 23 27 # define PARAMS(args) () 24 28 # 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 ':' 25 48 #endif 26 49 … … 51 74 52 75 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. */ 53 80 extern const char *_nl_normalize_codeset PARAMS ((const char *codeset, 54 81 size_t name_len)); … … 67 94 extern const char *_nl_expand_alias PARAMS ((const char *name)); 68 95 96 /* normalized_codeset is dynamically allocated and has to be freed by 97 the caller. */ 69 98 extern int _nl_explode_name PARAMS ((char *name, const char **language, 70 99 const char **modifier, … … 77 106 78 107 extern char *_nl_find_language PARAMS ((const char *name)); 108 109 #endif /* loadinfo.h */ trunk/sweep/intl/loadmsgcat.c
r7 r124 1 1 /* Load needed message catalogs. 2 Copyright (C) 1995 , 1996, 1997, 1998Free 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 by6 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) 7 7 any later version. 8 8 9 9 This program is distributed in the hope that it will be useful, 10 10 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 17 25 18 26 #ifdef HAVE_CONFIG_H … … 20 28 #endif 21 29 30 #include <ctype.h> 31 #include <errno.h> 22 32 #include <fcntl.h> 23 33 #include <sys/types.h> 24 34 #include <sys/stat.h> 25 35 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 47 char *alloca (); 48 # endif 49 # endif 50 # endif 51 #endif 52 53 #include <stdlib.h> 54 #include <string.h> 29 55 30 56 #if defined HAVE_UNISTD_H || defined _LIBC 31 57 # include <unistd.h> 58 #endif 59 60 #ifdef _LIBC 61 # include <langinfo.h> 62 # include <locale.h> 32 63 #endif 33 64 … … 43 74 #include "gettext.h" 44 75 #include "gettextP.h" 76 77 #ifdef _LIBC 78 # include "../locale/localeinfo.h" 79 #endif 45 80 46 81 /* @@ end of prolog @@ */ … … 57 92 #endif 58 93 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 59 130 /* We need a sign, whether a new catalog was loaded, which can be associated 60 131 with all translations. This is important if the translations are 61 132 cached by one of GCC's features. */ 62 int _nl_msg_cat_cntr = 0; 63 133 int _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". */ 140 static const struct expression plvar = 141 { 142 .nargs = 0, 143 .operation = var, 144 }; 145 static const struct expression plone = 146 { 147 .nargs = 0, 148 .operation = num, 149 .val = 150 { 151 .num = 1 152 } 153 }; 154 static 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 175 static struct expression plvar; 176 static struct expression plone; 177 static struct expression germanic_plural; 178 179 static void 180 init_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. */ 205 const char * 206 internal_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. */ 317 void 318 internal_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 } 64 335 65 336 /* Load the message catalogs specified by FILENAME. If it is no valid … … 67 338 void 68 339 internal_function 69 _nl_load_domain (domain_file )340 _nl_load_domain (domain_file, domainbinding) 70 341 struct loaded_l10nfile *domain_file; 342 struct binding *domainbinding; 71 343 { 72 344 int fd; 73 345 size_t size; 346 #ifdef _LIBC 347 struct stat64 st; 348 #else 74 349 struct stat st; 350 #endif 75 351 struct mo_file_header *data = (struct mo_file_header *) -1; 76 352 int use_mmap = 0; 77 353 struct loaded_domain *domain; 354 const char *nullentry; 78 355 79 356 domain_file->decided = 1; 80 357 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). */ 81 362 82 363 /* If the record does not represent a valid locale the FILENAME … … 88 369 89 370 /* Try to open the addressed file. */ 90 fd = open (domain_file->filename, O_RDONLY );371 fd = open (domain_file->filename, O_RDONLY | O_BINARY); 91 372 if (fd == -1) 92 373 return; 93 374 94 375 /* 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)) 98 384 { 99 385 /* Something went wrong. */ … … 108 394 MAP_PRIVATE, fd, 0); 109 395 110 if ( data != (struct mo_file_header *) -1)396 if (__builtin_expect (data != (struct mo_file_header *) -1, 1)) 111 397 { 112 398 /* mmap() call was successful. */ … … 132 418 { 133 419 long int nb = (long int) read (fd, read_ptr, to_read); 134 if (nb == -1)420 if (nb <= 0) 135 421 { 422 #ifdef EINTR 423 if (nb == -1 && errno == EINTR) 424 continue; 425 #endif 136 426 close (fd); 137 427 return; 138 428 } 139 140 429 read_ptr += nb; 141 430 to_read -= nb; … … 148 437 /* Using the magic number we can test whether it really is a message 149 438 catalog file. */ 150 if (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED) 439 if (__builtin_expect (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED, 440 0)) 151 441 { 152 442 /* The magic number is wrong: not a message catalog file. */ … … 160 450 } 161 451 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) 165 454 return; 166 167 domain = (struct loaded_domain *) domain_file->data; 455 domain_file->data = domain; 456 168 457 domain->data = (char *) data; 169 458 domain->use_mmap = use_mmap; … … 197 486 } 198 487 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 } 202 544 } 203 545 … … 209 551 struct loaded_domain *domain; 210 552 { 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 212 559 if (domain->use_mmap) 213 560 munmap ((caddr_t) domain->data, domain->mmap_size); 214 561 else 215 # endif /* _POSIX_MAPPED_FILES */562 # endif /* _POSIX_MAPPED_FILES */ 216 563 free ((void *) domain->data); 217 564 trunk/sweep/intl/localealias.c
r7 r124 1 1 /* 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) 8 7 any later version. 9 8 10 9 This program is distributed in the hope that it will be useful, 11 10 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 18 25 19 26 #ifdef HAVE_CONFIG_H … … 42 49 #endif 43 50 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> 66 54 #if !HAVE_STRCHR && !defined _LIBC 67 55 # ifndef strchr … … 70 58 #endif 71 59 72 #include "gettext.h"73 60 #include "gettextP.h" 74 61 … … 96 83 #endif 97 84 98 /* For those lo osing systems which don't have `alloca' we have to add85 /* For those losing systems which don't have `alloca' we have to add 99 86 some additional code emulating it. */ 100 87 #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 */ 104 89 #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 132 93 133 94 #if defined _LIBC_REENTRANT || defined HAVE_FGETS_UNLOCKED … … 148 109 149 110 150 static char *string_space = NULL;151 static size_t string_space_act = 0;152 static size_t string_space_max = 0;111 static char *string_space; 112 static size_t string_space_act; 113 static size_t string_space_max; 153 114 static struct alias_map *map; 154 static size_t nmap = 0;155 static size_t maxmap = 0;115 static size_t nmap; 116 static size_t maxmap; 156 117 157 118 … … 159 120 static size_t read_alias_file PARAMS ((const char *fname, int fname_len)) 160 121 internal_function; 161 static voidextend_alias_table PARAMS ((void));122 static int extend_alias_table PARAMS ((void)); 162 123 static int alias_compare PARAMS ((const struct alias_map *map1, 163 124 const struct alias_map *map2)); … … 205 166 const char *start; 206 167 207 while (locale_alias_path[0] == ':')168 while (locale_alias_path[0] == PATH_SEPARATOR) 208 169 ++locale_alias_path; 209 170 start = locale_alias_path; 210 171 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) 212 174 ++locale_alias_path; 213 175 … … 232 194 int fname_len; 233 195 { 234 #ifndef HAVE_ALLOCA235 struct block_list *block_list = NULL;236 #endif237 196 FILE *fp; 238 197 char *full_fname; … … 241 200 242 201 full_fname = (char *) alloca (fname_len + sizeof aliasfile); 243 ADD_BLOCK (block_list, full_fname);244 202 #ifdef HAVE_MEMPCPY 245 203 mempcpy (mempcpy (full_fname, fname, fname_len), … … 251 209 252 210 fp = fopen (full_fname, "r"); 211 freea (full_fname); 253 212 if (fp == NULL) 254 { 255 FREE_BLOCKS (block_list); 256 return 0; 257 } 213 return 0; 258 214 259 215 added = 0; … … 327 283 328 284 if (nmap >= maxmap) 329 extend_alias_table (); 285 if (__builtin_expect (extend_alias_table (), 0)) 286 return added; 330 287 331 288 alias_len = strlen (alias) + 1; … … 340 297 char *new_pool = (char *) realloc (string_space, new_size); 341 298 if (new_pool == NULL) 299 return added; 300 301 if (__builtin_expect (string_space != new_pool, 0)) 342 302 { 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 } 345 310 } 311 346 312 string_space = new_pool; 347 313 string_space_max = new_size; … … 370 336 (int (*) PARAMS ((const void *, const void *))) alias_compare); 371 337 372 FREE_BLOCKS (block_list);373 338 return added; 374 339 } 375 340 376 341 377 static void342 static int 378 343 extend_alias_table () 379 344 { … … 386 351 if (new_map == NULL) 387 352 /* Simply don't extend: we don't have any more core. */ 388 return ;353 return -1; 389 354 390 355 map = new_map; 391 356 maxmap = new_size; 357 return 0; 392 358 } 393 359 trunk/sweep/intl/textdomain.c
r7 r124 1 1 /* 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. 4 3 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 by7 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) 8 7 any later version. 9 8 10 9 This program is distributed in the hope that it will be useful, 11 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNUGeneral Public License for more details.11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 14 13 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. */ 18 18 19 19 #ifdef HAVE_CONFIG_H … … 21 21 #endif 22 22 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> 35 25 36 26 #ifdef _LIBC 37 27 # include <libintl.h> 38 28 #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__ 40 49 #endif 41 50 … … 62 71 #endif 63 72 73 /* Lock variable to protect the global data in the gettext implementation. */ 74 __libc_rwlock_define (extern, _nl_state_lock) 75 64 76 /* Set the current default message catalog to DOMAINNAME. 65 77 If DOMAINNAME is null, return the current default. … … 69 81 const char *domainname; 70 82 { 71 char *old; 83 char *new_domain; 84 char *old_domain; 72 85 73 86 /* A NULL pointer requests the current setting. */ … … 75 88 return (char *) _nl_current_default_domain; 76 89 77 old = (char *) _nl_current_default_domain; 90 __libc_rwlock_wrlock (_nl_state_lock); 91 92 old_domain = (char *) _nl_current_default_domain; 78 93 79 94 /* If domain name is the null string set to default domain "messages". */ 80 95 if (domainname[0] == '\0' 81 96 || 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; 83 105 else 84 106 { … … 87 109 are out of core. */ 88 110 #if defined _LIBC || defined HAVE_STRDUP 89 _nl_current_default_domain = strdup (domainname);111 new_domain = strdup (domainname); 90 112 #else 91 113 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); 96 117 #endif 118 119 if (new_domain != NULL) 120 _nl_current_default_domain = new_domain; 97 121 } 98 122 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; 101 129 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; 103 137 } 104 138 trunk/sweep/missing
r7 r124 1 1 #! /bin/sh 2 2 # 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. 5 5 6 6 # This program is free software; you can redistribute it and/or modify … … 19 19 # 02111-1307, USA. 20 20 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 21 26 if test $# -eq 0; then 22 27 echo 1>&2 "Try \`$0 --help' for more information" … … 24 29 fi 25 30 31 run=: 32 33 # In the cases where this matters, `missing' is being run in the 34 # srcdir already. 35 if test -f configure.ac; then 36 configure_ac=configure.ac 37 else 38 configure_ac=configure.in 39 fi 40 41 case "$1" in 42 --run) 43 # Try to run requested program, and just exit if it succeeds. 44 run= 45 shift 46 "$@" && exit 0 47 ;; 48 esac 49 50 # If it does not exist, or fails to run (possibly an outdated version), 51 # try to emulate it. 26 52 case "$1" in 27 53 … … 36 62 -h, --help display this help and exit 37 63 -v, --version output version information and exit 64 --run try to run the given command, and emulate it if it fails 38 65 39 66 Supported PROGRAM values: … … 44 71 bison create \`y.tab.[ch]', if possible, from existing .[ch] 45 72 flex create \`lex.yy.c', if possible, from existing .c 73 help2man touch the output file 46 74 lex create \`lex.yy.c', if possible, from existing .c 47 75 makeinfo touch the output file 76 tar try tar, gnutar, gtar, then tar without non-portable flags 48 77 yacc create \`y.tab.[ch]', if possible, from existing .[ch]" 49 78 ;; 50 79 51 80 -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 52 echo "missing - GNU libit 0.0"81 echo "missing 0.4 - GNU automake" 53 82 ;; 54 83 … … 59 88 ;; 60 89 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 "\ 97 WARNING: \`$1' is missing on your system. You should only need it if 98 you modified \`acinclude.m4' or \`${configure_ac}'. You might want 65 99 to install the \`Automake' and \`Perl' packages. Grab them from 66 100 any GNU archive site." … … 69 103 70 104 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 "\ 111 WARNING: \`$1' is missing on your system. You should only need it if 112 you modified \`${configure_ac}'. You might want to install the 74 113 \`Autoconf' and \`GNU m4' packages. Grab them from any GNU 75 114 archive site." … … 78 117 79 118 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 "\ 125 WARNING: \`$1' is missing on your system. You should only need it if 126 you modified \`acconfig.h' or \`${configure_ac}'. You might want 83 127 to install the \`Autoconf' and \`GNU m4' packages. Grab them 84 128 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}` 86 130 test -z "$files" && files="config.h" 87 131 touch_files= … … 96 140 ;; 97 141 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 "\ 149 WARNING: \`$1' is missing on your system. You should only need it if 150 you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. 102 151 You might want to install the \`Automake' and \`Perl' packages. 103 152 Grab them from any GNU archive site." … … 105 154 sed 's/\.am$/.in/' | 106 155 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 "\ 165 WARNING: \`$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 107 184 ;; 108 185 … … 160 237 ;; 161 238 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 "\ 246 WARNING: \`$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 162 264 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 163 270 echo 1>&2 "\ 164 271 WARNING: \`$1' is missing on your system. You should only need it if … … 176 283 ;; 177 284 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 "\ 318 WARNING: 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 178 324 *) 179 325 echo 1>&2 "\ trunk/sweep/mkinstalldirs
r7 r124 5 5 # Public domain 6 6 7 # $Id$ 7 errstatus=0 8 dirmode="" 8 9 9 errstatus=0 10 usage="\ 11 Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." 12 13 # process command line arguments 14 while 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 27 done 28 29 for file 30 do 31 if test -d "$file"; then 32 shift 33 else 34 break 35 fi 36 done 37 38 case $# in 39 0) exit 0 ;; 40 esac 41 42 case $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 ;; 53 esac 10 54 11 55 for file … … 23 67 24 68 if test ! -d "$pathcomp"; then 25 echo "mkdir $pathcomp"69 echo "mkdir $pathcomp" 26 70 27 mkdir "$pathcomp" || lasterr=$?71 mkdir "$pathcomp" || lasterr=$? 28 72 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 32 87 fi 33 88 … … 38 93 exit $errstatus 39 94 95 # Local Variables: 96 # mode: shell-script 97 # sh-indentation: 3 98 # End: 40 99 # mkinstalldirs ends here trunk/sweep/plugins/Makefile.am
r84 r124 1 1 ## Process this file with automake to produce Makefile.in 2 2 3 SUBDIRS = example byenergy echo normalise reverse ladspa3 SUBDIRS = example byenergy echo fade normalise reverse ladspa trunk/sweep/plugins/byenergy/byenergy.c
r80 r124 57 57 { 58 58 N_("Select regions above threshold"), 59 N_("Whether to select those regions lying above a given thresh hold"59 N_("Whether to select those regions lying above a given threshold " 60 60 "or below it."), 61 61 SWEEP_TYPE_BOOL, … … 112 112 gfloat max_interruption_f = pset[4].f; 113 113 114 sw_sounddata * sounddata; 114 115 sw_audio_t * d; 115 116 glong window, win_s; … … 120 121 sw_audio_intermediate_t di, energy, max_energy=0, factor=1.0; 121 122 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); 125 128 126 129 /* check (end-1 - (start+1)) > 0 */ 127 130 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); 135 138 136 139 /* Find max for normalisation */ 137 140 138 length = s ->sounddata->nr_frames;141 length = sounddata->nr_frames; 139 142 doff = 0; 140 143 while (length > 0) { 141 144 energy = 0; 142 145 143 win_s = frames_to_samples (s ->sounddata->format, MIN(length, window));146 win_s = frames_to_samples (sounddata->format, MIN(length, window)); 144 147 145 148 /* calculate avg. for this window */ … … 166 169 threshold *= (gfloat)max_energy; 167 170 168 length = s ->sounddata->nr_frames;171 length = sounddata->nr_frames; 169 172 doff = 0; 170 173 while (length > 0) { 171 174 energy = 0; 172 175 173 win_s = frames_to_samples (s ->sounddata->format, MIN(length, window));176 win_s = frames_to_samples (sounddata->format, MIN(length, window)); 174 177 175 178 /* calculate RMS energy for this window */ … … 198 201 if (loc - end > max_interruption) { 199 202 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); 201 204 } 202 205 end = start = -1; … … 211 214 if (start != -1) { 212 215 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); 222 221 } 223 222 … … 227 226 return 228 227 perform_selection_op (sample, _("Select by energy"), 229 (Sweep Modify)select_by_energy, pset, NULL);228 (SweepFilter)select_by_energy, pset, NULL); 230 229 } 231 230 … … 233 232 N_("Select by energy"), 234 233 N_("Select loud or quiet regions"), 235 "C onrad Parker",236 "Copyright (C) 2000 ",234 "C. Parker, S. Pfeiffer", 235 "Copyright (C) 2000 CSIRO Australia", 237 236 "http://sweep.sourceforge.net/plugins/byenergy", 238 237 "Filters/Select by energy", /* identifier */ trunk/sweep/plugins/example/Makefile.am
r96 r124 9 9 # lib to stop it from actually being installed. 10 10 # 11 lib_LTLIBRARIES = libexample.la12 #noinst_LTLIBRARIES = libexample.la11 #lib_LTLIBRARIES = libexample.la 12 noinst_LTLIBRARIES = libexample.la 13 13 14 14 libexample_la_SOURCES = example.c trunk/sweep/plugins/ladspa/ladspa.h
r13 r124 1 1 /* ladspa.h 2 2 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. */ 5 21 6 22 #ifndef LADSPA_INCLUDED … … 21 37 them dynamically (`plug') into a range of these packages (`hosts'). 22 38 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. 25 40 26 41 This API is deliberately short and simple. To achieve compatibility … … 58 73 is used to communicate audio samples and control values. It is 59 74 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. */ 61 79 62 80 typedef float LADSPA_Data; … … 184 202 specified then the value of LowerBound should be multiplied by the 185 203 sample rate. */ 186 #define LADSPA_HINT_BOUNDED_BELOW 0x1204 #define LADSPA_HINT_BOUNDED_BELOW 0x1 187 205 188 206 /* Hint LADSPA_HINT_BOUNDED_ABOVE indicates that the UpperBound field … … 192 210 specified then the value of UpperBound should be multiplied by the 193 211 sample rate. */ 194 #define LADSPA_HINT_BOUNDED_ABOVE 0x2212 #define LADSPA_HINT_BOUNDED_ABOVE 0x2 195 213 196 214 /* Hint LADSPA_HINT_TOGGLED indicates that the data item should be … … 198 216 be considered `off' or `false,' and data above zero should be 199 217 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 202 221 203 222 /* Hint LADSPA_HINT_SAMPLE_RATE indicates that any bounds specified … … 207 226 with LowerBound = 0 and UpperBound = 0.5. Hosts that support bounds 208 227 at all must support this hint to retain meaning. */ 209 #define LADSPA_HINT_SAMPLE_RATE 0x8228 #define LADSPA_HINT_SAMPLE_RATE 0x8 210 229 211 230 /* Hint LADSPA_HINT_LOGARITHMIC indicates that it is likely that the 212 231 user will find it more intuitive to view values using a logarithmic 213 232 scale. This is particularly useful for frequencies and gains. */ 214 #define LADSPA_HINT_LOGARITHMIC 0x10233 #define LADSPA_HINT_LOGARITHMIC 0x10 215 234 216 235 /* Hint LADSPA_HINT_INTEGER indicates that a user interface would … … 220 239 instance, the integer set {0,1,2,3} might be described as [-0.1, 221 240 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 223 305 224 306 #define LADSPA_IS_HINT_BOUNDED_BELOW(x) ((x) & LADSPA_HINT_BOUNDED_BELOW) … … 228 310 #define LADSPA_IS_HINT_LOGARITHMIC(x) ((x) & LADSPA_HINT_LOGARITHMIC) 229 311 #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) 230 332 231 333 typedef struct _LADSPA_PortRangeHint { … … 490 592 491 593 #ifdef __cplusplus 492 } ;594 } 493 595 #endif 494 596 trunk/sweep/plugins/ladspa/ladspameta.c
r58 r124 39 39 40 40 #include <sweep/sweep.h> 41 #include "../src/sweep_app.h" 41 42 42 43 #include "ladspa.h" … … 115 116 116 117 if (LADSPA_IS_HINT_BOUNDED_BELOW(prhd)) 117 ret &= SW_RANGE_LOWER_BOUND_VALID;118 ret |= SW_RANGE_LOWER_BOUND_VALID; 118 119 if (LADSPA_IS_HINT_BOUNDED_ABOVE(prhd)) 119 ret &= SW_RANGE_UPPER_BOUND_VALID;120 ret |= SW_RANGE_UPPER_BOUND_VALID; 120 121 121 122 return ret; … … 123 124 124 125 static sw_param_range * 125 convert_constraint (const LADSPA_PortRangeHint * prh) 126 convert_constraint ( /* sw_format * format, */ 127 const LADSPA_PortRangeHint * prh) 126 128 { 127 129 sw_param_range * pr; 128 130 LADSPA_PortRangeHintDescriptor prhd = prh->HintDescriptor; 131 LADSPA_Data lower, upper; 129 132 130 133 if (LADSPA_IS_HINT_TOGGLED(prhd)) … … 135 138 pr->valid_mask = get_valid_mask (prhd); 136 139 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 137 153 if (LADSPA_IS_HINT_INTEGER(prhd)) { 138 154 if (LADSPA_IS_HINT_BOUNDED_BELOW(prhd)) 139 pr->lower.i = (sw_int) prh->LowerBound;155 pr->lower.i = (sw_int)lower; 140 156 if (LADSPA_IS_HINT_BOUNDED_ABOVE(prhd)) 141 pr->upper.i = (sw_int) prh->UpperBound;157 pr->upper.i = (sw_int)upper; 142 158 } else { 143 159 if (LADSPA_IS_HINT_BOUNDED_BELOW(prhd)) 144 pr->lower.f = (sw_float) prh->LowerBound;160 pr->lower.f = (sw_float)lower; 145 161 if (LADSPA_IS_HINT_BOUNDED_ABOVE(prhd)) 146 pr->upper.f = (sw_float) prh->UpperBound;162 pr->upper.f = (sw_float)upper; 147 163 } 148 164 … … 171 187 } 172 188 189 static sw_param 190 convert_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 173 261 static void 174 ladspa_meta_apply_region (gpointer pcmdata, sw_format * format, 175 gint nr_frames, 176 sw_param_set pset, gpointer custom_data) 262 ladspa_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 287 static sw_sample * 288 ladspa_meta_apply_filter (sw_sample * sample, sw_param_set pset, 289 gpointer custom_data) 177 290 { 178 291 lm_custom * lm = (lm_custom *)custom_data; … … 180 293 sw_param_spec * param_specs = lm->param_specs; 181 294 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; 183 313 LADSPA_Data ** input_buffers, ** output_buffers; 184 LADSPA_Data * mono_input_buffer =NULL;314 LADSPA_Data * mono_input_buffers[1], * mono_output_buffers[1]; 185 315 LADSPA_Data * p; 186 316 LADSPA_Data * control_inputs; … … 189 319 glong length_b; 190 320 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; 199 322 200 323 /* Enumerate the numbers of each type of port on the ladspa plugin */ … … 206 329 207 330 /* The number of audio channels to be processed */ 208 gint nr_channels = format->channels;331 gint nr_channels; 209 332 210 333 /* The number of input and output buffers to use */ … … 214 337 gint ibi=0, obi=0; 215 338 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; 219 350 220 351 /* Cache how many of each type of port this ladspa plugin has */ … … 243 374 g_assert (nr_ao > 0); 244 375 245 iterations = (gint) ceil(((double)nr_channels) / ((double)nr_ao));376 nr_handles = (gint) ceil(((double)nr_channels) / ((double)nr_ao)); 246 377 247 378 /* Numbers of input and output buffers: ensure 248 379 * nr_i >= nr_channels && nr_o >= nr_channels 249 380 */ 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 */ 252 385 253 386 if ((nr_channels == 1) && (nr_ai == 1) && (nr_ao >= 1)) { … … 257 390 */ 258 391 259 /* C opy PCM dataif this ladspa plugin cannot work inplace */392 /* Create an input buffer if this ladspa plugin cannot work inplace */ 260 393 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); 264 396 } 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; 269 405 270 406 } else { 271 length_b = LADSPA_frames_to_bytes ( nr_frames);407 length_b = LADSPA_frames_to_bytes (BLOCK_SIZE); 272 408 273 409 /* Allocate zeroed input buffers; these will remain zeroed … … 302 438 } 303 439 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); 323 444 } 324 445 … … 350 471 break; 351 472 } 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 353 478 j++; 354 479 } 355 480 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]); 395 588 } 396 589 } 397 590 398 591 /* 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 402 601 /* free the input and output buffers */ 403 602 if (control_inputs) g_free (control_inputs); 404 603 405 604 if ((nr_channels == 1) && (nr_ai == 1) && (nr_ao >= 1)) { 406 605 if (LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 407 g_free (mono_input_buffer );606 g_free (mono_input_buffers[0]); 408 607 } 409 608 } else { 410 609 411 610 /* free the output buffers */ 412 611 for (i=0; i < nr_o; i++) { … … 430 629 g_free (input_buffers); 431 630 } 631 632 return sample; 432 633 } 433 634 … … 440 641 441 642 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); 445 646 } 446 647 … … 479 680 480 681 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; 484 685 485 686 nr_params=0; … … 499 700 pd = d->PortDescriptors[j]; 500 701 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]; 503 704 proc->param_specs[k].type = 504 705 convert_type (d->PortRangeHints[j].HintDescriptor); … … 515 716 } 516 717 718 proc->suggest = ladspa_meta_suggest; 719 517 720 proc->apply = ladspa_meta_apply; 518 721 trunk/sweep/src/Makefile.am
r83 r124 4 4 -I$(top_srcdir)/intl \ 5 5 -I$(top_srcdir)/include \ 6 @GTK_CFLAGS@ \ 7 @AUDIOFILE_CFLAGS@ 6 @SNDFILE_CFLAGS@ \ 7 @OGG_CFLAGS@ @VORBIS_CFLAGS@ \ 8 @SAMPLERATE_CFLAGS@ 8 9 9 10 bin_PROGRAMS = sweep … … 13 14 main.c \ 14 15 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 \ 15 26 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 \ 17 33 format.c format.h \ 34 head.c head.h \ 18 35 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 \ 23 37 notes.c notes.h \ 24 38 param.c param.h \ 39 paste_dialogs.c paste_dialogs.h \ 40 pcmio.h \ 41 pixmaps.h \ 42 play.c play.h \ 25 43 plugin.c plugin.h \ 44 preferences.c preferences.h \ 26 45 print.c print.h \ 46 question_dialogs.c question_dialogs.h \ 47 record.c record.h \ 27 48 sample-display.c sample-display.h \ 49 samplerate.c \ 50 sw_chooser.c sw_chooser.h \ 28 51 sweep_filter.c \ 29 52 sweep_sample.c sample.h \ … … 33 56 sweep_undo.c \ 34 57 time_ruler.c time_ruler.h \ 58 timeouts.c \ 59 undo_dialog.c undo_dialog.h \ 35 60 view.c view.h \ 36 pixmaps.h \ 37 view_pixmaps.h \ 38 horiz.xpm horiz_plus.xpm 61 view_pixmaps.h 39 62 40 sweep_LDADD = @GTK_LIBS@ @AUDIOFILE_LIB@ $(INTLLIBS) $(PTHREAD_LIBS) 63 sweep_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) 41 68 69 sweep_LDFLAGS = ${EXPORT_SYMBOLS_LDFLAGS} trunk/sweep/src/about_dialog.c
r57 r124 25 25 #include <stdio.h> 26 26 #include <stdlib.h> 27 #include <string.h> 27 28 #include <time.h> 28 29 … … 53 54 #endif 54 55 56 static void 57 sweep_homepage (GtkWidget * widget, gpointer data) 58 { 59 system ("gnome-moz-remote http://sweep.sourceforge.net/"); 60 } 61 55 62 void 56 63 about_dialog_create() … … 64 71 #define BUF_LEN 64 65 72 gchar buf[BUF_LEN]; 73 GtkWidget * button; 66 74 67 75 if (!about_dialog) { … … 123 131 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); 124 132 gtk_widget_show(label); 133 #endif 125 134 126 135 gtk_widget_pop_style(); 127 136 137 #if 0 128 138 alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); 129 139 gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0); … … 135 145 #endif 136 146 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); 137 152 } 138 153 if (!GTK_WIDGET_VISIBLE(about_dialog)) { trunk/sweep/src/callbacks.c
r98 r124 25 25 #include <stdio.h> 26 26 #include <string.h> 27 #include <stdlib.h> 27 28 28 29 #include <gtk/gtk.h> … … 30 31 #include "callbacks.h" 31 32 33 #include <sweep/sweep_i18n.h> 32 34 #include <sweep/sweep_types.h> 33 35 #include <sweep/sweep_undo.h> 34 36 #include <sweep/sweep_sample.h> 37 #include <sweep/sweep_typeconvert.h> 35 38 36 39 #include "sample.h" 37 40 #include "interface.h" 38 41 #include "edit.h" 42 #include "head.h" 39 43 #include "sample-display.h" 44 #include "play.h" 40 45 #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" 43 50 44 51 /* … … 55 62 * where DEFAULT_MIN_ZOOM is defined in view.c 56 63 */ 57 #define DEFAULT_ZOOM 1.2 58 64 #define DEFAULT_ZOOM 2.0 65 66 #define ZOOM_FRAMERATE 10 59 67 60 68 /* Sample creation */ … … 63 71 sample_new_empty_cb (GtkWidget * widget, gpointer data) 64 72 { 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 } 88 80 } 89 81 … … 101 93 102 94 ns = sample_new_copy(s); 95 96 while (ns->color == s->color) { 97 ns->color = (random()) % VIEW_COLOR_MAX; 98 } 99 103 100 v = view_new_all (ns, 1.0); 104 101 sample_add_view (ns, v); … … 107 104 } 108 105 106 /* Generic repeater */ 107 108 static void 109 view_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 119 void 120 repeater_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 } 109 129 110 130 /* View */ … … 124 144 125 145 void 146 view_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 160 void 126 161 view_close_cb (GtkWidget * widget, gpointer data) 127 162 { … … 137 172 exit_cb (GtkWidget * widget, gpointer data) 138 173 { 139 stop_playback(); 140 gtk_main_quit(); 174 sweep_quit (); 141 175 } 142 176 … … 145 179 set_tool_cb (GtkWidget * widget, gpointer data) 146 180 { 181 #if 0 147 182 gint tool = (gint)data; 148 183 149 current_tool = tool; 184 /* current_tool = tool;*/ 185 #endif 186 g_print ("NOOOOOOOOOOOOOO global current_tool\n"); 187 } 188 189 void 190 view_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); 150 201 } 151 202 152 203 /* Zooming */ 153 204 205 static gboolean 206 zoom_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 154 215 void 155 216 zoom_in_cb (GtkWidget * widget, gpointer data) 156 217 { 218 sw_view * view = (sw_view *)data; 219 view_zoom_in (view, DEFAULT_ZOOM); 220 } 221 222 static gboolean 223 zoom_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 232 void 233 zoom_out_cb (GtkWidget * widget, gpointer data) 234 { 235 sw_view * view = (sw_view *)data; 236 view_zoom_out (view, DEFAULT_ZOOM); 237 } 238 239 240 void 241 zoom_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 249 void 250 zoom_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 258 void 259 zoom_to_sel_cb (GtkWidget * widget, gpointer data) 260 { 157 261 SampleDisplay * sd = SAMPLE_DISPLAY(data); 158 262 sw_view * v = sd->view; 159 263 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 267 void 268 zoom_left_cb (GtkWidget * widget, gpointer data) 165 269 { 166 270 SampleDisplay * sd = SAMPLE_DISPLAY(data); 167 271 sw_view * v = sd->view; 168 272 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 276 void 277 zoom_right_cb (GtkWidget * widget, gpointer data) 174 278 { 175 279 SampleDisplay * sd = SAMPLE_DISPLAY(data); 176 280 sw_view * v = sd->view; 177 281 178 view_zoom_to_sel (v);179 }180 181 void182 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 void191 zoom_right_cb (GtkWidget * widget, gpointer data)192 {193 SampleDisplay * sd = SAMPLE_DISPLAY(data);194 sw_view * v = sd->view;195 196 282 view_zoom_right (v); 197 283 } … … 200 286 zoom_all_cb (GtkWidget * widget, gpointer data) 201 287 { 202 SampleDisplay * sd = SAMPLE_DISPLAY(data); 203 sw_view * v = sd->view; 288 sw_view * v = (sw_view *)data; 204 289 205 290 view_zoom_all (v); … … 224 309 { 225 310 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); 231 314 } 232 315 … … 235 318 { 236 319 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 325 void 326 zoom_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 333 void 334 zoom_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 362 void 363 device_config_cb (GtkWidget * widget, gpointer data) 364 { 365 device_config (); 366 } 367 368 /* Sample */ 369 370 void 371 sample_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); 242 378 } 243 379 … … 245 381 246 382 void 383 follow_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 392 void 393 follow_toggle_cb (GtkWidget * widget, gpointer data) 394 { 395 sw_view * view = (sw_view *)data; 396 view_set_following (view, !view->following); 397 } 398 399 void 400 loop_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 409 void 410 loop_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 416 void 417 playrev_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 426 void 427 playrev_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 433 void 434 mute_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 443 void 444 mute_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 450 void 451 monitor_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 460 void 461 monitor_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 467 void 468 play_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 484 void 247 485 play_view_cb (GtkWidget * widget, gpointer data) 248 486 { 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 500 void 501 play_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 } 266 520 } 267 521 … … 269 523 play_view_sel_cb (GtkWidget * widget, gpointer data) 270 524 { 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 543 void 544 pause_playback_cb (GtkWidget * widget, gpointer data) 545 { 546 sw_view * view = (sw_view *)data; 547 548 pause_playback (view->sample); 288 549 } 289 550 … … 291 552 stop_playback_cb (GtkWidget * widget, gpointer data) 292 553 { 293 stop_playback (); 554 sw_view * view = (sw_view *)data; 555 556 stop_playback (view->sample); 557 } 558 559 void 560 preview_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 573 void 574 preroll_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 585 void 586 show_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 595 static gboolean 596 rewind_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 607 static gboolean 608 ffwd_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 619 void 620 page_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 630 void 631 page_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 641 void 642 rewind_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 650 void 651 ffwd_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 659 void 660 goto_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 669 void 670 goto_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 679 void 680 goto_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 689 void 690 goto_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); 294 697 } 295 698 … … 333 736 } 334 737 738 void 739 adj_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 } 335 762 336 763 /* Selection */ … … 342 769 343 770 sample_selection_invert (sd->view->sample); 344 345 sample_refresh_views (sd->view->sample);346 771 } 347 772 … … 352 777 353 778 sample_selection_select_all (sd->view->sample); 354 355 sample_refresh_views (sd->view->sample);356 779 } 357 780 … … 362 785 363 786 sample_selection_select_none (sd->view->sample); 364 365 sample_refresh_views (sd->view->sample); 366 } 367 787 } 788 789 void 790 selection_halve_cb (GtkWidget * widget, gpointer data) 791 { 792 SampleDisplay * sd = SAMPLE_DISPLAY(data); 793 794 sample_selection_halve (sd->view->sample); 795 } 796 797 void 798 selection_double_cb (GtkWidget * widget, gpointer data) 799 { 800 SampleDisplay * sd = SAMPLE_DISPLAY(data); 801 802 sample_selection_double (sd->view->sample); 803 } 804 805 void 806 select_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 813 void 814 select_shift_right_cb (GtkWidget * widget, gpointer data) 815 { 816 SampleDisplay * sd = SAMPLE_DISPLAY(data); 817 818 sample_selection_shift_right (sd->view->sample); 819 } 368 820 369 821 /* Undo / Redo */ 370 822 371 823 void 824 show_undo_dialog_cb (GtkWidget * widget, gpointer data) 825 { 826 sw_view * view = (sw_view *)data; 827 828 undo_dialog_create (view->sample); 829 } 830 831 void 372 832 undo_cb (GtkWidget * widget, gpointer data) 373 833 { 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); 377 837 } 378 838 … … 380 840 redo_cb (GtkWidget * widget, gpointer data) 381 841 { 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 847 void 848 cancel_cb (GtkWidget * widget, gpointer data) 849 { 850 sw_view * view = (sw_view *)data; 851 852 cancel_active_op (view->sample); 853 } 387 854 388 855 /* Edit */ … … 391 858 copy_cb (GtkWidget * widget, gpointer data) 392 859 { 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; 395 862 396 863 do_copy (s); … … 400 867 cut_cb (GtkWidget * widget, gpointer data) 401 868 { 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; 404 871 405 872 do_cut (s); … … 409 876 clear_cb (GtkWidget * widget, gpointer data) 410 877 { 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; 413 880 414 881 do_clear (s); … … 418 885 delete_cb (GtkWidget * widget, gpointer data) 419 886 { 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; 422 889 423 890 do_delete (s); … … 425 892 426 893 void 894 crop_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 902 void 427 903 paste_cb (GtkWidget * widget, gpointer data) 428 904 { 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 911 void 912 paste_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 924 void 925 paste_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 } 433 935 } 434 936 … … 436 938 paste_as_new_cb (GtkWidget * widget, gpointer data) 437 939 { 438 SampleDisplay * sd = SAMPLE_DISPLAY(data);439 940 sw_sample * s; 440 941 sw_view * v; 441 942 442 do_paste_as_new (sd->view->sample, &s);443 943 s = do_paste_as_new (); 944 444 945 if (s) { 445 946 v = view_new_all (s, 1.0); 446 947 sample_add_view (s, v); 447 } 448 } 449 948 sample_bank_add (s); 949 } 950 } 951 952 void 953 show_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 34 34 35 35 void 36 view_new_cb (GtkWidget * widget, gpointer data); 37 38 void 36 39 view_close_cb (GtkWidget * widget, gpointer data); 37 40 … … 43 46 44 47 void 48 view_set_tool_cb (GtkWidget * widget, gpointer data); 49 50 void 51 repeater_released_cb (GtkWidget * widget, gpointer data); 52 53 void 45 54 zoom_in_cb (GtkWidget * widget, gpointer data); 46 55 … … 49 58 50 59 void 60 zoom_in_pressed_cb (GtkWidget * widget, gpointer data); 61 62 void 63 zoom_out_pressed_cb (GtkWidget * widget, gpointer data); 64 65 void 51 66 zoom_to_sel_cb (GtkWidget * widget, gpointer data); 52 67 … … 70 85 71 86 void 87 zoom_center_cb (GtkWidget * widget, gpointer data); 88 89 void 90 zoom_combo_changed_cb (GtkWidget * widget, gpointer data); 91 92 void 93 sample_set_color_cb (GtkWidget * widget, gpointer data); 94 95 void 96 device_config_cb (GtkWidget * widget, gpointer data); 97 98 void 99 follow_toggled_cb (GtkWidget * widget, gpointer data); 100 101 void 102 follow_toggle_cb (GtkWidget * widget, gpointer data); 103 104 void 105 loop_toggled_cb (GtkWidget * widget, gpointer data); 106 107 void 108 loop_toggle_cb (GtkWidget * widget, gpointer data); 109 110 void 111 playrev_toggled_cb (GtkWidget * widget, gpointer data); 112 113 void 114 playrev_toggle_cb (GtkWidget * widget, gpointer data); 115 116 void 117 mute_toggled_cb (GtkWidget * widget, gpointer data); 118 119 void 120 mute_toggle_cb (GtkWidget * widget, gpointer data); 121 122 void 123 monitor_toggled_cb (GtkWidget * widget, gpointer data); 124 125 void 126 monitor_toggle_cb (GtkWidget * widget, gpointer data); 127 128 void 129 play_view_button_cb (GtkWidget * widget, gpointer data); 130 131 void 132 play_view_sel_button_cb (GtkWidget * widget, gpointer data); 133 134 void 72 135 play_view_cb (GtkWidget * widget, gpointer data); 73 136 74 137 void 138 play_view_all_once_cb (GtkWidget * widget, gpointer data); 139 140 void 75 141 play_view_all_loop_cb (GtkWidget * widget, gpointer data); 76 142 … … 79 145 80 146 void 147 play_view_sel_once_cb (GtkWidget * widget, gpointer data); 148 149 void 81 150 play_view_sel_loop_cb (GtkWidget * widget, gpointer data); 82 151 83 152 void 153 pause_playback_cb (GtkWidget * widget, gpointer data); 154 155 void 84 156 stop_playback_cb (GtkWidget * widget, gpointer data); 85 157 86 158 void 159 preview_cut_cb (GtkWidget * widget, gpointer data); 160 161 void 162 preroll_cb (GtkWidget * widget, gpointer data); 163 164 void 165 show_rec_dialog_cb (GtkWidget * widget, gpointer data); 166 167 void 168 page_back_cb (GtkWidget * widget, gpointer data); 169 170 void 171 page_fwd_cb (GtkWidget * widget, gpointer data); 172 173 void 174 rewind_pressed_cb (GtkWidget * widget, gpointer data); 175 176 void 177 ffwd_pressed_cb (GtkWidget * widget, gpointer data); 178 179 void 180 goto_start_cb (GtkWidget * widget, gpointer data); 181 182 void 183 goto_start_of_view_cb (GtkWidget * widget, gpointer data); 184 185 void 186 goto_end_of_view_cb (GtkWidget * widget, gpointer data); 187 188 void 189 goto_end_cb (GtkWidget * widget, gpointer data); 190 191 void 87 192 sd_sel_changed_cb (GtkWidget * widget); 88 193 … … 94 199 95 200 void 201 adj_value_changed_cb (GtkWidget * widget, gpointer data); 202 203 void 96 204 select_invert_cb (GtkWidget * widget, gpointer data); 97 205 … … 103 211 104 212 void 213 selection_halve_cb (GtkWidget * widget, gpointer data); 214 215 void 216 selection_double_cb (GtkWidget * widget, gpointer data); 217 218 void 219 select_shift_left_cb (GtkWidget * widget, gpointer data); 220 221 void 222 select_shift_right_cb (GtkWidget * widget, gpointer data); 223 224 void 225 show_undo_dialog_cb (GtkWidget * widget, gpointer data); 226 227 void 105 228 undo_cb (GtkWidget * widget, gpointer data); 106 229 … … 109 232 110 233 void 234 cancel_cb (GtkWidget * widget, gpointer data); 235 236 void 111 237 copy_cb (GtkWidget * widget, gpointer data); 112 238 … … 121 247 122 248 void 249 crop_cb (GtkWidget * widget, gpointer data); 250 251 void 123 252 paste_cb (GtkWidget * widget, gpointer data); 124 253 125 254 void 255 paste_mix_cb (GtkWidget * widget, gpointer data); 256 257 void 258 paste_xfade_cb (GtkWidget * widget, gpointer data); 259 260 void 126 261 paste_as_new_cb (GtkWidget * widget, gpointer data); 127 262 … … 132 267 normalise_cb (GtkWidget * widget, gpointer data); 133 268 269 void 270 show_info_dialog_cb (GtkWidget * widget, gpointer data); 271 134 272 #endif /* __CALLBACKS_H__ */ trunk/sweep/src/cursors.c
r7 r124 19 19 */ 20 20 21 #ifdef HAVE_CONFIG_H 22 # include <config.h> 23 #endif 24 21 25 #include <stdio.h> 22 26 #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 44 GdkCursor * sweep_cursors[SWEEP_CURSOR_MAX]; 45 23 46 24 47 void … … 64 87 *mask = gdk_bitmap_create_from_data (NULL, mask_buffer, 32, 32); 65 88 } 89 90 void 91 init_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 22 22 #define __CURSORS_H__ 23 23 24 enum { 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 24 38 void 25 39 create_bitmap_and_mask_from_xpm (GdkBitmap ** bitmap, … … 27 41 gchar ** xpm); 28 42 43 void 44 init_cursors (void); 45 29 46 #endif trunk/sweep/src/driver.c
r106 r124 35 35 #include <pthread.h> 36 36 37 #include <gtk/gtk.h> 38 #include <sweep/sweep_i18n.h> 39 37 40 #include <sweep/sweep_types.h> 38 41 #include <sweep/sweep_sample.h> … … 40 43 #include "driver.h" 41 44 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; 45 extern sw_driver * driver_alsa; 46 extern sw_driver * driver_oss; 47 extern sw_driver * driver_solaris; 48 49 extern GMutex * play_mutex; 50 51 /* preferred driver */ 52 static sw_driver _driver_null = { 53 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL 54 }; 55 56 static sw_driver * pref = &_driver_null; 57 58 #include "preferences.h" 59 #include "pcmio.h" 60 61 char * 62 pcmio_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; 90 71 } 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 (¶ms, 0, sizeof(params)); 199 memset (¶ms_info, 0, sizeof(params_info)); 200 201 if (snd_pcm_params_info (pcm_handle, ¶ms_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, ¶ms)) < 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 76 char * 77 pcmio_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; 566 87 } 567 88 } 568 89 569 reset_dev_dsp (); 570 571 close_dev_dsp (); 90 return NULL; 91 } 92 93 char * 94 pcmio_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 105 char * 106 pcmio_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 117 gboolean 118 pcmio_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 128 int 129 pcmio_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 139 extern GtkStyle * style_bw; 140 static GtkWidget * dialog = NULL; 141 static GtkWidget * main_combo; 142 static GtkWidget * monitor_combo; 143 static GtkObject * adj; 144 145 146 static gboolean 147 monitor_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 157 static void 158 config_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 186 static void 187 config_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 195 static void 196 update_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 220 static void 221 set_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 237 static void 238 set_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 246 static void 247 pcmio_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 266 static void 267 pcmio_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 283 static void 284 pcmio_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 302 static void 303 monitor_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 313 static void 314 pcmio_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 321 static void 322 pcmio_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 329 static GtkWidget * 330 create_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; 572 343 } 573 344 574 345 void 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); 346 device_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); 584 641 } 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 658 sw_handle * 659 device_open (int cueing, int flags) 660 { 661 if (pref->open) 662 return pref->open (cueing, flags); 663 else 664 return NULL; 612 665 } 613 666 614 667 void 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 } 668 device_setup (sw_handle * handle, sw_format * format) 669 { 670 if (pref->setup) 671 pref->setup (handle, format); 672 } 673 674 int 675 device_wait (sw_handle * handle) 676 { 677 if (pref->wait) 678 return pref->wait (handle); 679 else 680 return 0; 681 } 682 683 ssize_t 684 device_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 692 ssize_t 693 device_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 706 sw_framecount_t 707 device_offset (sw_handle * handle) 708 { 709 if (pref->offset) 710 return pref->offset (handle); 711 else 712 return -1; 631 713 } 632 714 633 715 void 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); 716 device_reset (sw_handle * handle) 717 { 718 if (pref->reset) 719 pref->reset (handle); 643 720 } 644 721 645 722 void 646 sample_stop_playback (sw_sample * sample) 647 { 648 if (playing == sample) stop_playback(); 649 } 723 device_flush (sw_handle * handle) 724 { 725 if (pref->flush) 726 pref->flush (handle); 727 } 728 729 void 730 device_drain (sw_handle * handle) 731 { 732 if (pref->drain) 733 pref->drain (handle); 734 } 735 736 void 737 device_close (sw_handle * handle) 738 { 739 if (pref->close) 740 pref->close (handle); 741 742 handle->driver_fd = -1; 743 } 744 745 void 746 init_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 19 19 */ 20 20 21 #ifndef __DRIVER_OSS_H__ 22 #define __DRIVER_OSS_H__ 21 #ifndef __DRIVER_H__ 22 #define __DRIVER_H__ 23 24 #include <unistd.h> 23 25 24 26 #include "sweep_app.h" 25 27 26 void 27 play_view_all (sw_view * view); 28 #define PBUF_SIZE 256 29 30 typedef struct _sw_handle sw_handle; 31 typedef struct _sw_driver sw_driver; 32 33 struct _sw_handle { 34 int driver_flags; 35 int driver_fd; 36 int driver_channels; 37 int driver_rate; 38 void * custom_data; 39 }; 40 41 struct _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 }; 28 55 29 56 void 30 play_view_all_loop (sw_view * view); 57 device_config (void); 58 59 sw_handle * 60 device_open (int cueing, int flags); 31 61 32 62 void 33 play_view_sel (sw_view * view); 63 device_setup (sw_handle * handle, sw_format * format); 64 65 int 66 device_wait (sw_handle * handle); 67 68 /* 69 * For recording, ie. reading pcm data from the device. 70 */ 71 ssize_t 72 device_read (sw_handle * handle, sw_audio_t * buf, size_t count); 73 74 ssize_t 75 device_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 */ 95 sw_framecount_t 96 device_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 */ 104 void 105 device_reset (sw_handle * handle); 34 106 35 107 void 36 play_view_sel_loop (sw_view * view); 108 device_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 */ 114 void 115 device_drain (sw_handle * handle); 37 116 38 117 void 39 play_view_all_pitch (sw_view * view, gfloat pitch);118 device_close (sw_handle * handle); 40 119 41 120 void 42 stop_playback(void);121 init_devices (void); 43 122 44 123 void 45 s ample_stop_playback (sw_sample * sample);124 stop_playback (sw_sample * s) ; 46 125 47 #endif /* __DRIVER_ OSS_H__ */126 #endif /* __DRIVER_H__ */ trunk/sweep/src/edit.c
r57 r124 19 19 */ 20 20 21 #ifdef HAVE_CONFIG_H 22 # include <config.h> 23 #endif 24 21 25 #include <stdio.h> 22 26 #include <string.h> 23 27 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> 24 35 #include <sweep/sweep_types.h> 25 36 #include <sweep/sweep_typeconvert.h> … … 27 38 #include <sweep/sweep_sounddata.h> 28 39 #include <sweep/sweep_sample.h> 29 40 #include <sweep/sweep_selection.h> 41 42 #include "sweep_app.h" 30 43 #include "edit.h" 31 44 #include "format.h" … … 34 47 sw_edit_buffer * ebuf = NULL; 35 48 49 void * 50 sweep_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 91 void * 92 sweep_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 130 void 131 sweep_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 36 141 static sw_edit_region * 37 edit_region_new (sw_format * format, sw_framecount_t start, sw_framecount_t end, gpointer data) 142 edit_region_new (sw_format * format, sw_framecount_t start, 143 sw_framecount_t end, gpointer data) 38 144 { 39 145 sw_edit_region * er; … … 46 152 47 153 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); 51 155 52 156 return er; … … 54 158 55 159 static sw_edit_region * 56 edit_region_new0 (sw_format * format, sw_framecount_t start, sw_framecount_t end, gpointer data0) 160 edit_region_new0 (sw_format * format, sw_framecount_t start, 161 sw_framecount_t end, gpointer data0) 57 162 { 58 163 sw_framecount_t offset; … … 83 188 eb->format = format_copy (format); 84 189 eb->regions = NULL; 190 eb->refcount = 1; 85 191 86 192 return eb; … … 107 213 } 108 214 215 sw_edit_buffer * 216 edit_buffer_ref (sw_edit_buffer * eb) 217 { 218 eb->refcount++; 219 return eb; 220 } 221 109 222 static void 110 223 edit_buffer_clear (sw_edit_buffer * eb) … … 112 225 GList * gl; 113 226 sw_edit_region * er; 227 size_t len; 114 228 115 229 if (!eb) return; 116 117 g_free (eb->format);118 230 119 231 for (gl = eb->regions; gl; gl = gl->next) { 120 232 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 } 122 237 } 123 238 g_list_free (eb->regions); 239 240 g_free (eb->format); 124 241 125 242 eb->format = NULL; 126 243 eb->regions = NULL; 244 eb->refcount = 0; 127 245 } 128 246 … … 130 248 edit_buffer_destroy (sw_edit_buffer * eb) 131 249 { 250 eb->refcount--; 251 if (eb->refcount > 0) return; 252 132 253 edit_buffer_clear (eb); 133 254 g_free (eb); … … 139 260 if (!ebuf) return; 140 261 141 edit_buffer_ clear(ebuf);142 g_free (ebuf); 262 edit_buffer_destroy (ebuf); 263 143 264 ebuf = NULL; 144 265 } 145 266 146 static gint267 static sw_framecount_t 147 268 edit_buffer_length (sw_edit_buffer * eb) 148 269 { 149 270 GList * gl; 150 271 sw_edit_region * er; 151 gint length = 0;272 sw_framecount_t length = 0; 152 273 153 274 for (gl = eb->regions; gl; gl = gl->next) { … … 160 281 } 161 282 283 static sw_framecount_t 284 edit_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 303 sw_framecount_t 304 clipboard_width (void) 305 { 306 return edit_buffer_width (ebuf); 307 } 308 162 309 static sw_edit_buffer * 163 edit_buffer_from_sounddata (sw_sounddata * sounddata)310 edit_buffer_from_sounddata_sels (sw_sounddata * sounddata, GList * sels) 164 311 { 165 312 sw_edit_buffer * eb; … … 170 317 eb = edit_buffer_new (sounddata->format); 171 318 172 for (gl = s ounddata->sels; gl; gl = gl->next) {319 for (gl = sels; gl; gl = gl->next) { 173 320 sel = (sw_sel *)gl->data; 174 321 … … 187 334 } 188 335 336 static sw_edit_buffer * 337 edit_buffer_from_sounddata (sw_sounddata * sounddata) 338 { 339 return edit_buffer_from_sounddata_sels (sounddata, sounddata->sels); 340 } 341 189 342 sw_edit_buffer * 190 343 edit_buffer_from_sample (sw_sample * sample) 191 344 { 192 345 return edit_buffer_from_sounddata (sample->sounddata); 346 } 347 348 static GList * 349 sels_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; 193 369 } 194 370 … … 207 383 if (!gl) return NULL; 208 384 209 start = ((sw_edit_region *)gl->data)->start; 385 er = (sw_edit_region *)gl->data; 386 start = er->start; 210 387 211 388 for (; gl->next; gl = gl->next); … … 213 390 length = er->end - start; 214 391 215 s = sample_new_empty (NULL, "Untitled",392 s = sample_new_empty (NULL, 216 393 eb->format->channels, 217 394 eb->format->rate, … … 227 404 memcpy ((gpointer)(s->sounddata->data + offset), er->data, len); 228 405 406 sounddata_add_selection_1 (s->sounddata, er->start - start, 407 er->end - start); 408 229 409 #ifdef DEBUG 230 410 printf("Adding sample region [%ld - %ld]\n", er->start, er->end); … … 235 415 } 236 416 237 /* returns new sounddata */ 238 sw_sounddata * 239 splice_out_sel (sw_sounddata * sounddata) 240 { 417 static void 418 head_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 434 static void 435 head_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 450 static void 451 head_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 */ 468 sw_sample * 469 splice_out_sel (sw_sample * sample) 470 { 471 sw_sounddata * sounddata = sample->sounddata; 241 472 sw_format * f = sounddata->format; 242 473 gint length; 243 474 GList * gl; 244 475 sw_sel * osel, * sel; 245 sw_sounddata * out;476 /*sw_sounddata * out;*/ 246 477 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; 248 480 249 481 if (!sounddata->sels) { 250 482 printf ("Nothing to splice out.\n"); 251 return s ounddata;483 return sample; 252 484 } 253 485 254 486 length = sounddata->nr_frames - sounddata_selection_nr_frames (sounddata); 487 run_length = 0; 255 488 256 489 #ifdef DEBUG … … 258 491 #endif 259 492 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); 263 502 264 503 gl = sounddata->sels; 265 504 sel = osel = (sw_sel *)gl->data; 266 505 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); 269 523 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) { 274 529 sel = (sw_sel *)gl->data; 275 530 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 276 554 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); 279 559 d += len; 280 560 561 run_length += move_length; 562 sample_set_progress_percent (sample, run_length / (length/100)); 563 281 564 osel = sel; 282 565 } 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); 283 577 284 578 if (sel->sel_end != sounddata->nr_frames) { 285 579 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; 295 601 } 296 602 … … 316 622 317 623 /* returns new sounddata */ 318 sw_sounddata * 319 splice_in_eb (sw_sounddata * sounddata, sw_edit_buffer * eb) 320 { 624 static sw_sample * 625 splice_in_eb_data (sw_sample * sample, sw_edit_buffer * eb) 626 { 627 sw_sounddata * sounddata = sample->sounddata; 321 628 sw_format * f = sounddata->format; 322 629 gint length; 323 630 GList * gl; 324 631 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; 327 634 gpointer di, d; 328 635 sw_framecount_t len; 329 636 330 637 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 */ 708 sw_sample * 709 splice_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 */ 718 static sw_sounddata * 719 crop_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) { 331 730 return sounddata; 332 731 } 333 732 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 801 sw_sample * 802 crop_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; 341 811 342 812 gl = eb->regions; 343 813 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; 378 839 } 379 840 380 841 /* Modifies sounddata */ 381 static sw_sounddata * 382 edit_clear_sel (sw_sounddata * sounddata) 383 { 842 static void 843 edit_clear_sel (sw_sample * sample) 844 { 845 sw_sounddata * sounddata = sample->sounddata; 384 846 sw_format * f = sounddata->format; 385 847 GList * gl; 386 848 sw_sel * sel; 387 849 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 */ 880 sw_sample * 881 crop_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) { 390 982 sel = (sw_sel *)gl->data; 391 983 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 */ 999 static sw_sample * 1000 paste_insert (sw_sample * sample, sw_edit_buffer * eb, 1001 sw_framecount_t paste_offset) 1002 { 1003 sw_sounddata * sounddata = sample->sounddata; 405 1004 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; 409 1007 GList * gl; 410 1008 sw_edit_region * er; 411 1009 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); 418 1012 419 1013 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) { 433 1030 er = (sw_edit_region *)gl->data; 434 1031 435 1032 len = frames_to_bytes (f, er->end - er->start); 1033 sel_length += (er->end - er->start); 1034 1035 d -= len; 436 1036 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; 453 1073 } 454 1074 … … 480 1100 } 481 1101 1102 /* Modifies sample */ 1103 static sw_sample * 1104 paste_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 */ 1181 static sw_sample * 1182 paste_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 1276 static void 1277 do_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 } 482 1293 483 1294 /* No undo for copy -- is input only */ 1295 static 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 484 1305 void 485 1306 do_copy (sw_sample * sample) 486 1307 { 1308 schedule_operation (sample, _("Copy"), ©_op, NULL); 1309 } 1310 1311 1312 static void 1313 do_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 487 1328 ebuf_clear (); 488 1329 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")); 490 1343 } 491 1344 492 1345 static sw_operation cut_op = { 493 /* OP_FILTER,*/ 494 /* {(SweepFilter *)do_cut},*/ 1346 SWEEP_EDIT_MODE_ALLOC, 1347 (SweepCallback)do_cut_thread, 1348 (SweepFunction)NULL, 495 1349 (SweepCallback)undo_by_splice_in, 496 1350 (SweepFunction)splice_data_destroy, … … 499 1353 }; 500 1354 501 sw_op_instance * 1355 void 502 1356 do_cut (sw_sample * sample) 503 1357 { 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 1361 static void 1362 do_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")); 527 1389 } 528 1390 529 1391 static sw_operation clear_op = { 1392 SWEEP_EDIT_MODE_FILTER, 1393 (SweepCallback)do_clear_thread, 1394 (SweepFunction)NULL, 530 1395 (SweepCallback)undo_by_paste_over, 531 1396 (SweepFunction)paste_over_data_destroy, … … 534 1399 }; 535 1400 536 sw_op_instance * 1401 void 537 1402 do_clear (sw_sample * sample) 538 1403 { 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 1407 static void 1408 do_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")); 556 1431 } 557 1432 558 1433 static sw_operation delete_op = { 1434 SWEEP_EDIT_MODE_ALLOC, 1435 (SweepCallback)do_delete_thread, 1436 (SweepFunction)NULL, 559 1437 (SweepCallback)undo_by_splice_in, 560 1438 (SweepFunction)splice_data_destroy, … … 563 1441 }; 564 1442 565 sw_op_instance * 1443 1444 void 566 1445 do_delete (sw_sample * sample) 567 1446 { 568 sw_sounddata * out; 569 sw_op_instance * inst; 1447 schedule_operation (sample, _("Delete"), &delete_op, NULL); 1448 } 1449 1450 static void 1451 do_crop_thread (sw_op_instance * inst) 1452 { 1453 sw_sample * sample = inst->sample; 1454 GList * sels; 570 1455 sw_edit_buffer * eb; 571 1456 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 1485 static 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 1495 void 1496 do_crop (sw_sample * sample) 1497 { 1498 schedule_operation (sample, _("Crop"), &crop_op, NULL); 1499 } 1500 1501 #if 0 590 1502 static sw_operation paste_in_op = { 1503 SWEEP_EDIT_MODE_ALLOC, 1504 (SweepCallback)do_paste_in, 1505 (SweepFunction)NULL, 591 1506 (SweepCallback)undo_by_splice_out, 592 1507 (SweepFunction)splice_data_destroy, … … 595 1510 }; 596 1511 1512 /* XXX: why is this **out ?? */ 597 1513 sw_op_instance * 598 1514 do_paste_in (sw_sample * in, sw_sample ** out) … … 601 1517 sw_edit_buffer * eb; 602 1518 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); 605 1524 606 1525 (*out)->sounddata = splice_in_eb (in->sounddata, ebuf); 607 1526 608 1527 inst->redo_data = inst->undo_data = 609 splice_data_new (eb );1528 splice_data_new (eb, NULL); 610 1529 611 1530 sample_refresh_views (*out); … … 613 1532 return inst; 614 1533 } 615 616 static sw_operation paste_at_op = { 1534 #endif 1535 1536 static void 1537 do_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 1576 static sw_operation paste_insert_op = { 1577 SWEEP_EDIT_MODE_ALLOC, 1578 (SweepCallback)do_paste_insert_thread, 1579 (SweepFunction)NULL, 617 1580 (SweepCallback)undo_by_splice_out, 618 1581 (SweepFunction)splice_data_destroy, … … 621 1584 }; 622 1585 623 sw_op_instance * 624 do_paste_at (sw_sample * sample) 625 { 1586 1587 void 1588 do_paste_insert (sw_sample * sample) 1589 { 1590 schedule_operation (sample, _("Paste insert"), &paste_insert_op, NULL); 1591 } 1592 1593 typedef struct { 1594 gdouble src_gain; 1595 gdouble dest_gain; 1596 } paste_mix_op_data; 1597 1598 static void 1599 do_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; 626 1603 sw_sounddata * out; 627 sw_op_instance * inst;1604 GList * old_sels, * sels; 628 1605 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 1650 static 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 1660 void 1661 do_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 1672 typedef 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 1679 static void 1680 do_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 1734 static 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 1744 void 1745 do_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 649 1761 static sw_operation paste_over_op = { 1762 SWEEP_EDIT_MODE_FILTER, 1763 (SweepCallback)NULL, 1764 (SweepFunction)NULL, 650 1765 (SweepCallback)undo_by_paste_over, 651 1766 (SweepFunction)paste_over_data_destroy, … … 660 1775 sw_edit_buffer * old_eb, * new_eb; 661 1776 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); 663 1780 old_eb = edit_buffer_from_sample (in); 664 1781 … … 673 1790 return inst; 674 1791 } 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 1794 sw_sample * 1795 do_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 24 24 #include <sweep/sweep_types.h> 25 25 26 void * 27 sweep_large_alloc_zero (size_t len, int prot); 28 29 void * 30 sweep_large_alloc_data (size_t len, void * data, int prot); 31 32 33 sw_framecount_t 34 clipboard_width (void); 35 36 sw_edit_buffer * 37 edit_buffer_ref (sw_edit_buffer * eb); 38 26 39 sw_edit_buffer * 27 40 edit_buffer_from_sample (sw_sample * sample); … … 30 43 edit_buffer_destroy (sw_edit_buffer * eb); 31 44 32 sw_s ounddata*33 splice_out_sel (sw_s ounddata * sounddata);45 sw_sample * 46 splice_out_sel (sw_sample * sample); 34 47 35 sw_sounddata * 36 splice_in_eb (sw_sounddata * sounddata, sw_edit_buffer * eb); 48 sw_sample * 49 splice_in_eb (sw_sample * sample, sw_edit_buffer * eb); 50 51 sw_sample * 52 crop_out (sw_sample * sample); 53 54 sw_sample * 55 crop_in (sw_sample * sample, sw_edit_buffer * eb); 37 56 38 57 sw_sample * … … 42 61 do_copy (sw_sample * sample); 43 62 44 sw_op_instance * 63 void 45 64 do_cut (sw_sample * sample); 46 65 47 sw_op_instance * 66 void 48 67 do_clear (sw_sample * sample); 49 68 50 sw_op_instance * 69 void 51 70 do_delete (sw_sample * sample); 71 72 void 73 do_crop (sw_sample * sample); 52 74 53 75 sw_op_instance * 54 76 do_paste_in (sw_sample * in, sw_sample ** out); 55 77 56 sw_op_instance * 57 do_paste_at (sw_sample * sample); 78 void 79 do_paste_insert (sw_sample * sample); 80 81 void 82 do_paste_mix (sw_sample * sample, gdouble src_gain, gdouble dest_gain); 83 84 void 85 do_paste_xfade (sw_sample * sample, gdouble src_gain_start, 86 gdouble src_gain_end, gdouble dest_gain_start, 87 gdouble dest_gain_end); 58 88 59 89 sw_op_instance * 60 90 do_paste_over (sw_sample * in, sw_sample ** out); 61 91 92 #if 0 62 93 void 63 94 do_paste_as_new (sw_sample * in, sw_sample ** out); 64 95 96 #else 97 98 sw_sample * 99 do_paste_as_new (void); 100 101 #endif 102 65 103 #endif /* __EDIT_H__ */ trunk/sweep/src/file_dialogs.c
r121 r124 19 19 */ 20 20 21 #ifdef HAVE_CONFIG_H 22 # include <config.h> 23 #endif 24 21 25 #include <stdio.h> 22 26 #include <string.h> 27 #include <sys/types.h> 28 #include <sys/stat.h> 23 29 #include <unistd.h> 30 #include <errno.h> 31 32 #include <gdk/gdkkeysyms.h> 24 33 #include <gtk/gtk.h> 34 35 #include <sndfile.h> 25 36 26 37 #include <sweep/sweep_types.h> 27 38 #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" 30 43 #include "sample.h" 31 44 #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 52 extern sw_sample * vorbis_sample_reload (sw_sample * sample); 53 extern sw_sample * vorbis_sample_load (char * pathname); 54 extern int vorbis_save_options_dialog (sw_sample * sample, char * pathname); 55 #endif 56 57 #ifdef HAVE_SPEEX 58 extern sw_sample * speex_sample_reload (sw_sample * sample); 59 extern sw_sample * speex_sample_load (char * pathname); 60 extern int speex_save_options_dialog (sw_sample * sample, char * pathname); 61 #endif 62 63 #ifdef HAVE_MAD 64 extern sw_sample * mad_sample_reload (sw_sample * sample); 65 extern sw_sample * mad_sample_load (char * pathname); 66 #endif 67 68 void 69 mp3_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 83 typedef struct { 84 sw_file_format_t file_format; 85 gchar * name; 86 gchar * exts; /* comma separated extensions */ 87 } sw_file_format_desc; 88 89 void 90 file_guess_method (sw_sample * sample, char * pathname); 91 92 #if ! (defined (SNDFILE_1)) 93 94 static 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 139 static gboolean 140 sweep_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 170 static gboolean 171 file_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 186 sw_sample * 187 sample_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 214 static sw_sample * 215 try_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 242 sw_sample * 243 sample_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 268 static void 269 sample_load_destroy_cb (GtkWidget * widget, gpointer data) 270 { 271 sample_bank_remove (NULL); 272 } 35 273 36 274 static void 37 275 sample_load_ok_cb(GtkWidget * widget, gpointer data) 38 276 { 39 sw_sample * s;40 sw_view * v;41 277 gchar *dir; 42 278 43 279 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); 53 282 54 283 gtk_widget_destroy(GTK_WIDGET(data)); … … 62 291 63 292 void 64 sample_load_cb(GtkWidget * wi get, gpointer data)293 sample_load_cb(GtkWidget * widget, gpointer data) 65 294 { 66 295 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 69 318 if(load_current_file) { 70 319 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), 71 320 load_current_file); 321 free (load_current_file); 72 322 } 73 323 … … 81 331 } 82 332 333 gboolean 334 sample_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 349 void 350 sample_revert_ok_cb (GtkWidget * widget, gpointer data) 351 { 352 sw_sample * sample = (sw_sample *)data; 353 354 sample_reload (sample); 355 } 356 83 357 void 84 358 sample_revert_cb (GtkWidget * widget, gpointer data) 85 359 { 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 379 void 380 sample_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 391 void 392 file_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 497 typedef struct { 498 sw_sample * sample; 499 char * pathname; 500 } save_as_data; 501 502 static void 503 overwrite_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 538 static void 539 overwrite_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); 104 549 } 105 550 … … 107 552 sample_save_as_ok_cb(GtkWidget * widget, gpointer data) 108 553 { 109 SampleDisplay * s = SAMPLE_DISPLAY(data);554 sw_view * view = (sw_view *)data; 110 555 sw_sample * sample; 111 556 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; 115 567 filesel = gtk_widget_get_toplevel (widget); 116 568 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 } 125 591 } 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 } 133 604 134 605 gtk_widget_destroy(GTK_WIDGET(filesel)); … … 141 612 } 142 613 614 static void 615 file_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 626 static GtkWidget * 627 create_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 143 739 void 144 740 sample_save_as_cb(GtkWidget * widget, gpointer data) 145 741 { 146 SampleDisplay * s = SAMPLE_DISPLAY(data);742 sw_view * view = (sw_view *)data; 147 743 sw_sample * sample; 148 744 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 156 775 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); 158 816 159 817 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), … … 166 824 } 167 825 826 static void 827 sample_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 168 859 void 169 sample_save_cb (GtkWidget * widget, gpointer data)170 { 171 SampleDisplay * s = SAMPLE_DISPLAY(data);860 sample_save_cb (GtkWidget * widget, gpointer data) 861 { 862 sw_view * view = (sw_view *)data; 172 863 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) { 177 872 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); 178 883 } else { 179 sample_save (sample);180 } 181 } 884 sample_save_ok_cb (widget, view); 885 } 886 } trunk/sweep/src/file_dialogs.h
r7 r124 22 22 #define __FILE_DIALOGS_H__ 23 23 24 #include <sweep/sweep_types.h> 25 26 void 27 mp3_unsupported_dialog (void); 28 29 sw_file_format_t 30 guess_file_format (gchar * pathname); 31 32 gboolean 33 sample_mtime_changed (sw_sample * sample); 34 35 sw_sample * 36 sample_load(char * pathname); 37 24 38 void 25 39 sample_load_cb(GtkWidget * wiget, gpointer data); 40 41 void 42 sample_revert_ok_cb (GtkWidget * widget, gpointer data); 26 43 27 44 void … … 34 51 sample_save_cb(GtkWidget * wiget, gpointer data); 35 52 53 void 54 sample_store_and_free_pathname (sw_sample * sample, gchar * pathname); 55 36 56 #endif /* __FILE_DIALOGS_H__ */ trunk/sweep/src/format.c
r57 r124 18 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 19 */ 20 21 #ifdef HAVE_CONFIG_H 22 # include <config.h> 23 #endif 20 24 21 25 #include <sweep/sweep_types.h> trunk/sweep/src/interface.c
r57 r124 35 35 #include "sweep_app.h" 36 36 37 #include "driver.h" 37 38 #include "callbacks.h" 38 39 #include "file_dialogs.h" … … 41 42 #include "pixmaps.h" 42 43 43 static void 44 main_destroy_cb (GtkWidget * widget, gpointer data) 45 { 46 gtk_main_quit(); 47 } 44 GtkStyle * style_wb; 45 GtkStyle * style_bw; 46 GtkStyle * style_LCD; 47 GtkStyle * style_light_grey; 48 GtkStyle * style_green_grey; 49 GtkStyle * style_red_grey; 50 GtkStyle * style_dark_grey; 51 GtkStyle * style_red; 48 52 49 53 GtkWidget * … … 64 68 return gtk_pixmap_new (pixmap_data, mask); 65 69 } 70 71 /* 72 * create_color (r, g, b) 73 * 74 * Ripped from grip, Copyright (c) 1998-2002 Mike Oliphant 75 */ 76 GdkColor * 77 create_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 91 static 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 */ 98 GtkStyle * 99 create_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 123 void 124 init_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 167 GtkWidget * 168 create_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 227 static void 228 main_destroy_cb (GtkWidget * widget, gpointer data) 229 { 230 gtk_main_quit(); 231 } 232 66 233 67 234 GtkWidget* … … 74 241 GtkWidget *handlebox1; 75 242 GtkWidget *toolbar1; 76 GtkWidget *button1, /* *button2,*/ *button3;243 GtkWidget *button1, * button; 77 244 GtkWidget *pixmap1, *pixmap3; 78 245 GtkWidget *menu; … … 114 281 gtk_menu_append (GTK_MENU(menu), menuitem); 115 282 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); 117 284 gtk_widget_show(menuitem); 118 285 gtk_widget_add_accelerator (menuitem, "activate", accel_group, … … 151 318 gtk_widget_show(menuitem); 152 319 153 320 #if 0 154 321 handlebox1 = gtk_handle_box_new (); 155 322 gtk_widget_show (handlebox1); … … 159 326 gtk_widget_show (toolbar1); 160 327 gtk_container_add (GTK_CONTAINER (handlebox1), toolbar1); 328 329 /* SELECT */ 161 330 162 331 pixmap1 = create_widget_from_xpm (toolbar1, rect_xpm); … … 180 349 181 350 #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 */ 185 356 _("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 */ 193 382 194 383 pixmap3 = create_widget_from_xpm (window1, magnify_xpm); 195 384 gtk_widget_show (pixmap3); 196 385 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 */ 210 429 211 430 return window1; 212 431 } 213 432 433 #endif trunk/sweep/src/interface.h
r7 r124 22 22 #define __INTERFACE_H__ 23 23 24 #include "sweep_app.h" 25 24 26 GtkWidget * 25 27 create_widget_from_xpm (GtkWidget * widget, gchar **xpm_data); 28 29 GdkColor * 30 create_color (int red, int green, int blue); 31 32 GtkStyle * 33 create_style (GdkColor * fg, GdkColor * bg, gboolean do_grade); 34 35 void 36 init_styles (void); 37 38 GtkWidget * 39 create_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); 26 45 27 46 GtkWidget* create_toolbox (void); trunk/sweep/src/main.c
r111 r124 25 25 26 26 #include <stdlib.h> 27 #include <string.h> 28 #include <time.h> 29 27 30 #include <glib.h> 28 31 #include <gtk/gtk.h> … … 30 33 #include <sweep/sweep_version.h> 31 34 #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" 34 39 #include "interface.h" 35 40 #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 47 extern void sweep_timeouts_init (void); 36 48 37 49 /* … … 49 61 { 50 62 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 } 51 70 52 sample_load _with_view (arg);71 sample_load (pathname); 53 72 54 73 return FALSE; 55 74 } 56 75 76 #if 0 77 static gint 78 initial_sample_new (gpointer data) 79 { 80 sample_new_empty_cb (NULL, NULL); 81 82 return FALSE; 83 } 84 #endif 85 86 static gint 87 initial_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 } 57 99 58 100 /* … … 63 105 { 64 106 int i; 107 #if 0 65 108 GtkWidget *toolbox; 109 #endif 66 110 67 111 gboolean show_version = FALSE; 68 112 gboolean show_help = FALSE; 69 gboolean show_toolbox = TRUE; 113 /* gboolean show_toolbox = TRUE;*/ 114 115 gboolean no_files = TRUE; 70 116 71 117 #ifdef HAVE_PUTENV … … 79 125 80 126 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 81 141 gtk_init (&argc, &argv); 82 142 … … 87 147 88 148 g_thread_init (NULL); 149 150 /* must be done before gtk_idle_add / gtk_timeout_add */ 151 sweep_timeouts_init (); 89 152 90 153 for(i = 1; i < argc; i++) { … … 97 160 show_version = TRUE; 98 161 argv[i] = NULL; 162 #if 0 99 163 } else if (strcmp (argv[i], "--no-toolbox") == 0) { 100 164 show_toolbox = FALSE; 101 165 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 102 172 } else if (argv[i][0] == '-') { 173 /* check for unknown options */ 174 #endif 103 175 show_help = TRUE; 104 176 } else { 105 177 gtk_idle_add ((GtkFunction)initial_sample_load, argv[i]); 178 no_files = FALSE; 106 179 } 107 180 } … … 120 193 g_print (_(" -v --version Output version info.\n")); 121 194 g_print (_(" --display <display> Use the designated X display.\n")); 195 #if 0 122 196 g_print (_(" --no-toolbox Do not show the toolbox window.\n")); 197 #endif 123 198 } 124 199 … … 127 202 } 128 203 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 129 214 /* initialise plugins */ 130 215 init_plugins (); 131 216 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 132 230 if (show_toolbox) { 133 231 toolbox = create_toolbox (); 134 232 gtk_widget_show (toolbox); 135 233 } 234 #endif 136 235 137 236 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 24 24 25 25 #include <stdio.h> 26 #include <stdlib.h> 26 27 #include <string.h> 27 28 28 29 #include <gtk/gtk.h> 30 #include <gdk/gdkkeysyms.h> 29 31 30 32 #include "callbacks.h" 33 34 #include <sweep/sweep_i18n.h> 31 35 32 36 #include <sweep/sweep_types.h> … … 34 38 #include <sweep/sweep_sample.h> 35 39 40 #include "head.h" 36 41 #include "interface.h" 37 42 #include "edit.h" 38 43 #include "sample-display.h" 39 #include " driver.h"44 #include "play.h" 40 45 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" 46 47 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##); \ 48 typedef struct _sw_noteplay sw_noteplay; 49 50 struct _sw_noteplay { 51 char name [5]; 52 float pitch; 53 guint accel_key; 54 }; 55 56 static void play_view_note_cb (GtkWidget * widget, gpointer data); 57 58 static 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 105 void 106 noteplay_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; 55 127 } 56 128 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);129 static void 130 play_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; 69 141 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 } 71 150 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 19 19 */ 20 20 21 #ifndef __NOTES_H__ _21 #ifndef __NOTES_H__ 22 22 #define __NOTES_H__ 23 23 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); 24 void noteplay_setup (GtkWidget *subsubmenu, sw_view * view, GtkAccelGroup *accel_group) ; 72 25 73 26 #endif /* __NOTES_H__ */ trunk/sweep/src/param.c
r108 r124 19 19 */ 20 20 21 #ifdef HAVE_CONFIG_H 22 # include <config.h> 23 #endif 24 21 25 #include <stdio.h> 26 #include <string.h> 27 #include <math.h> 28 22 29 #include <sweep/sweep_i18n.h> 23 30 #include <sweep/sweep_types.h> 24 31 #include "sweep_app.h" 32 #include "interface.h" 33 34 #include "../pixmaps/ladlogo.xpm" 35 36 extern GtkStyle * style_bw; 25 37 26 38 static gint … … 103 115 switch (type) { 104 116 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")); 107 119 break; 108 120 case SWEEP_TYPE_INT: … … 205 217 sw_param_set pset; 206 218 GtkWidget * window; 207 GtkWidget * frame;208 GtkWidget * vbox;219 GtkWidget * scrolled; 220 GtkWidget * table; 209 221 sw_ps_widget * widgets; 210 222 GList * plsk_list; … … 224 236 ps->window = window; 225 237 226 ps-> frame= NULL;227 ps-> vbox= NULL;238 ps->scrolled = NULL; 239 ps->table = NULL; 228 240 229 241 ps->widgets = g_malloc (sizeof (sw_ps_widget) * proc->nr_params); … … 348 360 349 361 static GtkWidget * 350 create_param_set_ vbox(sw_ps_adjuster * ps)362 create_param_set_table (sw_ps_adjuster * ps) 351 363 { 352 364 gint i, j; … … 363 375 gchar buf[BUF_LEN]; 364 376 365 GtkWidget * vbox;377 GtkWidget * table; 366 378 GtkWidget * hbox; 367 379 GtkWidget * label; … … 374 386 GtkObject * adj; 375 387 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++) { 384 393 pspec = &proc->param_specs[i]; 385 394 386 395 if (pspec->type == SWEEP_TYPE_BOOL) { 387 396 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); 390 400 391 401 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), … … 403 413 } else { 404 414 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); 407 422 gtk_widget_show (label); 408 423 … … 410 425 411 426 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); 413 429 gtk_widget_show (optionmenu); 414 430 … … 449 465 #define ADJUSTER_NUMERIC(T, DIGITS) \ 450 466 \ 451 value = (gfloat) pset[i]. ##T##;\467 value = (gfloat) pset[i].T; \ 452 468 \ 453 469 if (pspec->constraint_type == SW_PARAM_CONSTRAINED_NOT) { \ … … 458 474 \ 459 475 if (valid & SW_RANGE_LOWER_BOUND_VALID) { \ 460 lower = (gfloat) pspec->constraint.range->lower. ##T##;\476 lower = (gfloat) pspec->constraint.range->lower.T; \ 461 477 } else { \ 462 478 lower = G_MINFLOAT; \ … … 464 480 \ 465 481 if (valid & SW_RANGE_UPPER_BOUND_VALID) { \ 466 upper = (gfloat) pspec->constraint.range->upper. ##T##;\482 upper = (gfloat) pspec->constraint.range->upper.T; \ 467 483 } else { \ 468 484 upper = G_MAXFLOAT; \ … … 470 486 \ 471 487 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 { \ 474 492 step_inc = (gfloat) 0.01; \ 475 493 } \ 476 494 page_inc = step_inc; \ 477 495 page_size = step_inc; \ 496 if (step_inc < 1.0) \ 497 digits = - (gint)ceil(log10((double)step_inc)); \ 498 else \ 499 digits = 1; \ 478 500 \ 479 501 adj = gtk_adjustment_new (value, lower, upper, step_inc, \ … … 482 504 if ( (valid & SW_RANGE_LOWER_BOUND_VALID) && \ 483 505 (valid & SW_RANGE_UPPER_BOUND_VALID)) { \ 506 GTK_ADJUSTMENT(adj)->upper += step_inc; \ 484 507 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); \ 486 512 } else { \ 487 513 num_widget = gtk_spin_button_new (GTK_ADJUSTMENT(adj), \ … … 493 519 TRUE); \ 494 520 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); \ 496 523 } \ 497 524 \ … … 508 535 } 509 536 510 return vbox; 537 return table; 538 539 #undef BUF_LEN 511 540 } 512 541 … … 519 548 sw_ps_adjuster * ps = (sw_ps_adjuster *)data; 520 549 521 GtkWidget * vbox;550 GtkWidget * table; 522 551 523 552 if (ps->proc->suggest) { … … 526 555 } 527 556 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; 535 565 } 536 566 … … 541 571 sw_ps_adjuster * ps; 542 572 573 GtkStyle * style; 574 543 575 GtkWidget * window; 544 576 GtkWidget * main_vbox; 577 GtkWidget * pixmap; 578 GtkWidget * label; 579 GtkWidget * scrolled; 580 GtkWidget * ebox; 581 GtkWidget * hbox; 545 582 GtkWidget * vbox; 546 GtkWidget * hbox;583 GtkWidget * table; 547 584 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);*/ 552 605 553 606 ps = ps_adjuster_new (proc, view, pset, window); … … 555 608 gtk_signal_connect (GTK_OBJECT(window), "destroy", 556 609 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 558 623 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); 560 625 gtk_widget_show (main_vbox); 561 626 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 562 640 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); 564 643 gtk_widget_show (hbox); 565 644 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); 568 751 gtk_widget_show (button); 569 752 gtk_signal_connect (GTK_OBJECT(button), "clicked", 570 753 GTK_SIGNAL_FUNC (param_set_suggest_cb), ps); 571 754 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); 574 773 gtk_widget_show (frame); 575 774 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); 578 778 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", 591 787 GTK_SIGNAL_FUNC (param_set_apply_cb), ps); 788 592 789 593 790 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); 595 794 gtk_widget_show (button); 596 795 gtk_signal_connect (GTK_OBJECT(button), "clicked", 597 796 GTK_SIGNAL_FUNC (param_set_cancel_cb), ps); 598 797 798 gtk_widget_grab_default (ok_button); 799 599 800 gtk_widget_show (window); 600 801 trunk/sweep/src/pixmaps.h
r7 r124 19 19 */ 20 20 21 21 #if 0 22 22 static char *rect_xpm [] = 23 23 { … … 183 183 " ", 184 184 " "}; 185 #endif trunk/sweep/src/plugin.c
r58 r124 33 33 #include <gmodule.h> 34 34 35 #include <sweep/sweep_i18n.h> 35 36 #include <sweep/sweep_version.h> 36 37 #include <sweep/sweep_types.h> … … 38 39 39 40 GList * plugins = NULL; 41 42 static gint 43 cmp_proc_names (sw_procedure * a, sw_procedure * b) 44 { 45 return strcmp (_(a->name), _(b->name)); 46 } 40 47 41 48 void … … 61 68 for (gl = m_plugin->plugin_init (); 62 69 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); 64 72 } 65 73 } … … 139 147 init_dynamic_plugins (); 140 148 } 149 150 141 151 } trunk/sweep/src/print.c
r57 r124 19 19 */ 20 20 21 #ifdef HAVE_CONFIG_H 22 # include <config.h> 23 #endif 24 21 25 #include <stdio.h> 22 26 #include <string.h> … … 29 33 * using standard abbreviations (GB, MB, kB, byte[s]) 30 34 */ 31 void 35 int 32 36 snprint_bytes (gchar * s, gint n, glong nr_bytes) 33 37 { 34 38 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)); 37 41 } 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)); 40 44 } 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)); 43 47 } else if (nr_bytes == 1) { 44 snprintf (s, n, "1 byte");48 return snprintf (s, n, "1 byte"); 45 49 } else { 46 snprintf (s, n, "%ld bytes", nr_bytes);50 return snprintf (s, n, "%ld bytes", nr_bytes); 47 51 } 48 52 } … … 51 55 * Print a time in the format HH:MM:SS.sss 52 56 */ 53 void 57 int 54 58 snprint_time (gchar * s, gint n, sw_time_t time) 55 59 { … … 66 70 sec = time - ((sw_time_t)hrs * 3600.0)- ((sw_time_t)min * 60.0); 67 71 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 } 69 78 } 70 79 … … 72 81 * Print a time in SMPTE format 73 82 */ 74 void 83 int 75 84 snprint_time_smpte (gchar * s, gint n, sw_time_t time, gint F) 76 85 { … … 86 95 87 96 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); 89 98 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); 91 100 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); 93 102 else if (N > 0.0) 94 snprintf (s, n, "PT%.0fN%dF", N, F);103 return snprintf (s, n, "PT%.0fN%dF", N, F); 95 104 else 96 snprintf (s, n, "P0S");105 return snprintf (s, n, "P0S"); 97 106 } 107 108 double 109 strtime_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 134 done: 135 136 result = ((h * 3600.0) + (m * 60.0) + s); 137 138 return result; 139 } trunk/sweep/src/print.h
r57 r124 28 28 * using standard abbreviations (GB, MB, kB, byte[s]) 29 29 */ 30 void 30 int 31 31 snprint_bytes (gchar * s, gint n, glong nr_bytes); 32 32 … … 34 34 * Print a time in the format HH:MM:SS.sss 35 35 */ 36 void 36 int 37 37 snprint_time (gchar * s, gint n, sw_time_t time); 38 38 … … 40 40 * Print a time in SMPTE format 41 41 */ 42 void 42 int 43 43 snprint_time_smpte (gchar * s, gint n, sw_time_t time, gint F); 44 44 45 /* 46 * Parse a time format string (eg. 1:30:43.34) to a double 47 */ 48 double 49 strtime_to_seconds (char * str); 50 45 51 #endif /* __PRINT_H__ */ trunk/sweep/src/sample-display.c
r98 r124 22 22 */ 23 23 24 #ifdef HAVE_CONFIG_H 25 # include <config.h> 26 #endif 27 24 28 #include <stdlib.h> 29 #include <math.h> 30 #include <time.h> 25 31 26 32 #include "sample-display.h" 27 33 34 #include <gdk/gdkkeysyms.h> 28 35 #include <gtk/gtk.h> 36 37 #include <sweep/sweep_i18n.h> 29 38 30 39 #include "sweep_app.h" 31 40 #include "sample.h" 41 #include "head.h" 32 42 #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 58 extern GdkCursor * sweep_cursors[]; 40 59 41 60 /* Maximum number of samples to consider per pixel */ … … 52 71 53 72 #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) 55 74 56 75 #define SAMPLE_TO_PIXEL(n) \ … … 63 82 64 83 #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 66 111 67 112 #define MARCH_INTERVAL 300 113 #define PULSE_INTERVAL 450 68 114 69 115 extern sw_view * last_tmp_view; … … 74 120 */ 75 121 76 #ifdef _MUSHROOM_BROWN 122 #if 1 123 77 124 static 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 */ 88 141 }; 142 89 143 #else 144 90 145 static 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 */ 100 162 81, 101, 81, /* lowlight */ 163 240, 0, 0, /* rec */ 101 164 }; 102 165 #endif 103 166 167 static 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 182 static 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 }; 104 192 105 193 /* Values for s->selecting */ … … 109 197 SELECTING_SELECTION_END, 110 198 SELECTING_PAN_WINDOW, 199 SELECTING_PLAYMARKER, 200 SELECTING_PENCIL, 201 SELECTING_NOISE, 111 202 }; 112 203 … … 115 206 SELECTION_MODE_REPLACE, 116 207 SELECTION_MODE_INTERSECT, 208 SELECTION_MODE_SUBTRACT, 209 SELECTION_MODE_MAX 117 210 }; 118 119 211 120 212 enum { … … 125 217 }; 126 218 219 static 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 127 226 #define IS_INITIALIZED(s) (s->view != NULL) 128 227 … … 136 235 sample_display_refresh (SampleDisplay *s) 137 236 { 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 261 sw_framecount_t 262 sample_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); 139 270 } 140 271 … … 146 277 147 278 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 151 284 /* gtk_signal_emit(GTK_OBJECT(s), sample_display_signals[SIG_WINDOW_CHANGED], s->view->start, s->view->start + (s->view->end - s->view->start));*/ 152 285 153 #if 0154 s->old_ss = s->old_se = -1;155 #endif156 286 s->selecting = SELECTING_NOTHING; 157 287 s->selection_mode = SELECTION_MODE_NONE; … … 161 291 162 292 void 163 sample_display_set_playmarker (SampleDisplay *s, 164 int offset) 165 { 293 sample_display_refresh_user_marker (SampleDisplay *s) 294 { 295 sw_sample * sample; 296 gint x, width; 297 166 298 g_return_if_fail(s != NULL); 167 299 g_return_if_fail(IS_SAMPLE_DISPLAY(s)); … … 170 302 return; 171 303 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 326 void 327 sample_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 360 void 361 sample_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 396 static void 397 sample_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 459 void 460 sample_display_set_cursor (SampleDisplay * s, GdkCursor * cursor) 461 { 462 gdk_window_set_cursor (GTK_WIDGET(s)->window, cursor); 463 } 464 465 void 466 sample_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 497 static void 498 sample_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 514 static void 515 sample_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 } 178 530 179 531 void … … 189 541 len = s->view->sample->sounddata->nr_frames; 190 542 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 195 547 if (vlen > len) { 548 /* Align to middle if entire length of sample is visible */ 196 549 start = (len - vlen) / 2; 197 550 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); 198 556 } 199 557 200 558 s->view->start = start; 201 559 s->view->end = end; 560 561 sample_display_refresh_user_marker (s); 202 562 203 563 gtk_signal_emit(GTK_OBJECT(s), sample_display_signals[SIG_WINDOW_CHANGED]); … … 320 680 gint attributes_mask; 321 681 SampleDisplay *s; 682 gint i; 322 683 323 684 g_return_if_fail (widget != NULL); … … 333 694 attributes.wclass = GDK_INPUT_OUTPUT; 334 695 attributes.window_type = GDK_WINDOW_CHILD; 696 #if 0 335 697 attributes.event_mask = gtk_widget_get_events (widget) 336 698 | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 337 699 | 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 339 705 340 706 attributes.visual = gtk_widget_get_visual (widget); … … 342 708 343 709 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); 345 712 346 713 widget->style = gtk_style_attach (widget->style, widget->window); … … 357 724 gdk_gc_set_foreground(s->zeroline_gc, &SAMPLE_DISPLAY_CLASS(GTK_OBJECT(widget)->klass)->colors[SAMPLE_DISPLAYCOL_ZERO]); 358 725 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 362 736 s->sel_gc = gdk_gc_new(widget->window); 363 737 gdk_gc_set_foreground(s->sel_gc, &SAMPLE_DISPLAY_CLASS(GTK_OBJECT(widget)->klass)->colors[SAMPLE_DISPLAYCOL_SEL]); … … 383 757 gdk_gc_set_foreground(s->lowlight_gc, &SAMPLE_DISPLAY_CLASS(GTK_OBJECT(widget)->klass)->colors[SAMPLE_DISPLAYCOL_LOWLIGHT]); 384 758 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 } 385 766 386 767 sample_display_init_display(s, attributes.width, attributes.height); 387 768 388 SET_CURSOR(widget, crosshair_cr);769 sample_display_set_default_cursor (s); 389 770 390 771 gdk_window_set_user_data (widget->window, widget); … … 401 782 int channel) 402 783 { 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; 404 789 sw_audio_intermediate_t totpos, totneg; 405 790 sw_audio_t d, maxpos, avgpos, minneg, avgneg; 406 791 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; 408 793 sw_sample * sample; 409 794 const int channels = s->view->sample->sounddata->format->channels; … … 411 796 sample = s->view->sample; 412 797 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], 414 801 TRUE, x, y, width, height); 415 802 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); 416 845 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); 419 855 420 856 totpos = totneg = 0.0; 421 857 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 } 422 904 423 905 while(width >= 0) { … … 427 909 maxpos = minneg = 0; 428 910 429 /* 'step' ensures that no more than STEP_MAX values get looked at430 * 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)); 435 917 i+=step) { 436 918 d = ((sw_audio_t *)sample->sounddata->data)[i*channels + channel]; … … 445 927 } 446 928 } 929 930 g_mutex_unlock (sample->ops_mutex); 447 931 448 932 if (nr_pos > 0) { … … 458 942 } 459 943 460 #define YPOS(v) (y + ((((v) - SW_AUDIO_T_MIN) * height) \461 / (SW_AUDIO_T_MAX - SW_AUDIO_T_MIN)))462 463 944 gdk_draw_line(win, s->minmax_gc, 464 945 x, YPOS(maxpos), … … 474 955 x, YPOS(prev_minneg), 475 956 x, YPOS(minneg)); 476 477 478 gdk_draw_line(win, s->fg_gc, 957 958 gdk_draw_line(win, fg_gc, 479 959 x, YPOS(avgpos), 480 960 x, YPOS(avgneg)); … … 486 966 width--; 487 967 } 968 #endif 488 969 489 970 } 490 971 491 972 static void 492 sample_display_draw_data (GdkDrawable *win, 493 const SampleDisplay *s, 494 int x, 495 int width) 973 sample_display_draw_data (GdkDrawable *win, const SampleDisplay *s, 974 int x, int width) 496 975 { 497 976 const int sh = s->height; 498 int start_x, end_x ;977 int start_x, end_x, i, cy, cheight, cerr; 499 978 const int channels = s->view->sample->sounddata->format->channels; 500 979 501 if (width == 0)980 if (width == 0) 502 981 return; 503 982 … … 505 984 g_return_if_fail(x + width <= s->width); 506 985 507 #if 0986 #ifdef DEBUG 508 987 g_print("draw_data: view %u --> %u, drawing x=%d, width=%d\n", 509 988 s->view->start, s->view->end, x, width); … … 548 1027 } 549 1028 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; 553 1067 554 1068 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); 567 1079 } 568 1080 … … 591 1103 cy2 = ((sw_audio_t *)sample->sounddata->data)[OFFSET_RANGE(sample->sounddata->nr_frames, XPOS_TO_OFFSET(x)) + cx2]; 592 1104 593 gdk_draw_line( s->backing_pixmap, s->crossing_gc,1105 gdk_draw_line(win, s->crossing_gc, 594 1106 x - cx1, (((cy1 + 1.0) * sh) / 2.0), 595 1107 x + cx2, (((cy2 + 1.0) * sh) / 2.0)); … … 618 1130 dash_offset %= 8; 619 1131 620 gtk_widget_queue_draw (GTK_WIDGET(s));1132 sample_display_refresh_sels (s); 621 1133 622 1134 return TRUE; 623 1135 } 624 1136 625 void 626 sample_display_start_marching_ants (SampleDisplay * s) 627 { 1137 static void 1138 sd_start_marching_ants_timeout (SampleDisplay * s) 1139 { 1140 if (s->marching_tag > 0) 1141 gtk_timeout_remove (s->marching_tag); 1142 628 1143 s->marching_tag = gtk_timeout_add (MARCH_INTERVAL, 629 1144 (GtkFunction)sd_march_ants, … … 632 1147 633 1148 void 634 sample_display_stop_marching_ants (SampleDisplay * s) 1149 sample_display_start_marching_ants (SampleDisplay * s) 1150 { 1151 sd_start_marching_ants_timeout (s); 1152 s->marching = TRUE; 1153 } 1154 1155 static void 1156 sd_stop_marching_ants_timeout (SampleDisplay * s) 635 1157 { 636 1158 if (s->marching_tag > 0) … … 638 1160 639 1161 s->marching_tag = 0; 1162 } 1163 1164 void 1165 sample_display_stop_marching_ants (SampleDisplay * s) 1166 { 1167 sd_stop_marching_ants_timeout (s); 1168 s->marching = FALSE; 640 1169 } 641 1170 … … 704 1233 705 1234 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 706 1240 l_end = (x >= x_min) && (x <= x_max); 1241 x = CLAMP (x, x_min, x_max); 707 1242 708 x2 = OFFSET_TO_XPOS(sel->sel_end);709 1243 r_end = (x2 >= x_min) && (x2 <= x_max); 1244 x2 = CLAMP (x2, x_min, x_max); 710 1245 711 1246 /* 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, 713 1248 s, x, x2 - x - 1, 714 1249 l_end, r_end /* draw_ends */); … … 723 1258 x = OFFSET_TO_XPOS(sel->sel_start); 724 1259 l_end = (x >= x_min) && (x <= x_max); 725 1260 x = CLAMP (x, x_min, x_max); 1261 726 1262 x2 = OFFSET_TO_XPOS(sel->sel_end); 727 1263 r_end = (x2 >= x_min) && (x2 <= x_max); 728 1264 x2 = CLAMP (x2, x_min, x_max); 1265 729 1266 /* 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, 731 1268 s, x, x2 - x - 1, 732 1269 l_end, r_end /* draw_ends */); … … 735 1272 736 1273 737 /*** PLAY MARKER ***/1274 /*** PLAY MARKER, CURSOR ***/ 738 1275 739 1276 #if 0 … … 777 1314 #endif /* _{start,end}offset_to_xpos */ 778 1315 1316 static gint 1317 sd_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 1333 void 1334 sample_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 1344 void 1345 sample_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 779 1357 static 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) { 1358 sample_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 1417 static void 1418 sample_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 1467 static void 1468 sample_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) { 791 1475 #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 ***/ 809 1508 810 1509 static void 811 sample_display_draw_main (GtkWidget *widget, 812 GdkRectangle *area) 1510 sample_display_draw (GtkWidget *widget, GdkRectangle *area) 813 1511 { 814 1512 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; 817 1519 818 1520 if(area->width == 0) … … 821 1523 if(area->x + area->width > s->width) 822 1524 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 823 1530 824 1531 if(!IS_INITIALIZED(s)) { 825 1532 gtk_style_apply_default_background (GTK_WIDGET(s)->style, widget->window, 826 1533 TRUE, GTK_STATE_NORMAL, 827 NULL, 1534 NULL, 0, 0, s->width, s->height); 1535 #if 0 828 1536 area->x, area->y, 829 1537 area->width, area->height); 1538 #endif 830 1539 } else { 831 1540 const int x_min = area->x; 832 1541 const int x_max = area->x + area->width; 833 1542 1543 #ifdef DOUBLE_BUFFER 1544 drawable = s->backing_pixmap; 1545 #else 1546 drawable = widget->window; 1547 #endif 1548 834 1549 /* 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 846 1592 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 } 931 1599 932 1600 /*** EVENT HANDLERS ***/ 1601 933 1602 934 1603 static gint … … 936 1605 GdkEventExpose *event) 937 1606 { 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 939 1634 return FALSE; 940 1635 } 941 1636 1637 static gint 1638 sample_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 1661 static gint 1662 sample_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 942 1685 static void 943 sample_display_handle_motion (SampleDisplay *s, 1686 sample_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 1697 void 1698 sample_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 1709 static void 1710 sample_display_handle_sel_motion (SampleDisplay *s, 944 1711 int x, 945 1712 int y, … … 948 1715 sw_sample * sample; 949 1716 sw_sel * sel; 950 int o l, or;1717 int o; 951 1718 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; 955 1722 956 1723 if(!s->selecting) … … 965 1732 sample = s->view->sample; 966 1733 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 967 1751 sel = sample->tmp_sel; 968 1752 … … 970 1754 se = sel->sel_end; 971 1755 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; 974 1758 x = 0; 975 else if(x >= s->width) 1759 } else if(x >= s->width - 1) { 1760 scroll_right = TRUE; 976 1761 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; 986 1767 } 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; 1005 1772 } 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; 1026 1780 } 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; 1036 1783 s->selecting = SELECTING_SELECTION_START; 1037 1784 } 1038 }1039 break;1040 default:1041 g_assert_not_reached();1042 break;1785 break; 1786 default: 1787 g_assert_not_reached (); 1788 break; 1789 } 1043 1790 } 1044 1791 … … 1049 1796 sample_display_signals[SIG_SELECTION_CHANGED]); 1050 1797 } 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 } 1051 1827 } 1052 1828 1053 1829 /* Handle middle mousebutton display window panning */ 1054 1830 static 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; 1831 sample_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; 1062 1843 1063 1844 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); 1066 1851 1067 1852 if(new_win_start != s->view->start) { 1068 1853 sample_display_set_window (s, 1069 1854 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 } 1086 1857 } 1087 1858 1088 1859 static 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); 1860 sample_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; 1100 1886 } 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 1896 static void 1897 sample_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 1930 static void 1931 sample_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 2038 static gint 2039 sample_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 2049 static gint 2050 sample_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; 1103 2067 } 1104 2068 … … 1109 2073 SampleDisplay *s; 1110 2074 GdkModifierType state; 1111 GList * gl;1112 sw_sel * sel;1113 2075 sw_sample * sample; 1114 2076 int x, y; 1115 int xss, xse;1116 2077 int o; 1117 2078 … … 1125 2086 return TRUE; 1126 2087 2088 gtk_widget_grab_focus (widget); 2089 1127 2090 sample = s->view->sample; 1128 2091 … … 1130 2093 if (event->button == 4) { 1131 2094 /* mouse wheel up */ 1132 view_ volume_increase (s->view);2095 view_zoom_in (s->view, 2.0); 1133 2096 return TRUE; 1134 2097 } else if (event->button == 5) { 1135 2098 /* mouse wheel down */ 1136 view_ volume_decrease (s->view);2099 view_zoom_out (s->view, 2.0); 1137 2100 return TRUE; 1138 2101 } 1139 2102 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. */ 1142 2109 sample_display_clear_sel (s); 1143 2110 } else if (last_tmp_view && last_tmp_view != s->view && … … 1154 2121 return TRUE; 1155 2122 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; 1157 2137 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); 1183 2153 } 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); 1196 2163 } 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); 1199 2168 } 1200 1201 sample_display_handle_motion(s, x, y, TRUE); 2169 #endif 1202 2170 break; 1203 1204 2171 case TOOL_ZOOM: 1205 2172 o = XPOS_TO_OFFSET(x); … … 1210 2177 view_zoom_in (s->view, 2.0); 1211 2178 } 1212 return TRUE;1213 1214 2179 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; 1216 2188 default: 1217 2189 break; … … 1222 2194 gdk_window_get_pointer (event->window, &s->selecting_x0, NULL, NULL); 1223 2195 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); 1225 2198 } else if(last_button == 3) { 1226 2199 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); 1230 2201 } 1231 2202 } … … 1239 2210 { 1240 2211 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 1246 2214 s->selecting = SELECTING_NOTHING; 1247 2215 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); 1250 2232 } 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 } 1257 2252 } 1258 2253 … … 1262 2257 { 1263 2258 SampleDisplay *s; 2259 #ifdef SEL_SCRUBS 2260 GdkModifierType state; 2261 int x, y; 2262 #endif 1264 2263 1265 2264 g_return_val_if_fail (widget != NULL, FALSE); … … 1269 2268 s = SAMPLE_DISPLAY(widget); 1270 2269 1271 switch ( current_tool) {2270 switch (s->view->current_tool) { 1272 2271 case TOOL_SELECT: 1273 2272 … … 1276 2275 */ 1277 2276 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 } 1279 2285 } 1280 2286 … … 1287 2293 } 1288 2294 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; 1289 2306 break; 1290 2307 case TOOL_MOVE: … … 1296 2313 } 1297 2314 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); 1299 2323 1300 return FALSE;1301 }1302 1303 static gint1304 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 1320 2324 return FALSE; 1321 2325 } … … 1349 2353 sample_display_signals[SIG_MOUSE_OFFSET_CHANGED]); 1350 2354 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); 1354 2380 } 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 1355 2402 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)); 1357 2404 else 1358 2405 gdk_window_set_cursor (widget->window, NULL); … … 1368 2415 } 1369 2416 #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 not1383 * leaving them lying around.*/1384 2417 } 1385 2418 1386 2419 return FALSE; 2420 } 2421 2422 static gint 2423 sample_display_enter_notify (GtkWidget *widget, 2424 GdkEventCrossing *event) 2425 { 2426 gtk_widget_grab_focus (widget); 2427 return TRUE; 1387 2428 } 1388 2429 … … 1401 2442 } 1402 2443 2444 static gint 2445 sample_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 2468 static gint 2469 sample_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 2488 static gint 2489 sample_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) {
