diff options
348 files changed, 0 insertions, 49080 deletions
diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index 4c57be0ac0..0000000000 --- a/.cvsignore +++ /dev/null @@ -1,20 +0,0 @@ -Makefile.in -aclocal.m4 -configure -config.guess -config.sub -ltconfig -ltmain.sh -config.h.in -config.log -config.h -config.cache -libtool -config.status -stamp-h -Makefile -stamp.h -stamp-h.in -xlibtool -xltmain.sh -intl diff --git a/ABOUT-NLS b/ABOUT-NLS deleted file mode 100644 index 28d38c76fd..0000000000 --- a/ABOUT-NLS +++ /dev/null @@ -1,226 +0,0 @@ -Notes on the Free Translation Project -************************************* - - Free software is going international! The Free Translation Project -is a way to get maintainers of free software, translators, and users all -together, so that will gradually become able to speak many languages. -A few packages already provide translations for their messages. - - If you found this `ABOUT-NLS' file inside a distribution, you may -assume that the distributed package does use GNU `gettext' internally, -itself available at your nearest GNU archive site. But you do *not* -need to install GNU `gettext' prior to configuring, installing or using -this package with messages translated. - - Installers will find here some useful hints. These notes also -explain how users should proceed for getting the programs to use the -available translations. They tell how people wanting to contribute and -work at translations should contact the appropriate team. - - When reporting bugs in the `intl/' directory or bugs which may be -related to internationalization, you should tell about the version of -`gettext' which is used. The information can be found in the -`intl/VERSION' file, in internationalized packages. - -One advise in advance -===================== - - If you want to exploit the full power of internationalization, you -should configure it using - - ./configure --with-included-gettext - -to force usage of internationalizing routines provided within this -package, despite the existence of internationalizing capabilities in the -operating system where this package is being installed. So far, only -the `gettext' implementation in the GNU C library version 2 provides as -many features (such as locale alias or message inheritance) as the -implementation here. It is also not possible to offer this additional -functionality on top of a `catgets' implementation. Future versions of -GNU `gettext' will very likely convey even more functionality. So it -might be a good idea to change to GNU `gettext' as soon as possible. - - So you need not provide this option if you are using GNU libc 2 or -you have installed a recent copy of the GNU gettext package with the -included `libintl'. - -INSTALL Matters -=============== - - Some packages are "localizable" when properly installed; the -programs they contain can be made to speak your own native language. -Most such packages use GNU `gettext'. Other packages have their own -ways to internationalization, predating GNU `gettext'. - - By default, this package will be installed to allow translation of -messages. It will automatically detect whether the system provides -usable `catgets' (if using this is selected by the installer) or -`gettext' functions. If neither is available, the GNU `gettext' own -library will be used. This library is wholly contained within this -package, usually in the `intl/' subdirectory, so prior installation of -the GNU `gettext' package is *not* required. Installers may use -special options at configuration time for changing the default -behaviour. The commands: - - ./configure --with-included-gettext - ./configure --with-catgets - ./configure --disable-nls - -will respectively bypass any pre-existing `catgets' or `gettext' to use -the internationalizing routines provided within this package, enable -the use of the `catgets' functions (if found on the locale system), or -else, *totally* disable translation of messages. - - When you already have GNU `gettext' installed on your system and run -configure without an option for your new package, `configure' will -probably detect the previously built and installed `libintl.a' file and -will decide to use this. This might be not what is desirable. You -should use the more recent version of the GNU `gettext' library. I.e. -if the file `intl/VERSION' shows that the library which comes with this -package is more recent, you should use - - ./configure --with-included-gettext - -to prevent auto-detection. - - By default the configuration process will not test for the `catgets' -function and therefore they will not be used. The reasons are already -given above: the emulation on top of `catgets' cannot provide all the -extensions provided by the GNU `gettext' library. If you nevertheless -want to use the `catgets' functions use - - ./configure --with-catgets - -to enable the test for `catgets' (this causes no harm if `catgets' is -not available on your system). If you really select this option we -would like to hear about the reasons because we cannot think of any -good one ourself. - - Internationalized packages have usually many `po/LL.po' files, where -LL gives an ISO 639 two-letter code identifying the language. Unless -translations have been forbidden at `configure' time by using the -`--disable-nls' switch, all available translations are installed -together with the package. However, the environment variable `LINGUAS' -may be set, prior to configuration, to limit the installed set. -`LINGUAS' should then contain a space separated list of two-letter -codes, stating which languages are allowed. - -Using This Package -================== - - As a user, if your language has been installed for this package, you -only have to set the `LANG' environment variable to the appropriate -ISO 639 `LL' two-letter code prior to using the programs in the -package. For example, let's suppose that you speak German. At the -shell prompt, merely execute `setenv LANG de' (in `csh'), -`export LANG; LANG=de' (in `sh') or `export LANG=de' (in `bash'). This -can be done from your `.login' or `.profile' file, once and for all. - - An operating system might already offer message localization for -many of its programs, while other programs have been installed locally -with the full capabilities of GNU `gettext'. Just using `gettext' -extended syntax for `LANG' would break proper localization of already -available operating system programs. In this case, users should set -both `LANGUAGE' and `LANG' variables in their environment, as programs -using GNU `gettext' give preference to `LANGUAGE'. For example, some -Swedish users would rather read translations in German than English for -when Swedish is not available. This is easily accomplished by setting -`LANGUAGE' to `sv:de' while leaving `LANG' to `sv'. - -Translating Teams -================= - - For the Free Translation Project to be a success, we need interested -people who like their own language and write it well, and who are also -able to synergize with other translators speaking the same language. -Each translation team has its own mailing list, courtesy of Linux -International. You may reach your translation team at the address -`LL@li.org', replacing LL by the two-letter ISO 639 code for your -language. Language codes are *not* the same as the country codes given -in ISO 3166. The following translation teams exist, as of December -1997: - - Chinese `zh', Czech `cs', Danish `da', Dutch `nl', English `en', - Esperanto `eo', Finnish `fi', French `fr', German `de', Hungarian - `hu', Irish `ga', Italian `it', Indonesian `id', Japanese `ja', - Korean `ko', Latin `la', Norwegian `no', Persian `fa', Polish - `pl', Portuguese `pt', Russian `ru', Slovenian `sl', Spanish `es', - Swedish `sv', and Turkish `tr'. - -For example, you may reach the Chinese translation team by writing to -`zh@li.org'. - - If you'd like to volunteer to *work* at translating messages, you -should become a member of the translating team for your own language. -The subscribing address is *not* the same as the list itself, it has -`-request' appended. For example, speakers of Swedish can send a -message to `sv-request@li.org', having this message body: - - subscribe - - Keep in mind that team members are expected to participate -*actively* in translations, or at solving translational difficulties, -rather than merely lurking around. If your team does not exist yet and -you want to start one, or if you are unsure about what to do or how to -get started, please write to `translation@iro.umontreal.ca' to reach the -coordinator for all translator teams. - - The English team is special. It works at improving and uniformizing -the terminology in use. Proven linguistic skill are praised more than -programming skill, here. - -Available Packages -================== - - Languages are not equally supported in all packages. The following -matrix shows the current state of internationalization, as of December -1997. The matrix shows, in regard of each package, for which languages -PO files have been submitted to translation coordination. - - Ready PO files cs da de en es fi fr it ja ko nl no pl pt ru sl sv - .----------------------------------------------------. - bash | [] [] [] | 3 - bison | [] [] [] | 3 - clisp | [] [] [] [] | 4 - cpio | [] [] [] [] [] [] | 6 - diffutils | [] [] [] [] [] | 5 - enscript | [] [] [] [] [] [] | 6 - fileutils | [] [] [] [] [] [] [] [] [] [] | 10 - findutils | [] [] [] [] [] [] [] [] [] | 9 - flex | [] [] [] [] | 4 - gcal | [] [] [] [] [] | 5 - gettext | [] [] [] [] [] [] [] [] [] [] [] | 12 - grep | [] [] [] [] [] [] [] [] [] [] | 10 - hello | [] [] [] [] [] [] [] [] [] [] [] | 11 - id-utils | [] [] [] | 3 - indent | [] [] [] [] [] | 5 - libc | [] [] [] [] [] [] [] | 7 - m4 | [] [] [] [] [] [] | 6 - make | [] [] [] [] [] [] | 6 - music | [] [] | 2 - ptx | [] [] [] [] [] [] [] [] | 8 - recode | [] [] [] [] [] [] [] [] [] | 9 - sh-utils | [] [] [] [] [] [] [] [] | 8 - sharutils | [] [] [] [] [] [] | 6 - tar | [] [] [] [] [] [] [] [] [] [] [] | 11 - texinfo | [] [] [] | 3 - textutils | [] [] [] [] [] [] [] [] [] | 9 - wdiff | [] [] [] [] [] [] [] [] | 8 - `----------------------------------------------------' - 17 languages cs da de en es fi fr it ja ko nl no pl pt ru sl sv - 27 packages 6 4 25 1 18 1 26 2 1 12 20 9 19 7 4 7 17 179 - - Some counters in the preceding matrix are higher than the number of -visible blocks let us expect. This is because a few extra PO files are -used for implementing regional variants of languages, or language -dialects. - - For a PO file in the matrix above to be effective, the package to -which it applies should also have been internationalized and -distributed as such by its maintainer. There might be an observable -lag between the mere existence a PO file and its wide availability in a -distribution. - - If December 1997 seems to be old, you may fetch a more recent copy -of this `ABOUT-NLS' file on most GNU archive sites. - diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 6a6b4a1bc9..0000000000 --- a/AUTHORS +++ /dev/null @@ -1,10 +0,0 @@ -Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - Main author of Camel. - -Miguel de Icaza <miguel@gnu.org> - Base64 encoding in Camel. - -Robert Brady <rwb197@ecs.soton.ac.uk> - Unicode and RFC2047 support for Camel. - - diff --git a/COPYING b/COPYING deleted file mode 100644 index d60c31a97a..0000000000 --- a/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index 504762e26f..0000000000 --- a/ChangeLog +++ /dev/null @@ -1,1680 +0,0 @@ -1999-11-17 Ettore Perazzoli <ettore@gnu.org> - - * composer/Makefile.am (EXTRA_DIST): Added `$(glade_DATA)'. - - * camel/Makefile.am (EXTRA_DIST): Added - `$(libcamel_extra_sources)'. - (libcamelinclude_HEADERS): Added `gmime-base64.h'. - -1999-11-17 Ettore Perazzoli <ettore@gnu.org> - - * camel/camel-mime-message.c (_write_to_stream): Removed extra ':' - in the `Mime-Version' header. - - * tests/ui-tests/msg-composer-test.c: Removed. - - * Makefile.am (SUBDIRS): Added `composer'. - - * configure.in: Create `composer/Makefile'. - - * camel/camel-simple-data-wrapper-stream.c - (camel_simple_data_wrapper_stream_construct): Updated accordingly. - (camel_simple_data_wrapper_stream_new): Updated accordingly. - * camel/camel-stream-data-wrapper.c - (camel_stream_data_wrapper_construct): Updated accordingly. - - * camel/camel-data-wrapper.h: Replaced `IS_CAMEL...()' type check - macro name with `CAMEL_IS...()'. - * camel/camel-folder-pt-proxy.h: Likewise. - * camel/camel-folder-summary.h: Likewise. - * camel/camel-folder.h: Likewise. - * camel/camel-medium.h: Likewise. - * camel/camel-mime-body-part.h: Likewise. - * camel/camel-mime-message.h: Likewise. - * camel/camel-mime-part.h: Likewise. - * camel/camel-multipart.h: Likewise. - * camel/camel-service.h: Likewise. - * camel/camel-session.h: Likewise. - * camel/camel-simple-data-wrapper-stream.h: Likewise. - * camel/camel-simple-data-wrapper.h: Likewise. - * camel/camel-store.h: Likewise. - * camel/camel-stream-buffered-fs.h: Likewise. - * camel/camel-stream-data-wrapper.h: Likewise. - * camel/camel-stream-fs.h: Likewise. - * camel/camel-stream-mem.h: Likewise. - * camel/camel-stream.h: Likewise. - - * tests/test1.c (main): Updated to match the `RECIPIENT_TYPE' - changes. - - * camel/camel-mime-message.h: Changed `RECIPIENT_TYPE_TO', - `RECIPIENT_TYPE_CC' and `RECIPIENT_TYPE_BCC' into - `CAMEL_RECIPIENT_TYPE_TO', `CAMEL_RECIPIENT_TYPE_CC' and - `CAMEL_RECIPIENT_TYPE_BCC', respectively. - -1999-11-17 Ettore Perazzoli <ettore@gnu.org> - - * camel/camel-mime-message.c (_write_to_stream): Write - "Mime-Version: 1.0" to the stream. - - * tests/test1.c: If executed with a file name parameter, attach a - file with with that name to the email without loading it into - core, thus demonstrating usage of my latest changes. - - * camel/camel-mime-part.c (_set_encoding): Updated to use - `CamelMimePartEncodingType'. - (camel_mime_part_set_encoding): Likewise. - (_get_encoding): Likewise. - (camel_mime_part_get_encoding): Likewise. - (_write_content_to_stream): Honour the `encoding' member. - (_construct_from_stream): Made static. - (camel_mime_part_encoding_to_string): New function. - (_write_to_stream): Write the encoding string using it. - (camel_mime_part_init): Set encoding to - `CAMEL_MIME_PART_ENCODING_DEFAULT'. - (_finalize): Don't free `encoding' anymore. - (camel_mime_part_encoding_from_string): New function. - (_parse_header_pair): Use it. - - * camel/camel-mime-part.h: New enum `CamelMimePartEncodingType'. - Member `encoding' of `struct _CamelMimePart' changed from `gchar - *' to `CamelMimePartEncodingType'. All the encoding-related - methods changed to use this type instead of `gchar *'. - - * camel/gmime-base64.c (gmime_encode_base64): Got it to work. - - * camel/Makefile.am (libcamel_la_SOURCES): Compile - `gmime-base64.c'. - - * camel/gmime-base64.h: New, previously missing, header. - - * camel/camel-stream-data-wrapper.c: New file implementing the - `CamelStreamDataWrapper' class. - * camel/camel-stream-data-wrapper.h: Corresponding header. - - * camel/camel-simple-data-wrapper.c: Implemented the `get_stream' - virtual method. - (_get_stream): New function implementing the method. - (camel_simple_data_wrapper_class_init): Install it in the class - struct. - (camel_simple_data_wrapper_init): New function initializing the - `stream' member to NULL, - (camel_simple_data_wrapper_class_init): Set it as the - GtkObjectInitFunc. - - * camel/camel-simple-data-wrapper.h: New member `stream' in - `struct _CamelSimpleDataWrapper'. - - * camel/camel-simple-data-wrapper-stream.c: New file implementing - the `CamelSimpleDataWrapperStream' class. - * camel/camel-simple-data-wrapper-stream.h: Corresponding header. - - * camel/camel-data-wrapper.c (camel_data_wrapper_get_stream): New - function. - (_get_stream): New private function, just returning NULL. - (camel_data_wrapper_class_init): Install it as the default - `get_stream' virtual method. - - * camel/camel-data-wrapper.h: New virtual method `get_stream' in - `CamelDataWrapperClass'. - (camel_data_wrapper_get_stream): New function prototype. - -1999-11-05 Ettore Perazzoli <ettore@gnu.org> - - * tests/ui-tests/msg-composer-test.c: New file for testing the - `EMsgComposer' widget. - * tests/ui-tests/Makefile.am (noinst_PROGRAMS): Compile it. Do - not compile `store_listing' for now because it's currently broken. - (INCLUDES): Added the `widgets' source directory to the include - path list. - (LDADD): Removed the MH dependency; link with - `libevolutionwidgets.la' from the `widgets' directory. - - * configure.in: Create `widgets/Makefile'. - - * camel/gmime-rfc2047.c (rfc2047_clean): Removed C++-like comment. - * camel/camel-folder.c (camel_folder_get_message_uid_by_number): - Likewise. - * camel/gmime-content-field.c (gmime_content_field_get_parameter): - Likewise. - * camel/camel.c (camel_init): Likewise. - * camel/camel-provider.c (camel_provider_register): Likewise. - * camel/camel-multipart.c (_construct_from_stream): Likewise. - * camel/camel-mime-part.c (_write_content_to_stream): Likewise. - * camel/camel-medium.c (camel_medium_class_init): Likewise. - - * camel/camel-data-wrapper.h (camel_data_wrapper_get_type): Make - prototype non-static. - - * camel/Makefile.am (libcamelinclude_HEADERS): Move - `camel-exception-list.def' from `EXTRA_DIST' to - `libcamelinclude_HEADERS'. - - * camel/camel.h: Do not #include <config.h>. - * camel/data-wrapper-repository.h: Likewise. - -1999-11-05 Ettore Perazzoli <ettore@gnu.org> - - * tests/Makefile.am (INCLUDES): Add `-I$(top_srcdir)'. - -1999-10-13 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-folder.c (camel_folder_close): the - folder->close method is now asynchronous. - - * camel/camel-folder-pt-proxy.c (_folder_open_cb): - (_open): - (_folder_open_cb): - (_open): - open/close method implemented in the thread proxy - folder. More to come. - - * camel/camel-exception.c (camel_exception_xfer): - new utility func. - - * camel/camel-marshal-utils.c: some new marshallers - - * camel/camel-folder-pt-proxy.c: Some explanations - on the thread proxy system. - -1999-10-11 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-marshal-utils.c: - camel/camel-marshal-utils.h: - Handles operation marshalling. - - * camel/camel-thread-proxy.c: - camel/camel-thread-proxy.h: - new files. Generic proxy system. - - * camel/camel-folder-pt-proxy.c - moved all proxy related code in dedicated files. - - (camel_folder_pt_proxy_init): - removed proxy initialisation code - (_finalize): - removed proxy finalization code - - - * camel/camel-exception.c - (camel_exception_new): - (camel_exception_set): - (camel_exception_free): - New funcs. - -1999-09-21 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-folder-pt-proxy.c (_async_close): - implemented. - - * configure.in: - Check pthreads. - - * camel/Makefile.am: - camel-folder-pt-proxy.c is only compiled - when pthreads are available. - - * camel/camel-folder-pt-proxy.c: - Signal proxying implemenatation. - (_signal_marshaller_server_side): - (_signal_marshaller_client_side): - (_init_signals_proxy): - Code not is tested and has to be best - explained as it uses threads conditions and - gtk signal system. - (_thread_notification_catch): notify pending signals - as well as thread availability. - -1999-09-20 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-folder-pt-proxy.c (_op_exec_or_plan_for_exec): - completed - - Binch of new funcs: - (_maybe_run_next_op): - Called by the watch notification when - a threaded op is completed - (_thread_notification_catch): - notification watch call back - (_init_notify_system): - set up the notification channel - (notify_availability): - called by threads before completion. - -1999-09-18 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-folder-pt-proxy.c (_op_exec_or_plan_for_exec): - new func. Try to exec an operation in a thread - or queue it if a thread is already busy. - - * camel/camel-op-queue.c (camel_op_queue_set_service_availability): - (camel_op_queue_get_service_availability): - new funcs. - - * camel/camel-op-queue.c (camel_op_new): - (camel_op_free): - new funcs. Uses glib mem chunks. - - -1999-09-17 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-folder-pt-proxy.c (_init_with_store): - added notify io_channel. - - * camel/camel-op-queue.h: - * camel/camel-op-queue.c: - New object. Operation queue. Meant to be used in - non-blocking proxy objects. - (camel_op_queue_run_next_op): new func. - run the next operation. - -1999-09-14 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/Makefile.am (libcamel_la_SOURCES): - added camel-folder-pt-proxy.[ch] to the build - process. - - * camel/camel-folder-pt-proxy.c (_init_with_store): - started implementation of the pthread-based - folder proxy. - - -1999-09-08 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/providers/MH/mh-summary.c - (mh_load_summary): - (mh_save_summary): - (mh_create_summary): - implemented summary (files) for MH folders. - - * camel/providers/MH/camel-mh-folder.c - (_get_message_by_uid): implemented. - (camel_mh_folder_class_init): - (_get_message_uid): implemented - - * camel/camel-folder.c (camel_folder_has_uid_capability): - (camel_folder_get_message_uid): - (camel_folder_get_message_uid_by_number): - (camel_folder_get_message_by_uid): - (camel_folder_get_uid_list): - Documented UID methods. - (camel_folder_get_message_uid_by_number): - const'ified uid. - (camel_folder_get_message_by_uid): idem - removed stupid camel_folder_get_message_uid_by_number - method. - - * tests/ui-tests/store_listing.c (close_all): - close all open folders and stores. (necessary - for UID list saving ). - - * camel/providers/MH/mh-uid.c (mh_generate_uid_list): - fix: store UID list in CamelMHFolder object. - - * camel/providers/MH/camel-mh-folder.c (_open): - read or create UID list. - (_close): save UID list. - -1999-09-07 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/md5-utils.c (md5_get_digest_from_file): - correct parameter decl (const) - - * camel/md5-utils.h: typo. - - * camel/providers/MH/mh-uid.c - More work on UID stuff for MH. - (mh_save_uid_list): - (mh_load_uid_list): - (mh_generate_uid_list): - new funcs. Manage on-disk uid list. - - * camel/providers/MH/mh-utils.c (mh_is_a_message_file): - Util routines live here now. - - * camel/md5-utils.c - Documented all funcs. - - (md5_get_digest_from_stream): - correct typo. - (md5_get_digest_from_file): - same typo corrected. - - - * camel/md5-utils.h : - raw routines are declared public now. - Md5 use has to be versatile. - - * camel/providers/MH/mh-uid.c (mh_uid_get_for_file): - new func. Returns an UID for an MH message. - -1999-09-06 bertrand <Bertrand.Guiheneuf@aful.org> - - - * camel/md5-utils.h: - * camel/md5-utils.c: - changed names to follow camel style. - (md5_get_digest_from_stream): - new methods. - (md5_get_digest_from_file): - new function : get file md5 signature. - To be used in providers code. - - * camel/md5-utils.c: imported md5 coding - routine from rpm. Compiles. - - -1999-09-05 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-folder.c (camel_folder_has_uid_capability): - (camel_folder_get_message_uid): - (camel_folder_get_message_uid_by_number): - (camel_folder_get_message_by_uid): - (camel_folder_get_uid_list): - Basic UID framework. - - * devel-docs/misc/ref_and_id_proposition.txt: - New revision. Some fixes. - - * camel/camel-folder.h (struct _CamelFolder): added - uid_capability field. - - - * camel/camel-folder.c (camel_folder_close): publicized - the close method. - - * tests/ui-tests/store_listing.c (show_folder_messages): - use folder summary instead of opening all messages. - (show_folder_messages): re-enabled old CPU/Mem consumming - method. Useful for pop3 for instance. - - * camel/providers/MH/camel-mh-folder.c (_create_summary): - basic and highly non-efficient summary implementation. - Should be seen as a proof of concept only. - subfolder summary still has to be implemented. - - * camel/providers/maildir/camel-maildir-folder.c (_init_with_store): - hasn't summary for the moment. - * camel/providers/maildir/camel-maildir-folder.c - cosmetic changes. - - -1999-09-04 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/providers/MH/camel-mh-folder.c (_create_summary): - started summary implementation. - (_open): correct use of open. - - * camel/camel-folder.c (camel_folder_get_summary): - get folder associated summary object. - - * camel/Makefile.am: - added summary files build - - * camel/camel-folder-summary.[ch]: - basic summary framework - -1999-09-03 bertrand <Bertrand.Guiheneuf@aful.org> - - * devel-docs/camel/Makefile.am: - sgml doc has camel-recipient now. - - * camel/camel-recipient.c (camel_recipient_foreach_recipient_type): - added in-line documentation. - -1999-09-02 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/providers/maildir: Added (experimental) maildir - provider written by Jukka Zitting <hukka@greywolves.org> - - * camel/providers/Makefile.am (SUBDIRS): build maildir - provider. - - * camel/camel-provider.c (camel_provider_get_for_protocol): - bug fix. patch from Jukka Zitting <hukka@greywolves.org> - - * camel/camel-mime-message.c (_write_one_recipient_to_stream): - changed decl to fit CRLFunc. - (_write_recipients_to_stream): - calls camel_recipient_foreach_recipient_type now. - - * camel/camel-recipient.c (camel_recipient_foreach_recipient_type): - new convinience function. Iterate over all recipient types. - - * camel/gmime-utils.c (gmime_write_header_table_to_stream): - s/write_header_table_to_stream/gmime_write_header_table_to_stream/ - (gmime_write_header_with_glist_to_stream): - s/write_header_with_glist_to_stream/gmime_write_header_with_glist_to_stream/ - -1999-09-01 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-message.c (_finalize): - (_add_recipient): - (_remove_recipient): - (_get_recipients): now use CamelRecipientTable - - * camel/gmime-content-field.c: - (gmime_content_field_unref): test if object - to free is non void. - - * camel/camel-folder.c (_finalize): - (_set_name): - * camel/camel-mime-part.c (_finalize): - (_set_description): - (_set_disposition): - * camel/camel-service.c (_finalize): - * camel/camel-stream-fs.c (_finalize): - * camel/gmime-content-field.c: - (gmime_content_field_construct_from_string): - - * camel/url-util.c (g_url_free): - - When using g_free (obj) don't test if obj != NULL - g_free () already do that. Thanks to elerium for - the feedback. - -1999-08-30 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-recipient.c (camel_recipient_get): - (camel_recipient_remove): - (camel_recipient_add): - new func. More work on new independant recipient code. - -1999-08-29 bertrand <Bertrand.Guiheneuf@aful.org> - - * MAINTAINERS: updated my e-mail address. - -1999-08-28 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-part.c (camel_mime_part_set_text): - text parameter declared const - - * camel/camel-mime-part-utils.c (camel_mime_part_store_stream_in_buffer): - actually test correctly nb_bytes_read_chunk is >0 - - * camel/gstring-util.c: - * camel/gmime-content-field.c: - * camel/providers/MH/camel-mh-folder.c: - * camel/camel-stream-fs.c: - include string.h - - * camel/camel-stream-mem.c (_write): return - the numver of written bytes. - - * camel/camel-stream-buffered-fs.c (_eos): - return sthg - - * camel/camel-stream.c (default_camel_seek): - return something. - -1999-08-26 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-part.c (_get_content_object): - contruct the content from the buffer before calling - CamelMedium implementation. - (_construct_from_stream): Do not construct the content - by default, just store the content bytes in - a temporary buffer. Content will be constructed only - at caller request (when calling CamelMedium::get_content_object) - Providers with better access to the messages (mbox/MH ...) - will have to provider lighter implementation, that is - shall not read content at all unless the caller asks - for it (again with get_content). - - * camel/camel-mime-part-utils.c: new file, groups - mime-part related utils. Meant to be used by providers - subclassing MimeMessage. - (camel_mime_part_construct_headers_from_stream): - (camel_mime_part_construct_content_from_stream): - no more useless temporary hash table. - - * camel/camel-mime-part.c (_construct_from_stream): calls - mime-part-utils functions now. - - * camel/gmime-utils.c (_store_header_pair_from_string): - do not use hash table to store header, use an array instead. - -1999-08-25 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-part.c: now descend from CamelMedium. - - * tests/test1.c (main): all headers must be strdup'ed - (main): unref created objects - - * camel/camel-medium.c (_set_content_object): - (_get_content_object): these methods are - in CamelMedium now. - -1999-08-24 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-medium.c (camel_medium_class_init): - new class. Will handle all sort of information media - (Mime mail messages, Lotus Notes mail messages, - postit notes, faxes, who knows .... :) - CamelMimePart will inherit from it. - - * camel/camel-mime-part.c (_set_disposition): - (_set_description): - description and disposition parameters are now const. - - - * camel/gmime-content-field.c (gmime_content_field_free): added - assertion code. - - * camel/providers/MH/camel-mh-folder.c (_get_message): - uses buffered stream. - - * camel/camel-stream-buffered-fs.c: - new stream to accelerate file ops. - -1999-08-20 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-stream-fs.c (camel_stream_fs_new_with_name): - name parameter is const. This fixes a bug in destroy () - -1999-08-18 Robert Brady <rwb197@ecs.soton.ac.uk> - - * camel/gmime-rfc2047.c: more work on encoder. - -1999-08-17 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-stream.c (camel_stream_read): - return the number of bytes read. - How can this have ever worked ? - (camel_stream_flush): don't return anything. - - * camel/gmime-utils.c (get_header_table_from_stream): - mem leak fixed. - -1999-08-16 bertrand <Bertrand.Guiheneuf@aful.org> - - * tests/ui-tests/store_listing.c: - Now has a popup menu on mailbox tree to allow - easier tests. Implemented the copy stuff. - Works well for the MH provider :))) - - * camel/providers/MH/camel-mh-folder.c (_copy_message_to): - Test MH provider fast copy implemented. - - -1999-08-15 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-folder.c (camel_folder_expunge): - moved the active list readjustment code here. - Much saner, providers won't have to worry about - that. - (_copy_message_to): new method. - - * camel/providers/MH/camel-mh-folder.c (_expunge): - no more active list readjustment stuff. - - * camel/camel-folder.h: the expunge virtual no more - returns a list of expunged messages. Now providers - only have to set the expunge flag on the expunged - messages. - - * camel/camel-folder.c (camel_folder_get_message): - moved the caching code here. Finally, I don't want - providers to crash the libs with a bad message cache - implementation. - (_close): do not call the CamelFolder virtual expunge - method directly, use camel_folder_expunge() instead. - (camel_folder_expunge): added the want_list param. - The client can decide if it wants the expunged message - list or not. If yes, it'll have to unref the messages - itself. - -1999-08-14 bertrand <Bertrand.Guiheneuf@aful.org> - - * tests/ui-tests/store_listing.c (delete_selected_messages): - (expunge_selected_folders): - Implemented deletion/expunge mechanism. - - * camel/camel-folder.c (_get_message): - Added some debug info. - - * camel/providers/MH/camel-mh-folder.c (_expunge): - implemented and tested. - - * camel/camel-mime-message.c (_set_flag): - changed the old braindead implementation. - boolean are inserted in the flag hash - table casted as gpointers. - - - * camel/camel-mime-message.c: indentation fix - - -1999-08-13 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-folder.c (_get_message): default implementation - to be called first by providers methods. It looks in the - folder message list (in memory) to see if the message has - not already been retrieved, and in this case, returns - the same CamelMimeMessage object - - * camel/providers/MH/camel-mh-folder.c (_get_message): set - message->message_number correctly. - - * camel/camel-folder.h (struct _CamelFolder): - New field (message_list) which will hold a - reference on each message obtained by the folder, - which is necessary in order for the caching procedure - to work (Getting the same message from a folder twice - will return the same CamelMimeMessage object). - - * camel/camel-folder.c (camel_folder_get_message): - When the store retreives a message put it in its - message list. - (_finalize): free message list. - - * ChangeLog: fix typo (parmanent) - - * camel/camel-folder.c (_get_permanent_flag_list): - (camel_folder_get_permanent_flag_list): - new method, returns the list of permanent - flags supported by the folder. - - * camel/camel-mime-message.c (_get_flag_list): - (camel_mime_message_get_flag_list): new method, - return the list of flag name used by this message. - - * camel/hash-table-utils.c (g_strcase_equal): - (g_strcase_hash): those two func go here now. - - * camel/hash_table_utils.c (hash_table_generic_free): - free a (gpointer, gpointer) hash table pair. - - * camel/camel-mime-message.c (camel_mime_message_init): use - case insensitive hash table functions. - (_set_flag): - (camel_mime_message_set_flag): - (_get_flag): - (camel_mime_message_get_flag): - Use const for flag name, they are now - duplicated. - -1999-08-12 bertrand <Bertrand.Guiheneuf@aful.org> - - * tests/ui-tests/store_listing.c (show_folder_messages): - remove stupid debug code. - (add_mail_store): use camel_session_get_store instead - of creating MH store directly. - (main): load MH provider. - - * camel/camel-provider.c (camel_provider_register_as_module): - register new provider. - (camel_provider_get_for_protocol): - Now, implementation is correct. - - * camel/camel-store.c (_finalize): - * camel/camel-store.h (struct _CamelStore): - further disabled url_name field use. - URL will be generated dynamically. - - * camel/camel-session.c (camel_session_get_store_for_protocol): - compilation and runtime fixes. - - * camel/providers/MH/camel-mh-store.c (_init): - synced with CamelStore. - - * camel/camel-store.c (_init): - in CamelStore::init, url_name is now const. - disabled url_name copy. - - * camel/camel-session.c (camel_session_get_store): - new function: returns a store for an URL. - (camel_session_get_store_for_protocol): - new functionc: returns a store for a given - store protocol (as IMAP/POP/MH ...) - * camel/string-utils.c (g_strcase_equal): - (g_strcase_hash): case insensitive hash table - funcs. - - * camel/camel-session.c (camel_session_init): hash table - keys are case insensitive. - - * camel/camel-provider.c (camel_provider_get_for_protocol): - new function, returns the last registered - provider for a protocol. - - * camel/providers/MH/camel-mh-provider.c: - new file. MH provider registration stuff. - - * camel/camel-provider.c (camel_provider_register_as_module): - load a provider from a shared object (plugin). - (camel_provider_register): register a provider - "by hand". Used for statically defined providers. - - * tests/test7.c: new test. - tests providers loading framework. - -1999-08-11 - - * camel/camel-service.c (_finalize): - * camel/camel-stream-fs.c (_finalize): - (_destroy): close file descriptor. - * camel/camel-stream-mem.c (_finalize): - * camel/camel-store.c (_finalize): - * camel/camel-folder.c (_finalize): - * camel/camel-multipart.c (_finalize): - * camel/camel-simple-data-wrapper.c (_finalize): - * camel/camel-mime-part.c (_finalize): - implemented destructors. - - - * camel/gmime-content-field.c (gmime_content_field_ref): - (gmime_content_field_unref): - New reference mechanism for GMimeContentField objects. - - * camel/camel-data-wrapper.c (_finalize): - Started implementing destructors. - - * camel/camel-mime-part.c (_construct_from_stream): - * camel/gmime-content-field.c (gmime_content_field_write_to_stream): - * camel/camel-multipart.c (_construct_from_stream): - removed forgotten anarchic traces. - -1999-08-10 bertrand <Bertrand.Guiheneuf@aful.org> - - * tests/ui-tests/store_listing.c: - * tests/ui-tests/store_listing.glade: - Quick and (very) dirty hack to test Camel more - easily. - - * camel/camel-folder.c (camel_folder_append_message): - new method. - -1999-08-09 bertrand <Bertrand.Guiheneuf@aful.org> - - * devel-docs/misc/ref_and_id_proposition.txt: - new file. Document message UID and vfolder - implementation. - -1999-08-08 Robert Brady <rwb197@ecs.soton.ac.uk> - - * camel/gmime-rfc2047.c: more advanced RFC2047 encoder started. - -1999-08-08 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/providers/MH/camel-mh-folder.c (_get_message): - fix. In MH, message number is not related to - message position in folder. - - * camel/providers/MH/camel-mh-folder.c (_is_a_message_file): - util func. - (_get_message_count): implemented. - -1999-08-06 bertrand <Bertrand.Guiheneuf@aful.org> - - * devel-docs/camel/: - updated some autogen doc stuff. - Still don't understand warnings :( - - * camel/camel-data-wrapper.c: - * camel/providers/MH/camel-mh-store.c: - * camel/url-util.c: - * camel/gmime-content-field.c: - * camel/camel-store.c: - various inline doc corrections. - - * camel/camel-folder.c (get_message_count): - new method. Returns the number of message - in the folder. - - - -1999-08-06 Robert Brady <rwb197@ecs.soton.ac.uk> - - * tests/test6.c: encoder test. - - * camel/gmime-rfc2047.c: Fixed decoder bug : sequence - ?= is not always the terminator for an encoded-string. - - -1999-08-06 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/providers/MH/camel-mh-folder.c (_list_subfolders): - stat was not testing the good file. Fixed. - - * tests/test4.c (main): added real test for MH folder - provider. All tested things seem to work OK :) - -1998-08-06 Robert Brady <rwb197@ecs.soton.ac.uk> - - * tests/test5.c: test for RFC2047 decoder. - - * camel/gmime-rfc2047.c: Improved RFC2047 decoder. - -1999-08-06 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/providers/MH/camel-mh-folder.c (_exists): add debug information - (_list_subfolders): test if first char in folder name is not '.' - before adding it to the folder list. - - * camel/camel-store.c (_init): - disable session check temporarily - (_get_separator): - (_get_folder): new static func. - Fixed several oddities in class definition. - - * camel/providers/MH/camel-mh-store.c (camel_mh_store_get_type): - parent type is CAMEL_STORE_TYPE not CAMEL_FOLDER_TYPE - - * camel/camel-store.c: - prent class is CamelServiceClass not GtkObjectClass - - * camel/url-util.c : - cosmetic changes + use of const when possible. - (find_host): - fix a bug: when there is no host and no port don't skip the '/' - all static find_* func are now named _func_* - (g_url_free): destructor func. - cache field has been disabled. Constructing the url string - won't be too slow and will occur rarely enough that we - do not need to add complexity to this code. - - * camel/providers/MH/camel-mh-store.c: - parent class is CamelStorClass not GtkObjectClass - -1999-08-05 bertrand <Bertrand.Guiheneuf@aful.org> - - * tests/test4.c: - test mh provider. - - * camel/providers/MH/camel-mh-folder.c (_get_message): - implemented - - * camel/camel-folder.c (_get_message): - new method. - (camel_folder_get_message): - corresponding public call - - * camel/README.HACKING: - Some notes. - - * camel/CODING.STYLE: - short note about coding style. - - * camel/README.COPYRIGHT: - Note about copyright policy. - - * camel/providers/MH/camel-mh-folder.c (_list_subfolders): - minor typo fixes. - - -1999-08-04 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/gmime-rfc2047.c: - * camel/gmime-rfc2047.h: - indentation and cosmetic changes. - - * camel/providers/MH/camel-mh-folder.c (_list_subfolders): - implemented. - * camel/providers/MH/camel-mh-folder.c (_delete): - finshed implementation - (_delete_messages): implemented. - - -1999-08-04 Robert Brady <rwb197@ecs.soton.ac.uk> - - * camel/gmime-rfc2047.[ch]: added an implemention of RFC2047 - (support for character sets other than US-ASCII in MIME - headers). Not actually called from anywhere yet. - - -1999-08-03 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/providers/MH/camel-mh-folder.c (_create): - implemented. - (_delete): started implementation. - - * camel/camel-folder.c (_get_folder): default implementation - calls camel_store_get_folder (). - - * camel/providers/MH/camel-mh-folder.c (_init_with_store): - implemented. - - * camel/camel-folder.h (struct _CamelFolder): - remove useless exist_on_store field. - - * camel/camel-folder.c (_exists): - do not use exist_on_store field. - - * camel/camel-folder.c (camel_folder_set_name): - (camel_folder_get_name): - new public functions - (_set_name): set full_path. - - (_set_full_name): - (camel_folder_set_full_name): - commented out this functions def. - It would make things very difficult to handle, and would not - be very useful. - - * camel/providers/MH/camel-mh-store.h: - * camel/providers/MH/camel-mh-store.c (camel_mh_store_set_toplevel_dir): - (camel_mh_store_get_toplevel_dir): - * camel/providers/MH/camel-mh-folder.c (_set_name): - * camel/providers/MH/camel-mh-folder.h: - use (gchar *) instead of (GString *) everywhere. - use const when necessary. - - * camel/camel-folder.h (struct _CamelFolder): - removed unused message_list field. - - * camel/camel-mime-part.c (_set_content_object): - There is a probleme here. We can not allow mime part - content-type field and content_object mime-type to be - different. I thus chosed to set mime part object - content field to be freed (if necessary) and set - to be a pointer to content_object mime type - field. - (_construct_from_stream): set content_object mime type - to be the same as mime_part's one. This is necessary - because we use _set_content_type. - - This two things are a bit hackish ansd may need - to be redesigned. - - * camel/gmime-utils.c (gmime_write_header_pair_to_stream): - use g_strdup_printf and remove a bug. - - * camel/camel-simple-data-wrapper.c (_construct_from_stream): - more debugging output + nb_bytes_read is now a signed int - to avoid bug when eos is encountered. - - * camel/camel-mime-part.c (_construct_from_stream): - sync to data_wrapper_repository function name changes. - Use default "text/plain" type when conten-type field - is not found. (following RFC 2046 spec). - - * camel/data-wrapper-repository.c (data_wrapper_repository_set_data_wrapper_type): - (data_wrapper_repository_get_data_wrapper_type): - change function name prefix (s/data_wrapper/data_wrapper_repository/) - - * camel/camel-multipart.c (_read_part): - add `\n` at eol but not before boundary. - - * camel/gmime-utils.c (get_header_table_from_stream): - correct implementation of end of stream detection. - -1999-08-01 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-multipart.c (_read_part): - use a stream to store the part instead of GString. - - * camel/camel-mime-part.c (camel_mime_part_set_text): - set data wrapper content type to "text/plain". - - * camel/camel-stream-mem.c: - * camel/camel-stream-mem.h: - new memory buffer based stream. - - * camel/camel-stream-fs.c (_seek): - implementation for file system based stream. - - * camel/camel-stream.c (camel_stream_seek): - new method. - - * camel/camel-stream-fs.c (camel_stream_fs_class_init): - pass CamelStreamFsClass instead of CamelStreamClass. - -1999-08-01 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/gmime-utils.c (gmime_write_header_pair_to_stream): - corrected a bug with memory not allocated for '\0' in strtmp - - * camel/gmime-utils.c (gmime_read_line_from_stream): - do not return NULL when line is empty. - - * camel/camel-multipart.c (_read_part): return true when end - of multipart is found, not the opposite - -1999-07-31 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/gmime-utils.c (gmime_read_line_from_stream): - Don't return crlf at end of line. - -1999-07-30 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/gmime-utils.c (gmime_read_line_from_stream): - new function: reads a line from a stream. - should be in streams utils maybe. - -1999-07-29 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-part.c (_construct_from_stream): - Uses data wrapper repository to find what data wrapper - to use to construct the content from a stream. When - no object is registered for the mime type found in - content type field a CamelSimpleDataWrapper is - used. - - * camel/camel-mime-part.c (_get_content_type): - (camel_mime_part_get_content_type): returns - a pointer on the content_type field instead - of the gchar * mime "type/subtype". - -1999-07-28 bertrand <Bertrand.Guiheneuf@aful.org> - - - * camel/data-wrapper-repository.c - * camel/data-wrapper-repository.h - New files. Handles mime type <-> camel object - (for example "multipart" <-> CamelMultipart - * tests/tesst3.c: test data repository thing. - -1999-07-26 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-multipart.c (_write_to_stream): - implemented output of multipart. - - * tests/test1.c (main): testing content objects operations. - -1999-07-25 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-part.c (camel_mime_part_set_text): - new util function to set a mime part content to be - a text string. - - * camel/camel-simple-data-wrapper.c (camel_simple_data_wrapper_set_buffer_from_text): - new util func. - (camel_simple_data_wrapper_new): new func. - - * camel/camel-multipart.c (_write_to_stream): - implemented output of multiparts. - -1999-07-24 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/gmime-content-field.c (gmime_content_field_get_parameter): - New function. Returns the value associated to a - mime parameter. - - -1999-07-22 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-multipart.h: - * camel/camel-multipart.c: - New class. Models multipart mime objects. - - * camel/camel-mime-body-part.h: - * camel/camel-mime-body-part.c: - New class. Body part is a mime part contained in - a multipart object. - - -1999-07-21 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-log.h: - implemented hard log level stuff. - * came/*.c use "CAMEL_LOG_*" instead of "CAMEL_LOG (*" - in order to allow hard level switch. - - * tests/test1.c: - * tests/test2.c: - updated to use gchar instead of GString. Tests passed. - - -1999-07-19 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-stream.c: - * camel/camel-stream.h: - "const"-antified - - - * camel/camel-simple-data-wrapper.c: (_construct_from_stream) - do not use any limit when constructing the object from a stream - - * camel/camel-stream-fs.c: - * camel/camel-stream-fs.h: - * camel/camel-mime-message.c: - * camel/camel-mime-message.h: - * camel/camel-session.c: - * camel/camel-session.h: - * camel/camel-service.c: - * camel/camel-service.h: - * camel/camel-store.c: - * camel/camel-store.h: - * camel/camel-folder.c: - * camel/camel-folder.h: - * camel/gmime-utils.c: - * camel/gmime-utils.h: - GString -> gchar - constantified what had to be. - - * camel/string-utils.c: - * camel/string-utils.h: - New files. Meant to replace gstring-util for gchar * - -1999-07-16 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/gmime-content-field.c (gmime_content_field_construct_from_string): - GString -> gchar - use const to indicate copied parameter. - -1999-07-15 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-simple-data-wrapper.c: - * camel/camel-simple-data-wrapper.h: - Gstring -> gchar - -1999-07-15 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/url-util.c: - * camel/url-util.h: - Do not use GStrings any more. - Added assertion code. - Cosmetic reformating - - * AUTHORS: - * ChangeLog: - Changed my email address. - - -1999-07-13 Miguel de Icaza <miguel@gnu.org> - - * camel/gmime-base64.c (gmime_encode_base64): Implemented base64 - encoder based on CamelStreams. Should the encoder/decoder be a - Stream itself? - - * camel/gmime-utils.c: include config.h here. - * camel/url-util.c: ditto. - * camel/gstring-util.c: ditto. - * camel/gmime-content-field.c: ditto. - * camel/camel-stream.c: ditto. - * camel/camel-stream-fs.c: ditto. - * camel/camel-store.c: ditto. - * camel/camel-simple-data-wrapper.c: ditto. - * camel/camel-session.c: ditto. - * camel/camel-service.c: ditto. - * camel/camel-mime-part.c: ditto. - * camel/camel-mime-message.c: ditto. - * camel/camel-log.c: ditto. - * camel/camel-data-wrapper.c: ditto - * camel/camel-folder.c: ditto. - - * camel/camel-stream.c (camel_stream_write): Moved api - documentation to the places that they document. - (camel_stream_class_init): Virtual classes do not need to have a - default implementation. So null them all. - (camel_stream_write): Return value from write. - (camel_stream_available): implement. - (camel_stream_write_strings): documented. - - * devel-docs/query/virtual-folder-in-depth.sgml: Small - reformatting - -1999-06-28 bertrand <Bertrand.Guiheneuf@aful.org> - - * tests/test2.c (main): now use - CamelDataWrapper::contruct_form_stream to test - message parsing - - * camel/camel-data-wrapper.c: - * camel/camel-data-wrapper.h: - construct_from_stream no longer has maximimum size arg. - - * camel/camel-mime-part.c (_construct_from_stream): new. - Construct the mime_part from a stream. - - * camel/camel-mime-part.c: - new field (content_type) and associated methods. - (camel_mime_part_init): initialize content_type field. - (_parse_header_pair): now set content_type MimePart field - instead of using DataWrapper Mime typing facility. - -1999-06-28 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-data-wrapper.h: - s/content_type/mime_type/ - -1999-06-24 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-simple-data-wrapper.[ch]: - new class. Simple implementation of a data wrapper: - simply keeps the stream result in a byte array. - - * camel/camel-mime-part.c (_parse_header_pair): added a warning. - Have to think about the correct way to store content type stuff. - -1999-06-24 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-message.c (_write_one_recipient_to_stream): - includes gmime-utils header. - patch from Ulrich Drepper <drepper at cygnus.com> - set separator string in write_header_with_glist_to_stream() - - * camel/camel-log.c (camel_log): - patch from Ulrich Drepper <drepper at cygnus.com> - Do not use stderr in initialization of logfile descriptor. - - * camel/camel-stream-fs.c (camel_stream_fs_new_with_name): - patch from Ulrich Drepper <drepper at cygnus.com> - initialize mode field in open(). - -1999-06-22 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-data-wrapper.c (_get_content_type): - moved all the content-type stuff here. - (camel_data_wrapper_init): initialize the instance - content-type field. - - * camel/camel-mime-part.c (_parse_header_pair): - parse Content-Type stuff in header. - (_write_to_stream): write the content type stuff to - the stream. - - * camel/gmime-content-field.c (gmime_content_field_get_mime_type): - new function, returns "type/subtype" mime type string. - (gmime_content_field_construct_from_string): - new function, construbt a content_field object - form a string. be used to set the mime_type from a - string. - - * camel/camel-mime-part.c (_set_content_type): - (camel_mime_part_set_content_type): - (_get_content_type): - (_get_content_type): - new methods. - -1999-06-21 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/gmime-utils.c (get_header_table_from_stream): - replace CR/LF+'\t' with ' ' - - * camel/camel-mime-message.c (_set_recipient_list_from_string): - trim \t when splitting - - * camel/gmime-utils.c (get_header_table_from_file): - corrected bug in scanning tabulations ('t' -> '\t') - - * tests/test2.c (main): read mail.test instead - of mail1.test - - * camel/camel-mime-part.c (_add_header): - added comments - -1999-06-03 bertrand <Bertrand.Guiheneuf@aful.org> - - * devel-docs/query/virtual-folder-in-depth.sgml: - sgmlized Giao's doc about virtual folders. - -1999-05-31 bertrand <Bertrand.Guiheneuf@aful.org> - - * tests/test2.c (main): - use new stream code instead of raw file * stuff. - - * camel/gmime-utils.c (get_header_table_from_stream): - new func. Will replace get_header_table_from_file and will - be used to parse headers from files as well as from - memory buffers. - - * camel/camel-stream-fs.c: - CamelStream Subclass. File system based - stream. - - -1999-05-30 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-stream.h: new class. Represents an - abstract stream object. - - * camel/camel-mime-message.c (_set_recipient_list_from_string): - remove leading and trailing spaces in recipient addresses. - - * camel/gmime-utils.c (_store_header_pair_from_gstring): - remove leading and trailing spaces from header values. - - * camel/gstring-util.c (g_string_trim): new - func: remove leading or trailng chars from - a specified char set. - (g_string_split): allow trimming of substrings. - - * tests/test1.c (main): remove gtk_main call - -1999-05-28 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-part.c - (_parse_header_pair): - (_init_header_name_table): - More header parsing code. - - -1999-05-27 bertrand <Bertrand.Guiheneuf@aful.org> - - * tests/test2.c (main): rewrite message obtained via - parsing into a file. Actually, it works pretty well :)) - - * camel/camel-mime-message.c (_set_recipient_list_from_string): - create recipient list form a comma separated string. - (_parse_header_pair): added recipient lists parsing. - - * camel/camel-mime-part.c (_parse_header_pair): - new (protected) method. Parse a head pair and - decides what to do with it. - - (_add_header): Call in _parse_header_pair - - * camel/camel-mime-message.c (_parse_header_pair): - overload header parsing MimePart mthod. - - * camel/gstring-util.c (g_string_split): - new func: split a gstring into a GList of - substring. - -1999-05-26 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/gmime-utils.c (get_header_lines_from_file): - new func. Parses message header zone and returns - a Glist of all header lines. - - * tests/test2.c: tests message parsing - - * camel/gmime-utils.c (write_header_table_to_file): - new func to write a table of headers. - -1999-05-20 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-message.c (_write_to_file): - recipient list printing - - * tests/test1.c (main): more tests. - -1999-05-19 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-part.c (_write_to_file): test if content - exists before calling its write_to method. - - * camel/camel-mime-message.c (_write_to_file): bugs fix. - - * camel/camel-mime-message.c (camel_mime_message_new_with_session): - new func. Creates a message with the session field set - up correctly. - -1999-05-18 bertrand <Bertrand.Guiheneuf@aful.org> - - * tests/test1.c (main): tests - - * camel/camel-mime-message.c (_write_to_file): - started write_to framework for mime_messages - - * camel/camel-mime-message.c (*_message_number): - message number funcs. - -1999-05-15 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-message.c (*_flag): - flags handling methods - -1999-05-14 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-message.c (camel_mime_message_class_init): - added recipient handling class funcs. - -1999-05-13 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-message.c (camel_mime_message_init): - create recipients hash table - (_remove_recipient): - (_add_recipient): - (_get_recipients): new funcs. - Internal Recipients data structure is - a bit complicated though. - - * camel/camel-mime-part.c (camel_mime_part_init): - create headers hash table - - * camel/camel-mime-message.h: - a bunch of get/set header field - method done. Does nothing yet though. - - * camel/camel-mime-message.[ch] : - new file. - -1999-05-12 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-part.h (struct ): - disposition is now a full GMimeContentField - object. - - * camel/gmime-content-field.c: new file - handle "type/subtype ;parameter=value ; parameter=value ..." - BNF grammar elements - (gmime_content_field_write_to_file): new func - - * camel/gmime-utils.c (gmime_write_header_pair_to_file): - namespace change - -1999-05-11 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-part.c (_write_to_file): - overload wrapper class method. - (_write_to_file): start to write some text in - file. - - * camel/camel-store.c: typo fix. - - * camel/camel-store.c: - * camel/camel-service.c: - * camel/camel-folder.c: - * camel/camel-data-wrapper.c: - * camel/camel-mime-part.c: - static functions naming follows gnome - coding style guide. - - * camel/camel-mime-part.h: implemented public interfaces - - -1999-05-10 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-part.c (__camel_mime_part_get_header_lines): - (__camel_mime_part_set_header_lines): - (__camel_mime_part_get_content_languages): - (__camel_mime_part_set_content_languages): - (__camel_mime_part_get_encoding): - (__camel_mime_part_set_encoding): - (__camel_mime_part_get_content_MD5): - (__camel_mime_part_set_content_MD5): - (__camel_mime_part_get_content_id): - (__camel_mime_part_set_content_id): - A bunch of new set/get func. - - * camel/gstring-util.c (g_string_list_free): - convenience function for string list - complete deallocation. - -1999-05-09 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-part.c (__camel_mime_part_add_header): - new method - - * camel/camel-mime-part.h (struct CamelMimePart): - added core fields. - -1999-05-08 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-mime-part.[ch]: - new class. models a mime mail part. - - * camel/camel-data-wrapper.c - (camel_data_wrapper_write_to_buffer): method to - stream data content in a buffer. - (camel_data_wrapper_write_to_file): - (camel_data_wrapper_construct_from_buffer): - (camel_data_wrapper_construct_from_file): - new methods. - -1999-05-07 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-data-wrapper.[ch]:new class. - This should not be a class but rather an - interface. The day Gtk support interfaces, - it dataWrapper should become an interface. - -1999-05-04 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-service.c (camel_service_get_url): - new method. - - * devel-docs/camel/camel-sections.txt: added - function doc references - - * camel/camel-folder.c (__camel_folder_close): - fixed indentation. - (camel_folder_expunge): new method. - (__camel_folder_close): used expunge flag - -1999-05-03 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-folder.c (camel_folder_get_mode): - typo fix - - * camel/camel-folder.c (__camel_folder_list_subfolders): - new func. - - * some doc stuffs - - -1999-05-01 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-folder.c - (__camel_folder_get_mode): - (camel_folder_get_mode): - (camel_folder_get_parent_store): - (__camel_folder_get_parent_store): - (camel_folder_get_parent_folder): - (__camel_folder_get_parent_folder): - new methods - - * camel/camel-service.c: put __ prefix before - private virtual funcs. - - * camel/camel-folder.c (camel_folder_delete): - (camel_folder_delete_messages): - new methods. - - * camel/url-util.c (g_url_new): some - more comments - -1999-04-27 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-folder.c (camel_folder_create): - new public function. - -1999-04-25 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-session.c (camel_session_get_store_from_provider): - initialize folder object. - - * camel/camel-store.c (init): new method. - called by session object at instantiation time. - - * camel/camel-store.h (struct _CamelStore): - new fields : session and url_name - -1999-04-25 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-session.c (camel_session_set_provider): - new method to set the default provider for a protocol. - (camel_session_get_store_from_provider): - new method to instantiate a folder from a provider. - - * camel/camel-provider.h: s/GString/gchar/g - + typo fix. - - * camel/camel-provider.[ch]: - basic provider structure. Have to write the - code for dynamic loading. - -1999-04-24 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/url-util.[ch]: s/new_g_url/g_url_new - - * camel/url-util.c (new_g_url): URL - rewritten completely. Error handling not - implemented in public functions. - But URL scan works pretty well :))) - -1999-04-24 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/url-util.[ch]: I needed the url - functions to use GString, and I wanted a more - general scheme so I finally started rewriting - the whole thing from scratch. - No more code from gzilla :( - -1999-04-23 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/url-util.[ch]: - Utility functions to parse URLs. - Stolen shamelessly from gzilla (www.gzilla.com) - written by Raph Levien <raph@acm.org> - - * camel/Makefile.am: added url-util.[ch] - compilation. - - * Makefile.am (SUBDIRS): removed devel-docs - until I come up with a correct Makefile.am - - * camel/camel-store.h: - * camel/camel-folder.h: - correct declarations of structs - - -1999-04-22 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/providers/MH/camel-mh-store.c: - more test implementation. - - * camel/camel-store.c (camel_store_get_type): typo fix - - -1999-04-21 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/providers/MH/camel-mh-folder.c (camel_mh_folder_get_type): - start test provider. - -1999-04-20 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-store.h: now CamelStore inherits from - CamelService. - - * camel/camel-service.c (camel_service_class_init): - basic abstract service class. - -1999-04-19 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/README: added some (few) explanations. - -1999-04-18 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-store.[ch]: started implementation - * camel/camel-folder.c (camel_folder_get_type): typo - uncommented the store related code. - (camel_folder_create): enable som store relted code. - Not finished. Have to define public methods first. - - * camel/camel-log.h: some explanation about the - log system - -1999-04-18 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-folder.c: - (camel_folder_create): implemented (partially) - have to write CamelStore before finishing it. - - * camel/camel-folder.h (CamelFolder): added full_name field - (CamelFolderClass): added set/get_full_name methods - -1999-04-18 bertrand <Bertrand.Guiheneuf@aful.org> - - * camel/camel-folder.c: some work - * camel/camel-log.c: log system for camel - * camel/gstring-util.c: some utilities for GString objects - - -1999-04-18 bertrand <Bertrand.Guiheneuf@aful.org> - - * autogen.sh (PKG_NAME): groomf -> gnome-mailer - diff --git a/INSTALL b/INSTALL deleted file mode 100644 index b42a17ac46..0000000000 --- a/INSTALL +++ /dev/null @@ -1,182 +0,0 @@ -Basic Installation -================== - - These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, a file -`config.cache' that saves the results of its tests to speed up -reconfiguring, and a file `config.log' containing compiler output -(useful mainly for debugging `configure'). - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If at some point `config.cache' -contains results you don't want to keep, you may remove or edit it. - - The file `configure.in' is used to create `configure' by a program -called `autoconf'. You only need `configure.in' if you want to change -it or regenerate `configure' using a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. You can give `configure' -initial values for variables by setting them in the environment. Using -a Bourne-compatible shell, you can do that on the command line like -this: - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure - -Or on systems that have the `env' program, you can do it like this: - env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not supports the `VPATH' -variable, you have to compile the package for one architecture at a time -in the source code directory. After you have installed the package for -one architecture, use `make distclean' before reconfiguring for another -architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' can not figure out -automatically, but needs to determine by the type of host the package -will run on. Usually `configure' can figure that out, but if it prints -a message saying it can not guess the host type, give it the -`--host=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name with three fields: - CPU-COMPANY-SYSTEM - -See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the host type. - - If you are building compiler tools for cross-compiling, you can also -use the `--target=TYPE' option to select the type of system they will -produce code for and the `--build=TYPE' option to select the type of -system on which you are compiling the package. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Operation Controls -================== - - `configure' recognizes the following options to control how it -operates. - -`--cache-file=FILE' - Use and save the results of the tests in FILE instead of - `./config.cache'. Set FILE to `/dev/null' to disable caching, for - debugging `configure'. - -`--help' - Print a summary of the options to `configure', and exit. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--version' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`configure' also accepts some other, not widely useful, options. diff --git a/MAINTAINERS b/MAINTAINERS deleted file mode 100644 index b9e2e7819d..0000000000 --- a/MAINTAINERS +++ /dev/null @@ -1,2 +0,0 @@ -Email: Bertrand.Guiheneuf@aful.org - diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 280f2610c4..0000000000 --- a/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -SUBDIRS = \ - po \ - macros \ - camel \ - composer \ - tests - -dist-hook: - for subdir in intl ; do \ - mkdir $(distdir)/$$subdir ; \ - cp -pr $(srcdir)/$$subdir $(distdir) ; \ - done @@ -1,8 +0,0 @@ -01/Jun/1999 ------------ - -New development document from Giao Nguyen : -TITLE: An in-depth look at the virtual folder mechanism -(see devel-docs/query) - - diff --git a/README b/README deleted file mode 100644 index 9b4f6c7ca8..0000000000 --- a/README +++ /dev/null @@ -1,3 +0,0 @@ -This is the future gnome mailer. - -See camel/README for details about the mail library.
\ No newline at end of file diff --git a/acconfig.h b/acconfig.h deleted file mode 100644 index 4ac725695e..0000000000 --- a/acconfig.h +++ /dev/null @@ -1,14 +0,0 @@ -#undef ENABLE_NLS -#undef HAVE_CATGETS -#undef HAVE_GETTEXT -#undef HAVE_LC_MESSAGES -#undef HAVE_STPCPY -#undef HAVE_LIBSM -#undef PACKAGE -#undef VERSION -#undef HAVE_BONOBO -#undef CAMEL_HARD_LOG_LEVEL - -/* Define this if you want to build against the development gtk */ -#undef HAVE_DEVGTK - diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index eec4b5f56d..0000000000 --- a/autogen.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# Run this to generate all the initial makefiles, etc. - -srcdir=`dirname $0` -test -z "$srcdir" && srcdir=. - -PKG_NAME="evolution" - - -. $srcdir/macros/autogen.sh diff --git a/camel/.cvsignore b/camel/.cvsignore deleted file mode 100644 index fd6b811c68..0000000000 --- a/camel/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -.deps -Makefile -Makefile.in -.libs -.deps -*.lo -*.la diff --git a/camel/CODING.STYLE b/camel/CODING.STYLE deleted file mode 100644 index a236f0060f..0000000000 --- a/camel/CODING.STYLE +++ /dev/null @@ -1,19 +0,0 @@ -Note to hackers ---------------- - -When hacking on camel (and on the gnome mailer in general), -be sure to follow the same coding style as the intial authors. -Please read the file HACKING in gnumeric and follow the -general guidelines explained in it. - -Please take a look at camel source files and try to exactly -imitate the coding style. We are perfectly aware that this -is not the best and unique style, but it is absolutely -mandatory that Camel is homogeneous. If you find the current -coding style to have some weaknesses, please contact the -authors to discuss this matter. - -Thanks. - - Bertrand. - diff --git a/camel/Makefile.am b/camel/Makefile.am deleted file mode 100644 index 8e74253eac..0000000000 --- a/camel/Makefile.am +++ /dev/null @@ -1,117 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = #providers - -libcamelincludedir = $(includedir)/camel - - -lib_LTLIBRARIES = libcamel.la - -INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \ - -I$(top_srcdir)/intl \ - $(GTK_INCLUDEDIR) - - -if HAVE_PTHREAD - -pthread_SRC = \ - camel-folder-pt-proxy.c \ - camel-thread-proxy.c - -pthread_HDR = \ - camel-folder-pt-proxy.h \ - camel-thread-proxy.h - -else - -libcamel_pthread_SRC = -libcamel_pthread_HDR= - -endif - - -libcamel_la_SOURCES = \ - camel.c \ - camel-log.c \ - camel-data-wrapper.c \ - camel-exception.c \ - camel-simple-data-wrapper.c \ - camel-simple-data-wrapper-stream.c \ - camel-stream-data-wrapper.c \ - camel-folder.c \ - camel-folder-summary.c \ - camel-medium.c \ - camel-marshal-utils.c \ - camel-mime-body-part.c \ - camel-mime-message.c \ - camel-mime-part.c \ - camel-mime-part-utils.c \ - camel-multipart.c \ - camel-op-queue.c \ - camel-provider.c \ - camel-recipient.c \ - camel-service.c \ - camel-session.c \ - camel-store.c \ - camel-stream.c \ - camel-stream-buffered-fs.c \ - camel-stream-fs.c \ - camel-stream-mem.c \ - data-wrapper-repository.c \ - gmime-base64.c \ - gmime-content-field.c \ - gmime-utils.c \ - gstring-util.c \ - hash-table-utils.c \ - md5-utils.c \ - string-utils.c \ - url-util.c \ - $(pthread_SRC) - -libcamelinclude_HEADERS = \ - camel.h \ - camel-log.h \ - camel-data-wrapper.h \ - camel-exception.h \ - camel-simple-data-wrapper.h \ - camel-simple-data-wrapper-stream.h \ - camel-stream-data-wrapper.h \ - camel-folder.h \ - camel-folder-summary.h \ - camel-mime-body-part.h \ - camel-marshal-utils.h \ - camel-medium.h \ - camel-mime-message.h \ - camel-mime-part.h \ - camel-mime-part-utils.h \ - camel-multipart.h \ - camel-op-queue.h \ - camel-provider.h \ - camel-recipient.h \ - camel-service.h \ - camel-session.h \ - camel-store.h \ - camel-stream.h \ - camel-stream-buffered-fs.h \ - camel-stream-fs.h \ - camel-stream-mem.h \ - data-wrapper-repository.h \ - gmime-base64.h \ - gmime-content-field.h \ - gmime-utils.h \ - gstring-util.h \ - hash-table-utils.h \ - md5-utils.h \ - string-utils.h \ - url-util.h \ - camel-exception-list.def \ - $(pthread_HDR) - -libcamel_extra_sources = \ - camel-arg-collector.c - -libcamel_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) - -EXTRA_DIST = \ - $(libcamel_extra_sources) \ - README diff --git a/camel/README b/camel/README deleted file mode 100644 index 44f93fa6d8..0000000000 --- a/camel/README +++ /dev/null @@ -1,57 +0,0 @@ - - CAMEL - - - A generic Messaging Library - - - ---- - - -Introduction: -------------- - -Camel will be a generic messaging library. It will evntually support -the standard messaging system for receiving and sending messages. -It aims at being the backend for the future gnome-mailer system. - -The name "camel" stands for ... nothing. Open area of developpement there. -You know, that "bazaar" thing. Maybe could we organize a big contest on -gnome-list to find the best signification :) - -Camel draws heacily from JavaMail and the IMAP4rev1 RFC. -people wanting to hack on a provider are recommended to read the JavaMail -API specification but CMC and MAPI are of interest too. - -Please, before starting anything, wait for me to finish the abstract classes. -Some parts are not definitive yet. - - -Organization: -------------- - -The library is roughly a set of abstract classes, some kind of generic -"interfaces" (idl interfaces, not java interfaces ). - -Particular implementations are called providers. - -Here are the basic objects: - -* CamelService : an abstract class representing an access to a server. -Handles the connection and authentication to any server. - -* CamelStore (CamelService): A hierarchy of folders on a server. - -* CamelFolder : An object containing messages. A folder is always associated -to a store. - -* CamelMessage : An object contained in folders. Is defined by a set of -attribute and a content. (Attributes are generally: The date it was received, -the sender address, .....) - -* CamelTransport (CamelService): A way to send messages. - -.... -... - - diff --git a/camel/README.COPYRIGHT b/camel/README.COPYRIGHT deleted file mode 100644 index 4597bc34d8..0000000000 --- a/camel/README.COPYRIGHT +++ /dev/null @@ -1,47 +0,0 @@ -Important note for Camel hackers: ---------------------------------- - -Camel has been a lot of work, and has been conceived to be general -enough to be used outside the gnome-mailer. It is possible in the -future that it is used in softwares with licenses incompatible with the -LGPL. For this reason, the copyright has to be owned by a unique -person. Be sure, however, that Camel will always be available under -the LGPL. Significant authors will always be consulted before any -special use of Camel. Moreover, in special situations, they may be -given the authorization to use Camel with a license different than the -LGPL. - -Thus, when adding code in Camel, always add the following lines at the -begining of the file: - -/* - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -You may also want to add your name to the author name list after this -header. - -Please contact me (Bertrand.Guiheneuf@aful.org) if you want to discuss -this copyright issue. - -Happy hacking, - -Bertrand. - - diff --git a/camel/README.HACKING b/camel/README.HACKING deleted file mode 100644 index a4742ee7b8..0000000000 --- a/camel/README.HACKING +++ /dev/null @@ -1,14 +0,0 @@ -You want to hack on Camel ? - -Thanks. Camel aims at being the best messaging -library for Linux and your help is welcome. -Please be sure to read the following files before -commiting any change or sending any patch: - -CODING.STYLE -README.COPYRIGHT - - -Thanks. - - Bertrand <Bertrand.Guiheneuf@aful.org>
\ No newline at end of file diff --git a/camel/camel-arg-collector.c b/camel/camel-arg-collector.c deleted file mode 100644 index 091cc82251..0000000000 --- a/camel/camel-arg-collector.c +++ /dev/null @@ -1,186 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -/* - * included in camel because it is not exported - * by gtk - * - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - */ - -/* collect a single argument value from a va_list. - * this is implemented as a huge macro <shrug>, because we can't - * pass va_list variables by reference on some systems. - * the corresponding prototype would be: - * static inline gchar* - * gtk_arg_collect_value (GtkArg *arg, - * va_list var_args); - */ -#define CAMEL_ARG_COLLECT_VALUE(arg, var_args, _error) \ -G_STMT_START { \ - gchar *error_msg; \ - GtkType fundamental_type; \ - \ - fundamental_type = GTK_FUNDAMENTAL_TYPE (arg->type); \ - if (fundamental_type > GTK_TYPE_FUNDAMENTAL_LAST) \ - { \ - fundamental_type = gtk_type_get_varargs_type (fundamental_type); \ - if (!fundamental_type) \ - fundamental_type = GTK_FUNDAMENTAL_TYPE (arg->type); \ - } \ - \ - error_msg = NULL; \ - switch (fundamental_type) \ - { \ - case GTK_TYPE_INVALID: \ - error_msg = g_strdup ("invalid untyped argument"); \ - break; \ - \ - case GTK_TYPE_NONE: \ - /* we just ignore this type, since it arithmetically just requires \ - * us to not move the var_args pointer any further. callers need to \ - * check for the validity of GTK_TYPE_NONE themselves. \ - * \ - * error_msg = g_strdup ("invalid argument type `void'"); \ - */ \ - break; \ - \ - /* everything smaller than an int is guarranteed to be \ - * passed as an int \ - */ \ - case GTK_TYPE_CHAR: \ - GTK_VALUE_CHAR (*arg) = va_arg (var_args, gint); \ - break; \ - case GTK_TYPE_UCHAR: \ - GTK_VALUE_UCHAR (*arg) = va_arg (var_args, guint); \ - break; \ - case GTK_TYPE_BOOL: \ - GTK_VALUE_BOOL (*arg) = va_arg (var_args, gint); \ - break; \ - case GTK_TYPE_INT: \ - GTK_VALUE_INT (*arg) = va_arg (var_args, gint); \ - break; \ - case GTK_TYPE_UINT: \ - GTK_VALUE_UINT (*arg) = va_arg (var_args, guint); \ - break; \ - case GTK_TYPE_ENUM: \ - GTK_VALUE_ENUM (*arg) = va_arg (var_args, gint); \ - break; \ - case GTK_TYPE_FLAGS: \ - GTK_VALUE_FLAGS (*arg) = va_arg (var_args, guint); \ - break; \ - \ - /* we collect longs as glongs since they differ in size with \ - * integers on some platforms \ - */ \ - case GTK_TYPE_LONG: \ - GTK_VALUE_LONG (*arg) = va_arg (var_args, glong); \ - break; \ - case GTK_TYPE_ULONG: \ - GTK_VALUE_ULONG (*arg) = va_arg (var_args, gulong); \ - break; \ - \ - /* floats are always passed as doubles \ - */ \ - case GTK_TYPE_FLOAT: \ - /* GTK_VALUE_FLOAT (*arg) = va_arg (var_args, gfloat); */ \ - GTK_VALUE_FLOAT (*arg) = va_arg (var_args, gdouble); \ - break; \ - case GTK_TYPE_DOUBLE: \ - GTK_VALUE_DOUBLE (*arg) = va_arg (var_args, gdouble); \ - break; \ - \ - /* collect pointer values \ - */ \ - case GTK_TYPE_STRING: \ - GTK_VALUE_STRING (*arg) = va_arg (var_args, gchar*); \ - break; \ - case GTK_TYPE_POINTER: \ - GTK_VALUE_POINTER (*arg) = va_arg (var_args, gpointer); \ - break; \ - case GTK_TYPE_BOXED: \ - GTK_VALUE_BOXED (*arg) = va_arg (var_args, gpointer); \ - break; \ - \ - /* structured types \ - */ \ - case GTK_TYPE_SIGNAL: \ - GTK_VALUE_SIGNAL (*arg).f = va_arg (var_args, GtkSignalFunc); \ - GTK_VALUE_SIGNAL (*arg).d = va_arg (var_args, gpointer); \ - break; \ - case GTK_TYPE_ARGS: \ - GTK_VALUE_ARGS (*arg).n_args = va_arg (var_args, gint); \ - GTK_VALUE_ARGS (*arg).args = va_arg (var_args, GtkArg*); \ - break; \ - case GTK_TYPE_FOREIGN: \ - GTK_VALUE_FOREIGN (*arg).data = va_arg (var_args, gpointer); \ - GTK_VALUE_FOREIGN (*arg).notify = va_arg (var_args, GtkDestroyNotify); \ - break; \ - case GTK_TYPE_CALLBACK: \ - GTK_VALUE_CALLBACK (*arg).marshal = va_arg (var_args, GtkCallbackMarshal); \ - GTK_VALUE_CALLBACK (*arg).data = va_arg (var_args, gpointer); \ - GTK_VALUE_CALLBACK (*arg).notify = va_arg (var_args, GtkDestroyNotify); \ - break; \ - case GTK_TYPE_C_CALLBACK: \ - GTK_VALUE_C_CALLBACK (*arg).func = va_arg (var_args, GtkFunction); \ - GTK_VALUE_C_CALLBACK (*arg).func_data = va_arg (var_args, gpointer); \ - break; \ - \ - /* we do some extra sanity checking when collecting objects, \ - * i.e. if the object pointer is not NULL, we check whether we \ - * actually got an object pointer within the desired class branch. \ - */ \ - case GTK_TYPE_OBJECT: \ - GTK_VALUE_OBJECT (*arg) = va_arg (var_args, GtkObject*); \ - if (GTK_VALUE_OBJECT (*arg) != NULL) \ - { \ - register GtkObject *object = GTK_VALUE_OBJECT (*arg); \ - \ - if (object->klass == NULL) \ - error_msg = g_strconcat ("invalid unclassed object pointer for argument type `", \ - gtk_type_name (arg->type), \ - "'", \ - NULL); \ - else if (!gtk_type_is_a (GTK_OBJECT_TYPE (object), arg->type)) \ - error_msg = g_strconcat ("invalid object `", \ - gtk_type_name (GTK_OBJECT_TYPE (object)), \ - "' for argument type `", \ - gtk_type_name (arg->type), \ - "'", \ - NULL); \ - } \ - break; \ - \ - default: \ - error_msg = g_strconcat ("unsupported argument type `", \ - gtk_type_name (arg->type), \ - "'", \ - NULL); \ - break; \ - } \ - \ - _error = error_msg; /* return error_msg; */ \ -} G_STMT_END diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c deleted file mode 100644 index 5c5ac86eef..0000000000 --- a/camel/camel-data-wrapper.c +++ /dev/null @@ -1,252 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelDataWrapper.c : Abstract class for a data_wrapper */ - -/** THIS IS MOSTLY AN ABSTRACT CLASS THAT SHOULD HAVE BEEN AN - INTERFACE. **/ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "camel-data-wrapper.h" -#include "camel-log.h" - -static GtkObjectClass *parent_class=NULL; - -/* Returns the class for a CamelDataWrapper */ -#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (GTK_OBJECT(so)->klass) - -static void _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -static void _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -static void _set_mime_type (CamelDataWrapper *data_wrapper, gchar *mime_type); -static gchar *_get_mime_type (CamelDataWrapper *data_wrapper); -static GMimeContentField *_get_mime_type_field (CamelDataWrapper *data_wrapper); -static void _set_mime_type_field (CamelDataWrapper *data_wrapper, GMimeContentField *mime_type); -static CamelStream *_get_stream (CamelDataWrapper *data_wrapper); -static void _finalize (GtkObject *object); - -static void -camel_data_wrapper_class_init (CamelDataWrapperClass *camel_data_wrapper_class) -{ - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_data_wrapper_class); - - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - camel_data_wrapper_class->write_to_stream = _write_to_stream; - camel_data_wrapper_class->construct_from_stream = _construct_from_stream; - camel_data_wrapper_class->set_mime_type = _set_mime_type; - camel_data_wrapper_class->get_mime_type = _get_mime_type; - camel_data_wrapper_class->get_mime_type_field = _get_mime_type_field; - camel_data_wrapper_class->set_mime_type_field = _set_mime_type_field; - camel_data_wrapper_class->get_stream = _get_stream; - - /* virtual method overload */ - gtk_object_class->finalize = _finalize; -} - - - - - -static void -camel_data_wrapper_init (gpointer object, gpointer klass) -{ - CamelDataWrapper *camel_data_wrapper = CAMEL_DATA_WRAPPER (object); - - CAMEL_LOG_FULL_DEBUG ( "camel_data_wrapper_init:: Entering\n"); - camel_data_wrapper->mime_type = gmime_content_field_new (NULL, NULL); - CAMEL_LOG_FULL_DEBUG ( "camel_data_wrapper_init:: Leaving\n"); -} - - - -GtkType -camel_data_wrapper_get_type (void) -{ - static GtkType camel_data_wrapper_type = 0; - - if (!camel_data_wrapper_type) { - GtkTypeInfo camel_data_wrapper_info = - { - "CamelDataWrapper", - sizeof (CamelDataWrapper), - sizeof (CamelDataWrapperClass), - (GtkClassInitFunc) camel_data_wrapper_class_init, - (GtkObjectInitFunc) camel_data_wrapper_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_data_wrapper_type = gtk_type_unique (gtk_object_get_type (), &camel_data_wrapper_info); - } - - return camel_data_wrapper_type; -} - - -static void -_finalize (GtkObject *object) -{ - CamelDataWrapper *camel_data_wrapper = CAMEL_DATA_WRAPPER (object); - - CAMEL_LOG_FULL_DEBUG ("Entering CamelDataWrapper::finalize\n"); - CAMEL_LOG_FULL_DEBUG ("CamelDataWrapper::finalize, finalizing object %p\n", object); - if (camel_data_wrapper->mime_type) - gmime_content_field_unref (camel_data_wrapper->mime_type); - - parent_class->finalize (object); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelDataWrapper::finalize\n"); -} - - -/** - * _write_to_stream: write data content in a byte stream - * @data_wrapper: the data wrapper object - * @stream byte stream where data will be written - * - * This method must be overriden by subclasses - * Data must be written in the bytes stream - * in a architecture independant fashion. - * If data is a standard data (for example an jpg image) - * it must be serialized in the strea exactly as it - * would be saved on disk. A simple dump of the stream in - * a file should be sufficient for the data to be - * re-read by a foreign application. - * - **/ -static void -_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - /* nothing */ -} - - -/** - * camel_data_wrapper_write_to_stream: write data in a stream - * @data_wrapper: the data wrapper object - * @stream: byte stream where data will be written - * - * Write data content in a stream. Data is stored in a machine - * independant format. - * - **/ -void -camel_data_wrapper_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CAMEL_LOG_FULL_DEBUG ( "camel_data_wrapper_write_to_stream:: Entering\n"); - CDW_CLASS(data_wrapper)->write_to_stream (data_wrapper, stream); - CAMEL_LOG_FULL_DEBUG ( "camel_data_wrapper_write_to_stream:: Leaving\n"); -} - - - - - - -static void -_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - /* nothing */ -} - -void -camel_data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CAMEL_LOG_FULL_DEBUG ( "camel_data_wrapper_construct_from_stream:: Entering\n"); - CDW_CLASS(data_wrapper)->construct_from_stream (data_wrapper, stream); - CAMEL_LOG_FULL_DEBUG ( "camel_data_wrapper_construct_from_stream:: Leaving\n"); -} - - - -static void -_set_mime_type (CamelDataWrapper *data_wrapper, gchar *mime_type) -{ - CAMEL_LOG_FULL_DEBUG ( "CamelDataWrapper::set_mime_type Entering\n"); - g_assert (mime_type); - gmime_content_field_construct_from_string (data_wrapper->mime_type, mime_type); - CAMEL_LOG_FULL_DEBUG ( "CamelDataWrapper::set_mime_type Leaving\n"); -} - -void -camel_data_wrapper_set_mime_type (CamelDataWrapper *data_wrapper, gchar *mime_type) -{ - CDW_CLASS(data_wrapper)->set_mime_type (data_wrapper, mime_type); -} - -static gchar * -_get_mime_type (CamelDataWrapper *data_wrapper) -{ - gchar *mime_type; - - mime_type = gmime_content_field_get_mime_type (data_wrapper->mime_type); - return mime_type; -} - -gchar * -camel_data_wrapper_get_mime_type (CamelDataWrapper *data_wrapper) -{ - CAMEL_LOG_FULL_DEBUG ( "camel_data_wrapper_get_mime_type:: Entering before returning\n"); - return CDW_CLASS(data_wrapper)->get_mime_type (data_wrapper); -} - - -static GMimeContentField * -_get_mime_type_field (CamelDataWrapper *data_wrapper) -{ - return data_wrapper->mime_type; -} - -GMimeContentField * -camel_data_wrapper_get_mime_type_field (CamelDataWrapper *data_wrapper) -{ - return CDW_CLASS(data_wrapper)->get_mime_type_field (data_wrapper); -} - - -static void -_set_mime_type_field (CamelDataWrapper *data_wrapper, GMimeContentField *mime_type) -{ - if (data_wrapper->mime_type) gmime_content_field_free (data_wrapper->mime_type); - data_wrapper->mime_type = mime_type; -} - -void -camel_data_wrapper_set_mime_type_field (CamelDataWrapper *data_wrapper, GMimeContentField *mime_type) -{ - CDW_CLASS(data_wrapper)->set_mime_type_field (data_wrapper, mime_type); -} - -static CamelStream * -_get_stream (CamelDataWrapper *data_wrapper) -{ - /* This needs to be implemented in subclasses. */ - return NULL; -} - -CamelStream * -camel_data_wrapper_get_stream (CamelDataWrapper *data_wrapper) -{ - CDW_CLASS(data_wrapper)->get_stream (data_wrapper); -} diff --git a/camel/camel-data-wrapper.h b/camel/camel-data-wrapper.h deleted file mode 100644 index 7e8fb8c72c..0000000000 --- a/camel/camel-data-wrapper.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelDataWrapper.h : Abstract class for a data wrapper */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_DATA_WRAPPER_H -#define CAMEL_DATA_WRAPPER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include <stdio.h> -#include "gmime-content-field.h" -#include "camel-stream.h" - - - -#define CAMEL_DATA_WRAPPER_TYPE (camel_data_wrapper_get_type ()) -#define CAMEL_DATA_WRAPPER(obj) (GTK_CHECK_CAST((obj), CAMEL_DATA_WRAPPER_TYPE, CamelDataWrapper)) -#define CAMEL_DATA_WRAPPER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_DATA_WRAPPER_TYPE, CamelDataWrapperClass)) -#define CAMEL_IS_DATA_WRAPPER(o) (GTK_CHECK_TYPE((o), CAMEL_DATA_WRAPPER_TYPE)) - - -typedef struct -{ - GtkObject parent_object; - - GMimeContentField *mime_type; -} CamelDataWrapper; - - - -typedef struct { - GtkObjectClass parent_class; - - /* Virtual methods */ - void (*write_to_stream) (CamelDataWrapper *data_wrapper, CamelStream *stream); - void (*construct_from_stream) (CamelDataWrapper *data_wrapper, CamelStream *stream); - void (*set_mime_type) (CamelDataWrapper *data_wrapper, gchar * mime_type); - gchar * (*get_mime_type) (CamelDataWrapper *data_wrapper); - GMimeContentField * (*get_mime_type_field) (CamelDataWrapper *data_wrapper); - void (*set_mime_type_field) (CamelDataWrapper *data_wrapper, GMimeContentField *mime_type_field); - CamelStream * (*get_stream) (CamelDataWrapper *data_wrapper); -} CamelDataWrapperClass; - - - -/* Standard Gtk function */ -GtkType camel_data_wrapper_get_type (void); - - -/* public methods */ - -void camel_data_wrapper_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -void camel_data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -void camel_data_wrapper_set_mime_type (CamelDataWrapper *data_wrapper, gchar *mime_type); -gchar *camel_data_wrapper_get_mime_type (CamelDataWrapper *data_wrapper); -GMimeContentField *camel_data_wrapper_get_mime_type_field (CamelDataWrapper *data_wrapper); -void camel_data_wrapper_set_mime_type_field (CamelDataWrapper *data_wrapper, GMimeContentField *mime_type); -CamelStream *camel_data_wrapper_get_stream (CamelDataWrapper *data_wrapper); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_DATA_WRAPPER_H */ diff --git a/camel/camel-exception-list.def b/camel/camel-exception-list.def deleted file mode 100644 index 67c8a13a57..0000000000 --- a/camel/camel-exception-list.def +++ /dev/null @@ -1 +0,0 @@ -CAMEL_EXCEPTION_NONE, diff --git a/camel/camel-exception.c b/camel/camel-exception.c deleted file mode 100644 index f1f806bbac..0000000000 --- a/camel/camel-exception.c +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-execpetion.c : exception utils */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include <config.h> -#include "camel-exception.h" - -void -camel_exception_free (CamelException *exception) -{ - if (!exception) return; - - if (exception->desc) - g_free (exception->desc); - - g_free (exception); -} - - -CamelException * -camel_exception_new () -{ - CamelException *ex; - - ex = g_new (CamelException, 1); - return ex; -} - - -void -camel_exception_set (CamelException *ex, - ExceptionId id, - const char *desc) -{ - ex->id = id; - if (ex->desc) - g_free (ex->desc); - ex->desc = g_strdup (desc); -} - -void -camel_exception_xfer (CamelException *ex_dst, - CamelException *ex_src) -{ - if (ex_dst->desc) - g_free (ex_dst->desc); - - ex_dst->id = ex_src->id; - ex_dst->desc = ex_src->desc; - - ex_src->desc = NULL; - ex_src->id = CAMEL_EXCEPTION_NONE; -} diff --git a/camel/camel-exception.h b/camel/camel-exception.h deleted file mode 100644 index 112f2fac3e..0000000000 --- a/camel/camel-exception.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-execpetion.h : exception utils */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - -#ifndef CAMEL_EXCEPTION_H -#define CAMEL_EXCEPTION_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <glib.h> - - -typedef enum { -#include "camel-exception-list.def" - -} ExceptionId; - -typedef struct { - - ExceptionId id; - char *desc; - -} CamelException; - -void camel_exception_free (CamelException *exception); -CamelException *camel_exception_new (); -void camel_exception_set (CamelException *ex, - ExceptionId id, - const char *desc); -void camel_exception_xfer (CamelException *ex_dst, - CamelException *ex_src); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_EXCEPTION_H */ - diff --git a/camel/camel-folder-pt-proxy.c b/camel/camel-folder-pt-proxy.c deleted file mode 100644 index d554b70d30..0000000000 --- a/camel/camel-folder-pt-proxy.c +++ /dev/null @@ -1,831 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-folder-pt-proxy.c : proxy folder using posix threads */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - -#include <config.h> -#include "camel-folder-pt-proxy.h" -#include "camel-log.h" -#include "camel-marshal-utils.h" -#include "camel-exception.h" -#include <pthread.h> -#include <unistd.h> -#include <string.h> -#include <errno.h> - - -static CamelFolderClass *parent_class=NULL; - -/* Returns the class for CamelFolderPtProxy and CamelFolder objects */ -#define CFPP_CLASS(so) CAMEL_FOLDER_PT_PROXY_CLASS (GTK_OBJECT(so)->klass) -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) - - -enum CamelFolderFunc { - CAMEL_FOLDER_OPEN, - CAMEL_FOLDER_CLOSE, - CAMEL_FOLDER__LAST_FUNC -}; - -static CamelFuncDef _camel_func_def [CAMEL_FOLDER__LAST_FUNC]; - - -static void _init_with_store (CamelFolder *folder, - CamelStore *parent_store, - CamelException *ex); -static void _open (CamelFolder *folder, - CamelFolderOpenMode mode, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex); -static void _close (CamelFolder *folder, - gboolean expunge, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex); -static void _set_name (CamelFolder *folder, - const gchar *name, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex); - -static const gchar *_get_name (CamelFolder *folder, CamelException *ex); -static const gchar *_get_full_name (CamelFolder *folder, CamelException *ex); -static gboolean _can_hold_folders (CamelFolder *folder, CamelException *ex); -static gboolean _can_hold_messages(CamelFolder *folder, CamelException *ex); -static gboolean _exists (CamelFolder *folder, CamelException *ex); -static gboolean _is_open (CamelFolder *folder, CamelException *ex); -static CamelFolder *_get_folder (CamelFolder *folder, const gchar *folder_name, CamelException *ex); -static gboolean _create (CamelFolder *folder, CamelException *ex); -static gboolean _delete (CamelFolder *folder, gboolean recurse, CamelException *ex); -static gboolean _delete_messages (CamelFolder *folder, CamelException *ex); -static CamelFolder *_get_parent_folder (CamelFolder *folder, CamelException *ex); -static CamelStore *_get_parent_store (CamelFolder *folder, CamelException *ex); -static CamelFolderOpenMode _get_mode (CamelFolder *folder, CamelException *ex); -static GList *_list_subfolders (CamelFolder *folder, CamelException *ex); -static void _expunge (CamelFolder *folder, CamelException *ex); -static CamelMimeMessage *_get_message (CamelFolder *folder, gint number, CamelException *ex); -static gint _get_message_count (CamelFolder *folder, CamelException *ex); -static gint _append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); -static const GList *_list_permanent_flags (CamelFolder *folder, CamelException *ex); -static void _copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder, CamelException *ex); - -static const gchar *_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); -static CamelMimeMessage *_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex); -static GList *_get_uid_list (CamelFolder *folder, CamelException *ex); - -static void _finalize (GtkObject *object); - - -static void -camel_folder_pt_proxy_class_init (CamelFolderPtProxyClass *camel_folder_pt_proxy_class) -{ - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_folder_pt_proxy_class); - CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_folder_pt_proxy_class); - CamelFolderPtProxyClass *proxy_class = camel_folder_pt_proxy_class; - - parent_class = gtk_type_class (camel_folder_get_type ()); - - /* virtual method definition */ - camel_folder_class->init_with_store = _init_with_store; - camel_folder_class->open = _open; - camel_folder_class->close = _close; - camel_folder_class->set_name = _set_name; - camel_folder_class->get_name = _get_name; - camel_folder_class->can_hold_folders = _can_hold_folders; - camel_folder_class->can_hold_messages = _can_hold_messages; - camel_folder_class->exists = _exists; - camel_folder_class->is_open = _is_open; - camel_folder_class->get_folder = _get_folder; - camel_folder_class->create = _create; - camel_folder_class->delete = _delete; - camel_folder_class->delete_messages = _delete_messages; - camel_folder_class->get_parent_folder = _get_parent_folder; - camel_folder_class->get_parent_store = _get_parent_store; - camel_folder_class->get_mode = _get_mode; - camel_folder_class->list_subfolders = _list_subfolders; - camel_folder_class->expunge = _expunge; - camel_folder_class->get_message = _get_message; - camel_folder_class->get_message_count = _get_message_count; - camel_folder_class->append_message = _append_message; - camel_folder_class->list_permanent_flags = _list_permanent_flags; - camel_folder_class->copy_message_to; - camel_folder_class->get_message_uid = _get_message_uid; - camel_folder_class->get_message_by_uid = _get_message_by_uid; - camel_folder_class->get_uid_list = _get_uid_list; - - /* virtual method overload */ - gtk_object_class->finalize = _finalize; - - /* function definition for proxying */ - proxy_class->open_func_def = - camel_func_def_new (camel_marshal_NONE__POINTER_INT_POINTER_POINTER, - 4, - GTK_TYPE_POINTER, - GTK_TYPE_INT, - GTK_TYPE_POINTER, - GTK_TYPE_POINTER); - proxy_class->open_cb_def = - camel_func_def_new (camel_marshal_NONE__POINTER_POINTER_POINTER, - 3, - GTK_TYPE_POINTER, - GTK_TYPE_POINTER, - GTK_TYPE_POINTER); - - proxy_class->close_func_def = - camel_func_def_new (camel_marshal_NONE__POINTER_BOOL_POINTER_POINTER, - 4, - GTK_TYPE_POINTER, - GTK_TYPE_BOOL, - GTK_TYPE_POINTER, - GTK_TYPE_POINTER); - proxy_class->close_cb_def = - camel_func_def_new (camel_marshal_NONE__POINTER_POINTER_POINTER, - 3, - GTK_TYPE_POINTER, - GTK_TYPE_POINTER, - GTK_TYPE_POINTER); - - proxy_class->set_name_func_def = - camel_func_def_new (camel_marshal_NONE__POINTER_BOOL_POINTER_POINTER, - 4, - GTK_TYPE_POINTER, - GTK_TYPE_BOOL, - GTK_TYPE_POINTER, - GTK_TYPE_POINTER); - proxy_class->set_name_cb_def = - camel_func_def_new (camel_marshal_NONE__POINTER_POINTER_POINTER, - 3, - GTK_TYPE_POINTER, - GTK_TYPE_POINTER, - GTK_TYPE_POINTER); - -} - - - - -static void -camel_folder_pt_proxy_init (CamelFolderPtProxy *folder_pt_proxy) -{ - folder_pt_proxy->thread_ex = camel_exception_new (); - folder_pt_proxy->pud = g_new (_ProxyCbUserData, 1); -} - - - - -GtkType -camel_folder_pt_proxy_get_type (void) -{ - static GtkType camel_folder_pt_proxy_type = 0; - - if (!camel_folder_pt_proxy_type) { - GtkTypeInfo camel_folder_pt_proxy_info = - { - "CamelFolderPtProxy", - sizeof (CamelFolderPtProxy), - sizeof (CamelFolderPtProxyClass), - (GtkClassInitFunc) camel_folder_pt_proxy_class_init, - (GtkObjectInitFunc) camel_folder_pt_proxy_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_folder_pt_proxy_type = gtk_type_unique (gtk_object_get_type (), &camel_folder_pt_proxy_info); - } - - return camel_folder_pt_proxy_type; -} - - -static void -_finalize (GtkObject *object) -{ - CamelFolder *camel_folder = CAMEL_FOLDER (object); - CamelFolderPtProxy *camel_folder_pt_proxy = CAMEL_FOLDER_PT_PROXY (camel_folder); - GList *message_node; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelFolderPtProxy::finalize\n"); - - camel_exception_free (camel_folder_pt_proxy->thread_ex); - g_free (camel_folder_pt_proxy->pud); - GTK_OBJECT_CLASS (parent_class)->finalize (object); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelFolderPtProxy::finalize\n"); -} - - - - - - -/*********/ - -/**** Operations implementation ****/ - - - -static gpointer -_proxy_cb_user_data (_ProxyCbUserData *pud, - CamelFolderAsyncCallback real_callback, - CamelFolderPtProxy *proxy_folder, - CamelException *ex, - gpointer real_user_data) -{ - pud->real_callback = real_callback; - pud->proxy_folder = proxy_folder; - pud->ex = ex; - pud->real_user_data = real_user_data; - return (gpointer)pud; -} - - -/* ******** */ - -/* thread->init_with_store implementation */ -static void -_init_with_store (CamelFolder *folder, - CamelStore *parent_store, - CamelException *ex) -{ - - parent_class->init_with_store (folder, parent_store, ex); - if (ex->id != CAMEL_EXCEPTION_NONE) - return; -#warning use proxy store here - CF_CLASS (folder)->init_with_store (CAMEL_FOLDER_PT_PROXY (folder)->real_folder, - parent_store, - ex); -} - - - -/* a little bit of explanation for the folder_class->open - * method implementation : - * - * the proxy object "open" method is called by the client - * program in the main thread. This method creates a - * CamelOp object containing all the necessary informations - * to call the corresponding "open" method on the real - * folder object in the child thread. This CamelOp object - * is thus pushed in a queue in the main thread (see the - * CamelThreadProxy structure for more details). - * The operations in this queue are executed one by one - * in a child thread. - * Once the "open" method of the real object is finished, - * it calls a callback. This callback is not the one supplied - * by the client object. Instead, the _folder_open_cb() - * function is called (in the child thread) which pushes - * the real callback function in another operation queue. - * The real callback is then called in the main thread. - */ - -/* folder->open implementation */ - -/* - * proxy callback. Called in the child thread by the - * real folder "open" method when it is completed - */ -static void -_folder_open_cb (CamelFolder *folder, - gpointer user_data, - CamelException *ex) -{ - CamelOp *cb; - _ProxyCbUserData *pud; - CamelFuncDef *cb_def; - - /* transfer the exception information from "ex" to the - * client supplied exception (kept in pud->ex) */ - camel_exception_xfer (pud->ex, ex); - - /* create an operation which will call the real client - * supplied callback in the main thread */ - cb_def = CAMEL_FOLDER_PT_PROXY_CLASS(pud->proxy_folder)->open_cb_def; - cb = camel_marshal_create_op (cb_def, - pud->real_callback, - pud->proxy_folder, - pud->real_user_data, - pud->ex); - camel_thread_proxy_push_cb (pud->proxy_folder->proxy_object, cb); - -} - - -static void -_open (CamelFolder *folder, - CamelFolderOpenMode mode, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - CamelOp *op; - CamelFuncDef *func_def; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - - /* create an operation corresponding to the "open" - * method of the real object. The operation definition - * is common to all instances of the CamelFolderPtProxy - * class so it is contained in the CamelFolderPtProxyClass - * structure. */ - func_def = CAMEL_FOLDER_PT_PROXY_CLASS(proxy_folder)->open_func_def; - if (callback) - op = camel_marshal_create_op (func_def, - CAMEL_FOLDER_CLASS (proxy_folder->real_folder)->open, - proxy_folder->real_folder, - mode, - _folder_open_cb, - _proxy_cb_user_data (proxy_folder->pud, callback, proxy_folder, ex, user_data), - proxy_folder->thread_ex); - else - op = camel_marshal_create_op (func_def, - CAMEL_FOLDER_CLASS (proxy_folder->real_folder)->open, - proxy_folder->real_folder, - mode, - NULL, - NULL, - NULL); - /* push the operation in the operation queue. This operation - * will be executed in a child thread but only one operation - * will be executed at a time, so that folder implementations - * don't have to be MultiThread safe. */ - camel_thread_proxy_push_op (proxy_folder->proxy_object, op); -} - - - - - -/* folder->close implementation */ - -static void -_folder_close_cb (CamelFolder *folder, - gpointer user_data, - CamelException *ex) -{ - CamelOp *cb; - _ProxyCbUserData *pud; - CamelFuncDef *cb_def; - - camel_exception_xfer (pud->ex, ex); - cb_def = CAMEL_FOLDER_PT_PROXY_CLASS(pud->proxy_folder)->close_cb_def; - cb = camel_marshal_create_op (cb_def, - pud->real_callback, - pud->proxy_folder, - pud->real_user_data, - pud->ex); - camel_thread_proxy_push_cb (pud->proxy_folder->proxy_object, cb); - -} - -static void -_close (CamelFolder *folder, - gboolean expunge, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - CamelOp *op; - CamelFuncDef *func_def; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - - func_def = CAMEL_FOLDER_PT_PROXY_CLASS(proxy_folder)->close_func_def; - if (callback) - op = camel_marshal_create_op (func_def, - CAMEL_FOLDER_CLASS (proxy_folder->real_folder)->close, - proxy_folder->real_folder, - expunge, - _folder_close_cb, - _proxy_cb_user_data (proxy_folder->pud, callback, proxy_folder, ex, user_data), - proxy_folder->thread_ex); - else - op = camel_marshal_create_op (func_def, - CAMEL_FOLDER_CLASS (proxy_folder->real_folder)->close, - proxy_folder->real_folder, - expunge, - NULL, - NULL, - NULL); - camel_thread_proxy_push_op (proxy_folder->proxy_object, op); - -} - - - - -/* folder->set_name implementation */ -static void -_folder_set_name_cb (CamelFolder *folder, - gpointer user_data, - CamelException *ex) -{ - CamelOp *cb; - _ProxyCbUserData *pud; - CamelFuncDef *cb_def; - - camel_exception_xfer (pud->ex, ex); - cb_def = CAMEL_FOLDER_PT_PROXY_CLASS(pud->proxy_folder)->set_name_cb_def; - cb = camel_marshal_create_op (cb_def, - pud->real_callback, - pud->proxy_folder, - pud->real_user_data, - pud->ex); - camel_thread_proxy_push_cb (pud->proxy_folder->proxy_object, cb); -} - -static void -_set_name (CamelFolder *folder, - const gchar *name, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - CamelOp *op; - CamelFuncDef *func_def; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - - func_def = CAMEL_FOLDER_PT_PROXY_CLASS(proxy_folder)->close_func_def; - if (callback) - op = camel_marshal_create_op (func_def, - CAMEL_FOLDER_CLASS (proxy_folder->real_folder)->set_name, - proxy_folder->real_folder, - name, - _folder_set_name_cb, - _proxy_cb_user_data (proxy_folder->pud, callback, proxy_folder, ex, user_data), - proxy_folder->thread_ex); - else - op = camel_marshal_create_op (func_def, - CAMEL_FOLDER_CLASS (proxy_folder->real_folder)->set_name, - proxy_folder->real_folder, - name, - NULL, - NULL, - NULL); - camel_thread_proxy_push_op (proxy_folder->proxy_object, op); - -} - - -/* folder->get_name implementation */ -/* this one is not executed in a thread */ -static const gchar * -_get_name (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - get_name (proxy_folder->real_folder, ex); -} - - - -/* folder->get_full_name implementation */ -/* this one is not executed in a thread */ - -static const gchar * -_get_full_name (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - get_full_name (proxy_folder->real_folder, ex); -} - - - - -static gboolean -_can_hold_folders (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - can_hold_folders (proxy_folder->real_folder, ex); -} - - - - -static gboolean -_can_hold_messages (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - can_hold_messages (proxy_folder->real_folder, ex); -} - - - -static gboolean -_exists (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - exists (proxy_folder->real_folder, ex); -} - - - - -static gboolean -_is_open (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - is_open (proxy_folder->real_folder, ex); -} - - - - - -static CamelFolder * -_get_folder (CamelFolder *folder, const gchar *folder_name, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - get_folder (proxy_folder->real_folder, folder_name, ex); -} - - - - - - -static gboolean -_create(CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - create (proxy_folder->real_folder, ex); -} - - - - - - - - -static gboolean -_delete (CamelFolder *folder, gboolean recurse, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - delete (proxy_folder->real_folder, recurse, ex); -} - - - - - - - -static gboolean -_delete_messages (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - delete_messages (proxy_folder->real_folder, ex); -} - - - - - - -static CamelFolder * -_get_parent_folder (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; -#warning return proxy parent folder if any - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - get_parent_folder (proxy_folder->real_folder, ex); -} - - - - - -static CamelStore * -_get_parent_store (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - get_parent_store (proxy_folder->real_folder, ex); -} - - - - -static CamelFolderOpenMode -_get_mode (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - get_mode (proxy_folder->real_folder, ex); -} - - - - -static GList * -_list_subfolders (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - list_subfolders (proxy_folder->real_folder, ex); -} - - - - -static void -_expunge (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - CF_CLASS (proxy_folder->real_folder)-> - expunge (proxy_folder->real_folder, ex); -} - - - - -static CamelMimeMessage * -_get_message (CamelFolder *folder, gint number, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - get_message (proxy_folder->real_folder, number, ex); -} - - - - - -static gint -_get_message_count (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - get_message_count (proxy_folder->real_folder, ex); -} - - - - -static gint -_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - append_message (proxy_folder->real_folder, message, ex); -} - - - -static const GList * -_list_permanent_flags (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - list_permanent_flags (proxy_folder->real_folder, ex); -} - - - -static void -_copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - CF_CLASS (proxy_folder->real_folder)-> - copy_message_to (proxy_folder->real_folder, message, dest_folder, ex); -} - - - - - - -/* UIDs stuff */ - - -static const gchar * -_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - get_message_uid (proxy_folder->real_folder, message, ex); -} - - -/* the next two func are left there temporarily */ -#if 0 -static const gchar * -_get_message_uid_by_number (CamelFolder *folder, gint message_number, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - get_message_uid_by_number (proxy_folder->real_folder, message_number, ex); -} - -#endif - -static CamelMimeMessage * -_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - get_message_by_uid (proxy_folder->real_folder, uid, ex); -} - - -static GList * -_get_uid_list (CamelFolder *folder, CamelException *ex) -{ - CamelFolderPtProxy *proxy_folder; - - proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); - return CF_CLASS (proxy_folder->real_folder)-> - get_uid_list (proxy_folder->real_folder, ex); -} - - -/* **** */ - - - - - diff --git a/camel/camel-folder-pt-proxy.h b/camel/camel-folder-pt-proxy.h deleted file mode 100644 index dd0d87c7d5..0000000000 --- a/camel/camel-folder-pt-proxy.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-folder-pt-proxy.h : proxy folder using posix threads */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - - - -#ifndef CAMEL_FOLDER_PT_PROXY_H -#define CAMEL_FOLDER_PT_PROXY_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include "camel-folder.h" -#include "camel-op-queue.h" -#include "camel-thread-proxy.h" - - -#define CAMEL_FOLDER_PT_PROXY_TYPE (camel_folder_pt_proxy_get_type ()) -#define CAMEL_FOLDER_PT_PROXY(obj) (GTK_CHECK_CAST((obj), CAMEL_FOLDER_PT_PROXY_TYPE, CamelFolderPtProxy)) -#define CAMEL_FOLDER_PT_PROXY_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_FOLDER_PT_PROXY_TYPE, CamelFolderPtProxyClass)) -#define CAMEL_IS_FOLDER_PT_PROXY(o) (GTK_CHECK_TYPE((o), CAMEL_FOLDER_PT_PROXY_TYPE)) - -typedef struct _CamelFolderPtProxy CamelFolderPtProxy; - -typedef struct { - CamelFolderAsyncCallback real_callback; - CamelFolderPtProxy *proxy_folder; - CamelException *ex; - gpointer real_user_data; -} _ProxyCbUserData; - -struct _CamelFolderPtProxy { - CamelFolder parent; - - /* private fields */ - CamelFolder *real_folder; - CamelThreadProxy *proxy_object; - CamelException *thread_ex; - _ProxyCbUserData *pud; - -}; - - - -typedef struct { - CamelFolderClass parent_class; - - /* functions and callbacks definition (for marshalling) */ - CamelFuncDef *open_func_def; - CamelFuncDef *open_cb_def; - CamelFuncDef *close_func_def; - CamelFuncDef *close_cb_def; - CamelFuncDef *set_name_func_def; - CamelFuncDef *set_name_cb_def; - -} CamelFolderPtProxyClass; - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_FOLDER_PT_PROXY_H */ diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c deleted file mode 100644 index 39583c3dfe..0000000000 --- a/camel/camel-folder-summary.c +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelFolderSummary.c : Abstract class for a folder_summary */ - - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "camel-folder-summary.h" -#include "camel-log.h" - -static GtkObjectClass *parent_class=NULL; - -/* Returns the class for a CamelFolderSummary */ -#define CFS_CLASS(so) CAMEL_FOLDER_SUMMARY_CLASS (GTK_OBJECT(so)->klass) - - -static const GList *_get_subfolder_info_list (CamelFolderSummary *summary); -static const GList *_get_message_info_list (CamelFolderSummary *summary); - -static void _finalize (GtkObject *object); - -static void -camel_folder_summary_class_init (CamelFolderSummaryClass *camel_folder_summary_class) -{ - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_folder_summary_class); - - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - camel_folder_summary_class->get_subfolder_info_list = _get_subfolder_info_list; - camel_folder_summary_class->get_message_info_list = _get_message_info_list; - - - /* virtual method overload */ - gtk_object_class->finalize = _finalize; -} - - - - - -static void -camel_folder_summary_init (gpointer object, gpointer klass) -{ - CamelFolderSummary *summary = CAMEL_FOLDER_SUMMARY (object); - - CAMEL_LOG_FULL_DEBUG ( "camel_folder_summary_init:: Entering\n"); - summary->subfolder_info_list = NULL; - summary->message_info_list = NULL; - CAMEL_LOG_FULL_DEBUG ( "camel_folder_summary_init:: Leaving\n"); -} - - - -GtkType -camel_folder_summary_get_type (void) -{ - static GtkType camel_folder_summary_type = 0; - - if (!camel_folder_summary_type) { - GtkTypeInfo camel_folder_summary_info = - { - "CamelFolderSummary", - sizeof (CamelFolderSummary), - sizeof (CamelFolderSummaryClass), - (GtkClassInitFunc) camel_folder_summary_class_init, - (GtkObjectInitFunc) camel_folder_summary_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_folder_summary_type = gtk_type_unique (gtk_object_get_type (), &camel_folder_summary_info); - } - - return camel_folder_summary_type; -} - - -static void -_finalize (GtkObject *object) -{ - CamelFolderSummary *camel_folder_summary = CAMEL_FOLDER_SUMMARY (object); - - CAMEL_LOG_FULL_DEBUG ("Entering CamelFolderSummary::finalize\n"); - CAMEL_LOG_FULL_DEBUG ("CamelFolderSummary::finalize, finalizing object %p\n", object); - - parent_class->finalize (object); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelFolderSummary::finalize\n"); -} - - -CamelFolderSummary * -camel_folder_summary_new () -{ - return gtk_type_new (CAMEL_FOLDER_SUMMARY_TYPE); -} - -static const GList * -_get_subfolder_info_list (CamelFolderSummary *summary) -{ - return summary->subfolder_info_list; -} - - -const GList * -camel_folder_summary_get_subfolder_info_list (CamelFolderSummary *summary) -{ - return CFS_CLASS (summary)->get_subfolder_info_list (summary); -} - - - - -static const GList * -_get_message_info_list (CamelFolderSummary *summary) -{ - return summary->message_info_list; -} - -const GList * -camel_folder_summary_get_message_info_list (CamelFolderSummary *summary) -{ - return CFS_CLASS (summary)->get_message_info_list (summary); -} - - diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h deleted file mode 100644 index bc8ea0be28..0000000000 --- a/camel/camel-folder-summary.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelFolderSummary.h : Abstract class for a folder summary */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_FOLDER_SUMMARY_H -#define CAMEL_FOLDER_SUMMARY_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> - - - -#define CAMEL_FOLDER_SUMMARY_TYPE (camel_folder_summary_get_type ()) -#define CAMEL_FOLDER_SUMMARY(obj) (GTK_CHECK_CAST((obj), CAMEL_FOLDER_SUMMARY_TYPE, CamelFolderSummary)) -#define CAMEL_FOLDER_SUMMARY_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_FOLDER_SUMMARY_TYPE, CamelFolderSummaryClass)) -#define CAMEL_IS_FOLDER_SUMMARY(o) (GTK_CHECK_TYPE((o), CAMEL_FOLDER_SUMMARY_TYPE)) - -typedef struct { - gchar *name; - gint nb_message; - gint nb_unread_message; - gint nb_deleted_message; - - GHashTable *extended_fields; -} CamelFolderInfo; - -typedef struct { - gchar *subject; - gchar *uid; - gchar *date; - gchar *sender; - - GHashTable *extended_fields; -} CamelMessageInfo; - - -typedef struct -{ - GtkObject parent_object; - - GList *subfolder_info_list; /* informations on subfolders */ - GList *message_info_list; /* informations on messages */ - -} CamelFolderSummary; - - - -typedef struct { - GtkObjectClass parent_class; - - /* Virtual methods */ - const GList * (*get_subfolder_info_list) (CamelFolderSummary *summary); - const GList * (*get_message_info_list) (CamelFolderSummary *summary); - -} CamelFolderSummaryClass; - - - -/* Standard Gtk function */ -GtkType camel_folder_summary_get_type (void); - - -/* public methods */ -CamelFolderSummary *camel_folder_summary_new (); -const GList *camel_folder_summary_get_subfolder_info_list (CamelFolderSummary *summary); -const GList *camel_folder_summary_get_message_info_list (CamelFolderSummary *summary); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_FOLDER_SUMMARY_H */ diff --git a/camel/camel-folder.c b/camel/camel-folder.c deleted file mode 100644 index cacfa318e0..0000000000 --- a/camel/camel-folder.c +++ /dev/null @@ -1,1187 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelFolder.c : Abstract class for an email folder */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "camel-folder.h" -#include "camel-log.h" -#include "string-utils.h" - -static GtkObjectClass *parent_class=NULL; - -/* Returns the class for a CamelFolder */ -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) - -static void _init_with_store (CamelFolder *folder, CamelStore *parent_store, CamelException *ex); -static void _open (CamelFolder *folder, - CamelFolderOpenMode mode, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex); -static void _close (CamelFolder *folder, - gboolean expunge, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex); -/* static void _set_name (CamelFolder *folder, const gchar *name, CamelException *ex); */ -static void _set_name (CamelFolder *folder, - const gchar *name, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex); -/* static void _set_full_name (CamelFolder *folder, const gchar *name); */ -static const gchar *_get_name (CamelFolder *folder, CamelException *ex); -static const gchar *_get_full_name (CamelFolder *folder, CamelException *ex); -static gboolean _can_hold_folders (CamelFolder *folder, CamelException *ex); -static gboolean _can_hold_messages(CamelFolder *folder, CamelException *ex); -static gboolean _exists (CamelFolder *folder, CamelException *ex); -static gboolean _is_open (CamelFolder *folder, CamelException *ex); -static CamelFolder *_get_folder (CamelFolder *folder, const gchar *folder_name, CamelException *ex); -static gboolean _create (CamelFolder *folder, CamelException *ex); -static gboolean _delete (CamelFolder *folder, gboolean recurse, CamelException *ex); -static gboolean _delete_messages (CamelFolder *folder, CamelException *ex); -static CamelFolder *_get_parent_folder (CamelFolder *folder, CamelException *ex); -static CamelStore *_get_parent_store (CamelFolder *folder, CamelException *ex); -static CamelFolderOpenMode _get_mode (CamelFolder *folder, CamelException *ex); -static GList *_list_subfolders (CamelFolder *folder, CamelException *ex); -static void _expunge (CamelFolder *folder, CamelException *ex); -static CamelMimeMessage *_get_message (CamelFolder *folder, gint number, CamelException *ex); -static gint _get_message_count (CamelFolder *folder, CamelException *ex); -static gint _append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); -static const GList *_list_permanent_flags (CamelFolder *folder, CamelException *ex); -static void _copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder, CamelException *ex); - -static const gchar *_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); -static CamelMimeMessage *_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex); -static GList *_get_uid_list (CamelFolder *folder, CamelException *ex); - - -static void _finalize (GtkObject *object); - - -static void -camel_folder_class_init (CamelFolderClass *camel_folder_class) -{ - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_folder_class); - - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - camel_folder_class->init_with_store = _init_with_store; - camel_folder_class->open = _open; - camel_folder_class->close = _close; - camel_folder_class->set_name = _set_name; - camel_folder_class->get_name = _get_name; - camel_folder_class->get_full_name = _get_full_name; - camel_folder_class->can_hold_folders = _can_hold_folders; - camel_folder_class->can_hold_messages = _can_hold_messages; - camel_folder_class->exists = _exists; - camel_folder_class->is_open = _is_open; - camel_folder_class->get_folder = _get_folder; - camel_folder_class->create = _create; - camel_folder_class->delete = _delete; - camel_folder_class->delete_messages = _delete_messages; - camel_folder_class->get_parent_folder = _get_parent_folder; - camel_folder_class->get_parent_store = _get_parent_store; - camel_folder_class->get_mode = _get_mode; - camel_folder_class->list_subfolders = _list_subfolders; - camel_folder_class->expunge = _expunge; - camel_folder_class->get_message = _get_message; - camel_folder_class->get_message_count = _get_message_count; - camel_folder_class->append_message = _append_message; - camel_folder_class->list_permanent_flags = _list_permanent_flags; - camel_folder_class->copy_message_to; - camel_folder_class->get_message_uid = _get_message_uid; - camel_folder_class->get_message_by_uid = _get_message_by_uid; - camel_folder_class->get_uid_list = _get_uid_list; - - /* virtual method overload */ - gtk_object_class->finalize = _finalize; -} - - - - - - - -GtkType -camel_folder_get_type (void) -{ - static GtkType camel_folder_type = 0; - - if (!camel_folder_type) { - GtkTypeInfo camel_folder_info = - { - "CamelFolder", - sizeof (CamelFolder), - sizeof (CamelFolderClass), - (GtkClassInitFunc) camel_folder_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_folder_type = gtk_type_unique (gtk_object_get_type (), &camel_folder_info); - } - - return camel_folder_type; -} - - -static void -_finalize (GtkObject *object) -{ - CamelFolder *camel_folder = CAMEL_FOLDER (object); - GList *message_node; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelFolder::finalize\n"); - - g_free (camel_folder->name); - g_free (camel_folder->full_name); - g_free (camel_folder->permanent_flags); - if (camel_folder->message_list) { - /* unref all messages got from the folder */ - message_node = camel_folder->message_list; - while (message_node) { - gtk_object_unref (GTK_OBJECT (message_node->data)); - g_list_next (message_node); - } - g_list_free (camel_folder->message_list); - } - GTK_OBJECT_CLASS (parent_class)->finalize (object); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelFolder::finalize\n"); -} - - -/** - * _init_with_store: init the folder by setting its parent store. - * @folder: folder object to initialize - * @parent_store: parent store object of the folder - * - * - **/ -static void -_init_with_store (CamelFolder *folder, CamelStore *parent_store, CamelException *ex) -{ - g_assert(folder); - g_assert(parent_store); - - if (folder->parent_store) gtk_object_unref (GTK_OBJECT (folder->parent_store)); - folder->parent_store = parent_store; - if (parent_store) gtk_object_ref (GTK_OBJECT (parent_store)); - folder->open_mode = FOLDER_OPEN_UNKNOWN; - folder->open_state = FOLDER_CLOSE; - folder->name = NULL; - folder->full_name = NULL; -} - - - - - -static void -_open (CamelFolder *folder, - CamelFolderOpenMode mode, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex) -{ -/* folder->open_state = FOLDER_OPEN; */ -/* folder->open_mode = mode; */ -} - -/** - * camel_folder_open: Open a folder - * @folder: The folder object - * @mode: open mode (R/W/RW ?) - * @callback: function to call when the operation is over - * @user_data: data to pass to the callback - * @ex: exception object - * - * Open a folder in a given mode. When the opration is over - * the callback is called and the client program can determine - * if the operation suceeded by examining the exception. - * - **/ -void -camel_folder_open (CamelFolder *folder, - CamelFolderOpenMode mode, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex) -{ - CF_CLASS(folder)->open (folder, mode, callback, user_data, ex); -} - - - - -static void -_close (CamelFolder *folder, - gboolean expunge, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex) -{ - folder->open_state = FOLDER_CLOSE; -} - -/** - * camel_folder_close: Close a folder. - * @folder: The folder object - * @expunge: if TRUE, the flagged message are deleted. - * @callback: function to call when the operation is over - * @user_data: data to pass to the callback - * @ex: exception object - * - * Put a folder in its closed state, and possibly - * expunge the flagged messages. The callback is called - * when the operation is over and the client program can determine - * if the operation suceeded by examining the exception. - * - **/ -void -camel_folder_close (CamelFolder *folder, - gboolean expunge, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex) -{ - CF_CLASS(folder)->close (folder, expunge, callback, user_data, ex); -} - - - -static void -_set_name (CamelFolder *folder, - const gchar *name, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex) -{ - gchar separator; - gchar *full_name; - const gchar *parent_full_name; - - g_assert (folder); - g_assert (name); - g_assert (folder->parent_store); - - g_free (folder->name); - g_free (folder->full_name); - - separator = camel_store_get_separator (folder->parent_store); - - if (folder->parent_folder) { - parent_full_name = camel_folder_get_full_name (folder->parent_folder, ex); - full_name = g_strdup_printf ("%s%d%s", parent_full_name, separator, name); - - } else { - full_name = g_strdup (name); - } - - folder->name = g_strdup (name); - folder->full_name = full_name; - -} - - -/** - * camel_folder_set_name:set the (short) name of the folder - * @folder: folder - * @name: new name of the folder - * - * set the name of the folder. - * - * - **/ -void -camel_folder_set_name (CamelFolder *folder, - const gchar *name, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex) -{ - CF_CLASS(folder)->set_name (folder, name, callback, user_data, ex); -} - - -#if 0 -static void -_set_full_name (CamelFolder *folder, const gchar *name, CamelException *ex) -{ - g_free(folder->full_name); - folder->full_name = g_strdup (name); -} - - -/** - * camel_folder_set_full_name:set the (full) name of the folder - * @folder: folder - * @name: new name of the folder - * - * set the name of the folder. - * - **/ -void -camel_folder_set_full_name (CamelFolder *folder, const gchar *name, CamelException *ex) -{ - CF_CLASS(folder)->set_full_name (folder, name, ex); -} -#endif - -static const gchar * -_get_name (CamelFolder *folder, CamelException *ex) -{ - return folder->name; -} - - -/** - * camel_folder_get_name: get the (short) name of the folder - * @folder: - * - * get the name of the folder. The fully qualified name - * can be obtained with the get_full_ame method (not implemented) - * - * Return value: name of the folder - **/ -const gchar * -camel_folder_get_name (CamelFolder *folder, CamelException *ex) -{ - return CF_CLASS(folder)->get_name (folder, ex); -} - - - -static const gchar * -_get_full_name (CamelFolder *folder, CamelException *ex) -{ - return folder->full_name; -} - -/** - * camel_folder_get_full_name:get the (full) name of the folder - * @folder: folder to get the name - * - * get the name of the folder. - * - * Return value: full name of the folder - **/ -const gchar * -camel_folder_get_full_name (CamelFolder *folder, CamelException *ex) -{ - return CF_CLASS(folder)->get_full_name (folder, ex); -} - - -/** - * _can_hold_folders: tests if the folder can contain other folders - * @folder: The folder object - * - * Tests if a folder can contain other folder - * (as for example MH folders) - * - * Return value: - **/ -static gboolean -_can_hold_folders (CamelFolder *folder, CamelException *ex) -{ - return folder->can_hold_folders; -} - - - - -/** - * _can_hold_messages: tests if the folder can contain messages - * @folder: The folder object - * - * Tests if a folder object can contain messages. - * In the case it can not, it most surely can only - * contain folders (rare). - * - * Return value: true if it can contain messages false otherwise - **/ -static gboolean -_can_hold_messages (CamelFolder *folder, CamelException *ex) -{ - return folder->can_hold_messages; -} - - - -static gboolean -_exists (CamelFolder *folder, CamelException *ex) -{ - return FALSE; -} - - -/** - * _exists: tests if the folder object exists in its parent store. - * @folder: folder object - * - * Test if a folder exists on a store. A folder can be - * created without physically on a store. In that case, - * use CamelFolder::create to create it - * - * Return value: true if the folder exists on the store false otherwise - **/ -gboolean -camel_folder_exists (CamelFolder *folder, CamelException *ex) -{ - return (CF_CLASS(folder)->exists (folder, ex)); -} - - - -/** - * _is_open: test if the folder is open - * @folder: The folder object - * - * Tests if a folder is open. If not open it can be opened - * CamelFolder::open - * - * Return value: true if the folder exists, false otherwise - **/ -static gboolean -_is_open (CamelFolder *folder, CamelException *ex) -{ - return (folder->open_state == FOLDER_OPEN); -} - - - - - -static CamelFolder * -_get_folder (CamelFolder *folder, const gchar *folder_name, CamelException *ex) -{ - CamelFolder *new_folder; - gchar *full_name; - const gchar *current_folder_full_name; - gchar separator; - - g_assert (folder); - g_assert (folder_name); - - if (!folder->parent_store) return NULL; - - current_folder_full_name = camel_folder_get_full_name (folder, ex); - if (!current_folder_full_name) return NULL; - - separator = camel_store_get_separator (folder->parent_store); - full_name = g_strdup_printf ("%s%d%s", current_folder_full_name, separator, folder_name); - - new_folder = camel_store_get_folder (folder->parent_store, full_name); - return new_folder; -} - - - -/** - * camel_folder_get_folder: return the (sub)folder object that is specified - * @folder: the folder - * @folder_name: subfolder path - * - * This method returns a folder objects. This folder - * is necessarily a subfolder of the current folder. - * It is an error to ask a folder begining with the - * folder separator character. - * - * Return value: Required folder. NULL if the subfolder object could not be obtained - **/ -CamelFolder * -camel_folder_get_folder (CamelFolder *folder, gchar *folder_name, CamelException *ex) -{ - return (CF_CLASS(folder)->get_folder(folder,folder_name, ex)); -} - - - - -/** - * _create: creates a folder on its store - * @folder: a CamelFolder object. - * - * this routine handles the recursion mechanism. - * Children classes have to implement the actual - * creation mechanism. They must call this method - * before physically creating the folder in order - * to be sure the parent folder exists. - * Calling this routine on an existing folder is - * not an error, and returns %TRUE. - * - * Return value: %TRUE if the folder exists, %FALSE otherwise - **/ -static gboolean -_create(CamelFolder *folder, CamelException *ex) -{ - gchar *prefix; - gchar dich_result; - CamelFolder *parent; - gchar sep; - - g_assert (folder); - g_assert (folder->parent_store); - g_assert (folder->name); - - if (CF_CLASS(folder)->exists (folder, ex)) - return TRUE; - - sep = camel_store_get_separator (folder->parent_store); - if (folder->parent_folder) - camel_folder_create (folder->parent_folder, ex); - else { - if (folder->full_name) { - dich_result = string_dichotomy ( - folder->full_name, sep, &prefix, NULL, - STRING_DICHOTOMY_STRIP_TRAILING | STRING_DICHOTOMY_RIGHT_DIR); - if (dich_result!='o') { - g_warning("I have to handle the case where the path is not OK\n"); - return FALSE; - } else { - parent = camel_store_get_folder (folder->parent_store, prefix); - camel_folder_create (parent, ex); - } - } - } - return TRUE; -} - - -/** - * camel_folder_create: create the folder object on the physical store - * @folder: folder object to create - * - * This routine physically creates the folder object on - * the store. Having created the object does not - * mean the folder physically exists. If it does not - * exists, this routine will create it. - * if the folder full name contains more than one level - * of hierarchy, all folders between the current folder - * and the last folder name will be created if not existing. - * - * Return value: - **/ -gboolean -camel_folder_create (CamelFolder *folder, CamelException *ex) -{ - return (CF_CLASS(folder)->create(folder, ex)); -} - - - - - -/** - * _delete: delete folder - * @folder: folder to delete - * @recurse: true is subfolders must also be deleted - * - * Delete a folder and its subfolders (if recurse is TRUE). - * The scheme is the following: - * 1) delete all messages in the folder - * 2) if recurse is FALSE, and if there are subfolders - * return FALSE, else delete current folder and retuen TRUE - * if recurse is TRUE, delete subfolders, delete - * current folder and return TRUE - * - * subclasses implementing a protocol with a different - * deletion behaviour must emulate this one or implement - * empty folders deletion and call this routine which - * will do all the works for them. - * Opertions must be done in the folllowing order: - * - call this routine - * - delete empty folder - * - * Return value: true if the folder has been deleted - **/ -static gboolean -_delete (CamelFolder *folder, gboolean recurse, CamelException *ex) -{ - GList *subfolders=NULL; - GList *sf; - gboolean ok; - - g_assert(folder); - - /* method valid only on closed folders */ - if (folder->open_state != FOLDER_CLOSE) return FALSE; - - /* delete all messages in the folder */ - CF_CLASS(folder)->delete_messages(folder, ex); - - subfolders = CF_CLASS(folder)->list_subfolders(folder, ex); - if (recurse) { /* delete subfolders */ - if (subfolders) { - sf = subfolders; - do { - /* CF_CLASS(sf->data)->delete(sf->data, TRUE, ex); */ - } while (sf = sf->next); - } - } else if (subfolders) return FALSE; - - - return TRUE; -} - - - -/** - * camel_folder_delete: delete a folder - * @folder: folder to delete - * @recurse: TRUE if subfolders must be deleted - * - * Delete a folder. All messages in the folder - * are deleted before the folder is deleted. - * When recurse is true, all subfolders are - * deleted too. When recurse is FALSE and folder - * contains subfolders, all messages are deleted, - * but folder deletion fails. - * - * Return value: TRUE if deletion was successful - **/ -gboolean camel_folder_delete (CamelFolder *folder, gboolean recurse, CamelException *ex) -{ - return CF_CLASS(folder)->delete(folder, recurse, ex); -} - - - - - -/** - * _delete_messages: delete all messages in the folder - * @folder: - * - * - * - * Return value: - **/ -static gboolean -_delete_messages (CamelFolder *folder, CamelException *ex) -{ - return TRUE; -} - - -/** - * camel_folder_delete_messages: delete all messages in the folder - * @folder: folder - * - * delete all messages stored in a folder - * - * Return value: TRUE if the messages could be deleted - **/ -gboolean -camel_folder_delete_messages (CamelFolder *folder, CamelException *ex) -{ - return CF_CLASS(folder)->delete_messages(folder, ex); -} - - - - - - -/** - * _get_parent_folder: return parent folder - * @folder: folder to get the parent - * - * - * - * Return value: - **/ -static CamelFolder * -_get_parent_folder (CamelFolder *folder, CamelException *ex) -{ - return folder->parent_folder; -} - - -/** - * camel_folder_get_parent_folder:return parent folder - * @folder: folder to get the parent - * - * - * - * Return value: - **/ -CamelFolder * -camel_folder_get_parent_folder (CamelFolder *folder, CamelException *ex) -{ - return CF_CLASS(folder)->get_parent_folder(folder, ex); -} - - -/** - * _get_parent_store: return parent store - * @folder: folder to get the parent - * - * - * - * Return value: - **/ -static CamelStore * -_get_parent_store (CamelFolder *folder, CamelException *ex) -{ - return folder->parent_store; -} - - -/** - * camel_folder_get_parent_store:return parent store - * @folder: folder to get the parent - * - * - * - * Return value: - **/ -CamelStore * -camel_folder_get_parent_store (CamelFolder *folder, CamelException *ex) -{ - return CF_CLASS(folder)->get_parent_store(folder, ex); -} - - - -/** - * _get_mode: return the open mode of a folder - * @folder: - * - * - * - * Return value: open mode of the folder - **/ -static CamelFolderOpenMode -_get_mode (CamelFolder *folder, CamelException *ex) -{ - return folder->open_mode; -} - - -/** - * camel_folder_get_mode: return the open mode of a folder - * @folder: - * - * - * - * Return value: open mode of the folder - **/ -CamelFolderOpenMode -camel_folder_get_mode (CamelFolder *folder, CamelException *ex) -{ - return CF_CLASS(folder)->get_mode(folder, ex); -} - - - - -static GList * -_list_subfolders (CamelFolder *folder, CamelException *ex) -{ - return NULL; -} - - -/** - * camel_folder_list_subfolders: list subfolders in a folder - * @folder: the folder - * - * List subfolders in a folder. - * - * Return value: list of subfolders - **/ -GList * -camel_folder_list_subfolders (CamelFolder *folder, CamelException *ex) -{ - return CF_CLASS(folder)->list_subfolders(folder, ex); -} - - - - -static void -_expunge (CamelFolder *folder, CamelException *ex) -{ - -} - -/* util func. Should not stay here */ -gint -camel_mime_message_number_cmp (gconstpointer a, gconstpointer b) -{ - CamelMimeMessage *m_a = CAMEL_MIME_MESSAGE (a); - CamelMimeMessage *m_b = CAMEL_MIME_MESSAGE (b); - - return (m_a->message_number - (m_b->message_number)); -} - -/** - * camel_folder_expunge: physically delete messages marked as "DELETED" - * @folder: the folder - * - * Delete messages which have been marked as "DELETED" - * - * - * Return value: list of expunged message objects. - **/ -GList * -camel_folder_expunge (CamelFolder *folder, gboolean want_list, CamelException *ex) -{ - GList *expunged_list = NULL; - CamelMimeMessage *message; - GList *message_node; - GList *next_message_node; - guint nb_expunged = 0; - - - /* sort message list by ascending message number */ - if (folder->message_list) - folder->message_list = g_list_sort (folder->message_list, camel_mime_message_number_cmp); - - /* call provider method, - * PROVIDERS MUST SET THE EXPUNGED FLAGS TO TRUE - * when they expunge a message of the active message list */ - CF_CLASS (folder)->expunge (folder, ex); - - message_node = folder->message_list; - - /* look in folder message list which messages - * need to be expunged */ - while ( message_node) { - message = CAMEL_MIME_MESSAGE (message_node->data); - - /* we may free message_node so get the next node now */ - next_message_node = message_node->next; - - if (message) { - CAMEL_LOG_FULL_DEBUG ("CamelFolder::expunge, examining message %d\n", message->message_number); - if (message->expunged) { - if (want_list) - expunged_list = g_list_append (expunged_list, message); - /* remove the message from active message list */ - g_list_remove_link (folder->message_list, message_node); - g_list_free_1 (message_node); - nb_expunged++; - } else { - /* readjust message number */ - CAMEL_LOG_FULL_DEBUG ("CamelFolder:: Readjusting message number %d", - message->message_number); - message->message_number -= nb_expunged; - CAMEL_LOG_FULL_DEBUG (" to %d\n", message->message_number); - } - } - else { - CAMEL_LOG_WARNING ("CamelFolder::expunge warning message_node contains no message\n"); - } - message_node = next_message_node; - CAMEL_LOG_FULL_DEBUG ("CamelFolder::expunge, examined message node %p\n", message_node); - } - - return expunged_list; -} - - - -static CamelMimeMessage * -_get_message (CamelFolder *folder, gint number, CamelException *ex) -{ - return NULL; -} - - - - -/** - * _get_message: return the message corresponding to that number in the folder - * @folder: a CamelFolder object - * @number: the number of the message within the folder. - * - * Return the message corresponding to that number within the folder. - * - * Return value: A pointer on the corresponding message or NULL if no corresponding message exists - **/ -CamelMimeMessage * -camel_folder_get_message (CamelFolder *folder, gint number, CamelException *ex) -{ -#warning this code has nothing to do here. - CamelMimeMessage *a_message; - CamelMimeMessage *new_message = NULL; - GList *message_node; - - message_node = folder->message_list; - CAMEL_LOG_FULL_DEBUG ("CamelFolder::get_message Looking for message nummber %d\n", number); - /* look in folder message list if the - * if the message has not already been retreived */ - while ((!new_message) && message_node) { - a_message = CAMEL_MIME_MESSAGE (message_node->data); - - if (a_message) { - CAMEL_LOG_FULL_DEBUG ("CamelFolder::get_message " - "found message number %d in the active list\n", - a_message->message_number); - if (a_message->message_number == number) { - CAMEL_LOG_FULL_DEBUG ("CamelFolder::get_message message " - "%d already retreived once: returning %pOK\n", - number, a_message); - new_message = a_message; - } - } else { - CAMEL_LOG_WARNING ("CamelFolder::get_message " - " problem in the active list, a message was NULL\n"); - } - message_node = message_node->next; - - CAMEL_LOG_FULL_DEBUG ("CamelFolder::get_message message node = %p\n", message_node); - } - if (!new_message) new_message = CF_CLASS (folder)->get_message (folder, number, ex); - if (!new_message) return NULL; - - /* if the message has not been already put in - * this folder active message list, put it in */ - if ((!folder->message_list) || (!g_list_find (folder->message_list, new_message))) - folder->message_list = g_list_append (folder->message_list, new_message); - - return new_message; -} - - -static gint -_get_message_count (CamelFolder *folder, CamelException *ex) -{ - return -1; -} - - - -/** - * camel_folder_get_message_count: get the number of messages in the folder - * @folder: A CamelFolder object - * - * Returns the number of messages in the folder. - * - * Return value: the number of messages or -1 if unknown. - **/ -gint -camel_folder_get_message_count (CamelFolder *folder, CamelException *ex) -{ - return CF_CLASS (folder)->get_message_count (folder, ex); -} - - -static gint -_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex) -{ - return -1; -} - - -gint camel_folder_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex) -{ - return CF_CLASS (folder)->append_message (folder, message, ex); -} - - -static const GList * -_list_permanent_flags (CamelFolder *folder, CamelException *ex) -{ - return folder->permanent_flags; -} - - -const GList * -camel_folder_list_permanent_flags (CamelFolder *folder, CamelException *ex) -{ - return CF_CLASS (folder)->list_permanent_flags (folder, ex); -} - - - - -static void -_copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder, CamelException *ex) -{ - camel_folder_append_message (dest_folder, message, ex); -} - - -void -camel_folder_copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder, CamelException *ex) -{ - CF_CLASS (folder)->copy_message_to (folder, message, dest_folder, ex);; -} - - - - - -/* summary stuff */ - -gboolean -camel_folder_has_summary_capability (CamelFolder *folder, CamelException *ex) -{ - return folder->has_summary_capability; -} - - -CamelFolderSummary * -camel_folder_get_summary (CamelFolder *folder, CamelException *ex) -{ - return folder->summary; -} - - - - -/* UIDs stuff */ - -/** - * camel_folder_has_uid_capability: detect if the folder support UIDs - * @folder: Folder object - * - * Detects if a folder supports UID operations, that is - * reference messages by a Unique IDentifier instead - * of by message number. - * - * Return value: TRUE if the folder supports UIDs - **/ -gboolean -camel_folder_has_uid_capability (CamelFolder *folder, CamelException *ex) -{ - return folder->has_uid_capability; -} - - - -static const gchar * -_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex) -{ - return NULL; -} - -/** - * camel_folder_get_message_uid: get the UID of a message in a folder - * @folder: Folder in which the UID must refer to - * @message: Message object - * - * Return the UID of a message relatively to a folder. - * A message can have different UID, each one corresponding - * to a different folder, if the message is referenced in - * several folders. - * - * Return value: The UID of the message in the folder - **/ -const gchar * -camel_folder_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex) -{ - if (!folder->has_uid_capability) return NULL; - return CF_CLASS (folder)->get_message_uid (folder, message, ex); -} - - - -/* the next two func are left there temporarily */ -static const gchar * -_get_message_uid_by_number (CamelFolder *folder, gint message_number, CamelException *ex) -{ - return NULL; -} - -/** - * camel_folder_get_message_uid_by_number: get the UID corresponding to a message number - * @folder: Folder object - * @message_number: Message number - * - * get the UID corresponding to a message number. - * Use of this routine should be avoiding, as on - * folders supporting UIDs, message numbers should - * not been used. - * - * Return value: - **/ -const gchar * -camel_folder_get_message_uid_by_number (CamelFolder *folder, gint message_number, CamelException *ex) -{ - /* if (!folder->has_uid_capability) return NULL; */ - /* return CF_CLASS (folder)->get_message_uid_by_number (folder, message_number, ex); */ -} - - -static CamelMimeMessage * -_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex) -{ - return NULL; -} - - -/** - * camel_folder_get_message_by_uid: Get a message by its UID in a folder - * @folder: the folder object - * @uid: the UID - * - * Get a message from its UID in the folder. Messages - * are cached within a folder, that is, asking twice - * for the same UID returns the same message object. - * - * Return value: Message corresponding to the UID - **/ -CamelMimeMessage * -camel_folder_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex) -{ - if (!folder->has_uid_capability) return NULL; - return CF_CLASS (folder)->get_message_by_uid (folder, uid, ex); -} - -static GList * -_get_uid_list (CamelFolder *folder, CamelException *ex) -{ - return NULL; -} - -/** - * camel_folder_get_uid_list: get the list of UID in a folder - * @folder: folder object - * - * get the list of UID available in a folder. This - * routine is usefull to know what messages are - * available when the folder does not support - * summaries. The UIDs in the list must not be freed, - * the folder object caches them. - * - * Return value: Glist of UID correspondind to the messages available in the folder. - **/ -GList * -camel_folder_get_uid_list (CamelFolder *folder, CamelException *ex) -{ - if (!folder->has_uid_capability) return NULL; - return CF_CLASS (folder)->get_uid_list (folder, ex); -} - - -/* **** */ diff --git a/camel/camel-folder.h b/camel/camel-folder.h deleted file mode 100644 index fcc84aaa04..0000000000 --- a/camel/camel-folder.h +++ /dev/null @@ -1,200 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelFolder.h : Abstract class for an email folder */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_FOLDER_H -#define CAMEL_FOLDER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> - -typedef struct _CamelFolder CamelFolder; - -#include "camel-store.h" -#include "camel-mime-message.h" -#include "camel-folder-summary.h" -#include "camel-exception.h" - -#define CAMEL_FOLDER_TYPE (camel_folder_get_type ()) -#define CAMEL_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_FOLDER_TYPE, CamelFolder)) -#define CAMEL_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_FOLDER_TYPE, CamelFolderClass)) -#define CAMEL_IS_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_FOLDER_TYPE)) - -typedef enum { - FOLDER_OPEN, - FOLDER_CLOSE -} CamelFolderState; - -typedef enum { - FOLDER_OPEN_UNKNOWN = 0, /* folder open mode is unknown */ - FOLDER_OPEN_READ = 1, /* folder is read only */ - FOLDER_OPEN_WRITE = 2, /* folder is write only */ - FOLDER_OPEN_RW = 3 /* folder is read/write */ -} CamelFolderOpenMode; - -typedef void (*CamelFolderAsyncCallback) (); - -struct _CamelFolder -{ - GtkObject parent_object; - - gboolean can_hold_folders; - gboolean can_hold_messages; - CamelFolderOpenMode open_mode; - CamelFolderState open_state; - gchar *name; - gchar *full_name; - CamelStore *parent_store; - CamelFolder *parent_folder; - GList *permanent_flags; - - gboolean has_summary_capability; - CamelFolderSummary *summary; - - gboolean has_uid_capability; - - GList *message_list; - -}; - - - -typedef struct { - GtkObjectClass parent_class; - - /* Virtual methods */ - void (*init_with_store) (CamelFolder *folder, - CamelStore *parent_store, - CamelException *ex); - void (*open) (CamelFolder *folder, - CamelFolderOpenMode mode, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex); - void (*close) (CamelFolder *folder, - gboolean expunge, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex); - /* void (*set_name) (CamelFolder *folder, const gchar *name, CamelException *ex); */ - void (*set_name) (CamelFolder *folder, - const gchar *name, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex); - /* void (*set_full_name) (CamelFolder *folder, const gchar *name); */ - const gchar * (*get_name) (CamelFolder *folder, CamelException *ex); - const gchar * (*get_full_name) (CamelFolder *folder, CamelException *ex); - gboolean (*can_hold_folders) (CamelFolder *folder, CamelException *ex); - gboolean (*can_hold_messages) (CamelFolder *folder, CamelException *ex); - gboolean (*exists) (CamelFolder *folder, CamelException *ex); - gboolean (*is_open) (CamelFolder *folder, CamelException *ex); - CamelFolder * (*get_folder) (CamelFolder *folder, const gchar *folder_name, CamelException *ex); - gboolean (*create) (CamelFolder *folder, CamelException *ex); - gboolean (*delete) (CamelFolder *folder, gboolean recurse, CamelException *ex); - gboolean (*delete_messages) (CamelFolder *folder, CamelException *ex); - CamelFolder * (*get_parent_folder) (CamelFolder *folder, CamelException *ex); - CamelStore * (*get_parent_store) (CamelFolder *folder, CamelException *ex); - CamelFolderOpenMode (*get_mode) (CamelFolder *folder, CamelException *ex); - GList * (*list_subfolders) (CamelFolder *folder, CamelException *ex); - void (*expunge) (CamelFolder *folder, CamelException *ex); - CamelMimeMessage * (*get_message) (CamelFolder *folder, gint number, CamelException *ex); - gint (*get_message_count) (CamelFolder *folder, CamelException *ex); - gint (*append_message) (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); - const GList * (*list_permanent_flags) (CamelFolder *folder, CamelException *ex); - void (*copy_message_to) (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder, CamelException *ex); - - const gchar * (*get_message_uid) (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); - CamelMimeMessage * (*get_message_by_uid) (CamelFolder *folder, const gchar *uid, CamelException *ex); - GList * (*get_uid_list) (CamelFolder *folder, CamelException *ex); - -} CamelFolderClass; - - - -/* Standard Gtk function */ -GtkType camel_folder_get_type (void); - - -/* public methods */ -CamelFolder *camel_folder_get_folder (CamelFolder *folder, gchar *folder_name, CamelException *ex); - -void camel_folder_open (CamelFolder *folder, - CamelFolderOpenMode mode, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex); - -void camel_folder_close (CamelFolder *folder, - gboolean expunge, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex); - -gboolean camel_folder_create (CamelFolder *folder, CamelException *ex); -gboolean camel_folder_delete (CamelFolder *folder, gboolean recurse, CamelException *ex); -gboolean camel_folder_delete_messages (CamelFolder *folder, CamelException *ex); -CamelFolder *camel_folder_get_parent_folder (CamelFolder *folder, CamelException *ex); -CamelStore *camel_folder_get_parent_store (CamelFolder *folder, CamelException *ex); -CamelFolderOpenMode camel_folder_get_mode (CamelFolder *folder, CamelException *ex); -GList *camel_folder_list_subfolders (CamelFolder *folder, CamelException *ex); -GList *camel_folder_expunge (CamelFolder *folder, gboolean want_list, CamelException *ex); -void camel_folder_set_name (CamelFolder *folder, - const gchar *name, - CamelFolderAsyncCallback callback, - gpointer user_data, - CamelException *ex); - -const gchar *camel_folder_get_name (CamelFolder *folder, CamelException *ex); -/* void camel_folder_set_full_name (CamelFolder *folder, const gchar *name); */ -const gchar *camel_folder_get_full_name (CamelFolder *folder, CamelException *ex); -CamelMimeMessage *camel_folder_get_message (CamelFolder *folder, gint number, CamelException *ex); -gboolean camel_folder_exists (CamelFolder *folder, CamelException *ex); -gint camel_folder_get_message_count (CamelFolder *folder, CamelException *ex); -gint camel_folder_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); -const GList *camel_folder_list_permanent_flags (CamelFolder *folder, CamelException *ex); -void camel_folder_copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder, CamelException *ex); - -gboolean camel_folder_has_summary_capability (CamelFolder *folder, CamelException *ex); -CamelFolderSummary *camel_folder_get_summary (CamelFolder *folder, CamelException *ex); - - -gboolean camel_folder_has_uid_capability (CamelFolder *folder, CamelException *ex); -const gchar * camel_folder_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); -CamelMimeMessage *camel_folder_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex); -GList *camel_folder_get_uid_list (CamelFolder *folder, CamelException *ex); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_FOLDER_H */ - diff --git a/camel/camel-log.c b/camel/camel-log.c deleted file mode 100644 index 9b31cfdd5b..0000000000 --- a/camel/camel-log.c +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include <config.h> -#include "camel-log.h" - -int camel_debug_level = CAMEL_LOG_LEVEL_FULL_DEBUG; -FILE *camel_log_file_descriptor = NULL; - -void -camel_log(guint level, const gchar *format, ... ) -{ - va_list args; - if (camel_log_file_descriptor == NULL) - camel_log_file_descriptor = stdout; - - if (level<=camel_debug_level) - { - va_start(args, format); - vfprintf(camel_log_file_descriptor, format, args); - va_end (args); - } -} diff --git a/camel/camel-log.h b/camel/camel-log.h deleted file mode 100644 index ce374d8111..0000000000 --- a/camel/camel-log.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef CAMEL_LOG_H -#define CAMEL_LOG_H - - -#include <stdarg.h> -#include <glib.h> -#include <stdio.h> - -extern int camel_debug_level; -extern FILE *camel_log_file_descriptor; - -#define CAMEL_LOG_LEVEL_NO_LOG 0 -#define CAMEL_LOG_LEVEL_STRANGE 5 -#define CAMEL_LOG_LEVEL_WARNING 6 -#define CAMEL_LOG_LEVEL_TRACE 8 -#define CAMEL_LOG_LEVEL_FULL_DEBUG 10 - -/* #define CAMEL_HARD_LOG_LEVEL CAMEL_LOG_LEVEL_TRACE */ - -/* the idea here is to be able to have a hard maximum log -level, given at compilation time, and a soft one, given at -runtime (with camel_debug_level) */ - -#if CAMEL_HARD_LOG_LEVEL>=CAMEL_LOG_LEVEL_STRANGE -#define CAMEL_LOG_STRANGE(args...) camel_log(CAMEL_LOG_LEVEL_STRANGE, ##args) -#else /* CAMEL_LOG_LEVEL_STRANGE */ -#define CAMEL_LOG_STRANGE(args...) -#endif /* CAMEL_LOG_LEVEL_STRANGE */ - -#if CAMEL_HARD_LOG_LEVEL>=CAMEL_LOG_LEVEL_WARNING -#define CAMEL_LOG_WARNING(args...) camel_log(CAMEL_LOG_LEVEL_WARNING, ##args) -#else /* CAMEL_LOG_LEVEL_WARNING */ -#define CAMEL_LOG_WARNING(args...) -#endif /* CAMEL_LOG_LEVEL_WARNING */ - -#if CAMEL_HARD_LOG_LEVEL>=CAMEL_LOG_LEVEL_TRACE -#define CAMEL_LOG_TRACE(args...) camel_log(CAMEL_LOG_LEVEL_TRACE, ##args) -#else /* CAMEL_LOG_LEVEL_TRACE */ -#define CAMEL_LOG_TRACE(args...) -#endif /* CAMEL_LOG_LEVEL_TRACE */ - -#if CAMEL_HARD_LOG_LEVEL>=CAMEL_LOG_LEVEL_FULL_DEBUG -#define CAMEL_LOG_FULL_DEBUG(args...) camel_log(CAMEL_LOG_LEVEL_FULL_DEBUG, ##args) -#else /* CAMEL_LOG_LEVEL_FULL_DEBUG */ -#define CAMEL_LOG_FULL_DEBUG(args...) -#endif /* CAMEL_LOG_LEVEL_FULL_DEBUG */ - - - - -extern void camel_log(guint level, const gchar *format, ... ); - -#endif /* CAMEL_LOG_H */ diff --git a/camel/camel-marshal-utils.c b/camel/camel-marshal-utils.c deleted file mode 100644 index 35567c273b..0000000000 --- a/camel/camel-marshal-utils.c +++ /dev/null @@ -1,374 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-marshal-utils.c : marshal utils */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - - -#include "config.h" -#include "camel-log.h" -#include "camel-marshal-utils.h" -#include "camel-arg-collector.c" - - -#define NB_OP_CHUNKS 20 -static GMemChunk *op_chunk=NULL; -static GStaticMutex op_chunk_mutex = G_STATIC_MUTEX_INIT; - -CamelFuncDef * -camel_func_def_new (CamelMarshal marshal, guint n_params, ...) -{ - CamelFuncDef *func_def; - va_list args; - GtkType type; - int i; - - func_def = g_new (CamelFuncDef, 1); - func_def->marshal = marshal; - func_def->n_params = n_params; - func_def->params_type = g_new (GtkType, n_params); - - va_start (args, n_params); - for (i=0; i<n_params; i++) { - type = va_arg (args, GtkType); - func_def->params_type [i] = type; - } - va_end (args); - - return func_def; -} - - - - -static gboolean -_collect_params (GtkArg *params, - CamelFuncDef *func_def, - va_list var_args) -{ - GtkArg *last_param; - int i; - gboolean failed = FALSE; - - - for (i=0; - i<func_def->n_params; - i++, params++) - { - gchar *error; - - params->name = NULL; - params->type = (func_def->params_type) [i]; - CAMEL_ARG_COLLECT_VALUE (params, - var_args, - error); - if (error) - { - failed = TRUE; - CAMEL_LOG_FULL_DEBUG ("CamelMarshall::_collect_params(): %s", error); - g_free (error); - } - } - return (failed); -} - - - -/** - * camel_marshal_create_op: create an operation - * @func_def: function definition object - * @func: function to call - * - * create a function ready to be executed. The - * vari - * - * - * Return value: operation ready to be executed - **/ -CamelOp * -camel_marshal_create_op (CamelFuncDef *func_def, CamelFunc func, ...) -{ - GtkArg *params; - gboolean error; - CamelOp *op; - va_list args; - - g_assert (func_def); - - op = camel_op_new (func_def); - op->func = func; - - va_start (args, func); - error = _collect_params (op->params, func_def, args); - va_end (args); - - if (error) { - camel_op_free (op); - return NULL; - } else - return (op); -} - - - - -/** - * camel_op_new: return a new CamelOp object - * - * The obtained object must be destroyed with - * camel_op_free () - * - * Return value: the newly allocated CamelOp object - **/ -CamelOp * -camel_op_new (CamelFuncDef *func_def) -{ - CamelOp *op; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelOp::new\n"); - g_static_mutex_lock (&op_chunk_mutex); - if (!op_chunk) - op_chunk = g_mem_chunk_create (CamelOp, - NB_OP_CHUNKS, - G_ALLOC_AND_FREE); - g_static_mutex_unlock (&op_chunk_mutex); - - op = g_chunk_new (CamelOp, op_chunk); - op->func_def = func_def; - op->params = g_new (GtkArg, func_def->n_params); - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelOp::new\n"); - return op; -} - -/** - * camel_op_free: free a CamelOp object allocated with camel_op_new - * @op: CamelOp object to free - * - * Free a CamelOp object allocated with camel_op_new () - * this routine won't work with CamelOp objects allocated - * with other allocators. - **/ -void -camel_op_free (CamelOp *op) -{ - CAMEL_LOG_FULL_DEBUG ("Entering CamelOp::free\n"); - g_free (op->params); - g_chunk_free (op, op_chunk); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelOp::free\n"); -} - - -/** - * camel_op_run: run an operation - * @op: the operation object - * - * run an operation - * - **/ -void -camel_op_run (CamelOp *op) -{ - GtkArg *params; - gboolean error; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelOp::run\n"); - g_assert (op); - g_assert (op->func_def); - g_assert (op->params); - - op->func_def->marshal (op->func, op->params); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelOp::run\n"); -} - - - - -/** - * camel_op_set_user_data: set the private field - * @op: operation - * @user_data: private field - * - * associate a field to an operation object - **/ -void -camel_op_set_user_data (CamelOp *op, gpointer user_data) -{ - CAMEL_LOG_FULL_DEBUG ("Entering CamelOp::set_user_data\n"); - g_assert (op); - op->user_data = user_data; - CAMEL_LOG_FULL_DEBUG ("Leaving CamelOp::set_user_data\n"); -} - - -/** - * camel_op_get_user_data: return the private field - * @op: operation object - * - * return the private field associated to - * an operation object. - * - * Return value: - **/ -gpointer -camel_op_get_user_data (CamelOp *op) -{ - CAMEL_LOG_FULL_DEBUG ("Entering CamelOp::get_user_data\n"); - g_assert (op); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelOp::get_user_data\n"); - return op->user_data; -} - - - -/* misc marshaller */ - - -typedef void (*CamelMarshal_NONE__POINTER_INT) (gpointer arg1, - gint arg2); -void camel_marshal_NONE__POINTER_INT (CamelFunc func, - GtkArg *args) -{ - CamelMarshal_NONE__POINTER_INT rfunc; - - CAMEL_LOG_FULL_DEBUG ("Entering camel_marshal_NONE__POINTER_INT\n"); - rfunc = (CamelMarshal_NONE__POINTER_INT) func; - (* rfunc) (GTK_VALUE_POINTER(args[0]), - GTK_VALUE_INT(args[1])); - CAMEL_LOG_FULL_DEBUG ("Leaving camel_marshal_NONE__POINTER_INT\n"); -} - - - - - -typedef void (*CamelMarshal_NONE__POINTER_INT_POINTER) (gpointer arg1, - gint arg2, - gpointer arg3); -void camel_marshal_NONE__POINTER_INT_POINTER (CamelFunc func, - GtkArg *args) -{ - CamelMarshal_NONE__POINTER_INT_POINTER rfunc; - - CAMEL_LOG_FULL_DEBUG ("Entering camel_marshal_NONE__POINTER_INT_POINTER\n"); - rfunc = (CamelMarshal_NONE__POINTER_INT_POINTER) func; - (* rfunc) (GTK_VALUE_POINTER(args[0]), - GTK_VALUE_INT(args[1]), - GTK_VALUE_POINTER(args[2])); - CAMEL_LOG_FULL_DEBUG ("Leaving camel_marshal_NONE__POINTER_INT_POINTER\n"); -} - - -typedef void (*CamelMarshal_NONE__POINTER_BOOL_POINTER) (gpointer arg1, - gboolean arg2, - gpointer arg3); -void camel_marshal_NONE__POINTER_BOOL_POINTER (CamelFunc func, - GtkArg *args) -{ - CamelMarshal_NONE__POINTER_BOOL_POINTER rfunc; - - CAMEL_LOG_FULL_DEBUG ("Entering camel_marshal_NONE__POINTER_BOOL_POINTER\n"); - rfunc = (CamelMarshal_NONE__POINTER_BOOL_POINTER) func; - (* rfunc) (GTK_VALUE_POINTER(args[0]), - GTK_VALUE_BOOL(args[1]), - GTK_VALUE_POINTER(args[2])); - CAMEL_LOG_FULL_DEBUG ("Leaving camel_marshal_NONE__POINTER_BOOL_POINTER\n"); -} - - -typedef void (*CamelMarshal_NONE__POINTER_INT_POINTER_POINTER) (gpointer arg1, - gint arg2, - gpointer arg3, - gpointer arg4); -void camel_marshal_NONE__POINTER_INT_POINTER_POINTER (CamelFunc func, - GtkArg *args) -{ - CamelMarshal_NONE__POINTER_INT_POINTER_POINTER rfunc; - - CAMEL_LOG_FULL_DEBUG ("Entering camel_marshal_NONE__POINTER_INT_POINTER_POINTER\n"); - rfunc = (CamelMarshal_NONE__POINTER_INT_POINTER_POINTER) func; - (* rfunc) (GTK_VALUE_POINTER(args[0]), - GTK_VALUE_INT(args[1]), - GTK_VALUE_POINTER(args[2]), - GTK_VALUE_POINTER(args[3])); - CAMEL_LOG_FULL_DEBUG ("Leaving camel_marshal_NONE__POINTER_INT_POINTER_POINTER\n"); -} - - - -typedef void (*CamelMarshal_NONE__POINTER_BOOL_POINTER_POINTER) (gpointer arg1, - gboolean arg2, - gpointer arg3, - gpointer arg4); -void camel_marshal_NONE__POINTER_BOOL_POINTER_POINTER (CamelFunc func, - GtkArg *args) -{ - CamelMarshal_NONE__POINTER_BOOL_POINTER_POINTER rfunc; - - CAMEL_LOG_FULL_DEBUG ("Entering camel_marshal_NONE__POINTER_BOOL_POINTER_POINTER\n"); - rfunc = (CamelMarshal_NONE__POINTER_BOOL_POINTER_POINTER) func; - (* rfunc) (GTK_VALUE_POINTER(args[0]), - GTK_VALUE_BOOL(args[1]), - GTK_VALUE_POINTER(args[2]), - GTK_VALUE_POINTER(args[3])); - CAMEL_LOG_FULL_DEBUG ("Leaving camel_marshal_NONE__POINTER_BOOL_POINTER_POINTER\n"); -} - - - -typedef void (*CamelMarshal_NONE__POINTER_POINTER_POINTER) (gpointer arg1, - gpointer arg2, - gpointer arg3); -void camel_marshal_NONE__POINTER_POINTER_POINTER (CamelFunc func, - GtkArg *args) -{ - CamelMarshal_NONE__POINTER_POINTER_POINTER rfunc; - - CAMEL_LOG_FULL_DEBUG ("Entering camel_marshal_NONE__POINTER_POINTER_POINTER\n"); - rfunc = (CamelMarshal_NONE__POINTER_POINTER_POINTER) func; - (* rfunc) (GTK_VALUE_POINTER(args[0]), - GTK_VALUE_POINTER(args[1]), - GTK_VALUE_POINTER(args[2])); - CAMEL_LOG_FULL_DEBUG ("Leaving camel_marshal_NONE__POINTER_POINTER_POINTER\n"); -} - - -typedef void (*CamelMarshal_NONE__INT) (gint arg1); -void camel_marshal_NONE__INT (CamelFunc func, - GtkArg *args) -{ - CamelMarshal_NONE__INT rfunc; - - CAMEL_LOG_FULL_DEBUG ("Entering camel_marshal_NONE__INT\n"); - rfunc = (CamelMarshal_NONE__INT) func; - (* rfunc) (GTK_VALUE_INT (args[0])); - CAMEL_LOG_FULL_DEBUG ("Leaving camel_marshal_NONE__INT\n"); -} - - - - - - diff --git a/camel/camel-marshal-utils.h b/camel/camel-marshal-utils.h deleted file mode 100644 index ab7782530f..0000000000 --- a/camel/camel-marshal-utils.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-maeshal-utils.h : marshal utils */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - -#ifndef CAMEL_MARSHAL_UTILS_H -#define CAMEL_MARSHAL_UTILS_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> - - -typedef void (*CamelFunc) (); - -typedef void ( *CamelMarshal) (CamelFunc func, - GtkArg *args); - - - - - -typedef struct { - - CamelMarshal marshal; - guint n_params; - GtkType *params_type; - -} CamelFuncDef; - - - -typedef struct { - CamelFuncDef *func_def; - CamelFunc func; - GtkArg *params; - gpointer user_data; -} CamelOp; - - -CamelFuncDef * -camel_func_def_new (CamelMarshal marshal, - guint n_params, - ...); - - -CamelOp *camel_op_new (CamelFuncDef *func_def); -void camel_op_free (CamelOp *op); -void camel_op_run (CamelOp *op); -void camel_op_run_and_free (CamelOp *op); -void camel_op_set_user_data (CamelOp *op, gpointer user_data); -gpointer camel_op_get_user_data (CamelOp *op); - -CamelOp *camel_marshal_create_op (CamelFuncDef *func_def, CamelFunc func, ...); - -/* marshallers */ -void camel_marshal_NONE__POINTER_INT_POINTER (CamelFunc func, - GtkArg *args); -void camel_marshal_NONE__POINTER_BOOL_POINTER (CamelFunc func, - GtkArg *args); -void camel_marshal_NONE__POINTER_INT_POINTER_POINTER (CamelFunc func, - GtkArg *args); -void camel_marshal_NONE__POINTER_BOOL_POINTER_POINTER (CamelFunc func, - GtkArg *args); -void camel_marshal_NONE__POINTER_POINTER_POINTER (CamelFunc func, - GtkArg *args); -void camel_marshal_NONE__INT (CamelFunc func, - GtkArg *args); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MARSHAL_UTILS_H */ - diff --git a/camel/camel-medium.c b/camel/camel-medium.c deleted file mode 100644 index 01aa440f84..0000000000 --- a/camel/camel-medium.c +++ /dev/null @@ -1,257 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelMedium.c : Abstract class for a medium */ - - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "camel-medium.h" -#include <stdio.h> -#include "gmime-content-field.h" -#include "string-utils.h" -#include "camel-log.h" -#include "gmime-utils.h" -#include "camel-simple-data-wrapper.h" - - - - - -static CamelDataWrapperClass *parent_class=NULL; - -/* Returns the class for a CamelMedium */ -#define CM_CLASS(so) CAMEL_MEDIUM_CLASS (GTK_OBJECT(so)->klass) - -static void _add_header (CamelMedium *medium, gchar *header_name, gchar *header_value); -static void _remove_header (CamelMedium *medium, const gchar *header_name); -static const gchar *_get_header (CamelMedium *medium, const gchar *header_name); - -static CamelDataWrapper *_get_content_object(CamelMedium *medium); -static void _set_content_object(CamelMedium *medium, CamelDataWrapper *content); - -static void _finalize (GtkObject *object); - -static void -camel_medium_class_init (CamelMediumClass *camel_medium_class) -{ - CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_medium_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_data_wrapper_class); - - parent_class = gtk_type_class (camel_data_wrapper_get_type ()); - - /* virtual method definition */ - camel_medium_class->add_header = _add_header; - camel_medium_class->remove_header = _remove_header; - camel_medium_class->get_header = _get_header; - - camel_medium_class->set_content_object = _set_content_object; - camel_medium_class->get_content_object = _get_content_object; - - /* virtual method overload */ - /* camel_data_wrapper_class->write_to_stream = _write_to_stream; */ - /* camel_data_wrapper_class->construct_from_stream = _construct_from_stream; */ - - gtk_object_class->finalize = _finalize; -} - -static void -camel_medium_init (gpointer object, gpointer klass) -{ - CamelMedium *camel_medium = CAMEL_MEDIUM (object); - - camel_medium->headers = g_hash_table_new (g_str_hash, g_str_equal); - camel_medium->content = NULL; -} - - - - -GtkType -camel_medium_get_type (void) -{ - static GtkType camel_medium_type = 0; - - if (!camel_medium_type) { - GtkTypeInfo camel_medium_info = - { - "CamelMedium", - sizeof (CamelMedium), - sizeof (CamelMediumClass), - (GtkClassInitFunc) camel_medium_class_init, - (GtkObjectInitFunc) camel_medium_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_medium_type = gtk_type_unique (camel_data_wrapper_get_type (), &camel_medium_info); - } - - return camel_medium_type; -} - - -static void -_finalize (GtkObject *object) -{ - CamelMedium *medium = CAMEL_MEDIUM (object); - - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMedium::finalize\n"); - - if (medium->headers) { -#warning Free hash table elements - g_hash_table_destroy (medium->headers); - } - - GTK_OBJECT_CLASS (parent_class)->finalize (object); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMedium::finalize\n"); -} - - - -/* **** */ - -static void -_add_header (CamelMedium *medium, gchar *header_name, gchar *header_value) -{ - gboolean header_exists; - gchar *old_header_name; - gchar *old_header_value; - - - header_exists = g_hash_table_lookup_extended (medium->headers, header_name, - (gpointer *) &old_header_name, - (gpointer *) &old_header_value); - if (header_exists) { - g_free (old_header_name); - g_free (old_header_value); - } - - g_hash_table_insert (medium->headers, header_name, header_value); -} - - -void -camel_medium_add_header (CamelMedium *medium, gchar *header_name, gchar *header_value) -{ - CM_CLASS(medium)->add_header(medium, header_name, header_value); -} - - -/* **** */ - - -static void -_remove_header (CamelMedium *medium, const gchar *header_name) -{ - - gboolean header_exists; - gchar *old_header_name; - gchar *old_header_value; - - header_exists = g_hash_table_lookup_extended (medium->headers, header_name, - (gpointer *) &old_header_name, - (gpointer *) &old_header_value); - if (header_exists) { - g_free (old_header_name); - g_free (old_header_value); - } - - g_hash_table_remove (medium->headers, header_name); - -} - -void -camel_medium_remove_header (CamelMedium *medium, const gchar *header_name) -{ - CM_CLASS(medium)->remove_header(medium, header_name); -} - - -/* **** */ - - -static const gchar * -_get_header (CamelMedium *medium, const gchar *header_name) -{ - - gchar *old_header_name; - gchar *old_header_value; - gchar *header_value; - - header_value = (gchar *)g_hash_table_lookup (medium->headers, header_name); - return header_value; -} - -const gchar * -camel_medium_get_header (CamelMedium *medium, const gchar *header_name) -{ - return CM_CLASS(medium)->get_header (medium, header_name); -} - - -/* **** */ - - -static CamelDataWrapper * -_get_content_object (CamelMedium *medium) -{ - return medium->content; - -} - - -CamelDataWrapper * -camel_medium_get_content_object (CamelMedium *medium) -{ - return CM_CLASS(medium)->get_content_object (medium); -} - - -/* **** */ - - -static void -_set_content_object (CamelMedium *medium, CamelDataWrapper *content) -{ - GMimeContentField *object_content_field; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMedium::set_content_object\n"); - if (medium->content) { - CAMEL_LOG_FULL_DEBUG ("CamelMedium::set_content_object unreferencing old content object\n"); - gtk_object_unref (GTK_OBJECT (medium->content)); - } - gtk_object_ref (GTK_OBJECT (content)); - medium->content = content; - -} - -void -camel_medium_set_content_object (CamelMedium *medium, CamelDataWrapper *content) -{ - CM_CLASS(medium)->set_content_object (medium, content); -} - - -/* **** */ diff --git a/camel/camel-medium.h b/camel/camel-medium.h deleted file mode 100644 index a75efed3c2..0000000000 --- a/camel/camel-medium.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-medium.h : class for a medium object */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_MEDIUM_H -#define CAMEL_MEDIUM_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include "camel-data-wrapper.h" -#include "camel-stream.h" - - -#define CAMEL_MEDIUM_TYPE (camel_medium_get_type ()) -#define CAMEL_MEDIUM(obj) (GTK_CHECK_CAST((obj), CAMEL_MEDIUM_TYPE, CamelMedium)) -#define CAMEL_MEDIUM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MEDIUM_TYPE, CamelMediumClass)) -#define CAMEL_IS_MEDIUM(o) (GTK_CHECK_TYPE((o), CAMEL_MEDIUM_TYPE)) - - -typedef struct -{ - CamelDataWrapper parent_object; - - GHashTable *headers; - - CamelDataWrapper *content; /* part real content */ - -} CamelMedium; - - - -typedef struct { - CamelDataWrapperClass parent_class; - - /* Virtual methods */ - void (*add_header) (CamelMedium *medium, gchar *header_name, gchar *header_value); - void (*remove_header) (CamelMedium *medium, const gchar *header_name); - const gchar * (*get_header) (CamelMedium *medium, const gchar *header_name); - - CamelDataWrapper * (*get_content_object) (CamelMedium *medium); - void (*set_content_object) (CamelMedium *medium, CamelDataWrapper *content); - -} CamelMediumClass; - - - -/* Standard Gtk function */ -GtkType camel_medium_get_type (void); - - -/* public methods */ -void camel_medium_add_header (CamelMedium *medium, gchar *header_name, gchar *header_value); -void camel_medium_remove_header (CamelMedium *medium, const gchar *header_name); -const gchar *camel_medium_get_header (CamelMedium *medium, const gchar *header_name); - - -CamelDataWrapper *camel_medium_get_content_object (CamelMedium *medium); -void camel_medium_set_content_object (CamelMedium *medium, CamelDataWrapper *content); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MEDIUM_H */ - diff --git a/camel/camel-mime-body-part.c b/camel/camel-mime-body-part.c deleted file mode 100644 index aa1114b365..0000000000 --- a/camel/camel-mime-body-part.c +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mime-body-part.c : Abstract class for a mime body part */ - - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "camel-mime-body-part.h" -#include "camel-log.h" - - -static void _set_parent (CamelMimeBodyPart *mime_body_part, CamelMultipart *multipart); -static const CamelMultipart *_get_parent (CamelMimeBodyPart *mime_body_part); - - -static CamelMimePartClass *parent_class=NULL; - -/* Returns the class for a CamelMimeBodyPart */ -#define CMBP_CLASS(so) CAMEL_MIME_BODY_PART_CLASS (GTK_OBJECT(so)->klass) - - - -static void -camel_mime_body_part_class_init (CamelMimeBodyPartClass *camel_mime_body_part_class) -{ - CamelMimePartClass *camel_mime_part_class = CAMEL_MIME_PART_CLASS (camel_mime_body_part_class); - parent_class = gtk_type_class (camel_mime_part_get_type ()); - - /* virtual method definition */ - camel_mime_body_part_class->set_parent = _set_parent; - camel_mime_body_part_class->get_parent = _get_parent; -} - -static void -camel_mime_body_part_init (gpointer object, gpointer klass) -{ - CamelMimeBodyPart *camel_mime_body_part = CAMEL_MIME_BODY_PART (object); -} - - - - -GtkType -camel_mime_body_part_get_type (void) -{ - static GtkType camel_mime_body_part_type = 0; - - if (!camel_mime_body_part_type) { - GtkTypeInfo camel_mime_body_part_info = - { - "CamelMimeBodyPart", - sizeof (CamelMimeBodyPart), - sizeof (CamelMimeBodyPartClass), - (GtkClassInitFunc) camel_mime_body_part_class_init, - (GtkObjectInitFunc) camel_mime_body_part_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mime_body_part_type = gtk_type_unique (camel_mime_part_get_type (), &camel_mime_body_part_info); - } - - return camel_mime_body_part_type; -} - -CamelMimeBodyPart * -camel_mime_body_part_new () -{ - CamelMimeBodyPart *mime_body_part; - CAMEL_LOG_FULL_DEBUG ("CamelMimeBodyPart:: Entering new()\n"); - - mime_body_part = (CamelMimeBodyPart *)gtk_type_new (CAMEL_MIME_BODY_PART_TYPE); - CAMEL_LOG_FULL_DEBUG ("CamelMimeBodyPart:: Leaving new()\n"); - return mime_body_part; -} - - -static void -_set_parent (CamelMimeBodyPart *mime_body_part, CamelMultipart *multipart) -{ - if (mime_body_part->parent) gtk_object_unref (GTK_OBJECT (mime_body_part->parent)); - mime_body_part->parent = multipart; - if (multipart) gtk_object_ref (GTK_OBJECT (multipart)); -} - - -void -camel_mime_body_part_set_parent (CamelMimeBodyPart *mime_body_part, CamelMultipart *multipart) -{ - CMBP_CLASS (mime_body_part)->set_parent (mime_body_part, multipart); -} - - -static const CamelMultipart * -_get_parent (CamelMimeBodyPart *mime_body_part) -{ - return mime_body_part->parent; -} - - -const CamelMultipart * -camel_mime_body_part_get_parent (CamelMimeBodyPart *mime_body_part) -{ - return CMBP_CLASS (mime_body_part)->get_parent (mime_body_part); -} - - diff --git a/camel/camel-mime-body-part.h b/camel/camel-mime-body-part.h deleted file mode 100644 index 5835dd2ec1..0000000000 --- a/camel/camel-mime-body-part.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mime-body-part.h : class for a mime body part */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_MIME_BODY_PART_H -#define CAMEL_MIME_BODY_PART_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -typedef struct _CamelMimeBodyPart CamelMimeBodyPart; - -#include <gtk/gtk.h> -#include "camel-mime-part.h" -#include "camel-multipart.h" - - - -#define CAMEL_MIME_BODY_PART_TYPE (camel_mime_body_part_get_type ()) -#define CAMEL_MIME_BODY_PART(obj) (GTK_CHECK_CAST((obj), CAMEL_MIME_BODY_PART_TYPE, CamelMimeBodyPart)) -#define CAMEL_MIME_BODY_PART_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MIME_BODY_PART_TYPE, CamelMimeBodyPartClass)) -#define CAMEL_IS_MIME_BODY_PART(o) (GTK_CHECK_TYPE((o), CAMEL_MIME_BODY_PART_TYPE)) - - -struct _CamelMimeBodyPart -{ - CamelMimePart parent_object; - CamelMultipart *parent; - -}; - - - -typedef struct { - CamelMimePartClass parent_class; - - /* Virtual methods */ - void (*set_parent) (CamelMimeBodyPart *mime_body_part, CamelMultipart *multipart); - const CamelMultipart * (*get_parent) (CamelMimeBodyPart *mime_body_part); - -} CamelMimeBodyPartClass; - - -/* Standard Gtk function */ -GtkType camel_mime_body_part_get_type (void); - - -/* public methods */ -CamelMimeBodyPart *camel_mime_body_part_new (); -void camel_mime_body_part_set_parent (CamelMimeBodyPart *mime_body_part, CamelMultipart *multipart); -const CamelMultipart *camel_mime_body_part_get_parent (CamelMimeBodyPart *mime_body_part); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MIME_BODY_PART_H */ - diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c deleted file mode 100644 index 8a5928c542..0000000000 --- a/camel/camel-mime-message.c +++ /dev/null @@ -1,704 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelMimeMessage.c : class for a mime_message */ - - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "camel-mime-message.h" -#include <stdio.h> -#include "gmime-content-field.h" -#include "string-utils.h" -#include "camel-log.h" -#include "gmime-utils.h" -#include "hash-table-utils.h" - -typedef enum { - HEADER_UNKNOWN, - HEADER_FROM, - HEADER_REPLY_TO, - HEADER_SUBJECT, - HEADER_TO, - HEADER_CC, - HEADER_BCC -} CamelHeaderType; - -static GHashTable *header_name_table; - - - -static CamelMimePartClass *parent_class=NULL; - -static gchar *received_date_str; -static gchar *sent_date_str; -static gchar *reply_to_str; -static gchar *subject_str; -static gchar *from_str; - -static void _set_received_date (CamelMimeMessage *mime_message, gchar *received_date); -static const gchar *_get_received_date (CamelMimeMessage *mime_message); -static const gchar *_get_sent_date (CamelMimeMessage *mime_message); -static void _set_reply_to (CamelMimeMessage *mime_message, gchar *reply_to); -static const gchar *_get_reply_to (CamelMimeMessage *mime_message); -static void _set_subject (CamelMimeMessage *mime_message, gchar *subject); -static const gchar *_get_subject (CamelMimeMessage *mime_message); -static void _set_from (CamelMimeMessage *mime_message, gchar *from); -static const gchar *_get_from (CamelMimeMessage *mime_message); -static void _add_recipient (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient); -static void _remove_recipient (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient); -static const GList *_get_recipients (CamelMimeMessage *mime_message, const gchar *recipient_type); -static void _set_flag (CamelMimeMessage *mime_message, const gchar *flag, gboolean value); -static gboolean _get_flag (CamelMimeMessage *mime_message, const gchar *flag); -static GList *_get_flag_list (CamelMimeMessage *mime_message); -static void _set_message_number (CamelMimeMessage *mime_message, guint number); -static guint _get_message_number (CamelMimeMessage *mime_message); -static void _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -static gboolean _parse_header_pair (CamelMimePart *mime_part, gchar *header_name, gchar *header_value); -static void _finalize (GtkObject *object); - -/* Returns the class for a CamelMimeMessage */ -#define CMM_CLASS(so) CAMEL_MIME_MESSAGE_CLASS (GTK_OBJECT(so)->klass) -#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (GTK_OBJECT(so)->klass) - - -static void -_init_header_name_table() -{ - header_name_table = g_hash_table_new (g_str_hash, g_str_equal); - g_hash_table_insert (header_name_table, "From", (gpointer)HEADER_FROM); - g_hash_table_insert (header_name_table, "Reply-To", (gpointer)HEADER_REPLY_TO); - g_hash_table_insert (header_name_table, "Subject", (gpointer)HEADER_SUBJECT); - g_hash_table_insert (header_name_table, "To", (gpointer)HEADER_TO); - g_hash_table_insert (header_name_table, "Cc", (gpointer)HEADER_CC); - g_hash_table_insert (header_name_table, "Bcc", (gpointer)HEADER_BCC); - -} - -static void -camel_mime_message_class_init (CamelMimeMessageClass *camel_mime_message_class) -{ - CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_mime_message_class); - CamelMimePartClass *camel_mime_part_class = CAMEL_MIME_PART_CLASS (camel_mime_message_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_mime_message_class); - - parent_class = gtk_type_class (camel_mime_part_get_type ()); - _init_header_name_table(); - - received_date_str = ""; - sent_date_str = ""; - reply_to_str = "Reply-To"; - subject_str = "Subject"; - from_str = "From"; - - /* virtual method definition */ - camel_mime_message_class->set_received_date = _set_received_date; - camel_mime_message_class->get_received_date = _get_received_date; - camel_mime_message_class->get_sent_date = _get_sent_date; - camel_mime_message_class->set_reply_to = _set_reply_to; - camel_mime_message_class->get_reply_to = _get_reply_to; - camel_mime_message_class->set_subject = _set_subject; - camel_mime_message_class->get_subject = _get_subject; - camel_mime_message_class->set_from = _set_from; - camel_mime_message_class->get_from = _get_from; - camel_mime_message_class->add_recipient = _add_recipient; - camel_mime_message_class->remove_recipient = _remove_recipient; - camel_mime_message_class->get_recipients = _get_recipients; - camel_mime_message_class->set_flag = _set_flag; - camel_mime_message_class->get_flag = _get_flag; - camel_mime_message_class->get_flag_list = _get_flag_list; - camel_mime_message_class->set_message_number = _set_message_number; - camel_mime_message_class->get_message_number = _get_message_number; - - /* virtual method overload */ - camel_data_wrapper_class->write_to_stream = _write_to_stream; - camel_mime_part_class->parse_header_pair = _parse_header_pair; - - gtk_object_class->finalize = _finalize; -} - - - - -static void -camel_mime_message_init (gpointer object, gpointer klass) -{ - CamelMimeMessage *camel_mime_message = CAMEL_MIME_MESSAGE (object); - - camel_mime_message->recipients = camel_recipient_table_new (); - camel_mime_message->flags = g_hash_table_new (g_strcase_hash, g_strcase_equal); - - camel_mime_message->received_date = NULL; - camel_mime_message->sent_date = NULL; - camel_mime_message->subject = NULL; - camel_mime_message->reply_to = NULL; - camel_mime_message->from = NULL; - camel_mime_message->folder = NULL; - camel_mime_message->session = NULL; -} - -GtkType -camel_mime_message_get_type (void) -{ - static GtkType camel_mime_message_type = 0; - - if (!camel_mime_message_type) { - GtkTypeInfo camel_mime_message_info = - { - "CamelMimeMessage", - sizeof (CamelMimeMessage), - sizeof (CamelMimeMessageClass), - (GtkClassInitFunc) camel_mime_message_class_init, - (GtkObjectInitFunc) camel_mime_message_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mime_message_type = gtk_type_unique (camel_mime_part_get_type (), &camel_mime_message_info); - } - - return camel_mime_message_type; -} - - -static void -_finalize (GtkObject *object) -{ - CamelMimeMessage *message = CAMEL_MIME_MESSAGE (object); - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMimeMessage::finalize\n"); - g_free (message->received_date); - g_free (message->sent_date); - g_free (message->subject); - g_free (message->reply_to); - g_free (message->from); - - if (message->recipients) camel_recipient_table_unref (message->recipients); - if (message->folder) gtk_object_unref (GTK_OBJECT (message->folder)); - if (message->session) gtk_object_unref (GTK_OBJECT (message->session)); - - if (message->flags) - g_hash_table_foreach (message->flags, g_hash_table_generic_free, NULL); - - GTK_OBJECT_CLASS (parent_class)->finalize (object); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMimeMessage::finalize\n"); -} - - - -CamelMimeMessage * -camel_mime_message_new_with_session (CamelSession *session) -{ - CamelMimeMessage *mime_message; - mime_message = gtk_type_new (CAMEL_MIME_MESSAGE_TYPE); - mime_message->session = session; - if (session) gtk_object_ref (GTK_OBJECT (session)); - - return mime_message; -} - - -/* some utils func */ - -static void -_set_field (CamelMimeMessage *mime_message, gchar *name, gchar *value, gchar **variable) -{ - if (variable) { - g_free (*variable); - *variable = value; - } -} - -/* for future use */ -/* for the moment, only @variable is used */ -static gchar * -_get_field (CamelMimeMessage *mime_message, gchar *name, gchar *variable) -{ - return variable; -} - -static gboolean -_check_not_expunged (CamelMimeMessage *mime_message) -{ - if (mime_message->expunged) { - CAMEL_LOG_WARNING ("CamelMimeMessage:: An invalid operation has been tempted on an expunged message\n"); - } - return (!mime_message->expunged); -} - -/* * */ - - -static void -_set_received_date (CamelMimeMessage *mime_message, gchar *received_date) -{ - _set_field (mime_message, received_date_str, received_date, &(mime_message->received_date)); -} - -void -camel_mime_message_set_received_date (CamelMimeMessage *mime_message, gchar *received_date) -{ - g_assert (mime_message); - g_return_if_fail (_check_not_expunged (mime_message)); - CMM_CLASS (mime_message)->set_received_date (mime_message, received_date); -} - - -static const gchar * -_get_received_date (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, received_date_str, mime_message->received_date); -} - -const gchar * -camel_mime_message_get_received_date (CamelMimeMessage *mime_message) -{ - g_assert (mime_message); - g_return_val_if_fail (_check_not_expunged (mime_message), NULL); - return CMM_CLASS (mime_message)->get_received_date (mime_message); -} - - -static const gchar * -_get_sent_date (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, sent_date_str, mime_message->sent_date); -} - -const gchar * -camel_mime_message_get_sent_date (CamelMimeMessage *mime_message) -{ - g_assert (mime_message); - g_return_val_if_fail (_check_not_expunged (mime_message), NULL); - return CMM_CLASS (mime_message)->get_sent_date (mime_message); -} - - -static void -_set_reply_to (CamelMimeMessage *mime_message, gchar *reply_to) -{ - _set_field (mime_message, reply_to_str, reply_to, &(mime_message->reply_to)); -} - -void -camel_mime_message_set_reply_to (CamelMimeMessage *mime_message, gchar *reply_to) -{ - g_assert (mime_message); - g_return_if_fail (_check_not_expunged (mime_message)); - CMM_CLASS (mime_message)->set_reply_to (mime_message, reply_to); -} - - -static const gchar * -_get_reply_to (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, reply_to_str, mime_message->reply_to); -} - -const gchar * -camel_mime_message_get_reply_to (CamelMimeMessage *mime_message) -{ - g_assert (mime_message); - g_return_val_if_fail (_check_not_expunged (mime_message), NULL); - return CMM_CLASS (mime_message)->get_reply_to (mime_message); -} - - - - -static void -_set_subject (CamelMimeMessage *mime_message, gchar *subject) -{ - _set_field (mime_message, subject_str, subject, &(mime_message->subject)); -} - -void -camel_mime_message_set_subject (CamelMimeMessage *mime_message, gchar *subject) -{ - g_assert (mime_message); - g_return_if_fail (_check_not_expunged (mime_message)); - CMM_CLASS (mime_message)->set_subject (mime_message, subject); -} - - -static const gchar * -_get_subject (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, subject_str, mime_message->subject); -} - -const gchar * -camel_mime_message_get_subject (CamelMimeMessage *mime_message) -{ - g_assert (mime_message); - g_return_val_if_fail (_check_not_expunged (mime_message), NULL); - return CMM_CLASS (mime_message)->get_subject (mime_message); -} - - - - -static void -_set_from (CamelMimeMessage *mime_message, gchar *from) -{ - _set_field (mime_message, from_str, from, &(mime_message->from)); -} - -void -camel_mime_message_set_from (CamelMimeMessage *mime_message, gchar *from) -{ - g_assert (mime_message); - g_return_if_fail (_check_not_expunged (mime_message)); - CMM_CLASS (mime_message)->set_from (mime_message, from); -} - - -static const gchar * -_get_from (CamelMimeMessage *mime_message) -{ - return _get_field (mime_message, from_str, mime_message->from); -} - -const gchar * -camel_mime_message_get_from (CamelMimeMessage *mime_message) -{ - g_assert (mime_message); - g_return_val_if_fail (_check_not_expunged (mime_message), NULL); - return CMM_CLASS (mime_message)->get_from (mime_message); -} - - - - - - - -/* **** */ - - - - - -static void -_add_recipient (CamelMimeMessage *mime_message, - const gchar *recipient_type, - const gchar *recipient) -{ - camel_recipient_table_add (mime_message->recipients, recipient_type, recipient); -} - - - -void -camel_mime_message_add_recipient (CamelMimeMessage *mime_message, - const gchar *recipient_type, - const gchar *recipient) -{ - g_assert (mime_message); - g_return_if_fail (_check_not_expunged (mime_message)); - CMM_CLASS (mime_message)->add_recipient (mime_message, recipient_type, recipient); -} - - -static void -_remove_recipient (CamelMimeMessage *mime_message, - const gchar *recipient_type, - const gchar *recipient) -{ - camel_recipient_table_remove (mime_message->recipients, recipient_type, recipient); -} - - -void -camel_mime_message_remove_recipient (CamelMimeMessage *mime_message, - const gchar *recipient_type, - const gchar *recipient) -{ - g_assert (mime_message); - g_return_if_fail (_check_not_expunged (mime_message)); - CMM_CLASS (mime_message)->remove_recipient (mime_message, recipient_type, recipient); -} - - -static const GList * -_get_recipients (CamelMimeMessage *mime_message, - const gchar *recipient_type) -{ - return camel_recipient_table_get (mime_message->recipients, recipient_type); -} - - -const GList * -camel_mime_message_get_recipients (CamelMimeMessage *mime_message, - const gchar *recipient_type) -{ - g_assert (mime_message); - g_return_val_if_fail (_check_not_expunged (mime_message), NULL); - return CMM_CLASS (mime_message)->get_recipients (mime_message, recipient_type); -} - - - -/* **** */ - - - -static void -_set_flag (CamelMimeMessage *mime_message, const gchar *flag, gboolean value) -{ - gchar *old_flags; - gboolean ptr_value; - - if (! g_hash_table_lookup_extended (mime_message->flags, - flag, - (gpointer)&(old_flags), - (gpointer)&(ptr_value)) ) { - - g_hash_table_insert (mime_message->flags, g_strdup (flag), GINT_TO_POINTER (value)); - } else - g_hash_table_insert (mime_message->flags, old_flags, GINT_TO_POINTER (value)); - -} - -void -camel_mime_message_set_flag (CamelMimeMessage *mime_message, const gchar *flag, gboolean value) -{ - g_assert (mime_message); - g_return_if_fail (_check_not_expunged (mime_message)); - CMM_CLASS (mime_message)->set_flag (mime_message, flag, value); -} - - - -static gboolean -_get_flag (CamelMimeMessage *mime_message, const gchar *flag) -{ - return GPOINTER_TO_INT (g_hash_table_lookup (mime_message->flags, flag)); -} - -gboolean -camel_mime_message_get_flag (CamelMimeMessage *mime_message, const gchar *flag) -{ - g_assert (mime_message); - g_return_val_if_fail (_check_not_expunged (mime_message), FALSE); - return CMM_CLASS (mime_message)->get_flag (mime_message, flag); -} - - - -static void -_add_flag_to_list (gpointer key, gpointer value, gpointer user_data) -{ - GList **flag_list = (GList **)user_data; - gchar *flag_name = (gchar *)key; - - if ((flag_name) && (flag_name[0] != '\0')) - *flag_list = g_list_append (*flag_list, flag_name); -} - -static GList * -_get_flag_list (CamelMimeMessage *mime_message) -{ - GList *flag_list = NULL; - - if (mime_message->flags) - g_hash_table_foreach (mime_message->flags, _add_flag_to_list, &flag_list); - return flag_list; -} - - -GList * -camel_mime_message_get_flag_list (CamelMimeMessage *mime_message) -{ - g_assert (mime_message); - g_return_val_if_fail (_check_not_expunged (mime_message), NULL); - return CMM_CLASS (mime_message)->get_flag_list (mime_message); -} - - - -static void -_set_message_number (CamelMimeMessage *mime_message, guint number) -{ - mime_message->message_number = number; -} - -static guint -_get_message_number (CamelMimeMessage *mime_message) -{ - return mime_message->message_number; -} - - - -guint -camel_mime_message_get_message_number (CamelMimeMessage *mime_message) -{ - return CMM_CLASS (mime_message)->get_message_number (mime_message); -} - - - - -#ifdef WHPT -#warning : WHPT is already defined !!!!!! -#endif -#define WHPT gmime_write_header_pair_to_stream - -static void -_write_one_recipient_to_stream (gchar *recipient_type, - GList *recipient_list, - gpointer user_data) -{ - - CamelStream *stream = (CamelStream *)user_data; - if (recipient_type) - gmime_write_header_with_glist_to_stream (stream, recipient_type, recipient_list, ", "); -} - -static void -_write_recipients_to_stream (CamelMimeMessage *mime_message, CamelStream *stream) -{ - camel_recipient_foreach_recipient_type (mime_message->recipients, - _write_one_recipient_to_stream, - (gpointer)stream); -} - -static void -_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CamelMimeMessage *mm = CAMEL_MIME_MESSAGE (data_wrapper); - CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage::write_to_stream\n"); - CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing \"From\"\n"); - WHPT (stream, "From", mm->from); - CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing \"Reply-To\"\n"); - WHPT (stream, "Reply-To", mm->reply_to); - CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing recipients\n"); - _write_recipients_to_stream (mm, stream); - CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing \"Date\"\n"); - WHPT (stream, "Date", mm->received_date); - CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing \"Subject\"\n"); - WHPT (stream, "Subject", mm->subject); - - /* FIXME correct to do it here? */ - CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing \"Mime-Version\"\n"); - WHPT (stream, "Mime-Version", "1.0"); - - CAMEL_DATA_WRAPPER_CLASS (parent_class)->write_to_stream (data_wrapper, stream); - -} - -/*******************************/ -/* mime message header parsing */ - -static void -_set_recipient_list_from_string (CamelMimeMessage *message, gchar *recipient_type, gchar *recipients_string) -{ - GList *recipients_list; - CAMEL_LOG_FULL_DEBUG ("CamelMimeMessage::_set_recipient_list_from_string parsing ##%s##\n", recipients_string); - recipients_list = string_split ( - recipients_string, ',', "\t ", - STRING_TRIM_STRIP_TRAILING | STRING_TRIM_STRIP_LEADING); - camel_recipient_table_add_list (message->recipients, recipient_type, recipients_list); - -} - -static gboolean -_parse_header_pair (CamelMimePart *mime_part, gchar *header_name, gchar *header_value) -{ - CamelHeaderType header_type; - CamelMimeMessage *message = CAMEL_MIME_MESSAGE (mime_part); - gboolean header_handled = FALSE; - - - header_type = (CamelHeaderType) g_hash_table_lookup (header_name_table, header_name); - switch (header_type) { - - case HEADER_FROM: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimeMessage::parse_header_pair found HEADER_FROM : %s\n", - header_value ); - - camel_mime_message_set_from (message, header_value); - header_handled = TRUE; - break; - - case HEADER_REPLY_TO: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimeMessage::parse_header_pair found HEADER_REPLY_YO : %s\n", - header_value ); - - camel_mime_message_set_reply_to (message, header_value); - header_handled = TRUE; - break; - - case HEADER_SUBJECT: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimeMessage::parse_header_pair found HEADER_SUBJECT : %s\n", - header_value ); - - camel_mime_message_set_subject (message, header_value); - header_handled = TRUE; - break; - - case HEADER_TO: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimeMessage::parse_header_pair found HEADER_TO : %s\n", - header_value ); - - _set_recipient_list_from_string (message, "To", header_value); - g_free (header_value); - header_handled = TRUE; - break; - - case HEADER_CC: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimeMessage::parse_header_pair found HEADER_CC : %s\n", - header_value ); - - _set_recipient_list_from_string (message, "Cc", header_value); - g_free (header_value); - header_handled = TRUE; - break; - - case HEADER_BCC: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimeMessage::parse_header_pair found HEADER_BCC : %s\n", - header_value ); - - _set_recipient_list_from_string (message, "Bcc", header_value); - g_free (header_value); - header_handled = TRUE; - break; - - - } - if (header_handled) { - g_free (header_name); - return TRUE; - } else - return parent_class->parse_header_pair (mime_part, header_name, header_value); - - -} - diff --git a/camel/camel-mime-message.h b/camel/camel-mime-message.h deleted file mode 100644 index e233f99899..0000000000 --- a/camel/camel-mime-message.h +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelMimeMessage.h : class for a mime message */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_MIME_MESSAGE_H -#define CAMEL_MIME_MESSAGE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -typedef struct _CamelMimeMessage CamelMimeMessage; - -#include <gtk/gtk.h> -#include "camel-mime-part.h" -#include "camel-folder.h" -#include "camel-session.h" -#include "camel-recipient.h" - - -#define CAMEL_RECIPIENT_TYPE_TO "To" -#define CAMEL_RECIPIENT_TYPE_CC "Cc" -#define CAMEL_RECIPIENT_TYPE_BCC "Bcc" - - -#define CAMEL_MIME_MESSAGE_TYPE (camel_mime_message_get_type ()) -#define CAMEL_MIME_MESSAGE(obj) (GTK_CHECK_CAST((obj), CAMEL_MIME_MESSAGE_TYPE, CamelMimeMessage)) -#define CAMEL_MIME_MESSAGE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MIME_MESSAGE_TYPE, CamelMimeMessageClass)) -#define CAMEL_IS_MIME_MESSAGE(o) (GTK_CHECK_TYPE((o), CAMEL_MIME_MESSAGE_TYPE)) - - - -struct _CamelMimeMessage -{ - CamelMimePart parent_object; - - /* header fields */ - gchar *received_date; - gchar *sent_date; - - gchar *subject; - gchar *reply_to; - - gchar *from; - CamelRecipientTable *recipients; - - /* other fields */ - GHashTable *flags; /* boolean values */ - gboolean expunged; - - guint message_number; /* set by folder object when retrieving message */ - gchar *message_uid; - - CamelFolder *folder; - CamelSession *session; - -}; - - - -typedef struct { - CamelMimePartClass parent_class; - - /* Virtual methods */ - void (*set_received_date) (CamelMimeMessage *mime_message, gchar *received_date); - const gchar * (*get_received_date) (CamelMimeMessage *mime_message); - const gchar * (*get_sent_date) (CamelMimeMessage *mime_message); - void (*set_reply_to) (CamelMimeMessage *mime_message, gchar *reply_to); - const gchar * (*get_reply_to) (CamelMimeMessage *mime_message); - void (*set_subject) (CamelMimeMessage *mime_message, gchar *subject); - const gchar * (*get_subject) (CamelMimeMessage *mime_message); - void (*set_from) (CamelMimeMessage *mime_message, gchar *from); - const gchar * (*get_from) (CamelMimeMessage *mime_message); - void (*add_recipient) (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient); - void (*remove_recipient) (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient); - const GList * (*get_recipients) (CamelMimeMessage *mime_message, const gchar *recipient_type); - void (*set_flag) (CamelMimeMessage *mime_message, const gchar *flag, gboolean value); - gboolean (*get_flag) (CamelMimeMessage *mime_message, const gchar *flag); - GList * (*get_flag_list) (CamelMimeMessage *mime_message); - void (*set_message_number)(CamelMimeMessage *mime_message, guint number); - guint (*get_message_number)(CamelMimeMessage *mime_message); -} CamelMimeMessageClass; - - - -/* Standard Gtk function */ -GtkType camel_mime_message_get_type (void); - - -/* public methods */ -CamelMimeMessage *camel_mime_message_new_with_session (CamelSession *session); - - -void camel_mime_message_set_received_date (CamelMimeMessage *mime_message, gchar *received_date); -const gchar *camel_mime_message_get_received_date (CamelMimeMessage *mime_message); -const gchar *camel_mime_message_get_sent_date (CamelMimeMessage *mime_message); -void camel_mime_message_set_reply_to (CamelMimeMessage *mime_message, gchar *reply_to); -const gchar *camel_mime_message_get_reply_to (CamelMimeMessage *mime_message); -void camel_mime_message_set_subject (CamelMimeMessage *mime_message, gchar *subject); -const gchar *camel_mime_message_get_subject (CamelMimeMessage *mime_message); -void camel_mime_message_set_from (CamelMimeMessage *mime_message, gchar *from); -const gchar *camel_mime_message_get_from (CamelMimeMessage *mime_message); - -void camel_mime_message_add_recipient (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient); -void camel_mime_message_remove_recipient (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient); -const GList *camel_mime_message_get_recipients (CamelMimeMessage *mime_message, const gchar *recipient_type); - -void camel_mime_message_set_flag (CamelMimeMessage *mime_message, const gchar *flag, gboolean value); -gboolean camel_mime_message_get_flag (CamelMimeMessage *mime_message, const gchar *flag); -GList *camel_mime_message_get_flag_list (CamelMimeMessage *mime_message); - -guint camel_mime_message_get_message_number (CamelMimeMessage *mime_message); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MIME_MESSAGE_H */ diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c deleted file mode 100644 index 504e7fdef5..0000000000 --- a/camel/camel-mime-part-utils.c +++ /dev/null @@ -1,171 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mime-part-utils : Utility for mime parsing and so on */ - - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "gmime-content-field.h" -#include "string-utils.h" -#include "camel-log.h" -#include "gmime-utils.h" -#include "camel-simple-data-wrapper.h" - -#include "camel-mime-part-utils.h" - - -void -camel_mime_part_construct_headers_from_stream (CamelMimePart *mime_part, - CamelStream *stream) -{ - GArray *header_array; - Rfc822Header *cur_header; - int i; - - CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils:: " - "Entering _construct_headers_from_stream\n"); - g_assert (stream); - CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::construct_headers_from_stream " - "parsing headers\n"); - /* - * parse all header lines - */ - header_array = get_header_array_from_stream (stream); - if (header_array) { - for (i=0; i<header_array->len; i++) { - cur_header = (Rfc822Header *)header_array->data + i; - camel_medium_add_header ( CAMEL_MEDIUM (mime_part), - cur_header->name, - cur_header->value); - } - - g_array_free (header_array, TRUE); - - CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::construct_headers_from_stream " - "headers parsed. Leaving \n"); - } -} - - - - - -void -camel_mime_part_construct_content_from_stream (CamelMimePart *mime_part, - CamelStream *stream) -{ - GMimeContentField *content_type = NULL; - gchar *mime_type = NULL; - GtkType content_object_type; - CamelDataWrapper *content_object = NULL; - - /* - * find content mime type - */ - CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::construct_content_from_stream " - "parsing content\n"); - - content_type = camel_mime_part_get_content_type (mime_part); - if (content_type) - mime_type = gmime_content_field_get_mime_type (content_type); - - /* - * no mime type found for the content, - * using text/plain is the default - */ - if (!mime_type) { - CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::construct_content_from_stream " - "content type field not found " - "using default \"text/plain\"\n"); - mime_type = g_strdup ("text/plain"); - camel_mime_part_set_content_type (mime_part, mime_type); - } - - /* - * find in the repository what particular data wrapper is - * associated to this mime type - */ - content_object_type = - data_wrapper_repository_get_data_wrapper_type (mime_type); - - CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::construct_content_from_stream content" - " type object type used: %s\n", - gtk_type_name (content_object_type)); - - g_free (mime_type); - - content_object = CAMEL_DATA_WRAPPER (gtk_type_new (content_object_type)); - camel_data_wrapper_set_mime_type_field (content_object, - camel_mime_part_get_content_type (mime_part)); - camel_medium_set_content_object ( CAMEL_MEDIUM (mime_part), content_object); - camel_data_wrapper_construct_from_stream (content_object, stream); - - /* - * the object is referenced in the set_content_object method, - * so unref it here - */ - gtk_object_unref (GTK_OBJECT (content_object)); - - - CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::construct_from_stream " - "content parsed\n"); - - CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils:: Leaving _construct_from_stream\n"); -} - - - -void -camel_mime_part_store_stream_in_buffer (CamelMimePart *mime_part, - CamelStream *stream) -{ - gint nb_bytes_read_total = 0; - gint nb_bytes_read_chunk; - GByteArray *buffer; -#define STREAM_READ_CHUNK_SZ 100 - - CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::store_stream_in_buffer entering\n"); - - if (mime_part->temp_message_buffer == NULL) - mime_part->temp_message_buffer = g_byte_array_new (); - - buffer = mime_part->temp_message_buffer; - - g_byte_array_set_size (buffer, nb_bytes_read_total + STREAM_READ_CHUNK_SZ); - nb_bytes_read_chunk = camel_stream_read (stream, - buffer->data + nb_bytes_read_total, - STREAM_READ_CHUNK_SZ); - nb_bytes_read_total += nb_bytes_read_chunk; - - while (nb_bytes_read_chunk >0) { - g_byte_array_set_size (buffer, nb_bytes_read_total + STREAM_READ_CHUNK_SZ); - nb_bytes_read_chunk = camel_stream_read (stream, - buffer->data + nb_bytes_read_total, - STREAM_READ_CHUNK_SZ); - nb_bytes_read_total += nb_bytes_read_chunk; - } - - g_byte_array_set_size (buffer, nb_bytes_read_total); - CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::store_stream_in_buffer entering\n"); - -} diff --git a/camel/camel-mime-part-utils.h b/camel/camel-mime-part-utils.h deleted file mode 100644 index 2fe60face9..0000000000 --- a/camel/camel-mime-part-utils.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mime-part-utils : Utility for mime parsing and so on */ - - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef CAMEL_MIME_PART_UTILS_H -#define CAMEL_MIME_PART_UTILS_H 1 - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include "camel-mime-part.h" - - -void camel_mime_part_construct_headers_from_stream (CamelMimePart *mime_part, - CamelStream *stream); - -void camel_mime_part_construct_content_from_stream (CamelMimePart *mime_part, - CamelStream *stream); - -void camel_mime_part_store_stream_in_buffer (CamelMimePart *mime_part, - CamelStream *stream); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MIME_PART_UTILS_H */ - diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c deleted file mode 100644 index fbf7c89591..0000000000 --- a/camel/camel-mime-part.c +++ /dev/null @@ -1,865 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelMimePart.c : Abstract class for a mime_part */ - - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "camel-mime-part.h" -#include <stdio.h> -#include "gmime-content-field.h" -#include "string-utils.h" -#include "camel-log.h" -#include "gmime-utils.h" -#include "camel-simple-data-wrapper.h" -#include "hash-table-utils.h" -#include "camel-stream-mem.h" - -typedef enum { - HEADER_UNKNOWN, - HEADER_DESCRIPTION, - HEADER_DISPOSITION, - HEADER_CONTENT_ID, - HEADER_ENCODING, - HEADER_CONTENT_MD5, - HEADER_CONTENT_LANGUAGES, - HEADER_CONTENT_TYPE -} CamelHeaderType; - - -static GHashTable *header_name_table; - - -static CamelMediumClass *parent_class=NULL; - -/* Returns the class for a CamelMimePart */ -#define CMP_CLASS(so) CAMEL_MIME_PART_CLASS (GTK_OBJECT(so)->klass) - -/* from GtkObject */ -static void _finalize (GtkObject *object); - -/* from CamelDataWrapper */ -static void _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -static void _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); - -/* from CamelMedia */ -static void _add_header (CamelMedium *medium, gchar *header_name, gchar *header_value); - -static void _set_content_object (CamelMedium *medium, CamelDataWrapper *content); -static CamelDataWrapper *_get_content_object (CamelMedium *medium); - -/* CamelMimePart methods */ -static void _set_description (CamelMimePart *mime_part, const gchar *description); -static const gchar *_get_description (CamelMimePart *mime_part); -static void _set_disposition (CamelMimePart *mime_part, const gchar *disposition); -static const gchar *_get_disposition (CamelMimePart *mime_part); -static void _set_filename (CamelMimePart *mime_part, gchar *filename); -static const gchar *_get_filename (CamelMimePart *mime_part); -static void _set_content_id (CamelMimePart *mime_part, gchar *content_id); -static const gchar *_get_content_id (CamelMimePart *mime_part); -static void _set_content_MD5 (CamelMimePart *mime_part, gchar *content_MD5); -static const gchar *_get_content_MD5 (CamelMimePart *mime_part); -static void _set_encoding (CamelMimePart *mime_part, CamelMimePartEncodingType encoding); -static CamelMimePartEncodingType _get_encoding (CamelMimePart *mime_part); -static void _set_content_languages (CamelMimePart *mime_part, GList *content_languages); -static const GList *_get_content_languages (CamelMimePart *mime_part); -static void _set_header_lines (CamelMimePart *mime_part, GList *header_lines); -static const GList *_get_header_lines (CamelMimePart *mime_part); -static void _set_content_type (CamelMimePart *mime_part, const gchar *content_type); -static GMimeContentField *_get_content_type (CamelMimePart *mime_part); - -static gboolean _parse_header_pair (CamelMimePart *mime_part, gchar *header_name, gchar *header_value); - - - -/* loads in a hash table the set of header names we */ -/* recognize and associate them with a unique enum */ -/* identifier (see CamelHeaderType above) */ -static void -_init_header_name_table() -{ - header_name_table = g_hash_table_new (g_strcase_hash, g_strcase_equal); - g_hash_table_insert (header_name_table, "Content-Description", (gpointer)HEADER_DESCRIPTION); - g_hash_table_insert (header_name_table, "Content-Disposition", (gpointer)HEADER_DISPOSITION); - g_hash_table_insert (header_name_table, "Content-id", (gpointer)HEADER_CONTENT_ID); - g_hash_table_insert (header_name_table, "Content-Transfer-Encoding", (gpointer)HEADER_ENCODING); - g_hash_table_insert (header_name_table, "Content-MD5", (gpointer)HEADER_CONTENT_MD5); - g_hash_table_insert (header_name_table, "Content-Type", (gpointer)HEADER_CONTENT_TYPE); - -} - -static void -camel_mime_part_class_init (CamelMimePartClass *camel_mime_part_class) -{ - CamelMediumClass *camel_medium_class = CAMEL_MEDIUM_CLASS (camel_mime_part_class); - CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_mime_part_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_data_wrapper_class); - - parent_class = gtk_type_class (camel_medium_get_type ()); - _init_header_name_table(); - - /* virtual method definition */ - camel_mime_part_class->set_description = _set_description; - camel_mime_part_class->get_description = _get_description; - camel_mime_part_class->set_disposition = _set_disposition; - camel_mime_part_class->get_disposition = _get_disposition; - camel_mime_part_class->set_filename = _set_filename; - camel_mime_part_class->get_filename = _get_filename; - camel_mime_part_class->set_content_id = _set_content_id; - camel_mime_part_class->get_content_id = _get_content_id; - camel_mime_part_class->set_content_MD5 =_set_content_MD5; - camel_mime_part_class->get_content_MD5 = _get_content_MD5; - camel_mime_part_class->set_encoding = _set_encoding; - camel_mime_part_class->get_encoding = _get_encoding; - camel_mime_part_class->set_content_languages = _set_content_languages; - camel_mime_part_class->get_content_languages = _get_content_languages; - camel_mime_part_class->set_header_lines =_set_header_lines; - camel_mime_part_class->get_header_lines =_get_header_lines; - camel_mime_part_class->set_content_type = _set_content_type; - camel_mime_part_class->get_content_type = _get_content_type; - - camel_mime_part_class->parse_header_pair = _parse_header_pair; - - /* virtual method overload */ - camel_medium_class->add_header = _add_header; - camel_medium_class->set_content_object = _set_content_object; - camel_medium_class->get_content_object = _get_content_object; - - camel_data_wrapper_class->write_to_stream = _write_to_stream; - camel_data_wrapper_class->construct_from_stream = _construct_from_stream; - - gtk_object_class->finalize = _finalize; -} - -static void -camel_mime_part_init (gpointer object, gpointer klass) -{ - CamelMimePart *camel_mime_part = CAMEL_MIME_PART (object); - - camel_mime_part->content_type = gmime_content_field_new (NULL, NULL); - camel_mime_part->description = NULL; - camel_mime_part->disposition = NULL; - camel_mime_part->content_id = NULL; - camel_mime_part->content_MD5 = NULL; - camel_mime_part->content_languages = NULL; - camel_mime_part->encoding = CAMEL_MIME_PART_ENCODING_DEFAULT; - camel_mime_part->filename = NULL; - camel_mime_part->header_lines = NULL; - - camel_mime_part->temp_message_buffer = NULL; - -} - - - - -GtkType -camel_mime_part_get_type (void) -{ - static GtkType camel_mime_part_type = 0; - - if (!camel_mime_part_type) { - GtkTypeInfo camel_mime_part_info = - { - "CamelMimePart", - sizeof (CamelMimePart), - sizeof (CamelMimePartClass), - (GtkClassInitFunc) camel_mime_part_class_init, - (GtkObjectInitFunc) camel_mime_part_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mime_part_type = gtk_type_unique (camel_medium_get_type (), &camel_mime_part_info); - } - - return camel_mime_part_type; -} - - -static void -_finalize (GtkObject *object) -{ - CamelMimePart *mime_part = CAMEL_MIME_PART (object); - -#warning do something for (mime_part->disposition) which should not be a GMimeContentField - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMimePart::finalize\n"); - - - - g_free (mime_part->description); - gmime_content_field_unref (mime_part->disposition); - g_free (mime_part->content_id); - g_free (mime_part->content_MD5); - string_list_free (mime_part->content_languages); - g_free (mime_part->filename); - if (mime_part->header_lines) string_list_free (mime_part->header_lines); - - if (mime_part->content_type) gmime_content_field_unref (mime_part->content_type); - if (mime_part->temp_message_buffer) g_byte_array_free (mime_part->temp_message_buffer, TRUE); - - GTK_OBJECT_CLASS (parent_class)->finalize (object); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMimePart::finalize\n"); -} - - -/* **** */ - -static void -_add_header (CamelMedium *medium, gchar *header_name, gchar *header_value) -{ - CamelMimePart *mime_part = CAMEL_MIME_PART (medium); - gboolean header_exists; - gchar *old_header_name; - gchar *old_header_value; - - /* Try to parse the header pair. If it corresponds to something */ - /* known, the job is done in the parsing routine. If not, */ - /* we simply add the header in a raw fashion */ - if (! CMP_CLASS(mime_part)->parse_header_pair (mime_part, header_name, header_value) ) - parent_class->add_header (medium, header_name, header_value); -} - - - - - - -static void -_set_description (CamelMimePart *mime_part, const gchar *description) -{ - g_free (mime_part->description); - mime_part->description = g_strdup (description); -} - -void -camel_mime_part_set_description (CamelMimePart *mime_part, const gchar *description) -{ - CMP_CLASS(mime_part)->set_description (mime_part, description); -} - - - -/* **** */ - - - -static const gchar * -_get_description (CamelMimePart *mime_part) -{ - return mime_part->description; -} - -const gchar * -camel_mime_part_get_description (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_description (mime_part); -} - - - -/* **** */ - - -static void -_set_disposition (CamelMimePart *mime_part, const gchar *disposition) -{ -#warning Do not use MimeContentfield here !!! - - if (mime_part->disposition) g_free ((mime_part->disposition)->type); - g_free (mime_part->disposition); - - mime_part->disposition = g_new0 (GMimeContentField,1); - (mime_part->disposition)->type = g_strdup (disposition); -} - - -void -camel_mime_part_set_disposition (CamelMimePart *mime_part, const gchar *disposition) -{ - CMP_CLASS(mime_part)->set_disposition (mime_part, disposition); -} - - -/* **** */ - - - -static const gchar * -_get_disposition (CamelMimePart *mime_part) -{ - if (!mime_part->disposition) return NULL; - return (mime_part->disposition)->type; -} - - -const gchar * -camel_mime_part_get_disposition (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_disposition (mime_part); -} - - - -static void -_set_filename (CamelMimePart *mime_part, gchar *filename) -{ - g_free(mime_part->filename); - mime_part->filename = filename; -} - - -void -camel_mime_part_set_filename (CamelMimePart *mime_part, gchar *filename) -{ - CMP_CLASS(mime_part)->set_filename (mime_part, filename); -} - - - -/* **** */ - - -static const gchar * -_get_filename (CamelMimePart *mime_part) -{ - return mime_part->filename; -} - - -const gchar * -camel_mime_part_get_filename (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_filename (mime_part); -} - - -/* **** */ - - -/* this routine must not be public */ -static void -_set_content_id (CamelMimePart *mime_part, gchar *content_id) -{ - g_free(mime_part->content_id); - mime_part->content_id = content_id; -} - - -static const gchar * -_get_content_id (CamelMimePart *mime_part) -{ - return mime_part->content_id; -} - - -/* **** */ - - -const gchar * -camel_mime_part_get_content_id (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_content_id (mime_part); -} - - -/* this routine must not be public */ -static void -_set_content_MD5 (CamelMimePart *mime_part, gchar *content_MD5) -{ - g_free(mime_part->content_MD5); - mime_part->content_MD5 = content_MD5; -} - - -/* **** */ - - -static const gchar * -_get_content_MD5 (CamelMimePart *mime_part) -{ - return mime_part->content_MD5; -} - -const gchar * -camel_mime_part_get_content_MD5 (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_content_MD5 (mime_part); -} - - -/* **** */ - - - -static void -_set_encoding (CamelMimePart *mime_part, CamelMimePartEncodingType encoding) -{ - mime_part->encoding = encoding; -} - -void -camel_mime_part_set_encoding (CamelMimePart *mime_part, - CamelMimePartEncodingType encoding) -{ - CMP_CLASS(mime_part)->set_encoding (mime_part, encoding); -} - - -/* **** */ - - - -static CamelMimePartEncodingType -_get_encoding (CamelMimePart *mime_part) -{ - return mime_part->encoding; -} - -const CamelMimePartEncodingType -camel_mime_part_get_encoding (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_encoding (mime_part); -} - - - -/* **** */ - - - -static void -_set_content_languages (CamelMimePart *mime_part, GList *content_languages) -{ - if (mime_part->content_languages) string_list_free (mime_part->content_languages); - mime_part->content_languages = content_languages; -} - -void -camel_mime_part_set_content_languages (CamelMimePart *mime_part, GList *content_languages) -{ - CMP_CLASS(mime_part)->set_content_languages (mime_part, content_languages); -} - - -/* **** */ - - - -static const GList * -_get_content_languages (CamelMimePart *mime_part) -{ - return mime_part->content_languages; -} - - -const GList * -camel_mime_part_get_content_languages (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_content_languages (mime_part); -} - - -/* **** */ - - - -static void -_set_header_lines (CamelMimePart *mime_part, GList *header_lines) -{ - if (mime_part->header_lines) string_list_free (mime_part->header_lines); - mime_part->header_lines = header_lines; -} - -void -camel_mime_part_set_header_lines (CamelMimePart *mime_part, GList *header_lines) -{ - CMP_CLASS(mime_part)->set_header_lines (mime_part, header_lines); -} - - -/* **** */ - - - -static const GList * -_get_header_lines (CamelMimePart *mime_part) -{ - return mime_part->header_lines; -} - - - -const GList * -camel_mime_part_get_header_lines (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_header_lines (mime_part); -} - - -/* **** */ - - - -static void -_set_content_type (CamelMimePart *mime_part, const gchar *content_type) -{ - g_assert (content_type); - gmime_content_field_construct_from_string (mime_part->content_type, content_type); -} - -void -camel_mime_part_set_content_type (CamelMimePart *mime_part, gchar *content_type) -{ - CMP_CLASS(mime_part)->set_content_type (mime_part, content_type); -} - -/* **** */ - - -static GMimeContentField * -_get_content_type (CamelMimePart *mime_part) -{ - return mime_part->content_type; -} - -GMimeContentField * -camel_mime_part_get_content_type (CamelMimePart *mime_part) -{ - return CMP_CLASS(mime_part)->get_content_type (mime_part); -} - -/*********/ - - - -static void -_set_content_object (CamelMedium *medium, CamelDataWrapper *content) -{ - CamelMimePart *mime_part = CAMEL_MIME_PART (medium); - GMimeContentField *object_content_field; - - parent_class->set_content_object (medium, content); - - object_content_field = camel_data_wrapper_get_mime_type_field (content); - if (mime_part->content_type && (mime_part->content_type != object_content_field)) - gmime_content_field_unref (mime_part->content_type); - mime_part->content_type = object_content_field; - gmime_content_field_ref (object_content_field); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMimePart::set_content_object\n"); - -} - -static CamelDataWrapper * -_get_content_object (CamelMedium *medium) -{ - CamelMimePart *mime_part = CAMEL_MIME_PART (medium); - CamelStream *stream; - - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::get_content_object entering\n"); - /* - * test if there is not pending content stored in the - * temporary buffer - */ - if ((!medium->content ) && (mime_part->temp_message_buffer)) { - stream = camel_stream_mem_new_with_buffer (mime_part->temp_message_buffer, - CAMEL_STREAM_MEM_READ); - camel_mime_part_construct_content_from_stream (mime_part, stream); - /* - * Beware : this will destroy the temp buffer as well - */ - gtk_object_unref (GTK_OBJECT (stream)); - } else { - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::get_content_object part has a pointer " - "to a content object as well as a temp buffer\n"); - } - - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::get_content_object leaving\n"); - - return parent_class->get_content_object (medium); - -} - - -/* **** */ - - - - -/**********************************************************************/ -#ifdef WHPT -#warning : WHPT is already defined !!!!!! -#endif -#define WHPT gmime_write_header_pair_to_stream - - -static void -_write_content_to_stream (CamelMimePart *mime_part, CamelStream *stream) -{ - CamelMedium *medium = CAMEL_MEDIUM (mime_part); - CamelStream *wrapper_stream; - guint buffer_size; - gchar *buffer; - gchar *encoded_buffer; - - CamelDataWrapper *content = medium->content; - CAMEL_LOG_FULL_DEBUG ( "Entering CamelMimePart::_write_content_to_stream\n"); - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::_write_content_to_stream, content=%p\n", content); - if (!content) return; - - switch (mime_part->encoding) { - case CAMEL_MIME_PART_ENCODING_DEFAULT: - case CAMEL_MIME_PART_ENCODING_7BIT: - case CAMEL_MIME_PART_ENCODING_8BIT: - camel_data_wrapper_write_to_stream (content, stream); - break; - case CAMEL_MIME_PART_ENCODING_BASE64: - wrapper_stream = camel_data_wrapper_get_stream (content); - if (wrapper_stream == NULL) { - /* FIXME in this case, we should probably copy stuff - in-memory and make sure things work anyway. */ - g_warning ("Class `%s' does not implement `get_stream'", - gtk_type_name (GTK_OBJECT (content)->klass->type)); - } - gmime_encode_base64 (wrapper_stream, stream); - break; - default: - g_warning ("Encoding type `%s' not supported.", - camel_mime_part_encoding_to_string - (mime_part->encoding)); - } - - CAMEL_LOG_FULL_DEBUG ( "Leaving CamelMimePart::_write_content_to_stream\n"); -} - - - - - -static void -_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CamelMimePart *mp = CAMEL_MIME_PART (data_wrapper); - CamelMedium *medium = CAMEL_MEDIUM (data_wrapper); - - CAMEL_LOG_FULL_DEBUG ( "Entering CamelMimePart::write_to_stream\n"); - - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-disposition\n"); - gmime_content_field_write_to_stream(mp->disposition, stream); - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-transfer-encoding\n"); - WHPT (stream, "Content-Transfer-Encoding", - camel_mime_part_encoding_to_string (mp->encoding)); - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-description\n"); - WHPT (stream, "Content-Description", mp->description); - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-MD5\n"); - WHPT (stream, "Content-MD5", mp->content_MD5); - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-id\n"); - WHPT (stream, "Content-id", mp->content_id); - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-languages\n"); - gmime_write_header_with_glist_to_stream (stream, "Content-Language", mp->content_languages,", "); - - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing other headers\n"); - gmime_write_header_table_to_stream (stream, medium->headers); - - CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-type\n"); - gmime_content_field_write_to_stream (mp->content_type, stream); - - camel_stream_write_string(stream,"\n"); - _write_content_to_stream (mp, stream); - -} - - - -/*******************************/ -/* mime part parsing */ - -static gboolean -_parse_header_pair (CamelMimePart *mime_part, gchar *header_name, gchar *header_value) -{ - CamelHeaderType header_type; - gboolean header_handled = FALSE; - - - header_type = (CamelHeaderType) g_hash_table_lookup (header_name_table, header_name); - switch (header_type) { - - case HEADER_DESCRIPTION: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimePart::parse_header_pair found HEADER_DESCRIPTION: %s\n", - header_value ); - - camel_mime_part_set_description (mime_part, header_value); - header_handled = TRUE; - break; - - case HEADER_DISPOSITION: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimePart::parse_header_pair found HEADER_DISPOSITION: %s\n", - header_value); - - camel_mime_part_set_disposition (mime_part, header_value); - header_handled = TRUE; - break; - - case HEADER_CONTENT_ID: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimePart::parse_header_pair found HEADER_CONTENT_ID: %s\n", - header_value); - - CMP_CLASS(mime_part)->set_content_id (mime_part, header_value); - header_handled = TRUE; - break; - - case HEADER_ENCODING: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimePart::parse_header_pair found HEADER_ENCODING: %s\n", - header_value); - - camel_mime_part_set_encoding - (mime_part, - camel_mime_part_encoding_from_string (header_value)); - header_handled = TRUE; - break; - - case HEADER_CONTENT_MD5: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimePart::parse_header_pair found HEADER_CONTENT_MD5: %s\n", - header_value ); - - CMP_CLASS(mime_part)->set_content_MD5 (mime_part, header_value); - header_handled = TRUE; - break; - - case HEADER_CONTENT_TYPE: - CAMEL_LOG_FULL_DEBUG ( - "CamelMimePart::parse_header_pair found HEADER_CONTENT_TYPE: %s\n", - header_value ); - - gmime_content_field_construct_from_string (mime_part->content_type, header_value); - header_handled = TRUE; - break; - - - } - - - if (header_handled) { - g_free (header_name); - return TRUE; - } else return FALSE; - -} - - -static void -_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - - CamelMimePart *mime_part = CAMEL_MIME_PART (data_wrapper); - - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_from_stream entering\n"); - camel_mime_part_construct_headers_from_stream (mime_part, stream); - - camel_mime_part_store_stream_in_buffer (mime_part, stream); - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_from_stream leaving\n"); - -} - - -const gchar * -camel_mime_part_encoding_to_string (CamelMimePartEncodingType encoding) -{ - switch (encoding) { - case CAMEL_MIME_PART_ENCODING_DEFAULT: - case CAMEL_MIME_PART_ENCODING_7BIT: - return "7bit"; - case CAMEL_MIME_PART_ENCODING_8BIT: - return "8bit"; - case CAMEL_MIME_PART_ENCODING_BASE64: - return "base64"; - case CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE: - return "quoted-printable"; - } -} - - -/* FIXME I am not sure this is the correct way to do this. */ -CamelMimePartEncodingType -camel_mime_part_encoding_from_string (const gchar *string) -{ - if (strncmp (string, "7bit") == 0) - return CAMEL_MIME_PART_ENCODING_7BIT; - else if (strncmp (string, "8bit") == 0) - return CAMEL_MIME_PART_ENCODING_8BIT; - else if (strncmp (string, "base64") == 0) - return CAMEL_MIME_PART_ENCODING_BASE64; - else if (strncmp (string, "quoted-printable") == 0) - return CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE; - else - /* FIXME? Spit a warning? */ - return CAMEL_MIME_PART_ENCODING_DEFAULT; -} - - -/******************************/ -/** Misc utility functions **/ - - -/** - * camel_mime_part_set_text: set the content to be some text - * @camel_mime_part: Mime part - * @text: the text - * - * Utility function used to set the content of a mime part object to - * be a text string. When @text is NULL, this routine can be used as - * a way to remove old text content. - * - **/ -void -camel_mime_part_set_text (CamelMimePart *camel_mime_part, const gchar *text) -{ - CamelSimpleDataWrapper *simple_data_wrapper; - CamelMedium *medium = CAMEL_MEDIUM (camel_mime_part); - - CAMEL_LOG_FULL_DEBUG ("CamelMimePart:: Entering set_text\n"); - CAMEL_LOG_TRACE ("CamelMimePart::set_text, setting text as a mime part content\n"); - if (medium->content) { - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::set_text unreferencing old content object\n"); - gtk_object_unref (GTK_OBJECT (medium->content)); - } - if (text) { - simple_data_wrapper = camel_simple_data_wrapper_new (); - CAMEL_LOG_FULL_DEBUG ("CamelMimePart::set_text calling CamelSimpleDataWrapper:set_text with %d chars\n", strlen (text)); - camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (simple_data_wrapper), "text/plain"); - camel_simple_data_wrapper_set_text ( simple_data_wrapper, text); - camel_medium_set_content_object ( CAMEL_MEDIUM (camel_mime_part), CAMEL_DATA_WRAPPER (simple_data_wrapper)); - gtk_object_unref (GTK_OBJECT (simple_data_wrapper)); - } else medium->content = NULL; - - CAMEL_LOG_FULL_DEBUG ("CamelMimePart:: Leaving camel_mime_part_set_text\n"); -} - - diff --git a/camel/camel-mime-part.h b/camel/camel-mime-part.h deleted file mode 100644 index b7da6f109b..0000000000 --- a/camel/camel-mime-part.h +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mime-part.h : class for a mime part */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_MIME_PART_H -#define CAMEL_MIME_PART_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include "camel-medium.h" -#include "camel-stream.h" - - -#define CAMEL_MIME_PART_TYPE (camel_mime_part_get_type ()) -#define CAMEL_MIME_PART(obj) (GTK_CHECK_CAST((obj), CAMEL_MIME_PART_TYPE, CamelMimePart)) -#define CAMEL_MIME_PART_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MIME_PART_TYPE, CamelMimePartClass)) -#define CAMEL_IS_MIME_PART(o) (GTK_CHECK_TYPE((o), CAMEL_MIME_PART_TYPE)) - - -enum _CamelMimePartEncodingType { - CAMEL_MIME_PART_ENCODING_DEFAULT, - CAMEL_MIME_PART_ENCODING_7BIT, - CAMEL_MIME_PART_ENCODING_8BIT, - CAMEL_MIME_PART_ENCODING_BASE64, - CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE, - CAMEL_MIME_PART_NUM_ENCODINGS -}; -typedef enum _CamelMimePartEncodingType CamelMimePartEncodingType; - - -/* Do not change these values directly, you - would regret it one day */ -typedef struct -{ - CamelMedium parent_object; - - /* All fields here are -** PRIVATE **- */ - gchar *description; - GMimeContentField *disposition; - gchar *content_id; - gchar *content_MD5; - GList *content_languages; - CamelMimePartEncodingType encoding; - gchar *filename; - GList *header_lines; - - GByteArray *temp_message_buffer; - GMimeContentField *content_type; - -} CamelMimePart; - - - -typedef struct { - CamelMediumClass parent_class; - - /* Virtual methods */ - void (*set_description) (CamelMimePart *mime_part, const gchar *description); - const gchar * (*get_description) (CamelMimePart *mime_part); - void (*set_disposition) (CamelMimePart *mime_part, const gchar *disposition); - const gchar * (*get_disposition) (CamelMimePart *mime_part); - void (*set_filename) (CamelMimePart *mime_part, gchar *filename); - const gchar * (*get_filename) (CamelMimePart *mime_part); - void (*set_content_id) (CamelMimePart *mime_part, gchar *content_id); - const gchar * (*get_content_id) (CamelMimePart *mime_part); - void (*set_content_MD5) (CamelMimePart *mime_part, gchar *content_MD5); - const gchar * (*get_content_MD5) (CamelMimePart *mime_part); - void (*set_encoding) (CamelMimePart *mime_part, CamelMimePartEncodingType type); - const CamelMimePartEncodingType (*get_encoding) (CamelMimePart *mime_part); - void (*set_content_languages) (CamelMimePart *mime_part, GList *content_languages); - const GList * (*get_content_languages) (CamelMimePart *mime_part); - void (*set_header_lines) (CamelMimePart *mime_part, GList *header_lines); - const GList * (*get_header_lines) (CamelMimePart *mime_part); - - void (*set_content_type) (CamelMimePart *mime_part, const gchar *content_type); - GMimeContentField * (*get_content_type) (CamelMimePart *mime_part); - - gboolean (*parse_header_pair) (CamelMimePart *mime_part, gchar *header_name, gchar *header_value); - - -} CamelMimePartClass; - - - -/* Standard Gtk function */ -GtkType camel_mime_part_get_type (void); - - -/* public methods */ -void camel_mime_part_set_description (CamelMimePart *mime_part, - const gchar *description); -const gchar *camel_mime_part_get_description (CamelMimePart *mime_part); -void camel_mime_part_set_disposition (CamelMimePart *mime_part, - const gchar *disposition); -const gchar *camel_mime_part_get_disposition (CamelMimePart *mime_part); -void camel_mime_part_set_filename (CamelMimePart *mime_part, - gchar *filename); -const gchar *camel_mime_part_get_filename (CamelMimePart *mime_part); -const gchar *camel_mime_part_get_content_id (CamelMimePart *mime_part); -const gchar *camel_mime_part_get_content_MD5 (CamelMimePart *mime_part); -void camel_mime_part_set_encoding (CamelMimePart *mime_part, - CamelMimePartEncodingType type); -CamelMimePartEncodingType camel_mime_part_get_encoding (CamelMimePart *mime_part); -void camel_mime_part_set_content_languages (CamelMimePart *mime_part, - GList *content_languages); -const GList *camel_mime_part_get_content_languages (CamelMimePart *mime_part); -void camel_mime_part_set_header_lines (CamelMimePart *mime_part, - GList *header_lines); -const GList *camel_mime_part_get_header_lines (CamelMimePart *mime_part); - -GMimeContentField *camel_mime_part_get_content_type (CamelMimePart *mime_part); - -const gchar *camel_mime_part_encoding_to_string (CamelMimePartEncodingType encoding); -CamelMimePartEncodingType camel_mime_part_encoding_from_string (const gchar *string); - -/* utility functions */ -void camel_mime_part_set_text (CamelMimePart *camel_mime_part, const gchar *text); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MIME_PART_H */ - diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c deleted file mode 100644 index f3128be9e7..0000000000 --- a/camel/camel-multipart.c +++ /dev/null @@ -1,505 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-multipart.c : Abstract class for a multipart */ - - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include <config.h> -#include "camel-multipart.h" -#include "camel-log.h" -#include "gmime-content-field.h" -#include "gmime-utils.h" -#include "camel-stream-mem.h" - - -static void _add_part (CamelMultipart *multipart, CamelMimeBodyPart *part); -static void _add_part_at (CamelMultipart *multipart, CamelMimeBodyPart *part, guint index); -static void _remove_part (CamelMultipart *multipart, CamelMimeBodyPart *part); -static CamelMimeBodyPart *_remove_part_at (CamelMultipart *multipart, guint index); -static CamelMimeBodyPart *_get_part (CamelMultipart *multipart, guint index); -static guint _get_number (CamelMultipart *multipart); -static void _set_parent (CamelMultipart *multipart, CamelMimePart *parent); -static CamelMimePart *_get_parent (CamelMultipart *multipart); -static void _set_boundary (CamelMultipart *multipart, gchar *boundary); -static const gchar *_get_boundary (CamelMultipart *multipart); -static void _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -static void _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); - -static void _finalize (GtkObject *object); - -static CamelDataWrapperClass *parent_class=NULL; - -/* Returns the class for a CamelMultipart */ -#define CMP_CLASS(so) CAMEL_MULTIPART_CLASS (GTK_OBJECT(so)->klass) - -/* Returns the class for a CamelDataWrapper */ -#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (GTK_OBJECT(so)->klass) - - -static void -camel_multipart_class_init (CamelMultipartClass *camel_multipart_class) -{ - CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_multipart_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_multipart_class); - - parent_class = gtk_type_class (camel_data_wrapper_get_type ()); - - /* virtual method definition */ - camel_multipart_class->add_part = _add_part; - camel_multipart_class->add_part_at = _add_part_at; - camel_multipart_class->remove_part = _remove_part; - camel_multipart_class->remove_part_at = _remove_part_at; - camel_multipart_class->get_part = _get_part; - camel_multipart_class->get_number = _get_number; - camel_multipart_class->set_parent = _set_parent; - camel_multipart_class->get_parent = _get_parent; - camel_multipart_class->set_boundary = _set_boundary; - camel_multipart_class->get_boundary = _get_boundary; - - /* virtual method overload */ - camel_data_wrapper_class->write_to_stream = _write_to_stream; - camel_data_wrapper_class->construct_from_stream = _construct_from_stream; - - gtk_object_class->finalize = _finalize; -} - -static void -camel_multipart_init (gpointer object, gpointer klass) -{ - CamelMultipart *multipart = CAMEL_MULTIPART (object); - camel_data_wrapper_set_mime_type ( CAMEL_DATA_WRAPPER (multipart), "multipart"); - camel_multipart_set_boundary (multipart, "__camel_boundary__"); - multipart->preface = NULL; - multipart->postface = NULL; - -} - - - - -GtkType -camel_multipart_get_type (void) -{ - static GtkType camel_multipart_type = 0; - - if (!camel_multipart_type) { - GtkTypeInfo camel_multipart_info = - { - "CamelMultipart", - sizeof (CamelMultipart), - sizeof (CamelMultipartClass), - (GtkClassInitFunc) camel_multipart_class_init, - (GtkObjectInitFunc) camel_multipart_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_multipart_type = gtk_type_unique (camel_data_wrapper_get_type (), &camel_multipart_info); - } - - return camel_multipart_type; -} - -static void -_unref_part (gpointer data, gpointer user_data) -{ - GtkObject *body_part = GTK_OBJECT (data); - - gtk_object_unref (body_part); -} - -static void -_finalize (GtkObject *object) -{ - CamelMultipart *multipart = CAMEL_MULTIPART (object); - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMultipart::finalize\n"); - - if (multipart->parent) gtk_object_unref (GTK_OBJECT (multipart->parent)); - - g_list_foreach (multipart->parts, _unref_part, NULL); - - if (multipart->boundary) g_free (multipart->boundary); - if (multipart->preface) g_free (multipart->preface); - if (multipart->postface) g_free (multipart->postface); - - GTK_OBJECT_CLASS (parent_class)->finalize (object); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMultipart::finalize\n"); -} - - -CamelMultipart * -camel_multipart_new () -{ - CamelMultipart *multipart; - CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Entering new()\n"); - - multipart = (CamelMultipart *)gtk_type_new (CAMEL_MULTIPART_TYPE); - multipart->preface = NULL; - multipart->postface = NULL; - - - CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Leaving new()\n"); - return multipart; -} - - -static void -_add_part (CamelMultipart *multipart, CamelMimeBodyPart *part) -{ - multipart->parts = g_list_append (multipart->parts, part); - if (part) gtk_object_ref (GTK_OBJECT (part)); -} - -void -camel_multipart_add_part (CamelMultipart *multipart, CamelMimeBodyPart *part) -{ - CMP_CLASS (multipart)->add_part (multipart, part); -} - - -static void -_add_part_at (CamelMultipart *multipart, CamelMimeBodyPart *part, guint index) -{ - multipart->parts = g_list_insert (multipart->parts, part, index); - if (part) gtk_object_ref (GTK_OBJECT (part)); -} - -void -camel_multipart_add_part_at (CamelMultipart *multipart, CamelMimeBodyPart *part, guint index) -{ - CMP_CLASS (multipart)->add_part_at (multipart, part, index); -} - -static void -_remove_part (CamelMultipart *multipart, CamelMimeBodyPart *part) -{ - if (!multipart->parts) { - CAMEL_LOG_FULL_DEBUG ("CamelMultipart::remove_part part list id void\n"); - return; - } - multipart->parts = g_list_remove (multipart->parts, part); - if (part) gtk_object_unref (GTK_OBJECT (part)); -} - -void -camel_multipart_remove_part (CamelMultipart *multipart, CamelMimeBodyPart *part) -{ - CMP_CLASS (multipart)->remove_part (multipart, part); -} - - -static CamelMimeBodyPart * -_remove_part_at (CamelMultipart *multipart, guint index) -{ - GList *parts_list; - GList *part_to_remove; - CamelMimeBodyPart *removed_body_part; - - CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Entering remove_part_at\n"); - CAMEL_LOG_TRACE ("CamelMultipart::remove_part_at : Removing part number %d\n", index); - - if (!(multipart->parts)) { - CAMEL_LOG_FULL_DEBUG ("CamelMultipart::remove_part_at part list is void \n"); - return NULL; - } - - parts_list = multipart->parts; - part_to_remove = g_list_nth (parts_list, index); - if (!part_to_remove) { - CAMEL_LOG_WARNING ("CamelMultipart::remove_part_at : part to remove is NULL\n"); - CAMEL_LOG_FULL_DEBUG ("CamelMultipart::remove_part_at : index = %d, number of parts=%d\n", - index, g_list_length (parts_list)); - return NULL; - } - removed_body_part = CAMEL_MIME_BODY_PART (part_to_remove->data); - - multipart->parts = g_list_remove_link (parts_list, part_to_remove); - if (part_to_remove->data) gtk_object_unref (GTK_OBJECT (part_to_remove->data)); - g_list_free_1 (part_to_remove); - - CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Leaving remove_part_at\n"); - return removed_body_part; - -} - -CamelMimeBodyPart * -camel_multipart_remove_part_at (CamelMultipart *multipart, guint index) -{ - return CMP_CLASS (multipart)->remove_part_at (multipart, index); -} - - -static CamelMimeBodyPart * -_get_part (CamelMultipart *multipart, guint index) -{ - GList *part; - if (!(multipart->parts)) { - CAMEL_LOG_FULL_DEBUG ("CamelMultipart::get_part part list is void \n"); - return NULL; - } - - part = g_list_nth (multipart->parts, index); - if (part) return CAMEL_MIME_BODY_PART (part->data); - else { - CAMEL_LOG_FULL_DEBUG ("CamelMultipart::get_part part number %d not found\n", index); - return NULL; - } -} - -CamelMimeBodyPart * -camel_multipart_get_part (CamelMultipart *multipart, guint index) -{ - return CMP_CLASS (multipart)->get_part (multipart, index); -} - - -static guint -_get_number (CamelMultipart *multipart) -{ - return g_list_length (multipart->parts); -} - -guint -camel_multipart_get_number (CamelMultipart *multipart) -{ - return CMP_CLASS (multipart)->get_number (multipart); -} - - -static void -_set_parent (CamelMultipart *multipart, CamelMimePart *parent) -{ - multipart->parent = parent; - if (parent) gtk_object_ref (GTK_OBJECT (parent)); -} - -void -camel_multipart_set_parent (CamelMultipart *multipart, CamelMimePart *parent) -{ - CMP_CLASS (multipart)->set_parent (multipart, parent); -} - - -static CamelMimePart * -_get_parent (CamelMultipart *multipart) -{ - return multipart->parent; -} - - -CamelMimePart * -camel_multipart_get_parent (CamelMultipart *multipart) -{ - return CMP_CLASS (multipart)->get_parent (multipart); -} - - - - - -static void -_set_boundary (CamelMultipart *multipart, gchar *boundary) -{ - gmime_content_field_set_parameter (CAMEL_DATA_WRAPPER (multipart)->mime_type, "boundary", boundary); -} - -void -camel_multipart_set_boundary (CamelMultipart *multipart, gchar *boundary) -{ - CMP_CLASS (multipart)->set_boundary (multipart, boundary); -} - - -static const gchar * -_get_boundary (CamelMultipart *multipart) -{ - const gchar *boundary; - CAMEL_LOG_FULL_DEBUG ("Entering CamelMultipart::_get_boundary\n"); - if (!CAMEL_DATA_WRAPPER (multipart)->mime_type) { - CAMEL_LOG_WARNING ("CamelMultipart::_get_boundary CAMEL_DATA_WRAPPER (multipart)->mime_type is NULL\n"); - return NULL; - } - boundary = gmime_content_field_get_parameter (CAMEL_DATA_WRAPPER (multipart)->mime_type, "boundary"); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMultipart::_get_boundary\n"); - return boundary; -} - - -const gchar * -camel_multipart_get_boundary (CamelMultipart *multipart) -{ - return CMP_CLASS (multipart)->get_boundary (multipart); -} - - -struct _print_part_user_data { - CamelStream *stream; - const gchar *boundary; -}; - - - -static void -_print_part (gpointer data, gpointer user_data) -{ - CamelMimeBodyPart *body_part = CAMEL_MIME_BODY_PART (data); - struct _print_part_user_data *ud = (struct _print_part_user_data *)user_data; - - if (ud->boundary) camel_stream_write_strings (ud->stream, "\n--", ud->boundary, "\n", NULL); - else camel_stream_write_strings (ud->stream, "\n--\n", NULL); - camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (body_part), ud->stream); - - -} - - - -static void -_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper); - struct _print_part_user_data ud; - const gchar *boundary; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMultipart::_write_to_stream entering\n"); - boundary = camel_multipart_get_boundary (multipart); - CAMEL_LOG_FULL_DEBUG ("Entering CamelMultipart::_write_to_stream, boundary = %s\n", boundary); - g_return_if_fail (boundary); - ud.boundary = boundary; - ud.stream = stream; - if (multipart->preface) camel_stream_write_strings (stream, multipart->preface, NULL); - g_list_foreach (multipart->parts, _print_part, (gpointer)&ud); - camel_stream_write_strings (stream, "\n--", boundary, "--\n", NULL); - if (multipart->postface) camel_stream_write_strings (stream, multipart->postface, NULL); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMultipart::_write_to_stream leaving \n"); -} - - - - -/** - * _read_part: read one part in a multipart environement. - * @new_part_stream: stream to add the part to - * @stream: the stream to read the lines from. - * @normal_boundary: end of part bundary. - * @end_boundary: end of multipart boundary. - * - * This routine is a bit special: RFC 2046 says that, in a multipart - * environment, the last crlf before a boundary belongs to the boundary. - * Thus, if there is no blank line before the boundary, the last crlf - * of the last line of the part is removed. - * - * Return value: true if the last boundary element has been found or if no more data was available from the stream, flase otherwise - **/ - -static gboolean -_read_part (CamelStream *new_part_stream, CamelStream *stream, gchar *normal_boundary, gchar *end_boundary) -{ - gchar *new_line = NULL; - gboolean end_of_part = FALSE; - gboolean last_part = FALSE; - gboolean first_line = TRUE; - - /* Note for future enhancements */ - /* RFC 2046 precises that when parsing the content of a multipart - * element, the program should not think it will find the last boundary, - * and in particular, the message could have been damaged during - * transport, the parsing should still be OK */ - CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Entering _read_part\n"); - - new_line = gmime_read_line_from_stream (stream); - while (new_line && !end_of_part && !last_part) { - end_of_part = (strcmp (new_line, normal_boundary) == 0); - last_part = (strcmp (new_line, end_boundary) == 0); - if (!end_of_part && !last_part) { - if (first_line) { - first_line = FALSE; - camel_stream_write_string (new_part_stream, new_line); - } else camel_stream_write_strings (new_part_stream, "\n", new_line, NULL); - g_free (new_line); - new_line = gmime_read_line_from_stream (stream); - } - } - if (new_line) g_free (new_line); - - CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Leaving _read_part\n"); - return (last_part || (new_line == NULL)); -} - -static void -_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper); - const gchar *boundary; - gchar *real_boundary_line; - gchar *end_boundary_line; - CamelStream *new_part_stream; - gboolean end_of_multipart; - CamelMimeBodyPart *body_part; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMultipart::_construct_from_stream\n"); - boundary = camel_multipart_get_boundary (multipart); - g_return_if_fail (boundary); - - real_boundary_line = g_strdup_printf ("--%s", boundary); - end_boundary_line = g_strdup_printf ("--%s--", boundary); - - - /* read the prefix if any */ - new_part_stream = camel_stream_mem_new (CAMEL_STREAM_MEM_RW); - end_of_multipart = _read_part (new_part_stream, stream, real_boundary_line, end_boundary_line); - CAMEL_LOG_FULL_DEBUG ("CamelMultipart::construct_from_stream freeing new_part_stream:%p\n", new_part_stream); - gtk_object_unref (GTK_OBJECT (new_part_stream)); - if (multipart->preface) g_free (multipart->preface); - - /* if ( (new_part->str)[0] != '\0') multipart->preface = g_strdup (new_part->str); */ - - /* read all the real parts */ - while (!end_of_multipart) { - CAMEL_LOG_FULL_DEBUG ("CamelMultipart::construct_from_stream, detected a new part\n"); - new_part_stream = camel_stream_mem_new (CAMEL_STREAM_MEM_RW); - body_part = camel_mime_body_part_new (); - - end_of_multipart = _read_part ( new_part_stream, stream, real_boundary_line, end_boundary_line); - camel_stream_seek (new_part_stream, 0, CAMEL_STREAM_SET); - camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (body_part), new_part_stream); - camel_multipart_add_part (multipart, body_part); - gtk_object_destroy (GTK_OBJECT (new_part_stream)); - - } - - /* g_string_assign (new_part, ""); */ - /* _read_part (new_part, stream, real_boundary_line, end_boundary_line); */ - - if (multipart->postface) g_free (multipart->postface); - /* if ( (new_part->str)[0] != '\0') multipart->postface = g_strdup (new_part->str); */ - - /* g_string_free (new_part, TRUE); */ - - g_free (real_boundary_line); - g_free (end_boundary_line); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMultipart::_construct_from_stream\n"); -} diff --git a/camel/camel-multipart.h b/camel/camel-multipart.h deleted file mode 100644 index b53d8af4f2..0000000000 --- a/camel/camel-multipart.h +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-multipart.h : class for a multipart */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_MULTIPART_H -#define CAMEL_MULTIPART_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -typedef struct _CamelMultipart CamelMultipart; - -#include <gtk/gtk.h> -#include "camel-mime-part.h" -#include "camel-mime-body-part.h" - - -#define CAMEL_MULTIPART_TYPE (camel_multipart_get_type ()) -#define CAMEL_MULTIPART(obj) (GTK_CHECK_CAST((obj), CAMEL_MULTIPART_TYPE, CamelMultipart)) -#define CAMEL_MULTIPART_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MULTIPART_TYPE, CamelMultipartClass)) -#define CAMEL_IS_MULTIPART(o) (GTK_CHECK_TYPE((o), CAMEL_MULTIPART_TYPE)) - - -struct _CamelMultipart -{ - CamelDataWrapper parent_object; - - CamelMimePart *parent; - GList *parts; - gchar *boundary; - gchar *preface; - gchar *postface; - -}; - - - -typedef struct { - CamelDataWrapperClass parent_class; - - /* Virtual methods */ - void (*add_part) (CamelMultipart *multipart, CamelMimeBodyPart *part); - void (*add_part_at) (CamelMultipart *multipart, CamelMimeBodyPart *part, guint index); - void (*remove_part) (CamelMultipart *multipart, CamelMimeBodyPart *part); - CamelMimeBodyPart * (*remove_part_at) (CamelMultipart *multipart, guint index); - CamelMimeBodyPart * (*get_part) (CamelMultipart *multipart, guint index); - guint (*get_number) (CamelMultipart *multipart); - void (*set_parent) (CamelMultipart *multipart, CamelMimePart *parent); - CamelMimePart * (*get_parent) (CamelMultipart *multipart); - void (*set_boundary) (CamelMultipart *multipart, gchar *boundary); - const gchar * (*get_boundary) (CamelMultipart *multipart); - -} CamelMultipartClass; - - -/* Standard Gtk function */ -GtkType camel_multipart_get_type (void); - - -/* public methods */ -CamelMultipart *camel_multipart_new (); -void camel_multipart_add_part (CamelMultipart *multipart, CamelMimeBodyPart *part); -void camel_multipart_add_part_at (CamelMultipart *multipart, CamelMimeBodyPart *part, guint index); -void camel_multipart_remove_part (CamelMultipart *multipart, CamelMimeBodyPart *part); -CamelMimeBodyPart *camel_multipart_remove_part_at (CamelMultipart *multipart, guint index); -CamelMimeBodyPart *camel_multipart_get_part (CamelMultipart *multipart, guint index); -guint camel_multipart_get_number (CamelMultipart *multipart); -void camel_multipart_set_parent (CamelMultipart *multipart, CamelMimePart *parent); -CamelMimePart *camel_multipart_get_parent (CamelMultipart *multipart); -void camel_multipart_set_boundary (CamelMultipart *multipart, gchar *boundary); -const gchar *camel_multipart_get_boundary (CamelMultipart *multipart); - - - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MULTIPART_H */ - diff --git a/camel/camel-op-queue.c b/camel/camel-op-queue.c deleted file mode 100644 index 453fd0f7ee..0000000000 --- a/camel/camel-op-queue.c +++ /dev/null @@ -1,187 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -/* MT safe */ - - -#include <config.h> -#include "camel-log.h" -#include "camel-op-queue.h" - -static GStaticMutex op_queue_mutex = G_STATIC_MUTEX_INIT; - - - -/** - * camel_op_queue_new: create a new operation queue - * - * Create a new operation queue. - * - * Return value: the newly allcated object - **/ -CamelOpQueue * -camel_op_queue_new () -{ - CamelOpQueue *op_queue; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelOpQueue::new\n"); - - op_queue = g_new (CamelOpQueue, 1); - op_queue->ops_tail = NULL; - op_queue->ops_head = NULL; - op_queue->service_available = TRUE; - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelOpQueue::new\n"); - return op_queue; -} - - -void -camel_op_queue_free (CamelOpQueue *op_queue) -{ - CAMEL_LOG_FULL_DEBUG ("Entering CamelOpQueue::free\n"); - g_list_free (op_queue->ops_head); - g_free (op_queue); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelOpQueue::free\n"); -} - -/** - * camel_op_queue_push_op: Add an operation to the queue - * @queue: queue object - * @op: operation to add - * - * Add an operation to an operation queue. - * The queue is a FIFO queue. - **/ -void -camel_op_queue_push_op (CamelOpQueue *queue, CamelOp *op) -{ - GList *new_op; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelOpQueue::push_op\n"); - g_assert (queue); - g_static_mutex_lock (&op_queue_mutex); - if (!queue->ops_tail) { - CAMEL_LOG_FULL_DEBUG ("CamelOpQueue::push_op queue does not exists yet. " - "Creating it\n"); - queue->ops_head = g_list_prepend (NULL, op); - queue->ops_tail = queue->ops_head; - } else - queue->ops_head = g_list_prepend (queue->ops_head, op); - g_static_mutex_unlock (&op_queue_mutex); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelOpQueue::push_op\n"); -} - - -/** - * camel_op_queue_pop_op: Pop the next operation pending in the queue - * @queue: queue object - * - * Pop the next operation pending in the queue. - * - * Return value: - **/ -CamelOp * -camel_op_queue_pop_op (CamelOpQueue *queue) -{ - GList *op_list; - CamelOp *op; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelOpQueue::pop_op\n"); - g_assert (queue); - - g_static_mutex_lock (&op_queue_mutex); - op_list = queue->ops_tail; - if (!op_list) return NULL; - - queue->ops_tail = queue->ops_tail->prev; - op = (CamelOp *)op_list->data; - g_static_mutex_unlock (&op_queue_mutex); - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelOpQueue::pop_op\n"); - return op; -} - - -/** - * camel_op_queue_run_next_op: run the next pending operation - * @queue: queue object - * - * Run the next pending operation in the queue. - * - * Return value: TRUE if an operation was launched FALSE if there was no operation pending in the queue. - **/ -gboolean -camel_op_queue_run_next_op (CamelOpQueue *queue) -{ - CamelOp *op; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelOpQueue::run_next_op\n"); - op = camel_op_queue_pop_op (queue); - if (!op) return FALSE; - - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelOpQueue::run_next_op\n"); - return FALSE; -} - -/** - * camel_op_queue_set_service_availability: set the service availability for an operation queue - * @queue: queue object - * @available: availability flag - * - * set the service availability - **/ -void -camel_op_queue_set_service_availability (CamelOpQueue *queue, gboolean available) -{ - CAMEL_LOG_FULL_DEBUG ("Entering CamelOpQueue::set_service_availability\n"); - g_static_mutex_lock (&op_queue_mutex); - queue->service_available = available; - g_static_mutex_unlock (&op_queue_mutex); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelOpQueue::set_service_availability\n"); -} - -/** - * camel_op_queue_get_service_availability: determine if an operation queue service is available - * @queue: queue object - * - * Determine if the service associated to an operation queue is available. - * - * Return value: service availability. - **/ -gboolean -camel_op_queue_get_service_availability (CamelOpQueue *queue) -{ - gboolean available; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelOpQueue::get_service_availability\n"); - g_static_mutex_lock (&op_queue_mutex); - available = queue->service_available; - g_static_mutex_unlock (&op_queue_mutex); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelOpQueue::get_service_availability\n"); - return available; -} - diff --git a/camel/camel-op-queue.h b/camel/camel-op-queue.h deleted file mode 100644 index 2ce24ea1d4..0000000000 --- a/camel/camel-op-queue.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_OP_QUEUE_H -#define CAMEL_OP_QUEUE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <glib.h> -#include "camel-marshal-utils.h" - - - -typedef struct -{ - GList *ops_head; - GList *ops_tail; - gboolean service_available; - -} CamelOpQueue; - - -/* public methods */ -CamelOpQueue *camel_op_queue_new (); -void camel_op_queue_free (CamelOpQueue *op_queue); -void camel_op_queue_push_op (CamelOpQueue *queue, CamelOp *op); -CamelOp *camel_op_queue_pop_op (CamelOpQueue *queue); -gboolean camel_op_queue_run_next_op (CamelOpQueue *queue); -gboolean camel_op_queue_get_service_availability (CamelOpQueue *queue); -void camel_op_queue_set_service_availability (CamelOpQueue *queue, gboolean available); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_OP_QUEUE_H */ - diff --git a/camel/camel-provider.c b/camel/camel-provider.c deleted file mode 100644 index 7664838975..0000000000 --- a/camel/camel-provider.c +++ /dev/null @@ -1,186 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-provider.c : provider framework */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -/* - A provider can be added "by hand" or by loading a module. - - - Adding providers with modules. - ------------------------------ - - The modules are shared libraries which must contain the - function - - CamelProvider *camel_provider_module_init (); - - returning the provider object defined in the module - - -*/ - -/* FIXME: Shouldn't we add a version number to providers ? */ - -#include "config.h" -#include "camel-provider.h" -#include "camel-log.h" - - -static GList *_provider_list = NULL; -static gchar *_last_error; - -static gint -_provider_name_cmp (gconstpointer a, gconstpointer b) -{ - CamelProvider *provider_a = CAMEL_PROVIDER (a); - CamelProvider *provider_b = CAMEL_PROVIDER (b); - - return strcmp ( provider_a->name, provider_b->name); -} - -void -camel_provider_register (CamelProvider *provider) -{ - GList *old_provider_node = NULL; - - g_assert (provider); - - if (_provider_list) - old_provider_node = g_list_find_custom (_provider_list, provider, _provider_name_cmp); - - if (old_provider_node != NULL) { - /* camel_provider_unref (CAMEL_PROVIDER (old_provider_node->data)); */ - old_provider_node->data = provider; - } else { - /* be careful, we use prepend here, so that last registered - providers come first */ - _provider_list = g_list_prepend (_provider_list, provider); - } - /* camel_provider_ref (provider); */ -} - - -const CamelProvider * -camel_provider_register_as_module (const gchar *module_path) -{ - - CamelProvider *new_provider = NULL; - GModule *new_module = NULL; - CamelProvider * (*camel_provider_module_init) (); - gboolean has_module_init; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelProvider::register_as_module\n"); - - g_return_val_if_fail (module_path, NULL); - - if (!g_module_supported ()) { - CAMEL_LOG_WARNING ("CamelProvider::register_as_module module loading not supported on this system\n"); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelProvider::register_as_module\n"); - return NULL; - } - - - new_module = g_module_open (module_path, 0); - if (!new_module) { - CAMEL_LOG_WARNING ("CamelProvider::register_as_module Unable to load module %s\n", module_path); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelProvider::register_as_module\n"); - return NULL; - } - - has_module_init = g_module_symbol (new_module, "camel_provider_module_init", (gpointer *)&camel_provider_module_init); - if (!has_module_init){ - CAMEL_LOG_WARNING ("CamelProvider::register_as_module loading of module %s failed,\n" - "\t Symbol camel_provider_module_init not defined in it\n", module_path); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelProvider::register_as_module\n"); - return NULL; - } - - new_provider = camel_provider_module_init(); - new_provider->gmodule = new_module; - camel_provider_register (new_provider); - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelProvider::register_as_module\n"); - return new_provider; - - -} - - - - -/* - be careful to this function, @a is expected to be - a provider, @b a protocol name (const gchar *) -*/ -static gint -_provider_protocol_find (gconstpointer a, gconstpointer b) -{ - CamelProvider *provider_a = CAMEL_PROVIDER (a); - const gchar *name_b = (const gchar *)b; - - return g_strcasecmp ( provider_a->name, name_b); -} - -/** - * camel_provider_get_for_protocol: get a registered provider for a protocol - * @protocol: protocol name (case insensitive) - * @type: provider type (transport, store, ...) - * - * Look into the list of registered provider if - * one correspond both to the protocol name - * and to the protocol type. When several providers - * exist for a same protocol, the last registered - * is returned. - * - * Return value: Matching provider or NULL if none exists. - **/ -const CamelProvider * -camel_provider_get_for_protocol (const gchar *protocol, ProviderType type) -{ - CamelProvider *current_provider = NULL; - GList *current_provider_node; - gboolean protocol_is_found; - gboolean provider_is_found; - - g_assert (protocol); - g_return_val_if_fail (_provider_list, NULL); - - current_provider_node = _provider_list; - provider_is_found = FALSE; - - while ((!provider_is_found) && current_provider_node) { - current_provider = (CamelProvider *)current_provider_node->data; - - protocol_is_found = (g_strcasecmp (protocol, current_provider->protocol) == 0); - if (protocol_is_found) - provider_is_found = (current_provider->provider_type == type); - - current_provider_node = current_provider_node->next; - } - - if (provider_is_found) return current_provider; - else return NULL; -} diff --git a/camel/camel-provider.h b/camel/camel-provider.h deleted file mode 100644 index 69d989370e..0000000000 --- a/camel/camel-provider.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-provider.h : provider definition */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_PROVIDER_H -#define CAMEL_PROVIDER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include <gmodule.h> - -#define CAMEL_PROVIDER(obj) (CamelProvider *)(obj) - -typedef enum { - PROVIDER_STORE, - PROVIDER_TRANSPORT -} ProviderType; - - -typedef struct { - GtkType object_type; /* used to create instance of the provider */ - ProviderType provider_type; /* is a store or a transport */ - gchar *protocol; /* name of the protocol ("imap"/"smtp"/"mh" ...) */ - gchar *name; /* name of the provider ("Raymond the imap provider") */ - gchar *description; /* Useful when multiple providers are available for a same protocol */ - - GModule *gmodule; -} CamelProvider; - -void camel_provider_register (CamelProvider *provider); -const CamelProvider *camel_provider_register_as_module (const gchar *module_path); -const CamelProvider *camel_provider_get_for_protocol (const gchar *protocol, ProviderType type); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_PROVIDER_H */ diff --git a/camel/camel-recipient.c b/camel/camel-recipient.c deleted file mode 100644 index b36b9e2dba..0000000000 --- a/camel/camel-recipient.c +++ /dev/null @@ -1,281 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-recipient.h : handle recipients (addresses) and recipiemt lists */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include "glib.h" -#include "hash-table-utils.h" -#include "camel-recipient.h" - - -/** - * camel_recipient_table_new: Create a new recipient table object - * - * - * creates a new recipient table object. A recipient table - * objects merely associates a recipient list (GList) to - * recipient types (as for example "To", "Cc" for mime - * maile messages - * - * Return value: the newly created recipient table object - **/ -CamelRecipientTable * -camel_recipient_table_new () -{ - CamelRecipientTable *recipient_table; - - recipient_table = g_new0 (CamelRecipientTable, 1); - recipient_table->recipient_hash_table = g_hash_table_new (g_strcase_hash, g_strcase_equal); - recipient_table->ref_count = 1; - return recipient_table; -} - - -/** - * camel_recipient_table_ref: add a reference to a recipient table object - * @recipient_table: the recipient table object - * - * Add a reference to a recipient table object. - **/ -void -camel_recipient_table_ref (CamelRecipientTable *recipient_table) -{ - g_return_if_fail (recipient_table); - recipient_table->ref_count += 1; -} - - - -static void -_free_recipient_list (gpointer key, gpointer value, gpointer user_data) -{ - GList *recipient_list = (GList *)value; - gchar *recipient_name = (gchar *)key; - - while (recipient_list) { - g_free (recipient_list->data); - recipient_list = recipient_list->next; - } - - g_free (recipient_name); - -} - -/** - * camel_recipient_table_free: Free a recipient table object - * @recipient_table: the recipient table object to free - * - * Free a recipient table object. All recipients and recipient - * are freed. - **/ -void -camel_recipient_table_free (CamelRecipientTable *recipient_table) -{ - if (!recipient_table) return; - - /* free each recipient list */ - g_hash_table_foreach (recipient_table->recipient_hash_table, _free_recipient_list, NULL); - g_hash_table_destroy (recipient_table->recipient_hash_table); -} - - - - -/** - * camel_recipient_table_unref: Removes a reference to a recipient table object - * @recipient_table: the recipient table object - * - * Removes a reference to the reference count of a recipient - * table object. If the reference count falls to zero, the - * recipient table object is freed. - * - **/ -void -camel_recipient_table_unref (CamelRecipientTable *recipient_table) -{ - if (!recipient_table) return; - - recipient_table->ref_count -= 1; - if (recipient_table->ref_count <1) - camel_recipient_table_free (recipient_table); - -} - - - - -/** - * camel_recipient_table_add: Add a recipient to a recipient table object. - * @recipient_table: The recipient table object - * @recipient_type: Recipient type string - * @recipient: The recipient to add - * - * Add a recipient to a recipient table object. - * The recipient is appended to the list of recipients - * of type @recipient_type. @recipient and @recipient_type - * are duplicated if necessary and freed when - * camel_recipient_table_free is called. - **/ -void -camel_recipient_table_add (CamelRecipientTable *recipient_table, - const gchar *recipient_type, - const gchar *recipient) -{ - GList *recipients_list; - GList *existent_list; - - /* see if there is already a list for this recipient type */ - existent_list = (GList *)g_hash_table_lookup (recipient_table->recipient_hash_table, recipient_type); - - - /* append the new recipient to the recipient list - if the existent_list is NULL, then a new GList is - automagically created */ - recipients_list = g_list_append (existent_list, (gpointer)g_strdup (recipient)); - - if (!existent_list) /* if there was no recipient of this type create the section */ - g_hash_table_insert (recipient_table->recipient_hash_table, g_strdup (recipient_type), recipients_list); - - -} - - -/** - * camel_recipient_table_add_list: Add a full list of recipients to a recipient table. - * @recipient_table: The recipient table object - * @recipient_type: Recipient type string. - * @recipient_list: Recipient list to add. - * - * Add a full list of recipients to a recipient table. - * The new recipients are appended at the end of the - * existing recipient list corresponding to @recipient_type. - * Be careful, the list is used as is, and its element - * will be freed by camel_recipient_table_unref - **/ -void -camel_recipient_table_add_list (CamelRecipientTable *recipient_table, - const gchar *recipient_type, - GList *recipient_list) -{ - GList *recipients_list; - GList *existent_list; - - /* see if there is already a list for this recipient type */ - existent_list = (GList *)g_hash_table_lookup (recipient_table->recipient_hash_table, recipient_type); - - - if (existent_list) - g_list_concat (existent_list, recipient_list); - else - g_hash_table_insert (recipient_table->recipient_hash_table, g_strdup (recipient_type), recipients_list); -} - - - - -/** - * camel_recipient_table_remove: Remove a recipient from a recipient table. - * @recipient_table: The recipient table object - * @recipient_type: Recipient type string. - * @recipient: Recipient to remove from the table - * - * Remove a recipient from a recipient table. The recipient is - * only removed from the recipient list corresponding to - * @recipient_type. The removed recipient is freed. - * - **/ -void -camel_recipient_table_remove (CamelRecipientTable *recipient_table, - const gchar *recipient_type, - const gchar *recipient) -{ - GList *recipients_list; - GList *new_recipients_list; - GList *old_element; - gchar *old_recipient_type; - - /* if the recipient type section does not exist, do nothing */ - if (! g_hash_table_lookup_extended (recipient_table->recipient_hash_table, - recipient_type, - (gpointer)&(old_recipient_type), - (gpointer)&(recipients_list)) - ) return; - - /* look for the recipient to remove */ - /* g_list_find_custom , use gpointer instead of gconstpointer */ - old_element = g_list_find_custom (recipients_list, (gpointer)recipient, g_strcase_equal); - if (old_element) { - /* if recipient exists, remove it */ - new_recipients_list = g_list_remove_link (recipients_list, old_element); - - /* if glist head has changed, fix up hash table */ - if (new_recipients_list != recipients_list) - g_hash_table_insert (recipient_table->recipient_hash_table, old_recipient_type, new_recipients_list); - - g_free( (gchar *)(old_element->data)); - g_list_free_1 (old_element); - } -} - - - -/** - * camel_recipient_table_get: Get the recipients corresponding to a recipient type. - * @recipient_table: The recipient table object - * @recipient_type: Recipient type string. - * - * Return the list of recipients corresponding to - * @recipient_type. The returned list is not a copy - * of the internal list used by the recipient table object - * but the list itself. It thus must not be freed. - * The recipients it contains can be modified. - * - * Return value: The list of recipients. - **/ -const GList * -camel_recipient_table_get (CamelRecipientTable *recipient_table, - const gchar *recipient_type) -{ - return (const GList *)g_hash_table_lookup (recipient_table->recipient_hash_table, recipient_type); -} - - - - -/** - * camel_recipient_foreach_recipient_type: Runs a function over over all recipients type lists. - * @recipient_table: The recipient table object. - * @func: The function to run. - * @user_data: User data to pass to the function. - * - * Runs a function over over all recipients type lists. - **/ -void -camel_recipient_foreach_recipient_type (CamelRecipientTable *recipient_table, - CRLFunc func, - gpointer user_data) -{ - g_hash_table_foreach (recipient_table->recipient_hash_table, (GHFunc)func, user_data); -} diff --git a/camel/camel-recipient.h b/camel/camel-recipient.h deleted file mode 100644 index 5750e616eb..0000000000 --- a/camel/camel-recipient.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-recipient.h : handle recipients (addresses) and recipiemt lists */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - -#ifndef CAMEL_RECIPIENT_H -#define CAMEL_RECIPIENT_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <glib.h> - - - -typedef struct { - GHashTable *recipient_hash_table; - gint ref_count; - -} CamelRecipientTable; - - -typedef void (*CRLFunc) (gchar *recipient_type, - GList *recipient_list, - gpointer user_data); - - - - -CamelRecipientTable *camel_recipient_table_new (); - -void camel_recipient_table_ref (CamelRecipientTable *recipient_table); - -void camel_recipient_table_unref (CamelRecipientTable *recipient_table); - -void camel_recipient_table_add (CamelRecipientTable *recipient_table, - const gchar *recipient_type, - const gchar *recipient); - -void camel_recipient_table_add_list (CamelRecipientTable *recipient_table, - const gchar *recipient_type, - GList *recipient_list); - -void camel_recipient_table_remove (CamelRecipientTable *recipient_table, - const gchar *recipient_type, - const gchar *recipient); - -const GList *camel_recipient_table_get (CamelRecipientTable *recipient_table, - const gchar *recipient_type); - -void camel_recipient_foreach_recipient_type (CamelRecipientTable *recipient_table, - CRLFunc func, - gpointer user_data); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_RECIPIENT_H */ - diff --git a/camel/camel-service.c b/camel/camel-service.c deleted file mode 100644 index 986823d4e2..0000000000 --- a/camel/camel-service.c +++ /dev/null @@ -1,297 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelService.c : Abstract class for an email service */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "camel-service.h" -#include "camel-log.h" - -static GtkObjectClass *parent_class=NULL; - -/* Returns the class for a CamelService */ -#define CSERV_CLASS(so) CAMEL_SERVICE_CLASS (GTK_OBJECT(so)->klass) - -static void _connect(CamelService *service); -static void _connect_to_with_login_passwd (CamelService *service, gchar *host, gchar *login, gchar *passwd); -static void _connect_to_with_login_passwd_port (CamelService *service, gchar *host, gchar *login, gchar *passwd, guint port); -static gboolean _is_connected (CamelService *service); -static void _set_connected (CamelService *service, gboolean state); -static const gchar *_get_url (CamelService *service); -static void _finalize (GtkObject *object); - -static void -camel_service_class_init (CamelServiceClass *camel_service_class) -{ - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_service_class); - - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - camel_service_class->connect = _connect; - camel_service_class->connect_to_with_login_passwd = _connect_to_with_login_passwd; - camel_service_class->connect_to_with_login_passwd_port = _connect_to_with_login_passwd_port; - camel_service_class->is_connected = _is_connected; - camel_service_class->set_connected = _set_connected; - camel_service_class->get_url = _get_url; - - /* virtual method overload */ - gtk_object_class->finalize = _finalize; -} - - - - - - - -GtkType -camel_service_get_type (void) -{ - static GtkType camel_service_type = 0; - - if (!camel_service_type) { - GtkTypeInfo camel_service_info = - { - "CamelService", - sizeof (CamelService), - sizeof (CamelServiceClass), - (GtkClassInitFunc) camel_service_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_service_type = gtk_type_unique (gtk_object_get_type (), &camel_service_info); - } - - return camel_service_type; -} - - -static void -_finalize (GtkObject *object) -{ - CamelService *camel_service = CAMEL_SERVICE (object); - - CAMEL_LOG_FULL_DEBUG ("Entering CamelService::finalize\n"); - - g_free (camel_service->url); - - GTK_OBJECT_CLASS (parent_class)->finalize (object); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelService::finalize\n"); -} - - - -/** - * _connect : connect to a service - * - * connect to the service using the parameters - * stored in the session it is initialized with - * WARNING: session not implemented for the moment - * - * @service: object to connect - **/ -static void -_connect (CamelService *service) -{ - CSERV_CLASS(service)->set_connected(service, TRUE); -} - - - -/** - * camel_service_connect:connect to a service - * @service: CamelService object - * - * connect to the service using the parameters - * stored in the session it is initialized with - * WARNING: session not implemented for the moment - * - **/ -void -camel_service_connect (CamelService *service) -{ - CSERV_CLASS(service)->connect(service); -} - - - -/** - * _connect_to: connect to the specified address - * - * Connect to the service, but do not use the session - * default parameters to retrieve server's address - * - * @service: object to connect - * @host: host to connect to - * @login: user name used to log in - * @passwd: password used to log in - **/ -static void -_connect_to_with_login_passwd (CamelService *service, gchar *host, gchar *login, gchar *passwd) -{ - CSERV_CLASS(service)->set_connected(service, TRUE); -} - -/** - * camel_service_connect_to_with_login_passwd: connect a service - * @service: the service to connect - * @host: host to connect to - * @login: login to connect with - * @passwd: password to connect with - * - * Connect to a service, but do not use the session - * default parameters to retrieve server's address - * - **/ -void -camel_service_connect_to_with_login_passwd (CamelService *service, gchar *host, gchar *login, gchar *passwd) -{ - CSERV_CLASS(service)->connect_to_with_login_passwd (service, host, login, passwd); -} - - - - -/** - * _connect_to_with_login_passwd_port: connect to the specified address - * @service: service to connect - * @host: host to connect to - * @login: user name used to log in - * @passwd: password used to log in - * @port: port to connect to - * - * - **/ -static void -_connect_to_with_login_passwd_port (CamelService *service, gchar *host, gchar *login, gchar *passwd, guint port) -{ - CSERV_CLASS(service)->set_connected(service, TRUE); -} - - -/** - * camel_service_connect_to_with_login_passwd_port: connect a service - * @service: service to connect - * @host: host to connect to - * @login: user name used to log in - * @passwd: password used to log in - * @port: port to connect to - * - * Connect to a service, but do not use the session - * default parameters to retrieve server's address - * - **/ -void -camel_service_connect_to_with_login_passwd_port (CamelService *service, gchar *host, gchar *login, gchar *passwd, guint port) -{ - CSERV_CLASS(service)->connect_to_with_login_passwd_port (service, host, login, passwd, port); -} - - - - -/** - * _is_connected: test if the service object is connected - * @service: object to test - * - * - * - * Return value: - **/ -static gboolean -_is_connected (CamelService *service) -{ - return service->connected; -} - - -/** - * camel_service_is_connected: test if the service object is connected - * @service: object to test - * - * - * - * Return value: - **/ -gboolean -camel_service_is_connected (CamelService *service) -{ - return CSERV_CLASS(service)->is_connected(service); -} - - - -/** - * _set_connected:set the connected state - * @service: object to set the state of - * @state: connected/disconnected - * - * This routine has to be called by providers to set the - * connection state, mainly when the service is disconnected - * wheras the close() method has not been called. - * - **/ -static void -_set_connected (CamelService *service, gboolean state) -{ - service->connected = state; -} - - - -/** - * _get_url: get url representing a service - * @service: the service - * - * This method merely returns the "url" field. Subclasses - * may provide more active implementations. - * - * - * Return value: - **/ -static const gchar * -_get_url (CamelService *service) -{ - return service->url; -} - -/** - * camel_service_get_url: get the url representing a service - * @service: the service - * - * returns the URL representing a service. For security reasons - * This routine may not always return the password. - * - * Return value: the url name - **/ -const gchar * -camel_service_get_url (CamelService *service) -{ - return CSERV_CLASS(service)->get_url(service); -} - - diff --git a/camel/camel-service.h b/camel/camel-service.h deleted file mode 100644 index 4849273226..0000000000 --- a/camel/camel-service.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-service.h : Abstract class for an email service */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_SERVICE_H -#define CAMEL_SERVICE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> - -#define CAMEL_SERVICE_TYPE (camel_service_get_type ()) -#define CAMEL_SERVICE(obj) (GTK_CHECK_CAST((obj), CAMEL_SERVICE_TYPE, CamelService)) -#define CAMEL_SERVICE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SERVICE_TYPE, CamelServiceClass)) -#define CAMEL_IS_SERVICE(o) (GTK_CHECK_TYPE((o), CAMEL_SERVICE_TYPE)) - - - -typedef struct { - GtkObject parent_object; - - gboolean connected; - gchar *url; /* This may be a full object ? */ - -} CamelService; - - - -typedef struct { - GtkObjectClass parent_class; - - void (*connect) (CamelService *service); - void (*connect_to_with_login_passwd) (CamelService *service, gchar *host, gchar *login, gchar *passwd); - void (*connect_to_with_login_passwd_port) (CamelService *service, gchar *host, gchar *login, gchar *passwd, guint port); - gboolean (*is_connected) (CamelService *service); - void (*set_connected) (CamelService *service, gboolean state); - const gchar * (*get_url) (CamelService *service); - -} CamelServiceClass; - - - - -/* public methods */ -void camel_service_connect (CamelService *service); -gboolean camel_service_is_connected (CamelService *service); -void camel_service_connect_to_with_login_passwd (CamelService *service, gchar *host, gchar *login, gchar *passwd); -void camel_service_connect_to_with_login_passwd_port (CamelService *service, gchar *host, gchar *login, gchar *passwd, guint port); -const gchar *camel_service_get_url (CamelService *service); -/* Standard Gtk function */ -GtkType camel_service_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_SERVICE_H */ - diff --git a/camel/camel-session.c b/camel/camel-session.c deleted file mode 100644 index 416c93a622..0000000000 --- a/camel/camel-session.c +++ /dev/null @@ -1,217 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-session.c : Abstract class for an email session */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "camel-session.h" -#include "string-utils.h" -#include "url-util.h" -#include "camel-provider.h" -#include "hash-table-utils.h" - -static GtkObjectClass *parent_class=NULL; - -/* Returns the class for a CamelSession */ -#define CSS_CLASS(so) CAMEL_SESSION_CLASS (GTK_OBJECT(so)->klass) - - -static void -camel_session_class_init (CamelSessionClass *camel_session_class) -{ - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - /* virtual method overload */ -} - - - - - -static void -camel_session_init (CamelSession *session) -{ - session->store_provider_list = g_hash_table_new (g_strcase_hash, g_strcase_equal); - session->transport_provider_list = g_hash_table_new (g_strcase_hash, g_strcase_equal); -} - - - -GtkType -camel_session_get_type (void) -{ - static GtkType camel_session_type = 0; - - if (!camel_session_type) { - GtkTypeInfo camel_session_info = - { - "CamelSession", - sizeof (CamelSession), - sizeof (CamelSessionClass), - (GtkClassInitFunc) camel_session_class_init, - (GtkObjectInitFunc) camel_session_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_session_type = gtk_type_unique (gtk_object_get_type (), &camel_session_info); - } - - return camel_session_type; -} - - -CamelSession * -camel_session_new () -{ - return gtk_type_new (CAMEL_SESSION_TYPE); -} - -/** - * camel_session_set_provider: set the default provider for a protocol - * @session: session object for wich the provider will the default - * @provider: provider object - * - * Set the default implementation for a protocol. The protocol - * is determined by provider->protocol field (See CamelProtocol). - * It overrides the default provider for this protocol. - * - **/ -void -camel_session_set_provider (CamelSession *session, CamelProvider *provider) -{ - GHashTable *table; - - g_assert(session); - g_assert(provider); - - if (provider->provider_type == PROVIDER_STORE) - table = session->store_provider_list; - else - table = session->transport_provider_list; - - g_hash_table_insert (table, (gpointer)(provider->protocol), (gpointer)(provider)); - -} - - - - - -/** - * camel_session_get_store_from_provider: create a folder instance for a given provider - * @session: session object the folder will be initialized with - * @provider: provider folder to instantiate - * - * - * - * Return value: the newly instantiated store - **/ -CamelStore * -camel_session_get_store_from_provider (CamelSession *session, CamelProvider *provider) -{ - CamelStore *store; - - g_assert(session); - g_assert(provider); - - store = CAMEL_STORE (gtk_object_new (provider->object_type, NULL)); -#warning set the url to a useful value. - camel_store_init(store, session, NULL); - return store; -} - - - - -/** - * camel_session_get_store_for_protocol: get the store associated to a protocol - * @session: CamelSession object - * @protocol: protocol name - * - * Return a CamelStore object associated to a given - * store protocol. If a provider has been set for this - * protocol in the session @session using - * camel_session_set_provider (), then a store - * obtained from this provider is return. - * Otherwise, if one or more provider corresponding - * to this protocol has been registered (See - * camel_provider_register_as_module), the last registered - * one is used. - * - * Return value: store associated to this protocol or NULL if no provider was found. - **/ -CamelStore * -camel_session_get_store_for_protocol (CamelSession *session, const gchar *protocol) -{ - const CamelProvider *provider = NULL; - CamelStore *new_store; - - /* look if there is a provider assiciated to this - protocol in this session */ - provider = CAMEL_PROVIDER (g_hash_table_lookup (session->store_provider_list, protocol)); - if (!provider) - /* no provider was found in this session, look - if there is a registered provider for this - protocol */ - provider = camel_provider_get_for_protocol (protocol, PROVIDER_STORE); - - if (!provider) return NULL; - - new_store = (CamelStore *)gtk_type_new (provider->object_type); - return new_store; -} - - - - -/** - * camel_session_get_store: get a store object for an URL - * @session: session object - * @url_string: url - * - * return a store corresponding to an URL. - * - * Return value: the store, or NULL if no provider correponds to the protocol - **/ -CamelStore * -camel_session_get_store (CamelSession *session, const gchar *url_string) -{ - Gurl *url = NULL; - CamelStore *new_store = NULL; - - url = g_url_new (url_string); - g_return_val_if_fail (url, NULL); - - if (url->protocol) { - new_store = camel_session_get_store_for_protocol (session, url->protocol); - if (new_store) - camel_store_init (new_store, session, url_string); - } - g_url_free (url); - - return new_store; - -} diff --git a/camel/camel-session.h b/camel/camel-session.h deleted file mode 100644 index 0b40e71dd7..0000000000 --- a/camel/camel-session.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-session.h : Abstract class for an email session */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_SESSION_H -#define CAMEL_SESSION_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> - -typedef struct _CamelSession CamelSession; - -#include "camel-provider.h" -#include "camel-store.h" - -#define CAMEL_SESSION_TYPE (camel_session_get_type ()) -#define CAMEL_SESSION(obj) (GTK_CHECK_CAST((obj), CAMEL_SESSION_TYPE, CamelSession)) -#define CAMEL_SESSION_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SESSION_TYPE, CamelSessionClass)) -#define CAMEL_IS_SESSION(o) (GTK_CHECK_TYPE((o), CAMEL_SESSION_TYPE)) - - - - -struct _CamelSession -{ - GtkObject parent_object; - GHashTable *store_provider_list; /* providers are identified by their protocol */ - GHashTable *transport_provider_list; - - -}; - - - -typedef struct { - GtkObjectClass parent_class; - - /* Virtual methods */ - -} CamelSessionClass; - - -/* public methods */ - -/* Standard Gtk function */ -GtkType camel_session_get_type (void); - - -CamelSession *camel_session_new (); -void camel_session_set_provider (CamelSession *session, CamelProvider *provider); -CamelStore *camel_session_get_store_for_protocol (CamelSession *session, const gchar *protocol); -CamelStore *camel_session_get_store (CamelSession *session, const gchar *url_string); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_SESSION_H */ diff --git a/camel/camel-simple-data-wrapper-stream.c b/camel/camel-simple-data-wrapper-stream.c deleted file mode 100644 index e9d4ebe8ad..0000000000 --- a/camel/camel-simple-data-wrapper-stream.c +++ /dev/null @@ -1,276 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* camel-simple-data-wrapper-stream.c - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "camel-simple-data-wrapper-stream.h" - - -static CamelStreamClass *parent_class = NULL; - - -/* CamelStream methods. */ - -static gint -read (CamelStream *stream, - gchar *buffer, - gint n) -{ - CamelSimpleDataWrapperStream *wrapper_stream; - CamelSimpleDataWrapper *wrapper; - GByteArray *array; - gint len; - - wrapper_stream = CAMEL_SIMPLE_DATA_WRAPPER_STREAM (stream); - wrapper = wrapper_stream->wrapper; - g_return_val_if_fail (wrapper != NULL, -1); - array = wrapper->byte_array; - - len = MIN (n, array->len - wrapper_stream->current_position); - if (len > 0) { - memcpy (buffer, array->data, len); - wrapper_stream->current_position += len; - return len; - } else { - return 0; - } -} - -static gint -write (CamelStream *stream, - const gchar *buffer, - gint n) -{ - CamelSimpleDataWrapperStream *wrapper_stream; - CamelSimpleDataWrapper *wrapper; - GByteArray *array; - gint len; - const gchar *buffer_next; - gint left; - - wrapper_stream = CAMEL_SIMPLE_DATA_WRAPPER_STREAM (stream); - wrapper = wrapper_stream->wrapper; - g_return_val_if_fail (wrapper != NULL, -1); - array = wrapper->byte_array; - - len = MIN (n, array->len - wrapper_stream->current_position); - if (len > 0) { - memcpy (array->data, buffer, len); - buffer_next = buffer + len; - left = n - len; - } else { - /* If we are past the end of the array, fill with zeros. */ - if (wrapper_stream->current_position > array->len) { - gint saved_length; - - saved_length = array->len; - g_byte_array_set_size - (array, wrapper_stream->current_position); - memset (array->data + saved_length, - 0, - (wrapper_stream->current_position - - saved_length)); - } - - buffer_next = buffer; - left = n; - } - - if (n > 0) - g_byte_array_append (array, buffer_next, left); - - wrapper_stream->current_position += n; - return n; -} - -static void -flush (CamelStream *stream) -{ - /* No op, as we don't do any buffering. */ -} - -static gint -available (CamelStream *stream) -{ - CamelSimpleDataWrapperStream *wrapper_stream; - CamelSimpleDataWrapper *wrapper; - GByteArray *array; - gint available; - - wrapper_stream = CAMEL_SIMPLE_DATA_WRAPPER_STREAM (stream); - wrapper = wrapper_stream->wrapper; - g_return_val_if_fail (wrapper != NULL, -1); - array = wrapper->byte_array; - - available = array->len - wrapper_stream->current_position; - return MAX (available, 0); -} - -static gboolean -eos (CamelStream *stream) -{ - if (available (stream) > 0) - return TRUE; - else - return FALSE; -} - -static void -close (CamelStream *stream) -{ - /* Nothing to do, we have no associated file descriptor. */ -} - -static gint -seek (CamelStream *stream, - gint offset, - CamelStreamSeekPolicy policy) -{ - CamelSimpleDataWrapperStream *wrapper_stream; - gint new_position; - - wrapper_stream = CAMEL_SIMPLE_DATA_WRAPPER_STREAM (stream); - - switch (policy) { - case CAMEL_STREAM_SET: - new_position = offset; - break; - case CAMEL_STREAM_CUR: - new_position = wrapper_stream->current_position + offset; - break; - case CAMEL_STREAM_END: - new_position = wrapper_stream->wrapper->byte_array->len; - break; - default: - g_warning ("Unknown CamelStreamSeekPolicy %d.", policy); - return -1; - } - - wrapper_stream->current_position = new_position; - return new_position; -} - - -/* This handles destruction of the associated CamelDataWrapper. */ -/* Hm, this should never happen though, because we gtk_object_ref() the - wrapper. */ -static void -wrapper_destroy_cb (GtkObject *object, - gpointer data) -{ - CamelSimpleDataWrapperStream *stream; - - g_warning ("CamelSimpleDataWrapperStream: associated CamelSimpleDataWrapper was destroyed."); - stream = CAMEL_SIMPLE_DATA_WRAPPER_STREAM (object); - stream->wrapper = NULL; -} - - -/* GtkObject methods. */ - -static void -destroy (GtkObject *object) -{ - CamelSimpleDataWrapperStream *stream; - - stream = CAMEL_SIMPLE_DATA_WRAPPER_STREAM (object); - - gtk_object_unref (GTK_OBJECT (stream->wrapper)); - - if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -static void -class_init (CamelSimpleDataWrapperStreamClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) klass; - - parent_class = gtk_type_class (camel_stream_get_type ()); -} - -static void -init (CamelSimpleDataWrapperStream *simple_data_wrapper_stream) -{ - simple_data_wrapper_stream->current_position = 0; -} - - -GtkType -camel_simple_data_wrapper_stream_get_type (void) -{ - static GtkType type = 0; - - if (type == 0) { - static const GtkTypeInfo info = { - "CamelSimpleDataWrapperStream", - sizeof (CamelSimpleDataWrapperStream), - sizeof (CamelSimpleDataWrapperStreamClass), - (GtkClassInitFunc) class_init, - (GtkObjectInitFunc) init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (camel_stream_get_type (), &info); - } - - return type; -} - -void -camel_simple_data_wrapper_stream_construct (CamelSimpleDataWrapperStream *stream, - CamelSimpleDataWrapper *wrapper) -{ - g_return_if_fail (stream != NULL); - g_return_if_fail (CAMEL_IS_SIMPLE_DATA_WRAPPER_STREAM (stream)); - g_return_if_fail (wrapper != NULL); - g_return_if_fail (CAMEL_IS_SIMPLE_DATA_WRAPPER (wrapper)); - - gtk_object_ref (GTK_OBJECT (wrapper)); - stream->wrapper = wrapper; - gtk_signal_connect (GTK_OBJECT (wrapper), "destroy", - wrapper_destroy_cb, stream); -} - -CamelStream * -camel_simple_data_wrapper_stream_new (CamelSimpleDataWrapper *wrapper) -{ - CamelStream *stream; - - g_return_val_if_fail (wrapper != NULL, NULL); - g_return_val_if_fail (CAMEL_IS_SIMPLE_DATA_WRAPPER (wrapper), NULL); - - stream = gtk_type_new (camel_simple_data_wrapper_stream_get_type ()); - - camel_simple_data_wrapper_stream_construct - (CAMEL_SIMPLE_DATA_WRAPPER_STREAM (stream), wrapper); - - return stream; -} diff --git a/camel/camel-simple-data-wrapper-stream.h b/camel/camel-simple-data-wrapper-stream.h deleted file mode 100644 index bdb6741693..0000000000 --- a/camel/camel-simple-data-wrapper-stream.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* camel-simple-data-wrapper-stream.h - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef __CAMEL_SIMPLE_DATA_WRAPPER_STREAM_H__ -#define __CAMEL_SIMPLE_DATA_WRAPPER_STREAM_H__ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtk.h> - -#include "camel-simple-data-wrapper.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define CAMEL_TYPE_SIMPLE_DATA_WRAPPER_STREAM \ - (camel_simple_data_wrapper_stream_get_type ()) -#define CAMEL_SIMPLE_DATA_WRAPPER_STREAM(obj) \ - (GTK_CHECK_CAST ((obj), CAMEL_TYPE_SIMPLE_DATA_WRAPPER_STREAM, CamelSimpleDataWrapperStream)) -#define CAMEL_SIMPLE_DATA_WRAPPER_STREAM_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), CAMEL_TYPE_SIMPLE_DATA_WRAPPER_STREAM, CamelSimpleDataWrapperStreamClass)) -#define CAMEL_IS_SIMPLE_DATA_WRAPPER_STREAM(obj) \ - (GTK_CHECK_TYPE ((obj), CAMEL_TYPE_SIMPLE_DATA_WRAPPER_STREAM)) -#define CAMEL_IS_SIMPLE_DATA_WRAPPER_STREAM_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((obj), CAMEL_TYPE_SIMPLE_DATA_WRAPPER_STREAM)) - - -typedef struct _CamelSimpleDataWrapperStream CamelSimpleDataWrapperStream; -typedef struct _CamelSimpleDataWrapperStreamClass CamelSimpleDataWrapperStreamClass; - -struct _CamelSimpleDataWrapperStream { - CamelStream parent; - - CamelSimpleDataWrapper *wrapper; - gint current_position; -}; - -struct _CamelSimpleDataWrapperStreamClass { - CamelStreamClass parent_class; -}; - - -GtkType camel_simple_data_wrapper_stream_get_type (void); -CamelStream *camel_simple_data_wrapper_stream_new (CamelSimpleDataWrapper *wrapper); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __CAMEL_SIMPLE_DATA_WRAPPER_STREAM_H__ */ diff --git a/camel/camel-simple-data-wrapper.c b/camel/camel-simple-data-wrapper.c deleted file mode 100644 index fb1c682814..0000000000 --- a/camel/camel-simple-data-wrapper.c +++ /dev/null @@ -1,230 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-simple-data-wrapper.c : simple implementation of a data wrapper */ -/* store the data in a glib byte array */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> - -#include "camel-simple-data-wrapper.h" -#include "camel-simple-data-wrapper-stream.h" -#include "camel-log.h" - -static CamelDataWrapperClass *parent_class=NULL; - -/* Returns the class for a CamelDataWrapper */ -#define CSDW_CLASS(so) CAMEL_SIMPLE_DATA_WRAPPER_CLASS (GTK_OBJECT(so)->klass) - -static void _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -static void _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); -static void _finalize (GtkObject *object); -static CamelStream *_get_stream (CamelDataWrapper *data_wrapper); - -static void -camel_simple_data_wrapper_class_init (CamelSimpleDataWrapperClass *camel_simple_data_wrapper_class) -{ - CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_simple_data_wrapper_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_data_wrapper_class); - - parent_class = gtk_type_class (camel_data_wrapper_get_type ()); - /* virtual method definition */ - - /* virtual method overload */ - camel_data_wrapper_class->write_to_stream = _write_to_stream; - camel_data_wrapper_class->construct_from_stream = _construct_from_stream; - - camel_data_wrapper_class->get_stream = _get_stream; - - gtk_object_class->finalize = _finalize; -} - - -static void -camel_simple_data_wrapper_init (CamelSimpleDataWrapper *wrapper) -{ - wrapper->stream = NULL; -} - -GtkType -camel_simple_data_wrapper_get_type (void) -{ - static GtkType camel_simple_data_wrapper_type = 0; - - if (!camel_simple_data_wrapper_type) { - GtkTypeInfo camel_simple_data_wrapper_info = - { - "CamelSimpleDataWrapper", - sizeof (CamelSimpleDataWrapper), - sizeof (CamelSimpleDataWrapperClass), - (GtkClassInitFunc) camel_simple_data_wrapper_class_init, - (GtkObjectInitFunc) camel_simple_data_wrapper_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_simple_data_wrapper_type = gtk_type_unique (camel_data_wrapper_get_type (), &camel_simple_data_wrapper_info); - } - - return camel_simple_data_wrapper_type; -} - - -static void -_finalize (GtkObject *object) -{ - CamelSimpleDataWrapper *simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (object); - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMimePart::finalize\n"); - if (simple_data_wrapper->byte_array) g_byte_array_free (simple_data_wrapper->byte_array, TRUE); - - GTK_OBJECT_CLASS (parent_class)->finalize (object); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMimePart::finalize\n"); -} - - -/** - * camel_simple_data_wrapper_new: create a new CamelSimpleDataWrapper object - * - * - * - * Return value: - **/ -CamelSimpleDataWrapper * -camel_simple_data_wrapper_new () -{ - CamelSimpleDataWrapper *simple_data_wrapper; - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering new()\n"); - - simple_data_wrapper = (CamelSimpleDataWrapper *)gtk_type_new (CAMEL_SIMPLE_DATA_WRAPPER_TYPE); - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Leaving new()\n"); - return simple_data_wrapper; -} - - - -static void -_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CamelSimpleDataWrapper *simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper); - GByteArray *array; - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering _write_to_stream\n"); - - g_assert (data_wrapper); - g_assert (stream); - g_assert (simple_data_wrapper->byte_array); - array = simple_data_wrapper->byte_array; - if (array->len) - camel_stream_write (stream, (gchar *)array->data, array->len); - - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Leaving _write_to_stream\n"); -} - - -#define _CMSDW_TMP_BUF_SIZE 100 -static void -_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) -{ - CamelSimpleDataWrapper *simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper); - gint nb_bytes_read; - static gchar *tmp_buf; - GByteArray *array; - - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering _construct_from_stream\n"); - - g_assert (data_wrapper); - g_assert (stream); - - if (!tmp_buf) { - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::construct_from_stream allocating new temp buffer " - "with %d bytes\n", _CMSDW_TMP_BUF_SIZE); - tmp_buf = g_new (gchar, _CMSDW_TMP_BUF_SIZE); - } - - array = simple_data_wrapper->byte_array; - if (array) { - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::construct_from_stream freeing old byte array\n"); - g_byte_array_free (array, FALSE); - } - - array = g_byte_array_new (); - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::construct_from_stream new byte array address:%p\n", array); - simple_data_wrapper->byte_array = array; - nb_bytes_read = camel_stream_read (stream, tmp_buf, _CMSDW_TMP_BUF_SIZE); - while (nb_bytes_read>0) { - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::construct_from_stream read %d bytes from stream\n", nb_bytes_read); - if (nb_bytes_read>0) g_byte_array_append (array, tmp_buf, nb_bytes_read); - nb_bytes_read = camel_stream_read (stream, tmp_buf, _CMSDW_TMP_BUF_SIZE); - }; - - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Leaving _construct_from_stream\n"); -} - - - - -/** - * camel_simple_data_wrapper_set_text: set some text as data wrapper content - * @simple_data_wrapper: SimpleDataWrapper object - * @text: the text to use - * - * Utility routine used to set up the content of a SimpleDataWrapper object - * to be a character string. - **/ -void -camel_simple_data_wrapper_set_text (CamelSimpleDataWrapper *simple_data_wrapper, const gchar *text) -{ - GByteArray *array; - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering set_text\n"); - - array = simple_data_wrapper->byte_array; - if (array) { - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::set_text freeing old byte array\n"); - g_byte_array_free (array, FALSE); - } - - array = g_byte_array_new (); - simple_data_wrapper->byte_array = array; - - g_byte_array_append (array, text, strlen (text)); - - CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering set_text\n"); -} - - - -static CamelStream * -_get_stream (CamelDataWrapper *data_wrapper) -{ - CamelSimpleDataWrapper *simple_data_wrapper; - - simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper); - if (simple_data_wrapper->stream == NULL) { - CamelStream *s; - - s = camel_simple_data_wrapper_stream_new (simple_data_wrapper); - simple_data_wrapper->stream = s; - } - - return simple_data_wrapper->stream; -} diff --git a/camel/camel-simple-data-wrapper.h b/camel/camel-simple-data-wrapper.h deleted file mode 100644 index 335f512213..0000000000 --- a/camel/camel-simple-data-wrapper.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-simple-data-wrapper.c : simple implementation of a data wrapper */ -/* store the data in a glib byte array */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_SIMPLE_DATA_WRAPPER_H -#define CAMEL_SIMPLE_DATA_WRAPPER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include <stdio.h> -#include "camel-stream.h" -#include "camel-data-wrapper.h" - - - -#define CAMEL_SIMPLE_DATA_WRAPPER_TYPE (camel_simple_data_wrapper_get_type ()) -#define CAMEL_SIMPLE_DATA_WRAPPER(obj) (GTK_CHECK_CAST((obj), CAMEL_SIMPLE_DATA_WRAPPER_TYPE, CamelSimpleDataWrapper)) -#define CAMEL_SIMPLE_DATA_WRAPPER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SIMPLE_DATA_WRAPPER_TYPE, CamelSimpleDataWrapperClass)) -#define CAMEL_IS_SIMPLE_DATA_WRAPPER(o) (GTK_CHECK_TYPE((o), CAMEL_SIMPLE_DATA_WRAPPER_TYPE)) - - -typedef struct -{ - CamelDataWrapper parent_object; - - GByteArray *byte_array; - CamelStream *stream; -} CamelSimpleDataWrapper; - - - -typedef struct { - CamelDataWrapperClass parent_class; - - -} CamelSimpleDataWrapperClass; - - - -/* Standard Gtk function */ -GtkType camel_simple_data_wrapper_get_type (void); - - -/* public methods */ - -CamelSimpleDataWrapper *camel_simple_data_wrapper_new (); -void camel_simple_data_wrapper_set_text (CamelSimpleDataWrapper *simple_data_wrapper, const gchar *text); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_SIMPLE_DATA_WRAPPER_H */ diff --git a/camel/camel-store.c b/camel/camel-store.c deleted file mode 100644 index 153138a273..0000000000 --- a/camel/camel-store.c +++ /dev/null @@ -1,263 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camelStore.c : Abstract class for an email store */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "camel-store.h" -#include "camel-log.h" - -static CamelServiceClass *parent_class = NULL; - -/* Returns the class for a CamelStore */ -#define CS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass) - -static void _set_separator(CamelStore *store, gchar sep); -static CamelFolder *_get_root_folder(CamelStore *store); -static CamelFolder *_get_default_folder(CamelStore *store); -static void _init(CamelStore *store, CamelSession *session, const gchar *url_name); -static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name); -static gchar _get_separator (CamelStore *store); - -static void _finalize (GtkObject *object); - -static void -camel_store_class_init (CamelStoreClass *camel_store_class) -{ - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_store_class); - - parent_class = gtk_type_class (camel_service_get_type ()); - - /* virtual method definition */ - camel_store_class->init = _init; - camel_store_class->set_separator = _set_separator; - camel_store_class->get_separator = _get_separator; - camel_store_class->get_folder = _get_folder; - camel_store_class->get_root_folder = _get_root_folder; - camel_store_class->get_default_folder = _get_default_folder; - - /* virtual method overload */ - gtk_object_class->finalize = _finalize; -} - - - - - - - -GtkType -camel_store_get_type (void) -{ - static GtkType camel_store_type = 0; - - if (!camel_store_type) { - GtkTypeInfo camel_store_info = - { - "CamelStore", - sizeof (CamelStore), - sizeof (CamelStoreClass), - (GtkClassInitFunc) camel_store_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_store_type = gtk_type_unique (CAMEL_SERVICE_TYPE, &camel_store_info); - } - - return camel_store_type; -} - - - - - -/** - * camel_store_init: call store's init method - * @store: the store to initialize - * @session: session which instantiates the store - * @url_name: URL defining the store - * - * This routine is called by the session object from which this - * store is created. It must not be called directly. - * - **/ -void -camel_store_init (CamelStore *store, CamelSession *session, const gchar *url_name) -{ - g_assert(store); - CS_CLASS(store)->init (store, session, url_name); -} - - -/** - * init: method called by a session object to initialize a store object - * @store: the store to initialize - * @session: session which instantiates the store - * @url_name: URL defining the store - * - * This routine is called by the session object from which this - * store is created. Be careful, @url_name is used as a private field - * of the store object. - * - **/ -static void -_init (CamelStore *store, CamelSession *session, const gchar *url_name) -{ - -#warning re-enable assertion here. - g_assert(session); - g_assert(url_name); - - store->session = session; - gtk_object_ref (GTK_OBJECT (session)); - /*store->url_name = url_name;*/ -} - - -static void -_finalize (GtkObject *object) -{ - CamelStore *camel_store = CAMEL_STORE (object); - CAMEL_LOG_FULL_DEBUG ("Entering CamelStore::finalize\n"); - - /* if (camel_store->url_name) g_free (camel_store->url_name); */ - if (camel_store->session) gtk_object_unref (GTK_OBJECT (camel_store->session)); - - GTK_OBJECT_CLASS (parent_class)->finalize (object); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelStore::finalize\n"); -} - - - -/** - * camel_store_set_separator: set the character which separates this folder path from the folders names in a lower level of hierarchy. - * - * @store: - * @sep: - * - **/ -static void -_set_separator (CamelStore *store, gchar sep) -{ - store->separator = sep; -} - - - - - -static gchar -_get_separator (CamelStore *store) -{ - g_assert(store); - return store->separator; -} - - - -/** - * camel_store_get_separator: return the character which separates this folder path from the folders names in a lower level of hierarchy. - * @store: store - * - * - * - * Return value: the separator - **/ -gchar -camel_store_get_separator (CamelStore *store) -{ - return CS_CLASS(store)->get_separator (store); -} - - - - - - - -static CamelFolder * -_get_folder (CamelStore *store, const gchar *folder_name) -{ - return NULL; -} - - -/** - * camel_store_get_folder: return the folder corresponding to a path. - * @store: store - * @folder_name: name of the folder to get - * - * Returns the folder corresponding to the path "name". - * If the path begins with the separator caracter, it - * is relative to the root folder. Otherwise, it is - * relative to the default folder. - * The folder does not necessarily exist on the store. - * To make sure it already exists, use its "exists" method. - * If it does not exist, you can create it with its - * "create" method. - * - * - * Return value: the folder - **/ -CamelFolder * -camel_store_get_folder (CamelStore *store, const gchar *folder_name) -{ - return CS_CLASS(store)->get_folder (store, folder_name); -} - - -/** - * camel_store_get_root_folder : return the toplevel folder - * - * Returns the folder which is at the top of the folder - * hierarchy. This folder is generally different from - * the default folder. - * - * @Return value: the tolevel folder. - **/ -static CamelFolder * -_get_root_folder (CamelStore *store) -{ - return NULL; -} - -/** - * camel_store_get_default_folder : return the store default folder - * - * The default folder is the folder which is presented - * to the user in the default configuration. The default - * is often the root folder. - * - * @Return value: the default folder. - **/ -static CamelFolder * -_get_default_folder (CamelStore *store) -{ - return NULL; -} - - - diff --git a/camel/camel-store.h b/camel/camel-store.h deleted file mode 100644 index 05a5909501..0000000000 --- a/camel/camel-store.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-store.h : Abstract class for an email store */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_STORE_H -#define CAMEL_STORE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> - -typedef struct _CamelStore CamelStore; - -#include "camel-folder.h" -#include "camel-service.h" -#include "camel-session.h" - -#define CAMEL_STORE_TYPE (camel_store_get_type ()) -#define CAMEL_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_STORE_TYPE, CamelStore)) -#define CAMEL_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STORE_TYPE, CamelStoreClass)) -#define CAMEL_IS_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_STORE_TYPE)) - - -struct _CamelStore -{ - CamelService parent_object; - - CamelSession *session; - /* gchar *url_name; */ - gchar separator; -}; - - - -typedef struct { - CamelServiceClass parent_class; - - void (*init) (CamelStore *store, CamelSession *session, const gchar *url_name); - void (*set_separator) (CamelStore *store, gchar sep); - gchar (*get_separator) (CamelStore *store); - CamelFolder * (*get_folder) (CamelStore *store, const gchar *folder_name); - CamelFolder * (*get_root_folder) (CamelStore *store); - CamelFolder * (*get_default_folder) (CamelStore *store); - -} CamelStoreClass; - - -/* public methods */ - -/* Standard Gtk function */ -GtkType camel_store_get_type (void); - -void camel_store_init (CamelStore *store, CamelSession *session, const gchar *url_name); -CamelFolder *camel_store_get_folder (CamelStore *store, const gchar *folder_name); -gchar camel_store_get_separator (CamelStore *store); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_STORE_H */ diff --git a/camel/camel-stream-buffered-fs.c b/camel/camel-stream-buffered-fs.c deleted file mode 100644 index 40dfde6741..0000000000 --- a/camel/camel-stream-buffered-fs.c +++ /dev/null @@ -1,265 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-stream-buffered-fs.c : file system based stream with buffer*/ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include <config.h> -#include "camel-stream-buffered-fs.h" -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <errno.h> -#include "camel-log.h" - -static CamelStreamFsClass *parent_class=NULL; - - -/* Returns the class for a CamelStreamBufferedFs */ -#define CSBFS_CLASS(so) CAMEL_STREAM_BUFFERED_FS_CLASS (GTK_OBJECT(so)->klass) -#define CSFS_CLASS(so) CAMEL_STREAM_FS_CLASS (GTK_OBJECT(so)->klass) -#define CS_CLASS(so) CAMEL_STREAM_CLASS (GTK_OBJECT(so)->klass) - -static gint _read (CamelStream *stream, gchar *buffer, gint n); -static gint _write (CamelStream *stream, const gchar *buffer, gint n); -static void _flush (CamelStream *stream); -static gint _available (CamelStream *stream); -static gboolean _eos (CamelStream *stream); -static void _close (CamelStream *stream); -static gint _seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy); - -static void _finalize (GtkObject *object); -static void _destroy (GtkObject *object); - -static void -camel_stream_buffered_fs_class_init (CamelStreamBufferedFsClass *camel_stream_buffered_fs_class) -{ - CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_stream_buffered_fs_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_stream_buffered_fs_class); - - parent_class = gtk_type_class (camel_stream_fs_get_type ()); - - /* virtual method definition */ - - /* virtual method overload */ - camel_stream_class->read = _read; - - gtk_object_class->finalize = _finalize; - gtk_object_class->destroy = _destroy; - -} - -static void -camel_stream_buffered_fs_init (gpointer object, gpointer klass) -{ - CamelStreamBufferedFs *stream = CAMEL_STREAM_BUFFERED_FS (object); - - stream->buffer_size = 200; - stream->read_buffer = g_new (gchar, stream->buffer_size); - stream->write_buffer = g_new (gchar, stream->buffer_size); - stream->read_pos = 0; - stream->read_pos_max = 0; - stream->write_pos = 0; - stream->write_pos_max = stream->buffer_size; -} - -GtkType -camel_stream_buffered_fs_get_type (void) -{ - static GtkType camel_stream_buffered_fs_type = 0; - - gdk_threads_enter (); - if (!camel_stream_buffered_fs_type) { - GtkTypeInfo camel_stream_buffered_fs_info = - { - "CamelStreamBufferedFs", - sizeof (CamelStreamBufferedFs), - sizeof (CamelStreamBufferedFsClass), - (GtkClassInitFunc) camel_stream_buffered_fs_class_init, - (GtkObjectInitFunc) camel_stream_buffered_fs_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_stream_buffered_fs_type = gtk_type_unique (camel_stream_fs_get_type (), &camel_stream_buffered_fs_info); - } - gdk_threads_leave (); - return camel_stream_buffered_fs_type; -} - - -static void -_destroy (GtkObject *object) -{ - CamelStreamBufferedFs *stream_buffered_fs = CAMEL_STREAM_BUFFERED_FS (object); - - CAMEL_LOG_FULL_DEBUG ("Entering CamelStreamBufferedFs::destroy\n"); - - - GTK_OBJECT_CLASS (parent_class)->destroy (object); - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelStreamBufferedFs::destroy\n"); -} - - -static void -_finalize (GtkObject *object) -{ - CamelStreamBufferedFs *stream_buffered_fs = CAMEL_STREAM_BUFFERED_FS (object); - - - CAMEL_LOG_FULL_DEBUG ("Entering CamelStreamBufferedFs::finalize\n"); - - g_free (stream_buffered_fs->read_buffer); - g_free (stream_buffered_fs->write_buffer); - - GTK_OBJECT_CLASS (parent_class)->finalize (object); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelStreamBufferedFs::finalize\n"); -} - - - -CamelStream * -camel_stream_buffered_fs_new_with_name (const gchar *name, CamelStreamFsMode mode) -{ - CamelStreamFs *stream_buffered_fs; - stream_buffered_fs = gtk_type_new (camel_stream_buffered_fs_get_type ()); - CSFS_CLASS (stream_buffered_fs)->init_with_name (stream_buffered_fs, name, mode); - - return CAMEL_STREAM (stream_buffered_fs); - -} - -CamelStream * -camel_stream_buffered_fs_new_with_fd (int fd) -{ - CamelStreamFs *stream_buffered_fs; - - CAMEL_LOG_FULL_DEBUG ( "Entering CamelStream::new_with_fd fd=%d\n",fd); - stream_buffered_fs = gtk_type_new (camel_stream_buffered_fs_get_type ()); - CSFS_CLASS (stream_buffered_fs)->init_with_fd (stream_buffered_fs, fd); - - - return CAMEL_STREAM (stream_buffered_fs); -} - -/** - * _read: read bytes from a stream - * @stream: stream - * @buffer: buffer where bytes are stored - * @n: max number of bytes to read - * - * - * - * Return value: number of bytes actually read. - **/ -static gint -_read (CamelStream *stream, gchar *buffer, gint n) -{ - CamelStreamBufferedFs *sbf = CAMEL_STREAM_BUFFERED_FS (stream); - gint v; - gint nb_bytes_buffered; - gint nb_bytes_to_read = n; - gint nb_bytes_read = 0; - gint bytes_chunk; - gboolean eof = FALSE; - - g_return_val_if_fail (n>0, n); - - nb_bytes_buffered = sbf->read_pos_max - sbf->read_pos; - while ( (!eof) && (nb_bytes_to_read>0)) { - if (nb_bytes_buffered <= 0) { - /* have to read some data on disk */ - v = CAMEL_STREAM_CLASS (parent_class)->read (stream, sbf->read_buffer, sbf->buffer_size); - nb_bytes_buffered = v; - sbf->read_pos_max = v; - sbf->read_pos = 0; - } - - /* nb of bytes to put inside buffer */ - bytes_chunk = MIN (nb_bytes_buffered, nb_bytes_to_read); - - if (bytes_chunk > 0) { - /* copy some bytes from the cache */ - memcpy (buffer, sbf->read_buffer + sbf->read_pos, bytes_chunk); - nb_bytes_buffered -= bytes_chunk; - nb_bytes_to_read -= bytes_chunk; - nb_bytes_read += bytes_chunk; - sbf->read_pos += bytes_chunk; - - } else /* nb_bytes_to_read is >0 so if bytes_chunk is <0 - * there was no data available */ - eof = TRUE; - } - - - - return nb_bytes_read; -} - - -static gint -_write (CamelStream *stream, const gchar *buffer, gint n) -{ - return 0; -} - - - -static void -_flush (CamelStream *stream) -{ - -} - - - -static gint -_available (CamelStream *stream) -{ - return 0; -} - - -static gboolean -_eos (CamelStream *stream) -{ - return FALSE; -} - - - -static void -_close (CamelStream *stream) -{ - -} - - -static gint -_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy) -{ - return 0; -} diff --git a/camel/camel-stream-buffered-fs.h b/camel/camel-stream-buffered-fs.h deleted file mode 100644 index 65a64b4340..0000000000 --- a/camel/camel-stream-buffered-fs.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-stream-bufered-fs.h :stream based on unix filesystem */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_STREAM_BUFFERED_FS_H -#define CAMEL_STREAM_BUFFERED_FS_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include <stdio.h> -#include "camel-stream-fs.h" - -#define CAMEL_STREAM_BUFFERED_FS_TYPE (camel_stream_buffered_fs_get_type ()) -#define CAMEL_STREAM_BUFFERED_FS(obj) (GTK_CHECK_CAST((obj), CAMEL_STREAM_BUFFERED_FS_TYPE, CamelStreamBufferedFs)) -#define CAMEL_STREAM_BUFFERED_FS_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STREAM_BUFFERED_FS_TYPE, CamelStreamBufferedFsClass)) -#define CAMEL_IS_STREAM_BUFFERED_FS(o) (GTK_CHECK_TYPE((o), CAMEL_STREAM_BUFFERED_FS_TYPE)) - -typedef enum -{ - CAMEL_STREAM_BUFFERED_FS_READ = 1, - CAMEL_STREAM_BUFFERED_FS_WRITE = 2 -} CamelStreamBufferedFsMode; - - -typedef struct -{ - CamelStreamFs parent_object; - - gint buffer_size; - gchar *read_buffer; - gint read_pos; - gint read_pos_max; - - gchar *write_buffer; - gint write_pos; - gint write_pos_max; - -} CamelStreamBufferedFs; - - - -typedef struct { - CamelStreamFsClass parent_class; - - /* Virtual methods */ - -} CamelStreamBufferedFsClass; - - - -/* Standard Gtk function */ -GtkType camel_stream_buffered_fs_get_type (void); - - -/* public methods */ -CamelStream *camel_stream_buffered_fs_new_with_name (const gchar *name, CamelStreamBufferedFsMode mode); -CamelStream *camel_stream_buffered_fs_new_with_fd (int fd); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_STREAM_BUFFERED_FS_H */ diff --git a/camel/camel-stream-data-wrapper.c b/camel/camel-stream-data-wrapper.c deleted file mode 100644 index 38ac8d92c1..0000000000 --- a/camel/camel-stream-data-wrapper.c +++ /dev/null @@ -1,209 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* camel-stream-data-wrapper.c - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtk.h> - -#include "camel-stream-data-wrapper.h" - - -static CamelDataWrapperClass *parent_class = NULL; - - -/* CamelDataWrapper methods. */ - -static void -write_to_stream (CamelDataWrapper *data_wrapper, - CamelStream *output_stream) -{ -#define BUFFER_SIZE 4096 - gchar buffer[BUFFER_SIZE]; - CamelStreamDataWrapper *stream_data_wrapper; - CamelStream *input_stream; - - stream_data_wrapper = CAMEL_STREAM_DATA_WRAPPER (data_wrapper); - input_stream = stream_data_wrapper->stream; - - while (TRUE) { - gchar *p; - gint read, written; - - read = camel_stream_read (input_stream, buffer, BUFFER_SIZE); - if (read == 0) - break; - - p = buffer; - while (read > 0) { - written = camel_stream_write (output_stream, p, read); - - /* FIXME no way to report an error?! */ - if (written == -1) - break; - - p += written; - read -= written; - } - } -#undef BUFFER_SIZE -} - -static CamelStream * -get_stream (CamelDataWrapper *data_wrapper) -{ - CamelStreamDataWrapper *stream_data_wrapper; - - stream_data_wrapper = CAMEL_STREAM_DATA_WRAPPER (data_wrapper); - return stream_data_wrapper->stream; -} - - -/* GtkObject methods. */ - -static void -destroy (GtkObject *object) -{ - CamelStreamDataWrapper *stream_data_wrapper; - GtkObject *stream_object; - - stream_data_wrapper = CAMEL_STREAM_DATA_WRAPPER (object); - - stream_object = GTK_OBJECT (object); - stream_data_wrapper->stream = NULL; - - gtk_object_unref (stream_object); -} - - -/* This handles destruction of the associated CamelDataWrapper outside - CamelStreamDataWrapper, for debuggin purposes (this should never happen). */ -static void -stream_destroy_cb (GtkObject *object, - gpointer data) -{ - CamelStreamDataWrapper *wrapper; - - wrapper = CAMEL_STREAM_DATA_WRAPPER (data); - - /* Hack: when we destroy the stream ourselves, we set the `stream' - member to NULL first, so that we can recognize when this is done out - of our control. */ - if (wrapper->stream != NULL) { - g_warning ("CamelSimpleDataWrapperStream: associated CamelSimpleDataWrapper was destroyed."); - wrapper->stream = NULL; - } -} - - -static void -class_init (CamelStreamDataWrapperClass *class) -{ - GtkObjectClass *object_class; - CamelDataWrapperClass *data_wrapper_class; - - object_class = GTK_OBJECT_CLASS (class); - object_class->destroy = destroy; - - data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (class); - data_wrapper_class->write_to_stream = write_to_stream; - data_wrapper_class->get_stream = get_stream; - - parent_class = gtk_type_class (camel_data_wrapper_get_type ()); -} - -static void -init (CamelStreamDataWrapper *wrapper) -{ - wrapper->stream = NULL; -} - - -GtkType -camel_stream_data_wrapper_get_type (void) -{ - static GtkType type = 0; - - if (type == 0) { - static const GtkTypeInfo info = { - "CamelStreamDataWrapper", - sizeof (CamelStreamDataWrapper), - sizeof (CamelStreamDataWrapperClass), - (GtkClassInitFunc) class_init, - (GtkObjectInitFunc) init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (camel_data_wrapper_get_type (), &info); - } - - return type; -} - -/** - * camel_stream_data_wrapper_construct: - * @wrapper: A CamelStreamDataWrapper object - * @stream: A Camel stream object - * - * Construct @wrapper associating @stream to it. Notice that, after this call, - * @stream is conceptually owned by @wrapper and will be destroyed when - * @wrapper is destroyed. - **/ -void -camel_stream_data_wrapper_construct (CamelStreamDataWrapper *wrapper, - CamelStream *stream) -{ - g_return_if_fail (wrapper != NULL); - g_return_if_fail (CAMEL_IS_STREAM_DATA_WRAPPER (wrapper)); - g_return_if_fail (stream != NULL); - g_return_if_fail (CAMEL_IS_STREAM (stream)); - - wrapper->stream = stream; - gtk_signal_connect (GTK_OBJECT (stream), "destroy", - GTK_SIGNAL_FUNC (stream_destroy_cb), wrapper); -} - -/** - * camel_stream_data_wrapper_new: - * @stream: A Camel stream object - * - * Create a new stream data wrapper object for @stream. Notice that, after - * this call, @stream is conceptually owned by the new wrapper and will be - * destroyed when the wrapper is destroyed. - * - * Return value: A pointer to the new CamelStreamDataWrapper object. - **/ -CamelDataWrapper * -camel_stream_data_wrapper_new (CamelStream *stream) -{ - CamelDataWrapper *wrapper; - - wrapper = gtk_type_new (camel_stream_data_wrapper_get_type ()); - camel_stream_data_wrapper_construct - (CAMEL_STREAM_DATA_WRAPPER (wrapper), stream); - - return wrapper; -} diff --git a/camel/camel-stream-data-wrapper.h b/camel/camel-stream-data-wrapper.h deleted file mode 100644 index b804f748d7..0000000000 --- a/camel/camel-stream-data-wrapper.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* camel-stream-data-wrapper.h - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef __CAMEL_STREAM_DATA_WRAPPER_H__ -#define __CAMEL_STREAM_DATA_WRAPPER_H__ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtk.h> -#include "camel-data-wrapper.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - - -#define CAMEL_TYPE_STREAM_DATA_WRAPPER \ - (camel_stream_data_wrapper_get_type ()) -#define CAMEL_STREAM_DATA_WRAPPER(obj) \ - (GTK_CHECK_CAST ((obj), CAMEL_TYPE_STREAM_DATA_WRAPPER, CamelStreamDataWrapper)) -#define CAMEL_STREAM_DATA_WRAPPER_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), CAMEL_TYPE_STREAM_DATA_WRAPPER, CamelStreamDataWrapperClass)) -#define CAMEL_IS_STREAM_DATA_WRAPPER(obj) \ - (GTK_CHECK_TYPE ((obj), CAMEL_TYPE_STREAM_DATA_WRAPPER)) -#define CAMEL_IS_STREAM_DATA_WRAPPER_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((obj), CAMEL_TYPE_STREAM_DATA_WRAPPER)) - - -typedef struct _CamelStreamDataWrapper CamelStreamDataWrapper; -typedef struct _CamelStreamDataWrapperClass CamelStreamDataWrapperClass; - -struct _CamelStreamDataWrapper { - CamelDataWrapper parent; - - CamelStream *stream; -}; - -struct _CamelStreamDataWrapperClass { - CamelDataWrapperClass parent_class; -}; - - -GtkType camel_stream_data_wrapper_get_type (void); -CamelDataWrapper *camel_stream_data_wrapper_new (CamelStream *stream); -void camel_stream_data_wrapper_construct (CamelStreamDataWrapper *wrapper, - CamelStream *stream); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __CAMEL_STREAM_DATA_WRAPPER_H__ */ diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c deleted file mode 100644 index 43d7fafabb..0000000000 --- a/camel/camel-stream-fs.c +++ /dev/null @@ -1,355 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-stream-fs.c : file system based stream */ - -/* inspired by gnome-stream-fs.c in bonobo by Miguel de Icaza */ -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "camel-stream-fs.h" -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <errno.h> -#include <string.h> -#include "camel-log.h" - -static CamelStreamClass *parent_class=NULL; - - -/* Returns the class for a CamelStreamFS */ -#define CSFS_CLASS(so) CAMEL_STREAM_FS_CLASS (GTK_OBJECT(so)->klass) - -static gint _read (CamelStream *stream, gchar *buffer, gint n); -static gint _write (CamelStream *stream, const gchar *buffer, gint n); -static void _flush (CamelStream *stream); -static gint _available (CamelStream *stream); -static gboolean _eos (CamelStream *stream); -static void _close (CamelStream *stream); -static gint _seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy); - -static void _finalize (GtkObject *object); -static void _destroy (GtkObject *object); - -static void _init_with_fd (CamelStreamFs *stream_fs, int fd); -static void _init_with_name (CamelStreamFs *stream_fs, const gchar *name, CamelStreamFsMode mode); - -static void -camel_stream_fs_class_init (CamelStreamFsClass *camel_stream_fs_class) -{ - CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_stream_fs_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_stream_fs_class); - - parent_class = gtk_type_class (camel_stream_get_type ()); - - /* virtual method definition */ - camel_stream_fs_class->init_with_fd = _init_with_fd; - camel_stream_fs_class->init_with_name = _init_with_name; - - /* virtual method overload */ - camel_stream_class->read = _read; - camel_stream_class->write = _write; - camel_stream_class->flush = _flush; - camel_stream_class->available = _available; - camel_stream_class->eos = _eos; - camel_stream_class->close = _close; - camel_stream_class->seek = _seek; - - gtk_object_class->finalize = _finalize; - gtk_object_class->destroy = _destroy; - -} - -static void -camel_stream_fs_init (gpointer object, gpointer klass) -{ - CamelStreamFs *stream = CAMEL_STREAM_FS (object); - - stream->name = NULL; -} - - -GtkType -camel_stream_fs_get_type (void) -{ - static GtkType camel_stream_fs_type = 0; - - if (!camel_stream_fs_type) { - GtkTypeInfo camel_stream_fs_info = - { - "CamelStreamFs", - sizeof (CamelStreamFs), - sizeof (CamelStreamFsClass), - (GtkClassInitFunc) camel_stream_fs_class_init, - (GtkObjectInitFunc) camel_stream_fs_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_stream_fs_type = gtk_type_unique (camel_stream_get_type (), &camel_stream_fs_info); - } - - return camel_stream_fs_type; -} - - -static void -_destroy (GtkObject *object) -{ - CamelStreamFs *stream_fs = CAMEL_STREAM_FS (object); - gint close_error; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelStreamFs::destroy\n"); - - close_error = close (stream_fs->fd); - if (close_error) { - CAMEL_LOG_FULL_DEBUG ("CamelStreamFs::destroy Error while closing file descriptor\n"); - CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno)); - } - GTK_OBJECT_CLASS (parent_class)->destroy (object); - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelStreamFs::destroy\n"); -} - - -static void -_finalize (GtkObject *object) -{ - CamelStreamFs *stream_fs = CAMEL_STREAM_FS (object); - - - CAMEL_LOG_FULL_DEBUG ("Entering CamelStreamFs::finalize\n"); - - g_free (stream_fs->name); - - GTK_OBJECT_CLASS (parent_class)->finalize (object); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelStreamFs::finalize\n"); -} - -static void -_init_with_fd (CamelStreamFs *stream_fs, int fd) -{ - stream_fs->fd = fd; -} - -static void -_init_with_name (CamelStreamFs *stream_fs, const gchar *name, CamelStreamFsMode mode) -{ - struct stat s; - int v, fd; - int flags; - - g_assert (name); - CAMEL_LOG_FULL_DEBUG ( "Entering CamelStream::new_with_name, name=\"%s\", mode=%d\n", name, mode); - v = stat (name, &s); - - if (mode & CAMEL_STREAM_FS_READ){ - if (mode & CAMEL_STREAM_FS_WRITE) - flags = O_RDWR | O_CREAT; - else - flags = O_RDONLY; - } else { - if (mode & CAMEL_STREAM_FS_WRITE) - flags = O_WRONLY | O_CREAT; - else - return; - } - if ( (mode & CAMEL_STREAM_FS_READ) && !(mode & CAMEL_STREAM_FS_WRITE) ) - if (v == -1) return; - - fd = open (name, flags, 0600); - if (fd==-1) { - CAMEL_LOG_WARNING ( "CamelStreamFs::new_with_name can not obtain fd for file \"%s\"\n", name); - CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno)); - return; - } - - stream_fs->name = g_strdup (name); - CSFS_CLASS (stream_fs)->init_with_fd (stream_fs, fd); - - - -} - - -CamelStream * -camel_stream_fs_new_with_name (const gchar *name, CamelStreamFsMode mode) -{ - CamelStreamFs *stream_fs; - stream_fs = gtk_type_new (camel_stream_fs_get_type ()); - CSFS_CLASS (stream_fs)->init_with_name (stream_fs, name, mode); - - return CAMEL_STREAM (stream_fs); - -} - -CamelStream * -camel_stream_fs_new_with_fd (int fd) -{ - CamelStreamFs *stream_fs; - - CAMEL_LOG_FULL_DEBUG ( "Entering CamelStream::new_with_fd fd=%d\n",fd); - stream_fs = gtk_type_new (camel_stream_fs_get_type ()); - CSFS_CLASS (stream_fs)->init_with_fd (stream_fs, fd); - - - return CAMEL_STREAM (stream_fs); -} - -/** - * _read: read bytes from a stream - * @stream: stream - * @buffer: buffer where bytes are stored - * @n: max number of bytes to read - * - * - * - * Return value: number of bytes actually read. - **/ -static gint -_read (CamelStream *stream, gchar *buffer, gint n) -{ - gint v; - do { - v = read ( (CAMEL_STREAM_FS (stream))->fd, buffer, n); - } while (v == -1 && errno == EINTR); - if (v<0) - CAMEL_LOG_FULL_DEBUG ("CamelStreamFs::read v=%d\n", v); - return v; -} - - -/** - * _write: read bytes to a stream - * @stream: the stream - * @buffer: byte buffer - * @n: number of bytes to write - * - * - * - * Return value: the number of bytes actually written - * in the stream. - **/ -static gint -_write (CamelStream *stream, const gchar *buffer, gint n) -{ - int v; - g_assert (stream); - g_assert ((CAMEL_STREAM_FS (stream))->fd); - CAMEL_LOG_FULL_DEBUG ( "CamelStreamFs:: entering write. n=%d\n", n); - do { - v = write ( (CAMEL_STREAM_FS (stream))->fd, buffer, n); - } while (v == -1 && errno == EINTR); - -#if HARD_LOG_LEVEL >= FULL_DEBUG - if (v==-1) { - perror(""); - CAMEL_LOG_FULL_DEBUG ( "CamelStreamFs::write could not write bytes in stream\n"); - } -#endif - return v; - -} - - - -/** - * _flush: flush pending changes - * @stream: the stream - * - * - **/ -static void -_flush (CamelStream *stream) -{ - fsync ((CAMEL_STREAM_FS (stream))->fd); -} - - - -/** - * _available: return the number of bytes available for reading - * @stream: the stream - * - * Return the number of bytes available without blocking. - * - * Return value: the number of bytes available - **/ -static gint -_available (CamelStream *stream) -{ - g_warning ("Not implemented yet"); - return -1; -} - - -/** - * _eos: test if there are bytes left to read - * @stream: the stream - * - * - * - * Return value: true if all stream has been read - **/ -static gboolean -_eos (CamelStream *stream) -{ - g_warning ("Not implemented yet"); - return FALSE; -} - - -/** - * _close: close a stream - * @stream: the stream - * - * - **/ -static void -_close (CamelStream *stream) -{ - close ((CAMEL_STREAM_FS (stream))->fd); -} - - -static gint -_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy) -{ - int whence; - switch (policy) { - case CAMEL_STREAM_SET: - whence = SEEK_SET; - break; - case CAMEL_STREAM_CUR: - whence = SEEK_CUR; - break; - case CAMEL_STREAM_END: - whence = SEEK_END; - break; - default: - return -1; - } - - - return lseek ((CAMEL_STREAM_FS (stream))->fd, offset, whence); -} diff --git a/camel/camel-stream-fs.h b/camel/camel-stream-fs.h deleted file mode 100644 index 3f27cc5bc0..0000000000 --- a/camel/camel-stream-fs.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-stream-fs.h :stream based on unix filesystem */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_STREAM_FS_H -#define CAMEL_STREAM_FS_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include <stdio.h> -#include "camel-stream.h" - -#define CAMEL_STREAM_FS_TYPE (camel_stream_fs_get_type ()) -#define CAMEL_STREAM_FS(obj) (GTK_CHECK_CAST((obj), CAMEL_STREAM_FS_TYPE, CamelStreamFs)) -#define CAMEL_STREAM_FS_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STREAM_FS_TYPE, CamelStreamFsClass)) -#define CAMEL_IS_STREAM_FS(o) (GTK_CHECK_TYPE((o), CAMEL_STREAM_FS_TYPE)) - -typedef enum -{ - CAMEL_STREAM_FS_READ = 1, - CAMEL_STREAM_FS_WRITE = 2 -} CamelStreamFsMode; - - -typedef struct -{ - CamelStream parent_object; - gchar *name; - int fd; -} CamelStreamFs; - - - -typedef struct { - CamelStreamClass parent_class; - - /* Virtual methods */ - void (*init_with_fd) (CamelStreamFs *stream_fs, int fd); - void (*init_with_name) (CamelStreamFs *stream_fs, const gchar *name, CamelStreamFsMode mode); - -} CamelStreamFsClass; - - - -/* Standard Gtk function */ -GtkType camel_stream_fs_get_type (void); - - -/* public methods */ -CamelStream *camel_stream_fs_new_with_name (const gchar *name, CamelStreamFsMode mode); -CamelStream *camel_stream_fs_new_with_fd (int fd); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_STREAM_FS_H */ diff --git a/camel/camel-stream-mem.c b/camel/camel-stream-mem.c deleted file mode 100644 index 82c6f2b1fc..0000000000 --- a/camel/camel-stream-mem.c +++ /dev/null @@ -1,286 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-stream-mem.c : memory buffer based stream */ - -/* inspired by gnome-stream-mem.c in bonobo by Miguel de Icaza */ -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "camel-stream-mem.h" -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <errno.h> -#include "camel-log.h" - -static CamelStreamClass *parent_class=NULL; - - -/* Returns the class for a CamelStreamMEM */ -#define CS_CLASS(so) CAMEL_STREAM_MEM_CLASS (GTK_OBJECT(so)->klass) - -static gint _read (CamelStream *stream, gchar *buffer, gint n); -static gint _write (CamelStream *stream, const gchar *buffer, gint n); -static void _flush (CamelStream *stream); -static gint _available (CamelStream *stream); -static gboolean _eos (CamelStream *stream); -static void _close (CamelStream *stream); -static gint _seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy); - -static void _finalize (GtkObject *object); - -static void -camel_stream_mem_class_init (CamelStreamMemClass *camel_stream_mem_class) -{ - CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_stream_mem_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_stream_mem_class); - - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - - /* virtual method overload */ - camel_stream_class->read = _read; - camel_stream_class->write = _write; - camel_stream_class->flush = _flush; - camel_stream_class->available = _available; - camel_stream_class->eos = _eos; - camel_stream_class->close = _close; - camel_stream_class->seek = _seek; - - gtk_object_class->finalize = _finalize; - -} - -static void -camel_stream_mem_init (gpointer object, gpointer klass) -{ - CamelStreamMem *camel_stream_mem = CAMEL_STREAM_MEM (object); - camel_stream_mem->position = 0; -} - -GtkType -camel_stream_mem_get_type (void) -{ - static GtkType camel_stream_mem_type = 0; - - if (!camel_stream_mem_type) { - GtkTypeInfo camel_stream_mem_info = - { - "CamelStreamMem", - sizeof (CamelStreamMem), - sizeof (CamelStreamMemClass), - (GtkClassInitFunc) camel_stream_mem_class_init, - (GtkObjectInitFunc) camel_stream_mem_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_stream_mem_type = gtk_type_unique (camel_stream_get_type (), &camel_stream_mem_info); - } - - return camel_stream_mem_type; -} - - -CamelStream * -camel_stream_mem_new (CamelStreamMemMode mode) -{ - CamelStreamMem *stream_mem; - GByteArray *buffer; - - buffer = g_byte_array_new (); - stream_mem = (CamelStreamMem *)camel_stream_mem_new_with_buffer (buffer, mode); - return CAMEL_STREAM (stream_mem); -} - - -CamelStream * -camel_stream_mem_new_with_buffer (GByteArray *buffer, CamelStreamMemMode mode) -{ - CamelStreamMem *stream_mem; - - stream_mem = gtk_type_new (camel_stream_mem_get_type ()); - stream_mem->mode = mode; - stream_mem->buffer = buffer; - - return CAMEL_STREAM (stream_mem); -} - - - -static void -_finalize (GtkObject *object) -{ - CamelStreamMem *stream_mem = CAMEL_STREAM_MEM (object); - - - CAMEL_LOG_FULL_DEBUG ("Entering CamelStreamMem::finalize\n"); - g_byte_array_free (stream_mem->buffer, TRUE); - - GTK_OBJECT_CLASS (parent_class)->finalize (object); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelStreamMem::finalize\n"); -} - - - -/** - * _read: read bytes from a stream - * @stream: stream - * @buffer: buffer where bytes are stored - * @n: max number of bytes to read - * - * - * - * Return value: number of bytes actually read. - **/ -static gint -_read (CamelStream *stream, gchar *buffer, gint n) -{ - CamelStreamMem *camel_stream_mem = CAMEL_STREAM_MEM (stream); - gint nb_bytes_to_read; - - g_assert (stream); - nb_bytes_to_read = MIN (n, (camel_stream_mem->buffer)->len - camel_stream_mem->position); - if (nb_bytes_to_read>0) { - memcpy (buffer, (camel_stream_mem->buffer)->data + camel_stream_mem->position, nb_bytes_to_read); - camel_stream_mem->position += nb_bytes_to_read; - } else nb_bytes_to_read = -1; - - return nb_bytes_to_read; -} - - -/** - * _write: read bytes to a stream - * @stream: the stream - * @buffer: byte buffer - * @n: number of bytes to write - * - * - * - * Return value: the number of bytes actually written - * in the stream. - **/ -static gint -_write (CamelStream *stream, const gchar *buffer, gint n) -{ - CamelStreamMem *camel_stream_mem = CAMEL_STREAM_MEM (stream); - - g_assert (stream); - g_return_val_if_fail (camel_stream_mem->position>=0, -1); - camel_stream_mem->buffer = g_byte_array_append (camel_stream_mem->buffer, (const guint8 *)buffer, n); - camel_stream_mem->position += n; - - return n; -} - - - -/** - * _flush: flush pending changes - * @stream: the stream - * - * - **/ -static void -_flush (CamelStream *stream) -{ - g_warning ("Not implemented yet"); -} - - - -/** - * _available: return the number of bytes available for reading - * @stream: the stream - * - * Return the number of bytes available without blocking. - * - * Return value: the number of bytes available - **/ -static gint -_available (CamelStream *stream) -{ - g_warning ("Not implemented yet"); - return -1; -} - - -/** - * _eos: test if there are bytes left to read - * @stream: the stream - * - * - * - * Return value: true if all stream has been read - **/ -static gboolean -_eos (CamelStream *stream) -{ - g_warning ("Not implemented yet"); - return FALSE; -} - - -/** - * _close: close a stream - * @stream: the stream - * - * - **/ -static void -_close (CamelStream *stream) -{ - g_warning ("Not implemented yet"); -} - - - -static gint -_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy) -{ - gint position; - CamelStreamMem *camel_stream_mem = CAMEL_STREAM_MEM (stream); - - switch (policy) { - case CAMEL_STREAM_SET: - position = offset; - break; - case CAMEL_STREAM_CUR: - position = camel_stream_mem->position + offset; - break; - case CAMEL_STREAM_END: - position = (camel_stream_mem->buffer)->len + offset; - break; - default: - return -1; - } - - position = MIN (position, (camel_stream_mem->buffer)->len); - position = MAX (position, 0); - - camel_stream_mem->position = position; - - return position; -} diff --git a/camel/camel-stream-mem.h b/camel/camel-stream-mem.h deleted file mode 100644 index d5d314d42d..0000000000 --- a/camel/camel-stream-mem.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-stream-mem.h :stream based on memory buffer */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_STREAM_MEM_H -#define CAMEL_STREAM_MEM_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include <stdio.h> -#include "camel-stream.h" - -#define CAMEL_STREAM_MEM_TYPE (camel_stream_mem_get_type ()) -#define CAMEL_STREAM_MEM(obj) (GTK_CHECK_CAST((obj), CAMEL_STREAM_MEM_TYPE, CamelStreamMem)) -#define CAMEL_STREAM_MEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STREAM_MEM_TYPE, CamelStreamMemClass)) -#define CAMEL_IS_STREAM_MEM(o) (GTK_CHECK_TYPE((o), CAMEL_STREAM_MEM_TYPE)) - -typedef enum -{ - CAMEL_STREAM_MEM_READ = 1, - CAMEL_STREAM_MEM_WRITE = 2, - CAMEL_STREAM_MEM_RW = 3 -} CamelStreamMemMode; - - -typedef struct -{ - CamelStream parent_object; - - GByteArray *buffer; - gint position; - CamelStreamMemMode mode; -} CamelStreamMem; - - - -typedef struct { - CamelStreamClass parent_class; - - /* Virtual methods */ - -} CamelStreamMemClass; - - - -/* Standard Gtk function */ -GtkType camel_stream_mem_get_type (void); - - -/* public methods */ -CamelStream *camel_stream_mem_new (CamelStreamMemMode mode); -CamelStream * camel_stream_mem_new_with_buffer (GByteArray *buffer, - CamelStreamMemMode mode); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_STREAM_MEM_H */ diff --git a/camel/camel-stream.c b/camel/camel-stream.c deleted file mode 100644 index 851a393cc0..0000000000 --- a/camel/camel-stream.c +++ /dev/null @@ -1,227 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-stream.c : abstract class for a stream */ - - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include "camel-stream.h" - -static GtkObjectClass *parent_class = NULL; - - -/* Returns the class for a CamelMimeMessage */ -#define CS_CLASS(so) CAMEL_STREAM_CLASS (GTK_OBJECT(so)->klass) - -static void -default_camel_flush (CamelStream *stream) -{ - /* nothing */ -} - -static void -default_camel_close (CamelStream *stream) -{ - /* nothing */ -} - -static gint -default_camel_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy) -{ - /* nothing */ - return -1; -} - -static void -camel_stream_class_init (CamelStreamClass *camel_stream_class) -{ - - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - camel_stream_class->read = NULL; - camel_stream_class->write = NULL; - camel_stream_class->flush = default_camel_flush; - camel_stream_class->available = NULL; - camel_stream_class->eos = NULL; - camel_stream_class->close = default_camel_close; - camel_stream_class->seek = default_camel_seek; - - /* virtual method overload */ -} - -GtkType -camel_stream_get_type (void) -{ - static GtkType camel_stream_type = 0; - - if (!camel_stream_type) { - GtkTypeInfo camel_stream_info = - { - "CamelStream", - sizeof (CamelStream), - sizeof (CamelStreamClass), - (GtkClassInitFunc) camel_stream_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_stream_type = gtk_type_unique (gtk_object_get_type (), &camel_stream_info); - } - - return camel_stream_type; -} - -/** - * camel_stream_read: - * @stream: a CamelStream. - * @buffer: buffer where bytes pulled from the stream are stored. - * @n: max number of bytes to read. - * - * Read at most @n bytes from the @stream object and stores them - * in the buffer pointed at by @buffer. - * - * Return value: number of bytes actually read. - **/ -gint -camel_stream_read (CamelStream *stream, gchar *buffer, gint n) -{ - return CS_CLASS (stream)->read (stream, buffer, n); -} - -/** - * camel_stream_write: - * @stream: a CamelStream object. - * @buffer: buffer to write. - * @n: number of bytes to write - * - * Write @n bytes from the buffer pointed at by @buffer into @stream. - * - * Return value: the number of bytes actually written - * in the stream. - **/ -gint -camel_stream_write (CamelStream *stream, const gchar *buffer, gint n) -{ - return CS_CLASS (stream)->write (stream, buffer, n); -} - -/** - * camel_stream_flush: - * @stream: a CamelStream object - * - * Flushes the contents of the stream to its backing store. - **/ -void -camel_stream_flush (CamelStream *stream) -{ - CS_CLASS (stream)->flush (stream); -} - -/** - * camel_stream_available: - * @stream: a CamelStream object - * - * Return value: the number of bytes available. - **/ -gint -camel_stream_available (CamelStream *stream) -{ - return CS_CLASS (stream)->available (stream); -} - -/** - * camel_stream_eos: - * @stream: a CamelStream object - * - * Test if there are bytes left to read on the @stream object. - * - * Return value: %TRUE if all the contents on the stream has been read, or - * %FALSE if information is still available. - **/ -gboolean -camel_stream_eos (CamelStream *stream) -{ - return CS_CLASS (stream)->eos (stream); -} - - -/** - * camel_stram_close: - * @stream: a CamelStream object. - * - * Close the @stream object. - **/ -void -camel_stream_close (CamelStream *stream) -{ - CS_CLASS (stream)->close (stream); -} - - -/** - * camel_stream_seek: - * @stream: a CamelStream object. - * @offset: offset value - * @policy: what to do with the offset - * - * - * - * Return value: new position, -1 if operation failed. - **/ -gint -camel_stream_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy) -{ - return CS_CLASS (stream)->seek (stream, offset, policy); -} - - - - -/***************** Utility functions ********************/ - -/** - * came_stream_write_strings: - * @stream: a CamelStream object. - * @...: A %NULL terminated list of strings. - * - * This is a utility function that writes the list of - * strings into the @stream object. - */ -void -camel_stream_write_strings (CamelStream *stream, ... ) -{ - va_list args; - const char *string; - - va_start(args, stream); - string = va_arg (args, const char *); - - while (string) { - camel_stream_write_string (stream, string); - string = va_arg (args, char *); - } - va_end (args); -} diff --git a/camel/camel-stream.h b/camel/camel-stream.h deleted file mode 100644 index be2c0d2988..0000000000 --- a/camel/camel-stream.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-stream.h : class for an abstract stream */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_STREAM_H -#define CAMEL_STREAM_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> - -#define CAMEL_STREAM_TYPE (camel_stream_get_type ()) -#define CAMEL_STREAM(obj) (GTK_CHECK_CAST((obj), CAMEL_STREAM_TYPE, CamelStream)) -#define CAMEL_STREAM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STREAM_TYPE, CamelStreamClass)) -#define CAMEL_IS_STREAM(o) (GTK_CHECK_TYPE((o), CAMEL_STREAM_TYPE)) - -typedef enum -{ - CAMEL_STREAM_SET, - CAMEL_STREAM_CUR, - CAMEL_STREAM_END -} CamelStreamSeekPolicy; - -typedef struct -{ - GtkObject parent_object; - -} CamelStream; - - - -typedef struct { - GtkObjectClass parent_class; - - /* Virtual methods */ - gint (*read) (CamelStream *stream, gchar *buffer, gint n); - gint (*write) (CamelStream *stream, const gchar *buffer, gint n); - void (*flush) (CamelStream *stream); - gint (*available) (CamelStream *stream); - gboolean (*eos) (CamelStream *stream); - void (*close) (CamelStream *stream); - gint (*seek) (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy); -} CamelStreamClass; - - - -/* Standard Gtk function */ -GtkType camel_stream_get_type (void); - - -/* public methods */ -gint camel_stream_read (CamelStream *stream, gchar *buffer, gint n); -gint camel_stream_write (CamelStream *stream, const gchar *buffer, gint n); -void camel_stream_flush (CamelStream *stream); -gint camel_stream_available (CamelStream *stream); -gboolean camel_stream_eos (CamelStream *stream); -void camel_stream_close (CamelStream *stream); -gint camel_stream_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy); - -/* utility macros and funcs */ -#define camel_stream_write_string(stream, string) camel_stream_write ((stream), (string), strlen (string)) - -void camel_stream_write_strings (CamelStream *stream, ... ); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_STREAM_H */ diff --git a/camel/camel-thread-proxy.c b/camel/camel-thread-proxy.c deleted file mode 100644 index a73bb16aef..0000000000 --- a/camel/camel-thread-proxy.c +++ /dev/null @@ -1,569 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-folder-pt-proxy.c : proxy folder using posix threads */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - -#include <config.h> -#include "camel-log.h" -#include "camel-marshal-utils.h" -#include "camel-thread-proxy.h" -#include <pthread.h> -#include <unistd.h> -#include <string.h> -#include <errno.h> - - - -/* vocabulary: - * operation: commanded by the main thread, executed by the child thread - * callback: commanded by the child thread, generally when an operation is - * completed. Executed in the main thread, - */ - -/* needed for proper casts of async funcs when - * calling pthreads_create - */ -typedef void * (*thread_call_func) (void *); - -/* forward declarations */ -static gboolean -_thread_notification_catch (GIOChannel *source, - GIOCondition condition, - gpointer data); - -static void -_notify_availability (CamelThreadProxy *proxy, gchar op_name); - -static int -_init_notify_system (CamelThreadProxy *proxy); - - - -/** - * camel_thread_proxy_new: create a new proxy object - * - * Create a new proxy object. This proxy object can be used - * to run async operations and this operations can trigger - * callbacks. It can also be used to proxy signals. - * - * Return value: The newly created proxy object - **/ -CamelThreadProxy * -camel_thread_proxy_new () -{ - CamelThreadProxy *proxy; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelThreadProxy::new\n"); - - proxy = g_new (CamelThreadProxy, 1); - if (!proxy) - return NULL; - - proxy->server_op_queue = camel_op_queue_new (); - proxy->client_op_queue = camel_op_queue_new (); - proxy->signal_data_cond = g_cond_new(); - proxy->signal_data_mutex = g_mutex_new(); - if (_init_notify_system (proxy) < 0) { - g_free (proxy); - return NULL; - } - CAMEL_LOG_FULL_DEBUG ("Leaving CamelThreadProxy::new\n"); - return proxy; -} - - -/** - * camel_thread_proxy_free: free a proxy object - * @proxy: proxy object to free - * - * free a proxy object - **/ -void -camel_thread_proxy_free (CamelThreadProxy *proxy) -{ - CAMEL_LOG_FULL_DEBUG ("Entering CamelThreadProxy::free\n"); - - g_cond_free (proxy->signal_data_cond); - g_mutex_free (proxy->signal_data_mutex); - camel_op_queue_free (proxy->server_op_queue); - camel_op_queue_free (proxy->client_op_queue); - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelThreadProxy::free\n"); -} - - - - - -/* Operations handling */ - - -/** - * _op_run_free_notify: - * @folder: folder to notify when the operation is completed. - * @op: operation to run. - * - * run an operation, free the operation field - * and then notify the main thread of the op - * completion. - * - * this routine is intended to be called - * in a new thread (in _run_next_op_in_thread) - * - **/ -void -_op_run_free_and_notify (CamelOp *op) -{ - gboolean error; - CamelThreadProxy *th_proxy; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelThreadProxy::_op_run_free_and_notify\n"); - - camel_op_run (op); - camel_op_free (op); - th_proxy = camel_op_get_user_data (op); - _notify_availability (th_proxy, 'a'); - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelThreadProxy::_op_run_free_and_notify\n"); -} - - -/** - * _run_next_op_in_thread: - * @proxy_object: - * - * run the next operation pending in the proxy - * operation queue - **/ -static void -_run_next_op_in_thread (CamelThreadProxy *proxy) -{ - CamelOp *op; - CamelOpQueue *server_op_queue; - CamelThreadProxy *th_proxy; - pthread_t thread; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelThreadProxy::_run_next_op_in_thread\n"); - - server_op_queue = proxy->server_op_queue; - /* get the next pending operation */ - op = camel_op_queue_pop_op (server_op_queue); - if (!op) { - camel_op_queue_set_service_availability (server_op_queue, TRUE); - return; - } - - /* run the operation in a child thread */ - pthread_create (&thread, NULL, (thread_call_func) _op_run_free_and_notify, op); - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelThreadProxy::_run_next_op_in_thread\n"); -} - - - -/** - * camel_thread_proxy_push_op: push an operation in the proxy operation queue - * @proxy: proxy object - * @op: operation to push in the execution queue - * - * if no thread is currently running, executes the - * operation directly, otherwise push the operation - * in the proxy operation queue. - **/ -void -camel_thread_proxy_push_op (CamelThreadProxy *proxy, CamelOp *op) -{ - CamelOpQueue *server_op_queue; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelThreadProxy::camel_thread_proxy_push_op\n"); - - g_assert (proxy); - server_op_queue = proxy->server_op_queue; - - /* put the proxy object in the user data - so that it can be notified when the - operation is completed */ - camel_op_set_user_data (op, (gpointer)proxy); - - /* get next operation */ - camel_op_queue_push_op (server_op_queue, op); - - if (camel_op_queue_get_service_availability (server_op_queue)) { - /* no thread is currently running, run - * the next operation. */ - camel_op_queue_set_service_availability (server_op_queue, FALSE); - /* when the operation is completed in the - child thread the main thread gets - notified and executes next operation - (see _thread_notification_catch, case 'a') - so there is no need to set the service - availability to FALSE except here - */ - _run_next_op_in_thread (proxy); - } - CAMEL_LOG_FULL_DEBUG ("Leaving CamelThreadProxy::camel_thread_proxy_push_op\n"); -} -/** - * _op_run_and_free: Run an operation and free it - * @op: Operation object - * - * Run an operation object in the current thread - * and free it. - **/ -static void -_op_run_and_free (CamelOp *op) -{ - CAMEL_LOG_FULL_DEBUG ("Entering CamelThreadProxy::_op_run_and_free\n"); - camel_op_run (op); - camel_op_free (op); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelThreadProxy::_op_run_and_free\n"); -} - - - - - - -/* Callbacks handling */ - -/** - * _run_next_cb: Run next callback pending in a proxy object - * @proxy: Proxy object - * - * Run next callback in the callback queue of a proxy object - **/ -static void -_run_next_cb (CamelThreadProxy *proxy) -{ - CamelOp *op; - CamelOpQueue *client_op_queue; - CamelThreadProxy *th_proxy; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelThreadProxy::_run_next_cb\n"); - client_op_queue = proxy->client_op_queue; - - /* get the next pending operation */ - op = camel_op_queue_pop_op (client_op_queue); - if (!op) return; - - /* run the operation in the main thread */ - _op_run_and_free (op); - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelThreadProxy::_run_next_cb\n"); -} - - -/** - * camel_thread_proxy_push_cb: push a callback in the client queue - * @proxy: proxy object concerned by the callback - * @cb: callback to push - * - * Push an operation in the client queue, ie the queue - * containing the operations (callbacks) intended to be - * executed in the main thread. - **/ -void -camel_thread_proxy_push_cb (CamelThreadProxy *proxy, CamelOp *cb) -{ - CamelOpQueue *client_op_queue; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelThreadProxy::camel_thread_proxy_push_cb\n"); - client_op_queue = proxy->client_op_queue; - - /* put the proxy object in the user data - so that it can be notified when the - operation is completed */ - camel_op_set_user_data (cb, (gpointer)proxy); - - /* push the callback in the client queue */ - camel_op_queue_push_op (client_op_queue, cb); - - /* tell the main thread a new callback is there */ - _notify_availability (proxy, 'c'); - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelThreadProxy::camel_thread_proxy_push_cb\n"); -} - - - -/** - * _init_notify_system: set the notify channel up - * @proxy: proxy object - * - * called once to set the notification channel up - **/ -static int -_init_notify_system (CamelThreadProxy *proxy) -{ - int filedes[2]; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelThreadProxy::_init_notify_system\n"); - - /* set up the notification channel */ - if (pipe (filedes) < 0) { - CAMEL_LOG_WARNING ("could not create pipe in CamelThreadProxy::_init_notify_system\n"); - CAMEL_LOG_FULL_DEBUG ("Full error message : %s\n", strerror(errno)); - return -1; - } - - - proxy->pipe_client_fd = filedes [0]; - proxy->pipe_server_fd = filedes [1]; - proxy->notify_source = g_io_channel_unix_new (filedes [0]); - proxy->notify_channel = g_io_channel_unix_new (filedes [1]); - - /* the _thread_notification_catch function - * will be called in the main thread when the - * child thread writes some data in the channel */ - g_io_add_watch (proxy->notify_source, G_IO_IN, - _thread_notification_catch, - proxy); - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelThreadProxy::_init_notify_system\n"); - return 1; -} - -/** - * _notify_availability: notify the main thread from an event - * @proxy: proxy object - * @op_name: operation name - * - * called by child thread to notify the main - * thread something is available for him. - * What this thing is depends on @op_name: - * - * 'a' : thread available. That means the thread is ready - * to process an operation. - * 's' : a signal is available. Used by the signal proxy. - * - */ -static void -_notify_availability (CamelThreadProxy *proxy, gchar op_name) -{ - GIOChannel *notification_channel; - guint bytes_written; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelThreadProxy::_notify_availability\n"); - - notification_channel = proxy->notify_channel; - - do { - /* the write operation will trigger the - * watch on the main thread side */ - g_io_channel_write (notification_channel, - &op_name, - 1, - &bytes_written); - } while (bytes_written < 1); - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelThreadProxy::_notify_availability\n"); -} - - - -/* signal proxying */ - - - -/** - * _signal_marshaller_server_side: called in the child thread to proxy a signal - * @object: - * @data: - * @n_args: - * @args: - * - * - **/ -static void -_signal_marshaller_server_side (GtkObject *object, - gpointer data, - guint n_args, - GtkArg *args) -{ - CamelThreadProxy *proxy; - guint signal_id; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelThreadProxy::_signal_marshaller_server_side\n"); - proxy = CAMEL_THREAD_PROXY (gtk_object_get_data (object, "__proxy__")); - signal_id = (guint)data; - g_assert (proxy); - - g_mutex_lock (proxy->signal_data_mutex); - - /* we are going to wait for the main client thread - * to have emitted the last signal we asked him - * to proxy. - */ - while (proxy->signal_data.args) - g_cond_wait (proxy->signal_data_cond, - proxy->signal_data_mutex); - - proxy->signal_data.signal_id = signal_id; - proxy->signal_data.args = args; - - - g_mutex_unlock (proxy->signal_data_mutex); - - /* tell the main thread there is a signal pending */ - _notify_availability (proxy, 's'); - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelThreadProxy::_signal_marshaller_server_side\n"); -} - - -static void -_signal_marshaller_client_side (CamelThreadProxy *proxy) -{ - g_mutex_lock (proxy->signal_data_mutex); - g_assert (proxy->signal_data.args); - - CAMEL_LOG_FULL_DEBUG ("Entering CamelThreadProxy::_signal_marshaller_client_side\n"); - /* emit the pending signal */ - gtk_signal_emitv (GTK_OBJECT (proxy), - proxy->signal_data.signal_id, - proxy->signal_data.args); - - proxy->signal_data.args = NULL; - - /* if waiting for the signal to be treated, - * awake the client thread up - */ - g_cond_signal (proxy->signal_data_cond); - g_mutex_unlock (proxy->signal_data_mutex); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelThreadProxy::_signal_marshaller_client_side\n"); -} - - -/** - * camel_thread_proxy_add_signals: init the signal proxy - * @proxy: proxy - * @proxy_object: Proxy Gtk Object - * @real_object: Real Gtk Object - * @signal_to_proxy: NULL terminated array of signal name - * - * Add some signals to the list of signals to be - * proxied by the proxy object. - * The signals emitted by the real object in the child - * thread are reemited by the proxy object in the - * main thread. - **/ -void -camel_thread_proxy_add_signals (CamelThreadProxy *proxy, - GtkObject *proxy_object, - GtkObject *real_object, - char *signal_to_proxy[]) -{ - GtkType camel_folder_type; - guint i; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelThreadProxy::camel_thread_proxy_init_signals\n"); - - for (i=0; signal_to_proxy[i]; i++) { - /* connect the signal to the signal marshaller - * user_data is the signal id */ - gtk_signal_connect_full (GTK_OBJECT (real_object), - signal_to_proxy[i], - NULL, - _signal_marshaller_server_side, - (gpointer)gtk_signal_lookup (signal_to_proxy[i], - GTK_OBJECT_CLASS (real_object)->type), - NULL, - TRUE, - FALSE); - } - - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelThreadProxy::camel_thread_proxy_init_signals\n"); - - -} - -/**** catch notification from child thread ****/ -/** - * _thread_notification_catch: call by glib loop when data is available on the thread io channel - * @source: - * @condition: - * @data: - * - * called by watch set on the IO channel - * - * Return value: TRUE because we don't want the watch to be removed - **/ -static gboolean -_thread_notification_catch (GIOChannel *source, - GIOCondition condition, - gpointer data) -{ - CamelThreadProxy *proxy = CAMEL_THREAD_PROXY (data); - gchar op_name; - guint bytes_read; - GIOError error; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelThreadProxy::_thread_notification_catch\n"); - - - error = g_io_channel_read (source, - &op_name, - 1, - &bytes_read); - - while ((!error) && (bytes_read == 1)) { - - switch (op_name) { - case 'a': /* the thread is OK for a new operation */ - _run_next_op_in_thread (proxy); - break; - case 's': /* there is a pending signal to proxy */ - _signal_marshaller_client_side (proxy); - break; - case 'c': /* there is a cb pending in the main thread */ - _run_next_cb (proxy); - break; - } - - error = g_io_channel_read (source, - &op_name, - 1, - &bytes_read); - - } - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelThreadProxy::_thread_notification_catch\n"); - - /* do not remove the io watch */ - return TRUE; -} - - - - - - - - - - - diff --git a/camel/camel-thread-proxy.h b/camel/camel-thread-proxy.h deleted file mode 100644 index acd93e7552..0000000000 --- a/camel/camel-thread-proxy.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-folder-pt-proxy.h : proxy folder using posix threads */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - - - -#ifndef CAMEL_THREAD_PROXY_H -#define CAMEL_THREAD_PROXY_H 1 - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include "camel-op-queue.h" - -#define CAMEL_THREAD_PROXY(o) (CamelThreadProxy *)(o) - - -typedef struct { - guint signal_id; - GtkArg *args; -} CamelThreadProxySignalData; - - -typedef struct { - - GtkObject *real_object; - GtkObject *proxy_object; - - CamelOpQueue *server_op_queue; - CamelOpQueue *client_op_queue; - - - gint pipe_client_fd; - gint pipe_server_fd; - GIOChannel *notify_source; - GIOChannel *notify_channel; - - /* signal proxy */ - GMutex *signal_data_mutex; - GCond *signal_data_cond; - CamelThreadProxySignalData signal_data; - -} CamelThreadProxy; - - -CamelThreadProxy *camel_thread_proxy_new (); -void camel_thread_proxy_free (CamelThreadProxy *proxy); - -void camel_thread_proxy_push_op (CamelThreadProxy *proxy, CamelOp *op); -void camel_thread_proxy_push_cb (CamelThreadProxy *proxy, CamelOp *cb); - -void camel_thread_proxy_add_signals (CamelThreadProxy *proxy, - GtkObject *proxy_object, - GtkObject *real_object, - char *signal_to_proxy[]); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_THREAD_PROXY_H */ - - diff --git a/camel/camel.c b/camel/camel.c deleted file mode 100644 index 68d0a54407..0000000000 --- a/camel/camel.c +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include <config.h> -#include "camel.h" - -gint -camel_init() -{ -#ifdef G_THREADS_ENABLED - g_thread_init (NULL); -#else /* G_THREADS_ENABLED */ - printf ("Threads are not supported by glib\n"); -#endif /* G_THREADS_ENABLED */ - - /* return data_wrapper_repository_init (); */ -} diff --git a/camel/camel.h b/camel/camel.h deleted file mode 100644 index b21ccf5e78..0000000000 --- a/camel/camel.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_H -#define CAMEL_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include <camel/data-wrapper-repository.h> -#include <camel/data-wrapper-repository.h> -#include <camel/camel-log.h> -#include <camel/camel-data-wrapper.h> -#include <camel-simple-data-wrapper.h> -#include <camel-folder.h> -#include <camel-folder-pt-proxy.h> -#include <camel-marshal-utils.h> -#include <camel-mime-body-part.h> -#include <camel-mime-message.h> -#include <camel-mime-part.h> -#include <camel-multipart.h> -#include <camel-op-queue.h> -#include <camel-provider.h> -#include <camel-service.h> -#include <camel-session.h> -#include <camel-store.h> -#include <camel-stream.h> -#include <camel-stream-fs.h> -#include <camel-stream-mem.h> -#include <camel-thread-proxy.h> -#include <data-wrapper-repository.h> -#include <gmime-content-field.h> -#include <gmime-utils.h> -#include <gstring-util.h> -#include <string-utils.h> -#include <url-util.h> - -gint camel_init (); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_H */ diff --git a/camel/data-wrapper-repository.c b/camel/data-wrapper-repository.c deleted file mode 100644 index b0480d9688..0000000000 --- a/camel/data-wrapper-repository.c +++ /dev/null @@ -1,127 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - - -#include "data-wrapper-repository.h" -#include "camel-multipart.h" - - - -static DataWrapperRepository _repository; -static _initialized = -1; -GMimeContentField *_content_field; - - - -/** - * data_wrapper_repository_init: initialize data wrapper repository - * - * initialize the data wrapper repository. When the repository has - * already been initialized, returns -1. - * - * Return value: 1 if correctly initialized returns -1. - **/ -gint -data_wrapper_repository_init () -{ - if (_initialized != -1) return -1; - _repository.mime_links = g_hash_table_new (g_str_hash, g_str_equal); - data_wrapper_repository_set_data_wrapper_type ("multipart", camel_multipart_get_type()); - _content_field = gmime_content_field_new (NULL, NULL); - _initialized = 1; - return 1; -} - -/** - * data_wrapper_repository_set_data_wrapper_type: associate a data wrapper object type to a mime type - * @mime_type: mime type - * @object_type: object type - * - * Associate an object type to a mime type. - **/ -void -data_wrapper_repository_set_data_wrapper_type (const gchar *mime_type, GtkType object_type) -{ - gboolean already_exists; - gchar *old_mime_type; - GtkType old_gtk_type; - - already_exists = g_hash_table_lookup_extended (_repository.mime_links, (gpointer)mime_type, - (gpointer)&old_mime_type, (gpointer)&old_gtk_type); - if (already_exists) - g_hash_table_insert (_repository.mime_links, (gpointer)old_mime_type, (gpointer)object_type); - else - g_hash_table_insert (_repository.mime_links, (gpointer)g_strdup (mime_type), (gpointer)object_type); -} - - - -/** - * data_wrapper_repository_get_data_wrapper_type: get the gtk type object associated to a mime type - * @mime_type: mime type - * - * returns the GtkType of the data wrapper object associated to - * a particular mime type. The mime type must be a character string - * of the form "type/subtype" or simply "type". When the complete - * mime type ("type/subtype") is not associated to any particular - * data wrapper object, this routine looks for a default data wrapper - * for the main mime type ("type"). When no particular association is - * found for this mime type, the type of the SimpleDataWrapper is - * returned. - * - * - * Return value: the associated data wrapper object type. - **/ -GtkType -data_wrapper_repository_get_data_wrapper_type (const gchar *mime_type) -{ - gboolean exists; - gchar *old_mime_type; - GtkType gtk_type; - - /* find if the complete mime type exists */ - exists = g_hash_table_lookup_extended (_repository.mime_links, (gpointer)mime_type, - (gpointer)&old_mime_type, (gpointer)>k_type); - if (exists) /* the complete mime type exists, return it */ - return gtk_type; - else { - /* the complete mime type association does not exists */ - /* is there an association for the main mime type ? */ - gmime_content_field_construct_from_string (_content_field, mime_type); - exists = g_hash_table_lookup_extended (_repository.mime_links, (gpointer)(_content_field->type), - (gpointer)&old_mime_type, (gpointer)>k_type); - - if (exists) /* the main mime type association exists */ - return gtk_type; - else return camel_simple_data_wrapper_get_type(); - } - - - - -} - diff --git a/camel/data-wrapper-repository.h b/camel/data-wrapper-repository.h deleted file mode 100644 index 27f782878a..0000000000 --- a/camel/data-wrapper-repository.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef DATA_WRAPPER_REPOSITORY_H -#define DATA_WRAPPER_REPOSITORY_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <glib.h> -#include "camel-data-wrapper.h" - - - -typedef struct { - GHashTable *mime_links; -} DataWrapperRepository; - - -gint data_wrapper_repository_init (); -void data_wrapper_repository_set_data_wrapper_type (const gchar *mime_type, GtkType object_type); -GtkType data_wrapper_repository_get_data_wrapper_type (const gchar *mime_type); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* DATA_WRAPPER_REPOSITORY_H */ diff --git a/camel/gmime-base64.c b/camel/gmime-base64.c deleted file mode 100644 index db784f7143..0000000000 --- a/camel/gmime-base64.c +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Base64 handlers - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - */ -#include <config.h> -#include "gmime-base64.h" - -#define BSIZE 512 - -/* - * 64-based alphabet used by the the Base64 enconding - */ -static char *base64_alphabet = -"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -/** - * gmime_encode_base64: - * @input: The data source to be encoded in base64 format - * @output: Where to put the encoded information in. - * - * This routine encodes the information pulled from @input using - * base64 encoding and stores it on the @output CamelStream object - */ -void -gmime_encode_base64 (CamelStream *input, CamelStream *output) -{ - char buffer [BSIZE]; - char obuf [80]; /* Output is limited to 76 characters, rfc2045 */ - int n, i, j, state; - int keep = 0; - - state = 0; - j = 0; - while ((n = camel_stream_read (input, buffer, sizeof (buffer))) > 0){ - for (i = 0; i < n; i++, state++){ - char c = buffer [i]; - - switch (state % 3){ - case 0: - obuf [j++] = base64_alphabet [c >> 2]; - keep = (c & 3) << 4; - break; - case 1: - obuf [j++] = base64_alphabet [keep | (c >> 4)]; - keep = (c & 0xf) << 2; - break; - case 2: - obuf [j++] = base64_alphabet [keep | (c >> 6)]; - obuf [j++] = base64_alphabet [c & 0x3f]; - break; - } - - if (j == 72){ - obuf [j++] = '\r'; - obuf [j++] = '\n'; - camel_stream_write (output, obuf, j); - j = 0; - } - } - } - - switch (state % 3){ - case 0: - /* full ouput, nothing left to do */ - break; - - case 1: - obuf [j++] = base64_alphabet [keep]; - obuf [j++] = '='; - obuf [j++] = '='; - break; - - case 2: - obuf [j++] = base64_alphabet [keep]; - obuf [j++] = '='; - break; - } - camel_stream_write (output, obuf, j); - camel_stream_flush (output); -} - - -/** - * gmime_decode_base64: - * @input: A buffer in base64 format. - * @output: Destination where the decoded information is stored. - * - * This routine decodes the base64 information pulled from @input - * and stores it on the @output CamelStream object. - */ -void -gmime_decode_base64 (CamelStream *input, CamelStream *output) -{ -} diff --git a/camel/gmime-base64.h b/camel/gmime-base64.h deleted file mode 100644 index 58ddd58722..0000000000 --- a/camel/gmime-base64.h +++ /dev/null @@ -1,16 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Base64 handlers - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - */ - -#ifndef _GMIME_BASE64_H -#define _GMIME_BASE64_H - -#include "camel-stream.h" - -void gmime_encode_base64 (CamelStream *input, CamelStream *output); - -#endif diff --git a/camel/gmime-content-field.c b/camel/gmime-content-field.c deleted file mode 100644 index 43691f0d62..0000000000 --- a/camel/gmime-content-field.c +++ /dev/null @@ -1,370 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* mime-content_field.c : mime content type field utilities */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include <config.h> -#include "gmime-content-field.h" -#include "string-utils.h" -#include "camel-log.h" -#include <string.h> - - -/** - * gmime_content_field_new: Creates a new GMimeContentField object - * @type: mime type - * @subtype: mime subtype - * - * Creates a GMimeContentField object and initialize it with - * a mime type and a mime subtype. For example, - * gmime_content_field_new ("application", "postcript"); - * will create a content field with complete mime type - * "application/postscript" - * - * Return value: The newly created GMimeContentField object - **/ -GMimeContentField * -gmime_content_field_new (const gchar *type, const gchar *subtype) -{ - GMimeContentField *ctf; - - ctf = g_new (GMimeContentField, 1); - ctf->type = g_strdup (type); - ctf->subtype = g_strdup (subtype); - ctf->parameters = g_hash_table_new (g_str_hash, g_str_equal); - ctf->ref = 1; - - return ctf; -} - - -static void -_free_parameter (gpointer name, gpointer value, gpointer user_data) -{ - g_free (name); - g_free (value); -} - -/** - * gmime_content_field_free: free a GMimeContentField object - * @content_field: GMimeContentField object - * - * This method destroys the object and should be used very carefully. - * Use gmime_content_field_unref instead. - * - **/ -void -gmime_content_field_free (GMimeContentField *content_field) -{ - if (!content_field) return; - - g_hash_table_foreach (content_field->parameters, _free_parameter, NULL); - g_free (content_field->type); - g_free (content_field->subtype); - g_hash_table_destroy (content_field->parameters); - g_free (content_field); -} - -/** - * gmime_content_field_ref: add a reference to a GMimeContentField object - * @content_field: GMimeContentField object - * - * Tell a GMimeContentField object that something holds a reference - * on him. This, coupled with the corresponding - * gmime_content_field_unref() method allow several - * objects to use the same GMimeContentField object. - **/ -void -gmime_content_field_ref (GMimeContentField *content_field) -{ - content_field->ref += 1; -} - -/** - * gmime_content_field_unref: remove a reference to a GMimeContentField object - * @content_field: GMimeContentField object - * - * Tell a GMimeContentField object that something which - * was holding a reference to him does not need it anymore. - * When no more reference exist, the GMimeContentField object - * is freed using gmime_content_field_free(). - * - **/ -void -gmime_content_field_unref (GMimeContentField *content_field) -{ - if (!content_field) return; - - content_field->ref -= 1; - if (content_field->ref <= 0) - gmime_content_field_free (content_field); -} - - - -/** - * gmime_content_field_set_parameter: set a parameter for a GMimeContentField object - * @content_field: content field - * @attribute: parameter name - * @value: paramteter value - * - * set a parameter (called attribute in RFC 2045) of a content field. Meaningfull - * or valid parameters name depend on the content type object. For example, - * gmime_content_field_set_parameter (cf, "charset", "us-ascii"); - * will make sense for a "text/plain" content field but not for a - * "image/gif". This routine does not check parameter validity. - **/ -void -gmime_content_field_set_parameter (GMimeContentField *content_field, const gchar *attribute, const gchar *value) -{ - gboolean attribute_exists; - gchar *old_attribute; - gchar *old_value; - CAMEL_LOG_FULL_DEBUG ("GMimeContentField:: Entering set_parameter\n"); - CAMEL_LOG_FULL_DEBUG ("GMimeContentField:: set_parameter content_field=%p name=%s, value=%s\n", content_field, attribute, value); - attribute_exists = g_hash_table_lookup_extended (content_field->parameters, - attribute, - (gpointer *) &old_attribute, - (gpointer *) &old_value); - /** CHECK THAT : is normal to free pointers before insertion ? **/ - if (attribute_exists) { - g_free (old_value); - g_free (old_attribute); - } - - g_hash_table_insert (content_field->parameters, g_strdup (attribute), g_strdup (value)); - CAMEL_LOG_FULL_DEBUG ("GMimeContentField:: Leaving set_parameter\n"); -} - - -/** - * _print_parameter: print a parameter/value pair to a stream as described in RFC 2045 - * @name: name of the parameter - * @value: value of the parameter - * @user_data: CamelStream object to write the text to. - * - * - **/ -static void -_print_parameter (gpointer name, gpointer value, gpointer user_data) -{ - CamelStream *stream = (CamelStream *)user_data; - - camel_stream_write_strings (stream, - "; \n ", - (gchar *)name, - "=", - (gchar *)value, - NULL); - -} - -/** - * gmime_content_field_write_to_stream: write a mime content type to a stream - * @content_field: content type object - * @stream: the stream - * - * - **/ -void -gmime_content_field_write_to_stream (GMimeContentField *content_field, CamelStream *stream) -{ - if (!content_field) return; - - g_assert (stream); - if (content_field->type) { - camel_stream_write_strings (stream, "Content-Type: ", content_field->type, NULL); - if (content_field->subtype) { - camel_stream_write_strings (stream, "/", content_field->subtype, NULL); - } - /* print all parameters */ - g_hash_table_foreach (content_field->parameters, _print_parameter, stream); - camel_stream_write_string (stream, "\n"); - } else CAMEL_LOG_FULL_DEBUG ("GMimeContentField::write_to_stream no mime type found\n"); -} - -/** - * gmime_content_field_get_mime_type: return the mime type of the content field object - * @content_field: content field object - * - * A RFC 2045 content type field contains the mime type in the - * form "type/subtype" (example : "application/postscript") and some - * parameters (attribute/value pairs). This routine returns the mime type - * in a gchar object. - * - * Return value: the mime type in the form "type/subtype" or NULL if not defined. - **/ -gchar * -gmime_content_field_get_mime_type (GMimeContentField *content_field) -{ - gchar *mime_type; - - if (!content_field->type) return NULL; - - if (content_field->subtype) - mime_type = g_strdup_printf ("%s/%s", content_field->type, content_field->subtype); - else - mime_type = g_strdup (content_field->type); - return mime_type; -} - -static void -___debug_print_parameter (gpointer name, gpointer value, gpointer user_data) -{ - - printf ("****** parameter \"%s\"=\"%s\"\n", (gchar *)name, (gchar *)value); - -} - -/** - * gmime_content_field_get_parameter: return the value of a mime type parameter - * @content_field: content field object - * @name: name of the parameter - * - * Returns the value of a parameter contained in the content field - * object. The content type is formed of a mime type, a mime subtype, - * and a parameter list. Each parameter is a name/value pair. This - * routine returns the value assiciated to a given name. - * When the parameter does not exist, NULL is returned. - * - * Return value: parameter value, or NULL if not found. - **/ -const gchar * -gmime_content_field_get_parameter (GMimeContentField *content_field, const gchar *name) -{ - const gchar *parameter; - const gchar *old_name; - gboolean parameter_exists; - - CAMEL_LOG_FULL_DEBUG ("Entering GMimeContentField::get_parameter content_field =%p\n", content_field); - g_assert (content_field->parameters); - g_assert (name); - CAMEL_LOG_FULL_DEBUG ("GMimeContentField::get_parameter looking for parameter \"%s\"\n", name); - /* parameter = (const gchar *)g_hash_table_lookup (content_field->parameters, name); */ - parameter_exists = g_hash_table_lookup_extended (content_field->parameters, - name, - (gpointer *) &old_name, - (gpointer *) ¶meter); - if (!parameter_exists) { - CAMEL_LOG_FULL_DEBUG ("GMimeContentField::get_parameter, parameter not found\n"); - g_hash_table_foreach (content_field->parameters, ___debug_print_parameter, NULL); - return NULL; - } - CAMEL_LOG_FULL_DEBUG ("Leaving GMimeContentField::get_parameter\n"); - return parameter; -} - - - - -/** - * gmime_content_field_construct_from_string: construct a ContentType object by parsing a string. - * - * @content_field: content type object to construct - * @string: string containing the content type field - * - * Parse a string containing a content type field as defined in - * RFC 2045, and construct the corresponding ContentType object. - * The string is not modified and not used in the ContentType - * object. It can and must be freed by the calling part. - **/ -void -gmime_content_field_construct_from_string (GMimeContentField *content_field, const gchar *string) -{ - gint first, len; - gchar *str; - gint i=0; - gchar *type, *subtype; - gchar *param_name, *param_value; - gboolean param_end; - - CAMEL_LOG_TRACE ( "GMimeContentField::construct_from_string, entering\n"); - g_assert (string); - g_assert (content_field); - - g_free (content_field->type); - g_free (content_field->subtype); - - - first = 0; - len = strlen (string); - if (!len) return; - CAMEL_LOG_FULL_DEBUG ("GMimeContentField::construct_from_string, All checks done\n"); - - /* find the type */ - while ( (i<len) && (!strchr ("/;", string[i])) ) i++; - - if (i == 0) return; - - type = g_strndup (string, i); - string_trim (type, " \t", STRING_TRIM_STRIP_TRAILING | STRING_TRIM_STRIP_LEADING); - content_field->type = type; - CAMEL_LOG_TRACE ( "GMimeContentField::construct_from_string, Found mime type : \"%s\"\n", type); - if (i >= len-1) { - content_field->subtype = NULL; - return; - } - - first = i+1; - /* find the subtype, if any */ - if (string[i++] == '/') { - while ( (i<len) && (string[i] != ';') ) i++; - if (i != first) { - subtype = g_strndup (string+first, i-first); - string_trim (subtype, " \t", STRING_TRIM_STRIP_TRAILING | STRING_TRIM_STRIP_LEADING); - content_field->subtype = subtype; - CAMEL_LOG_TRACE ( "GMimeContentField::construct_from_string, Found mime subtype: \"%s\"\n", subtype); - if (i >= len-1) return; - } - } - first = i+1; - - /* parse parameters list */ - param_end = FALSE; - do { - while ( (i<len) && (string[i] != '=') ) i++; - if ((i == len) || (i==first)) param_end = TRUE; - else { - /* we have found parameter name */ - param_name = g_strndup (string+first, i-first); - string_trim (param_name, " ", STRING_TRIM_STRIP_TRAILING | STRING_TRIM_STRIP_LEADING); - i++; - first = i; - /* Let's find parameter value */ - while ( (i<len) && (string[i] != ';') ) i++; - if (i != first) param_value = g_strndup (string+first, i-first); - else param_value = g_strdup (""); - CAMEL_LOG_TRACE ( "GMimeContentField::construct_from_string, Found mime parameter \"%s\"=\"%s\"\n", param_name, param_value); - string_trim (param_value, " \t", STRING_TRIM_STRIP_TRAILING | STRING_TRIM_STRIP_LEADING); - gmime_content_field_set_parameter (content_field, param_name, param_value); - g_free (param_name); - g_free (param_value); - i++; - first = i; - } - } while ((!param_end) && (first < len)); - - -} - diff --git a/camel/gmime-content-field.h b/camel/gmime-content-field.h deleted file mode 100644 index 2287657ffb..0000000000 --- a/camel/gmime-content-field.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* mime-content_field.h : mime content type field utilities */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef GMIME_CONTENT_FIELD_H -#define GMIME_CONTENT_FIELD_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <glib.h> -#include <stdio.h> -#include "camel-stream.h" - -typedef struct { - - gchar *type; - gchar *subtype; - GHashTable *parameters; - - gint ref; - -} GMimeContentField; - -GMimeContentField *gmime_content_field_new (const gchar *type, const gchar *subtype); -void gmime_content_field_ref (GMimeContentField *content_field); -void gmime_content_field_unref (GMimeContentField *content_field); - -void gmime_content_field_set_parameter (GMimeContentField *content_field, const gchar *attribute, const gchar *value); -void gmime_content_field_write_to_stream (GMimeContentField *content_field, CamelStream *stream); -void gmime_content_field_construct_from_string (GMimeContentField *content_field, const gchar *string); -void gmime_content_field_free (GMimeContentField *content_field); -gchar * gmime_content_field_get_mime_type (GMimeContentField *content_field); -const gchar *gmime_content_field_get_parameter (GMimeContentField *content_field, const gchar *name); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* GMIME_CONTENT_FIELD_H */ diff --git a/camel/gmime-rfc2047.c b/camel/gmime-rfc2047.c deleted file mode 100644 index 7da12450b6..0000000000 --- a/camel/gmime-rfc2047.c +++ /dev/null @@ -1,491 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* gmime-rfc2047.c: implemention of RFC2047 */ - -/* - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - * - */ - -/* - * Authors: Robert Brady <rwb197@ecs.soton.ac.uk> - */ - -#include <stdio.h> -#include <ctype.h> -#include <unicode.h> -#include <string.h> - -#include "gmime-rfc2047.h" - -#define NOT_RANKED -1 - -/* This should be changed ASAP to use the base64 code Miguel comitted */ - -const char *base64_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -static unsigned char base64_rank[256]; -static int base64_rank_table_built; -static void build_base64_rank_table (void); - -static int -hexval (gchar c) { - if (isdigit (c)) return c-'0'; - c = tolower (c); - return c - 'a' + 10; -} - -static gchar * -decode_quoted (const gchar *text, const gchar *end) -{ - gchar *to = malloc(end - text + 1), *to_2 = to; - - if (!to) return NULL; - while (*text && text < end) { - if (*text == '=') { - gchar a = hexval (text[1]); - gchar b = hexval (text[2]); - int c = (a << 4) + b; - *to = c; - to++; - text+=3; - } else if (*text == '_') { - *to = ' '; - to++; - text++; - } else { - *to = *text; - to++; - text++; - } - } - return to_2; -} - -static gchar * -decode_base64 (const gchar *data, const gchar *end) -{ - unsigned short pattern = 0; - int bits = 0; - int delimiter = '='; - gchar x; - gchar *buffer = g_malloc((end - data) * 3); - gchar *t = buffer; - int Q = 0; - - if (!buffer) return NULL; - - while (*data != delimiter) { - x = base64_rank[(unsigned char)(*data++)]; - if (x == NOT_RANKED) - continue; - pattern <<= 6; - pattern |= x; - bits += 6; - if (bits >= 8) { - x = (pattern >> (bits - 8)) & 0xff; - *t++ = x; - Q++; - bits -= 8; - } - } - *t = 0; - return buffer; -} - -static void -build_base64_rank_table (void) -{ - int i; - - if (!base64_rank_table_built) { - for (i = 0; i < 256; i++) - base64_rank[i] = NOT_RANKED; - for (i = 0; i < 64; i++) - base64_rank[(int) base64_alphabet[i]] = i; - base64_rank_table_built = 1; - } -} - - -static gchar * -rfc2047_decode_word (const gchar *data, const gchar *into_what) -{ - const char *charset = strstr (data, "=?"), *encoding, *text, *end; - - char *buffer, *b, *cooked_data; - - buffer = g_malloc (strlen(data) * 2); - b = buffer; - - if (!charset) return strdup (data); - charset+=2; - - encoding = strchr (charset, '?'); - if (!encoding) return strdup (data); - encoding++; - - text = strchr(encoding, '?'); - if (!text) return strdup (data); - text++; - - end = strstr(text, "?="); - if (!end) return strdup (data); - - b[0] = 0; - - if (toupper(*encoding)=='Q') - cooked_data = decode_quoted (text, end); - else if (toupper (*encoding)=='B') - cooked_data = decode_base64 (text, end); - else - return g_strdup(data); - - { - char *c = strchr (charset, '?'); - char *q = g_malloc (c - charset + 1); - char *cook_2 = cooked_data; - int cook_len = strlen (cook_2); - int b_len = 4096; - unicode_iconv_t i; - strncpy (q, charset, c - charset); - q[c - charset] = 0; - i = unicode_iconv_open (into_what, q); - if (!i) { - g_free (q); - return g_strdup (buffer); - } - if (unicode_iconv (i, &cook_2, &cook_len, &b, &b_len)==-1) - /* FIXME : use approximation code if we can't convert it properly. */ - ; - unicode_iconv_close (i); - *b = 0; - } - - return g_strdup (buffer); -} - -static const gchar * -find_end_of_encoded_word (const gchar *data) -{ - /* We can't just search for ?=, - because of the case : - "=?charset?q?=ff?=" :( */ - if (!data) return NULL; - data = strstr (data, "=?"); - if (!data) return NULL; - data = strchr(data+2, '?'); - if (!data) return NULL; - data = strchr (data+1, '?'); - if (!data) return NULL; - data = strstr (data+1, "?="); - if (!data) return NULL; - return data + 2; -} - -gchar * -gmime_rfc2047_decode (const gchar *data, const gchar *into_what) -{ - char *buffer = malloc (strlen(data) * 4), *b = buffer; - - int was_encoded_word = 0; - - build_base64_rank_table (); - - while (data && *data) { - char *word_start = strstr (data, "=?"), *decoded; - if (!word_start) { - strcpy (b, data); - b[strlen (data)] = 0; - return buffer; - } - if (word_start != data) { - - if (strspn (data, " \t\n\r") != (word_start - data)) { - strncpy (b, data, word_start - data); - b += word_start - data; - *b = 0; - } - } - decoded = rfc2047_decode_word (word_start, into_what); - strcpy (b, decoded); - b += strlen (decoded); - *b = 0; - g_free (decoded); - - data = find_end_of_encoded_word (data); - } - - *b = 0; - return buffer; -} - -#define isnt_ascii(a) ((a) <= 0x1f || (a) >= 0x7f) - -static int -rfc2047_clean (const gchar *string, const gchar *max) -{ - /* if (strstr (string, "?=")) return 1; */ - while (string < max) { - if (isnt_ascii ((unsigned char)*string)) - return 0; - string++; - } - return 1; -} - -static gchar * -encode_word (const gchar *string, int length, const gchar *said_charset) -{ - const gchar *max = string + length; - if (rfc2047_clean(string, max)) { - /* don't bother encoding it if it has no odd characters in it */ - return g_strndup (string, length); - } - { - char *temp = malloc (length * 4 + 1), *t = temp; - t += sprintf (t, "=?%s?q?", said_charset); - while (string < max) { - if (*string == ' ') - *(t++) = '_'; - else if ((*string <= 0x1f) || (*string >= 0x7f) || (*string == '=') || (*string == '?')) - t += sprintf (t, "=%2x", (unsigned char)*string); - else - *(t++) = *string; - - string++; - } - t += sprintf (t, "?="); - *t = 0; - return temp; - } -} - -static int -words_in(char *a) -{ - int words = 1; - while (*a) { - if (*(a++)==' ') - words++; - } - return words; -} - -struct word_data { - const char *word; - int word_length; - const char *to_encode_in; - char *encoded; - enum { - wt_None, - wt_Address, - } type; -}; - -static int string_can_fit_in(const char *a, int length, const char *charset) -{ - while (length--) { - if (*a < 0x1f || *a >= 0x7f) return 0; - a++; - } - return 1; -} - -static void -show_entry(struct word_data *a) -{ - a->type = wt_None; - - if (string_can_fit_in(a->word, a->word_length, "US-ASCII")) - a->to_encode_in = "US-ASCII"; - - if (a->word[0]=='<' && a->word[a->word_length-1]=='>') { - a->type = wt_Address; - } -} - -static void -break_into_words(const char *string, struct word_data *a, int words) -{ - int i; - for (i=0;i<words;i++) { - - char *next_space = strchr(string, ' '); - - if (!next_space) { - a[i].word = string; - a[i].word_length = strlen(string); - a[i].to_encode_in = NULL; /* i.e. the default */ - - show_entry(a+i); - - return; - } - - a[i].word = string; - a[i].word_length = next_space - string; - a[i].to_encode_in = NULL; - - show_entry(a+i); - - string = next_space + 1; - - } -} - -static void -join_words(struct word_data *a, int words) -{ - int i; - for (i=(words-1);i>0;i--) { - if (a[i].to_encode_in == a[i-1].to_encode_in) { - a[i-1].word_length += 1 + a[i].word_length; - a[i].word = 0; - a[i].word_length = 0; - } - - } -} - -static void show_words(struct word_data *words, int count) -{ - int i; - for (i=0;i<count;i++) - if (words[i].word) - show_entry(words+i); -} - -gchar * -gmime_rfc2047_encode (const gchar *string, const gchar *charset) -{ - int temp_len = strlen (string)*4 + 1, word_count; - char *temp = g_malloc (temp_len), *temp_2 = temp; - int string_length = strlen (string); - char *encoded = NULL, *p; - struct word_data *words; - - /* first, let us convert to UTF-8 */ - unicode_iconv_t i = unicode_iconv_open ("UTF-8", charset); - unicode_iconv (i, &string, &string_length, &temp_2, &temp_len); - unicode_iconv_close (i); - - /* null terminate it */ - *temp_2 = 0; - - /* now encode it as if it were a single word */ - - word_count = words_in ( temp ); - - words = g_malloc(sizeof (struct word_data) * word_count); - break_into_words(temp, words, word_count); - - join_words(words, word_count); - - show_words(words, word_count); - - { - size_t len = 0; - int c = 0; - for (c = 0;c<word_count;c++) { - if (words[c].word) - { - words[c].encoded = encode_word(words[c].word, words[c].word_length, - words[c].to_encode_in ? words[c].to_encode_in : - "UTF-8"); - len += strlen(words[c].encoded) + 1; - } - } - - { - encoded = g_malloc(len+1); - p = encoded; - for (c = 0; c < word_count;c++) if (words[c].word) { - strcpy(p, words[c].encoded); - p += strlen(p); - strcpy(p, " "); - p++; - } - *p = 0; - } - } - - - /* - - real algorithm : - - we need to - - split it into words - - identify portions that have NOT to be encoded (i.e. <> and the comment starter/ender ) - - identify the best character set for each word - - merge words which share a character set, allow jumping and merging with words which - would be ok to encode in non-US-ASCII. - - if we have to use 2 character sets, try and collapse them into one. - - (e.g. if one word contains letters in latin-1, and another letters in latin-2, use - latin-2 for the first word as well if possible). - - finally : - - if utf-8 will still be used, use it for everything. - - and then, at last, generate the encoded text, using base64/quoted-printable for - each word depending upon which is more efficient. - - TODO : - create a priority list of encodings - - i.e. - - US-ASCII, ISO-8859-1, ISO-8859-2, ISO-8859-3, KOI8, - - Should survey for most popular charsets : - what do people usually use for the following scripts? - - * Chinese/Japanese/Korean - * Greek - * Cyrillic - - (any other scripts commonly used in mail/news?) - - This algorithm is probably far from optimal, but should be - reasonably efficient for simple cases. (and almost free if - the text is just in US-ASCII : like 99% of the text that will - pass through it) - - - - current status : - - Algorithm now partially implemented. - - */ - - g_free(words); - g_free(temp); - - return encoded; -} diff --git a/camel/gmime-rfc2047.h b/camel/gmime-rfc2047.h deleted file mode 100644 index a3175955a2..0000000000 --- a/camel/gmime-rfc2047.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* gmime-rfc2047.c: implemention of RFC2047 */ - -/* - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - * - */ - -/* - * Authors: Robert Brady <rwb197@ecs.soton.ac.uk> - */ - -#ifndef GMIME_RFC2047_H -#define GMIME_RFC2047_H 1 -#include <glib.h> - -gchar *gmime_rfc2047_decode (const gchar *text, const gchar* charset); -gchar *gmime_rfc2047_encode (const gchar *text, const gchar* charset); - -/* - * pass text and charset, (e.g. "UTF-8", or "ISO-8859-1"), and - * it will encode or decode text according to RFC2047 - * - * You will need to link with libunicode for these. - * - * TODO : Make it so that if charset==NULL, the charset specified (either - * implicitly or explicity) in the locale is used. - * - * TODO : Run torture tests and fix the buffer overruns in these functions. - * - * The caller will need to free the memory for the string. - */ - -#endif /* GMIME_RFC2047_H */ diff --git a/camel/gmime-utils.c b/camel/gmime-utils.c deleted file mode 100644 index 343cc33aad..0000000000 --- a/camel/gmime-utils.c +++ /dev/null @@ -1,268 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* mime-utils.c : misc utilities for mime */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include <config.h> -#include "gmime-utils.h" -#include "string-utils.h" -#include "camel-log.h" -#include "camel-stream.h" - -void -gmime_write_header_pair_to_stream (CamelStream *stream, const gchar* name, const gchar *value) -{ - - gchar *strtmp; - - CAMEL_LOG_FULL_DEBUG ( "gmime_write_header_pair_to_stream:: Entering\n"); - g_assert(name); - - if (!value) return; - strtmp = g_strdup_printf ("%s: %s\n", name, value); - - camel_stream_write_string (stream, strtmp); - CAMEL_LOG_FULL_DEBUG ( "gmime_write_header_pair_to_stream:\n writing %s\n", strtmp); - - g_free (strtmp); - CAMEL_LOG_FULL_DEBUG ( "gmime_write_header_pair_to_stream:: Leaving\n"); - -} - - -static void -_write_one_header_to_stream (gpointer key, gpointer value, gpointer user_data) -{ - gchar *header_name = (gchar *)key; - gchar *header_value = (gchar *)value; - CamelStream *stream = (CamelStream *)user_data; - - CAMEL_LOG_FULL_DEBUG ( "_write_one_header_to_stream:: Entering\n"); - if ((header_name) && (header_value)) - gmime_write_header_pair_to_stream (stream, header_name, header_value); - CAMEL_LOG_FULL_DEBUG ( "_write_one_header_to_stream:: Leaving\n"); -} - -void -gmime_write_header_table_to_stream (CamelStream *stream, GHashTable *header_table) -{ - CAMEL_LOG_FULL_DEBUG ( "write_header_table_to_stream:: Entering\n"); - g_hash_table_foreach (header_table, - _write_one_header_to_stream, - (gpointer)stream); - CAMEL_LOG_FULL_DEBUG ( "write_header_table_to_stream:: Leaving\n"); -} - - -void -gmime_write_header_with_glist_to_stream (CamelStream *stream, - const gchar *header_name, - GList *header_values, - const gchar *separator) -{ - - gchar *current; - - CAMEL_LOG_FULL_DEBUG ( "write_header_with_glist_to_stream:: entering\n"); - if ( (header_name) && (header_values) ) - { - gboolean first; - - camel_stream_write (stream, header_name, strlen (header_name) ); - camel_stream_write (stream, ": ", 2); - first = TRUE; - while (header_values) { - current = (gchar *)header_values->data; - if (current) { - if (!first) camel_stream_write_string (stream, separator); - else first = FALSE; - camel_stream_write (stream, current, strlen (current)); - } - header_values = g_list_next (header_values); - } - camel_stream_write (stream, "\n", 1); - } - CAMEL_LOG_FULL_DEBUG ("write_header_with_glist_to_stream:: leaving\n"); - -} - - - - - -/* * * * * * * * * * * */ -/* scanning functions */ - -static void -_store_header_pair_from_string (GArray *header_array, gchar *header_line) -{ - gchar dich_result; - gchar *header_name, *header_value; - Rfc822Header header; - - CAMEL_LOG_FULL_DEBUG ( "_store_header_pair_from_string:: Entering\n"); - - g_assert (header_array); - g_return_if_fail (header_line); - - - if (header_line) { - dich_result = string_dichotomy ( header_line, ':', - &header_name, &header_value, - STRING_DICHOTOMY_NONE); - if (dich_result != 'o') { - CAMEL_LOG_WARNING ( - "** WARNING **\n" - "store_header_pair_from_string : dichotomy result is '%c'\n" - "header line is :\n--\n%s\n--\n" - "** \n", dich_result, header_line); - if (header_name) - g_free (header_name); - if (header_value) - g_free (header_value); - - } else { - string_trim (header_value, " \t", - STRING_TRIM_STRIP_LEADING | STRING_TRIM_STRIP_TRAILING); - - header.name = header_name; - header.value = header_value; - g_array_append_val (header_array, header); - } - } - - CAMEL_LOG_FULL_DEBUG ( "_store_header_pair_from_string:: Leaving\n"); - -} - - - - -GArray * -get_header_array_from_stream (CamelStream *stream) -{ -#warning Correct Lazy Implementation - /* should not use GString. */ - /* should read the header line by line */ - /* and not char by char */ - gchar next_char; - gint nb_char_read; - - gboolean crlf = FALSE; - gboolean end_of_header_line = FALSE; - gboolean end_of_headers = FALSE; - gboolean end_of_file = FALSE; - - GString *header_line=NULL; - gchar *str_header_line; - - GArray *header_array; - - - CAMEL_LOG_FULL_DEBUG ( "gmime-utils:: Entering get_header_table_from_stream\n"); - header_array = g_array_new (FALSE, FALSE, sizeof (Rfc822Header)); - - nb_char_read = camel_stream_read (stream, &next_char, 1); - do { - header_line = g_string_new (""); - end_of_header_line = FALSE; - crlf = FALSE; - - /* read a whole header line */ - do { - if (nb_char_read>0) { - switch (next_char) { - - case '\n': /* a blank line means end of headers */ - if (crlf) { - end_of_headers=TRUE; - end_of_header_line = TRUE; - } - else crlf = TRUE; - break; - case ' ': - case '\t': - if (crlf) { - crlf = FALSE; - next_char = ' '; - } - - default: - if (!crlf) header_line = g_string_append_c (header_line, next_char); - else end_of_header_line = TRUE; - } - } else { - end_of_file=TRUE; - end_of_header_line = TRUE; - } - /* if we have read a whole header line, we have also read - the first character of the next line to be sure the - crlf was not followed by a space or a tab char */ - if (!end_of_header_line) nb_char_read = camel_stream_read (stream, &next_char, 1); - - } while ( !end_of_header_line ); - if ( strlen(header_line->str) ) { - /* str_header_line = g_strdup (header_line->str); */ - _store_header_pair_from_string (header_array, header_line->str); - } - g_string_free (header_line, FALSE); - - } while ( (!end_of_headers) && (!end_of_file) ); - - CAMEL_LOG_FULL_DEBUG ( "gmime-utils:: Leaving get_header_table_from_stream\n"); - return header_array; -} - - -gchar * -gmime_read_line_from_stream (CamelStream *stream) -{ - GString *new_line; - gchar *result; - gchar next_char; - gboolean end_of_line = FALSE; - gboolean end_of_stream = FALSE; - gint nb_char_read; - - new_line = g_string_new (""); - do { - nb_char_read = camel_stream_read (stream, &next_char, 1); - if (nb_char_read>0) { - switch (next_char) { - case '\n': - end_of_line = TRUE; - /* g_string_append_c (new_line, next_char); */ - break; - default: - g_string_append_c (new_line, next_char); - } - } else end_of_stream = TRUE; - } while (!end_of_line && !end_of_stream); - - if (!end_of_stream) - result = g_strdup (new_line->str); - else result=NULL; - g_string_free (new_line, TRUE); - return result; -} diff --git a/camel/gmime-utils.h b/camel/gmime-utils.h deleted file mode 100644 index 518feda062..0000000000 --- a/camel/gmime-utils.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* mime-utils.h : misc utilities for mime */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef GMIME_UTILS_H -#define GMIME_UTILS_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <glib.h> -#include <stdio.h> -#include <camel-stream.h> - -typedef struct -{ - gchar *name; - gchar *value; - -} Rfc822Header; - - -void gmime_write_header_pair_to_stream (CamelStream *stream, - const gchar* name, - const gchar *value); - -void gmime_write_header_table_to_stream (CamelStream *stream, - GHashTable *header_table); - -void gmime_write_header_with_glist_to_stream (CamelStream *stream, - const gchar *header_name, - GList *header_values, - const gchar *separator); - -GArray *get_header_array_from_stream (CamelStream *stream); -gchar *gmime_read_line_from_stream (CamelStream *stream); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* GMIME_UTILS_H */ diff --git a/camel/gstring-util.c b/camel/gstring-util.c deleted file mode 100644 index 5d1a3982ac..0000000000 --- a/camel/gstring-util.c +++ /dev/null @@ -1,343 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* gstring-util : utilities for gstring object */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - -#include <config.h> -#include "gstring-util.h" -#include "camel-log.h" -#include <string.h> - -/** - * g_string_equals : test if two string are equal - * - * @string1 : first string - * @string2 : second string - * - * @Return Value : true if the strings equal, false otherwise - **/ -gboolean -g_string_equals (GString *string1, GString *string2) -{ - g_assert(string1); - g_assert(string2); - return !strcmp(string1->str, string2->str); -} - - - - -/** - * g_string_clone : clone a GString - * - * @string : the string to clone - * - * @Return Value : the clone ... - **/ -GString * -g_string_clone(GString *string) -{ - return g_string_new( g_strdup(string->str) ); -} - - - - -/** - * g_string_dichotomy: - * @sep : separator - * @prefix: pointer to be field by the prefix object - * the prefix is not returned when the given pointer is NULL - * @suffix: pointer to be field by the suffix object - * the suffix is not returned when the given pointer is NULL - * - * Return the strings before and/or after - * the last occurence of the specified separator - * - * This routine returns the string before and/or after - * a character given as an argument. - * if the separator is the last character, prefix and/or - * suffix is set to NULL and result is set to 'l' - * if the separator is not in the list, prefix and/or - * suffix is set to NULL and result is set to 'n' - * When the operation succedeed, the return value is 'o' - * - * @Return Value : result of the operation ('o', 'l' or 'n') - * - **/ -gchar -g_string_dichotomy (GString *string, gchar sep, GString **prefix, GString **suffix, - GStringDichotomyOption options) -{ - gchar *str, *tmp; - gint pos, len, first; - - CAMEL_LOG_FULL_DEBUG (\ - "Entering string_dichotomy: \n\tseparator=%c \n\tprefix=%p \n\tsuffix=%p \n\toptions=%ld\n",\ - sep, prefix, suffix, options); - g_assert( tmp=string->str ); - len = strlen(tmp); - if (!len) { - if (prefix) - *prefix=NULL; - if (suffix) - *suffix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: string is empty\n"); - return 'n'; - } - first = 0; - - if ( (options & GSTRING_DICHOTOMY_STRIP_LEADING ) && (tmp[first] == sep) ) - do {first++;} while ( (first<len) && (tmp[first] == sep) ); - - if (options & GSTRING_DICHOTOMY_STRIP_TRAILING ) - while (tmp[len-1] == sep) - len--; - - if (first==len) { - if (prefix) *prefix=NULL; - if (suffix) *suffix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: after stripping, string is empty\n"); - return 'n'; - } - - if (options & GSTRING_DICHOTOMY_RIGHT_DIR) { - pos = len; - - do { - pos--; - } while ((pos>=first) && (tmp[pos]!=sep)); - } else { - pos = first; - do { - pos++; - } while ((pos<len) && (tmp[pos]!=sep)); - - } - - if ( (pos<first) || (pos>=len) ) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: separator not found\n"); - return 'n'; - } - - /* if we have stripped trailing separators, we should */ - /* never enter here */ - if (pos==len-1) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: separator is last character\n"); - return 'l'; - } - /* if we have stripped leading separators, we should */ - /* never enter here */ - if (pos==first) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: separator is first character\n"); - return 'l'; - } - - if (prefix) /* return the prefix */ - { - str = g_strndup(tmp,pos); - *prefix = g_string_new(str); - g_free(str); - } - if (suffix) /* return the suffix */ - { - str = g_strdup(tmp+pos+1); - *suffix = g_string_new(str); - g_free(str); - } - - return 'o'; -} - - -/** - * g_string_append_g_string : append a GString to another GString - * - * @dest_string : string which will be appended - * @other_string : string to append - * - **/ -void -g_string_append_g_string(GString *dest_string, GString *other_string) -{ - g_assert(other_string); - g_assert(dest_string); - g_assert(other_string->str); - - g_string_append(dest_string, other_string->str); -} - - - -/** - * g_string_equal_for_hash: test equality of two GStrings for hash tables - * @v: string 1 - * @v2: string 2 - * - * - * - * Return value: - **/ -g_string_equal_for_hash (gconstpointer v, gconstpointer v2) -{ - return strcmp ( ((const GString*)v)->str, ((const GString*)v2)->str) == 0; -} - -g_string_equal_for_glist (gconstpointer v, gconstpointer v2) -{ - return !strcmp ( ((const GString*)v)->str, ((const GString*)v2)->str) == 0; -} - - -/** - * g_string_hash: computes a hash value for a Gstring - * @v: Gstring object - * - * - * - * Return value: - **/ -guint -g_string_hash (gconstpointer v) -{ - return g_str_hash(((const GString*)v)->str); -} - - - - -/* utility func : frees a GString element in a GList */ -static void -__g_string_list_free_string (gpointer data, gpointer user_data) -{ - GString *string = (GString *)data; - g_string_free(string, TRUE); -} - - -void -g_string_list_free (GList *string_list) -{ - g_list_foreach(string_list, __g_string_list_free_string, NULL); - g_list_free(string_list); -} - - - - - - -GList * -g_string_split (GString *string, char sep, gchar *trim_chars, GStringTrimOption trim_options) -{ - GList *result = NULL; - gint first, last, pos; - gchar *str; - gchar *new_str; - GString *new_gstring; - - g_assert (string); - str = string->str; - if (!str) return NULL; - - first = 0; - last = strlen(str) - 1; - - /* strip leading and trailing separators */ - while ( (first<=last) && (str[first]==sep) ) - first++; - while ( (first<=last) && (str[last]==sep) ) - last--; - - - CAMEL_LOG_FULL_DEBUG ("g_string_split:: trim options: %d\n", trim_options); - - while (first<=last) { - pos = first; - /* find next separator */ - while ((pos<=last) && (str[pos]!=sep)) pos++; - if (first != pos) { - new_str = g_strndup (str+first, pos-first); - new_gstring = g_string_new (new_str); - g_free (new_str); - /* could do trimming in line to speed up this code */ - if (trim_chars) g_string_trim (new_gstring, trim_chars, trim_options); - result = g_list_append (result, new_gstring); - } - first = pos + 1; - } - - return result; -} - - -void -g_string_trim (GString *string, gchar *chars, GStringTrimOption options) -{ - gint first_ok; - gint last_ok; - guint length; - gchar *str; - - CAMEL_LOG_FULL_DEBUG ("**\nentering g_string_trim::\n"); - - if ((!string) || (!string->str)) - return; - str = string->str; - length = strlen (str); - if (!length) - return; - - first_ok = 0; - last_ok = length - 1; - - CAMEL_LOG_FULL_DEBUG ("g_string_trim:: trim_options:%d\n", options); - if (options & GSTRING_TRIM_STRIP_LEADING) - while ( (first_ok <= last_ok) && (strchr (chars, str[first_ok])) ) - first_ok++; - - if (options & GSTRING_TRIM_STRIP_TRAILING) - while ( (first_ok <= last_ok) && (strchr (chars, str[last_ok])) ) - last_ok++; - CAMEL_LOG_FULL_DEBUG ("g_string_trim::\n\t\"%s\":first ok:%d last_ok:%d\n", - string->str, first_ok, last_ok); - - if (first_ok > 0) - g_string_erase (string, 0, first_ok); - - if (last_ok < length-1) - g_string_truncate (string, last_ok - first_ok +1); - -} diff --git a/camel/gstring-util.h b/camel/gstring-util.h deleted file mode 100644 index e04a9112ed..0000000000 --- a/camel/gstring-util.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* gstring-util : utilities for gstring object */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - -#ifndef GSTRING_UTIL_H -#define GSTRING_UTIL_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <glib.h> - -typedef enum { - GSTRING_DICHOTOMY_NONE = 0, - GSTRING_DICHOTOMY_RIGHT_DIR = 1, - GSTRING_DICHOTOMY_STRIP_TRAILING = 2, - GSTRING_DICHOTOMY_STRIP_LEADING = 4 - -} GStringDichotomyOption; - -typedef enum { - GSTRING_TRIM_NONE = 0, - GSTRING_TRIM_STRIP_TRAILING = 1, - GSTRING_TRIM_STRIP_LEADING = 2 -} GStringTrimOption; - - -gboolean g_string_equals (GString *string1, GString *string2); -GString *g_string_clone (GString *string); -gchar g_string_dichotomy (GString *string, gchar sep, - GString **prefix, GString **suffix, - GStringDichotomyOption options); -void g_string_append_g_string (GString *dest_string, - GString *other_string); - -gboolean g_string_equal_for_hash (gconstpointer v, gconstpointer v2); -gboolean g_string_equal_for_glist (gconstpointer v, gconstpointer v2); -guint g_string_hash (gconstpointer v); -void g_string_list_free (GList *string_list); - -GList *g_string_split (GString *string, char sep, - gchar *trim_chars, GStringTrimOption trim_options); -void g_string_trim (GString *string, gchar *chars, - GStringTrimOption options); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* GSTRING_UTIL_H */ diff --git a/camel/hash-table-utils.c b/camel/hash-table-utils.c deleted file mode 100644 index d58f4376fc..0000000000 --- a/camel/hash-table-utils.c +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* generic utilities for hash tables */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include "glib.h" -#include "hash-table-utils.h" - - -/* - * free a (key/value) hash table pair. - * to be called in a g_hash_table_foreach() - * before g_hash_table_destroy(). - */ -void -g_hash_table_generic_free (gpointer key, gpointer value, gpointer user_data) -{ - g_free (key); - g_free (value); -} - - - -/***/ -/* use these two funcs for case insensitive hash table */ - -gint -g_strcase_equal (gconstpointer a, gconstpointer b) -{ - return (g_strcasecmp ((gchar *)a, (gchar *)b) == 0); -} - - -/* modified g_str_hash from glib/gstring.c - because it would have been too slow to - us g_strdown() on the string */ -/* a char* hash function from ASU */ -guint -g_strcase_hash (gconstpointer v) -{ - const char *s = (char*)v; - const char *p; - char c; - guint h=0, g; - - for(p = s; *p != '\0'; p += 1) { - c = isupper ((guchar)*p) ? tolower ((guchar)*p) : *p; - h = ( h << 4 ) + c; - if ( ( g = h & 0xf0000000 ) ) { - h = h ^ (g >> 24); - h = h ^ g; - } - } - - return h /* % M */; -} - - - -/***/ diff --git a/camel/hash-table-utils.h b/camel/hash-table-utils.h deleted file mode 100644 index ed1479b5c4..0000000000 --- a/camel/hash-table-utils.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* generic utilities for hash tables */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef HASH_TABLE_UTILS_H -#define HASH_TABLE_UTILS_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -void g_hash_table_generic_free (gpointer key, gpointer value, gpointer user_data); - -gint g_strcase_equal (gconstpointer a, gconstpointer b); -guint g_strcase_hash (gconstpointer v); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* HASH_TABLE_UTILS_H */ diff --git a/camel/md5-utils.c b/camel/md5-utils.c deleted file mode 100644 index 53f3373bb5..0000000000 --- a/camel/md5-utils.c +++ /dev/null @@ -1,388 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * This code implements the MD5 message-digest algorithm. - * The algorithm is due to Ron Rivest. This code was - * written by Colin Plumb in 1993, no copyright is claimed. - * This code is in the public domain; do with it what you wish. - * - * Equivalent code is available from RSA Data Security, Inc. - * This code has been tested against that, and is equivalent, - * except that you don't need to include two pages of legalese - * with every copy. - * - * To compute the message digest of a chunk of bytes, declare an - * MD5Context structure, pass it to md5_init, call md5_update as - * needed on buffers full of bytes, and then call md5_Final, which - * will fill a supplied 16-byte array with the digest. - */ - -/* parts of this file are : - * Written March 1993 by Branko Lankester - * Modified June 1993 by Colin Plumb for altered md5.c. - * Modified October 1995 by Erik Troan for RPM - */ - - -#include "md5-utils.h" -#include <stdio.h> - -static void md5_transform (guint32 buf[4], const guint32 in[16]); - -static gint _ie = 0x44332211; -static union _endian { gint i; gchar b[4]; } *_endian = (union _endian *)&_ie; -#define IS_BIG_ENDIAN() (_endian->b[0] == '\x44') -#define IS_LITTLE_ENDIAN() (_endian->b[0] == '\x11') - - -/* - * Note: this code is harmless on little-endian machines. - */ -static void -_byte_reverse (guchar *buf, guint32 longs) -{ - guint32 t; - do { - t = (guint32) ((guint32) buf[3] << 8 | buf[2]) << 16 | - ((guint32) buf[1] << 8 | buf[0]); - *(guint32 *) buf = t; - buf += 4; - } while (--longs); -} - -/** - * md5_init: Initialise an md5 context object - * @ctx: md5 context - * - * Initialise an md5 buffer. - * - **/ -void -md5_init (MD5Context *ctx) -{ - ctx->buf[0] = 0x67452301; - ctx->buf[1] = 0xefcdab89; - ctx->buf[2] = 0x98badcfe; - ctx->buf[3] = 0x10325476; - - ctx->bits[0] = 0; - ctx->bits[1] = 0; - - if (IS_BIG_ENDIAN()) - ctx->doByteReverse = 1; - else - ctx->doByteReverse = 0; -} - - - -/** - * md5_update: add a buffer to md5 hash computation - * @ctx: conetxt object used for md5 computaion - * @buf: buffer to add - * @len: buffer length - * - * Update context to reflect the concatenation of another buffer full - * of bytes. Use this to progressively construct an md5 hash. - **/ -void -md5_update (MD5Context *ctx, const guchar *buf, guint32 len) -{ - guint32 t; - - /* Update bitcount */ - - t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((guint32) len << 3)) < t) - ctx->bits[1]++; /* Carry from low to high */ - ctx->bits[1] += len >> 29; - - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ - - /* Handle any leading odd-sized chunks */ - - if (t) { - guchar *p = (guchar *) ctx->in + t; - - t = 64 - t; - if (len < t) { - memcpy (p, buf, len); - return; - } - memcpy (p, buf, t); - if (ctx->doByteReverse) - _byte_reverse (ctx->in, 16); - md5_transform (ctx->buf, (guint32 *) ctx->in); - buf += t; - len -= t; - } - /* Process data in 64-byte chunks */ - - while (len >= 64) { - memcpy (ctx->in, buf, 64); - if (ctx->doByteReverse) - _byte_reverse (ctx->in, 16); - md5_transform (ctx->buf, (guint32 *) ctx->in); - buf += 64; - len -= 64; - } - - /* Handle any remaining bytes of data. */ - - memcpy (ctx->in, buf, len); -} - - - - - -/* - * Final wrapup - pad to 64-byte boundary with the bit pattern - * 1 0* (64-bit count of bits processed, MSB-first) - */ -/** - * md5_final: copy the final md5 hash to a bufer - * @digest: 16 bytes buffer - * @ctx: context containing the calculated md5 - * - * copy the final md5 hash to a bufer - **/ -void -md5_final (guchar digest[16], MD5Context *ctx) -{ - guint32 count; - guchar *p; - - /* Compute number of bytes mod 64 */ - count = (ctx->bits[0] >> 3) & 0x3F; - - /* Set the first char of padding to 0x80. This is safe since there is - always at least one byte free */ - p = ctx->in + count; - *p++ = 0x80; - - /* Bytes of padding needed to make 64 bytes */ - count = 64 - 1 - count; - - /* Pad out to 56 mod 64 */ - if (count < 8) { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset (p, 0, count); - if (ctx->doByteReverse) - _byte_reverse (ctx->in, 16); - md5_transform (ctx->buf, (guint32 *) ctx->in); - - /* Now fill the next block with 56 bytes */ - memset (ctx->in, 0, 56); - } else { - /* Pad block to 56 bytes */ - memset (p, 0, count - 8); - } - if (ctx->doByteReverse) - _byte_reverse (ctx->in, 14); - - /* Append length in bits and transform */ - ((guint32 *) ctx->in)[14] = ctx->bits[0]; - ((guint32 *) ctx->in)[15] = ctx->bits[1]; - - md5_transform (ctx->buf, (guint32 *) ctx->in); - if (ctx->doByteReverse) - _byte_reverse ((guchar *) ctx->buf, 4); - memcpy (digest, ctx->buf, 16); - memset (ctx, 0, sizeof(ctx)); /* In case it's sensitive */ -} - - - - -/* The four core functions - F1 is optimized somewhat */ - -/* #define F1(x, y, z) (x & y | ~x & z) */ -#define F1(x, y, z) (z ^ (x & (y ^ z))) -#define F2(x, y, z) F1(z, x, y) -#define F3(x, y, z) (x ^ y ^ z) -#define F4(x, y, z) (y ^ (x | ~z)) - -/* This is the central step in the MD5 algorithm. */ -#define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x ) - -/* - * The core of the MD5 algorithm, this alters an existing MD5 hash to - * reflect the addition of 16 longwords of new data. md5_Update blocks - * the data and converts bytes into longwords for this routine. - */ -static void -md5_transform (guint32 buf[4], const guint32 in[16]) -{ - register guint32 a, b, c, d; - - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - MD5STEP (F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP (F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP (F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP (F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP (F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP (F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP (F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP (F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP (F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP (F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP (F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP (F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP (F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP (F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP (F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP (F1, b, c, d, a, in[15] + 0x49b40821, 22); - - MD5STEP (F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP (F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP (F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP (F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP (F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP (F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP (F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP (F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP (F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP (F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP (F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - MD5STEP (F2, b, c, d, a, in[8] + 0x455a14ed, 20); - MD5STEP (F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP (F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP (F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP (F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - - MD5STEP (F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP (F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP (F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP (F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP (F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP (F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP (F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP (F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP (F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP (F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP (F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP (F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP (F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP (F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP (F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP (F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - - MD5STEP (F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP (F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP (F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP (F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP (F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP (F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP (F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP (F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP (F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP (F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP (F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP (F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP (F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP (F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP (F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP (F4, b, c, d, a, in[9] + 0xeb86d391, 21); - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; -} - - - - -/** - * md5_get_digest: get the md5 hash of a buffer - * @buffer: byte buffer - * @buffer_size: buffer size (in bytes) - * @digest: 16 bytes buffer receiving the hash code. - * - * Get the md5 hash of a buffer. The result is put in - * the 16 bytes buffer @digest . - **/ -void -md5_get_digest (const gchar *buffer, gint buffer_size, guchar digest[16]) -{ - MD5Context ctx; - - md5_init (&ctx); - md5_update (&ctx, buffer, buffer_size); - md5_final (digest, &ctx); - -} - - -/** - * md5_get_digest_from_stream: get the md5 hash of a stream - * @stream: stream - * @digest: 16 bytes buffer receiving the hash code. - * - * Get the md5 hash of a stream. The result is put in - * the 16 bytes buffer @digest . - **/ -void -md5_get_digest_from_stream (CamelStream *stream, guchar digest[16]) -{ - MD5Context ctx; - guchar tmp_buf[1024]; - gint nb_bytes_read; - - md5_init (&ctx); - - nb_bytes_read = camel_stream_read (stream, tmp_buf, 1024); - while (nb_bytes_read) { - md5_update (&ctx, tmp_buf, nb_bytes_read); - nb_bytes_read = camel_stream_read (stream, tmp_buf, 1024); - } - - md5_final (digest, &ctx); - -} - - - - -/** - * md5_get_digest_from_file: get the md5 hash of a file - * @filename: file name - * @digest: 16 bytes buffer receiving the hash code. - * - * Get the md5 hash of a file. The result is put in - * the 16 bytes buffer @digest . - **/ -void -md5_get_digest_from_file (const gchar *filename, guchar digest[16]) -{ - MD5Context ctx; - guchar tmp_buf[1024]; - gint nb_bytes_read; - FILE *fp; - - md5_init (&ctx); - fp = fopen(filename, "r"); - if (!fp) { - return; - } - - while ((nb_bytes_read = fread (tmp_buf, sizeof (guchar), 1024, fp)) > 0) - md5_update (&ctx, tmp_buf, nb_bytes_read); - - if (ferror(fp)) { - fclose(fp); - return; - } - - md5_final (digest, &ctx); - -} - - - - diff --git a/camel/md5-utils.h b/camel/md5-utils.h deleted file mode 100644 index a2552d21b2..0000000000 --- a/camel/md5-utils.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * This code implements the MD5 message-digest algorithm. - * The algorithm is due to Ron Rivest. This code was - * written by Colin Plumb in 1993, no copyright is claimed. - * This code is in the public domain; do with it what you wish. - * - * Equivalent code is available from RSA Data Security, Inc. - * This code has been tested against that, and is equivalent, - * except that you don't need to include two pages of legalese - * with every copy. - * - * To compute the message digest of a chunk of bytes, declare an - * MD5Context structure, pass it to rpmMD5Init, call rpmMD5Update as - * needed on buffers full of bytes, and then call rpmMD5Final, which - * will fill a supplied 16-byte array with the digest. - */ - -/* parts of this file are : - * Written March 1993 by Branko Lankester - * Modified June 1993 by Colin Plumb for altered md5.c. - * Modified October 1995 by Erik Troan for RPM - */ - - -#ifndef MD5_UTILS_H -#define MD5_UTILS_H - -#include <glib.h> -#include "camel-stream.h" - -typedef struct { - guint32 buf[4]; - guint32 bits[2]; - guchar in[64]; - gint doByteReverse; - -} MD5Context ; - - -void md5_get_digest (const gchar *buffer, gint buffer_size, guchar digest[16]); -void md5_get_digest_from_stream (CamelStream *stream, guchar digest[16]); - -/* use this one when speed is needed */ -/* for use in provider code only */ -void md5_get_digest_from_file (const gchar *filename, guchar digest[16]); - -/* raw routines */ -void md5_init (MD5Context *ctx); -void md5_update (MD5Context *ctx, const guchar *buf, guint32 len); -void md5_final (guchar digest[16], MD5Context *ctx); - - -#endif /* MD5_UTILS_H */ diff --git a/camel/providers/.cvsignore b/camel/providers/.cvsignore deleted file mode 100644 index b840c21800..0000000000 --- a/camel/providers/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile.in -Makefile
\ No newline at end of file diff --git a/camel/providers/MH/.cvsignore b/camel/providers/MH/.cvsignore deleted file mode 100644 index 2e7b174532..0000000000 --- a/camel/providers/MH/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -Makefile.in -Makefile -.deps -*.lo -*.la -.libs diff --git a/camel/providers/MH/Makefile.am b/camel/providers/MH/Makefile.am deleted file mode 100644 index dab6bec199..0000000000 --- a/camel/providers/MH/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = - -libcamelmhincludedir = $(includedir)/camel - - -lib_LTLIBRARIES = libcamelmh.la - -INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \ - -I$(top_srcdir)/intl \ - $(GTK_INCLUDEDIR) -I$(top_srcdir)/camel - -libcamelmh_la_SOURCES = \ - camel-mh-folder.c \ - camel-mh-provider.c \ - camel-mh-store.c \ - mh-summary.c \ - mh-uid.c \ - mh-utils.c - -libcamelmhinclude_HEADERS = \ - camel-mh-folder.h \ - camel-mh-store.h \ - mh-summary.c \ - mh-uid.h \ - mh-utils.h - - -libcamelmh_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) - - -EXTRA_DIST = diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c deleted file mode 100644 index 86bbab46ba..0000000000 --- a/camel/providers/MH/camel-mh-folder.c +++ /dev/null @@ -1,1022 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mh-folder.c : Abstract class for an email folder */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#include <config.h> -#include <sys/stat.h> -#include <sys/param.h> -#include <unistd.h> -#include <sys/types.h> -#include <fcntl.h> -#include <dirent.h> -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include "camel-mh-folder.h" -#include "camel-mh-store.h" -#include "gstring-util.h" -#include "camel-log.h" -#include "camel-stream-fs.h" -#include "camel-stream-buffered-fs.h" -#include "camel-folder-summary.h" -#include "gmime-utils.h" -#include "mh-utils.h" -#include "mh-uid.h" -#include "mh-summary.h" - - -static CamelFolderClass *parent_class=NULL; - -/* Returns the class for a CamelMhFolder */ -#define CMHF_CLASS(so) CAMEL_MH_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CMHS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass) - - -static void _set_name(CamelFolder *folder, const gchar *name, CamelException *ex); -static void _init_with_store (CamelFolder *folder, CamelStore *parent_store, CamelException *ex); -static gboolean _exists (CamelFolder *folder, CamelException *ex); -static gboolean _create(CamelFolder *folder, CamelException *ex); -static gboolean _delete (CamelFolder *folder, gboolean recurse, CamelException *ex); -static gboolean _delete_messages (CamelFolder *folder, CamelException *ex); -static GList *_list_subfolders (CamelFolder *folder, CamelException *ex); -static CamelMimeMessage *_get_message (CamelFolder *folder, gint number, CamelException *ex); -static gint _get_message_count (CamelFolder *folder, CamelException *ex); -static gint _append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); -static void _expunge (CamelFolder *folder, CamelException *ex); -static void _copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder, CamelException *ex); -static void _open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex); -static void _close (CamelFolder *folder, gboolean expunge, CamelException *ex); - -static const gchar *_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); -static CamelMimeMessage *_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex); -static GList *_get_uid_list (CamelFolder *folder, CamelException *ex); - -/* some utility functions */ -static int copy_reg (const char *src_path, const char *dst_path, CamelException *ex); - -static void -camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class) -{ - CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_mh_folder_class); - - parent_class = gtk_type_class (camel_folder_get_type ()); - - /* virtual method definition */ - /* virtual method overload */ - camel_folder_class->init_with_store = _init_with_store; - camel_folder_class->set_name = _set_name; - camel_folder_class->exists = _exists; - camel_folder_class->delete = _delete; - camel_folder_class->delete_messages = _delete_messages; - camel_folder_class->list_subfolders = _list_subfolders; - camel_folder_class->get_message = _get_message; - camel_folder_class->get_message_count = _get_message_count; - camel_folder_class->append_message = _append_message; - camel_folder_class->expunge = _expunge; - camel_folder_class->copy_message_to = _copy_message_to; - camel_folder_class->open = _open; - camel_folder_class->close = _close; - camel_folder_class->get_message_uid = _get_message_uid; - camel_folder_class->get_message_by_uid = _get_message_by_uid; - camel_folder_class->get_uid_list = _get_uid_list; - -} - - - - - - - -GtkType -camel_mh_folder_get_type (void) -{ - static GtkType camel_mh_folder_type = 0; - - if (!camel_mh_folder_type) { - GtkTypeInfo camel_mh_folder_info = - { - "CamelMhFolder", - sizeof (CamelMhFolder), - sizeof (CamelMhFolderClass), - (GtkClassInitFunc) camel_mh_folder_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mh_folder_type = gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_mh_folder_info); - } - - return camel_mh_folder_type; -} - - - -static gint -_message_name_compare (gconstpointer a, gconstpointer b) -{ - gchar *m1 = (gchar *)a; - gchar *m2 = (gchar *)b; - gint len_diff; - - return (atoi (m1) - atoi (m2)); -} - - -static void -_init_with_store (CamelFolder *folder, CamelStore *parent_store, CamelException *ex) -{ - /* call parent method */ - parent_class->init_with_store (folder, parent_store, ex); - - folder->can_hold_messages = TRUE; - folder->can_hold_folders = TRUE; - folder->has_summary_capability = TRUE; - folder->has_uid_capability = TRUE; - - folder->summary = NULL; - -} - - - -static void -_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex) -{ - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); - struct dirent *dir_entry; - DIR *dir_handle; - - - if (folder->open_state == FOLDER_OPEN) return; - - - /* create message list */ - /* read the whole folder and sort message names */ - dir_handle = opendir (mh_folder->directory_path); - /* read first entry in the directory */ - dir_entry = readdir (dir_handle); - while (dir_entry != NULL) { - /* tests if the entry correspond to a message file */ - if (mh_is_a_message_file (dir_entry->d_name, mh_folder->directory_path)) - /* add the file name to the list */ - mh_folder->file_name_list = g_list_insert_sorted (mh_folder->file_name_list, - g_strdup (dir_entry->d_name), - _message_name_compare); - /* read next entry */ - dir_entry = readdir (dir_handle); - } - - closedir (dir_handle); - - /* get (or create) uid list */ - if (!(mh_load_uid_list (mh_folder) > 0)) - mh_generate_uid_list (mh_folder); - - /* get or create summary */ - /* it is important that it comes after uid list reading/generation */ - if (!(mh_load_summary (mh_folder) > 0)) - mh_generate_summary (folder); - printf ("**** summary = %p\n", folder->summary); - -} - - - -static void -_close (CamelFolder *folder, gboolean expunge, CamelException *ex) -{ - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); - - /* save uid list, if any */ - if (mh_folder->uid_array) - mh_save_uid_list (mh_folder); - - /* save summary, if any */ - if (folder->summary) - mh_save_summary (mh_folder); - - /* call parent implementation */ - parent_class->close (folder, expunge, ex); -} - - - - - -/** - * camel_mh_folder_set_name: set the name of an MH folder - * @folder: the folder to set the name - * @name: a string representing the (short) name - * - * - * - **/ -static void -_set_name (CamelFolder *folder, const gchar *name, CamelException *ex) -{ - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); - const gchar *root_dir_path; - gchar *full_name; - const gchar *parent_full_name; - gchar separator; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMhFolder::set_name\n"); - g_assert (folder); - g_assert (name); - g_assert (folder->parent_store); - - /* call default implementation */ - parent_class->set_name (folder, name, ex); - - if (mh_folder->directory_path) g_free (mh_folder->directory_path); - - separator = camel_store_get_separator (folder->parent_store); - root_dir_path = camel_mh_store_get_toplevel_dir (CAMEL_MH_STORE(folder->parent_store)); - - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::set_name full_name is %s\n", folder->full_name); - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::set_name root_dir_path is %s\n", root_dir_path); - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::separator is %c\n", separator); - - mh_folder->directory_path = g_strdup_printf ("%s%c%s", root_dir_path, separator, folder->full_name); - - if (!camel_folder_exists (folder, ex)) return; - - - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::set_name mh_folder->directory_path is %s\n", - mh_folder->directory_path); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMhFolder::set_name\n"); -} - - - -static gboolean -_exists (CamelFolder *folder, CamelException *ex) -{ - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); - struct stat stat_buf; - gint stat_error; - gboolean exists; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMhFolder::exists\n"); - g_assert (folder); - - if (!mh_folder->directory_path) return FALSE; - - stat_error = stat (mh_folder->directory_path, &stat_buf); - if (stat_error == -1) { - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::exists when executing stat on %s, stat_error = %d\n", - mh_folder->directory_path, stat_error); - CAMEL_LOG_FULL_DEBUG (" Full error text is : %s\n", strerror(errno)); - return FALSE; - } - exists = S_ISDIR (stat_buf.st_mode); - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMhFolder::exists\n"); - return exists; -} - - -static gboolean -_create (CamelFolder *folder, CamelException *ex) -{ - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); - const gchar *directory_path; - mode_t dir_mode = S_IRWXU; - gint mkdir_error; - - g_assert(folder); - - /* call default implementation */ - parent_class->create (folder, ex); - - directory_path = mh_folder->directory_path; - if (!directory_path) return FALSE; - - if (camel_folder_exists (folder, ex)) return TRUE; - - mkdir_error = mkdir (directory_path, dir_mode); - return (mkdir_error == -1); -} - - - -static gboolean -_delete (CamelFolder *folder, gboolean recurse, CamelException *ex) -{ - - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); - const gchar *directory_path; - gint rmdir_error = 0; - - g_assert(folder); - - /* call default implementation */ - parent_class->delete (folder, recurse, ex); - /* the default implementation will care about deleting - messages first and recursing the operation if - necessary */ - - directory_path = mh_folder->directory_path; - if (!directory_path) return FALSE; - - if (!camel_folder_exists (folder, ex)) return TRUE; - - /* physically delete the directory */ - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::delete removing directory %s\n", directory_path); - rmdir_error = rmdir (directory_path); - if (rmdir_error == -1) { - CAMEL_LOG_WARNING ("CamelMhFolder::delete Error when removing directory %s\n", directory_path); - CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno)); - } - - return (rmdir_error != -1); -} - - -static gboolean -_delete_messages (CamelFolder *folder, CamelException *ex) -{ - - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); - const gchar *directory_path; - struct stat stat_buf; - gint stat_error = 0; - gchar *entry_name; - struct dirent *dir_entry; - gint unlink_error = 0; - DIR *dir_handle; - - g_assert(folder); - - /* call default implementation */ - parent_class->delete_messages (folder, ex); - - directory_path = mh_folder->directory_path; - if (!directory_path) return FALSE; - - if (!camel_folder_exists (folder, ex)) return TRUE; - - dir_handle = opendir (directory_path); - - /* read first entry in the directory */ - dir_entry = readdir (dir_handle); - while ((stat_error != -1) && (unlink_error != -1) && (dir_entry != NULL)) { - - /* get the name of the next entry in the dir */ - entry_name = dir_entry->d_name; - stat_error = stat (mh_folder->directory_path, &stat_buf); - - /* is it a regular file ? */ - if ((stat_error != -1) && S_ISREG(stat_buf.st_mode)) { - /* yes, delete it */ - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::delete_messages removing file %s\n", entry_name); - unlink_error = unlink(entry_name); - - if (unlink_error == -1) { - CAMEL_LOG_WARNING ("CamelMhFolder::delete_messages Error when deleting file %s\n", - entry_name); - CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno)); - } - } - /* read next entry */ - dir_entry = readdir (dir_handle); - } - - closedir (dir_handle); - - return ((stat_error != -1) && (unlink_error != -1)); - -} - - - -static GList * -_list_subfolders (CamelFolder *folder, CamelException *ex) -{ - GList *subfolder_name_list = NULL; - - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); - const gchar *directory_path; - struct stat stat_buf; - gint stat_error = 0; - GList *file_list; - gchar *entry_name; - gchar *full_entry_name; - struct dirent *dir_entry; - DIR *dir_handle; - - g_assert(folder); - - /* call default implementation */ - parent_class->delete_messages (folder, ex); - - directory_path = mh_folder->directory_path; - if (!directory_path) return NULL; - - if (!camel_folder_exists (folder, ex)) return NULL; - - dir_handle = opendir (directory_path); - - /* read first entry in the directory */ - dir_entry = readdir (dir_handle); - while ((stat_error != -1) && (dir_entry != NULL)) { - - /* get the name of the next entry in the dir */ - entry_name = dir_entry->d_name; - full_entry_name = g_strdup_printf ("%s/%s", mh_folder->directory_path, entry_name); - stat_error = stat (full_entry_name, &stat_buf); - g_free (full_entry_name); - - /* is it a directory ? */ - if ((stat_error != -1) && S_ISDIR (stat_buf.st_mode)) { - /* yes, add it to the list */ - if (entry_name[0] != '.') { - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::list_subfolders adding %s\n", entry_name); - subfolder_name_list = g_list_append (subfolder_name_list, g_strdup (entry_name)); - } - } - /* read next entry */ - dir_entry = readdir (dir_handle); - } - - closedir (dir_handle); - - return subfolder_name_list; -} - - - - - -static void -_filename_free (gpointer data) -{ - g_free ((gchar *)data); -} - - -/* slow routine, may be optimixed, or we should use - caches if users complain */ -static CamelMimeMessage * -_get_message (CamelFolder *folder, gint number, CamelException *ex) -{ - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); - const gchar *directory_path; - gchar *message_name; - gchar *message_file_name; - CamelStream *input_stream = NULL; - CamelMimeMessage *message = NULL; - GList *message_list = NULL; - - g_assert(folder); - - - directory_path = mh_folder->directory_path; - if (!directory_path) return NULL; - - - - message_name = g_list_nth_data (mh_folder->file_name_list, number); - - if (message_name != NULL) { - CAMEL_LOG_FULL_DEBUG ("CanelMhFolder::get_message message number = %d, name = %s\n", - number, message_name); - message_file_name = g_strdup_printf ("%s/%s", directory_path, message_name); - input_stream = camel_stream_buffered_fs_new_with_name (message_file_name, CAMEL_STREAM_BUFFERED_FS_READ); - - if (input_stream != NULL) { -#warning use session field here - message = camel_mime_message_new_with_session ( (CamelSession *)NULL); - camel_data_wrapper_construct_from_stream ( CAMEL_DATA_WRAPPER (message), input_stream); - gtk_object_unref (GTK_OBJECT (input_stream)); - message->message_number = number; - gtk_object_set_data_full (GTK_OBJECT (message), "filename", - g_strdup (message_name), _filename_free); - -#warning Set flags and all this stuff here - } - g_free (message_file_name); - } else - CAMEL_LOG_FULL_DEBUG ("CanelMhFolder::get_message message number = %d, not found\n", number); - - - return message; -} - - - -static gint -_get_message_count (CamelFolder *folder, CamelException *ex) -{ - - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); - const gchar *directory_path; - struct dirent *dir_entry; - DIR *dir_handle; - guint message_count = 0; - - g_assert(folder); - - directory_path = mh_folder->directory_path; - if (!directory_path) return -1; - - if (!camel_folder_exists (folder, ex)) return 0; - - dir_handle = opendir (directory_path); - - /* read first entry in the directory */ - dir_entry = readdir (dir_handle); - while (dir_entry != NULL) { - /* tests if the entry correspond to a message file */ - if (mh_is_a_message_file (dir_entry->d_name, directory_path)) - message_count++; - /* read next entry */ - dir_entry = readdir (dir_handle); - } - - closedir (dir_handle); - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::get_message_count found %d messages\n", message_count); - return message_count; -} - - - -static gboolean -_find_next_free_message_file (CamelFolder *folder, gint *new_msg_number, gchar **new_msg_filename, CamelException *ex) -{ - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); - const gchar *directory_path; - struct dirent *dir_entry; - DIR *dir_handle; - gint last_max_message_number = 0; - gint current_message_number; - - g_assert(folder); - - directory_path = mh_folder->directory_path; - if (!directory_path) return FALSE; - - if (!camel_folder_exists (folder, ex)) return FALSE; - - dir_handle = opendir (directory_path); - - /* read first entry in the directory */ - dir_entry = readdir (dir_handle); - while (dir_entry != NULL) { - /* tests if the entry correspond to a message file */ - if (mh_is_a_message_file (dir_entry->d_name, directory_path)) { - /* see if the message number is the biggest found */ - current_message_number = atoi (dir_entry->d_name); - if (current_message_number > last_max_message_number) - last_max_message_number = current_message_number; - } - /* read next entry */ - dir_entry = readdir (dir_handle); - } - closedir (dir_handle); - - *new_msg_number = last_max_message_number + 1; - *new_msg_filename = g_strdup_printf ("%s/%d", directory_path, *new_msg_number); - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::find_next_free_message_file new message path is %s\n", - *new_msg_filename); - return TRUE; - - -} -static gint -_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex) -{ - guint new_msg_number; - gchar *new_msg_filename; - CamelStream *output_stream; - gboolean error; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMhFolder::append_message\n"); - if (!_find_next_free_message_file (folder, &new_msg_number, &new_msg_filename, ex)) - return -1; - - output_stream = camel_stream_fs_new_with_name (new_msg_filename, CAMEL_STREAM_FS_WRITE); - if (output_stream != NULL) { - camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), output_stream); - camel_stream_close (output_stream); - } else { - CAMEL_LOG_WARNING ("CamelMhFolder::append_message could not open %s for writing\n", - new_msg_filename); - CAMEL_LOG_FULL_DEBUG (" Full error text is : %s\n", strerror(errno)); - error = TRUE; - } - - g_free (new_msg_filename); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMhFolder::append_message\n"); - if (error) return -1; - else return new_msg_number; -} - - - - - -static void -_expunge (CamelFolder *folder, CamelException *ex) -{ - /* For the moment, we look in the folder active message - * list. I did not make my mind for the moment, should - * the gtk_object->destroy signal be used to expunge - * freed messages objects marked DELETED ? - */ - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); - CamelMimeMessage *message; - GList *message_node; - gchar *fullpath; - gchar *filename; - gint unlink_error; - const gchar *directory_path; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelFolder::expunge\n"); - - message_node = folder->message_list; - - directory_path = mh_folder->directory_path; - if (!directory_path) return; - - /* look in folder message list which messages - * need to be expunged */ - while ( message_node) { - message = CAMEL_MIME_MESSAGE (message_node->data); - - if (message && camel_mime_message_get_flag (message, "DELETED")) { - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::expunge, expunging message %d\n", message->message_number); - /* expunge the message */ - filename = gtk_object_get_data (GTK_OBJECT (message), "filename"); - fullpath = g_strdup_printf ("%s/%s", directory_path, filename); - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::expunge, message fullpath is %s\n", - fullpath); - unlink_error = unlink(fullpath); - if (unlink_error != -1) { - message->expunged = TRUE; - } else { - CAMEL_LOG_WARNING ("CamelMhFolder:: could not unlink %s (message %d)\n", - fullpath, message->message_number); - CAMEL_LOG_FULL_DEBUG (" Full error text is : %s\n", strerror(errno)); - } - } - message_node = message_node->next; - CAMEL_LOG_FULL_DEBUG ("CamelFolder::expunge, examined message node %p\n", message_node); - } - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelFolder::expunge\n"); -} - - -static void -_copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder, CamelException *ex) -{ - gchar *src_msg_filename; - guint dest_msg_number; - gchar *dest_msg_filename; - - if (IS_CAMEL_MH_FOLDER (dest_folder)) { - /*g_return_if_fail (message->parent_folder == folder);*/ - - if (!_find_next_free_message_file (dest_folder, &dest_msg_number, &dest_msg_filename, ex)) - return; - src_msg_filename = gtk_object_get_data (GTK_OBJECT (message), "fullpath"); - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::copy_to copy file %s to %s\n", src_msg_filename, dest_msg_filename); - copy_reg (src_msg_filename, dest_msg_filename, ex); - - } else - parent_class->copy_message_to (folder, message, dest_folder, ex); -} - - - -/** UID **/ - -static const gchar * -_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex) -{ - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); - GArray *uid_array; - gboolean found = FALSE; - MhUidCouple *uid_couple; - gchar *filename; - guint file_number; - gint i; - - /* if the message already has its uid stored, - return it */ - if (message->message_uid) - return (message->message_uid); - - /* else, it has a filename associated to it */ - filename = gtk_object_get_data (GTK_OBJECT (message), "filename"); - file_number = atoi (file_number); - - uid_array = mh_folder->uid_array; - uid_couple = (MhUidCouple *)uid_array->data; - - /* look in the uid array for the file number */ - found = (uid_couple->file_number == file_number); - for (i=0; (i<uid_array->len) && (!found); i++) { - uid_couple++; - found = (uid_couple->file_number == file_number); - } - - if (found) return uid_couple->uid; - else return NULL; - -} - - -static CamelMimeMessage * -_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex) -{ - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); - GArray *uid_array; - gboolean found = FALSE; - MhUidCouple *uid_couple; - gint file_number; - gchar *filename; - CamelMimeMessage *message = NULL; - CamelStream *input_stream; - int i; - - /* - * because they are constructed with md5 - * signatures, all MH uids are 16 bytes long - */ - if (strlen (uid) != 16) return NULL; - - uid_array = mh_folder->uid_array; - uid_couple = (MhUidCouple *)uid_array->data; - - found = !strncmp (uid, uid_couple->uid, 16 * sizeof (guchar)); - for (i=0; (i<uid_array->len) && (!found); i++) { - uid_couple++; - found = !strncmp (uid, uid_couple->uid, 16 * sizeof (guchar)); - } - if (found) { - /* physically retrieve the message */ - file_number = uid_couple->file_number; - filename = g_strdup_printf ("%d", file_number); - input_stream = camel_stream_buffered_fs_new_with_name (filename, CAMEL_STREAM_BUFFERED_FS_READ); - - if (input_stream != NULL) { -#warning use session field here - message = camel_mime_message_new_with_session ( (CamelSession *)NULL); - camel_data_wrapper_construct_from_stream ( CAMEL_DATA_WRAPPER (message), input_stream); - gtk_object_unref (GTK_OBJECT (input_stream)); - - /* set message UID in CamelMimeMessage */ - message->message_uid = g_strdup (uid); - - } - g_free (filename); - } - - return message; - -} - -static GList * -_get_uid_list (CamelFolder *folder, CamelException *ex) -{ - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); - GList *uid_list; - GArray *uid_array; - MhUidCouple *uid_couple; - int i; - - uid_array = mh_folder->uid_array; - uid_couple = (MhUidCouple *)uid_array->data; - - for (i=0; i<uid_array->len; i++) { - uid_list = g_list_prepend (uid_list, uid_couple->uid); - uid_couple++; - } - - return uid_list; -} - - - - - - - - -/************************************************************************/ - -/*** Took directly from GNU fileutils-4.0 ***/ -/* Copyright (C) 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation. */ -/* This may be rwritten soon. -Bertrand */ - - -/* Write LEN bytes at PTR to descriptor DESC, retrying if interrupted. - Return LEN upon success, write's (negative) error code otherwise. */ -int -full_write (int desc, const char *ptr, size_t len) -{ - int total_written; - - total_written = 0; - while (len > 0) - { - int written = write (desc, ptr, len); - if (written < 0) - { - if (errno == EINTR) - continue; - return written; - } - total_written += written; - ptr += written; - len -= written; - } - return total_written; -} - - - - -static int -copy_reg (const char *src_path, const char *dst_path, CamelException *ex) -{ - char *buf; - int buf_size; - int dest_desc; - int source_desc; - int n_read; - struct stat sb; - char *cp; - int *ip; - int return_val = 0; - off_t n_read_total = 0; - int last_write_made_hole = 0; - int make_holes = TRUE; - - source_desc = open (src_path, O_RDONLY); - if (source_desc < 0) - { - /* If SRC_PATH doesn't exist, then chances are good that the - user did something like this `cp --backup foo foo': and foo - existed to start with, but copy_internal renamed DST_PATH - with the backup suffix, thus also renaming SRC_PATH. */ - if (errno == ENOENT) - error (0, 0, "`%s' and `%s' are the same file", - src_path, dst_path); - else - error (0, errno, "%s", src_path); - - return -1; - } - - /* Create the new regular file with small permissions initially, - to not create a security hole. */ - - dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, 0600); - if (dest_desc < 0) - { - error (0, errno, "cannot create regular file `%s'", dst_path); - return_val = -1; - goto ret2; - } - - /* Find out the optimal buffer size. */ - - if (fstat (dest_desc, &sb)) - { - error (0, errno, "%s", dst_path); - return_val = -1; - goto ret; - } - - buf_size = 8192; - - - - /* Make a buffer with space for a sentinel at the end. */ - - buf = (char *) alloca (buf_size + sizeof (int)); - - for (;;) - { - n_read = read (source_desc, buf, buf_size); - if (n_read < 0) - { - if (errno == EINTR) - continue; - error (0, errno, "%s", src_path); - return_val = -1; - goto ret; - } - if (n_read == 0) - break; - - n_read_total += n_read; - - ip = 0; - if (make_holes) - { - buf[n_read] = 1; /* Sentinel to stop loop. */ - - /* Find first nonzero *word*, or the word with the sentinel. */ - - ip = (int *) buf; - while (*ip++ == 0) - ; - - /* Find the first nonzero *byte*, or the sentinel. */ - - cp = (char *) (ip - 1); - while (*cp++ == 0) - ; - - /* If we found the sentinel, the whole input block was zero, - and we can make a hole. */ - - if (cp > buf + n_read) - { - /* Make a hole. */ - if (lseek (dest_desc, (off_t) n_read, SEEK_CUR) < 0L) - { - error (0, errno, "%s", dst_path); - return_val = -1; - goto ret; - } - last_write_made_hole = 1; - } - else - /* Clear to indicate that a normal write is needed. */ - ip = 0; - } - if (ip == 0) - { - if (full_write (dest_desc, buf, n_read) < 0) - { - error (0, errno, "%s", dst_path); - return_val = -1; - goto ret; - } - last_write_made_hole = 0; - } - } - - /* If the file ends with a `hole', something needs to be written at - the end. Otherwise the kernel would truncate the file at the end - of the last write operation. */ - - if (last_write_made_hole) - { -#if HAVE_FTRUNCATE - /* Write a null character and truncate it again. */ - if (full_write (dest_desc, "", 1) < 0 - || ftruncate (dest_desc, n_read_total) < 0) -#else - /* Seek backwards one character and write a null. */ - if (lseek (dest_desc, (off_t) -1, SEEK_CUR) < 0L - || full_write (dest_desc, "", 1) < 0) -#endif - { - error (0, errno, "%s", dst_path); - return_val = -1; - } - } - -ret: - if (close (dest_desc) < 0) - { - error (0, errno, "%s", dst_path); - return_val = -1; - } -ret2: - if (close (source_desc) < 0) - { - error (0, errno, "%s", src_path); - return_val = -1; - } - - return return_val; -} diff --git a/camel/providers/MH/camel-mh-folder.h b/camel/providers/MH/camel-mh-folder.h deleted file mode 100644 index 40800375eb..0000000000 --- a/camel/providers/MH/camel-mh-folder.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mh-folder.h : Abstract class for an email folder */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_MH_FOLDER_H -#define CAMEL_MH_FOLDER_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include "camel-folder.h" -/* #include "camel-store.h" */ - -#define CAMEL_MH_FOLDER_TYPE (camel_mh_folder_get_type ()) -#define CAMEL_MH_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_MH_FOLDER_TYPE, CamelMhFolder)) -#define CAMEL_MH_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MH_FOLDER_TYPE, CamelMhFolderClass)) -#define IS_CAMEL_MH_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_MH_FOLDER_TYPE)) - - -typedef struct { - CamelFolder parent_object; - - gchar *directory_path; - GList *file_name_list; - GArray *uid_array; - -} CamelMhFolder; - - - -typedef struct { - CamelFolderClass parent_class; - - /* Virtual methods */ - -} CamelMhFolderClass; - - -/* public methods */ - -/* Standard Gtk function */ -GtkType camel_mh_folder_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MH_FOLDER_H */ diff --git a/camel/providers/MH/camel-mh-provider.c b/camel/providers/MH/camel-mh-provider.c deleted file mode 100644 index 316b8a0797..0000000000 --- a/camel/providers/MH/camel-mh-provider.c +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mh-provider.c: mh provider registration code */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "config.h" -#include "camel-mh-store.h" -#include "camel-provider.h" -#include "camel-log.h" - - -static CamelProvider _mh_provider = { - (GtkType) 0, - PROVIDER_STORE, - "mh", - "Camel default mh provider", - "This is a very simple provider, mh is a bad protocol anyway", - (GModule *) NULL -}; - - - -CamelProvider * -camel_provider_module_init () -{ - _mh_provider.object_type = camel_mh_store_get_type(); - return &_mh_provider; -} diff --git a/camel/providers/MH/camel-mh-store.c b/camel/providers/MH/camel-mh-store.c deleted file mode 100644 index 60ba07f47b..0000000000 --- a/camel/providers/MH/camel-mh-store.c +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mh-store.c : class for an mh store */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "camel-mh-store.h" -#include "camel-mh-folder.h" -#include "url-util.h" - -static CamelStoreClass *parent_class=NULL; - -/* Returns the class for a CamelMhStore */ -#define CMHS_CLASS(so) CAMEL_MH_STORE_CLASS (GTK_OBJECT(so)->klass) -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CMHF_CLASS(so) CAMEL_MH_FOLDER_CLASS (GTK_OBJECT(so)->klass) - -static void _init (CamelStore *store, CamelSession *session, const gchar *url_name); -static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name); - - -static void -camel_mh_store_class_init (CamelMhStoreClass *camel_mh_store_class) -{ - CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS (camel_mh_store_class); - - parent_class = gtk_type_class (camel_store_get_type ()); - - /* virtual method definition */ - /* virtual method overload */ - camel_store_class->init = _init; - camel_store_class->get_folder = _get_folder; -} - - - -static void -camel_mh_store_init (gpointer object, gpointer klass) -{ - CamelMhStore *mh_store = CAMEL_MH_STORE (object); - CamelStore *store = CAMEL_STORE (object); - - store->separator = '/'; -} - - - - -GtkType -camel_mh_store_get_type (void) -{ - static GtkType camel_mh_store_type = 0; - - if (!camel_mh_store_type) { - GtkTypeInfo camel_mh_store_info = - { - "CamelMhStore", - sizeof (CamelMhStore), - sizeof (CamelMhStoreClass), - (GtkClassInitFunc) camel_mh_store_class_init, - (GtkObjectInitFunc) camel_mh_store_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_mh_store_type = gtk_type_unique (CAMEL_STORE_TYPE, &camel_mh_store_info); - } - - return camel_mh_store_type; -} - - - - -/* These evil public functions are here for test only */ -void -camel_mh_store_set_toplevel_dir (CamelMhStore *store, const gchar *toplevel) -{ - store->toplevel_dir = g_strdup (toplevel); - CAMEL_STORE(store)->separator = '/'; -} - - -const gchar * -camel_mh_store_get_toplevel_dir (CamelMhStore *store) -{ - return store->toplevel_dir; -} - - - -static void -_init (CamelStore *store, CamelSession *session, const gchar *url_name) -{ - CamelMhStore *mh_store = CAMEL_MH_STORE (store); - Gurl *store_url; - - g_assert (url_name); - /* call parent implementation */ - parent_class->init (store, session, url_name); - - - /* find the path in the URL*/ - store_url = g_url_new (url_name); - - g_return_if_fail (store_url); - g_return_if_fail (store_url->path); - - mh_store->toplevel_dir = g_strdup (store_url->path); - g_url_free (store_url); - - - -} - - -static CamelFolder * -_get_folder (CamelStore *store, const gchar *folder_name) -{ - CamelMhFolder *new_mh_folder; - CamelFolder *new_folder; - - /* check if folder has already been created */ - /* call the standard routine for that when */ - /* it is done ... */ - - new_mh_folder = gtk_type_new (CAMEL_MH_FOLDER_TYPE); - new_folder = CAMEL_FOLDER (new_mh_folder); - - CF_CLASS (new_folder)->init_with_store (new_folder, store, NULL); - CF_CLASS (new_folder)->set_name (new_folder, folder_name, NULL); - - - return new_folder; -} diff --git a/camel/providers/MH/camel-mh-store.h b/camel/providers/MH/camel-mh-store.h deleted file mode 100644 index 924a5a6fc5..0000000000 --- a/camel/providers/MH/camel-mh-store.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-mhstore.h : class for an mh store */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_MH_STORE_H -#define CAMEL_MH_STORE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include "camel-store.h" - -#define CAMEL_MH_STORE_TYPE (camel_mh_store_get_type ()) -#define CAMEL_MH_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_MH_STORE_TYPE, CamelMhStore)) -#define CAMEL_MH_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MH_STORE_TYPE, CamelMhStoreClass)) -#define IS_CAMEL_MH_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_MH_STORE_TYPE)) - - -typedef struct { - CamelStore parent_object; - - gchar *toplevel_dir; -} CamelMhStore; - - - -typedef struct { - CamelStoreClass parent_class; - - -} CamelMhStoreClass; - - -/* public methods */ - -/* Standard Gtk function */ -GtkType camel_mh_store_get_type (void); - -void camel_mh_store_set_toplevel_dir (CamelMhStore *store, const gchar *toplevel); -const gchar *camel_mh_store_get_toplevel_dir (CamelMhStore *store); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MH_STORE_H */ - - diff --git a/camel/providers/MH/mh-summary.c b/camel/providers/MH/mh-summary.c deleted file mode 100644 index 5a964696e0..0000000000 --- a/camel/providers/MH/mh-summary.c +++ /dev/null @@ -1,290 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include <config.h> - -#include "mh-uid.h" -#include "camel-log.h" -#include "camel-stream.h" -#include "camel-stream-fs.h" -#include "camel-stream-buffered-fs.h" -#include "gmime-utils.h" -#include "mh-utils.h" - -#include <sys/stat.h> -#include <unistd.h> -#include <sys/types.h> -#include <fcntl.h> -#include <dirent.h> -#include <stdio.h> -#include <string.h> -#include <errno.h> - -void -mh_generate_summary (CamelFolder *folder) -{ - CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); - CamelFolderSummary *summary; - CamelMessageInfo *message_info; - CamelFolderInfo *subfolder_info; - CamelStream *message_stream; - guint file_number; - gchar *message_fullpath; - gchar *directory_path; - GArray *header_array; - MhUidCouple *uid_couple; - Rfc822Header *cur_header; - int i; - int n_file; - GArray *uid_array; - - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::generate_summary entering \n"); - - g_assert (folder); - - directory_path = mh_folder->directory_path; - if (!directory_path) { - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::generate_summary folder has no directory path\n"); - return; - } - - summary = camel_folder_summary_new (); - folder->summary = summary; - - uid_array = mh_folder->uid_array; - - if (!uid_array) { - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::generate_summary " - "no uid list, that probably means there is " - "no message in this folder, exiting \n"); - return; - } - uid_couple = (MhUidCouple *)uid_array->data; - - for (n_file=0; n_file<uid_array->len; n_file++) { - - file_number = uid_couple->file_number; - - message_info = g_new0 (CamelMessageInfo, 1); - message_info->uid = g_new0 (guchar, 17); - strncpy (message_info->uid, uid_couple->uid, 16); - - - message_fullpath = g_strdup_printf ("%s/%d", directory_path, file_number); - message_stream = camel_stream_buffered_fs_new_with_name (message_fullpath, - CAMEL_STREAM_BUFFERED_FS_READ); - if (!message_stream) { - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::generate_summary " - "could not open %d for reading\n", message_fullpath); - g_free (message_fullpath); - return; - } - g_free (message_fullpath); - - header_array = get_header_array_from_stream (message_stream); - gtk_object_unref (GTK_OBJECT (message_stream)); - - for (i=0; i<header_array->len; i++) { - cur_header = (Rfc822Header *)header_array->data + i; - if (!g_strcasecmp (cur_header->name, "subject")) { - message_info->subject = cur_header->value; - g_free (cur_header->name); - } else if (!g_strcasecmp (cur_header->name, "sender")) { - message_info->date = cur_header->value; - g_free (cur_header->name); - } else if (!g_strcasecmp (cur_header->name, "date")) { - message_info->date = cur_header->value; - g_free (cur_header->name); - } else { - g_free (cur_header->name); - g_free (cur_header->value); - } - } - g_array_free (header_array, TRUE); - - summary->message_info_list = g_list_append (summary->message_info_list, message_info); - - /* next message in the uid list */ - uid_couple++; - } - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::generate_summary leaving \n"); - -} - - -void -mh_save_summary (CamelMhFolder *mh_folder) -{ - GArray *uid_array; - MhUidCouple *first_uid_couple; - CamelFolderSummary *summary; - GList *msg_info_list; - CamelMessageInfo *msg_info; - gchar *directory_path = mh_folder->directory_path; - gchar *summary_file_path; - gint fd; - gint i; - gint field_lgth; - - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::save_summary entering \n"); - - summary = CAMEL_FOLDER (mh_folder)->summary; - if (!summary) return; - - summary_file_path = g_strdup_printf ("%s/%s", directory_path, ".camel-summary"); - CAMEL_LOG_FULL_DEBUG ("In the process of writing %s\n", summary_file_path); - fd = open (summary_file_path, O_WRONLY | O_CREAT ); - - if (!fd) { - CAMEL_LOG_FULL_DEBUG ("could not open file %s for writing. Exiting.\n", summary_file_path); - g_free (summary_file_path); - return; - } - g_free (summary_file_path); - - msg_info_list = summary->message_info_list; - while (msg_info_list) { - msg_info = msg_info_list->data; - /* write subject */ - field_lgth = msg_info->subject ? strlen (msg_info->subject) : 0; - write (fd, &field_lgth, sizeof (gint)); - if (field_lgth) - write (fd, msg_info->subject, field_lgth); - - /* write uid */ - field_lgth = msg_info->uid ? strlen (msg_info->uid) : 0; - write (fd, &field_lgth, sizeof (gint)); - if (field_lgth) - write (fd, msg_info->uid, field_lgth); - - /* write date */ - field_lgth = msg_info->date ? strlen (msg_info->date) : 0; - write (fd, &field_lgth, sizeof (gint)); - if (field_lgth) - write (fd, msg_info->date, field_lgth); - - /* write sender */ - field_lgth = msg_info->sender ? strlen (msg_info->sender) : 0; - write (fd, &field_lgth, sizeof (gint)); - if (field_lgth) - write (fd, msg_info->sender, field_lgth); - - msg_info_list = msg_info_list->next; - - } - - close (fd); - - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::save_summary leaving \n"); - -} - - - - - -gint -mh_load_summary (CamelMhFolder *mh_folder) -{ - GArray *uid_array; - MhUidCouple *first_uid_couple; - CamelFolderSummary *summary; - CamelMessageInfo *msg_info; - gchar *directory_path = mh_folder->directory_path; - gchar *summary_file_path; - gint fd; - gint i; - gint field_lgth; - gboolean file_eof; - gint stat_error; - struct stat stat_buf; - - summary = CAMEL_FOLDER (mh_folder)->summary; - if (summary) return 1; /* should we regenerate it ? */ - - summary_file_path = g_strdup_printf ("%s/%s", directory_path, ".camel-summary"); - CAMEL_LOG_FULL_DEBUG ("In the process of reading %s\n", summary_file_path); - fd = open (summary_file_path, O_RDONLY); - /* tests if file exists */ - stat_error = stat (summary_file_path, &stat_buf); - - if (!((stat_error != -1) && S_ISREG (stat_buf.st_mode))) { - CAMEL_LOG_FULL_DEBUG ("could not open file %s for reading. Exiting.\n", summary_file_path); - g_free (summary_file_path); - return -1; - } - g_free (summary_file_path); - - for (;;) { - /* read subject */ - file_eof = (read (fd, &field_lgth, sizeof (gint)) <= 0); - if (file_eof) break; - - - /* allcate a summary if needed */ - if (!summary) - summary = camel_folder_summary_new (); - /* allocate a message info struct */ - msg_info = g_new0 (CamelMessageInfo, 1); - - if (!file_eof && (field_lgth > 0)) { - msg_info->subject = g_new0 (gchar, field_lgth + 1); - read (fd, msg_info->subject, field_lgth); - } else - msg_info->subject = NULL; - - /* read uid */ - if (!file_eof) file_eof = (read (fd, &field_lgth, sizeof (gint)) <= 0); - if (!file_eof && (field_lgth > 0)) { - msg_info->uid = g_new0 (gchar, field_lgth + 1); - read (fd, msg_info->uid, field_lgth); - } else - msg_info->uid = NULL; - - /* read date */ - if (!file_eof) file_eof = (read (fd, &field_lgth, sizeof (gint)) <= 0); - if (!file_eof && (field_lgth > 0)) { - msg_info->date = g_new0 (gchar, field_lgth + 1); - read (fd, msg_info->date, field_lgth); - } else - msg_info->date = NULL; - - /* read sender */ - if (!file_eof) file_eof = (read (fd, &field_lgth, sizeof (gint)) <= 0); - if (!file_eof && (field_lgth > 0)) { - msg_info->sender = g_new0 (gchar, field_lgth + 1); - read (fd, msg_info->sender, field_lgth); - } else - msg_info->sender = NULL; - - summary->message_info_list = g_list_prepend (summary->message_info_list, - msg_info); - } - - CAMEL_FOLDER (mh_folder)->summary = summary; - - close (fd); - return 1; -} - - diff --git a/camel/providers/MH/mh-summary.h b/camel/providers/MH/mh-summary.h deleted file mode 100644 index 27c9a21f60..0000000000 --- a/camel/providers/MH/mh-summary.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef MH_SUMMARY_H -#define MH_SUMMARY_H 1 - -#include <glib.h> -#include "camel-mh-folder.h" - -void mh_generate_summary (CamelFolder *folder); -void mh_save_summary (CamelMhFolder *mh_folder); -gint mh_load_summary (CamelMhFolder *mh_folder); - -#endif /* MH_SUMMARY_H */ diff --git a/camel/providers/MH/mh-uid.c b/camel/providers/MH/mh-uid.c deleted file mode 100644 index 7dbde4de00..0000000000 --- a/camel/providers/MH/mh-uid.c +++ /dev/null @@ -1,220 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include <config.h> - -#include "mh-uid.h" -#include "camel-log.h" -#include "camel-stream.h" -#include "camel-stream-fs.h" -#include "camel-stream-buffered-fs.h" -#include "gmime-utils.h" -#include "md5-utils.h" -#include "mh-utils.h" - -#include <sys/stat.h> -#include <unistd.h> -#include <sys/types.h> -#include <fcntl.h> -#include <dirent.h> -#include <stdio.h> -#include <string.h> -#include <errno.h> - -void -mh_uid_get_for_file (gchar *filename, guchar uid[16]) -{ - CamelStream *message_stream; - GArray *header_array; - Rfc822Header *cur_header; - int i; - MD5Context ctx; - - - message_stream = camel_stream_buffered_fs_new_with_name (filename, - CAMEL_STREAM_BUFFERED_FS_READ); - header_array = get_header_array_from_stream (message_stream); - gtk_object_unref (GTK_OBJECT (message_stream)); - - md5_init (&ctx); - for (i=0; i<header_array->len; i++) { - cur_header = (Rfc822Header *)header_array->data + i; - if (!g_strcasecmp (cur_header->name, "subject")) { - md5_update (&ctx, cur_header->value, strlen (cur_header->value)); - } else if (!g_strcasecmp (cur_header->name, "sender")) { - md5_update (&ctx, cur_header->value, strlen (cur_header->value)); - } else if (!g_strcasecmp (cur_header->name, "date")) { - md5_update (&ctx, cur_header->value, strlen (cur_header->value)); - } - - g_free (cur_header->name); - g_free (cur_header->value); - - } - - g_array_free (header_array, TRUE); - - md5_final (uid, &ctx); -} - - - - -void -mh_save_uid_list (CamelMhFolder *mh_folder) -{ - GArray *uid_array; - MhUidCouple *first_uid_couple; - gchar *directory_path = mh_folder->directory_path; - gchar *uidfile_path; - int fd; - int i; - - - uidfile_path = g_strdup_printf ("%s/%s", directory_path, ".camel-uid-list"); - CAMEL_LOG_FULL_DEBUG ("In the process of writing %s\n", uidfile_path); - fd = open (uidfile_path, O_WRONLY | O_CREAT ); - - if (!fd) { - CAMEL_LOG_FULL_DEBUG ("could not open file %s for writing. Exiting.\n", uidfile_path); - g_free (uidfile_path); - return; - } - g_free (uidfile_path); - - uid_array = mh_folder->uid_array; - first_uid_couple = (MhUidCouple *)uid_array->data; - - /* write the number of uid contained in the file */ - write (fd, &(uid_array->len), sizeof (guint)); - CAMEL_LOG_FULL_DEBUG ("%d entrie present in the list\n", uid_array->len); - /* now write the array of uid self */ - write (fd, first_uid_couple, sizeof (MhUidCouple) * uid_array->len); - - close (fd); -} - - -gint -mh_load_uid_list (CamelMhFolder *mh_folder) -{ - GArray *new_uid_array; - MhUidCouple *first_uid_couple; - gchar *directory_path = mh_folder->directory_path; - gchar *uidfile_path; - int fd; - guint uid_nb; - struct stat stat_buf; - gint stat_error = 0; - - uidfile_path = g_strdup_printf ("%s/%s", directory_path, ".camel-uid-list"); - - /* tests if file exists */ - stat_error = stat (uidfile_path, &stat_buf); - - - if (!((stat_error != -1) && S_ISREG (stat_buf.st_mode))) { - CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::load_uid_list " - "file %s does not exist. Exiting.\n", uidfile_path); - g_free (uidfile_path); - return -1; - } - - fd = open (uidfile_path, O_RDONLY); - g_free (uidfile_path); - if (!fd) return -1; - - if (mh_folder->uid_array) g_array_free (mh_folder->uid_array, FALSE); - - /* read the number of uids in the file */ - read (fd, &uid_nb, sizeof (guint)); - CAMEL_LOG_FULL_DEBUG ("reading %d uid_entries\n", uid_nb); - new_uid_array = g_array_new (FALSE, FALSE, sizeof (MhUidCouple)); - new_uid_array = g_array_set_size (new_uid_array, uid_nb); - first_uid_couple = (MhUidCouple *)new_uid_array->data; - - - read (fd, first_uid_couple, sizeof (MhUidCouple) * uid_nb); - - mh_folder->uid_array = new_uid_array; - - return 1; -} - - -gint -mh_generate_uid_list (CamelMhFolder *mh_folder) -{ - GArray *new_uid_array; - const gchar *directory_path; - struct dirent *dir_entry; - DIR *dir_handle; - gchar *msg_path; - guint msg_count; - MhUidCouple *uid_couple; - guint file_number; - - g_assert (mh_folder); - CAMEL_LOG_FULL_DEBUG ("in the process of creating uid list \n"); - directory_path = mh_folder->directory_path; - if (!directory_path) { - CAMEL_LOG_FULL_DEBUG ("folder has no directory path. Exiting\n"); - return -1; - } - - msg_count = camel_folder_get_message_count (CAMEL_FOLDER (mh_folder), NULL); - if (!msg_count) { - CAMEL_LOG_FULL_DEBUG ("no message in %s. Exiting\n", directory_path); - return -1; - } - - new_uid_array = g_array_new (FALSE, FALSE, sizeof (MhUidCouple)); - new_uid_array = g_array_set_size (new_uid_array, msg_count); - uid_couple = (MhUidCouple *)new_uid_array->data; - - dir_handle = opendir (directory_path); - - /* read first entry in the directory */ - dir_entry = readdir (dir_handle); - while (dir_entry != NULL) { - - /* tests if the entry correspond to a message file */ - if (mh_is_a_message_file (dir_entry->d_name, directory_path)) { - - /* get the uid for this message */ - msg_path = g_strdup_printf ("%s/%s", directory_path, dir_entry->d_name); - mh_uid_get_for_file (msg_path, uid_couple->uid); - g_free (msg_path); - - /* convert filename into file number */ - uid_couple->file_number = atoi (dir_entry->d_name); - uid_couple++; - } - - /* read next entry */ - dir_entry = readdir (dir_handle); - } - - closedir (dir_handle); - mh_folder->uid_array = new_uid_array; -} diff --git a/camel/providers/MH/mh-uid.h b/camel/providers/MH/mh-uid.h deleted file mode 100644 index 63dfe5b159..0000000000 --- a/camel/providers/MH/mh-uid.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef MH_UID_H -#define MH_UID_H 1 - -#include <glib.h> -#include "camel-mh-folder.h" - - -typedef struct { - gchar uid[16]; - guint file_number; -} MhUidCouple; - -void mh_uid_get_for_file (gchar *filename, guchar uid[16]); -void mh_save_uid_list (CamelMhFolder *mh_folder); -gint mh_load_uid_list (CamelMhFolder *mh_folder); -gint mh_generate_uid_list (CamelMhFolder *mh_folder); - -#endif /* MH_UID_H */ diff --git a/camel/providers/MH/mh-utils.c b/camel/providers/MH/mh-utils.c deleted file mode 100644 index 51bb84bc65..0000000000 --- a/camel/providers/MH/mh-utils.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include <config.h> -#include "mh-utils.h" - -#include <sys/stat.h> - -gboolean -mh_is_a_message_file (const gchar *file_name, const gchar *file_path) -{ - struct stat stat_buf; - gint stat_error = 0; - gboolean ok; - gchar *full_file_name; - int i; - - /* test if the name is a number */ - i=0; - while ((file_name[i] != '\0') && (file_name[i] >= '0') && (file_name[i] <= '9')) - i++; - if ((i==0) || (file_name[i] != '\0')) return FALSE; - - /* is it a regular file ? */ - full_file_name = g_strdup_printf ("%s/%s", file_path, file_name); - stat_error = stat (full_file_name, &stat_buf); - g_free (full_file_name); - - return ((stat_error != -1) && S_ISREG (stat_buf.st_mode)); -} - diff --git a/camel/providers/MH/mh-utils.h b/camel/providers/MH/mh-utils.h deleted file mode 100644 index 968228b0a3..0000000000 --- a/camel/providers/MH/mh-utils.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef MH_UTILS_H -#define MH_UTILS_H 1 - -#include <glib.h> - -gboolean mh_is_a_message_file (const gchar *file_name, const gchar *file_path); - -#endif /* MH_UTILS_H */ diff --git a/camel/providers/Makefile.am b/camel/providers/Makefile.am deleted file mode 100644 index b9d97b52d4..0000000000 --- a/camel/providers/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = MH maildir diff --git a/camel/providers/maildir/.cvsignore b/camel/providers/maildir/.cvsignore deleted file mode 100644 index 2e7b174532..0000000000 --- a/camel/providers/maildir/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -Makefile.in -Makefile -.deps -*.lo -*.la -.libs diff --git a/camel/providers/maildir/Makefile.am b/camel/providers/maildir/Makefile.am deleted file mode 100644 index 51a0d7327b..0000000000 --- a/camel/providers/maildir/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = - -libcamelmaildirincludedir = $(includedir)/camel - -lib_LTLIBRARIES = libcamelmaildir.la - -INCLUDES = -I.. -I$(srcdir)/.. -I$(top_srcdir)/intl -I$(top_srcdir)/camel \ - $(GTK_INCLUDEDIR) -I$(includedir) - -libcamelmaildir_la_SOURCES = \ - camel-maildir-folder.c \ - camel-maildir-provider.c \ - camel-maildir-store.c - -libcamelmaildirinclude_HEADERS = \ - camel-maildir-folder.h \ - camel-maildir-store.h - -libcamelmaildir_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) - -EXTRA_DIST = diff --git a/camel/providers/maildir/camel-maildir-folder.c b/camel/providers/maildir/camel-maildir-folder.c deleted file mode 100644 index 4ad5409658..0000000000 --- a/camel/providers/maildir/camel-maildir-folder.c +++ /dev/null @@ -1,803 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-maildir-folder.c : camel-folder subclass for maildir folders */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/* - * AUTHORS : Jukka Zitting - * - */ - - -#include <config.h> -#include <sys/stat.h> -#include <sys/param.h> -#include <unistd.h> -#include <sys/types.h> -#include <fcntl.h> -#include <dirent.h> -#include <stdio.h> -#include <errno.h> -#include <time.h> -#include <string.h> -#include "camel-maildir-folder.h" -#include "camel-maildir-store.h" -#include "camel-stream-fs.h" -#include "camel-log.h" - -static CamelFolderClass *parent_class=NULL; - -/* Returns the class for a CamelMaildirFolder */ -#define CMAILDIRF_CLASS(so) CAMEL_MAILDIR_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CMAILDIRS_CLASS(so) CAMEL_STORE_CLASS (GTK_OBJECT(so)->klass) - -static void _init_with_store (CamelFolder *folder, CamelStore *parent_store, CamelException *ex); -static void _set_name (CamelFolder *folder, const gchar *name, CamelException *ex); -static gboolean _exists (CamelFolder *folder, CamelException *ex); -static gboolean _create (CamelFolder *folder, CamelException *ex); -static gboolean _delete (CamelFolder *folder, gboolean recurse, CamelException *ex); -static gboolean _delete_messages (CamelFolder *folder, CamelException *ex); -static CamelMimeMessage *_get_message (CamelFolder *folder, gint number, CamelException *ex); -static gint _get_message_count (CamelFolder *folder, CamelException *ex); -static void _expunge (CamelFolder *folder, CamelException *ex); -static GList *_list_subfolders (CamelFolder *folder, CamelException *ex); - -/* fs utility functions */ -static DIR * _xopendir (const gchar *path); -static gboolean _xstat (const gchar *path, struct stat *buf); -static gboolean _xmkdir (const gchar *path); -static gboolean _xrename (const gchar *from, const gchar *to); -static gboolean _xunlink (const gchar *path); -static gboolean _xrmdir (const gchar *path); -/* ** */ - -static void -camel_maildir_folder_class_init (CamelMaildirFolderClass *camel_maildir_folder_class) -{ - CamelFolderClass *camel_folder_class = - CAMEL_FOLDER_CLASS (camel_maildir_folder_class); - - parent_class = gtk_type_class (camel_folder_get_type ()); - - /* virtual method definition */ - /* virtual method overload */ - camel_folder_class->init_with_store = _init_with_store; - camel_folder_class->set_name = _set_name; - camel_folder_class->exists = _exists; - camel_folder_class->create = _create; - camel_folder_class->delete = _delete; - camel_folder_class->delete_messages = _delete_messages; - camel_folder_class->expunge = _expunge; - camel_folder_class->get_message = _get_message; - camel_folder_class->get_message_count = _get_message_count; - camel_folder_class->list_subfolders = _list_subfolders; -} - -GtkType -camel_maildir_folder_get_type (void) -{ - static GtkType camel_maildir_folder_type = 0; - - if (!camel_maildir_folder_type) { - GtkTypeInfo camel_maildir_folder_info = - { - "CamelMaildirFolder", - sizeof (CamelMaildirFolder), - sizeof (CamelMaildirFolderClass), - (GtkClassInitFunc) camel_maildir_folder_class_init, - (GtkObjectInitFunc) NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_maildir_folder_type = - gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_maildir_folder_info); - } - - return camel_maildir_folder_type; -} - - - - - - -/** - * CamelMaildirFolder::init_with_store: initializes the folder object - * @folder: folder object to initialize - * @parent_store: parent store object of the folder - * - * Simply tells that the folder can contain messages but not subfolders. - * Perhaps we'll later implement subfolders too... - */ -static void -_init_with_store (CamelFolder *folder, CamelStore *parent_store, CamelException *ex) -{ - CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::init_with_store\n"); - g_assert (folder); - g_assert (parent_store); - - /* call parent method */ - parent_class->init_with_store (folder, parent_store, ex); - - folder->can_hold_messages = TRUE; - folder->can_hold_folders = TRUE; - folder->has_summary_capability = FALSE; - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::init_with_store\n"); -} - -/** - * CamelMaildirFolder::set_name: sets the name of the folder - * @folder: folder object - * @name: name of the folder - * - * Sets the name of the folder object. The existence of a folder with - * the given name is not checked in this function. - */ -static void -_set_name (CamelFolder *folder, const gchar *name, CamelException *ex) -{ - CamelMaildirFolder *maildir_folder; - CamelMaildirStore *maildir_store; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::set_name\n"); - g_assert (folder); - g_assert (name); - g_assert (folder->parent_store); - - maildir_folder = CAMEL_MAILDIR_FOLDER (folder); - maildir_store = CAMEL_MAILDIR_STORE (folder->parent_store); - - /* call default implementation */ - parent_class->set_name (folder, name, ex); - - if (maildir_folder->directory_path) - g_free (maildir_folder->directory_path); - - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::set_name full_name is %s\n", folder->full_name); - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::set_name toplevel_dir is %s\n", maildir_store->toplevel_dir); - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::set_name separator is %c\n", camel_store_get_separator (folder->parent_store)); - - if (folder->full_name && folder->full_name[0]) - maildir_folder->directory_path = - g_strconcat (maildir_store->toplevel_dir, G_DIR_SEPARATOR_S, - folder->full_name, NULL); - else - maildir_folder->directory_path = g_strdup (maildir_store->toplevel_dir); - - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::set_name: name set to %s\n", name); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::set_name\n"); -} - -/** - * CamelMaildirFolder::exists: tests whether the named maildir exists - * @folder: folder object - * - * A created maildir folder object doesn't necessarily exist yet in the - * filesystem. This function checks whether the maildir exists. - * The structure of the maildir is stated in the maildir.5 manpage. - * - * maildir.5: - * A directory in maildir format has three subdirectories, - * all on the same filesystem: tmp, new, and cur. - * - * Return value: TRUE if the maildir exists, FALSE otherwise - */ -static gboolean -_exists (CamelFolder *folder, CamelException *ex) -{ - CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder); - static const gchar *dir[3] = { "new", "cur", "tmp" }; - gint i; - struct stat statbuf; - const gchar *maildir; - gchar *path; - gboolean rv = TRUE; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::exists\n"); - g_assert (folder); - g_return_val_if_fail (maildir_folder->directory_path, FALSE); - - maildir = maildir_folder->directory_path; - - CAMEL_LOG_FULL_DEBUG ("CamelMailFolder::exists: checking maildir %s\n", - maildir); - - /* check whether the toplevel directory exists */ - rv = _xstat (maildir, &statbuf) && S_ISDIR (statbuf.st_mode); - - /* check whether the maildir subdirectories exist */ - for (i = 0; rv && i < 3; i++) { - path = g_strconcat (maildir, G_DIR_SEPARATOR_S, dir[i], NULL); - - rv = _xstat (path, &statbuf) && S_ISDIR (statbuf.st_mode); - - g_free (path); - } - - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::exists: %s\n", - (rv) ? "maildir found" : "maildir not found"); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::exists\n"); - return rv; -} - -/** - * CamelMaildirFolder::create: creates the named maildir - * @folder: folder object - * - * A created maildir folder object doesn't necessarily exist yet in the - * filesystem. This function creates the maildir if it doesn't yet exist. - * The structure of the maildir is stated in the maildir.5 manpage. - * - * maildir.5: - * A directory in maildir format has three subdirectories, - * all on the same filesystem: tmp, new, and cur. - * - * Return value: TRUE if the maildir existed already or was created, - * FALSE otherwise - */ -static gboolean -_create (CamelFolder *folder, CamelException *ex) -{ - CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder); - static const gchar *dir[3] = { "new", "cur", "tmp" }; - gint i; - const gchar *maildir; - gchar *path; - gboolean rv = TRUE; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::create\n"); - g_assert (folder); - - /* check whether the maildir already exists */ - if (camel_folder_exists (folder, ex)) return TRUE; - - maildir = maildir_folder->directory_path; - - CAMEL_LOG_FULL_DEBUG ("CamelMailFolder::create: creating maildir %s\n", - maildir); - - /* create the toplevel directory */ - rv = _xmkdir (maildir); - - /* create the maildir subdirectories */ - for (i = 0; rv && i < 3; i++) { - path = g_strconcat (maildir, G_DIR_SEPARATOR_S, dir[i], NULL); - - rv = _xmkdir (path); - - g_free (path); - } - - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::create: %s\n", - rv ? "maildir created" : "an error occurred"); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::create\n"); - return rv; -} - -/** - * CamelMaildirFolder::delete: delete the maildir folder - * @folder: the folder object - * @recurse: - * - * This function empties and deletes the maildir folder. The subdirectories - * "tmp", "cur", and "new" are removed first and then the toplevel maildir - * directory is deleted. All files from the directories are deleted as well, - * so you should be careful when using this function. If a subdirectory cannot - * be deleted, then the operation it is stopped. Thus if an error occurs, the - * maildir directory won't be removed, but it might no longer be a valid maildir. - */ -static gboolean -_delete (CamelFolder *folder, gboolean recurse, CamelException *ex) -{ - CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder); - static const gchar *dir[3] = { "new", "cur", "tmp" }; - gint i; - const gchar *maildir; - gchar *path; - gboolean rv = TRUE; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::create\n"); - g_assert (folder); - - /* check whether the maildir already exists */ - if (!camel_folder_exists (folder, ex)) return TRUE; - - maildir = maildir_folder->directory_path; - - CAMEL_LOG_FULL_DEBUG ("CamelMailFolder::delete: deleting maildir %s\n", - maildir); - - /* delete the maildir subdirectories */ - for (i = 0; rv && i < 3; i++) { - path = g_strconcat (maildir, G_DIR_SEPARATOR_S, dir[i], NULL); - - rv = _xrmdir (path); - - g_free (path); - } - - /* create the toplevel directory */ - if (rv) - rv = _xrmdir (maildir); - - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::delete: %s\n", - rv ? "maildir deleted" : "an error occurred"); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::delete\n"); - return rv; -} - -/** - * CamelMaildirFolder::delete_messages: empty the maildir folder - * @folder: the folder object - * - * This function empties the maildir folder. All messages from the - * "cur" subdirectory are deleted. If a message cannot be deleted, then - * it is just skipped and the rest of the messages are still deleted. - * Files with names starting with a dot are skipped as described in the - * maildir.5 manpage. - * - * maildir.5: - * It is a good idea for readers to skip all filenames in new - * and cur starting with a dot. Other than this, readers - * should not attempt to parse filenames. - * - * Return value: FALSE on error and if some messages could not be deleted. - * TRUE otherwise. - */ -static gboolean -_delete_messages (CamelFolder *folder, CamelException *ex) -{ - CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder); - const gchar *maildir; - gchar *curdir, *file; - DIR *dir_handle; - struct dirent *dir_entry; - gboolean rv = TRUE; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::delete_messages\n"); - g_assert (folder); - - /* call default implementation */ - parent_class->delete_messages (folder, ex); - - /* Check if the folder didn't exist */ - if (!camel_folder_exists (folder, ex)) return TRUE; - - maildir = maildir_folder->directory_path; - - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::delete_messages: " - "deleting messages from %s\n", maildir); - - /* delete messages from the maildir subdirectory "cur" */ - curdir = g_strconcat (maildir, G_DIR_SEPARATOR_S, "cur", NULL); - - dir_handle = _xopendir (curdir); - if (dir_handle) { - while ((dir_entry = readdir (dir_handle))) { - if (dir_entry->d_name[0] == '.') continue; - file = g_strconcat (curdir, G_DIR_SEPARATOR_S, - dir_entry->d_name, NULL); - - if (!_xunlink (file)) rv = FALSE; - - g_free (file); - } - closedir (dir_handle); - } else - rv = FALSE; - - g_free (curdir); - - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::delete_messages: %s\n", - rv ? "messages deleted" : "an error occurred"); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::delete_messages\n"); - return rv; -} - -/** - * CamelMaildirFolder::get_message: get a message from maildir - * @folder: the folder object - * @number: number of the message within the folder - * - * Return value: the message, NULL on error - */ -static CamelMimeMessage * -_get_message (CamelFolder *folder, gint number, CamelException *ex) -{ - CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER(folder); - DIR *dir_handle; - struct dirent *dir_entry; - CamelStream *stream; - CamelMimeMessage *message = NULL; - const gchar *maildir; - gchar *curdir, *file = NULL; - gint count = -1; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::get_message\n"); - g_assert(folder); - - /* Check if the folder exists */ - if (!camel_folder_exists (folder, ex)) return NULL; - - maildir = maildir_folder->directory_path; - - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::get_message: " - "getting message #%d from %s\n", number, maildir); - - /* Count until the desired message is reached */ - curdir = g_strconcat (maildir, G_DIR_SEPARATOR_S, "cur", NULL); - if ((dir_handle = _xopendir (curdir))) { - while ((count < number) && (dir_entry = readdir (dir_handle))) - if (dir_entry->d_name[0] != '.') count++; - - if (count == number) - file = g_strconcat (curdir, G_DIR_SEPARATOR_S, - dir_entry->d_name, NULL); - - closedir (dir_handle); - } - g_free (curdir); - if (!file) return NULL; - - /* Create the message object */ -#warning use session field here - message = camel_mime_message_new_with_session ((CamelSession *) NULL); - stream = camel_stream_fs_new_with_name (file, CAMEL_STREAM_FS_READ); - - if (!message || !stream) { - g_free (file); - if (stream) gtk_object_unref (GTK_OBJECT (stream)); - if (message) gtk_object_unref (GTK_OBJECT (message)); - return NULL; - } - - camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (message), - stream); - gtk_object_unref (GTK_OBJECT (stream)); - gtk_object_set_data_full (GTK_OBJECT (message), - "fullpath", file, g_free); - - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::get_message: " - "message %p created from %s\n", message, file); - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::get_message\n"); - return message; -} - -/** - * CamelMaildirFolder::get_message_count: count messages in maildir - * @folder: the folder object - * - * Returns the number of messages in the maildir folder. New messages - * are included in this count. - * - * Return value: number of messages in the maildir, -1 on error - */ -static gint -_get_message_count (CamelFolder *folder, CamelException *ex) -{ - CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER(folder); - const gchar *maildir; - gchar *newdir, *curdir, *newfile, *curfile; - DIR *dir_handle; - struct dirent *dir_entry; - guint count = 0; - - CAMEL_LOG_FULL_DEBUG ("Entering " - "CamelMaildirFolder::get_message_count\n"); - g_assert(folder); - - /* check if the maildir exists */ - if (!camel_folder_exists (folder, ex)) return -1; - - maildir = maildir_folder->directory_path; - - newdir = g_strconcat (maildir, G_DIR_SEPARATOR_S, "new", NULL); - curdir = g_strconcat (maildir, G_DIR_SEPARATOR_S, "cur", NULL); - - /* Check new messages */ - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::get_message_count: " - "getting new messages from %s\n", newdir); - if ((dir_handle = _xopendir (newdir))) { - while ((dir_entry = readdir (dir_handle))) { - if (dir_entry->d_name[0] == '.') continue; - newfile = g_strconcat (newdir, G_DIR_SEPARATOR_S, - dir_entry->d_name, NULL); - curfile = g_strconcat (curdir, G_DIR_SEPARATOR_S, - dir_entry->d_name, ":2,", NULL); - - _xrename (newfile, curfile); - - g_free (curfile); - g_free (newfile); - } - closedir (dir_handle); - } - - /* Count messages */ - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::get_message_count: " - "counting messages in %s\n", curdir); - if ((dir_handle = _xopendir (curdir))) { - while ((dir_entry = readdir (dir_handle))) - if (dir_entry->d_name[0] != '.') count++; - closedir (dir_handle); - } - - g_free (curdir); - g_free (newdir); - - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::get_message_count: " - " found %d messages\n", count); - CAMEL_LOG_FULL_DEBUG ("Leaving " - "CamelMaildirFolder::get_message_count\n"); - return count; -} - - - - -/** - * CamelMaildirFolder::expunge: expunge messages marked as deleted - * @folder: the folder object - * - * Physically deletes the messages marked as deleted in the folder. - */ -static void -_expunge (CamelFolder *folder, CamelException *ex) -{ - CamelMimeMessage *message; - GList *node; - gchar *fullpath; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::expunge\n"); - g_assert(folder); - - /* expunge messages marked for deletion */ - for (node = folder->message_list; node; node = g_list_next(node)) { - message = CAMEL_MIME_MESSAGE (node->data); - if (!message) { - CAMEL_LOG_WARNING ("CamelMaildirFolder::expunge: " - "null message in node %p\n", node); - continue; - } - - if (camel_mime_message_get_flag (message, "DELETED")) { - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::expunge: " - "expunging message #%d\n", - message->message_number); - - /* expunge the message */ - fullpath = gtk_object_get_data (GTK_OBJECT (message), - "fullpath"); - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::expunge: " - "message fullpath is %s\n", - fullpath); - - if (_xunlink (fullpath)) - message->expunged = TRUE; - } else { - CAMEL_LOG_FULL_DEBUG ("CamelMaildirFolder::expunge: " - "skipping message #%d\n", - message->message_number); - } - } - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::expunge\n"); -} - - - - -/** - * CamelMaildirFolder::list_subfolders: return a list of subfolders - * @folder: the folder object - * - * Returns the names of the maildir subfolders in a list. - * - * Return value: list of subfolder names - */ -static GList * -_list_subfolders (CamelFolder *folder, CamelException *ex) -{ - CamelMaildirFolder *maildir_folder = CAMEL_MAILDIR_FOLDER (folder); - const gchar *maildir; - gchar *subdir; - struct stat statbuf; - struct dirent *dir_entry; - DIR *dir_handle; - GList *subfolders = NULL; - - CAMEL_LOG_FULL_DEBUG ("Entering CamelMaildirFolder::list_subfolders\n"); - g_assert (folder); - - /* check if the maildir exists */ - if (!camel_folder_exists (folder, ex)) return NULL; - - /* scan through the maildir toplevel directory */ - maildir = maildir_folder->directory_path; - if ((dir_handle = _xopendir (maildir))) { - while ((dir_entry = readdir (dir_handle))) { - if (dir_entry->d_name[0] == '.') continue; - if (strcmp (dir_entry->d_name, "new") == 0) continue; - if (strcmp (dir_entry->d_name, "cur") == 0) continue; - if (strcmp (dir_entry->d_name, "tmp") == 0) continue; - - subdir = g_strconcat (maildir, G_DIR_SEPARATOR_S, - dir_entry->d_name, NULL); - - if (_xstat (subdir, &statbuf) - && S_ISDIR (statbuf.st_mode)) - subfolders = - g_list_append ( - subfolders, - g_strdup (dir_entry->d_name)); - - g_free (subdir); - } - closedir (dir_handle); - } - - CAMEL_LOG_FULL_DEBUG ("Leaving CamelMaildirFolder::list_subfolders\n"); - return subfolders; -} - - - - - - - -/* - * fs utility function - * - */ - -static DIR * -_xopendir (const gchar *path) -{ - DIR *handle; - g_assert (path); - - handle = opendir (path); - if (!handle) { - CAMEL_LOG_WARNING ("ERROR: opendir (%s);\n", path); - CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", - errno, strerror(errno)); - } - - return handle; -} - -static gboolean -_xstat (const gchar *path, struct stat *buf) -{ - gint stat_error; - g_assert (path); - g_assert (buf); - - stat_error = stat (path, buf); - if (stat_error == 0) { - return TRUE; - } else if (errno == ENOENT) { - buf->st_mode = 0; - return TRUE; - } else { - CAMEL_LOG_WARNING ("ERROR: stat (%s, %p);\n", path, buf); - CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", - errno, strerror(errno)); - return FALSE; - } -} - -static gboolean -_xmkdir (const gchar *path) -{ - g_assert (path); - - if (mkdir (path, S_IRWXU) == -1) { - CAMEL_LOG_WARNING ("ERROR: mkdir (%s, S_IRWXU);\n", path); - CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", - errno, strerror(errno)); - return FALSE; - } - - return TRUE; -} - -static gboolean -_xrename (const gchar *from, const gchar *to) -{ - g_assert (from); - g_assert (to); - - if (rename (from, to) == 0) { - return TRUE; - } else { - CAMEL_LOG_WARNING ("ERROR: rename (%s, %s);\n", from, to); - CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", - errno, strerror(errno)); - return FALSE; - } -} - -static gboolean -_xunlink (const gchar *path) -{ - g_assert (path); - - if (unlink (path) == 0) { - return TRUE; - } else if (errno == ENOENT) { - return TRUE; - } else { - CAMEL_LOG_WARNING ("ERROR: unlink (%s);\n", path); - CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", - errno, strerror(errno)); - return FALSE; - } -} - -static gboolean -_xrmdir (const gchar *path) -{ - DIR *dir_handle; - struct dirent *dir_entry; - gchar *file; - struct stat statbuf; - g_assert (path); - - dir_handle = opendir (path); - if (!dir_handle && errno == ENOENT) { - return TRUE; - } else if (!dir_handle) { - CAMEL_LOG_WARNING ("ERROR: opendir (%s);\n", path); - CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", - errno, strerror(errno)); - return FALSE; - } - - while ((dir_entry = readdir (dir_handle))) { - file = g_strconcat (path, G_DIR_SEPARATOR_S, dir_entry->d_name, - NULL); - if (_xstat (file, &statbuf) && S_ISREG (statbuf.st_mode)) - _xunlink (file); - g_free (file); - } - - closedir (dir_handle); - - if (rmdir (path) == 0) { - return TRUE; - } else if (errno == ENOENT) { - return TRUE; - } else { - CAMEL_LOG_WARNING ("ERROR: rmdir (%s);\n", path); - CAMEL_LOG_FULL_DEBUG (" Full error text is: (%d) %s\n", - errno, strerror(errno)); - return FALSE; - } -} - -/** *** **/ - diff --git a/camel/providers/maildir/camel-maildir-folder.h b/camel/providers/maildir/camel-maildir-folder.h deleted file mode 100644 index 5997da2011..0000000000 --- a/camel/providers/maildir/camel-maildir-folder.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-maildir-folder.h : Abstract class for an email folder */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#ifndef CAMEL_MAILDIR_FOLDER_H -#define CAMEL_MAILDIR_FOLDER_H 1 - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include "camel-folder.h" -/* #include "camel-store.h" */ - -#define CAMEL_MAILDIR_FOLDER_TYPE (camel_maildir_folder_get_type ()) -#define CAMEL_MAILDIR_FOLDER(obj) (GTK_CHECK_CAST((obj), CAMEL_MAILDIR_FOLDER_TYPE, CamelMaildirFolder)) -#define CAMEL_MAILDIR_FOLDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MAILDIR_FOLDER_TYPE, CamelMaildirFolderClass)) -#define IS_CAMEL_MAILDIR_FOLDER(o) (GTK_CHECK_TYPE((o), CAMEL_MAILDIR_FOLDER_TYPE)) - - -typedef struct { - CamelFolder parent_object; - - gchar *directory_path; -} CamelMaildirFolder; - - - -typedef struct { - CamelFolderClass parent_class; - - /* Virtual methods */ - -} CamelMaildirFolderClass; - - -/* public methods */ - -/* Standard Gtk function */ -GtkType camel_maildir_folder_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MAILDIR_FOLDER_H */ diff --git a/camel/providers/maildir/camel-maildir-provider.c b/camel/providers/maildir/camel-maildir-provider.c deleted file mode 100644 index cd5521adc0..0000000000 --- a/camel/providers/maildir/camel-maildir-provider.c +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-maildir-provider.c: maildir provider registration code */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "config.h" -#include "camel-maildir-store.h" -#include "camel-provider.h" -#include "camel-log.h" - - -static CamelProvider _maildir_provider = { - (GtkType) 0, - PROVIDER_STORE, - "maildir", - "Maildir provider for Camel", - "This maildir provider is based on the default MH provider of Camel", - (GModule *) NULL -}; - - - -CamelProvider * -camel_provider_module_init () -{ - _maildir_provider.object_type = camel_maildir_store_get_type(); - return &_maildir_provider; -} diff --git a/camel/providers/maildir/camel-maildir-store.c b/camel/providers/maildir/camel-maildir-store.c deleted file mode 100644 index 8f37494003..0000000000 --- a/camel/providers/maildir/camel-maildir-store.c +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-maildir-store.c : class for an maildir store */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "camel-maildir-store.h" -#include "camel-maildir-folder.h" -#include "url-util.h" - -static CamelStoreClass *parent_class=NULL; - -/* Returns the class for a CamelMaildirStore */ -#define CMAILDIRS_CLASS(so) CAMEL_MAILDIR_STORE_CLASS (GTK_OBJECT(so)->klass) -#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass) -#define CMAILDIRF_CLASS(so) CAMEL_MAILDIR_FOLDER_CLASS (GTK_OBJECT(so)->klass) - -static void _init (CamelStore *store, CamelSession *session, - const gchar *url_name); -static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name); - -static void -camel_maildir_store_class_init ( - CamelMaildirStoreClass *camel_maildir_store_class) -{ - CamelStoreClass *camel_store_class = - CAMEL_STORE_CLASS (camel_maildir_store_class); - - parent_class = gtk_type_class (camel_store_get_type ()); - - /* virtual method definition */ - /* virtual method overload */ - camel_store_class->init = _init; - camel_store_class->get_folder = _get_folder; -} - -static void -camel_maildir_store_init (gpointer object, gpointer klass) -{ - CamelMaildirStore *maildir_store = CAMEL_MAILDIR_STORE (object); - CamelStore *store = CAMEL_STORE (object); - - store->separator = G_DIR_SEPARATOR; -} - -GtkType -camel_maildir_store_get_type (void) -{ - static GtkType camel_maildir_store_type = 0; - - if (!camel_maildir_store_type) { - GtkTypeInfo camel_maildir_store_info = - { - "CamelMaildirStore", - sizeof (CamelMaildirStore), - sizeof (CamelMaildirStoreClass), - (GtkClassInitFunc) camel_maildir_store_class_init, - (GtkObjectInitFunc) camel_maildir_store_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - camel_maildir_store_type = - gtk_type_unique (CAMEL_STORE_TYPE, - &camel_maildir_store_info); - } - - return camel_maildir_store_type; -} - -static void -_init (CamelStore *store, CamelSession *session, const gchar *url_name) -{ - CamelMaildirStore *maildir_store = CAMEL_MAILDIR_STORE (store); - Gurl *store_url; - g_assert (url_name); - - /* call parent implementation */ - parent_class->init (store, session, url_name); - - /* find the path in the URL*/ - store_url = g_url_new (url_name); - - g_return_if_fail (store_url); - g_return_if_fail (store_url->path); - - maildir_store->toplevel_dir = g_strdup (store_url->path); - - g_url_free (store_url); -} - -static CamelFolder * -_get_folder (CamelStore *store, const gchar *folder_name) -{ - CamelMaildirStore *maildir_store = CAMEL_MAILDIR_STORE (store); - CamelMaildirFolder *new_maildir_folder; - CamelFolder *new_folder; - - new_maildir_folder = gtk_type_new (CAMEL_MAILDIR_FOLDER_TYPE); - new_folder = CAMEL_FOLDER (new_maildir_folder); - - CF_CLASS (new_folder)->init_with_store (new_folder, store, NULL); - CF_CLASS (new_folder)->set_name (new_folder, folder_name, NULL); - - return new_folder; -} diff --git a/camel/providers/maildir/camel-maildir-store.h b/camel/providers/maildir/camel-maildir-store.h deleted file mode 100644 index 1a95ed1436..0000000000 --- a/camel/providers/maildir/camel-maildir-store.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-maildirstore.h : class for an maildir store */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef CAMEL_MAILDIR_STORE_H -#define CAMEL_MAILDIR_STORE_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtk/gtk.h> -#include "camel-store.h" - -#define CAMEL_MAILDIR_STORE_TYPE (camel_maildir_store_get_type ()) -#define CAMEL_MAILDIR_STORE(obj) (GTK_CHECK_CAST((obj), CAMEL_MAILDIR_STORE_TYPE, CamelMaildirStore)) -#define CAMEL_MAILDIR_STORE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_MAILDIR_STORE_TYPE, CamelMaildirStoreClass)) -#define IS_CAMEL_MAILDIR_STORE(o) (GTK_CHECK_TYPE((o), CAMEL_MAILDIR_STORE_TYPE)) - - -typedef struct { - CamelStore parent_object; - - gchar *toplevel_dir; -} CamelMaildirStore; - - - -typedef struct { - CamelStoreClass parent_class; - - -} CamelMaildirStoreClass; - - -/* public methods */ - -/* Standard Gtk function */ -GtkType camel_maildir_store_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_MAILDIR_STORE_H */ - - diff --git a/camel/string-utils.c b/camel/string-utils.c deleted file mode 100644 index e5d41ba215..0000000000 --- a/camel/string-utils.c +++ /dev/null @@ -1,256 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* string-util : utilities for gchar* strings */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - -#include <config.h> -#include "string-utils.h" -#include "camel-log.h" -#include "string.h" - - - -gboolean -string_equal_for_glist (gconstpointer v, gconstpointer v2) -{ - return (!strcmp ( ((const gchar *)v), ((const gchar*)v2))) == 0; -} - -/** - * string_dichotomy: - * @sep : separator - * @prefix: pointer to be field by the prefix object - * the prefix is not returned when the given pointer is NULL - * @suffix: pointer to be field by the suffix object - * the suffix is not returned when the given pointer is NULL - * - * Return the strings before and/or after - * the last occurence of the specified separator - * - * This routine returns the string before and/or after - * a character given as an argument. - * if the separator is the last character, prefix and/or - * suffix is set to NULL and result is set to 'l' - * if the separator is not in the list, prefix and/or - * suffix is set to NULL and result is set to 'n' - * When the operation succedeed, the return value is 'o' - * - * @Return Value : result of the operation ('o', 'l' or 'n') - * - **/ -gchar -string_dichotomy (const gchar *string, gchar sep, gchar **prefix, gchar **suffix, - StringDichotomyOption options) -{ - gchar *tmp_str; - gint sep_pos, first, last, len; - - g_assert (string); - CAMEL_LOG_FULL_DEBUG (\ - "string_dichotomy:: string=\"%s\"\n\tseparator=\"%c\" \n\tprefix=%p \n\tsuffix=%p \n\toptions=%ld\n",\ - string, sep, prefix, suffix, options); - len = strlen (string); - if (!len) { - if (prefix) - *prefix=NULL; - if (suffix) - *suffix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy:: input string is empty\n"); - return 'n'; - } - first = 0; - last = len-1; - - if ( (options & STRING_DICHOTOMY_STRIP_LEADING ) && (string[first] == sep) ) - do {first++;} while ( (first<len) && (string[first] == sep) ); - - if (options & STRING_DICHOTOMY_STRIP_TRAILING ) - while ((string[last] == sep) && (last>first)) - last--; - - if (first==last) { - if (prefix) *prefix=NULL; - if (suffix) *suffix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: after stripping, string is empty\n"); - return 'n'; - } - - if (options & STRING_DICHOTOMY_RIGHT_DIR) { - sep_pos = last; - while ((sep_pos>=first) && (string[sep_pos]!=sep)) { - sep_pos--; - } - } else { - sep_pos = first; - while ((sep_pos<=last) && (string[sep_pos]!=sep)) { - sep_pos++; - } - - } - - if ( (sep_pos<first) || (sep_pos>last) ) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: separator not found\n"); - return 'n'; - } - - /* if we have stripped trailing separators, we should */ - /* never enter here */ - if (sep_pos==last) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: separator is last character\n"); - return 'l'; - } - /* if we have stripped leading separators, we should */ - /* never enter here */ - if (sep_pos==first) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: separator is first character\n"); - return 'l'; - } - CAMEL_LOG_FULL_DEBUG ("string_dichotomy: separator found at :%d\n", sep_pos); - if (prefix) { /* return the prefix */ - *prefix = g_strndup (string+first,sep_pos-first); - CAMEL_LOG_FULL_DEBUG ( "string_dichotomy:: prefix:\"%s\"\n", *prefix); - } - if (suffix) { /* return the suffix */ - *suffix = g_strndup (string+sep_pos+1, last-sep_pos); - CAMEL_LOG_FULL_DEBUG ( "string_dichotomy:: suffix:\"%s\"\n", *suffix); - } - - return 'o'; -} - - - - - - -/* utility func : frees a gchar element in a GList */ -static void -__string_list_free_string (gpointer data, gpointer user_data) -{ - gchar *string = (gchar *)data; - g_free (string); -} - - -void -string_list_free (GList *string_list) -{ - if (string_list == NULL) return; - - g_list_foreach (string_list, __string_list_free_string, NULL); - g_list_free (string_list); -} - - - - - - -GList * -string_split (const gchar *string, char sep, const gchar *trim_chars, StringTrimOption trim_options) -{ - GList *result = NULL; - gint first, last, pos; - gchar *new_string; - - g_assert (string); - - first = 0; - last = strlen(string) - 1; - - /* strip leading and trailing separators */ - while ( (first<=last) && (string[first]==sep) ) - first++; - while ( (first<=last) && (string[last]==sep) ) - last--; - - - CAMEL_LOG_FULL_DEBUG ("string_split:: trim options: %d\n", trim_options); - - while (first<=last) { - pos = first; - /* find next separator */ - while ((pos<=last) && (string[pos]!=sep)) pos++; - if (first != pos) { - new_string = g_strndup (string+first, pos-first); - /* could do trimming in line to speed up this code */ - if (trim_chars) string_trim (new_string, trim_chars, trim_options); - result = g_list_append (result, new_string); - } - first = pos + 1; - } - - return result; -} - - -void -string_trim (gchar *string, const gchar *trim_chars, StringTrimOption options) -{ - gint first_ok; - gint last_ok; - guint length; - - CAMEL_LOG_FULL_DEBUG ("string-utils:: Entering string_trim::\n"); - CAMEL_LOG_FULL_DEBUG ("string_trim:: trim_chars:\"%s\"", trim_chars); - CAMEL_LOG_FULL_DEBUG ("string_trim:: trim_options:%d\n", options); - - g_return_if_fail (string); - length = strlen (string); - g_return_if_fail (length > 0); - - first_ok = 0; - last_ok = length - 1; - - if (options & STRING_TRIM_STRIP_LEADING) - while ( (first_ok <= last_ok) && (strchr (trim_chars, string[first_ok])!=NULL) ) - first_ok++; - - if (options & STRING_TRIM_STRIP_TRAILING) - while ( (first_ok <= last_ok) && (strchr (trim_chars, string[last_ok])!=NULL) ) - last_ok--; - CAMEL_LOG_FULL_DEBUG ("string_trim::\n\t\"%s\":first ok:%d last_ok:%d\n", - string, first_ok, last_ok); - - if (first_ok > 0) - memmove (string, string+first_ok, last_ok - first_ok +2); - -} - - - - - - diff --git a/camel/string-utils.h b/camel/string-utils.h deleted file mode 100644 index 34f73c367d..0000000000 --- a/camel/string-utils.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* string-util : utilities for normal gchar * strings */ - -/* - * - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - -#ifndef STRING_UTIL_H -#define STRING_UTIL_H 1 - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <glib.h> - -typedef enum { - STRING_DICHOTOMY_NONE = 0, - STRING_DICHOTOMY_RIGHT_DIR = 1, - STRING_DICHOTOMY_STRIP_TRAILING = 2, - STRING_DICHOTOMY_STRIP_LEADING = 4 - -} StringDichotomyOption; - -typedef enum { - STRING_TRIM_NONE = 0, - STRING_TRIM_STRIP_TRAILING = 1, - STRING_TRIM_STRIP_LEADING = 2 -} StringTrimOption; - -gboolean string_equal_for_glist (gconstpointer v, gconstpointer v2); - -gchar string_dichotomy (const gchar *string, gchar sep, - gchar **prefix, gchar **suffix, - StringDichotomyOption options); -void string_list_free (GList *string_list); - -GList *string_split (const gchar *string, char sep, - const gchar *trim_chars, StringTrimOption trim_options); -void string_trim (gchar *string, const gchar *chars, - StringTrimOption options); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* STRING_UTIL_H */ diff --git a/camel/url-util.c b/camel/url-util.c deleted file mode 100644 index 7fd63d7b6d..0000000000 --- a/camel/url-util.c +++ /dev/null @@ -1,418 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* url-util.c : utility functions to parse URLs */ - - -/* - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - -/* - Here we deal with URL following the general scheme: - protocol://user:password@host:port/name - where name is a path-like string (ie dir1/dir2/....) - See rfc1738 for the complete description of - Uniform Ressource Locators - - Bertrand. */ -/* - XXX TODO: recover the words between #'s or ?'s after the path */ - -#include <config.h> -#include "url-util.h" - -/* general item finder */ -/* it begins the search at position @position in @url, - returns true when the item is found, amd set position after the item */ -typedef gboolean find_item_func(const gchar *url, gchar **item, guint *position, gboolean *error); - -/* used to find one item (protocol, then user .... */ -typedef struct { - char *item_name; /* item name : for debug only */ - gchar **item_value; /* where the item value will go */ - find_item_func *find_func; /* item finder */ -} FindStepStruct; - -static gboolean _find_protocol (const gchar *url, gchar **item, guint *position, gboolean *error); -static gboolean _find_user (const gchar *url, gchar **item, guint *position, gboolean *error); -static gboolean _find_passwd (const gchar *url, gchar **item, guint *position, gboolean *error); -static gboolean _find_host (const gchar *url, gchar **item, guint *position, gboolean *error); -static gboolean _find_port (const gchar *url, gchar **item, guint *position, gboolean *error); -static gboolean _find_path (const gchar *url, gchar **item, guint *position, gboolean *error); - - - -/** - * g_url_new: create an Gurl object from a string - * - * @url_string: The string containing the URL to scan - * - * This routine takes a gchar and parses it as an - * URL of the form: - * protocol://user:password@host:port/path - * there is no test on the values. For example, - * "port" can be a string, not only a number ! - * The Gurl structure fields ar filled with - * the scan results. When a member of the - * general URL can not be found, the corresponding - * Gurl member is NULL - * Fields filled in the Gurl structure are allocated - * and url_string is not modified. - * - * Return value: a Gurl structure containing the URL items. - **/ -Gurl *g_url_new (const gchar* url_string) -{ - Gurl *g_url; - - gchar *protocol; - gchar *user; - gchar *passwd; - gchar *host; - gchar *port; - gchar *path; - - guint position = 0; - gboolean error; - gboolean found; - guint i; - - g_url = g_new (Gurl,1); - -#define NB_STEP_URL 6 - { - FindStepStruct step[NB_STEP_URL] = { - { "protocol", &(g_url->protocol), _find_protocol}, - { "user", &(g_url->user), _find_user}, - { "password", &(g_url->passwd), _find_passwd}, - { "host", &(g_url->host), _find_host}, - { "port", &(g_url->port), _find_port}, - { "path", &(g_url->path), _find_path} - }; - - for (i = 0; i < NB_STEP_URL; i++) { - found = step[i].find_func (url_string, - step[i].item_value, - &position, - &error); - } - } - - return g_url; -} - - - -void -g_url_free (Gurl *url) -{ - g_assert (url); - - g_free (url->protocol); - g_free (url->user); - g_free (url->passwd); - g_free (url->host); - g_free (url->port); - g_free (url->path); - - g_free (url); - -} - -/**** PARSING FUNCTIONS ****/ - -/* So, yes, I must admit there would have been more elegant - ways to do this, but it works, and quite well :) */ - - -static gboolean -_find_protocol (const gchar *url, gchar **item, guint *position, gboolean *error) -{ - - guint i; - gint len_url; - - g_assert (url); - g_assert (item); - g_assert (position); - - len_url = strlen (url); - - *item = NULL; - *error = FALSE; - i = *position; - - /* find a ':' */ - while ((i < len_url) && (url[i] != ':')) i++; - - if (i == len_url) return FALSE; - i++; - - /* check if it is followed by a "//" */ - if ((i < len_url) && (url[i++] == '/')) - if ((i < len_url) && (url[i++] == '/')) - { - *item = g_strndup (url, i-3); - *position = i; - return TRUE; - } - - return FALSE; -} - - - - -static gboolean -_find_user (const gchar *url, gchar **item, guint *position, gboolean *error) -{ - guint i; - guint at_pos; - gint len_url; - - g_assert (url); - g_assert (item); - g_assert (position); - - len_url = strlen (url); - *item = NULL; - i = *position; - - /* find a '@' */ - while ((i < len_url) && (url[i] != '@')) i++; - - if (i == len_url) return FALSE; - at_pos = i; - i = *position; - - /* find a ':' */ - while ((i < at_pos) && (url[i] != ':')) i++; - - /* now if i has not been incremented at all, there is no user */ - if (i == *position) { - (*position)++; - return FALSE; - } - - *item = g_strndup (url+ *position, i - *position); - if (i < at_pos) *position = i + 1; /* there was a ':', skip it */ - else *position = i; - - return TRUE; -} - -static gboolean -_find_passwd (const gchar *url, gchar **item, guint *position, gboolean *error) -{ - guint i; - gint len_url; - gchar *str_passwd; - - g_assert (url); - g_assert (item); - g_assert (position); - - len_url = strlen (url); - *item = NULL; - i = *position; - - /* find a '@' */ - while ((i < len_url) && (url[i] != '@')) i++; - - if (i == len_url) return FALSE; - /*i has not been incremented at all, there is no passwd */ - if (i == *position) { - *position = i + 1; - return FALSE; - } - - *item = g_strndup (url + *position, i - *position); - *position = i + 1; /* skip it the '@' */ - - return TRUE; -} - - - -static gboolean -_find_host (const gchar *url, gchar **item, guint *position, gboolean *error) -{ - guint i; - guint slash_pos; - gint len_url; - - g_assert (url); - g_assert (item); - g_assert (position); - - len_url = strlen (url); - *item = NULL; - i = *position; - - /* find a '/' */ - while ((i < len_url) && (url[i] != '/')) i++; - - slash_pos = i; - i = *position; - - /* find a ':' */ - while ( (i < slash_pos) && (url[i] != ':') ) i++; - - /* at this point if i has not been incremented at all, - there is no host */ - if (i == *position) { - /* if we have not met / or \0, we have : and must skip it */ - if (i < slash_pos) (*position)++; - return FALSE; - } - - *item = g_strndup (url + *position, i - *position); - if (i < slash_pos) *position = i + 1; /* there was a ':', skip it */ - else *position=i; - - return TRUE; -} - - -static gboolean -_find_port (const gchar *url, gchar **item, guint *position, gboolean *error) -{ - guint i; - guint slash_pos; - gint len_url; - - g_assert (url); - g_assert (item); - g_assert (position); - - len_url = strlen (url); - *item = NULL; - i=*position; - - /* find a '/' */ - while ((i < len_url) && (url[i] != '/')) i++; - - slash_pos = i; - i = *position; - - /* find a ':' */ - while ((i < slash_pos) && (url[i] != ':')) i++; - - /* at this point if i has not been incremented at all, */ - /* there is no port */ - if (i == *position) return FALSE; - - *item = g_strndup (url+ *position, i - *position); - *position = i; - return TRUE; -} - - -static gboolean -_find_path (const gchar *url, gchar **item, guint *position, gboolean *error) -{ - guint i; - gint len_url; - - g_assert (url); - g_assert (item); - g_assert (position); - - len_url = strlen (url); - *item = NULL; - i = *position; - - - /* find a '#' */ - while ((i < len_url) && (url[i] != '#') && (url[i] != '?')) i++; - - /*i has not been incremented at all, there is no path */ - if (i == *position) return FALSE; - - *item = g_strndup (url + *position, i - *position); - *position=i; - - return TRUE; -} - - - - - -/**** TEST ROUTINE - NOT COMPILED BY DEFAULT ****/ - -/* to tests this file : - gcc -o test_url_util `glib-config --cflags` -I.. -DTEST_URL_UTIL url-util.c `glib-config --libs` - ./test_url_util URL -*/ -#ifdef TEST_URL_UTIL - - - -int -main (int argc, char **argv) -{ - - gchar *url; - gchar *protocol; - gchar *user; - gchar *passwd; - gchar *host; - gchar *port; - gchar *path; - guint position=0; - gboolean error; - gboolean found; - guint i; - guint i_pos; - -#define NB_STEP_TEST 6 - FindStepStruct test_step[NB_STEP_TEST] = { - { "protocol", &protocol, _find_protocol}, - { "user", &user, _find_user}, - { "password", &passwd, _find_passwd}, - { "host", &host, _find_host}, - { "port", &port, _find_port}, - { "path", &path, _find_path} - }; - url = argv[1]; - printf("URL to test : %s\n\n", url); - for (i=0; i<NB_STEP_TEST; i++) { - found = test_step[i].find_func (url, - test_step[i].item_value, - &position, - &error); - if (found) { - printf ("\t\t\t\t** %s found : %s\n", - test_step[i].item_name, - *(test_step[i].item_value)); - } else printf ("** %s not found in URL\n", test_step[i].item_name); - printf ("next item position:\n"); - printf ("%s\n", url); - for (i_pos = 0; i_pos < position; i_pos++) printf (" "); - printf ("^\n"); - - } - -} - -#endif /* TEST_URL_UTIL */ diff --git a/camel/url-util.h b/camel/url-util.h deleted file mode 100644 index 239853bb61..0000000000 --- a/camel/url-util.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* url-util.h : utility functions to parse URLs */ - -/* - * Author : - * Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> - * - * Copyright 1999 International GNOME Support (http://www.gnome-support.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef URL_UTIL_H -#define URL_UTIL_H 1 - -#include <glib.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -typedef struct { - gchar *protocol; - gchar *user; - gchar *passwd; - gchar *host; - gchar *port; - gchar *path; - -} Gurl; - -/* the cache system has been disabled because it would - need the user to use accessors instead of modifying the - structure field. As the speed is not so important here, - I chose not to use it */ - -Gurl *g_url_new (const gchar *url_string); -void g_url_free (Gurl *url); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* URL_UTIL_H */ diff --git a/composer/.cvsignore b/composer/.cvsignore deleted file mode 100644 index 09980ae6ba..0000000000 --- a/composer/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la diff --git a/composer/ChangeLog b/composer/ChangeLog deleted file mode 100644 index 744d633eae..0000000000 --- a/composer/ChangeLog +++ /dev/null @@ -1,20 +0,0 @@ -1999-11-17 Ettore Perazzoli <ettore@gnu.org> - - * Makefile.am: New Makefile to compile the message composer - executable. - - * main.c: New file. - - * e-msg-composer-hdrs.c (e_msg_composer_hdrs_to_message): Use - `CAMEL_RECIPIENT*' macros instead of the old `RECIPIENT*' ones - that do not exist anymore. - - * e-msg-composer-address-dialog.c - (e_msg_composer_address_dialog_construct): Use `E_GLADEDIR' - instead of `E_GUIDIR'. - * e-msg-composer-attachment.c (e_msg_composer_attachment_edit): - Likewise. - * e-msg-composer.c (e_msg_composer_construct): Likewise. - -(See `$(top_srcdir)/widgets/ChangeLog' for previous changes to the -message composer.) diff --git a/composer/Makefile.am b/composer/Makefile.am deleted file mode 100644 index 6983084e12..0000000000 --- a/composer/Makefile.am +++ /dev/null @@ -1,45 +0,0 @@ -gladedir = $(datadir)/evolution/glade - -glade_DATA = \ - e-msg-composer-address-dialog.glade \ - e-msg-composer-attachment.glade \ - e-msg-composer.glade - -INCLUDES = \ - -I$(top_srcdir)/camel \ - -I$(top_builddir)/camel \ - $(GNOME_INCLUDEDIR) - -CPPFLAGS = \ - -DE_GLADEDIR=\"$(gladedir)\" - -bin_PROGRAMS = \ - evolution-msg-composer - -evolution_msg_composer_SOURCES = \ - e-msg-composer-address-dialog.c \ - e-msg-composer-address-dialog.h \ - e-msg-composer-address-entry.c \ - e-msg-composer-address-entry.h \ - e-msg-composer-attachment-bar.c \ - e-msg-composer-attachment-bar.h \ - e-msg-composer-attachment.c \ - e-msg-composer-attachment.h \ - e-msg-composer-hdrs.c \ - e-msg-composer-hdrs.h \ - e-msg-composer.c \ - e-msg-composer.h \ - main.c - -evolution_msg_composer_LDADD = \ - $(top_builddir)/camel/libcamel.la \ - $(GNOME_LIBDIR) \ - $(GNOMEUI_LIBS) \ - $(INTLLIBS) \ - $(PTHREAD_LIB) \ - $(EXTRA_GNOME_LIBS) - - -EXTRA_DIST = \ - $(glade_DATA) \ - ChangeLog diff --git a/composer/e-msg-composer-address-dialog.c b/composer/e-msg-composer-address-dialog.c deleted file mode 100644 index 42a594756d..0000000000 --- a/composer/e-msg-composer-address-dialog.c +++ /dev/null @@ -1,660 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-msg-composer-address-dialog.c - * - * Copyright (C) 1999 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#include <gnome.h> -#include "e-msg-composer-address-dialog.h" - - -enum { - APPLY, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - -static GnomeDialogClass *parent_class = NULL; - - -/* This function should load the addresses we know of into the dialog. We - don't have a precise setup for the addressbook yet, so we will just put some - fake entries in. */ -static void -load_addresses (EMsgComposerAddressDialog *dialog) -{ - gchar *text[][3] = { - { "Bertrand Guiheneuf", "Bertrand.Guiheneuf@aful.org", NULL }, - { "Ettore Perazzoli", "ettore@gnu.org", NULL }, - { "Miguel de Icaza", "miguel@gnu.org", NULL }, - { "Nat Friedman", "nat@nat.org", NULL }, - { NULL, NULL, NULL } - }; - GtkCList *clist; - guint i; - - clist = GTK_CLIST (glade_xml_get_widget (dialog->gui, "address_clist")); - - for (i = 0; text[i][0] != NULL; i++) - gtk_clist_append (clist, text[i]); -} - -/* Combine name and email into an address, e.g. "Ettore Perazzoli - <ettore@gnu.org>". FIXME FIXME FIXME this does not handle quoting (commas - will cause troubles), but it should. */ -static gchar * -make_full_address (const gchar *name, - const gchar *email) -{ - return g_strconcat (name, " <", email, ">", NULL); -} - -/* This loads the selected address in the address GtkCList into the requested - GtkList. */ -static void -add_address (EMsgComposerAddressDialog *dialog, - const gchar *list_name) -{ - GtkCList *src_clist; - GtkCList *dest_clist; - gchar *name, *email; - gchar *text[2]; - guint row; - - src_clist = GTK_CLIST (glade_xml_get_widget (dialog->gui, - "address_clist")); - if (src_clist->selection == NULL) - return; - - dest_clist = GTK_CLIST (glade_xml_get_widget (dialog->gui, list_name)); - row = GPOINTER_TO_INT (src_clist->selection->data); - - gtk_clist_get_text (src_clist, row, 0, &name); - gtk_clist_get_text (src_clist, row, 1, &email); - - text[0] = make_full_address (name, email); - text[1] = NULL; - - gtk_clist_append (dest_clist, text); - - g_free (text[0]); -} - -static void -apply (EMsgComposerAddressDialog *dialog) -{ - gtk_signal_emit (GTK_OBJECT (dialog), signals[APPLY]); -} - - -/* Recipient list popup menu. */ - -struct _RecipientListInfo { - EMsgComposerAddressDialog *dialog; - GtkCList *clist; - gint row; /* -1 if menu was popped up in an empty - area. */ -}; -typedef struct _RecipientListInfo RecipientListInfo; - -static void -copy_recipient (RecipientListInfo *info, - gboolean remove) -{ - gchar *text; - gint row; - - if (info->clist->selection == NULL) - return; - - row = GPOINTER_TO_INT (info->clist->selection->data); - gtk_clist_get_text (info->clist, row, 0, &text); - - g_free (info->dialog->cut_buffer); - info->dialog->cut_buffer = g_strdup (text); - - if (remove) - gtk_clist_remove (info->clist, row); - - gtk_selection_owner_set (GTK_WIDGET (info->clist), - GDK_SELECTION_PRIMARY, - GDK_CURRENT_TIME); -} - -static void -copy_recipient_cb (GtkWidget *widget, - gpointer data) -{ - RecipientListInfo *info; - - info = (RecipientListInfo *) data; - copy_recipient (info, FALSE); - g_free (info); -} - -static void -cut_recipient_cb (GtkWidget *widget, - gpointer data) -{ - RecipientListInfo *info; - - info = (RecipientListInfo *) data; - copy_recipient (info, TRUE); - g_free (info); -} - -static void -paste_recipient_cb (GtkWidget *widget, - gpointer data) -{ - RecipientListInfo *info; - GdkAtom atom; - gchar *text[2]; - - info = (RecipientListInfo *) data; - - atom = gdk_atom_intern ("STRING", FALSE); - gtk_selection_convert (GTK_WIDGET (info->clist), - GDK_SELECTION_PRIMARY, - atom, - GDK_CURRENT_TIME); - - g_free (info); -} - -static GnomeUIInfo recipient_list_item_popup_info[] = { - GNOMEUIINFO_ITEM_STOCK (N_("Cut"), - N_("Cut selected item into clipboard"), - cut_recipient_cb, - GNOME_STOCK_MENU_CUT), - GNOMEUIINFO_ITEM_STOCK (N_("Copy"), - N_("Copy selected item into clipboard"), - copy_recipient_cb, - GNOME_STOCK_MENU_COPY), - GNOMEUIINFO_ITEM_STOCK (N_("Paste"), - N_("Paste item from clipboard"), - paste_recipient_cb, - GNOME_STOCK_MENU_PASTE), - GNOMEUIINFO_END -}; - -static GnomeUIInfo recipient_list_popup_info[] = { - GNOMEUIINFO_ITEM_STOCK (N_("Paste"), - N_("Paste item from clipboard"), - paste_recipient_cb, - GNOME_STOCK_MENU_PASTE), - GNOMEUIINFO_END -}; - - -/* Signals. */ - -static void -add_to_cb (GtkWidget *widget, - gpointer data) -{ - add_address (E_MSG_COMPOSER_ADDRESS_DIALOG (data), "to_clist"); -} - -static void -add_cc_cb (GtkWidget *widget, - gpointer data) -{ - add_address (E_MSG_COMPOSER_ADDRESS_DIALOG (data), "cc_clist"); -} - -static void -add_bcc_cb (GtkWidget *widget, - gpointer data) -{ - add_address (E_MSG_COMPOSER_ADDRESS_DIALOG (data), "bcc_clist"); -} - -static void -glade_connect (GladeXML *gui, - const gchar *widget_name, - const gchar *signal_name, - GtkSignalFunc callback, - gpointer callback_data) -{ - GtkWidget *widget; - - widget = glade_xml_get_widget (gui, widget_name); - if (widget == NULL) - g_warning ("Widget `%s' was not found.", widget_name); - else - gtk_signal_connect (GTK_OBJECT (widget), signal_name, - GTK_SIGNAL_FUNC (callback), callback_data); -} - -static gint -recipient_clist_button_press_cb (GtkWidget *widget, - GdkEventButton *event, - gpointer data) -{ - EMsgComposerAddressDialog *dialog; - RecipientListInfo *info; - GtkWidget *popup; - GtkCList *clist; - gboolean on_row; - gint row, column; - - dialog = E_MSG_COMPOSER_ADDRESS_DIALOG (data); - - clist = GTK_CLIST (widget); - - if (event->window != clist->clist_window || event->button != 3) - return FALSE; - - on_row = gtk_clist_get_selection_info (clist, event->x, event->y, - &row, &column); - - info = g_new (RecipientListInfo, 1); - info->dialog = dialog; - info->clist = clist; - - if (on_row) { - gtk_clist_unselect_all (clist); - gtk_clist_select_row (clist, row, 0); - info->row = row; - popup = gnome_popup_menu_new (recipient_list_item_popup_info); - } else { - info->row = -1; - popup = gnome_popup_menu_new (recipient_list_popup_info); - } - - gnome_popup_menu_do_popup_modal (popup, NULL, NULL, event, info); - - gtk_widget_destroy (popup); - - return TRUE; -} - -/* FIXME needs more work. */ -static void -recipient_clist_selection_received_cb (GtkWidget *widget, - GtkSelectionData *selection_data, - guint time, - gpointer data) -{ - GtkCList *clist; - gchar *text[2]; - gchar *p; - - puts (__FUNCTION__); - - if (selection_data->length < 0) - return; - - clist = GTK_CLIST (widget); - - /* FIXME quoting. */ - text[0] = g_strdup (selection_data->data); - text[1] = NULL; - - /* It is a common mistake to paste `\n's, let's work around that. */ - for (p = text[0]; *p != '\0'; p++) { - if (*p == '\n') { - *p = '\0'; - break; - } - } - - if (clist->selection != NULL) { - gint row; - - row = GPOINTER_TO_INT (clist->selection->data); - gtk_clist_insert (clist, row, text); - } else { - gtk_clist_append (clist, text); - } - - g_free (text[0]); -} - -static void -recipient_clist_selection_get_cb (GtkWidget *widget, - GtkSelectionData *selection_data, - guint info, - guint time, - gpointer data) -{ - EMsgComposerAddressDialog *dialog; - GdkAtom atom; - - puts (__FUNCTION__); - - dialog = E_MSG_COMPOSER_ADDRESS_DIALOG (data); - if (dialog->cut_buffer == NULL) - return; /* FIXME should I do something special? */ - - atom = gdk_atom_intern ("STRING", FALSE); - gtk_selection_data_set (selection_data, atom, 8, - dialog->cut_buffer, - strlen (dialog->cut_buffer)); -} - -static void -recipient_clist_selection_clear_event_cb (GtkWidget *widget, - GdkEventSelection *selection, - gpointer data) -{ - EMsgComposerAddressDialog *dialog; - - dialog = E_MSG_COMPOSER_ADDRESS_DIALOG (data); - g_free (dialog->cut_buffer); - dialog->cut_buffer = NULL; -} - -static void -setup_recipient_list_signals (EMsgComposerAddressDialog *dialog, - const gchar *name) -{ - glade_connect (dialog->gui, name, "button_press_event", - GTK_SIGNAL_FUNC (recipient_clist_button_press_cb), - dialog); - glade_connect (dialog->gui, name, "selection_received", - GTK_SIGNAL_FUNC (recipient_clist_selection_received_cb), - dialog); - glade_connect (dialog->gui, name, "selection_get", - GTK_SIGNAL_FUNC (recipient_clist_selection_get_cb), - dialog); - glade_connect (dialog->gui, name, "selection_clear_event", - GTK_SIGNAL_FUNC (recipient_clist_selection_clear_event_cb), - dialog); -} - -static void -setup_signals (EMsgComposerAddressDialog *dialog) -{ - glade_connect (dialog->gui, "to_add_button", "clicked", - GTK_SIGNAL_FUNC (add_to_cb), dialog); - glade_connect (dialog->gui, "cc_add_button", "clicked", - GTK_SIGNAL_FUNC (add_cc_cb), dialog); - glade_connect (dialog->gui, "bcc_add_button", "clicked", - GTK_SIGNAL_FUNC (add_bcc_cb), dialog); - - setup_recipient_list_signals (dialog, "to_clist"); - setup_recipient_list_signals (dialog, "cc_clist"); - setup_recipient_list_signals (dialog, "bcc_clist"); -} - - -static void -setup_selection_targets (EMsgComposerAddressDialog *dialog) -{ - gtk_selection_add_target (glade_xml_get_widget (dialog->gui, "to_clist"), - GDK_SELECTION_PRIMARY, - GDK_SELECTION_TYPE_STRING, 0); - gtk_selection_add_target (glade_xml_get_widget (dialog->gui, "cc_clist"), - GDK_SELECTION_PRIMARY, - GDK_SELECTION_TYPE_STRING, 0); - gtk_selection_add_target (glade_xml_get_widget (dialog->gui, "bcc_clist"), - GDK_SELECTION_PRIMARY, - GDK_SELECTION_TYPE_STRING, 0); -} - - -/* GnomeDialog methods. */ - -static void -clicked (GnomeDialog *dialog, - gint button_number) -{ - switch (button_number) { - case 0: /* OK */ - apply (E_MSG_COMPOSER_ADDRESS_DIALOG (dialog)); - gnome_dialog_close (dialog); - break; - case 1: /* Apply */ - apply (E_MSG_COMPOSER_ADDRESS_DIALOG (dialog)); - break; - case 2: /* Cancel */ - gnome_dialog_close (dialog); - break; - } -} - - -/* GtkObject methods. */ - -static void -destroy (GtkObject *object) -{ - EMsgComposerAddressDialog *dialog; - GtkCList *address_clist; - GList *p; - - dialog = E_MSG_COMPOSER_ADDRESS_DIALOG (object); - - gtk_object_unref (GTK_OBJECT (dialog->gui)); - g_free (dialog->cut_buffer); - - if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -/* Initialization. */ - -static void -class_init (EMsgComposerAddressDialogClass *class) -{ - GtkObjectClass *object_class; - GnomeDialogClass *gnome_dialog_class; - - object_class = GTK_OBJECT_CLASS (class); - object_class->destroy = destroy; - - gnome_dialog_class = GNOME_DIALOG_CLASS (class); - gnome_dialog_class->clicked = clicked; - - parent_class = gtk_type_class (gnome_dialog_get_type ()); - - signals[APPLY] - = gtk_signal_new ("apply", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EMsgComposerAddressDialogClass, - apply), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -init (EMsgComposerAddressDialog *dialog) -{ - dialog->gui = NULL; - dialog->cut_buffer = NULL; -} - - -GtkType -e_msg_composer_address_dialog_get_type (void) -{ - static GtkType type = 0; - - if (type == 0) { - static const GtkTypeInfo info = { - "EMsgComposerAddressDialog", - sizeof (EMsgComposerAddressDialog), - sizeof (EMsgComposerAddressDialogClass), - (GtkClassInitFunc) class_init, - (GtkObjectInitFunc) init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (gnome_dialog_get_type (), &info); - } - - return type; -} - -void -e_msg_composer_address_dialog_construct (EMsgComposerAddressDialog *dialog) -{ - static const gchar *buttons[] = { - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_APPLY, - GNOME_STOCK_BUTTON_CANCEL, - NULL - }; - - g_return_if_fail (dialog != NULL); - g_return_if_fail (E_IS_MSG_COMPOSER_ADDRESS_DIALOG (dialog)); - - gnome_dialog_constructv (GNOME_DIALOG (dialog), - _("Select recipients' addresses"), - buttons); - - dialog->gui = glade_xml_new - (E_GLADEDIR "/e-msg-composer-address-dialog.glade", - "main_table"); - if (dialog->gui == NULL) { - g_warning ("Cannot load `e-msg-composer-address-dialog.glade"); - return; - } - - gtk_container_add (GTK_CONTAINER (GNOME_DIALOG (dialog)->vbox), - glade_xml_get_widget (dialog->gui, "main_table")); - - setup_selection_targets (dialog); - load_addresses (dialog); - setup_signals (dialog); -} - -GtkWidget * -e_msg_composer_address_dialog_new (void) -{ - EMsgComposerAddressDialog *new; - - new = gtk_type_new (e_msg_composer_address_dialog_get_type ()); - e_msg_composer_address_dialog_construct (new); - - return GTK_WIDGET (new); -} - - -static void -set_list (EMsgComposerAddressDialog *dialog, - const gchar *list_name, - GList *list) -{ - GtkCList *clist; - GList *p; - gchar *text[2]; - - clist = GTK_CLIST (glade_xml_get_widget (dialog->gui, list_name)); - - gtk_clist_freeze (clist); - gtk_clist_clear (clist); - - text[1] = NULL; - for (p = list; p != NULL; p = p->next) { - text[0] = (gchar *) p->data; - gtk_clist_append (clist, text); - } - - gtk_clist_thaw (clist); -} - -void -e_msg_composer_address_dialog_set_to_list (EMsgComposerAddressDialog *dialog, - GList *to_list) -{ - g_return_if_fail (dialog != NULL); - g_return_if_fail (E_IS_MSG_COMPOSER_ADDRESS_DIALOG (dialog)); - - set_list (dialog, "to_clist", to_list); -} - -void -e_msg_composer_address_dialog_set_cc_list (EMsgComposerAddressDialog *dialog, - GList *cc_list) -{ - g_return_if_fail (dialog != NULL); - g_return_if_fail (E_IS_MSG_COMPOSER_ADDRESS_DIALOG (dialog)); - - set_list (dialog, "cc_clist", cc_list); -} - -void -e_msg_composer_address_dialog_set_bcc_list (EMsgComposerAddressDialog *dialog, - GList *bcc_list) -{ - g_return_if_fail (dialog != NULL); - g_return_if_fail (E_IS_MSG_COMPOSER_ADDRESS_DIALOG (dialog)); - - set_list (dialog, "bcc_clist", bcc_list); -} - - -static GList * -get_list (EMsgComposerAddressDialog *dialog, - const gchar *clist_name) -{ - GtkCList *address_clist; - GtkCList *clist; - GList *list; - guint i; - - clist = GTK_CLIST (glade_xml_get_widget (dialog->gui, clist_name)); - - list = NULL; - for (i = 0; i < clist->rows; i++) { - gchar *addr; - - gtk_clist_get_text (clist, i, 0, &addr); - list = g_list_prepend (list, g_strdup (addr)); - } - - return g_list_reverse (list); -} - -GList * -e_msg_composer_address_dialog_get_to_list (EMsgComposerAddressDialog *dialog) -{ - g_return_val_if_fail (dialog != NULL, NULL); - g_return_val_if_fail (E_IS_MSG_COMPOSER_ADDRESS_DIALOG (dialog), NULL); - - return get_list (dialog, "to_clist"); -} - -GList * -e_msg_composer_address_dialog_get_cc_list (EMsgComposerAddressDialog *dialog) -{ - g_return_val_if_fail (dialog != NULL, NULL); - g_return_val_if_fail (E_IS_MSG_COMPOSER_ADDRESS_DIALOG (dialog), NULL); - - return get_list (dialog, "cc_clist"); -} - -GList * -e_msg_composer_address_dialog_get_bcc_list (EMsgComposerAddressDialog *dialog) -{ - g_return_val_if_fail (dialog != NULL, NULL); - g_return_val_if_fail (E_IS_MSG_COMPOSER_ADDRESS_DIALOG (dialog), NULL); - - return get_list (dialog, "bcc_clist"); -} diff --git a/composer/e-msg-composer-address-dialog.glade b/composer/e-msg-composer-address-dialog.glade deleted file mode 100644 index 2249c27daf..0000000000 --- a/composer/e-msg-composer-address-dialog.glade +++ /dev/null @@ -1,575 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>address-composer</name> - <program_name>address-composer</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <use_widget_names>False</use_widget_names> - <output_main_file>True</output_main_file> - <output_support_files>True</output_support_files> - <output_build_files>True</output_build_files> - <backup_source_files>True</backup_source_files> - <main_source_file>interface.c</main_source_file> - <main_header_file>interface.h</main_header_file> - <handler_source_file>callbacks.c</handler_source_file> - <handler_header_file>callbacks.h</handler_header_file> - <support_source_file>support.c</support_source_file> - <support_header_file>support.h</support_header_file> - <translatable_strings_file></translatable_strings_file> -</project> - -<widget> - <class>GnomeDialog</class> - <name>dialog1</name> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>False</allow_grow> - <auto_shrink>False</auto_shrink> - <auto_close>False</auto_close> - <hide_on_close>False</hide_on_close> - - <widget> - <class>GtkVBox</class> - <child_name>GnomeDialog:vbox</child_name> - <name>dialog-vbox1</name> - <homogeneous>False</homogeneous> - <spacing>8</spacing> - <child> - <padding>4</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>main_table</name> - <rows>3</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>0</row_spacing> - <column_spacing>2</column_spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label3</name> - <label></label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label1</name> - <label>Recipient list:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>True</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox1</name> - <homogeneous>False</homogeneous> - <spacing>5</spacing> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label2</name> - <label>Name:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>name_entry</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <padding>5</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>search_button</name> - <width>65</width> - <can_focus>True</can_focus> - <label>Search...</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow1</name> - <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>5</ypad> - <xexpand>True</xexpand> - <yexpand>True</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkCList</class> - <name>address_clist</name> - <width>180</width> - <height>200</height> - <can_focus>True</can_focus> - <columns>2</columns> - <column_widths>128,107</column_widths> - <selection_mode>GTK_SELECTION_BROWSE</selection_mode> - <show_titles>True</show_titles> - <shadow_type>GTK_SHADOW_IN</shadow_type> - - <widget> - <class>GtkLabel</class> - <child_name>CList:title</child_name> - <name>label5</name> - <width>50</width> - <label>Name</label> - <justify>GTK_JUSTIFY_LEFT</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>CList:title</child_name> - <name>label6</name> - <width>100</width> - <label>Address</label> - <justify>GTK_JUSTIFY_LEFT</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox2</name> - <homogeneous>True</homogeneous> - <spacing>10</spacing> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkButton</class> - <name>button5</name> - <can_focus>True</can_focus> - <label>Properties...</label> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button6</name> - <can_focus>True</can_focus> - <label>Add...</label> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkTable</class> - <name>table2</name> - <rows>3</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>0</row_spacing> - <column_spacing>0</column_spacing> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>5</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkButton</class> - <name>to_add_button</name> - <width>60</width> - <can_focus>True</can_focus> - <label>To: >></label> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>5</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>True</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>cc_add_button</name> - <width>60</width> - <can_focus>True</can_focus> - <label>Cc: >></label> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>5</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>True</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>bcc_add_button</name> - <width>60</width> - <can_focus>True</can_focus> - <label>Bcc: >></label> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>5</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>True</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow4</name> - <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>2</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>True</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkCList</class> - <name>bcc_clist</name> - <width>180</width> - <height>100</height> - <can_focus>True</can_focus> - <columns>1</columns> - <column_widths>80</column_widths> - <selection_mode>GTK_SELECTION_BROWSE</selection_mode> - <show_titles>False</show_titles> - <shadow_type>GTK_SHADOW_IN</shadow_type> - - <widget> - <class>GtkLabel</class> - <child_name>CList:title</child_name> - <name>label9</name> - <label>label9</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> - - <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow2</name> - <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>2</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>True</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkCList</class> - <name>to_clist</name> - <width>180</width> - <height>100</height> - <can_focus>True</can_focus> - <columns>1</columns> - <column_widths>80</column_widths> - <selection_mode>GTK_SELECTION_BROWSE</selection_mode> - <show_titles>False</show_titles> - <shadow_type>GTK_SHADOW_IN</shadow_type> - - <widget> - <class>GtkLabel</class> - <child_name>CList:title</child_name> - <name>label7</name> - <label>label7</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> - - <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow3</name> - <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>2</xpad> - <ypad>4</ypad> - <xexpand>True</xexpand> - <yexpand>True</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkCList</class> - <name>cc_clist</name> - <width>180</width> - <height>100</height> - <can_focus>True</can_focus> - <columns>1</columns> - <column_widths>80</column_widths> - <selection_mode>GTK_SELECTION_BROWSE</selection_mode> - <show_titles>False</show_titles> - <shadow_type>GTK_SHADOW_IN</shadow_type> - - <widget> - <class>GtkLabel</class> - <child_name>CList:title</child_name> - <name>label8</name> - <label>label8</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHButtonBox</class> - <child_name>GnomeDialog:action_area</child_name> - <name>dialog-action_area1</name> - <layout_style>GTK_BUTTONBOX_END</layout_style> - <spacing>8</spacing> - <child_min_width>85</child_min_width> - <child_min_height>27</child_min_height> - <child_ipad_x>7</child_ipad_x> - <child_ipad_y>0</child_ipad_y> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - <pack>GTK_PACK_END</pack> - </child> - - <widget> - <class>GtkButton</class> - <name>button1</name> - <can_default>True</can_default> - <has_default>True</has_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> - </widget> - - <widget> - <class>GtkButton</class> - <name>button2</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button> - </widget> - - <widget> - <class>GtkButton</class> - <name>button3</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/composer/e-msg-composer-address-dialog.h b/composer/e-msg-composer-address-dialog.h deleted file mode 100644 index 19ffeda703..0000000000 --- a/composer/e-msg-composer-address-dialog.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-msg-composer-address-dialog.h - * - * Copyright (C) 1999 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ -#ifndef __E_MSG_COMPOSER_ADDRESS_DIALOG_H__ -#define __E_MSG_COMPOSER_ADDRESS_DIALOG_H__ - -#include <gnome.h> -#include <glade/glade-xml.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - - -#define E_TYPE_MSG_COMPOSER_ADDRESS_DIALOG (e_msg_composer_address_dialog_get_type ()) -#define E_MSG_COMPOSER_ADDRESS_DIALOG(obj) (GTK_CHECK_CAST ((obj), E_TYPE_MSG_COMPOSER_ADDRESS_DIALOG, EMsgComposerAddressDialog)) -#define E_MSG_COMPOSER_ADDRESS_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_MSG_COMPOSER_ADDRESS_DIALOG, EMsgComposerAddressDialogClass)) -#define E_IS_MSG_COMPOSER_ADDRESS_DIALOG(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_MSG_COMPOSER_ADDRESS_DIALOG)) -#define E_IS_MSG_COMPOSER_ADDRESS_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_MSG_COMPOSER_ADDRESS_DIALOG)) - - -typedef struct _EMsgComposerAddressDialog EMsgComposerAddressDialog; -typedef struct _EMsgComposerAddressDialogClass EMsgComposerAddressDialogClass; - -struct _EMsgComposerAddressDialog { - GnomeDialog parent; - - GladeXML *gui; - - gchar *cut_buffer; -}; - -struct _EMsgComposerAddressDialogClass { - GnomeDialogClass parent_class; - - void (* apply) (EMsgComposerAddressDialog *dialog); -}; - - -GtkType e_msg_composer_address_dialog_get_type (void); -GtkWidget *e_msg_composer_address_dialog_new (void); -void e_msg_composer_address_dialog_construct (EMsgComposerAddressDialog *dialog); -void e_msg_composer_address_dialog_set_to_list (EMsgComposerAddressDialog *dialog, GList *to_list); -void e_msg_composer_address_dialog_set_cc_list (EMsgComposerAddressDialog *dialog, GList *cc_list); -void e_msg_composer_address_dialog_set_bcc_list (EMsgComposerAddressDialog *dialog, GList *bcc_list); -GList *e_msg_composer_address_dialog_get_to_list (EMsgComposerAddressDialog *dialog); -GList *e_msg_composer_address_dialog_get_cc_list (EMsgComposerAddressDialog *dialog); -GList *e_msg_composer_address_dialog_get_bcc_list (EMsgComposerAddressDialog *dialog); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_MSG_COMPOSER_ADDRESS_DIALOG_H__ */ diff --git a/composer/e-msg-composer-address-entry.c b/composer/e-msg-composer-address-entry.c deleted file mode 100644 index be63c815f5..0000000000 --- a/composer/e-msg-composer-address-entry.c +++ /dev/null @@ -1,175 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-msg-composer-address-entry.c - * - * Copyright (C) 1999 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -/* This is a custom GtkEntry for entering address lists. For now, it does not - have any fancy features, but in the future we might want to make it - cooler. */ - -#include <gnome.h> - -#include "e-msg-composer-address-entry.h" - - -static GtkEntryClass *parent_class = NULL; - - -/* Initialization. */ - -static void -class_init (EMsgComposerAddressEntryClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) klass; - - parent_class = gtk_type_class (gtk_entry_get_type ()); -} - -static void -init (EMsgComposerAddressEntry *msg_composer_address_entry) -{ -} - -GtkType -e_msg_composer_address_entry_get_type (void) -{ - static GtkType type = 0; - - if (type == 0) { - static const GtkTypeInfo info = { - "EMsgComposerAddressEntry", - sizeof (EMsgComposerAddressEntry), - sizeof (EMsgComposerAddressEntryClass), - (GtkClassInitFunc) class_init, - (GtkObjectInitFunc) init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (gtk_entry_get_type (), &info); - } - - return type; -} - - -GtkWidget * -e_msg_composer_address_entry_new (void) -{ - GtkWidget *new; - - new = gtk_type_new (e_msg_composer_address_entry_get_type ()); - - return new; -} - - -/** - * e_msg_composer_address_entry_get_addresses: - * @entry: An address entry widget - * - * Retrieve the list of addresses stored in @entry. - * - * Return value: A GList of pointers to strings representing the addresses. - * Notice that the strings must be freed by the caller when not needed anymore. - **/ -GList * -e_msg_composer_address_entry_get_addresses (EMsgComposerAddressEntry *entry) -{ - GList *list; - const gchar *s; - const gchar *p, *oldp; - gboolean in_quotes; - - s = gtk_entry_get_text (GTK_ENTRY (entry)); - - in_quotes = FALSE; - list = NULL; - - p = s; - oldp = s; - - while (1) { - if (*p == '"') { - in_quotes = ! in_quotes; - p++; - } else if ((! in_quotes && *p == ',') || *p == 0) { - if (p != oldp) { - gchar *new_addr; - - new_addr = g_strndup (oldp, p - oldp); - new_addr = g_strstrip (new_addr); - if (*new_addr != '\0') - list = g_list_prepend (list, new_addr); - else - g_free (new_addr); - } - - while (*p == ',' || *p == ' ' || *p == '\t') - p++; - - if (*p == 0) - break; - - oldp = p; - } else { - p++; - } - } - - return g_list_reverse (list); -} - -/** - * e_msg_composer_address_entry_set_list: - * @entry: An address entry - * @list: List of pointers to strings representing the addresses that must - * appear in the entry - * - * Set the address list from @list. - **/ -void -e_msg_composer_address_entry_set_list (EMsgComposerAddressEntry *entry, - GList *list) -{ - GString *string; - GList *p; - - g_return_if_fail (entry != NULL); - - if (list == NULL) { - gtk_editable_delete_text (GTK_EDITABLE (entry), -1, -1); - return; - } - - string = g_string_new (NULL); - for (p = list; p != NULL; p = p->next) { - if (string->str[0] != '\0') - g_string_append (string, ", "); - g_string_append (string, p->data); - } - - gtk_entry_set_text (GTK_ENTRY (entry), string->str); - g_string_free (string, TRUE); -} diff --git a/composer/e-msg-composer-address-entry.h b/composer/e-msg-composer-address-entry.h deleted file mode 100644 index 8e926272e4..0000000000 --- a/composer/e-msg-composer-address-entry.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-msg-composer-address-entry.h - * - * Copyright (C) 1999 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef __E_MSG_COMPOSER_ADDRESS_ENTRY_H__ -#define __E_MSG_COMPOSER_ADDRESS_ENTRY_H__ - -#include <gnome.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_MSG_COMPOSER_ADDRESS_ENTRY (e_msg_composer_address_entry_get_type ()) -#define E_MSG_COMPOSER_ADDRESS_ENTRY(obj) (GTK_CHECK_CAST ((obj), E_TYPE_MSG_COMPOSER_ADDRESS_ENTRY, EMsgComposerAddressEntry)) -#define E_MSG_COMPOSER_ADDRESS_ENTRY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_MSG_COMPOSER_ADDRESS_ENTRY, EMsgComposerAddressEntryClass)) -#define E_IS_MSG_COMPOSER_ADDRESS_ENTRY(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_MSG_COMPOSER_ADDRESS_ENTRY)) -#define E_IS_MSG_COMPOSER_ADDRESS_ENTRY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_MSG_COMPOSER_ADDRESS_ENTRY)) - - -typedef struct _EMsgComposerAddressEntry EMsgComposerAddressEntry; -typedef struct _EMsgComposerAddressEntryClass EMsgComposerAddressEntryClass; - -struct _EMsgComposerAddressEntry { - GtkEntry parent; -}; - -struct _EMsgComposerAddressEntryClass { - GtkEntryClass parent_class; -}; - - -GtkType e_msg_composer_address_entry_get_type (void); -GtkWidget *e_msg_composer_address_entry_new (void); -GList *e_msg_composer_address_entry_get_addresses (EMsgComposerAddressEntry *entry); -void e_msg_composer_address_entry_set_list (EMsgComposerAddressEntry *entry, - GList *list); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_MSG_COMPOSER_ADDRESS_ENTRY_H__ */ diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c deleted file mode 100644 index b55a4cbad4..0000000000 --- a/composer/e-msg-composer-attachment-bar.c +++ /dev/null @@ -1,665 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-msg-composer-attachment-bar.c - * - * Copyright (C) 1999 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#include <gnome.h> -#include <glade/glade.h> - -#include "e-msg-composer-attachment.h" -#include "e-msg-composer-attachment-bar.h" - - -#define ICON_WIDTH 64 -#define ICON_SEPARATORS " /-_" -#define ICON_SPACING 2 -#define ICON_ROW_SPACING ICON_SPACING -#define ICON_COL_SPACING ICON_SPACING -#define ICON_BORDER 2 -#define ICON_TEXT_SPACING 2 - - -static GnomeIconListClass *parent_class = NULL; - -struct _EMsgComposerAttachmentBarPrivate { - GList *attachments; - guint num_attachments; - - GtkWidget *context_menu; - GtkWidget *icon_context_menu; -}; - - -enum { - CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - - -static void update (EMsgComposerAttachmentBar *bar); - - -static gchar * -size_to_string (gulong size) -{ - gchar *size_string; - - /* FIXME: The following should probably go into a separate module, as - we might have to do the same thing in other places as well. Also, - I am not sure this will be OK for all the languages. */ - - if (size < 1e3L) { - if (size == 1) - size_string = g_strdup (_("1 byte")); - else - size_string = g_strdup_printf (_("%u bytes"), - (guint) size); - } else { - gdouble displayed_size; - - if (size < 1e6L) { - displayed_size = (gdouble) size / 1.0e3; - size_string = g_strdup_printf (_("%.1fK"), - displayed_size); - } else if (size < 1e9L) { - displayed_size = (gdouble) size / 1.0e6; - size_string = g_strdup_printf (_("%.1fM"), - displayed_size); - } else { - displayed_size = (gdouble) size / 1.0e9; - size_string = g_strdup_printf (_("%.1fG"), - displayed_size); - } - } - - return size_string; -} - - -/* Sorting. */ - -static gint -attachment_sort_func (gconstpointer a, gconstpointer b) -{ - const EMsgComposerAttachment *attachment_a, *attachment_b; - - attachment_a = (EMsgComposerAttachment *) a; - attachment_b = (EMsgComposerAttachment *) b; - - return strcmp (attachment_a->description, attachment_b->description); -} - -static void -sort (EMsgComposerAttachmentBar *bar) -{ - EMsgComposerAttachmentBarPrivate *priv; - - priv = bar->priv; - - priv->attachments = g_list_sort (priv->attachments, - attachment_sort_func); -} - - -/* Attachment handling functions. */ - -static void -free_attachment_list (EMsgComposerAttachmentBar *bar) -{ - EMsgComposerAttachmentBarPrivate *priv; - GList *p; - - priv = bar->priv; - - for (p = priv->attachments; p != NULL; p = p->next) - gtk_object_unref (GTK_OBJECT (p->data)); -} - -static void -attachment_changed_cb (EMsgComposerAttachment *attachment, - gpointer data) -{ - update (E_MSG_COMPOSER_ATTACHMENT_BAR (data)); -} - -static void -add_from_file (EMsgComposerAttachmentBar *bar, - const gchar *file_name) -{ - EMsgComposerAttachment *attachment; - - attachment = e_msg_composer_attachment_new (file_name); - - gtk_signal_connect (GTK_OBJECT (attachment), "changed", - GTK_SIGNAL_FUNC (attachment_changed_cb), - bar); - - bar->priv->attachments = g_list_append (bar->priv->attachments, - attachment); - bar->priv->num_attachments++; - - sort (bar); - update (bar); - - gtk_signal_emit (GTK_OBJECT (bar), signals[CHANGED]); -} - -static void -remove_attachment (EMsgComposerAttachmentBar *bar, - EMsgComposerAttachment *attachment) -{ - bar->priv->attachments = g_list_remove (bar->priv->attachments, - attachment); - bar->priv->num_attachments--; - - gtk_object_unref (GTK_OBJECT (attachment)); - - gtk_signal_emit (GTK_OBJECT (bar), signals[CHANGED]); -} - - -/* Icon list contents handling. */ - -static void -update (EMsgComposerAttachmentBar *bar) -{ - EMsgComposerAttachmentBarPrivate *priv; - GnomeIconList *icon_list; - GList *p; - - priv = bar->priv; - icon_list = GNOME_ICON_LIST (bar); - - gnome_icon_list_freeze (icon_list); - - gnome_icon_list_clear (icon_list); - - /* FIXME could be faster, but we don't care. */ - - for (p = priv->attachments; p != NULL; p = p->next) { - EMsgComposerAttachment *attachment; - const gchar *icon_name; - gchar *size_string; - gchar *label; - - attachment = p->data; - icon_name = gnome_mime_get_value (attachment->mime_type, - "icon-filename"); - - /* FIXME we need some better default icon. */ - if (icon_name == NULL) - icon_name = gnome_mime_get_value ("text/plain", - "icon-filename"); - - size_string = size_to_string (attachment->size); - - /* FIXME: If GnomeIconList honoured "\n", the result would be a - lot better. */ - label = g_strconcat (attachment->description, "\n(", - size_string, ")", NULL); - - gnome_icon_list_append (icon_list, icon_name, label); - - g_free (label); - g_free (size_string); - } - - gnome_icon_list_thaw (icon_list); -} - -static void -remove_selected (EMsgComposerAttachmentBar *bar) -{ - GnomeIconList *icon_list; - EMsgComposerAttachment *attachment; - GList *attachment_list; - GList *p; - gint num; - - icon_list = GNOME_ICON_LIST (bar); - - /* Weee! I am especially proud of this piece of cheesy code: it is - truly awful. But unless one attaches a huge number of files, it - will not be as greedy as intended. FIXME of course. */ - - attachment_list = NULL; - for (p = icon_list->selection; p != NULL; p = p->next) { - num = GPOINTER_TO_INT (p->data); - attachment = E_MSG_COMPOSER_ATTACHMENT - (g_list_nth (bar->priv->attachments, num)->data); - attachment_list = g_list_prepend (attachment_list, attachment); - } - - for (p = attachment_list; p != NULL; p = p->next) - remove_attachment (bar, E_MSG_COMPOSER_ATTACHMENT (p->data)); - - g_list_free (attachment_list); - - update (bar); -} - -static void -edit_selected (EMsgComposerAttachmentBar *bar) -{ - GnomeIconList *icon_list; - EMsgComposerAttachment *attachment; - gint num; - - icon_list = GNOME_ICON_LIST (bar); - - num = GPOINTER_TO_INT (icon_list->selection->data); - attachment = g_list_nth (bar->priv->attachments, num)->data; - - e_msg_composer_attachment_edit (attachment, GTK_WIDGET (bar)); -} - - -/* "Attach" dialog. */ - -static void -attach_cb (GtkWidget *widget, - gpointer data) -{ - EMsgComposerAttachmentBar *bar; - GtkWidget *file_selection; - const gchar *file_name; - - file_selection = gtk_widget_get_toplevel (widget); - bar = E_MSG_COMPOSER_ATTACHMENT_BAR (data); - - file_name = gtk_file_selection_get_filename - (GTK_FILE_SELECTION (file_selection)); - add_from_file (bar, file_name); - - gtk_widget_hide (file_selection); -} - -static void -add_from_user (EMsgComposerAttachmentBar *bar) -{ - GtkWidget *file_selection; - GtkWidget *cancel_button; - GtkWidget *ok_button; - - file_selection = gtk_file_selection_new (_("Add attachment")); - gtk_window_set_position (GTK_WINDOW (file_selection), - GTK_WIN_POS_MOUSE); - - ok_button = GTK_FILE_SELECTION (file_selection)->ok_button; - gtk_signal_connect (GTK_OBJECT (ok_button), - "clicked", GTK_SIGNAL_FUNC (attach_cb), bar); - - cancel_button = GTK_FILE_SELECTION (file_selection)->cancel_button; - gtk_signal_connect_object (GTK_OBJECT (cancel_button), - "clicked", - GTK_SIGNAL_FUNC (gtk_widget_hide), - GTK_OBJECT (file_selection)); - - gtk_widget_show (GTK_WIDGET (file_selection)); -} - - -/* Callbacks. */ - -static void -add_cb (GtkWidget *widget, - gpointer data) -{ - g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (data)); - - add_from_user (E_MSG_COMPOSER_ATTACHMENT_BAR (data)); -} - -static void -properties_cb (GtkWidget *widget, - gpointer data) -{ - EMsgComposerAttachmentBar *bar; - - g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (data)); - - bar = E_MSG_COMPOSER_ATTACHMENT_BAR (data); - edit_selected (data); -} - -static void -remove_cb (GtkWidget *widget, - gpointer data) -{ - EMsgComposerAttachmentBar *bar; - - g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (data)); - - bar = E_MSG_COMPOSER_ATTACHMENT_BAR (data); - remove_selected (bar); -} - - -/* Popup menu handling. */ - -static GnomeUIInfo icon_context_menu_info[] = { - GNOMEUIINFO_ITEM (N_("Remove"), - N_("Remove selected items from the attachment list"), - remove_cb, NULL), - GNOMEUIINFO_MENU_PROPERTIES_ITEM (properties_cb, NULL), - GNOMEUIINFO_END -}; - -static GtkWidget * -get_icon_context_menu (EMsgComposerAttachmentBar *bar) -{ - EMsgComposerAttachmentBarPrivate *priv; - - priv = bar->priv; - if (priv->icon_context_menu == NULL) - priv->icon_context_menu = gnome_popup_menu_new - (icon_context_menu_info); - - return priv->icon_context_menu; -} - -static void -popup_icon_context_menu (EMsgComposerAttachmentBar *bar, - gint num, - GdkEventButton *event) -{ - GtkWidget *menu; - - menu = get_icon_context_menu (bar); - gnome_popup_menu_do_popup (menu, NULL, NULL, event, bar); -} - -static GnomeUIInfo context_menu_info[] = { - GNOMEUIINFO_ITEM (N_("Add attachment..."), - N_("Attach a file to the message"), - add_cb, NULL), - GNOMEUIINFO_END -}; - -static GtkWidget * -get_context_menu (EMsgComposerAttachmentBar *bar) -{ - EMsgComposerAttachmentBarPrivate *priv; - - priv = bar->priv; - if (priv->context_menu == NULL) - priv->context_menu = gnome_popup_menu_new (context_menu_info); - - return priv->context_menu; -} - -static void -popup_context_menu (EMsgComposerAttachmentBar *bar, - GdkEventButton *event) -{ - GtkWidget *menu; - - menu = get_context_menu (bar); - gnome_popup_menu_do_popup (menu, NULL, NULL, event, bar); -} - - -/* GtkObject methods. */ - -static void -destroy (GtkObject *object) -{ - EMsgComposerAttachmentBar *bar; - - bar = E_MSG_COMPOSER_ATTACHMENT_BAR (object); - - free_attachment_list (bar); - - if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -/* GtkWidget methods. */ - -static gint -button_press_event (GtkWidget *widget, - GdkEventButton *event) -{ - EMsgComposerAttachmentBar *bar; - GnomeIconList *icon_list; - gint icon_number; - - bar = E_MSG_COMPOSER_ATTACHMENT_BAR (widget); - icon_list = GNOME_ICON_LIST (widget); - - if (event->button != 3) - return GTK_WIDGET_CLASS (parent_class)->button_press_event - (widget, event); - - icon_number = gnome_icon_list_get_icon_at (icon_list, - event->x, event->y); - - if (icon_number >= 0) { - gnome_icon_list_select_icon (icon_list, icon_number); - popup_icon_context_menu (bar, icon_number, event); - } else { - popup_context_menu (bar, event); - } - - return TRUE; -} - - -/* GnomeIconList methods. */ - -static gboolean -text_changed (GnomeIconList *gil, - gint num, - const gchar *new_text) -{ - EMsgComposerAttachmentBar *bar; - EMsgComposerAttachment *attachment; - GList *p; - - bar = E_MSG_COMPOSER_ATTACHMENT_BAR (gil); - p = g_list_nth (bar->priv->attachments, num); - attachment = p->data; - - g_free (attachment->description); - attachment->description = g_strdup (new_text); - - return TRUE; -} - - -/* Initialization. */ - -static void -class_init (EMsgComposerAttachmentBarClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GnomeIconListClass *icon_list_class; - - object_class = GTK_OBJECT_CLASS (class); - widget_class = GTK_WIDGET_CLASS (class); - icon_list_class = GNOME_ICON_LIST_CLASS (class); - - parent_class = gtk_type_class (gnome_icon_list_get_type ()); - - object_class->destroy = destroy; - - widget_class->button_press_event = button_press_event; - - icon_list_class->text_changed = text_changed; - - /* Setup signals. */ - - signals[CHANGED] = - gtk_signal_new ("changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EMsgComposerAttachmentBarClass, - changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -init (EMsgComposerAttachmentBar *bar) -{ - EMsgComposerAttachmentBarPrivate *priv; - guint icon_size; - - priv = g_new (EMsgComposerAttachmentBarPrivate, 1); - - priv->attachments = NULL; - priv->context_menu = NULL; - priv->icon_context_menu = NULL; - - priv->num_attachments = 0; - - bar->priv = priv; - - /* FIXME partly hardcoded. We should compute height from the font, and - allow at least 2 lines for every item. */ - icon_size = ICON_WIDTH + ICON_SPACING + ICON_BORDER + ICON_TEXT_SPACING; - icon_size += 24; - - gtk_widget_set_usize (GTK_WIDGET (bar), icon_size * 4, icon_size); -} - - -GtkType -e_msg_composer_attachment_bar_get_type (void) -{ - static GtkType type = 0; - - if (type == 0) { - static const GtkTypeInfo info = { - "EMsgComposerAttachmentBar", - sizeof (EMsgComposerAttachmentBar), - sizeof (EMsgComposerAttachmentBarClass), - (GtkClassInitFunc) class_init, - (GtkObjectInitFunc) init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (gnome_icon_list_get_type (), &info); - } - - return type; -} - -GtkWidget * -e_msg_composer_attachment_bar_new (GtkAdjustment *adj) -{ - EMsgComposerAttachmentBar *new; - GnomeIconList *icon_list; - - gtk_widget_push_visual (gdk_imlib_get_visual ()); - gtk_widget_push_colormap (gdk_imlib_get_colormap ()); - new = gtk_type_new (e_msg_composer_attachment_bar_get_type ()); - gtk_widget_pop_visual (); - gtk_widget_pop_colormap (); - - icon_list = GNOME_ICON_LIST (new); - - gnome_icon_list_construct (icon_list, ICON_WIDTH, adj, 0); - - gnome_icon_list_set_separators (icon_list, ICON_SEPARATORS); - gnome_icon_list_set_row_spacing (icon_list, ICON_ROW_SPACING); - gnome_icon_list_set_col_spacing (icon_list, ICON_COL_SPACING); - gnome_icon_list_set_icon_border (icon_list, ICON_BORDER); - gnome_icon_list_set_text_spacing (icon_list, ICON_TEXT_SPACING); - gnome_icon_list_set_selection_mode (icon_list, GTK_SELECTION_MULTIPLE); - - return GTK_WIDGET (new); -} - - -static void -attach_to_multipart (CamelMultipart *multipart, - EMsgComposerAttachment *attachment) -{ - CamelMimeBodyPart *part; - - /* FIXME encoding etc. etc. ? */ - /* FIXME I am not sure how to add an attachment through the Camel - API. :-/ */ - - part = camel_mime_body_part_new (); - camel_mime_part_set_disposition (CAMEL_MIME_PART (part), "attachment"); - camel_mime_part_set_filename (CAMEL_MIME_PART (part), - g_strdup (g_basename (attachment->file_name))); - camel_mime_part_set_description (CAMEL_MIME_PART (part), - g_strdup (attachment->description)); - camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (part), - g_strdup (attachment->mime_type)); -} - -void -e_msg_composer_attachment_bar_to_multipart (EMsgComposerAttachmentBar *bar, - CamelMultipart *multipart) -{ - EMsgComposerAttachmentBarPrivate *priv; - GList *p; - - g_return_if_fail (bar != NULL); - g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar)); - g_return_if_fail (multipart != NULL); - g_return_if_fail (CAMEL_IS_MULTIPART (multipart)); - - priv = bar->priv; - - for (p = priv->attachments; p != NULL; p = p->next) { - EMsgComposerAttachment *attachment; - - attachment = E_MSG_COMPOSER_ATTACHMENT (p->data); - attach_to_multipart (multipart, attachment); - } -} - - -guint -e_msg_composer_attachment_bar_get_num_attachments (EMsgComposerAttachmentBar *bar) -{ - g_return_val_if_fail (bar != NULL, 0); - g_return_val_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar), 0); - - return bar->priv->num_attachments; -} - - -void -e_msg_composer_attachment_bar_attach (EMsgComposerAttachmentBar *bar, - const gchar *file_name) -{ - g_return_if_fail (bar != NULL); - g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar)); - - if (file_name == NULL) - add_from_user (bar); - else - add_from_file (bar, file_name); -} diff --git a/composer/e-msg-composer-attachment-bar.h b/composer/e-msg-composer-attachment-bar.h deleted file mode 100644 index 803b51a954..0000000000 --- a/composer/e-msg-composer-attachment-bar.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* msg-composer-attachment-bar.h - * - * Copyright (C) 1999 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef __E_MSG_COMPOSER_ATTACHMENT_BAR_H__ -#define __E_MSG_COMPOSER_ATTACHMENT_BAR_H__ - -#include <gnome.h> -#include <camel/camel-multipart.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_MSG_COMPOSER_ATTACHMENT_BAR \ - (e_msg_composer_attachment_bar_get_type ()) -#define E_MSG_COMPOSER_ATTACHMENT_BAR(obj) \ - (GTK_CHECK_CAST ((obj), E_TYPE_MSG_COMPOSER_ATTACHMENT_BAR, EMsgComposerAttachmentBar)) -#define E_MSG_COMPOSER_ATTACHMENT_BAR_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_MSG_COMPOSER_ATTACHMENT_BAR, EMsgComposerAttachmentBarClass)) -#define E_IS_MSG_COMPOSER_ATTACHMENT_BAR(obj) \ - (GTK_CHECK_TYPE ((obj), E_TYPE_MSG_COMPOSER_ATTACHMENT_BAR)) -#define E_IS_MSG_COMPOSER_ATTACHMENT_BAR_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_MSG_COMPOSER_ATTACHMENT_BAR)) - - -typedef struct _EMsgComposerAttachmentBarPrivate EMsgComposerAttachmentBarPrivate; - -struct _EMsgComposerAttachmentBar { - GnomeIconList parent; - - EMsgComposerAttachmentBarPrivate *priv; -}; -typedef struct _EMsgComposerAttachmentBar EMsgComposerAttachmentBar; - -struct _EMsgComposerAttachmentBarClass { - GnomeIconListClass parent_class; - - void (* changed) (EMsgComposerAttachmentBar *bar); -}; -typedef struct _EMsgComposerAttachmentBarClass EMsgComposerAttachmentBarClass; - - -GtkType e_msg_composer_attachment_bar_get_type (void); -GtkWidget *e_msg_composer_attachment_bar_new (GtkAdjustment *adj); -void e_msg_composer_attachment_bar_to_multipart (EMsgComposerAttachmentBar *bar, CamelMultipart *multipart); -guint e_msg_composer_attachment_bar_get_num_attachments (EMsgComposerAttachmentBar *bar); -void e_msg_composer_attachment_bar_attach (EMsgComposerAttachmentBar *bar, const gchar *file_name); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_MSG_COMPOSER_ATTACHMENT_BAR_H__ */ diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c deleted file mode 100644 index f4741d987f..0000000000 --- a/composer/e-msg-composer-attachment.c +++ /dev/null @@ -1,480 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-msg-composer-attachment.c - * - * Copyright (C) 1999 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -/* This is the object representing an email attachment. It is implemented as a - GtkObject to make it easier for the application to handle it. For example, - the "changed" signal is emitted whenever something changes in the - attachment. Also, this contains the code to let users edit the - attachment manually. */ - -#include <sys/stat.h> - -#include <gnome.h> - -#include "e-msg-composer-attachment.h" - - -enum { - CHANGED, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - -static GtkObjectClass *parent_class = NULL; - - -/* Utility functions. */ - -static const gchar * -get_mime_type (const gchar *file_name) -{ - const gchar *mime_type; - - mime_type = gnome_mime_type_of_file (file_name); - if (mime_type == NULL) - mime_type = "application/octet-stream"; - - return mime_type; -} - -static void -init_mime_type (EMsgComposerAttachment *attachment) -{ - attachment->mime_type = g_strdup (get_mime_type (attachment->file_name)); -} - -static void -set_mime_type (EMsgComposerAttachment *attachment) -{ - g_free (attachment->mime_type); - init_mime_type (attachment); -} - -static void -changed (EMsgComposerAttachment *attachment) -{ - gtk_signal_emit (GTK_OBJECT (attachment), signals[CHANGED]); -} - - -/* GtkObject methods. */ - -static void -destroy (GtkObject *object) -{ - EMsgComposerAttachment *attachment; - - attachment = E_MSG_COMPOSER_ATTACHMENT (object); - - g_free (attachment->file_name); - g_free (attachment->description); - g_free (attachment->mime_type); -} - - -/* Signals. */ - -static void -real_changed (EMsgComposerAttachment *msg_composer_attachment) -{ - g_return_if_fail (msg_composer_attachment != NULL); - g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT (msg_composer_attachment)); -} - - -static void -class_init (EMsgComposerAttachmentClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) klass; - - parent_class = gtk_type_class (gtk_object_get_type ()); - - object_class->destroy = destroy; - - signals[CHANGED] = gtk_signal_new ("changed", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET - (EMsgComposerAttachmentClass, - changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); - - klass->changed = real_changed; -} - -static void -init (EMsgComposerAttachment *msg_composer_attachment) -{ - msg_composer_attachment->editor_gui = NULL; - msg_composer_attachment->file_name = NULL; - msg_composer_attachment->description = NULL; - msg_composer_attachment->mime_type = NULL; - msg_composer_attachment->size = 0; -} - -GtkType -e_msg_composer_attachment_get_type (void) -{ - static GtkType type = 0; - - if (type == 0) { - static const GtkTypeInfo info = { - "EMsgComposerAttachment", - sizeof (EMsgComposerAttachment), - sizeof (EMsgComposerAttachmentClass), - (GtkClassInitFunc) class_init, - (GtkObjectInitFunc) init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - - -/** - * e_msg_composer_attachment_new: - * @file_name: - * - * Return value: - **/ -EMsgComposerAttachment * -e_msg_composer_attachment_new (const gchar *file_name) -{ - EMsgComposerAttachment *new; - struct stat statbuf; - - g_return_val_if_fail (file_name != NULL, NULL); - - new = gtk_type_new (e_msg_composer_attachment_get_type ()); - - new->editor_gui = NULL; - - new->file_name = g_strdup (file_name); - new->description = g_strdup (g_basename (new->file_name)); - - if (stat (file_name, &statbuf) < 0) - new->size = 0; - else - new->size = statbuf.st_size; - - init_mime_type (new); - - return new; -} - - -/* The attachment property dialog. */ - -struct _DialogData { - GtkWidget *dialog; - GtkEntry *file_name_entry; - GtkEntry *description_entry; - GtkEntry *mime_type_entry; - GtkWidget *browse_widget; - EMsgComposerAttachment *attachment; -}; -typedef struct _DialogData DialogData; - -static void -destroy_dialog_data (DialogData *data) -{ - if (data->browse_widget != NULL) - gtk_widget_destroy (data->browse_widget); - g_free (data); -} - -static void -update_mime_type (DialogData *data) -{ - const gchar *mime_type; - const gchar *file_name; - - file_name = gtk_entry_get_text (data->file_name_entry); - mime_type = get_mime_type (file_name); - - gtk_entry_set_text (data->mime_type_entry, mime_type); -} - -static void -browse_ok_cb (GtkWidget *widget, - gpointer data) -{ - GtkWidget *file_selection; - DialogData *dialog_data; - const gchar *file_name; - - dialog_data = (DialogData *) data; - file_selection = gtk_widget_get_toplevel (widget); - - file_name = gtk_file_selection_get_filename - (GTK_FILE_SELECTION (file_selection)); - - gtk_entry_set_text (dialog_data->file_name_entry, file_name); - - update_mime_type (dialog_data); - - gtk_widget_hide (file_selection); -} - -static void -browse (DialogData *data) -{ - if (data->browse_widget == NULL) { - GtkWidget *file_selection; - GtkWidget *cancel_button; - GtkWidget *ok_button; - - file_selection - = gtk_file_selection_new (_("Select attachment")); - gtk_window_set_position (GTK_WINDOW (file_selection), - GTK_WIN_POS_MOUSE); - gtk_window_set_transient_for (GTK_WINDOW (file_selection), - GTK_WINDOW (data->dialog)); - - ok_button = GTK_FILE_SELECTION (file_selection)->ok_button; - gtk_signal_connect (GTK_OBJECT (ok_button), - "clicked", GTK_SIGNAL_FUNC (browse_ok_cb), - data); - - cancel_button - = GTK_FILE_SELECTION (file_selection)->cancel_button; - gtk_signal_connect_object (GTK_OBJECT (cancel_button), - "clicked", - GTK_SIGNAL_FUNC (gtk_widget_hide), - GTK_OBJECT (file_selection)); - - data->browse_widget = file_selection; - } - - gtk_widget_show (GTK_WIDGET (data->browse_widget)); -} - -static void -set_entry (GladeXML *xml, - const gchar *widget_name, - const gchar *value) -{ - GtkEntry *entry; - - entry = GTK_ENTRY (glade_xml_get_widget (xml, widget_name)); - if (entry == NULL) - g_warning ("Entry for `%s' not found.", widget_name); - gtk_entry_set_text (entry, value); -} - -static void -connect_entry_changed (GladeXML *gui, - const gchar *name, - GtkSignalFunc func, - gpointer data) -{ - GtkWidget *widget; - - widget = glade_xml_get_widget (gui, name); - gtk_signal_connect (GTK_OBJECT (widget), "changed", func, data); -} - -static void -connect_widget (GladeXML *gui, - const gchar *name, - const gchar *signal_name, - GtkSignalFunc func, - gpointer data) -{ - GtkWidget *widget; - - widget = glade_xml_get_widget (gui, name); - gtk_signal_connect (GTK_OBJECT (widget), signal_name, func, data); -} - -static void -apply (DialogData *data) -{ - EMsgComposerAttachment *attachment; - - attachment = data->attachment; - - g_free (attachment->file_name); - attachment->file_name = g_strdup (gtk_entry_get_text - (data->file_name_entry)); - - g_free (attachment->description); - attachment->description = g_strdup (gtk_entry_get_text - (data->description_entry)); - - g_free (attachment->mime_type); - attachment->mime_type = g_strdup (gtk_entry_get_text - (data->mime_type_entry)); - - changed (attachment); -} - -static void -entry_changed_cb (GtkWidget *widget, gpointer data) -{ - DialogData *dialog_data; - GladeXML *gui; - GtkWidget *apply_button; - - dialog_data = (DialogData *) data; - gui = dialog_data->attachment->editor_gui; - - apply_button = glade_xml_get_widget (gui, "apply_button"); - gtk_widget_set_sensitive (apply_button, TRUE); -} - -static void -close_cb (GtkWidget *widget, - gpointer data) -{ - EMsgComposerAttachment *attachment; - DialogData *dialog_data; - - dialog_data = (DialogData *) data; - attachment = dialog_data->attachment; - - gtk_widget_destroy (glade_xml_get_widget (attachment->editor_gui, - "dialog")); - gtk_object_unref (GTK_OBJECT (attachment->editor_gui)); - attachment->editor_gui = NULL; - - destroy_dialog_data (dialog_data); -} - -static void -apply_cb (GtkWidget *widget, - gpointer data) -{ - DialogData *dialog_data; - - dialog_data = (DialogData *) data; - apply (dialog_data); -} - -static void -ok_cb (GtkWidget *widget, - gpointer data) -{ - apply_cb (widget, data); - close_cb (widget, data); -} - -static void -browse_cb (GtkWidget *widget, - gpointer data) -{ - DialogData *dialog_data; - - dialog_data = (DialogData *) data; - browse (dialog_data); -} - -static void -file_name_focus_out_cb (GtkWidget *widget, - GdkEventFocus *event, - gpointer data) -{ - DialogData *dialog_data; - - dialog_data = (DialogData *) data; - update_mime_type (dialog_data); -} - - -void -e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment, - GtkWidget *parent) -{ - DialogData *dialog_data; - GladeXML *editor_gui; - - g_return_if_fail (attachment != NULL); - g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT (attachment)); - - if (attachment->editor_gui != NULL) { - GtkWidget *window; - - window = glade_xml_get_widget (attachment->editor_gui, - "dialog"); - gdk_window_show (window->window); - return; - } - - editor_gui = glade_xml_new (E_GLADEDIR "/e-msg-composer-attachment.glade", - NULL); - if (editor_gui == NULL) { - g_warning ("Cannot load `e-msg-composer-attachment.glade'"); - return; - } - - attachment->editor_gui = editor_gui; - - gtk_window_set_transient_for - (GTK_WINDOW (glade_xml_get_widget (editor_gui, "dialog")), - GTK_WINDOW (gtk_widget_get_toplevel (parent))); - - dialog_data = g_new (DialogData, 1); - dialog_data->browse_widget = NULL; - dialog_data->attachment = attachment; - dialog_data->dialog = glade_xml_get_widget (editor_gui, "dialog"); - dialog_data->file_name_entry = GTK_ENTRY (glade_xml_get_widget - (editor_gui, - "file_name_entry")); - dialog_data->description_entry = GTK_ENTRY (glade_xml_get_widget - (editor_gui, - "description_entry")); - dialog_data->mime_type_entry = GTK_ENTRY (glade_xml_get_widget - (editor_gui, - "mime_type_entry")); - - if (attachment != NULL) { - set_entry (editor_gui, "file_name_entry", attachment->file_name); - set_entry (editor_gui, "description_entry", attachment->description); - set_entry (editor_gui, "mime_type_entry", attachment->mime_type); - } - - connect_entry_changed (editor_gui, "file_name_entry", - entry_changed_cb, dialog_data); - connect_entry_changed (editor_gui, "description_entry", - entry_changed_cb, dialog_data); - - connect_widget (editor_gui, "ok_button", "clicked", ok_cb, dialog_data); - connect_widget (editor_gui, "apply_button", "clicked", apply_cb, dialog_data); - connect_widget (editor_gui, "close_button", "clicked", close_cb, dialog_data); - - connect_widget (editor_gui, "browse_button", "clicked", browse_cb, dialog_data); - - connect_widget (editor_gui, "file_name_entry", "focus_out_event", - file_name_focus_out_cb, dialog_data); -} diff --git a/composer/e-msg-composer-attachment.glade b/composer/e-msg-composer-attachment.glade deleted file mode 100644 index 72c0132639..0000000000 --- a/composer/e-msg-composer-attachment.glade +++ /dev/null @@ -1,290 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>e-msg-composer-attachment</name> - <program_name>e-msg-composer-attachment</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <use_widget_names>False</use_widget_names> - <output_main_file>True</output_main_file> - <output_support_files>True</output_support_files> - <output_build_files>True</output_build_files> - <backup_source_files>True</backup_source_files> - <main_source_file>interface.c</main_source_file> - <main_header_file>interface.h</main_header_file> - <handler_source_file>callbacks.c</handler_source_file> - <handler_header_file>callbacks.h</handler_header_file> - <support_source_file>support.c</support_source_file> - <support_header_file>support.h</support_header_file> - <translatable_strings_file></translatable_strings_file> -</project> - -<widget> - <class>GnomeDialog</class> - <name>dialog</name> - <title>Attachment properties</title> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>False</allow_grow> - <auto_shrink>False</auto_shrink> - <auto_close>False</auto_close> - <hide_on_close>False</hide_on_close> - - <widget> - <class>GtkVBox</class> - <child_name>GnomeDialog:vbox</child_name> - <name>dialog-vbox1</name> - <homogeneous>False</homogeneous> - <spacing>8</spacing> - <child> - <padding>4</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>table1</name> - <rows>3</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>10</row_spacing> - <column_spacing>5</column_spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label1</name> - <label>Description:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label3</name> - <label>MIME type:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>description_entry</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label2</name> - <label>File name:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox3</name> - <homogeneous>False</homogeneous> - <spacing>10</spacing> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>True</yexpand> - <xshrink>True</xshrink> - <yshrink>True</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkEntry</class> - <name>file_name_entry</name> - <width>290</width> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>browse_button</name> - <width>80</width> - <can_focus>True</can_focus> - <label>Browse...</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkEntry</class> - <name>mime_type_entry</name> - <sensitive>False</sensitive> - <can_focus>True</can_focus> - <editable>False</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkHButtonBox</class> - <child_name>GnomeDialog:action_area</child_name> - <name>dialog-action_area1</name> - <layout_style>GTK_BUTTONBOX_END</layout_style> - <spacing>8</spacing> - <child_min_width>85</child_min_width> - <child_min_height>27</child_min_height> - <child_ipad_x>7</child_ipad_x> - <child_ipad_y>0</child_ipad_y> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - <pack>GTK_PACK_END</pack> - </child> - - <widget> - <class>GtkButton</class> - <name>ok_button</name> - <can_default>True</can_default> - <has_default>True</has_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> - </widget> - - <widget> - <class>GtkButton</class> - <name>apply_button</name> - <sensitive>False</sensitive> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button> - </widget> - - <widget> - <class>GtkButton</class> - <name>close_button</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/composer/e-msg-composer-attachment.h b/composer/e-msg-composer-attachment.h deleted file mode 100644 index 7e3c88238b..0000000000 --- a/composer/e-msg-composer-attachment.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-msg-composer-attachment.h - * - * Copyright (C) 1999 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ -#ifndef __E_MSG_COMPOSER_ATTACHMENT_H__ -#define __E_MSG_COMPOSER_ATTACHMENT_H__ - -#include <gnome.h> -#include <glade/glade-xml.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_MSG_COMPOSER_ATTACHMENT (e_msg_composer_attachment_get_type ()) -#define E_MSG_COMPOSER_ATTACHMENT(obj) (GTK_CHECK_CAST ((obj), E_TYPE_MSG_COMPOSER_ATTACHMENT, EMsgComposerAttachment)) -#define E_MSG_COMPOSER_ATTACHMENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_MSG_COMPOSER_ATTACHMENT, EMsgComposerAttachmentClass)) -#define E_IS_MSG_COMPOSER_ATTACHMENT(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_MSG_COMPOSER_ATTACHMENT)) -#define E_IS_MSG_COMPOSER_ATTACHMENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_MSG_COMPOSER_ATTACHMENT)) - - -typedef struct _EMsgComposerAttachment EMsgComposerAttachment; -typedef struct _EMsgComposerAttachmentClass EMsgComposerAttachmentClass; - -struct _EMsgComposerAttachment { - GtkObject parent; - - GladeXML *editor_gui; - - gchar *file_name; - gchar *description; - gchar *mime_type; - - gulong size; -}; - -struct _EMsgComposerAttachmentClass { - GtkObjectClass parent_class; - - void (*changed) (EMsgComposerAttachment *msg_composer_attachment); -}; - - -GtkType e_msg_composer_attachment_get_type (void); -EMsgComposerAttachment *e_msg_composer_attachment_new (const gchar *file_name); -void e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment, - GtkWidget *parent); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_MSG_COMPOSER_ATTACHMENT_H__ */ diff --git a/composer/e-msg-composer-hdrs.c b/composer/e-msg-composer-hdrs.c deleted file mode 100644 index 2c27531bb8..0000000000 --- a/composer/e-msg-composer-hdrs.c +++ /dev/null @@ -1,355 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* msg-composer-hdrs.c - * - * Copyright (C) 1999 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifdef _HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gnome.h> -#include <camel/camel.h> - -#include "e-msg-composer-address-entry.h" -#include "e-msg-composer-hdrs.h" - - -struct _EMsgComposerHdrsPrivate { - /* Total number of headers that we have. */ - guint num_hdrs; - - /* The tooltips. */ - GtkTooltips *tooltips; - - /* Standard headers. */ - GtkWidget *to_entry; - GtkWidget *cc_entry; - GtkWidget *bcc_entry; - GtkWidget *subject_entry; -}; - - -static GtkTableClass *parent_class = NULL; - -enum { - SHOW_ADDRESS_DIALOG, - LAST_SIGNAL -}; - -static gint signals[LAST_SIGNAL]; - - -static void -address_button_clicked_cb (GtkButton *button, - gpointer data) -{ - gtk_signal_emit (GTK_OBJECT (data), signals[SHOW_ADDRESS_DIALOG]); -} - -static GtkWidget * -add_header (EMsgComposerHdrs *hdrs, - const gchar *name, - const gchar *tip, - const gchar *tip_private, - gboolean addrbook_button) -{ - EMsgComposerHdrsPrivate *priv; - GtkWidget *label; - GtkWidget *entry; - guint pad; - - priv = hdrs->priv; - - if (addrbook_button) { - label = gtk_button_new_with_label (name); - gtk_signal_connect (GTK_OBJECT (label), "clicked", - GTK_SIGNAL_FUNC (address_button_clicked_cb), - hdrs); - pad = 2; - gtk_tooltips_set_tip (hdrs->priv->tooltips, label, - _("Click here for the address book"), - NULL); - } else { - label = gtk_label_new (name); - pad = GNOME_PAD; - } - - gtk_table_attach (GTK_TABLE (hdrs), label, - 0, 1, priv->num_hdrs, priv->num_hdrs + 1, - GTK_FILL, GTK_FILL, - pad, pad); - gtk_widget_show (label); - - entry = e_msg_composer_address_entry_new (); - gtk_table_attach (GTK_TABLE (hdrs), entry, - 1, 2, priv->num_hdrs, priv->num_hdrs + 1, - GTK_FILL | GTK_EXPAND, GTK_FILL, - 2, 2); - gtk_widget_show (entry); - - gtk_tooltips_set_tip (hdrs->priv->tooltips, entry, tip, tip_private); - - priv->num_hdrs++; - - return entry; -} - -static void -setup_headers (EMsgComposerHdrs *hdrs) -{ - EMsgComposerHdrsPrivate *priv; - - priv = hdrs->priv; - - priv->to_entry = add_header - (hdrs, _("To:"), - _("Enter the recipients of the message"), - NULL, - TRUE); - priv->cc_entry = add_header - (hdrs, _("Cc:"), - _("Enter the addresses that will receive a carbon copy of " - "the message"), - NULL, - TRUE); - priv->bcc_entry = add_header - (hdrs, _("Bcc:"), - _("Enter the addresses that will receive a carbon copy of " - "the message without appearing in the recipient list of " - "the message."), - NULL, - TRUE); - priv->subject_entry = add_header - (hdrs, _("Subject:"), - _("Enter the subject of the mail"), - NULL, - FALSE); -} - - -/* GtkObject methods. */ - -static void -destroy (GtkObject *object) -{ - EMsgComposerHdrs *hdrs; - EMsgComposerHdrsPrivate *priv; - - hdrs = E_MSG_COMPOSER_HDRS (object); - priv = hdrs->priv; - - gtk_object_destroy (GTK_OBJECT (priv->tooltips)); - - if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -static void -class_init (EMsgComposerHdrsClass *class) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS (class); - object_class->destroy = destroy; - - parent_class = gtk_type_class (gtk_table_get_type ()); - - signals[SHOW_ADDRESS_DIALOG] = - gtk_signal_new ("show_address_dialog", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EMsgComposerHdrsClass, - show_address_dialog), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -init (EMsgComposerHdrs *hdrs) -{ - EMsgComposerHdrsPrivate *priv; - - priv = g_new (EMsgComposerHdrsPrivate, 1); - - priv->to_entry = NULL; - priv->cc_entry = NULL; - priv->bcc_entry = NULL; - priv->subject_entry = NULL; - - priv->tooltips = gtk_tooltips_new (); - - priv->num_hdrs = 0; - - hdrs->priv = priv; -} - - -GtkType -e_msg_composer_hdrs_get_type (void) -{ - static GtkType type = 0; - - if (type == 0) { - static const GtkTypeInfo info = { - "EMsgComposerHdrs", - sizeof (EMsgComposerHdrs), - sizeof (EMsgComposerHdrsClass), - (GtkClassInitFunc) class_init, - (GtkObjectInitFunc) init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (gtk_table_get_type (), &info); - } - - return type; -} - -GtkWidget * -e_msg_composer_hdrs_new (void) -{ - EMsgComposerHdrs *new; - - new = gtk_type_new (e_msg_composer_hdrs_get_type ()); - - setup_headers (E_MSG_COMPOSER_HDRS (new)); - - return GTK_WIDGET (new); -} - - -static void -set_recipients (CamelMimeMessage *msg, - GtkWidget *entry_widget, - const gchar *type) -{ - EMsgComposerAddressEntry *entry; - GList *list; - GList *p; - - entry = E_MSG_COMPOSER_ADDRESS_ENTRY (entry_widget); - list = e_msg_composer_address_entry_get_addresses (entry); - - /* FIXME leak? */ - - for (p = list; p != NULL; p = p->next) { - printf ("Adding `%s:' header: %s\n", type, (gchar *) p->data); - camel_mime_message_add_recipient (msg, type, (gchar *) p->data); - } - - g_list_free (list); -} - -void -e_msg_composer_hdrs_to_message (EMsgComposerHdrs *hdrs, - CamelMimeMessage *msg) -{ - const gchar *s; - - g_return_if_fail (hdrs != NULL); - g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); - g_return_if_fail (msg != NULL); - g_return_if_fail (CAMEL_IS_MIME_MESSAGE (msg)); - - s = gtk_entry_get_text (GTK_ENTRY (hdrs->priv->subject_entry)); - camel_mime_message_set_subject (msg, g_strdup (s)); - - set_recipients (msg, hdrs->priv->to_entry, CAMEL_RECIPIENT_TYPE_TO); - set_recipients (msg, hdrs->priv->cc_entry, CAMEL_RECIPIENT_TYPE_CC); - set_recipients (msg, hdrs->priv->bcc_entry, CAMEL_RECIPIENT_TYPE_BCC); -} - - -void -e_msg_composer_hdrs_set_to (EMsgComposerHdrs *hdrs, - GList *to_list) -{ - EMsgComposerAddressEntry *entry; - - g_return_if_fail (hdrs != NULL); - g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); - - entry = E_MSG_COMPOSER_ADDRESS_ENTRY (hdrs->priv->to_entry); - e_msg_composer_address_entry_set_list (entry, to_list); -} - -void -e_msg_composer_hdrs_set_cc (EMsgComposerHdrs *hdrs, - GList *cc_list) -{ - EMsgComposerAddressEntry *entry; - - g_return_if_fail (hdrs != NULL); - g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); - - entry = E_MSG_COMPOSER_ADDRESS_ENTRY (hdrs->priv->cc_entry); - e_msg_composer_address_entry_set_list (entry, cc_list); -} - -void -e_msg_composer_hdrs_set_bcc (EMsgComposerHdrs *hdrs, - GList *bcc_list) -{ - EMsgComposerAddressEntry *entry; - - g_return_if_fail (hdrs != NULL); - g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); - - entry = E_MSG_COMPOSER_ADDRESS_ENTRY (hdrs->priv->bcc_entry); - e_msg_composer_address_entry_set_list (entry, bcc_list); -} - - -GList * -e_msg_composer_hdrs_get_to (EMsgComposerHdrs *hdrs) -{ - g_return_val_if_fail (hdrs != NULL, NULL); - g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL); - - return e_msg_composer_address_entry_get_addresses - (E_MSG_COMPOSER_ADDRESS_ENTRY (hdrs->priv->to_entry)); -} - -GList * -e_msg_composer_hdrs_get_cc (EMsgComposerHdrs *hdrs) -{ - g_return_val_if_fail (hdrs != NULL, NULL); - g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL); - - return e_msg_composer_address_entry_get_addresses - (E_MSG_COMPOSER_ADDRESS_ENTRY (hdrs->priv->cc_entry)); -} - -GList * -e_msg_composer_hdrs_get_bcc (EMsgComposerHdrs *hdrs) -{ - g_return_val_if_fail (hdrs != NULL, NULL); - g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL); - - return e_msg_composer_address_entry_get_addresses - (E_MSG_COMPOSER_ADDRESS_ENTRY (hdrs->priv->bcc_entry)); -} - diff --git a/composer/e-msg-composer-hdrs.h b/composer/e-msg-composer-hdrs.h deleted file mode 100644 index d053573d85..0000000000 --- a/composer/e-msg-composer-hdrs.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* msg-composer-hdrs.h - * - * Copyright (C) 1999 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef ___E_MSG_COMPOSER_HDRS_H__ -#define ___E_MSG_COMPOSER_HDRS_H__ - -#include <gnome.h> -#include <camel/camel-mime-message.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_MSG_COMPOSER_HDRS (e_msg_composer_hdrs_get_type ()) -#define E_MSG_COMPOSER_HDRS(obj) (GTK_CHECK_CAST ((obj), E_TYPE_MSG_COMPOSER_HDRS, EMsgComposerHdrs)) -#define E_MSG_COMPOSER_HDRS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_MSG_COMPOSER_HDRS, EMsgComposerHdrsClass)) -#define E_IS_MSG_COMPOSER_HDRS(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_MSG_COMPOSER_HDRS)) -#define E_IS_MSG_COMPOSER_HDRS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_MSG_COMPOSER_HDRS)) - - -typedef struct _EMsgComposerHdrs EMsgComposerHdrs; -typedef struct _EMsgComposerHdrsClass EMsgComposerHdrsClass; -typedef struct _EMsgComposerHdrsPrivate EMsgComposerHdrsPrivate; - -struct _EMsgComposerHdrs { - GtkTable parent; - - EMsgComposerHdrsPrivate *priv; -}; - -struct _EMsgComposerHdrsClass { - GtkTableClass parent_class; - - void (* show_address_dialog) (EMsgComposerHdrs *hdrs); -}; - - -GtkType e_msg_composer_hdrs_get_type (void); -GtkWidget *e_msg_composer_hdrs_new (void); -void e_msg_composer_hdrs_to_message (EMsgComposerHdrs *hdrs, - CamelMimeMessage *msg); - -void e_msg_composer_hdrs_set_to (EMsgComposerHdrs *hdrs, - GList *to_list); -void e_msg_composer_hdrs_set_cc (EMsgComposerHdrs *hdrs, - GList *cc_list); -void e_msg_composer_hdrs_set_bcc (EMsgComposerHdrs *hdrs, - GList *bcc_list); - -GList *e_msg_composer_hdrs_get_to (EMsgComposerHdrs *hdrs); -GList *e_msg_composer_hdrs_get_cc (EMsgComposerHdrs *hdrs); -GList *e_msg_composer_hdrs_get_bcc (EMsgComposerHdrs *hdrs); - -#ifdef _cplusplus -} -#endif /* _cplusplus */ - - -#endif /* __E_MSG_COMPOSER_HDRS_H__ */ diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c deleted file mode 100644 index f4271ea7e6..0000000000 --- a/composer/e-msg-composer.c +++ /dev/null @@ -1,564 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-msg-composer.c - * - * Copyright (C) 1999 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -/* - - TODO - - - Somehow users should be able to see if any file(s) are attached even when - the attachment bar is not shown. - -*/ - -#ifdef _HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gnome.h> -#include <glade/glade.h> -#include <camel/camel.h> - -#include "e-msg-composer.h" -#include "e-msg-composer-address-dialog.h" -#include "e-msg-composer-attachment-bar.h" -#include "e-msg-composer-hdrs.h" - - -#define DEFAULT_WIDTH 600 -#define DEFAULT_HEIGHT 500 - - -enum { - SEND, - POSTPONE, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -static GnomeAppClass *parent_class = NULL; - - -static void -free_string_list (GList *list) -{ - GList *p; - - if (list == NULL) - return; - - for (p = list; p != NULL; p = p->next) - g_free (p->data); - - g_list_free (list); -} - -/* This functions builds a CamelMimeMessage for the message that the user has - composed in `composer'. */ -static CamelMimeMessage * -build_message (EMsgComposer *composer) -{ - CamelMimeMessage *new; - CamelMimeBodyPart *body_part; - CamelMultipart *multipart; - gchar *text; - - new = camel_mime_message_new_with_session (NULL); - - e_msg_composer_hdrs_to_message (E_MSG_COMPOSER_HDRS (composer->hdrs), - new); - - multipart = camel_multipart_new (); - body_part = camel_mime_body_part_new (); - - text = gtk_editable_get_chars (GTK_EDITABLE (composer->text), 0, -1); - camel_mime_part_set_text (CAMEL_MIME_PART (body_part), text); - camel_multipart_add_part (multipart, body_part); - - e_msg_composer_attachment_bar_to_multipart - (E_MSG_COMPOSER_ATTACHMENT_BAR (composer->attachment_bar), - multipart); - - camel_medium_set_content_object (CAMEL_MEDIUM (new), - CAMEL_DATA_WRAPPER (multipart)); - - /* FIXME refcounting is most certainly wrong. We want all the stuff to - be destroyed when we unref() the message. */ - - return new; -} - - -static void -show_attachments (EMsgComposer *composer, - gboolean show) -{ - if (show) { - gtk_widget_show (composer->attachment_scrolled_window); - gtk_widget_show (composer->attachment_bar); - } else { - gtk_widget_hide (composer->attachment_scrolled_window); - gtk_widget_hide (composer->attachment_bar); - } - - composer->attachment_bar_visible = show; - - /* Update the GUI. */ - - gtk_check_menu_item_set_active - (GTK_CHECK_MENU_ITEM - (glade_xml_get_widget (composer->menubar_gui, - "menu_view_attachments")), - show); - - /* XXX we should update the toggle toolbar item as well. At - this point, it is not a toggle because Glade is broken. */ -} - - -/* Address dialog callbacks. */ - -static void -address_dialog_destroy_cb (GtkWidget *widget, - gpointer data) -{ - EMsgComposer *composer; - - composer = E_MSG_COMPOSER (data); - composer->address_dialog = NULL; -} - -static void -address_dialog_apply_cb (EMsgComposerAddressDialog *dialog, - gpointer data) -{ - EMsgComposerHdrs *hdrs; - GList *list; - - hdrs = E_MSG_COMPOSER_HDRS (E_MSG_COMPOSER (data)->hdrs); - - list = e_msg_composer_address_dialog_get_to_list (dialog); - e_msg_composer_hdrs_set_to (hdrs, list); - - list = e_msg_composer_address_dialog_get_cc_list (dialog); - e_msg_composer_hdrs_set_cc (hdrs, list); - - list = e_msg_composer_address_dialog_get_bcc_list (dialog); - e_msg_composer_hdrs_set_bcc (hdrs, list); -} - - -/* Message composer window callbacks. */ - -static void -send_cb (GtkWidget *widget, - gpointer data) -{ - gtk_signal_emit (GTK_OBJECT (data), signals[SEND]); -} - -static void -menu_view_attachments_activate_cb (GtkWidget *widget, - gpointer data) -{ - e_msg_composer_show_attachments (E_MSG_COMPOSER (data), - GTK_CHECK_MENU_ITEM (widget)->active); -} - -static void -toolbar_view_attachments_clicked_cb (GtkWidget *widget, - gpointer data) -{ - EMsgComposer *composer; - - composer = E_MSG_COMPOSER (data); - - e_msg_composer_show_attachments (composer, - ! composer->attachment_bar_visible); -} - -static void -add_attachment_cb (GtkWidget *widget, - gpointer data) -{ - EMsgComposer *composer; - - composer = E_MSG_COMPOSER (data); - - e_msg_composer_attachment_bar_attach - (E_MSG_COMPOSER_ATTACHMENT_BAR (composer->attachment_bar), - NULL); -} - -/* Create the address dialog if not created already. */ -static void -setup_address_dialog (EMsgComposer *composer) -{ - EMsgComposerAddressDialog *dialog; - EMsgComposerHdrs *hdrs; - GList *list; - - if (composer->address_dialog != NULL) - return; - - composer->address_dialog = e_msg_composer_address_dialog_new (); - dialog = E_MSG_COMPOSER_ADDRESS_DIALOG (composer->address_dialog); - hdrs = E_MSG_COMPOSER_HDRS (composer->hdrs); - - gtk_signal_connect (GTK_OBJECT (dialog), - "destroy", address_dialog_destroy_cb, composer); - gtk_signal_connect (GTK_OBJECT (dialog), - "apply", address_dialog_apply_cb, composer); - - list = e_msg_composer_hdrs_get_to (hdrs); - e_msg_composer_address_dialog_set_to_list (dialog, list); - - list = e_msg_composer_hdrs_get_cc (hdrs); - e_msg_composer_address_dialog_set_cc_list (dialog, list); - - list = e_msg_composer_hdrs_get_bcc (hdrs); - e_msg_composer_address_dialog_set_bcc_list (dialog, list); -} - -static void -address_dialog_cb (GtkWidget *widget, - gpointer data) -{ - EMsgComposer *composer; - - /* FIXME maybe we should hide the dialog on Cancel/OK instead of - destroying it. */ - - composer = E_MSG_COMPOSER (data); - - setup_address_dialog (composer); - - gtk_widget_show (composer->address_dialog); - gdk_window_show (composer->address_dialog->window); -} - -static void -glade_connect (GladeXML *gui, - const gchar *widget_name, - const gchar *signal_name, - GtkSignalFunc callback, - gpointer callback_data) -{ - GtkWidget *widget; - - widget = glade_xml_get_widget (gui, widget_name); - if (widget == NULL) - g_warning ("Widget `%s' was not found.", widget_name); - else - gtk_signal_connect (GTK_OBJECT (widget), signal_name, - GTK_SIGNAL_FUNC (callback), callback_data); -} - -static void -attachment_bar_changed (EMsgComposerAttachmentBar *bar, - gpointer data) -{ - EMsgComposer *composer; - - composer = E_MSG_COMPOSER (data); - - if (e_msg_composer_attachment_bar_get_num_attachments (bar) > 0) - e_msg_composer_show_attachments (composer, TRUE); - else - e_msg_composer_show_attachments (composer, FALSE); -} - -static void -setup_signals (EMsgComposer *composer) -{ - glade_connect (composer->menubar_gui, "menu_send", - "activate", GTK_SIGNAL_FUNC (send_cb), composer); - glade_connect (composer->toolbar_gui, "toolbar_send", - "clicked", GTK_SIGNAL_FUNC (send_cb), composer); - - glade_connect (composer->menubar_gui, "menu_view_attachments", - "activate", - GTK_SIGNAL_FUNC (menu_view_attachments_activate_cb), - composer); - glade_connect (composer->toolbar_gui, "toolbar_view_attachments", - "clicked", - GTK_SIGNAL_FUNC (toolbar_view_attachments_clicked_cb), - composer); - - glade_connect (composer->menubar_gui, "menu_add_attachment", - "activate", - GTK_SIGNAL_FUNC (add_attachment_cb), composer); - glade_connect (composer->toolbar_gui, "toolbar_add_attachment", - "clicked", - GTK_SIGNAL_FUNC (add_attachment_cb), composer); - - glade_connect (composer->menubar_gui, "menubar_address_dialog", - "activate", - GTK_SIGNAL_FUNC (address_dialog_cb), composer); - glade_connect (composer->toolbar_gui, "toolbar_address_dialog", - "clicked", - GTK_SIGNAL_FUNC (address_dialog_cb), composer); - - gtk_signal_connect (GTK_OBJECT (composer->attachment_bar), - "changed", - GTK_SIGNAL_FUNC (attachment_bar_changed), - composer); - - gtk_signal_connect (GTK_OBJECT (composer->hdrs), "show_address_dialog", - GTK_SIGNAL_FUNC (address_dialog_cb), - composer); -} - - -/* GtkObject methods. */ - -static void -destroy (GtkObject *object) -{ - EMsgComposer *composer; - - composer = E_MSG_COMPOSER (object); - - gtk_object_unref (GTK_OBJECT (composer->menubar_gui)); - gtk_object_unref (GTK_OBJECT (composer->toolbar_gui)); - gtk_object_unref (GTK_OBJECT (composer->appbar_gui)); - - if (composer->address_dialog != NULL) - gtk_widget_destroy (composer->address_dialog); - - if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -static void -class_init (EMsgComposerClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) klass; - - object_class->destroy = destroy; - - parent_class = gtk_type_class (gnome_app_get_type ()); - - signals[SEND] = - gtk_signal_new ("send", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EMsgComposerClass, send), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - signals[POSTPONE] = - gtk_signal_new ("postpone", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EMsgComposerClass, postpone), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -init (EMsgComposer *composer) -{ - composer->menubar_gui = NULL; - composer->toolbar_gui = NULL; - composer->appbar_gui = NULL; - - composer->hdrs = NULL; - - composer->text = NULL; - composer->text_scrolled_window = NULL; - - composer->address_dialog = NULL; - - composer->attachment_bar = NULL; - composer->attachment_scrolled_window = NULL; -} - - -GtkType -e_msg_composer_get_type (void) -{ - static GtkType type = 0; - - if (type == 0) { - static const GtkTypeInfo info = { - "EMsgComposer", - sizeof (EMsgComposer), - sizeof (EMsgComposerClass), - (GtkClassInitFunc) class_init, - (GtkObjectInitFunc) init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (gnome_app_get_type (), &info); - } - - return type; -} - - -/** - * e_msg_composer_construct: - * @composer: A message composer widget - * - * Construct @composer. - **/ -void -e_msg_composer_construct (EMsgComposer *composer) -{ - GtkWidget *vbox; - - gtk_window_set_default_size (GTK_WINDOW (composer), - DEFAULT_WIDTH, DEFAULT_HEIGHT); - - gnome_app_construct (GNOME_APP (composer), "e-msg-composer", - "Compose a message"); - - composer->menubar_gui = glade_xml_new (E_GLADEDIR "/e-msg-composer.glade", - "menubar"); - gnome_app_set_menus (GNOME_APP (composer), - GTK_MENU_BAR (glade_xml_get_widget (composer->menubar_gui, - "menubar"))); - - composer->toolbar_gui = glade_xml_new (E_GLADEDIR "/e-msg-composer.glade", - "toolbar"); - gnome_app_set_toolbar (GNOME_APP (composer), - GTK_TOOLBAR (glade_xml_get_widget (composer->toolbar_gui, - "toolbar"))); - - composer->appbar_gui = glade_xml_new (E_GLADEDIR "/e-msg-composer.glade", - "appbar"); - gnome_app_set_statusbar (GNOME_APP (composer), - glade_xml_get_widget (composer->appbar_gui, - "appbar")); - - vbox = gtk_vbox_new (FALSE, 0); - - composer->hdrs = e_msg_composer_hdrs_new (); - gtk_box_pack_start (GTK_BOX (vbox), composer->hdrs, FALSE, TRUE, 0); - gtk_widget_show (composer->hdrs); - - /* GtkText for message body editing, wrapped into a - GtkScrolledWindow. */ - - composer->text_scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy - (GTK_SCROLLED_WINDOW (composer->text_scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - composer->text = gtk_text_new (NULL, NULL); - gtk_text_set_word_wrap (GTK_TEXT (composer->text), FALSE); - gtk_text_set_editable (GTK_TEXT (composer->text), TRUE); - gtk_container_add (GTK_CONTAINER (composer->text_scrolled_window), - composer->text); - gtk_widget_show (composer->text); - gtk_box_pack_start (GTK_BOX (vbox), composer->text_scrolled_window, - TRUE, TRUE, 0); - gtk_widget_show (composer->text_scrolled_window); - - /* Attachment editor, wrapped into a GtkScrolledWindow. We don't - show it for now. */ - - composer->attachment_scrolled_window = gtk_scrolled_window_new (NULL, - NULL); - gtk_scrolled_window_set_policy - (GTK_SCROLLED_WINDOW (composer->attachment_scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - composer->attachment_bar = e_msg_composer_attachment_bar_new (NULL); - GTK_WIDGET_SET_FLAGS (composer->attachment_bar, GTK_CAN_FOCUS); - gtk_container_add (GTK_CONTAINER (composer->attachment_scrolled_window), - composer->attachment_bar); - gtk_box_pack_start (GTK_BOX (vbox), - composer->attachment_scrolled_window, - FALSE, TRUE, GNOME_PAD_SMALL); - - gnome_app_set_contents (GNOME_APP (composer), vbox); - gtk_widget_show (vbox); - - e_msg_composer_show_attachments (composer, FALSE); - - setup_signals (composer); -} - -/** - * e_msg_composer_new: - * - * Create a new message composer widget. - * - * Return value: A pointer to the newly created widget - **/ -GtkWidget * -e_msg_composer_new (void) -{ - GtkWidget *new; - - new = gtk_type_new (e_msg_composer_get_type ()); - e_msg_composer_construct (E_MSG_COMPOSER (new)); - - return new; -} - - -/** - * e_msg_composer_show_attachments: - * @composer: A message composer widget - * @show: A boolean specifying whether the attachment bar should be shown or - * not - * - * If @show is %FALSE, hide the attachment bar. Otherwise, show it. - **/ -void -e_msg_composer_show_attachments (EMsgComposer *composer, - gboolean show) -{ - g_return_if_fail (composer != NULL); - g_return_if_fail (E_IS_MSG_COMPOSER (composer)); - - show_attachments (composer, show); -} - - -/** - * e_msg_composer_get_message: - * @composer: A message composer widget - * - * Retrieve the message edited by the user as a CamelMimeMessage. The - * CamelMimeMessage object is created on the fly; subsequent calls to this - * function will always create new objects from scratch. - * - * Return value: A pointer to the new CamelMimeMessage object - **/ -CamelMimeMessage * -e_msg_composer_get_message (EMsgComposer *composer) -{ - g_return_val_if_fail (composer != NULL, NULL); - g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL); - - return build_message (composer); -} diff --git a/composer/e-msg-composer.glade b/composer/e-msg-composer.glade deleted file mode 100644 index b747c6f979..0000000000 --- a/composer/e-msg-composer.glade +++ /dev/null @@ -1,587 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>Message Composer</name> - <program_name>e-msg-composer</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <use_widget_names>False</use_widget_names> - <output_main_file>True</output_main_file> - <output_support_files>True</output_support_files> - <output_build_files>True</output_build_files> - <backup_source_files>True</backup_source_files> - <main_source_file>interface.c</main_source_file> - <main_header_file>interface.h</main_header_file> - <handler_source_file>callbacks.c</handler_source_file> - <handler_header_file>callbacks.h</handler_header_file> - <support_source_file>support.c</support_source_file> - <support_header_file>support.h</support_header_file> - <translatable_strings_file></translatable_strings_file> -</project> - -<widget> - <class>GnomeApp</class> - <name>app1</name> - <title>Message Composer</title> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - <enable_layout_config>True</enable_layout_config> - - <widget> - <class>GnomeDock</class> - <child_name>GnomeApp:dock</child_name> - <name>dock1</name> - <allow_floating>True</allow_floating> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GnomeDockItem</class> - <name>dockitem1</name> - <border_width>2</border_width> - <placement>GNOME_DOCK_TOP</placement> - <band>0</band> - <position>0</position> - <offset>0</offset> - <locked>False</locked> - <exclusive>True</exclusive> - <never_floating>False</never_floating> - <never_vertical>True</never_vertical> - <never_horizontal>False</never_horizontal> - <shadow_type>GTK_SHADOW_OUT</shadow_type> - - <widget> - <class>GtkMenuBar</class> - <name>menubar</name> - <shadow_type>GTK_SHADOW_NONE</shadow_type> - - <widget> - <class>GtkMenuItem</class> - <name>file</name> - <stock_item>GNOMEUIINFO_MENU_FILE_TREE</stock_item> - - <widget> - <class>GtkMenu</class> - <name>file_menu</name> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>open</name> - <signal> - <name>activate</name> - <handler>on_open_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:25:08 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_OPEN_ITEM</stock_item> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>save</name> - <signal> - <name>activate</name> - <handler>on_save_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:25:13 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_SAVE_ITEM</stock_item> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>save_as</name> - <signal> - <name>activate</name> - <handler>on_save_as_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:25:16 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_SAVE_AS_ITEM</stock_item> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>save_in_folder</name> - <signal> - <name>activate</name> - <handler>on_save_in_folder_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:25:20 GMT</last_modification_time> - </signal> - <label>Save in _Folder...</label> - <right_justify>False</right_justify> - <stock_icon>GNOME_STOCK_MENU_SAVE_AS</stock_icon> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>separator8</name> - <right_justify>False</right_justify> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>menu_send</name> - <signal> - <name>activate</name> - <handler>on_send_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:25:29 GMT</last_modification_time> - </signal> - <label>S_end</label> - <right_justify>False</right_justify> - <stock_icon>GNOME_STOCK_MENU_MAIL_SND</stock_icon> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>postpone</name> - <signal> - <name>activate</name> - <handler>on_postpone_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:25:37 GMT</last_modification_time> - </signal> - <label>_Postpone</label> - <right_justify>False</right_justify> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>separator1</name> - <right_justify>False</right_justify> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>exit</name> - <signal> - <name>activate</name> - <handler>on_exit_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:25:59 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_EXIT_ITEM</stock_item> - </widget> - </widget> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>edit</name> - <stock_item>GNOMEUIINFO_MENU_EDIT_TREE</stock_item> - - <widget> - <class>GtkMenu</class> - <name>edit_menu</name> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>undo</name> - <signal> - <name>activate</name> - <handler>on_undo_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:26:10 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_UNDO_ITEM</stock_item> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>redo</name> - <signal> - <name>activate</name> - <handler>on_redo_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:26:15 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_REDO_ITEM</stock_item> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>separator3</name> - <right_justify>False</right_justify> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>cut</name> - <signal> - <name>activate</name> - <handler>on_cut_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:26:21 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_CUT_ITEM</stock_item> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>copy</name> - <signal> - <name>activate</name> - <handler>on_copy_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:26:26 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_COPY_ITEM</stock_item> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>paste</name> - <signal> - <name>activate</name> - <handler>on_paste_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:26:31 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_PASTE_ITEM</stock_item> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>separator2</name> - <right_justify>False</right_justify> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>select_all</name> - <signal> - <name>activate</name> - <handler>on_select_all_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:26:37 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_SELECT_ALL_ITEM</stock_item> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>separator5</name> - <right_justify>False</right_justify> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>find</name> - <signal> - <name>activate</name> - <handler>on_find_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:26:42 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_FIND_ITEM</stock_item> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>find_again</name> - <signal> - <name>activate</name> - <handler>on_find_again_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:26:47 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_FIND_AGAIN_ITEM</stock_item> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>replace</name> - <signal> - <name>activate</name> - <handler>on_replace_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:26:53 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_REPLACE_ITEM</stock_item> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>separator6</name> - <right_justify>False</right_justify> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>properties</name> - <signal> - <name>activate</name> - <handler>on_properties_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:26:58 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_PROPERTIES_ITEM</stock_item> - </widget> - </widget> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>view1</name> - <stock_item>GNOMEUIINFO_MENU_VIEW_TREE</stock_item> - - <widget> - <class>GtkMenu</class> - <name>view1_menu</name> - - <widget> - <class>GtkCheckMenuItem</class> - <name>menu_view_attachments</name> - <signal> - <name>activate</name> - <handler>on_view_attachments_activate</handler> - <last_modification_time>Fri, 05 Nov 1999 18:31:16 GMT</last_modification_time> - </signal> - <label>Attachments</label> - <active>False</active> - <always_show_toggle>False</always_show_toggle> - </widget> - </widget> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>insert</name> - <label>_Insert</label> - <right_justify>False</right_justify> - - <widget> - <class>GtkMenu</class> - <name>insert_menu</name> - - <widget> - <class>GtkMenuItem</class> - <name>menu_add_attachment</name> - <signal> - <name>activate</name> - <handler>on_attachment_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:27:05 GMT</last_modification_time> - </signal> - <label>Attachment...</label> - <right_justify>False</right_justify> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>text_from_file</name> - <signal> - <name>activate</name> - <handler>on_text_from_file_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:27:16 GMT</last_modification_time> - </signal> - <label>Text from file...</label> - <right_justify>False</right_justify> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>separator6</name> - <right_justify>False</right_justify> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>hypertext_link</name> - <signal> - <name>activate</name> - <handler>on_hypertext_link_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:27:21 GMT</last_modification_time> - </signal> - <label>Hypertext link...</label> - <right_justify>False</right_justify> - </widget> - </widget> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>settings</name> - <stock_item>GNOMEUIINFO_MENU_SETTINGS_TREE</stock_item> - - <widget> - <class>GtkMenu</class> - <name>settings_menu</name> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>preferences</name> - <signal> - <name>activate</name> - <handler>on_preferences_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:27:37 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_PREFERENCES_ITEM</stock_item> - </widget> - </widget> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>tools</name> - <label>_Tools</label> - <right_justify>False</right_justify> - - <widget> - <class>GtkMenu</class> - <name>tools_menu</name> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>spell_check1</name> - <signal> - <name>activate</name> - <handler>on_spell_check_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:27:44 GMT</last_modification_time> - </signal> - <label>_Spell check</label> - <right_justify>False</right_justify> - <stock_icon>GNOME_STOCK_MENU_SPELLCHECK</stock_icon> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>separator7</name> - <right_justify>False</right_justify> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>check_names</name> - <signal> - <name>activate</name> - <handler>on_check_names_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:27:49 GMT</last_modification_time> - </signal> - <label>Check names</label> - <right_justify>False</right_justify> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>menubar_address_dialog</name> - <signal> - <name>activate</name> - <handler>on_address_book_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:27:53 GMT</last_modification_time> - </signal> - <label>Address book...</label> - <right_justify>False</right_justify> - <stock_icon>GNOME_STOCK_MENU_BOOK_RED</stock_icon> - </widget> - </widget> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>help</name> - <stock_item>GNOMEUIINFO_MENU_HELP_TREE</stock_item> - - <widget> - <class>GtkMenu</class> - <name>help_menu</name> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>about</name> - <signal> - <name>activate</name> - <handler>on_about_activate</handler> - <last_modification_time>Wed, 27 Oct 1999 22:28:01 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_ABOUT_ITEM</stock_item> - </widget> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GnomeDockItem</class> - <name>dockitem2</name> - <border_width>1</border_width> - <placement>GNOME_DOCK_TOP</placement> - <band>1</band> - <position>0</position> - <offset>0</offset> - <locked>False</locked> - <exclusive>True</exclusive> - <never_floating>False</never_floating> - <never_vertical>False</never_vertical> - <never_horizontal>False</never_horizontal> - <shadow_type>GTK_SHADOW_OUT</shadow_type> - - <widget> - <class>GtkToolbar</class> - <name>toolbar</name> - <border_width>1</border_width> - <orientation>GTK_ORIENTATION_HORIZONTAL</orientation> - <type>GTK_TOOLBAR_BOTH</type> - <space_size>16</space_size> - <space_style>GTK_TOOLBAR_SPACE_LINE</space_style> - <relief>GTK_RELIEF_NONE</relief> - <tooltips>True</tooltips> - - <widget> - <class>GtkButton</class> - <child_name>Toolbar:button</child_name> - <name>toolbar_send</name> - <tooltip>Send this message</tooltip> - <label>Send -</label> - <stock_pixmap>GNOME_STOCK_PIXMAP_MAIL_SND</stock_pixmap> - </widget> - - <widget> - <class>GtkToggleButton</class> - <child_name>Toolbar:button</child_name> - <name>toolbar_view_attachments</name> - <tooltip>Show attachments for this message</tooltip> - <label>Show -attachments</label> - <active>False</active> - </widget> - - <widget> - <class>GtkButton</class> - <child_name>Toolbar:button</child_name> - <name>toolbar_add_attachment</name> - <tooltip>Attach a file</tooltip> - <label>Attach -file</label> - </widget> - - <widget> - <class>GtkButton</class> - <child_name>Toolbar:button</child_name> - <name>toolbar_address_dialog</name> - <tooltip>Go to addressbook</tooltip> - <label>Edit -addresses</label> - <stock_pixmap>GNOME_STOCK_PIXMAP_BOOK_RED</stock_pixmap> - </widget> - </widget> - </widget> - - <widget> - <class>Placeholder</class> - <child_name>GnomeDock:contents</child_name> - </widget> - </widget> - - <widget> - <class>GnomeAppBar</class> - <child_name>GnomeApp:appbar</child_name> - <name>appbar</name> - <has_progress>True</has_progress> - <has_status>True</has_status> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> -</widget> - -</GTK-Interface> diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h deleted file mode 100644 index 3028dedca3..0000000000 --- a/composer/e-msg-composer.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-msg-composer.h - * - * Copyright (C) 1999 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef ___E_MSG_COMPOSER_H__ -#define ___E_MSG_COMPOSER_H__ - -#include <gnome.h> -#include <glade/glade.h> - -#include "e-msg-composer-attachment-bar.h" -#include "e-msg-composer-hdrs.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - - -#define E_TYPE_MSG_COMPOSER (e_msg_composer_get_type ()) -#define E_MSG_COMPOSER(obj) (GTK_CHECK_CAST ((obj), E_TYPE_MSG_COMPOSER, EMsgComposer)) -#define E_MSG_COMPOSER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_MSG_COMPOSER, EMsgComposerClass)) -#define E_IS_MSG_COMPOSER(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_MSG_COMPOSER)) -#define E_IS_MSG_COMPOSER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_MSG_COMPOSER)) - - -typedef struct _EMsgComposer EMsgComposer; -typedef struct _EMsgComposerClass EMsgComposerClass; - -struct _EMsgComposer { - GnomeApp parent; - - GladeXML *menubar_gui; - GladeXML *toolbar_gui; - GladeXML *appbar_gui; - - GtkWidget *hdrs; - - GtkWidget *text; - GtkWidget *text_scrolled_window; - - GtkWidget *attachment_bar; - GtkWidget *attachment_scrolled_window; - - GtkWidget *address_dialog; - - gboolean attachment_bar_visible : 1; -}; - -struct _EMsgComposerClass { - GnomeAppClass parent_class; - - void (* send) (EMsgComposer *composer); - void (* postpone) (EMsgComposer *composer); -}; - - -GtkType e_msg_composer_get_type (void); -void e_msg_composer_construct (EMsgComposer *composer); -GtkWidget *e_msg_composer_new (void); -void e_msg_composer_show_attachments (EMsgComposer *composer, gboolean show); -CamelMimeMessage *e_msg_composer_get_message (EMsgComposer *composer); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* ___E_MSG_COMPOSER_H__ */ diff --git a/composer/main.c b/composer/main.c deleted file mode 100644 index 8fbf01b5e8..0000000000 --- a/composer/main.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -#include <gnome.h> - -#include <camel/camel-data-wrapper.h> -#include <camel/camel-stream-fs.h> -#include <camel/camel-stream.h> - -#include "e-msg-composer.h" - -static void -send_cb (EMsgComposer *composer, - gpointer data) -{ - CamelMimeMessage *message; - CamelStream *stream; - gint stdout_dup; - - message = e_msg_composer_get_message (composer); - - stdout_dup = dup (1); - stream = camel_stream_fs_new_with_fd (stdout_dup); - camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), - stream); - camel_stream_close (stream); - - gtk_object_unref (GTK_OBJECT (message)); - -#if 0 - gtk_widget_destroy (GTK_WIDGET (composer)); - gtk_main_quit (); -#endif -} - -int -main (int argc, char **argv) -{ - GtkWidget *composer; - - gnome_init ("test", "0.0", argc, argv); - glade_gnome_init (); - - composer = e_msg_composer_new (); - gtk_widget_show (composer); - - gtk_signal_connect (GTK_OBJECT (composer), "send", - GTK_SIGNAL_FUNC (send_cb), NULL); - - gtk_main (); - - return 0; -} diff --git a/configure.in b/configure.in deleted file mode 100644 index d81d21c411..0000000000 --- a/configure.in +++ /dev/null @@ -1,111 +0,0 @@ -# Process this file with autoconf to produce a configure script. -AC_INIT(camel) -AM_CONFIG_HEADER(config.h) - -cflags_set=${CFLAGS+set} - -EVOLUTION_MAJOR_VERSION=0 -EVOLUTION_MINOR_VERSION=0 -EVOLUTION_MICRO_VERSION=1 -VERSION=$EVOLUTION_MAJOR_VERSION.$EVOLUTION_MINOR_VERSION.$EVOLUTION_MICRO_VERSION -PACKAGE=evolution - -AM_INIT_AUTOMAKE($PACKAGE, $VERSION) -AC_SUBST(VERSION) - - -dnl Initialize libtool -AM_PROG_LIBTOOL - -dnl Initialize maintainer mode -AM_MAINTAINER_MODE - -AC_CANONICAL_HOST - -AM_ACLOCAL_INCLUDE(macros) -GNOME_INIT - -AC_ISC_POSIX -AC_PROG_CC -AC_PROG_CPP -AC_STDC_HEADERS -AC_ARG_PROGRAM -AC_PROG_INSTALL -AC_PROG_LN_S -AC_PROG_MAKE_SET - -ALL_LINGUAS="" - -AM_GNOME_GETTEXT - -GNOME_X_CHECKS - -dnl ************************************************** -dnl * Posix thread support -dnl ************************************************** -GNOME_PTHREAD_CHECK -if test "x$PTHREAD_LIB" = "x" ; then - have_pthread=false -else - have_pthread=true -fi - -AM_CONDITIONAL(HAVE_PTHREAD, $have_pthread) - - -dnl ************************************************** -dnl * ORBit support -dnl ************************************************** -dnl GNOMEGNORBA_LIBS="$GNOMEGNORBA_LIBS" -dnl AC_SUBST(GNOMEGNORBA_LIBS) - - -dnl ****************************** -dnl Check for Bonobo -dnl ****************************** -dnl AM_PATH_BONOBO(0.1.0, [ -dnl AC_DEFINE(HAVE_BONOBO) -dnl have_bonobo=true -dnl ],[ -dnl have_bonobo=false -dnl ]) -dnl AM_CONDITIONAL(BONOBO, $have_bonobo) - - - - -dnl ****************************** -dnl LibGlade checking -dnl ****************************** -AC_MSG_CHECKING(For Glade libraries) -if gnome-config --libs libglade > /dev/null 2>&1; then - AC_MSG_RESULT(found) -else - AC_MSG_ERROR(Did not find libGlade installed) -fi - -EXTRA_GNOME_LIBS="`gnome-config --libs gnomeui libglade ` `glib-config --libs gthread`" -EXTRA_GNOME_CFLAGS="`gnome-config --cflags gnomeui libglade ` `glib-config --cflags gthread`" -AC_SUBST(EXTRA_GNOME_LIBS) -AC_SUBST(EXTRA_GNOME_CFLAGS) - - -AC_ARG_WITH(camel-hard-log-level, [ --with-camel-hard-log-level=level value of log level in camel (0-10)], - camel_hard_log_level="$withval", camel_hard_log_level="0") -AC_DEFINE_UNQUOTED(CAMEL_HARD_LOG_LEVEL, $camel_hard_log_level) - -AC_OUTPUT([ -Makefile -macros/Makefile -po/Makefile.in -camel/Makefile -camel/providers/Makefile -camel/providers/MH/Makefile -camel/providers/maildir/Makefile -composer/Makefile -devel-docs/Makefile -devel-docs/camel/Makefile -tests/Makefile -tests/ui-tests/Makefile -widgets/Makefile -]) diff --git a/devel-docs/.cvsignore b/devel-docs/.cvsignore deleted file mode 100644 index d436efd0f7..0000000000 --- a/devel-docs/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile.in -Makefile - diff --git a/devel-docs/Makefile.am b/devel-docs/Makefile.am deleted file mode 100644 index 74a5ff5b60..0000000000 --- a/devel-docs/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS=camel diff --git a/devel-docs/camel/.cvsignore b/devel-docs/camel/.cvsignore deleted file mode 100644 index 56d9506207..0000000000 --- a/devel-docs/camel/.cvsignore +++ /dev/null @@ -1,12 +0,0 @@ -sgml -html -Makefile.in -Makefile -camel.signals -camel.hierarchy -camel.args -camel-decl.txt -camel-unused.txt -camel.html -camel-decl-list.txt - diff --git a/devel-docs/camel/Makefile.am b/devel-docs/camel/Makefile.am deleted file mode 100644 index 276059cf88..0000000000 --- a/devel-docs/camel/Makefile.am +++ /dev/null @@ -1,101 +0,0 @@ -## Process this file with automake to produce Makefile.in - -# The name of the module. -DOC_MODULE=camel - -# The top-level SGML file. -DOC_MAIN_SGML_FILE=camel-docs.sgml - -# The directory containing the source code (if it contains documentation). -DOC_SOURCE_DIR=$(top_srcdir)/camel - -CFLAGS=`gtk-config --cflags gtk` -LDFLAGS="-lcamel `gtk-config --libs gtk` " - - -HTML_DIR=$(datadir)/gnome/html - - - -TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE) - -tmpl_sources = \ - tmpl/camel-data-wrapper.sgml \ - tmpl/camel-folder.sgml \ - tmpl/camel-mime-message.sgml \ - tmpl/camel-mime-part.sgml \ - tmpl/camel-recipient.sgml \ - tmpl/camel-service.sgml \ - tmpl/camel-store.sgml \ - tmpl/camel-stream.sgml - - -camel_docdir = $(HTML_DIR) -camel_doc_DATA = \ - camel.html \ - camel.hierarchy \ - camel.types \ - camel-scan.c \ - camel-decl.txt \ - camel-sections.txt - -EXTRA_DIST = $(camel_doc_DATA) - -camel.html: html/book1.html - -cd $(srcdir) && cp html/book1.html camel.html - -html/book1.html: sgml/camel-doc.bottom - $(MAKE) html - -sgml/camel-doc.bottom: $(tmpl_sources) - $(MAKE) sgml - -camel-scan.c: - -scan: camel-scan.c - CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) gtkdoc-scanobj --module=$(DOC_MODULE) - gtkdoc-scan --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) - -templates: scan - gtkdoc-mktmpl --module=$(DOC_MODULE) - -sgml: - gtkdoc-mkdb --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) - -html: - if ! test -d html ; then mkdir html ; fi - -cd html && gtkdoc-mkhtml $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE) - -clean-local: - rm -f *~ *.bak *.hierarchy *.signals *.args *-unused.txt camel.html - -maintainer-clean-local: clean - rm -rf sgml html $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt Makefile.in - -install-data-local: - $(mkinstalldirs) $(TARGET_DIR) - (installfiles=`echo $(srcdir)/html/*.html`; \ - if test "$$installfiles" = '$(srcdir)/html/*.html'; \ - then echo '-- Nothing to install' ; \ - else \ - for i in $$installfiles; do \ - echo '-- Installing '$$i ; \ - $(INSTALL_DATA) $$i $(TARGET_DIR); \ - done; \ - echo '-- Installing $(srcdir)/html/index.sgml' ; \ - $(INSTALL_DATA) $(srcdir)/html/index.sgml $(TARGET_DIR); \ - echo '-- Fixing Crossreferences' ; \ - gtkdoc-fixxref --module=$(DOC_MODULE) --html-dir=$(HTML_DIR)|| true; \ - fi) - -dist-hook: - mkdir $(distdir)/html - mkdir $(distdir)/sgml - mkdir $(distdir)/tmpl - -cp $(srcdir)/html/*.html $(srcdir)/html/*.css $(distdir)/html - -cp $(srcdir)/tmpl/*.sgml $(distdir)/tmpl - -cp $(srcdir)/sgml/*.sgml $(distdir)/sgml - -cp $(srcdir)/sgml/*.bottom $(srcdir)/sgml/*.top $(distdir)/sgml - - -.PHONY : html sgml templates scan diff --git a/devel-docs/camel/README_AND_TODO.txt b/devel-docs/camel/README_AND_TODO.txt deleted file mode 100644 index 5feeb1e4e9..0000000000 --- a/devel-docs/camel/README_AND_TODO.txt +++ /dev/null @@ -1,43 +0,0 @@ -Camel is currently (conceptualy) separated in four parts: - -* the session handling -* the storage mechanism. -* the (mime) message handling. -* some general utilities class/functions. - - - -* Session handling ------------------- - -(This is not gnome session managing related) -CamelSession is an object used to store some parameters on a user -basis. This can be a permanent (fs based) or volatile -(ram only) storage depending on user preferences. -The session object is, for example, responsible for -remembering authentication datas during application lifetime. -It is also responsible for selecting and loading providers -corresponding to protocols. In the case where only one -provider exists for a given protocol, the task is trivial, -but when multiple providers exist for a given protocol, the -user can choose their prefered one. Given its relationship -with providers, the session object is also used to instanciate -a store given an URL. - -Associated Classes: - CamelSession - implementation: 5% - -Associated Files: - camel-provider.[ch] - implementation: 2.5% (a struct in camel-provider.h) - - -* the storage mechanism. ------------------------- - -The storage mechanism is mainly represented by -the Store class and the Folder class. -* the (mime) message handling. -* some general utilities class/functions. - diff --git a/devel-docs/camel/camel-docs.sgml b/devel-docs/camel/camel-docs.sgml deleted file mode 100644 index 33c6623731..0000000000 --- a/devel-docs/camel/camel-docs.sgml +++ /dev/null @@ -1,28 +0,0 @@ -<!doctype book PUBLIC "-//Davenport//DTD DocBook V3.0//EN" [ -<!entity CamelDataWrapper SYSTEM "sgml/camel-data-wrapper.sgml"> -<!entity CamelFolder SYSTEM "sgml/camel-folder.sgml"> -<!entity CamelMimeMessage SYSTEM "sgml/camel-mime-message.sgml"> -<!entity CamelMimePart SYSTEM "sgml/camel-mime-part.sgml"> -<!entity CamelRecipient SYSTEM "sgml/camel-recipient.sgml"> -<!entity CamelService SYSTEM "sgml/camel-service.sgml"> -<!entity CamelStore SYSTEM "sgml/camel-store.sgml"> -<!entity CamelStream SYSTEM "sgml/camel-stream.sgml"> -]> - -<book> - <bookinfo> - <title>Camel Messaging Library Reference Manual</title> - </bookinfo> - - <chapter id="camel-objects"> - <title>Camel Objects</title> - &CamelMimeMessage; - &CamelService; - &CamelStore; - &CamelFolder; - &CamelMimePart; - &CamelDataWrapper; - &CamelRecipient; - - </chapter> -</book> diff --git a/devel-docs/camel/camel-sections.txt b/devel-docs/camel/camel-sections.txt deleted file mode 100644 index 1f6d45c03c..0000000000 --- a/devel-docs/camel/camel-sections.txt +++ /dev/null @@ -1,154 +0,0 @@ - -<INCLUDE>gnome.h</INCLUDE> -<INCLUDE>camel-data-wrapper.h</INCLUDE> - - -<SECTION> -<FILE>camel-data-wrapper</FILE> -CamelDataWrapper -<TITLE>CamelDataWrapper</TITLE> -camel_data_wrapper_write_to_stream -<SUBSECTION Standard> -CAMEL_DATA_WRAPPER -camel_data_wrapper_get_type -CAMEL_DATA_WRAPPER_CLASS -</SECTION> - -<SECTION> -<FILE>camel-recipient</FILE> -CamelRecipientTable -<TITLE>CamelRecipientTable</TITLE> -camel_recipient_table_new -camel_recipient_table_get -camel_recipient_table_add -camel_recipient_table_add_list -camel_recipient_table_remove -camel_recipient_table_ref -camel_recipient_table_unref -</SECTION> - -<SECTION> -<FILE>camel-mime-part</FILE> -CamelMimePart -<TITLE>CamelMimePart</TITLE> -camel_mime_part_add_header -camel_mime_part_set_content_object -camel_mime_part_set_filename -camel_mime_part_get_disposition -camel_mime_part_get_content_MD5 -camel_mime_part_get_encoding -camel_mime_part_set_header_lines -camel_mime_part_get_content_object -camel_mime_part_get_content_id -camel_mime_part_set_description -camel_mime_part_set_text -camel_mime_part_set_encoding -camel_mime_part_set_disposition -camel_mime_part_remove_header -camel_mime_part_get_filename -camel_mime_part_get_content_languages -camel_mime_part_set_content_languages -camel_mime_part_get_header_lines -camel_mime_part_get_description -camel_mime_part_get_header -<SUBSECTION Standard> -CAMEL_MIME_PART -camel_mime_part_get_type -CAMEL_MIME_PART_CLASS -</SECTION> - - - -<SECTION> -<FILE>camel-mime-message</FILE> -CamelMimeMessage -<TITLE>CamelMimeMessage</TITLE> -camel_mime_message_remove_recipient -camel_mime_message_get_recipients -camel_mime_message_set_flag -camel_mime_message_set_subject -camel_mime_message_get_reply_to -camel_mime_message_get_from -camel_mime_message_set_reply_to -camel_mime_message_get_sent_date -camel_mime_message_new_with_session -camel_mime_message_add_recipient -camel_mime_message_get_subject -camel_mime_message_set_from -camel_mime_message_get_flag -camel_mime_message_get_message_number -camel_mime_message_get_received_date -camel_mime_message_set_received_date -<SUBSECTION Standard> -CAMEL_MIME_MESSAGE -camel_mime_message_get_type -CAMEL_MIME_MESSAGE_CLASS -</SECTION> - - -<SECTION> -<FILE>camel-folder</FILE> -CamelFolder -<TITLE>CamelFolder</TITLE> -camel_folder_get_folder -camel_folder_create -camel_folder_delete -camel_folder_delete_messages -camel_folder_get_parent_folder -camel_folder_get_parent_store -camel_folder_get_mode -camel_folder_list_subfolders -<SUBSECTION Standard> -CAMEL_FOLDER -camel_folder_get_type -CAMEL_FOLDER_CLASS -</SECTION> - -<SECTION> -<FILE>camel-service</FILE> -CamelService -<TITLE>CamelService</TITLE> -camel_service_connect -camel_service_is_connected -camel_service_connect_to_with_login_passwd -camel_service_connect_to_with_login_passwd_port -camel_service_get_url -<SUBSECTION Standard> -CAMEL_SERVICE -camel_service_get_type -CAMEL_SERVICE_CLASS -</SECTION> - -<SECTION> -<FILE>camel-store</FILE> -CamelStore -<TITLE>CamelStore</TITLE> -camel_store_get_separator -camel_store_get_folder -<SUBSECTION Standard> -CAMEL_STORE -camel_store_get_type -CAMEL_STORE_CLASS -</SECTION> - - -<SECTION> -<FILE>camel-stream</FILE> -CamelStream -<TITLE>CamelStream</TITLE> -camel_stream_seek -camel_stream_write -camel_stream_flush -camel_stream_eos -camel_stream_write_string -camel_stream_close -camel_stream_write_strings -camel_stream_read -camel_stream_available -<SUBSECTION Standard> -CAMEL_STREAM -camel_stream_get_type -CAMEL_STREAM_CLASS -</SECTION> - - diff --git a/devel-docs/camel/camel.types b/devel-docs/camel/camel.types deleted file mode 100644 index 93142d8692..0000000000 --- a/devel-docs/camel/camel.types +++ /dev/null @@ -1,9 +0,0 @@ -#include <gtk/gtk.h> -#include <camel/camel-data-wrapper.h> -camel_data_wrapper_get_type -camel_folder_get_type -camel_mime_message_get_type -camel_mime_part_get_type -camel_service_get_type -camel_store_get_type -camel_stream_get_type diff --git a/devel-docs/camel/tmpl/.cvsignore b/devel-docs/camel/tmpl/.cvsignore deleted file mode 100644 index 29db8d052d..0000000000 --- a/devel-docs/camel/tmpl/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -camel-unused.sgml - diff --git a/devel-docs/camel/tmpl/camel-data-wrapper.sgml b/devel-docs/camel/tmpl/camel-data-wrapper.sgml deleted file mode 100644 index 6fce9eb128..0000000000 --- a/devel-docs/camel/tmpl/camel-data-wrapper.sgml +++ /dev/null @@ -1,26 +0,0 @@ -<!-- ##### SECTION Title ##### --> -CamelDataWrapper - -<!-- ##### SECTION Short_Description ##### --> -data container with streaming methods - -<!-- ##### SECTION Long_Description ##### --> -<para> -A CamelDataWrapper is wrapper around data which can save them to a stream -and restore them from a stream. -</para> - -<!-- ##### SECTION See_Also ##### --> -<para> - -</para> - -<!-- ##### FUNCTION camel_data_wrapper_write_to_stream ##### --> -<para> - -</para> - -@data_wrapper: -@stream: - - diff --git a/devel-docs/camel/tmpl/camel-folder.sgml b/devel-docs/camel/tmpl/camel-folder.sgml deleted file mode 100644 index 882d63499c..0000000000 --- a/devel-docs/camel/tmpl/camel-folder.sgml +++ /dev/null @@ -1,96 +0,0 @@ -<!-- ##### SECTION Title ##### --> -CamelFolder - -<!-- ##### SECTION Short_Description ##### --> -Represents a folder of messages on a store. - -<!-- ##### SECTION Long_Description ##### --> -<para> -CamelFolder represents a folder in a message store. -</para> - -<!-- ##### SECTION See_Also ##### --> -<para> - -</para> - -<!-- ##### STRUCT CamelFolder ##### --> -<para> - -</para> - - -<!-- ##### FUNCTION camel_folder_get_folder ##### --> -<para> - -</para> - -@folder: -@folder_name: -@Returns: - - -<!-- ##### FUNCTION camel_folder_create ##### --> -<para> - -</para> - -@folder: -@Returns: - - -<!-- ##### FUNCTION camel_folder_delete ##### --> -<para> - -</para> - -@folder: -@recurse: -@Returns: - - -<!-- ##### FUNCTION camel_folder_delete_messages ##### --> -<para> - -</para> - -@folder: -@Returns: - - -<!-- ##### FUNCTION camel_folder_get_parent_folder ##### --> -<para> - -</para> - -@folder: -@Returns: - - -<!-- ##### FUNCTION camel_folder_get_parent_store ##### --> -<para> - -</para> - -@folder: -@Returns: - - -<!-- ##### FUNCTION camel_folder_get_mode ##### --> -<para> - -</para> - -@folder: -@Returns: - - -<!-- ##### FUNCTION camel_folder_list_subfolders ##### --> -<para> - -</para> - -@folder: -@Returns: - - diff --git a/devel-docs/camel/tmpl/camel-mime-message.sgml b/devel-docs/camel/tmpl/camel-mime-message.sgml deleted file mode 100644 index 704f3d3572..0000000000 --- a/devel-docs/camel/tmpl/camel-mime-message.sgml +++ /dev/null @@ -1,171 +0,0 @@ -<!-- ##### SECTION Title ##### --> -CamelMimeMessage - -<!-- ##### SECTION Short_Description ##### --> - - -<!-- ##### SECTION Long_Description ##### --> -<para> - -</para> - -<!-- ##### SECTION See_Also ##### --> -<para> - -</para> - -<!-- ##### STRUCT CamelMimeMessage ##### --> -<para> - -</para> - - -<!-- ##### FUNCTION camel_mime_message_remove_recipient ##### --> -<para> - -</para> - -@mime_message: -@recipient_type: -@recipient: - - -<!-- ##### FUNCTION camel_mime_message_get_recipients ##### --> -<para> - -</para> - -@mime_message: -@recipient_type: -@Returns: - - -<!-- ##### FUNCTION camel_mime_message_set_flag ##### --> -<para> - -</para> - -@mime_message: -@flag: -@value: - - -<!-- ##### FUNCTION camel_mime_message_set_subject ##### --> -<para> - -</para> - -@mime_message: -@subject: - - -<!-- ##### FUNCTION camel_mime_message_get_reply_to ##### --> -<para> - -</para> - -@mime_message: -@Returns: - - -<!-- ##### FUNCTION camel_mime_message_get_from ##### --> -<para> - -</para> - -@mime_message: -@Returns: - - -<!-- ##### FUNCTION camel_mime_message_set_reply_to ##### --> -<para> - -</para> - -@mime_message: -@reply_to: - - -<!-- ##### FUNCTION camel_mime_message_get_sent_date ##### --> -<para> - -</para> - -@mime_message: -@Returns: - - -<!-- ##### FUNCTION camel_mime_message_new_with_session ##### --> -<para> - -</para> - -@session: -@Returns: - - -<!-- ##### FUNCTION camel_mime_message_add_recipient ##### --> -<para> - -</para> - -@mime_message: -@recipient_type: -@recipient: - - -<!-- ##### FUNCTION camel_mime_message_get_subject ##### --> -<para> - -</para> - -@mime_message: -@Returns: - - -<!-- ##### FUNCTION camel_mime_message_set_from ##### --> -<para> - -</para> - -@mime_message: -@from: - - -<!-- ##### FUNCTION camel_mime_message_get_flag ##### --> -<para> - -</para> - -@mime_message: -@flag: -@Returns: - - -<!-- ##### FUNCTION camel_mime_message_get_message_number ##### --> -<para> - -</para> - -@mime_message: -@Returns: - - -<!-- ##### FUNCTION camel_mime_message_get_received_date ##### --> -<para> - -</para> - -@mime_message: -@Returns: - - -<!-- ##### FUNCTION camel_mime_message_set_received_date ##### --> -<para> - -</para> - -@mime_message: -@received_date: - - diff --git a/devel-docs/camel/tmpl/camel-mime-part.sgml b/devel-docs/camel/tmpl/camel-mime-part.sgml deleted file mode 100644 index 2db158b25f..0000000000 --- a/devel-docs/camel/tmpl/camel-mime-part.sgml +++ /dev/null @@ -1,151 +0,0 @@ -<!-- ##### SECTION Title ##### --> -CamelMimePart - -<!-- ##### SECTION Short_Description ##### --> - - -<!-- ##### SECTION Long_Description ##### --> -<para> - -</para> - -<!-- ##### SECTION See_Also ##### --> -<para> - -</para> - -<!-- ##### FUNCTION camel_mime_part_set_filename ##### --> -<para> - -</para> - -@mime_part: -@filename: - - -<!-- ##### FUNCTION camel_mime_part_get_disposition ##### --> -<para> - -</para> - -@mime_part: -@Returns: - - -<!-- ##### FUNCTION camel_mime_part_get_content_MD5 ##### --> -<para> - -</para> - -@mime_part: -@Returns: - - -<!-- ##### FUNCTION camel_mime_part_get_encoding ##### --> -<para> - -</para> - -@mime_part: -@Returns: - - -<!-- ##### FUNCTION camel_mime_part_set_header_lines ##### --> -<para> - -</para> - -@mime_part: -@header_lines: - - -<!-- ##### FUNCTION camel_mime_part_get_content_id ##### --> -<para> - -</para> - -@mime_part: -@Returns: - - -<!-- ##### FUNCTION camel_mime_part_set_description ##### --> -<para> - -</para> - -@mime_part: -@description: - - -<!-- ##### FUNCTION camel_mime_part_set_text ##### --> -<para> - -</para> - -@camel_mime_part: -@text: - - -<!-- ##### FUNCTION camel_mime_part_set_encoding ##### --> -<para> - -</para> - -@mime_part: -@encoding: - - -<!-- ##### FUNCTION camel_mime_part_set_disposition ##### --> -<para> - -</para> - -@mime_part: -@disposition: - - -<!-- ##### FUNCTION camel_mime_part_get_filename ##### --> -<para> - -</para> - -@mime_part: -@Returns: - - -<!-- ##### FUNCTION camel_mime_part_get_content_languages ##### --> -<para> - -</para> - -@mime_part: -@Returns: - - -<!-- ##### FUNCTION camel_mime_part_set_content_languages ##### --> -<para> - -</para> - -@mime_part: -@content_languages: - - -<!-- ##### FUNCTION camel_mime_part_get_header_lines ##### --> -<para> - -</para> - -@mime_part: -@Returns: - - -<!-- ##### FUNCTION camel_mime_part_get_description ##### --> -<para> - -</para> - -@mime_part: -@Returns: - - diff --git a/devel-docs/camel/tmpl/camel-recipient.sgml b/devel-docs/camel/tmpl/camel-recipient.sgml deleted file mode 100644 index 4af84cf58e..0000000000 --- a/devel-docs/camel/tmpl/camel-recipient.sgml +++ /dev/null @@ -1,88 +0,0 @@ -<!-- ##### SECTION Title ##### --> -CamelRecipientTable - -<!-- ##### SECTION Short_Description ##### --> - - -<!-- ##### SECTION Long_Description ##### --> -<para> - -</para> - -<!-- ##### SECTION See_Also ##### --> -<para> - -</para> - -<!-- ##### STRUCT CamelRecipientTable ##### --> -<para> - -</para> - -@recipient_hash_table: -@ref_count: - -<!-- ##### FUNCTION camel_recipient_table_new ##### --> -<para> - -</para> - -@Returns: - - -<!-- ##### FUNCTION camel_recipient_table_unref ##### --> -<para> - -</para> - -@recipient_table: - - -<!-- ##### FUNCTION camel_recipient_table_get ##### --> -<para> - -</para> - -@recipient_table: -@recipient_type: -@Returns: - - -<!-- ##### FUNCTION camel_recipient_table_add ##### --> -<para> - -</para> - -@recipient_table: -@recipient_type: -@recipient: - - -<!-- ##### FUNCTION camel_recipient_table_remove ##### --> -<para> - -</para> - -@recipient_table: -@recipient_type: -@recipient: - - -<!-- ##### FUNCTION camel_recipient_table_add_list ##### --> -<para> - -</para> - -@recipient_table: -@recipient_type: -@recipient_list: - - -<!-- ##### FUNCTION camel_recipient_table_ref ##### --> -<para> - -</para> - -@recipient_table: - - diff --git a/devel-docs/camel/tmpl/camel-service.sgml b/devel-docs/camel/tmpl/camel-service.sgml deleted file mode 100644 index 5b51ea902e..0000000000 --- a/devel-docs/camel/tmpl/camel-service.sgml +++ /dev/null @@ -1,72 +0,0 @@ -<!-- ##### SECTION Title ##### --> -CamelService - -<!-- ##### SECTION Short_Description ##### --> - - -<!-- ##### SECTION Long_Description ##### --> -<para> - -</para> - -<!-- ##### SECTION See_Also ##### --> -<para> - -</para> - -<!-- ##### STRUCT CamelService ##### --> -<para> - -</para> - -@e: - -<!-- ##### FUNCTION camel_service_connect ##### --> -<para> - -</para> - -@service: - - -<!-- ##### FUNCTION camel_service_is_connected ##### --> -<para> - -</para> - -@service: -@Returns: - - -<!-- ##### FUNCTION camel_service_connect_to_with_login_passwd ##### --> -<para> - -</para> - -@service: -@host: -@login: -@passwd: - - -<!-- ##### FUNCTION camel_service_connect_to_with_login_passwd_port ##### --> -<para> - -</para> - -@service: -@host: -@login: -@passwd: -@port: - - -<!-- ##### FUNCTION camel_service_get_url ##### --> -<para> - -</para> - -@service: -@Returns: - - diff --git a/devel-docs/camel/tmpl/camel-store.sgml b/devel-docs/camel/tmpl/camel-store.sgml deleted file mode 100644 index 2882c09986..0000000000 --- a/devel-docs/camel/tmpl/camel-store.sgml +++ /dev/null @@ -1,45 +0,0 @@ -<!-- ##### SECTION Title ##### --> -CamelStore - -<!-- ##### SECTION Short_Description ##### --> - -A class representing a message (local or distant) repository - -<!-- ##### SECTION Long_Description ##### --> -<para> -The store class models a place where messages can be stored and retreived. It can be a local -store (for example an mbox-style store) or a distant server (for example an POP3 server). Messages are -not retreived or stored directly with a CamelStore object. Instead, a CamelFolder object must be -obtained from the store first. -</para> - -<!-- ##### SECTION See_Also ##### --> -<para> - -</para> - -<!-- ##### STRUCT CamelStore ##### --> -<para> - -</para> - - -<!-- ##### FUNCTION camel_store_get_separator ##### --> -<para> - -</para> - -@store: -@Returns: - - -<!-- ##### FUNCTION camel_store_get_folder ##### --> -<para> - -</para> - -@store: -@folder_name: -@Returns: - - diff --git a/devel-docs/camel/tmpl/camel-stream.sgml b/devel-docs/camel/tmpl/camel-stream.sgml deleted file mode 100644 index e965db2e45..0000000000 --- a/devel-docs/camel/tmpl/camel-stream.sgml +++ /dev/null @@ -1,101 +0,0 @@ -<!-- ##### SECTION Title ##### --> -CamelStream - -<!-- ##### SECTION Short_Description ##### --> - - -<!-- ##### SECTION Long_Description ##### --> -<para> - -</para> - -<!-- ##### SECTION See_Also ##### --> -<para> - -</para> - -<!-- ##### FUNCTION camel_stream_seek ##### --> -<para> - -</para> - -@stream: -@offset: -@policy: -@Returns: - - -<!-- ##### FUNCTION camel_stream_write ##### --> -<para> - -</para> - -@stream: -@buffer: -@n: -@Returns: - - -<!-- ##### FUNCTION camel_stream_flush ##### --> -<para> - -</para> - -@stream: - - -<!-- ##### FUNCTION camel_stream_eos ##### --> -<para> - -</para> - -@stream: -@Returns: - - -<!-- ##### MACRO camel_stream_write_string ##### --> -<para> - -</para> - -@stream: -@string: - - -<!-- ##### FUNCTION camel_stream_close ##### --> -<para> - -</para> - -@stream: - - -<!-- ##### FUNCTION camel_stream_write_strings ##### --> -<para> - -</para> - -@stream: -@Varargs: - - -<!-- ##### FUNCTION camel_stream_read ##### --> -<para> - -</para> - -@stream: -@buffer: -@n: -@Returns: - - -<!-- ##### FUNCTION camel_stream_available ##### --> -<para> - -</para> - -@stream: -@Returns: - - diff --git a/devel-docs/misc/ref_and_id_proposition.txt b/devel-docs/misc/ref_and_id_proposition.txt deleted file mode 100644 index 2127b45a57..0000000000 --- a/devel-docs/misc/ref_and_id_proposition.txt +++ /dev/null @@ -1,237 +0,0 @@ -Author: Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> -Date: August 9th 1999 -Last revision date : September 3rd 1999 -Version: 0.2 - -The last version of this document is always available in gnome CVS in -the gnome-mailer module: devel-docs/misc/ref_and_id_proposition.txt - - - -A) Identifying messages within folders --------------------------------------- - -Currently, in Camel there is only one way to retrieve a message from a -mail store: - CamelMimeMessage * - get_message (CamelFolder *folder, gint number) - -where number is an integer representing the message rank within its -parent folder. - -This is a traditional method (JavaMail, MAPI) and it is very useful -because this is often the only way to get a message in from a -classical store (pop3 for example). - -Moreover, various documents ([1], [2]) proposed to generalize the URL -scheme used in Camel ([3]) to access mail stores in order to identify -messages. Such an URL would be, for instance: - -pop3://po.myisp.com:1 - -Meaning: "Access message 1 on Pop3 server po.myisp.com" - - -However, referencing a message with its number within a folder is a -very unreliable method: - -1) Message order in a folder can change during a session: - - The user can move or remove messages from the folder, thus - completely changing message numbers. We could however imagine to - follow message operations in order to keep camel in a coherent - state at each time instant. This could be quite complex but may - be feasible using gtk signal system. - -2) Message order can change between sessions: - - Gnome-mailer was designed from the begining to allow messages to be - stored in classical mailboxes (mbox, maildir, MH, IMAP ...), in - order to allow users to run other MUA on their mailboxes if - necessary. These other MUA can change message order within folders - without any chance for Camel to trace the operations. - -These two scenarii show that it is quite impossible to use reliable -folder caching or message referencing if messages are referenced only -by their position within their parent folder. - - -We thus have to find a general way to identify and retreive a message -within its folder. One thing is sure, however: all folders -implementation won't allow this method. Pop3 stores will always access -messages using their rank on the server. MUA using Camel will thus -have to be prepared to access some stores providing only the old -fashionned message number access method. - -Basically, we have two choices: - -1) Accessing messages using (mailbox) Unique ID (UID) - - A UID is a string identifier associated to a message, which is - guaranteed to be unique within its parent folder and which will not - change between sessions. - -2) Accessing messages using Message ID - - A Message ID is a string identifier associated to a messages which - is guaranteed to be unique in the world, that is, no other message - can have the same Message ID. The message ID is defined in RFC 822, - and is stored as the message header "Message-id" - -Method (1) already exists in IMAP. -It is quite simple to define on local stores (MH, mbox, ....) but it -may not resist to message modification by other MUA. -Methods based on Message-id matching or message content checksum seem -to be the best one. Using an "X-" header is another possibility for -non read-only folders. A combination of these three methods may be the -most reliable solution. -The UID is impossible to implement in a POP3 store provider. - -(2) Can be used with IMAP, but would be very ineficient. -The main issue with this method is its dependancy upon other MUAs and -MTAs. Message-id is set before or during message transport. Moreover, -some rfc822 compliant messages may not even have any Message-id -header. -These are major issues when accessing read-only stores. -The M-ID is also impossible to implement in a POP3 store provider. - - -We may not rely on external MUA and MTA to guarentee the uniqueness of -the identifier . We may loose messages by never being able to read them -if two had the same uid. It would be possible to find workarounds, but -it could make Camel use a bit tricky. - -Given that most users will use IMAP or a database based store as their -main mail store, and given that this stores allow UID very -easily, I suggest that we use method (1). Discussion is still open, -though. - -Here are the public methods I propose to add to CamelFolder: - -gboolean camel_folder_supports_uid (CamelFolder *folder) - returns true if the folder can get messages - by their uid. - -gchar * camel_folder_get_uid_by_number (CamelFolder *folder, gint message_number) - return the uid of message which number in the folder - is %message_number. - -gchar * camel_folder_get_message_uid (CamelFolder *folder, CamelMimeMessage *message) - return the uid of the message within the folder. - -CamelMimeMessage *camel_folder_get_message_by_uid (CamelFolder *folder, gchar *uid) - return the message which uid is %uid - -In addition, the CamelMessage Class will have a new public method - -gchar * camel_mime_message_get_uid (CamelMimeMessage *message) - return the uid associated to the message in its physical parent - folder. - - - -B) Handling message references in (v)folders. ---------------------------------------------- - - -We want the future Gnome mailer to be able to build (virtual) folders -holding references to messages physically located in other -folders. More generally, we would like folders to be able to hold: - -1) messages -2) subfolders -3) references to messages - -(1) and (2) are already implemented in Camel because most mail stores -can hold messages and/or subfolders. - -(3) is a different issue, because no existing mail store can currently -hold, within folders, references to messages in other folders. -It will thus be a specific gnome-mailer extension. - - -One of the main issue is to determine what kind of behaviour we expect -from folders holding references. Here is a possible API. - -( the world (v)folder is used to distinguish between the physical -parent folder and the folder holding a reference to the message, when -a confusion may arise) - -Addition to CamelFolder: - -gboolean camel_folder_can_hold_references (CamelFolder *folder) - return true if the folder can contain references - -void camel_folder_add_reference_by_uid (CamelFolder *folder, gchar *folder_url, gchar *message_uid) - add a reference into a folder. %folder_url is the url of - the folder, %message_uid is the uid of the message within - its physical parent folder. - -void camel_folder_add_reference_by_message (CamelFolder *folder, CamelMessage *message) - add a reference. The place where the reference points - to is found using CamelMessage methods - -void camel_folder_remove_reference_by_uid (CamelFolder *folder, gchar *uid) - remove a message reference form a folder. Reference - is identified using its uid within the folder. - -gboolean camel_folder_uid_is_reference (CamelFolder *folder, gchar *uid) - return true if the message corresponding to the uid is a reference. - -Then all usual operations on the folder act if the message was -actually physically stored in this folder. For example, when the mailer -uses camel_folder_get_message_by_uid onto the (v)folder, the actual -message is retreived from its physical store. - -As you can see, the uid of the message within its physical parent -folder is different than its uid within the (v)folder. This is because -there is no way to guarantee that the uids of two messages in two -different folders would be different. Using references on this two -message in the same vfolder would break uniqueness of the uid in the -(v)folder. - -A couple of other methods could be defined but all the basics are -described here. - -This draft API is far from complete nor perfect, and is described here -only to stimulate discussions before the actual implementation. - - -The question now is to know how we store references. There are basically -two ways: - -1) references are stored using the URL of the physical folder - and the uid of the message within the folder - -2) a list of reference is kept, and in this list, reference are stored -as in (1). Folders would refer to the actual message using index in -the list - - - -The main problem with (1) is that references get lost as soon -as the actual message is moved. There is no way to find in which -folders references to the message exist. - -(2) is a way to solve this issue. When messages are used, Camel looks -in the list to see if the message is refered somewhere, and actualize -the URL and the uid with their new values. - -The problem with (2) is that we need to keep this information in a file -and libraries writing automatically to files are generally a bad idea. - -As in additional remark, it is clear that Camel will only be able to -hold references to messages on stores supporting UIDs. - - -Thanks in advance for your comments and ideas, - - - Bertrand <Bertrand.Guiheneuf@aful.org> - - --- - -[1] : http://www.selequa.com/%7epurp/gnomail/mail2db.html -[2] : http://www.selequa.com/%7epurp/gnomail/dbRecFmt.html -[3] : http://www.gnome.org/mailing-lists/archives/gnome-mailer-list/1999-April/0248.shtml diff --git a/devel-docs/query/virtual-folder-in-depth.sgml b/devel-docs/query/virtual-folder-in-depth.sgml deleted file mode 100644 index d3e3e0504b..0000000000 --- a/devel-docs/query/virtual-folder-in-depth.sgml +++ /dev/null @@ -1,407 +0,0 @@ -<!doctype article PUBLIC "-//Davenport//DTD DocBook V3.0//EN" []> - -<!-- SGMLized by Bertrand <Bertrand.Guiheneuf@aful.org> --> - -<article id="index"> - <artheader> - <authorgroup> - <author> - <firstname>Giao</firstname> - <surname>Nguyen</surname> - </author> - </authorgroup> - - <title>An in-depth look at the virtual folder mechanism</title> - <abstract> - <para> - This document describes a different way of approaching mail - organization and how all things are possible in this brave new - world. This document does not describe physical storage issues - nor interface issues. - </para> - <para> - Historically mail has been organized into folders. These - folders usually mapped to a single storage medium. The - relationship between mail organization and storage medium was - one to one. There was one mail organization for every storage - medium. This scheme had its limitations. - </para> - <para> - Efforts at categorizations are only meaningful at the instance that - one categorized. To find any piece of data, regardless of how well - it was categorized, required some amount of searching. Therefore, any - attempts to nullify searching is doomed to fail. It's time to embrace - searching as a way of life. - </para> - <para> - These are the terms and their definitions. The example rules used are - based on the syntax for VM (http://www.wonderworks.com/vm/) by Kyle - Jones whose ideas form the basis for this. I'm only adding the - existence of summary files to aid in scaling. I currently use VM and - it's virtual-folder rules for my daily mail purposes. To date, my only - complaints are speed (it has no caches) and for the unitiated, it's - not very user-friendly. - </para> - <para> - Comments, questions, rants, etc. should be directed at Giao Nguyen - (grail@cafebabe.org) who will try to address issues in a timely - manner. - </para> - </abstract> - </artheader> - - <!-- Definitions --> - <sect1 id="definitions"> - <title>Definitions</title> - <sect2> - <title>Store</title> - <para> - A location where mail can be found. This may be a file (Berkeley - mbox), directory (MH), IMAP server, POP3 server, Exchange server, - Lotus Notes server, a stack of Post-Its by your monitor fed through - some OCR system. - </para> - </sect2> - - <sect2> - <title>Message</title> - <para> - An individual mail message. - </para> - </sect2> - <sect2> - <title>Vfolder</title> - <para> - A group of messages sharing some commonality. This is the result of a - query. The vfolder maybe contained in a store, but it is not necessary - that a store holds only one vfolder. There is always an implicit - vfolder rule which matches all messages. A store contains the vfolder - which is the result of the query (any). It's short for virtual folder - or maybe view folder. I dunno. - </para> - </sect2> - <sect2> - <title>Default-vfolder</title> - <para> - The vfolder defined by (any) applied to the store. This is not the - inbox. The inbox could easily be defined by a query. A default rule - for the inbox could be (new) but it doesn't have to be. Mine happens - to be (or (unread) (new)). - </para> - </sect2> - <sect2> - <title>Folder</title> - <para> - The classical mail folder approach: one message organization per - store. - </para> - </sect2> - <sect2> - <title>Query</title> - <para> - A search for messages. The result of this is a vfolder. There are two - kinds of queries: named queries and lambda queries. More on this - later. - </para> - </sect2> - <sect2> - <title>Summary file </title> - <para> - An external file that contains pointers to messages which are matches - for a named query. In addition to pointers, the summary file should - also contain signatures of the store for sanity checks. When the term - "index" is used as a verb, it means to build a summary file for a - given name-value pair. - </para> - </sect2> - </sect1> - - <!-- Queries --> - <sect1> - <title>Queries</title> - <para> - Named queries are analogous to classical mail folders. Because named - queries maybe reused, summary files are kept as caches to reduce - the overall cost of viewing a vfolder. Summary files are superior to - folders in that they allow for the same messages to appear in multiple - vfolders without message duplications. Duplications of messages - defeats attempts at tagging a message with additional user information - like annotations. Named queries will define folders. - </para> - <para> - Lambda queries are similar to named queries except that they have no - name. These are created on the fly by the user to filter out or - include certain messages. - </para> - <para> - All queries can be layered on top of each other. A lambda query can be - layered on a named query and a named query can be layered on a lambda - query. The possibilities are endless. - </para> - <para> - The layerings can be done as boolean operations (and, or, not). Short - circuiting should be used. - </para> - <para> - Examples: - <programlisting> -(and (author "Giao") - (unread)) - </programlisting> - The (unread) query should only be evaluated on the results of (author - "Giao"). - <programlisting> -(or (author "Giao") - (unread)) - </programlisting> - Both of these queries should be evaluated. Any matches are added to the - resulting vfolder. - </para> - </sect1> - - <!-- Summary files --> - <sect1> - <title>Summary files</title> - <para> - Summary files are only meaningful when applied to the context of the - default-vfolder of a store. - </para> - <para> - Summary files should be generated for queries of the form: - <programlisting> -(function "constant value") - </programlisting> - Summary files should never be generated for queries of the form: - <programlisting> - (function (function1)) - - (and (function "value") - (another-function "another value")) - </programlisting> - Given a query of the form: - <programlisting> - (and (function "value") - (another-function "another value")) - </programlisting> - The system should use one summary file for (function "value") and - another summary file for (another-function "another value"). I will - call the prior form the "plain form". - </para> - <para> - It should be noted that the signature of the store should be based on - the assumption that new data may have been added to the store since - the application generated the summary file. Signatures generated on - the entirety of the store will most likely be meaningless for things - like POP/IMAP servers. - </para> - </sect1> - - <!-- Incremental Indexing --> - <sect1> - <title>Incremental indexing</title> - <para> - When new messages are detected, all known queries should be evaluated - on the new messages. vfolders should be notified of new messages that - are positive matches for their queries. The indexes generated by this - process should be merged into the current indexes for the vfolder. - </para> - </sect1> - - <!-- Can I have multiple stores --> - <sect1> - <title>Can I have multiple stores?</title> - <para> - I don't see why not. Again, the inbox is a vfolder so you can get a - unified inbox consisting of all new mail sent to all your stores or - your can get inboxes for each store or any combination your heart - desire. You get your cake, eat it, and someone else cleans the dishes! - </para> - </sect1> - - <!-- Why all this? --> - <sect1> - <title>Why all this?</title> - <para> - Consider the dynamic nature of the following query: - <programlisting> -(and (author "Giao") - (sent-after (today-midnight))) - </programlisting> - today-midnight would be a function that is evaluated at run-time to - calculate the appropriate object. - </para> - </sect1> - - <!-- Scenarios of usage and their solutions --> - <sect1> - <title>Scenarios of usage and their solutions</title> - <sect2> - <title>Mesage alterations</title> - <para> - This is a fuzzy area that should be left to the UI to handle. Messages - are altered. Read status are altered when a new message is read for - example. How do we handle this if our query is for unread messages? - Upon viewing the state would change. - </para> - <para> - One idea is to not evaluate the queries unless we're changing between - vfolder views. This assumes that one can only view a particular - vfolder at a time. For multi-vfolder viewing, a message change should - propagate through the vfolder system. Certain effects (as in our - example) would not be intuitive. - </para> - <para> - It would not be a clean solution to make special cases but they may be - necessary where certain defined fields are ignored when they are - changed. Some combination of the above rules can be used. I don't - think it's an easy solution. - </para> - </sect2> - <sect2> - <title>Message inclusion and exclusion</title> - <para> - Messages are included and excluded also with queries. The final query - will have the form of: - <programlisting> - (and (author "Giao") - (criteria value) - (not (criteria other-value))) - </programlisting> - Userland criterias may be a label of some sort. These may be userland - labels or Message-IDs. What are the performance issues involved in - this? With short circuiting, it's not a major problem. - </para> - <para> - The criterias and values are determined by the UI. The vfolder - mechanism isn't concerned with such issues. - </para> - <para> - Messages can be included and excluded at will. The idea is often - called "arbitrary inclusion/exclusion". This can be done by - Message-IDs or other fields. It's been noted that Message-IDs are not - unique. - </para> - <para> - I propose that any given vfolder is allocated an inclusion label and an - exclusion label. These should be randomly generated. This should be - part of the vfolder description. It should be noted that the vfolder - description has not been drafted yet. - </para> - <para> - The result is such that the rules for a given named query is: - <programlisting> - (and (user-query) - (label inclusion-label) - (not exclusion-label)) - </programlisting> - </para> - </sect2> - <sect2> - <title>Query scheduling</title> - <para> - Consider the following extremely dynamic queries: - <programlisting> - A: - (and (author "Giao") - (sent-after (today-midnight))) - - B: - (and (sent-after (today-midnight)) - (author "Giao")) - - C: - (or (author "Giao") - (sent-after (today-midnight))) - </programlisting> - Query A would be significantly faster because (author "Giao") is not - dynamic. A summary file could be generated for this query. Query B is - slow and can be optimized if there was a query compiler of some - sort. Query C demonstrates a query in which there is no good - optimization which can be applied. These come with a certain amount of - baggage. - </para> - <para> - It seems then that for boolean 'and' operations, plain forms should be - moved forward and other queries should be moved such that they are - evaluated later. I would expect that the majority of queries would be - of the plain form. - </para> - <para> - First is that the summary file is tied to the query and the store - where the query originates from. Second, a hashing function for - strings needs to be calculated for the query so that the query and the - summary file can be associated. This hashing function could be similar - to the hashing function described in Rob Pike's "The Practice of - Programming". (FIXME: Stick page number here) - </para> - </sect2> - <sect2> - <title>Archives</title> - <para> - Many people are concerned that archives won't be preserved, archives - aren't supported, and many other archive related issues. This is the - short version. - </para> - <para> - Archives are just that, archives. Archives are stores. Take your - vfolder, export it to a store. You are done. If you load up the store - again, then the default-vfolder of that store is the view of the - vfolder, except the query is different. - </para> - <para> - The point to vfolder is not to do away with classical folder - representation but to move the queries to the front where it would - make data management easier for people who don't think in terms of - files but in terms of queries because ordinary people don't think in - terms of files. - </para> - </sect2> - </sect1> - - <!-- Miscellany --> - <sect1> - <title>Miscellany</title> - <sect2> - <title>Annotations</title> - <para> - There should be a scheme to add annotations to messages. Common mail - user agents have used a tag in the message header to mark messages as - read/unread for example. Extending on this we have the ability to add - our own data to a message to add meaning to it. If we have a good - scheme for doing this, new possibilities are opened. - </para> - <sect3> - <title>Keywords</title> - <para> - When sending a message, a message could have certain keywords attached - to it. While this can be done with the subject line, the subject line - has a tendency to be munged by other mail applications. One popular - example is the "[rR]e:" prefix. Using the subject line also breaks the - "contract" with other mail user agents. Using keywords in another - field in the message header allows the sender to assist the recipient - in organizing data automatically. Note that the sender can only - provide hints as the sender is unlikely to know the organization - schemes of the recipient. - </para> - </sect3> - </sect2> - <sect2> - <title>Scope</title> - <para> - Let us assume that we have multiple stores. Does a query work on a - given store? Or does it work on all stores? Or is it configurable such - that a query can work on a user-selected list of stores? - </para> - </sect2> - </sect1> - - <!-- Alternatives to the above --> - <sect1> - <title>Alternatives to the above</title> - <para> - Jim Meyer (purp@selequa.com) is putting some notes on where - annotations needs to be located. They'll be located here as well as - any contributions I may have to them. - </para> - </sect1> -</article> diff --git a/devel-docs/query/virtual-folder-in-depth.txt b/devel-docs/query/virtual-folder-in-depth.txt deleted file mode 100644 index 01718a5f05..0000000000 --- a/devel-docs/query/virtual-folder-in-depth.txt +++ /dev/null @@ -1,309 +0,0 @@ -TITLE: An in-depth look at the virtual folder mechanism -AUTHOR: Giao Nguyen <grail@cafebabe.org> - -* introduction - -This document describes a different way of approaching mail -organization and how all things are possible in this brave new -world. This document does not describe physical storage issues nor -interface issues. - -Historically mail has been organized into folders. These folders -usually mapped to a single storage medium. The relationship between -mail organization and storage medium was one to one. There was one -mail organization for every storage medium. This scheme had its -limitations. - -Efforts at categorizations are only meaningful at the instance that -one categorized. To find any piece of data, regardless of how well -it was categorized, required some amount of searching. Therefore, any -attempts to nullify searching is doomed to fail. It's time to embrace -searching as a way of life. - -These are the terms and their definitions. The example rules used are -based on the syntax for VM (http://www.wonderworks.com/vm/) by Kyle -Jones whose ideas form the basis for this. I'm only adding the -existence of summary files to aid in scaling. I currently use VM and -it's virtual-folder rules for my daily mail purposes. To date, my only -complaints are speed (it has no caches) and for the unitiated, it's -not very user-friendly. - -Comments, questions, rants, etc. should be directed at Giao Nguyen -<grail@cafebabe.org> who will try to address issues in a timely -manner. - -* Definitions - -** store - -A location where mail can be found. This may be a file (Berkeley -mbox), directory (MH), IMAP server, POP3 server, Exchange server, -Lotus Notes server, a stack of Post-Its by your monitor fed through -some OCR system. - -** message - -An individual mail message. - -** vfolder - -A group of messages sharing some commonality. This is the result of a -query. The vfolder maybe contained in a store, but it is not necessary -that a store holds only one vfolder. There is always an implicit -vfolder rule which matches all messages. A store contains the vfolder -which is the result of the query (any). It's short for virtual folder -or maybe view folder. I dunno. - -** default-vfolder - -The vfolder defined by (any) applied to the store. This is not the -inbox. The inbox could easily be defined by a query. A default rule -for the inbox could be (new) but it doesn't have to be. Mine happens -to be (or (unread) (new)). - -** folder - -The classical mail folder approach: one message organization per -store. - -** query - -A search for messages. The result of this is a vfolder. There are two -kinds of queries: named queries and lambda queries. More on this -later. - -** summary file - -An external file that contains pointers to messages which are matches -for a named query. In addition to pointers, the summary file should -also contain signatures of the store for sanity checks. When the term -"index" is used as a verb, it means to build a summary file for a -given name-value pair. - -* Queries - -Named queries are analogous to classical mail folders. Because named -queries maybe reused, summary files are kept as caches to reduce -the overall cost of viewing a vfolder. Summary files are superior to -folders in that they allow for the same messages to appear in multiple -vfolders without message duplications. Duplications of messages -defeats attempts at tagging a message with additional user information -like annotations. Named queries will define folders. - -Lambda queries are similar to named queries except that they have no -name. These are created on the fly by the user to filter out or -include certain messages. - -All queries can be layered on top of each other. A lambda query can be -layered on a named query and a named query can be layered on a lambda -query. The possibilities are endless. - -The layerings can be done as boolean operations (and, or, not). Short -circuiting should be used. - -Examples: - -(and (author "Giao") - (unread)) - -The (unread) query should only be evaluated on the results of (author -"Giao"). - -(or (author "Giao") - (unread)) - -Both of these queries should be evaluated. Any matches are added to the -resulting vfolder. - -* Summary files - -Summary files are only meaningful when applied to the context of the -default-vfolder of a store. - -Summary files should be generated for queries of the form: - -(function "constant value") - -Summary files should never be generated for queries of the form: - -(function (function1)) - -(and (function "value") - (another-function "another value")) - -Given a query of the form: - -(and (function "value") - (another-function "another value")) - -The system should use one summary file for (function "value") and -another summary file for (another-function "another value"). I will -call the prior form the "plain form". - -It should be noted that the signature of the store should be based on -the assumption that new data may have been added to the store since -the application generated the summary file. Signatures generated on -the entirety of the store will most likely be meaningless for things -like POP/IMAP servers. - -* Incremental indexing - -When new messages are detected, all known queries should be evaluated -on the new messages. vfolders should be notified of new messages that -are positive matches for their queries. The indexes generated by this -process should be merged into the current indexes for the vfolder. - -* Can I have multiple stores? - -I don't see why not. Again, the inbox is a vfolder so you can get a -unified inbox consisting of all new mail sent to all your stores or -your can get inboxes for each store or any combination your heart -desire. You get your cake, eat it, and someone else cleans the dishes! - -* Why all this? - -Consider the dynamic nature of the following query: - -(and (author "Giao") - (sent-after (today-midnight))) - -today-midnight would be a function that is evaluated at run-time to -calculate the appropriate object. - -* Scenarios of usage and their solutions - -** Mesage alterations - -This is a fuzzy area that should be left to the UI to handle. Messages -are altered. Read status are altered when a new message is read for -example. How do we handle this if our query is for unread messages? -Upon viewing the state would change. - -One idea is to not evaluate the queries unless we're changing between -vfolder views. This assumes that one can only view a particular -vfolder at a time. For multi-vfolder viewing, a message change should -propagate through the vfolder system. Certain effects (as in our -example) would not be intuitive. - -It would not be a clean solution to make special cases but they may be -necessary where certain defined fields are ignored when they are -changed. Some combination of the above rules can be used. I don't -think it's an easy solution. - -** Message inclusion and exclusion - -Messages are included and excluded also with queries. The final query -will have the form of: - -(and (author "Giao") - (criteria value) - (not (criteria other-value))) - -Userland criterias may be a label of some sort. These may be userland -labels or Message-IDs. What are the performance issues involved in -this? With short circuiting, it's not a major problem. - -The criterias and values are determined by the UI. The vfolder -mechanism isn't concerned with such issues. - -Messages can be included and excluded at will. The idea is often -called "arbitrary inclusion/exclusion". This can be done by -Message-IDs or other fields. It's been noted that Message-IDs are not -unique. - -I propose that any given vfolder is allocated an inclusion label and an -exclusion label. These should be randomly generated. This should be -part of the vfolder description. It should be noted that the vfolder -description has not been drafted yet. - -The result is such that the rules for a given named query is: - -(and (user-query) - (label inclusion-label) - (not exclusion-label)) - -** Query scheduling - -Consider the following extremely dynamic queries: - -A: -(and (author "Giao") - (sent-after (today-midnight))) - -B: -(and (sent-after (today-midnight)) - (author "Giao")) - -C: -(or (author "Giao") - (sent-after (today-midnight))) - -Query A would be significantly faster because (author "Giao") is not -dynamic. A summary file could be generated for this query. Query B is -slow and can be optimized if there was a query compiler of some -sort. Query C demonstrates a query in which there is no good -optimization which can be applied. These come with a certain amount of -baggage. - -It seems then that for boolean 'and' operations, plain forms should be -moved forward and other queries should be moved such that they are -evaluated later. I would expect that the majority of queries would be -of the plain form. - -First is that the summary file is tied to the query and the store -where the query originates from. Second, a hashing function for -strings needs to be calculated for the query so that the query and the -summary file can be associated. This hashing function could be similar -to the hashing function described in Rob Pike's "The Practice of -Programming". (FIXME: Stick page number here) - -** Archives - -Many people are concerned that archives won't be preserved, archives -aren't supported, and many other archive related issues. This is the -short version. - -Archives are just that, archives. Archives are stores. Take your -vfolder, export it to a store. You are done. If you load up the store -again, then the default-vfolder of that store is the view of the -vfolder, except the query is different. - -The point to vfolder is not to do away with classical folder -representation but to move the queries to the front where it would -make data management easier for people who don't think in terms of -files but in terms of queries because ordinary people don't think in -terms of files. - -* Miscellany - -** Annotations - -There should be a scheme to add annotations to messages. Common mail -user agents have used a tag in the message header to mark messages as -read/unread for example. Extending on this we have the ability to add -our own data to a message to add meaning to it. If we have a good -scheme for doing this, new possibilities are opened. - -*** Keywords - -When sending a message, a message could have certain keywords attached -to it. While this can be done with the subject line, the subject line -has a tendency to be munged by other mail applications. One popular -example is the "[rR]e:" prefix. Using the subject line also breaks the -"contract" with other mail user agents. Using keywords in another -field in the message header allows the sender to assist the recipient -in organizing data automatically. Note that the sender can only -provide hints as the sender is unlikely to know the organization -schemes of the recipient. - -** Scope - -Let us assume that we have multiple stores. Does a query work on a -given store? Or does it work on all stores? Or is it configurable such -that a query can work on a user-selected list of stores? - -* Alternatives to the above - -Jim Meyer <purp@selequa.com> is putting some notes on where -annotations needs to be located. They'll be located here as well as -any contributions I may have to them. diff --git a/doc/Camel-Classes b/doc/Camel-Classes deleted file mode 100644 index da32d69460..0000000000 --- a/doc/Camel-Classes +++ /dev/null @@ -1,24 +0,0 @@ -CamelException -CamelProvider -CamelThreadProxy -GtkObject - + CamelDataWrapper - | + CameStreamDataWrapper - | + CamelMedium - | | + CamelMimePart - | | + CamelMimeBodyPart - | | + CamelMimeMessage - | + CamelMultipart - | + CamelSimpleDataWrapper - + CamelFolder - | + CamelFolderPtProxy - + CamelFolderSummary - + CamelService - | + CamelStore - + CamelSession - + CamelStream - | + CameDataWrapperStream - | + CamelStreamFs - | + CamelStreamBufferedFs - | + CamelStreamMem - + CamelThreadProxy
\ No newline at end of file diff --git a/doc/Design b/doc/Design deleted file mode 100644 index ae5cb911eb..0000000000 --- a/doc/Design +++ /dev/null @@ -1,135 +0,0 @@ - -The Evolution Project specification -Miguel de Icaza. - - -* Introduction - - Evolution is a project aiming at providing the free software - community with a professional, high-quality tool for managing - mail, appointments, tasks and other personal information - tools. - - We want to make Evolution a system that addresses our needs - (the free software development community) and we believe that - by addressing our needs, we will provide a system that will - scale in the years to come for other users that are just - starting to use computers and the internet. - - The main objectives of Evolution are to provide these powerful - features, and to make the user interface as pretty and - polished as possible. - - Evolution is a GNOME application. - - Evolution will copy the best user interface bits and the best - ideas and features found on contemporary groupware systems. - -* The overall organization - - A bar similar to outlook provides shortcuts for accessing the - various resources managed by Evolution: mail folders, - contacts, tasks, journal entries, notes, messages and other - user-defined destinations. - -* User interface widgets - -** The ETable package - - This package provides a way of displaying and editing tables. - - Tables are displayed based on a TableColumn definition that - defines the layout used for the display. Table Columns can be - nested, and the package does grouping of information displayed - according to the criteria defined there. - - This is used in multiple places troughout evolution: it is - used for the Mail summary display, for the TODO display and - TODO new data entry and for the address book. - - Nesting in the address book can be performed on various - fields. For example, a first level of nesting could be - "Company" and a second level would be "Country" the result is - a 2-level tree that can be collapsed expanded and contains the - information sorted/grouped by those two criteria. - - The user interface for this will be copied from Outlook: the - possibility of adding and removing fields with drag and drop - as well as grouping using drag and drop. - -* The Mail system - -** The Mail sources - - The mail system will support 4 sources of mail: - - POP3 (transfer to a local file). - IMAP - Local mbox format in $MAIL. - Local mbox format that have other delivery points. - - On top of that, it will be possible to browse existing mbox - archives (and possibly other formats in the future, like - Mailbox and Maildir). - -** Storing the mail - - Mail that gets incorporated into the system is stored in mbox - format, and summary files are provided for quick access to the - files. No modifications to the file on disk is performed (I - am not quite sure about this, perhaps we want to add the - status flags and some method for adding metadata to the mail). - - Summary files are rebuilt on demand or rebuild if the mbox - file and the summary file have got out of sync. - - A Metadata system that will enable us to attach information to - a message will have to be designed and implemented (enabling - users to add annotations to mails, and special keywords and - flags in a per-message fashion). - -** Virtual folders - - Virtual folders will enable users to read/browse their mail in - new ways: by specifying search criterias, these folders will - contain messages that match the criteria given. - - There is more information about this in the libcamel - directory. - - We will index all headers from a message, and possible the - contents of messages and keep those on a separate file, to - enable users to query their mail database. - -** Mail summary display - - The summary will be displayed using the ETable package, to - enable users to add a number of sorting criteria and various - display methods for the summary view. - - The Outlook methods for displaying will be present on the - system. - - Message threading will be supported in Evolution. - -** Message display engine - - We are going to be using a combination of - libcamel/limime/libjamie to parse messages and render them - into an HTML buffer. - -* The HTML engine - - The GtkHTML engine will be used to display messages, and will - be extended to support a number of features that we require: - internal handling of characters will be based on Unicode - -* The message composer - - Regular features found in composers will be added: connecting - the composer to the address book, support for drag and drop - for including attachments, editing the message, archiving - drafts and archiving messages sent. - - We will probably be extending the GtkHTML engine to support - editing of HTML text. diff --git a/e-util/e-cursors.c b/e-util/e-cursors.c deleted file mode 100644 index 150b84b90a..0000000000 --- a/e-util/e-cursors.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * cursors.c: cursor handling for Evolution. - * copied from Gnumeric. - * - * Authors: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <gnome.h> -#include "e-cursors.h" - -static GdkColor black, white; - -#define GDK_INTERNAL_CURSOR -1 - -typedef struct { - GdkCursor *cursor; - int hot_x, hot_y; - char **xpm; -} CursorDef; - -static CursorDef cursors [] = { - { NULL, GDK_INTERNAL_CURSOR, GDK_CROSSHAIR, NULL }, - { NULL, GDK_INTERNAL_CURSOR, GDK_LEFT_PTR, NULL }, - { NULL, GDK_INTERNAL_CURSOR, GDK_FLEUR, NULL }, - { NULL, GDK_INTERNAL_CURSOR, GDK_SB_H_DOUBLE_ARROW, NULL }, - { NULL, GDK_INTERNAL_CURSOR, GDK_SB_V_DOUBLE_ARROW, NULL }, - { NULL, 0, 0, NULL } -}; - - -static void -create_bitmap_and_mask_from_xpm (GdkBitmap **bitmap, GdkBitmap **mask, gchar **xpm) -{ - int height, width, colors; - char pixmap_buffer [(32 * 32)/8]; - char mask_buffer [(32 * 32)/8]; - int x, y, pix, yofs; - int transparent_color, black_color; - - sscanf (xpm [0], "%d %d %d %d", &height, &width, &colors, &pix); - - g_assert (height == 32); - g_assert (width == 32); - g_assert (colors <= 3); - - transparent_color = ' '; - black_color = '.'; - - yofs = colors + 1; - for (y = 0; y < 32; y++){ - for (x = 0; x < 32;){ - char value = 0, maskv = 0; - - for (pix = 0; pix < 8; pix++, x++){ - if (xpm [y + yofs][x] != transparent_color){ - maskv |= 1 << pix; - - /* - * Invert the colours here because it seems - * to workaround a bug the Matrox G100 Xserver? - * We reverse the foreground & background in the next - * routine to compensate. - */ - if (xpm [y + yofs][x] == black_color){ - value |= 1 << pix; - } - } - } - pixmap_buffer [(y * 4 + x/8)-1] = value; - mask_buffer [(y * 4 + x/8)-1] = maskv; - } - } - *bitmap = gdk_bitmap_create_from_data (NULL, pixmap_buffer, 32, 32); - *mask = gdk_bitmap_create_from_data (NULL, mask_buffer, 32, 32); -} - -void -e_cursors_init (void) -{ - GdkColormap *colormap; - int i; - - colormap = gtk_widget_get_default_colormap (); - gdk_color_white (colormap, &white); - gdk_color_black (colormap, &black); - - for (i = 0; cursors [i].hot_x; i++){ - GdkBitmap *bitmap, *mask; - - if (cursors [i].hot_x < 0) - cursors [i].cursor = gdk_cursor_new (cursors [i].hot_y); - else { - create_bitmap_and_mask_from_xpm (&bitmap, &mask, cursors [i].xpm); - - /* The foreground and background colours are reversed. - * See comment above for explanation. - */ - cursors [i].cursor = - gdk_cursor_new_from_pixmap ( - bitmap, mask, - &black, &white, - cursors [i].hot_x, - cursors [i].hot_y); - } - } - - g_assert (i == E_NUM_CURSORS); -} - -void -e_cursors_shutdown (void) -{ - int i; - - for (i = 0; cursors [i].hot_x; i++) - gdk_cursor_destroy (cursors [i].cursor); -} - - -/* Returns a cursor given its type */ -GdkCursor * -e_cursor_get (ECursorType type) -{ - g_return_val_if_fail (type >= 0 && type < E_NUM_CURSORS, NULL); - - return cursors [type].cursor; -} diff --git a/e-util/e-cursors.h b/e-util/e-cursors.h deleted file mode 100644 index 771e5f6d4d..0000000000 --- a/e-util/e-cursors.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef E_CURSORS_H -#define E_CURSORS_H - -/* Copied from Gnumeric */ - -typedef enum { - E_CURSOR_THIN_CROSS, - E_CURSOR_ARROW, - E_CURSOR_MOVE, - E_CURSOR_SIZE_X, - E_CURSOR_SIZE_Y, - E_NUM_CURSORS -} ECursorType; - -void e_cursors_init (void); -void e_cursors_shutdown (void); - -#define e_cursor_set(win, c) \ -G_STMT_START { \ - if (win) \ - gdk_window_set_cursor (win, e_cursor_get (c)); \ -} G_STMT_END - -#define e_cursor_set_widget(w, c) \ -G_STMT_START { \ - if (GTK_WIDGET (w)->window) \ - gdk_window_set_cursor (GTK_WIDGET (w)->window, e_cursor_get (c)); \ -} G_STMT_END - -GdkCursor *e_cursor_get (ECursorType type); - -#endif /* E_CURSORS_H */ - diff --git a/e-util/e-util.h b/e-util/e-util.h deleted file mode 100644 index ad4d754770..0000000000 --- a/e-util/e-util.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _E_UTIL_H_ -#define _E_UTIL_H_ - -#define E_MAKE_TYPE(l,str,t,ci,i,parent) \ -GtkType l##_get_type(void)\ -{\ - static GtkType type = 0;\ - if (!type){\ - GtkTypeInfo info = {\ - str,\ - sizeof (t),\ - sizeof (t##Class),\ - (GtkClassInitFunc) ci,\ - (GtkObjectInitFunc) i,\ - NULL, /* reserved 1 */\ - NULL, /* reserved 2 */\ - (GtkClassInitFunc) NULL\ - };\ - type = gtk_type_unique (parent, &info);\ - }\ - return type;\ -}\ - -#endif /* _E_UTIL_H_ */ diff --git a/e-util/e-util.h-29002 b/e-util/e-util.h-29002 deleted file mode 100644 index ad4d754770..0000000000 --- a/e-util/e-util.h-29002 +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _E_UTIL_H_ -#define _E_UTIL_H_ - -#define E_MAKE_TYPE(l,str,t,ci,i,parent) \ -GtkType l##_get_type(void)\ -{\ - static GtkType type = 0;\ - if (!type){\ - GtkTypeInfo info = {\ - str,\ - sizeof (t),\ - sizeof (t##Class),\ - (GtkClassInitFunc) ci,\ - (GtkObjectInitFunc) i,\ - NULL, /* reserved 1 */\ - NULL, /* reserved 2 */\ - (GtkClassInitFunc) NULL\ - };\ - type = gtk_type_unique (parent, &info);\ - }\ - return type;\ -}\ - -#endif /* _E_UTIL_H_ */ diff --git a/help/Camel-Classes b/help/Camel-Classes deleted file mode 100644 index da32d69460..0000000000 --- a/help/Camel-Classes +++ /dev/null @@ -1,24 +0,0 @@ -CamelException -CamelProvider -CamelThreadProxy -GtkObject - + CamelDataWrapper - | + CameStreamDataWrapper - | + CamelMedium - | | + CamelMimePart - | | + CamelMimeBodyPart - | | + CamelMimeMessage - | + CamelMultipart - | + CamelSimpleDataWrapper - + CamelFolder - | + CamelFolderPtProxy - + CamelFolderSummary - + CamelService - | + CamelStore - + CamelSession - + CamelStream - | + CameDataWrapperStream - | + CamelStreamFs - | + CamelStreamBufferedFs - | + CamelStreamMem - + CamelThreadProxy
\ No newline at end of file diff --git a/help/Design b/help/Design deleted file mode 100644 index ae5cb911eb..0000000000 --- a/help/Design +++ /dev/null @@ -1,135 +0,0 @@ - -The Evolution Project specification -Miguel de Icaza. - - -* Introduction - - Evolution is a project aiming at providing the free software - community with a professional, high-quality tool for managing - mail, appointments, tasks and other personal information - tools. - - We want to make Evolution a system that addresses our needs - (the free software development community) and we believe that - by addressing our needs, we will provide a system that will - scale in the years to come for other users that are just - starting to use computers and the internet. - - The main objectives of Evolution are to provide these powerful - features, and to make the user interface as pretty and - polished as possible. - - Evolution is a GNOME application. - - Evolution will copy the best user interface bits and the best - ideas and features found on contemporary groupware systems. - -* The overall organization - - A bar similar to outlook provides shortcuts for accessing the - various resources managed by Evolution: mail folders, - contacts, tasks, journal entries, notes, messages and other - user-defined destinations. - -* User interface widgets - -** The ETable package - - This package provides a way of displaying and editing tables. - - Tables are displayed based on a TableColumn definition that - defines the layout used for the display. Table Columns can be - nested, and the package does grouping of information displayed - according to the criteria defined there. - - This is used in multiple places troughout evolution: it is - used for the Mail summary display, for the TODO display and - TODO new data entry and for the address book. - - Nesting in the address book can be performed on various - fields. For example, a first level of nesting could be - "Company" and a second level would be "Country" the result is - a 2-level tree that can be collapsed expanded and contains the - information sorted/grouped by those two criteria. - - The user interface for this will be copied from Outlook: the - possibility of adding and removing fields with drag and drop - as well as grouping using drag and drop. - -* The Mail system - -** The Mail sources - - The mail system will support 4 sources of mail: - - POP3 (transfer to a local file). - IMAP - Local mbox format in $MAIL. - Local mbox format that have other delivery points. - - On top of that, it will be possible to browse existing mbox - archives (and possibly other formats in the future, like - Mailbox and Maildir). - -** Storing the mail - - Mail that gets incorporated into the system is stored in mbox - format, and summary files are provided for quick access to the - files. No modifications to the file on disk is performed (I - am not quite sure about this, perhaps we want to add the - status flags and some method for adding metadata to the mail). - - Summary files are rebuilt on demand or rebuild if the mbox - file and the summary file have got out of sync. - - A Metadata system that will enable us to attach information to - a message will have to be designed and implemented (enabling - users to add annotations to mails, and special keywords and - flags in a per-message fashion). - -** Virtual folders - - Virtual folders will enable users to read/browse their mail in - new ways: by specifying search criterias, these folders will - contain messages that match the criteria given. - - There is more information about this in the libcamel - directory. - - We will index all headers from a message, and possible the - contents of messages and keep those on a separate file, to - enable users to query their mail database. - -** Mail summary display - - The summary will be displayed using the ETable package, to - enable users to add a number of sorting criteria and various - display methods for the summary view. - - The Outlook methods for displaying will be present on the - system. - - Message threading will be supported in Evolution. - -** Message display engine - - We are going to be using a combination of - libcamel/limime/libjamie to parse messages and render them - into an HTML buffer. - -* The HTML engine - - The GtkHTML engine will be used to display messages, and will - be extended to support a number of features that we require: - internal handling of characters will be based on Unicode - -* The message composer - - Regular features found in composers will be added: connecting - the composer to the address book, support for drag and drop - for including attachments, editing the message, archiving - drafts and archiving messages sent. - - We will probably be extending the GtkHTML engine to support - editing of HTML text. diff --git a/po/.cvsignore b/po/.cvsignore deleted file mode 100644 index 607fa46017..0000000000 --- a/po/.cvsignore +++ /dev/null @@ -1,11 +0,0 @@ -*.gmo -*.mo -Makefile -Makefile.in -Makefile.in.in -POTFILES -cat-id-tbl.c -gnome-objc.pot -gnome.pot -stamp-cat-id - diff --git a/po/ChangeLog b/po/ChangeLog deleted file mode 100644 index 7d7a252a7c..0000000000 --- a/po/ChangeLog +++ /dev/null @@ -1,7 +0,0 @@ -1998-07-23 Nuno Ferreira <nmrf@rnl.ist.utl.pt> - - * pt.po: Added Portuguese translation. - -1996-06-12 Tristan Tarrant <ttarrant@suntlc.etnoteam.it> - - * it.po : Italian translations added diff --git a/po/POTFILES.in b/po/POTFILES.in deleted file mode 100644 index e69de29bb2..0000000000 --- a/po/POTFILES.in +++ /dev/null diff --git a/stamp.h.in b/stamp.h.in deleted file mode 100644 index 8b13789179..0000000000 --- a/stamp.h.in +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tests/.cvsignore b/tests/.cvsignore deleted file mode 100644 index 10cdebc6d6..0000000000 --- a/tests/.cvsignore +++ /dev/null @@ -1,11 +0,0 @@ -test1 -test2 -test3 -test4 -test5 -test6 -test7 -Makefile.in -Makefile -.deps -.libs diff --git a/tests/Makefile.am b/tests/Makefile.am deleted file mode 100644 index 85ee40b3a1..0000000000 --- a/tests/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -# process this file with automake to create Makefile.in - -INCLUDES = -I$(top_srcdir)/intl -I$(top_srcdir) -I$(top_srcdir)/camel \ - -I$(includedir) -I$(top_srcdir)/camel/providers/MH -LDADD = \ - $(top_builddir)/camel/libcamel.la \ - $(GNOME_LIBDIR) \ - $(GNOMEUI_LIBS) $(INTLLIBS) $(PTHREAD_LIB) $(EXTRA_GNOME_LIBS) -# $(BONOBO_LIBS) - - - - -#test4_LDADD = \ -# $(top_builddir)/camel/libcamel.la \ -# $(top_builddir)/camel/providers/MH/libcamelmh.la \ -# $(GNOME_LIBDIR) \ -# $(GNOMEUI_LIBS) $(INTLLIBS) $(PTHREAD_LIB) - - -noinst_PROGRAMS = \ - test1 \ - test2 \ - test3 \ - test7 \ - test8 diff --git a/tests/test1.c b/tests/test1.c deleted file mode 100644 index 5caac29c74..0000000000 --- a/tests/test1.c +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <stdio.h> - -#include "camel-mime-message.h" -#include "camel-mime-body-part.h" -#include "camel-multipart.h" -#include "camel-stream.h" -#include "camel-stream-fs.h" -#include "camel-stream-data-wrapper.h" -#include "camel-log.h" -#include "camel.h" - -int -main (int argc, char**argv) -{ - CamelMimeMessage *message; - CamelMultipart *multipart; - CamelMimeBodyPart *body_part; - CamelMimeBodyPart *attachment_part; - CamelStream *attachment_stream; - - /* FILE *output_file; */ - CamelStream *stream; - - gtk_init (&argc, &argv); - camel_init (); - - if (argc < 2) { - attachment_stream = NULL; - } else { - if (argc == 2) { - attachment_stream = camel_stream_fs_new_with_name - (argv[1], CAMEL_STREAM_FS_READ); - if (attachment_stream == NULL) { - fprintf (stderr, "Cannot open `%s'\n", - argv[1]); - return 1; - } - } else { - fprintf (stderr, "Usage: %s [<attachment>]\n", - argv[0]); - return 1; - } - } - - message = camel_mime_message_new_with_session ((CamelSession *)NULL); - - camel_mime_part_set_description (CAMEL_MIME_PART (message), "a test"); - - camel_medium_add_header (CAMEL_MEDIUM (message), "X-test1", "the value of a test"); - camel_medium_add_header (CAMEL_MEDIUM (message), "X-test2", "the value of another test"); - /*camel_mime_part_add_content_language (CAMEL_MIME_PART (message), g_string_new ("es-ca"));*/ - - camel_mime_message_set_received_date (message, g_strdup ("Thu, 20 May 1999, 10:39:14 +0200")); - camel_mime_message_set_subject (message, g_strdup ("A test message")); - camel_mime_message_set_reply_to (message, g_strdup ("toto@toto.com")); - camel_mime_message_set_from (message, g_strdup ("Bertrand.Guiheneuf@aful.org")); - - camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_TO, - g_strdup ("franck.dechamps@alseve.fr")); - camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_TO, - g_strdup ("mc@alseve.fr")); - camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_TO, - g_strdup ("richard.lengagne@aful.org")); - camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_CC, - g_strdup ("Francois.fleuret@aful.org")); - camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_CC, - g_strdup ("maury@justmagic.com")); - camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_BCC, - g_strdup ("Bertrand.Guiheneuf@aful.org")); - - multipart = camel_multipart_new (); - body_part = camel_mime_body_part_new (); - camel_mime_part_set_text (CAMEL_MIME_PART (body_part), "This is a test.\nThis is only a test.\n"); - camel_multipart_add_part (multipart, body_part); - - if (attachment_stream == NULL) { - attachment_part = NULL; - } else { - CamelDataWrapper *stream_wrapper; - - stream_wrapper = camel_stream_data_wrapper_new - (attachment_stream); - - attachment_part = camel_mime_body_part_new (); - camel_mime_part_set_encoding (CAMEL_MIME_PART (attachment_part), - CAMEL_MIME_PART_ENCODING_BASE64); - camel_medium_set_content_object (CAMEL_MEDIUM (attachment_part), - stream_wrapper); - camel_multipart_add_part (multipart, attachment_part); - - gtk_object_unref (GTK_OBJECT (stream_wrapper)); - } - - camel_medium_set_content_object (CAMEL_MEDIUM (message), CAMEL_DATA_WRAPPER (multipart)); - - stream = camel_stream_fs_new_with_name ("mail1.test", CAMEL_STREAM_FS_WRITE ); - if (!stream) { - CAMEL_LOG_FULL_DEBUG ("could not open output file"); - exit(2); - } - - camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), - stream); - camel_stream_close (stream); - gtk_object_unref (GTK_OBJECT (stream)); - - gtk_object_unref (GTK_OBJECT (message)); - gtk_object_unref (GTK_OBJECT (multipart)); - gtk_object_unref (GTK_OBJECT (body_part)); - - if (attachment_part != NULL) - gtk_object_unref (GTK_OBJECT (attachment_part)); - - printf ("Test1 finished\n"); - return 1; -} - diff --git a/tests/test2.c b/tests/test2.c deleted file mode 100644 index 20e8b739b9..0000000000 --- a/tests/test2.c +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* tests mime message file parsing */ -#include "gmime-utils.h" -#include "stdio.h" -#include "camel-log.h" -#include "camel-mime-message.h" -#include "camel-mime-part.h" -#include "camel-stream.h" -#include "camel-stream-fs.h" -#include "camel.h" - -int -main (int argc, char**argv) -{ - GHashTable *header_table; - CamelMimeMessage *message; - CamelStream *input_stream, *output_stream; - - gtk_init (&argc, &argv); - camel_init (); - camel_debug_level = CAMEL_LOG_LEVEL_FULL_DEBUG; - message = camel_mime_message_new_with_session( (CamelSession *)NULL); - - - input_stream = camel_stream_fs_new_with_name ("mail.test", CAMEL_STREAM_FS_READ); - if (!input_stream) { - perror ("could not open input file"); - printf ("You must create the file mail.test before running this test"); - exit(2); - } - - camel_data_wrapper_construct_from_stream ( CAMEL_DATA_WRAPPER (message), input_stream); - camel_medium_get_content_object (CAMEL_MEDIUM (message)); - camel_stream_close (input_stream); - gtk_object_unref (GTK_OBJECT (input_stream)); - - output_stream = camel_stream_fs_new_with_name ("mail2.test", CAMEL_STREAM_FS_WRITE); - camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), output_stream); - camel_stream_close (output_stream); - gtk_object_unref (GTK_OBJECT (output_stream)); - - gtk_object_unref (GTK_OBJECT (message)); - - return 0; - -} diff --git a/tests/test3.c b/tests/test3.c deleted file mode 100644 index 9893e2e507..0000000000 --- a/tests/test3.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#include "camel.h" - -int -main (int argc, char**argv) -{ - GtkType type; - - gtk_init (&argc, &argv); - camel_init (); - - printf ("Test 3 : data wrapper repository\n"); - - printf ("\nMime type : \"multipart\"\n"); - type = data_wrapper_repository_get_data_wrapper_type ("multipart"); - printf ("Type found %s\n", gtk_type_name (type) ); - - printf ("\nMime type : \"multipart/alternative\"\n"); - type = data_wrapper_repository_get_data_wrapper_type ("multipart/alternative"); - printf ("Type found %s\n", gtk_type_name (type) ); - - printf ("\nMime type : \"toto/titi\"\n"); - type = data_wrapper_repository_get_data_wrapper_type ("toto/titi"); - printf ("Type found %s\n", gtk_type_name (type) ); - - printf ("Test3 finished\n"); - return 1; -} - diff --git a/tests/test4.c b/tests/test4.c deleted file mode 100644 index 99285cec43..0000000000 --- a/tests/test4.c +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* testing mh providers - do not use CamelMhFolder and CamelMhStore directly. - We do it here for test purpose only */ - - - -#include "camel-folder.h" -#include "camel-mh-folder.h" -#include "camel-mh-store.h" -#include "camel.h" -#include "camel-log.h" - -int -main (int argc, char**argv) -{ - CamelStore *store; - CamelFolder *inbox_folder; - CamelFolder *root_mh_folder; - GList *mh_subfolders_name; - CamelMimeMessage *message_1; - gboolean inbox_exists; - - camel_debug_level = CAMEL_LOG_LEVEL_FULL_DEBUG; - - gtk_init (&argc, &argv); - camel_init (); - - - store = gtk_type_new (CAMEL_MH_STORE_TYPE); - camel_store_init (store, (CamelSession *)NULL, g_strdup ("mh:///root/Mail")); - - root_mh_folder = camel_store_get_folder (store, ""); - mh_subfolders_name = camel_folder_list_subfolders (root_mh_folder, NULL); - - printf ("\n------------- Listing root Mh folder subfolders --------\n"); - while (mh_subfolders_name) { - printf ("\t\"%s\"\n", (gchar *)mh_subfolders_name->data); - mh_subfolders_name = mh_subfolders_name->next; - } - printf ("--------------------------------------------------------\n\n"); - - inbox_folder = camel_store_get_folder (store, "inbox"); - if (!inbox_folder) { - printf ("** Error: could not get inbox folder from store\n"); - return 1; - } - - /* test existence */ - inbox_exists = camel_folder_exists (inbox_folder, NULL); - if (inbox_exists) - printf ("MH folder inbox exists, continuing tests\n"); - else { - printf ("MH folder inbox does not exist. Stopping \n"); - return 1; - } - - printf ("\n Inbox folder contains %d messages\n", camel_folder_get_message_count (inbox_folder, NULL)); - printf ("\n------------- Gettting message numer 3 in inbox --------\n"); - message_1 = camel_folder_get_message (inbox_folder, 3, NULL); - printf ("--------------------------------------------------------\n\n"); - - - return 1; - - -} diff --git a/tests/test5.c b/tests/test5.c deleted file mode 100644 index 2f47fda418..0000000000 --- a/tests/test5.c +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* test for the RFC 2047 decoder */ - -#include <string.h> -#include <unicode.h> - -#include "gmime-utils.h" -#include "stdio.h" -#include "camel-log.h" -#include "camel-mime-message.h" -#include "camel-mime-part.h" -#include "camel-stream.h" -#include "camel-stream-fs.h" -#include "camel.h" -#include "gmime-rfc2047.h" - -#define TERMINAL_CHARSET "UTF-8" - -/* - * Info on many unicode issues, including, utf-8 xterms from : - * - * http://www.cl.cam.ac.uk/~mgk/unicode.html - * - */ - -const char *tests[] = -{ -/* these strings come from RFC 2047. Ought to add a few torture cases here. */ - "=?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu>", - "=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>", - "=?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be>", - "=?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?= =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=", - "=?ISO-8859-1?Q?Olle_J=E4rnefors?= <ojarnef@admin.kth.se>", - "=?ISO-8859-1?Q?Patrik_F=E4ltstr=F6m?= <paf@nada.kth.se>", - "Nathaniel Borenstein <nsb@thumper.bellcore.com> (=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=)", - "", - "(=?ISO-8859-1?Q?a?=)", /* should be displayed as (a) */ - "(=?ISO-8859-1?Q?a?= b)", /* (a b) */ - "(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)", /* (ab) */ - "(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)", /* (ab) */ - "(=?ISO-8859-1?Q?a?= \n=?ISO-8859-1?Q?b?=)", /* (ab) */ - "(=?ISO-8859-1?Q?a_b?=)", /* (a b) */ - "(=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=)", /* (ab) */ - NULL -}; - - -int -main (int argc, char**argv) -{ - const char **b = tests; - while (*b) { - printf("%s\n", gmime_rfc2047_decode(*b, TERMINAL_CHARSET)); - b++; - } - - return 0; - -} diff --git a/tests/test6.c b/tests/test6.c deleted file mode 100644 index ead8312c52..0000000000 --- a/tests/test6.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* test for the RFC 2047 encoder */ - -#include <string.h> -#include <unicode.h> - -#include "gmime-utils.h" -#include "stdio.h" -#include "camel-log.h" -#include "camel-mime-message.h" -#include "camel-mime-part.h" -#include "camel-stream.h" -#include "camel-stream-fs.h" -#include "camel.h" -#include "gmime-rfc2047.h" - -#define TERMINAL_CHARSET "UTF-8" - -/* - * Info on many unicode issues, including, utf-8 xterms from : - * - * http://www.cl.cam.ac.uk/~mgk25/unicode.html - * - */ - -const char *tests[] = -{ - "Ðis is a test", "ISO-8859-1", - "Iñtérñàtiönælîçation", "ISO-8859-1", - "ΚαλημέÏα κόσμε", "UTF-8", - "コンニãƒãƒ", "UTF-8", - "ði ıntəˈnæʃənÉ™l fəˈnÉ›tık É™soÊŠsiˈeıʃn", "UTF-8", - NULL -}; - - -int -main (int argc, char**argv) -{ - const char **b = tests; - while (*b) { - char *e = gmime_rfc2047_encode(b[0], b[1]); - printf("%s\t%s\n", e, gmime_rfc2047_decode(e, TERMINAL_CHARSET)); - b+=2; - } - - return 0; - -} diff --git a/tests/test7.c b/tests/test7.c deleted file mode 100644 index 44c73d275b..0000000000 --- a/tests/test7.c +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* test provider stuff */ - - -#include "camel.h" - - -int -main (int argc, char**argv) -{ - const CamelProvider *new_provider; - - camel_debug_level = CAMEL_LOG_LEVEL_FULL_DEBUG; - - gtk_init (&argc, &argv); - camel_init (); - - - new_provider = camel_provider_register_as_module ("../camel/providers/MH/.libs/libcamelmh.so"); - - - return 1; -} diff --git a/tests/test8.c b/tests/test8.c deleted file mode 100644 index 1f446e171d..0000000000 --- a/tests/test8.c +++ /dev/null @@ -1,78 +0,0 @@ -/* test posix thread folder proxy */ - - -#include "camel.h" -#include "camel-log.h" - -CamelThreadProxy *proxy; -CamelFuncDef *func_def; - - -void -test_sync_func (int num) -{ - printf ("Sync function number %d\n", num); - printf ("Sync function : current thread : %d\n", pthread_self ()); - -} - - -void -test_async_cb (int num) -{ - printf ("Callback number %d\n", num); - printf ("Callback : current thread : %d\n", pthread_self ()); -} - -void -test_async_func (int num) -{ - CamelOp *cb; - - printf ("Async function number %d\n", num); - printf ("Async function : current thread : %d\n", pthread_self ()); - sleep (1); - cb = camel_marshal_create_op (func_def, test_async_cb, num); - camel_thread_proxy_push_cb (proxy, cb); - - -} - -int -main (int argc, char **argv) -{ - int i; - CamelOp *op; - - camel_debug_level = CAMEL_LOG_LEVEL_WARNING; - - camel_init (); - - func_def = - camel_func_def_new (camel_marshal_NONE__INT, - 1, - GTK_TYPE_INT); - - printf ("--== Testing Simple marshalling system ==--\n"); - for (i=0; i<5; i++) { - printf ("Iterration number %d\n", i); - op = camel_marshal_create_op (func_def, test_sync_func, i); - camel_op_run (op); - camel_op_free (op); - - } - printf ("\n\n"); - - proxy = camel_thread_proxy_new (); - - printf ("--== Testing Asynchronous Operation System ==--\n"); - for (i=0; i<5; i++) { - printf ("Pushing async operation number %d for execution\n", i); - op = camel_marshal_create_op (func_def, test_async_func, i); - camel_thread_proxy_push_op (proxy, op); - } - printf ("\n\n"); - printf ("--== Operations execution planned ==--\n"); - gtk_main (); -} - diff --git a/tests/ui-tests/.cvsignore b/tests/ui-tests/.cvsignore deleted file mode 100644 index 10c9ca5909..0000000000 --- a/tests/ui-tests/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -Makefile.in -Makefile -.deps -.libs -store_listing -msg-composer-test diff --git a/tests/ui-tests/Makefile.am b/tests/ui-tests/Makefile.am deleted file mode 100644 index 7c26399bbb..0000000000 --- a/tests/ui-tests/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -# process this file with automake to create Makefile.in - -INCLUDES = \ - -I$(top_srcdir)/intl \ - -I$(top_srcdir)/camel \ - -I$(includedir) \ - -I$(top_srcdir)/camel/providers/MH \ - -I$(top_srcdir)/widgets \ - $(EXTRA_GNOME_CFLAGS) - -LDADD = \ - $(top_builddir)/widgets/libevolutionwidgets.la \ - $(top_builddir)/camel/libcamel.la \ - $(INTLLIBS) \ - $(EXTRA_GNOME_LIBS) \ - $(PTHREAD_LIB) diff --git a/tests/ui-tests/store_listing.c b/tests/ui-tests/store_listing.c deleted file mode 100644 index fb7c2ae0f7..0000000000 --- a/tests/ui-tests/store_listing.c +++ /dev/null @@ -1,424 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Author : Bertrand.Guiheneuf@aful.org */ - - - -/* A simple and very dirty hack written to test - (and perhaps demonstrate) Camel */ - - -#include <gnome.h> -#include <glade/glade.h> - -#include "camel-folder.h" -#include "camel-mh-folder.h" -#include "camel-mh-store.h" -#include "camel.h" -#include "camel-folder-summary.h" - -static GladeXML *xml; -static CamelSession *_session; -static CamelFolder *currently_selected_folder = NULL; - -static GList *store_list; -static GList *folder_list; - -static void add_mail_store (const gchar *store_url); -static void show_folder_messages (CamelFolder *folder); - - - -static void -_destroy_menu (gpointer data) -{ - gtk_widget_destroy (GTK_WIDGET (data)); -} - -static void -_copy_message (GtkWidget *widget, gpointer data) -{ - CamelFolder *dest_folder = CAMEL_FOLDER (data); - GtkWidget *message_clist; - gint current_row; - GList *selected; - gint selected_row; - - CamelMimeMessage *message; - - printf ("Selected \"copy to folder\" with destination folder %s\n", camel_folder_get_name (dest_folder)); - message_clist = glade_xml_get_widget (xml, "message-clist"); - selected = GTK_CLIST (message_clist)->selection; - while (selected) { - selected_row = GPOINTER_TO_INT (selected->data); - message = CAMEL_MIME_MESSAGE (gtk_clist_get_row_data (GTK_CLIST (message_clist), selected_row)); - camel_folder_copy_message_to (currently_selected_folder, message, dest_folder); - selected = selected->next; - } - -} - -static GnomeUIInfo mailbox_popup_menu[] = { - GNOMEUIINFO_ITEM_STOCK ("_Copy selected message here", NULL, _copy_message, GNOME_STOCK_MENU_NEW), - GNOMEUIINFO_END -}; - -static void -_show_mailbox_context_menu (CamelFolder *folder) { - GtkWidget *menu; - GtkCTree *mailbox_and_store_tree; - - mailbox_and_store_tree = GTK_CTREE (glade_xml_get_widget (xml, "store-and-mailbox-tree")); - menu = gtk_object_get_data (GTK_OBJECT (mailbox_and_store_tree), "mailbox_popup_menu"); - if (!menu) { - menu = gnome_popup_menu_new (mailbox_popup_menu); - gtk_object_set_data_full (GTK_OBJECT (mailbox_and_store_tree), "mailbox_popup_menu", menu, _destroy_menu); - } - - gnome_popup_menu_do_popup (menu, NULL, NULL, NULL, folder); - - -} -static gboolean -mailbox_button_clicked_on_row (gint button, gint row) -{ - GtkCTreeNode *mailbox_node; - CamelFolder *folder; - GtkCTree *mailbox_and_store_tree; - const gchar *mailbox_name; - - mailbox_and_store_tree = GTK_CTREE (glade_xml_get_widget (xml, "store-and-mailbox-tree")); - - mailbox_node = gtk_ctree_node_nth (mailbox_and_store_tree, row); - - folder = gtk_ctree_node_get_row_data (mailbox_and_store_tree, mailbox_node); - if (folder && IS_CAMEL_FOLDER (folder)) { - - mailbox_name = camel_folder_get_name (folder); - printf ("mailbox %s clicked with button %d\n", mailbox_name, button); - switch (button) { - case 1: - currently_selected_folder = folder; - show_folder_messages (folder); - break; - case 2: - break; - case 3: - _show_mailbox_context_menu (folder); - } - return TRUE; - } else { - printf ("Node is a store\n"); - return FALSE; - } -} - - -static void -message_destroy_notify (gpointer data) -{ - CamelMimeMessage *message = CAMEL_MIME_MESSAGE (data); - - gtk_object_unref (GTK_OBJECT (message)); - -} - - - - - -static void -show_folder_messages (CamelFolder *folder) -{ - GtkWidget *message_clist; - gint folder_message_count; - CamelMimeMessage *message; - gint i; - const gchar *clist_row_text[3]; - const char *sent_date, *subject, *sender; - gint current_row; - CamelFolderSummary *summary; - - message_clist = glade_xml_get_widget (xml, "message-clist"); - - /* clear old message list */ - gtk_clist_clear (GTK_CLIST (message_clist)); - - if (camel_folder_has_summary_capability (folder)) { - const GList *message_info_list; - CamelMessageInfo *msg_info; - - printf ("Folder has summary. Good\n"); - summary = camel_folder_get_summary (folder); - message_info_list = camel_folder_summary_get_message_info_list (summary); - printf ("message_info_list = %p\n", message_info_list); - while (message_info_list) { - msg_info = (CamelMessageInfo *)message_info_list->data; - clist_row_text [0] = msg_info->date; - clist_row_text [1] = msg_info->sender; - clist_row_text [2] = msg_info->subject; - - current_row = gtk_clist_append (GTK_CLIST (message_clist), clist_row_text); - - message_info_list = message_info_list->next; - } - } else { - printf ("Folder does not have summary. Opening all messages\n"); - folder_message_count = camel_folder_get_message_count (folder); - - for (i=0; i<folder_message_count; i++) { - message = camel_folder_get_message (folder, i); - gtk_object_ref (GTK_OBJECT (message)); - sent_date = camel_mime_message_get_sent_date (message); - sender = camel_mime_message_get_from (message); - subject = camel_mime_message_get_subject (message); - - - if (sent_date) clist_row_text [0] = sent_date; - else clist_row_text [0] = NULL; - if (sender) clist_row_text [1] = sender; - else clist_row_text [1] = NULL; - if (subject) clist_row_text [2] = subject; - else clist_row_text [2] = NULL; - - current_row = gtk_clist_append (GTK_CLIST (message_clist), clist_row_text); - gtk_clist_set_row_data_full (GTK_CLIST (message_clist), current_row, (gpointer)message, message_destroy_notify); - } - - } -} - - -/* add a mail store given by its URL */ -static void -add_mail_store (const gchar *store_url) -{ - - CamelStore *store; - GtkWidget *mailbox_and_store_tree; - GtkCTreeNode* new_store_node; - GtkCTreeNode* new_folder_node; - char *new_tree_text[1]; - GList *subfolder_list; - CamelFolder *root_folder; - CamelFolder *new_folder; - - - - store = camel_session_get_store (_session, store_url); - if (!store) return; - - /* remember store */ - store_list = g_list_prepend (store_list, store); - - //store_list = g_list_append (store_list, (gpointer)store); - mailbox_and_store_tree = glade_xml_get_widget (xml, "store-and-mailbox-tree"); - new_tree_text[0] = g_strdup (store_url); - new_store_node = gtk_ctree_insert_node (GTK_CTREE (mailbox_and_store_tree), - NULL, - NULL, - new_tree_text, - 0, - NULL, - NULL, - NULL, - NULL, - FALSE, - FALSE); - - /* normally, use get_root_folder */ - root_folder = camel_store_get_folder (store, ""); - camel_folder_open (root_folder, FOLDER_OPEN_RW); - subfolder_list = camel_folder_list_subfolders (root_folder); - while (subfolder_list) { - new_tree_text[0] = subfolder_list->data; - new_folder = camel_store_get_folder (store, subfolder_list->data); - camel_folder_open (new_folder, FOLDER_OPEN_RW); - folder_list = g_list_prepend (folder_list, new_folder); - - new_folder_node = gtk_ctree_insert_node (GTK_CTREE (mailbox_and_store_tree), - new_store_node, - NULL, - new_tree_text, - 0, - NULL, - NULL, - NULL, - NULL, - FALSE, - FALSE); - - - gtk_ctree_node_set_row_data (GTK_CTREE (mailbox_and_store_tree), new_folder_node, (gpointer)new_folder); - subfolder_list = subfolder_list->next; - } -} - -static void -delete_selected_messages () -{ - GtkWidget *message_clist; - gint current_row; - GList *selected; - gint selected_row; - - CamelMimeMessage *message; - message_clist = glade_xml_get_widget (xml, "message-clist"); - selected = GTK_CLIST (message_clist)->selection; - while (selected) { - selected_row = GPOINTER_TO_INT (selected->data); - message = CAMEL_MIME_MESSAGE (gtk_clist_get_row_data (GTK_CLIST (message_clist), selected_row)); - camel_mime_message_set_flag (message, "DELETED", TRUE); - selected = selected->next; - } - -} - - -static void -expunge_selected_folders () -{ - GtkWidget *mailbox_and_store_tree; - CamelFolder *folder; - GtkCTreeNode* selected_node; - GList *selected; - const gchar *folder_name; - - mailbox_and_store_tree = glade_xml_get_widget (xml, "store-and-mailbox-tree"); - - selected = GTK_CLIST (mailbox_and_store_tree)->selection; - while (selected) { - - selected_node= GTK_CTREE_NODE (selected->data); - folder = CAMEL_FOLDER (gtk_ctree_node_get_row_data (GTK_CTREE (mailbox_and_store_tree), - selected_node)); - if (folder && IS_CAMEL_FOLDER (folder)) { - folder_name = camel_folder_get_name (folder); - printf ("folder to expunge : %s\n", folder_name); - camel_folder_expunge (folder, FALSE); - /* reshowing the folder this way is uggly - but allows to check the message are - correctly renoved and the cache works correctly */ - show_folder_messages (folder); - - } else { - printf ("A selected node is a store\n"); - } - - selected = selected->next; - } - - -} - -void -close_all () -{ - while (folder_list) { - camel_folder_close (CAMEL_FOLDER (folder_list->data), TRUE); - folder_list = folder_list->next; - } - - while (store_list) { - //camel_store_close (CAMEL_STORE (store_list->data)); - store_list = store_list->next; - } - -} - -/* ----- libglade callbacks */ -void -on_exit_activate (GtkWidget *widget, void *data) -{ - close_all (); - gtk_main_quit (); -} - - -void -on_about_activate (GtkWidget *widget, void *data) -{ - GtkWidget *about_widget; - - about_widget = glade_xml_get_widget (xml, "about_widget"); - gtk_widget_show (about_widget); -} - -void -on_new_store_activate (GtkWidget *widget, void *data) -{ - GtkWidget *new_store_dialog; - GtkWidget *new_store_gnome_entry; - GtkWidget *new_store_entry; - gchar *url_text; - - - gint pressed_button; - - new_store_dialog = glade_xml_get_widget (xml, "new_store_dialog"); - pressed_button = gnome_dialog_run (GNOME_DIALOG (new_store_dialog)); - - if ((pressed_button != 0) && (pressed_button != 1)) - return; - - new_store_gnome_entry = glade_xml_get_widget (xml, "new-store-entry"); - new_store_entry = gnome_entry_gtk_entry (GNOME_ENTRY (new_store_gnome_entry)); - url_text = gtk_entry_get_text (GTK_ENTRY (new_store_entry)); - - if (url_text) - add_mail_store (url_text); - -} - - -void -on_expunge_activate (GtkWidget *widget, void *data) -{ - expunge_selected_folders (); -} - - -void -on_message_delete_activate (GtkWidget *widget, void *data) -{ - delete_selected_messages(); -} - -gboolean -on_store_and_mailbox_tree_button_press_event (GtkWidget *widget, GdkEventButton *event, void *data) -{ - gint row; - GtkCList *clist = GTK_CLIST (widget); - - if (!gtk_clist_get_selection_info (clist, event->x, event->y, &row, NULL)) - return FALSE; - if (!mailbox_button_clicked_on_row (event->button, row)) - return FALSE; - - return TRUE; - -} - -/* ----- init */ -int -main(int argc, char *argv[]) -{ - GtkWidget *new_store_gnome_entry; - - gnome_init ("store_listing", "1.0", argc, argv); - - glade_gnome_init (); - camel_init (); - xml = glade_xml_new ("store_listing.glade", NULL); - if (xml) glade_xml_signal_autoconnect (xml); - - _session = camel_session_new (); - camel_provider_register_as_module ("../../camel/providers/MH/.libs/libcamelmh.so"); - - new_store_gnome_entry = glade_xml_get_widget (xml, "new-store-entry"); - gnome_entry_load_history (GNOME_ENTRY (new_store_gnome_entry)); - gtk_main (); - gnome_entry_save_history (GNOME_ENTRY (new_store_gnome_entry)); - - return 0; -} - diff --git a/tests/ui-tests/store_listing.glade b/tests/ui-tests/store_listing.glade deleted file mode 100644 index d551c90dbb..0000000000 --- a/tests/ui-tests/store_listing.glade +++ /dev/null @@ -1,489 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>store_listing</name> - <program_name>store_listing</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <use_widget_names>False</use_widget_names> - <output_main_file>True</output_main_file> - <output_support_files>True</output_support_files> - <output_build_files>True</output_build_files> - <backup_source_files>True</backup_source_files> - <main_source_file>interface.c</main_source_file> - <main_header_file>interface.h</main_header_file> - <handler_source_file>callbacks.c</handler_source_file> - <handler_header_file>callbacks.h</handler_header_file> - <support_source_file>support.c</support_source_file> - <support_header_file>support.h</support_header_file> - <translatable_strings_file></translatable_strings_file> -</project> - -<widget> - <class>GnomeApp</class> - <name>app1</name> - <width>600</width> - <height>400</height> - <title>store_listing</title> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - <enable_layout_config>True</enable_layout_config> - - <widget> - <class>GnomeDock</class> - <child_name>GnomeApp:dock</child_name> - <name>dock1</name> - <allow_floating>True</allow_floating> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GnomeDockItem</class> - <name>dockitem1</name> - <border_width>2</border_width> - <placement>GNOME_DOCK_TOP</placement> - <band>0</band> - <position>0</position> - <offset>0</offset> - <locked>False</locked> - <exclusive>True</exclusive> - <never_floating>False</never_floating> - <never_vertical>True</never_vertical> - <never_horizontal>False</never_horizontal> - <shadow_type>GTK_SHADOW_OUT</shadow_type> - - <widget> - <class>GtkMenuBar</class> - <name>menubar1</name> - <shadow_type>GTK_SHADOW_NONE</shadow_type> - - <widget> - <class>GtkMenuItem</class> - <name>file1</name> - <stock_item>GNOMEUIINFO_MENU_FILE_TREE</stock_item> - - <widget> - <class>GtkMenu</class> - <name>file1_menu</name> - - <widget> - <class>GtkMenuItem</class> - <name>separator1</name> - <right_justify>False</right_justify> - </widget> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>exit</name> - <signal> - <name>activate</name> - <handler>on_exit_activate</handler> - <last_modification_time>Tue, 10 Aug 1999 12:06:35 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_EXIT_ITEM</stock_item> - </widget> - </widget> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>store2</name> - <label>_Store</label> - <right_justify>False</right_justify> - - <widget> - <class>GtkMenu</class> - <name>store2_menu</name> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>new_store</name> - <signal> - <name>activate</name> - <handler>on_new_store_activate</handler> - <last_modification_time>Tue, 10 Aug 1999 10:29:12 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_NEW_ITEM</stock_item> - <label>_New store</label> - </widget> - </widget> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>folder1</name> - <signal> - <name>activate</name> - <handler>on_folder1_activate</handler> - <last_modification_time>Sat, 14 Aug 1999 17:23:25 GMT</last_modification_time> - </signal> - <label>Folder</label> - <right_justify>False</right_justify> - - <widget> - <class>GtkMenu</class> - <name>folder1_menu</name> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>expunge</name> - <signal> - <name>activate</name> - <handler>on_expunge_activate</handler> - <last_modification_time>Sat, 14 Aug 1999 16:36:03 GMT</last_modification_time> - </signal> - <label>_Expunge</label> - <right_justify>False</right_justify> - <stock_icon>GNOME_STOCK_MENU_CONVERT</stock_icon> - </widget> - </widget> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>message_menu</name> - <label>_Message</label> - <right_justify>False</right_justify> - - <widget> - <class>GtkMenu</class> - <name>message_menu_menu</name> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>message_delete</name> - <signal> - <name>activate</name> - <handler>on_message_delete_activate</handler> - <last_modification_time>Sat, 14 Aug 1999 14:54:04 GMT</last_modification_time> - </signal> - <label>_Delete</label> - <right_justify>False</right_justify> - <stock_icon>GNOME_STOCK_MENU_TRASH</stock_icon> - </widget> - </widget> - </widget> - - <widget> - <class>GtkMenuItem</class> - <name>help1</name> - <stock_item>GNOMEUIINFO_MENU_HELP_TREE</stock_item> - - <widget> - <class>GtkMenu</class> - <name>help1_menu</name> - - <widget> - <class>GtkPixmapMenuItem</class> - <name>about</name> - <signal> - <name>activate</name> - <handler>on_about_activate</handler> - <last_modification_time>Tue, 10 Aug 1999 12:06:58 GMT</last_modification_time> - </signal> - <stock_item>GNOMEUIINFO_MENU_ABOUT_ITEM</stock_item> - </widget> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GnomeDockItem</class> - <name>dockitem2</name> - <border_width>1</border_width> - <placement>GNOME_DOCK_TOP</placement> - <band>1</band> - <position>0</position> - <offset>0</offset> - <locked>False</locked> - <exclusive>True</exclusive> - <never_floating>False</never_floating> - <never_vertical>False</never_vertical> - <never_horizontal>False</never_horizontal> - <shadow_type>GTK_SHADOW_OUT</shadow_type> - - <widget> - <class>GtkToolbar</class> - <name>toolbar1</name> - <border_width>1</border_width> - <orientation>GTK_ORIENTATION_HORIZONTAL</orientation> - <type>GTK_TOOLBAR_BOTH</type> - <space_size>16</space_size> - <space_style>GTK_TOOLBAR_SPACE_LINE</space_style> - <relief>GTK_RELIEF_NONE</relief> - <tooltips>True</tooltips> - - <widget> - <class>GtkButton</class> - <child_name>Toolbar:button</child_name> - <name>new_store_button</name> - <signal> - <name>clicked</name> - <handler>on_new_store_activate</handler> - <last_modification_time>Tue, 10 Aug 1999 12:17:17 GMT</last_modification_time> - </signal> - <label>new store</label> - <stock_pixmap>GNOME_STOCK_PIXMAP_NEW</stock_pixmap> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHPaned</class> - <child_name>GnomeDock:contents</child_name> - <name>hpaned1</name> - <handle_size>10</handle_size> - <gutter_size>6</gutter_size> - <position>0</position> - - <widget> - <class>GtkCTree</class> - <name>store-and-mailbox-tree</name> - <width>150</width> - <can_focus>True</can_focus> - <signal> - <name>button_press_event</name> - <handler>on_store_and_mailbox_tree_button_press_event</handler> - <last_modification_time>Mon, 16 Aug 1999 13:06:15 GMT</last_modification_time> - </signal> - <columns>1</columns> - <column_widths>80</column_widths> - <selection_mode>GTK_SELECTION_SINGLE</selection_mode> - <show_titles>True</show_titles> - <shadow_type>GTK_SHADOW_IN</shadow_type> - <child> - <shrink>True</shrink> - <resize>False</resize> - </child> - - <widget> - <class>GtkLabel</class> - <child_name>CTree:title</child_name> - <name>store_and_inbox_name</name> - <label>name</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - - <widget> - <class>GtkCList</class> - <name>message-clist</name> - <can_focus>True</can_focus> - <columns>3</columns> - <column_widths>80,80,80</column_widths> - <selection_mode>GTK_SELECTION_SINGLE</selection_mode> - <show_titles>True</show_titles> - <shadow_type>GTK_SHADOW_IN</shadow_type> - <child> - <shrink>True</shrink> - <resize>True</resize> - </child> - - <widget> - <class>GtkLabel</class> - <child_name>CList:title</child_name> - <name>message_date_label</name> - <label>Date</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>CList:title</child_name> - <name>message_sender_label</name> - <label>Sender</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>CList:title</child_name> - <name>message_subject_label</name> - <label>Subject</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GnomeAppBar</class> - <child_name>GnomeApp:appbar</child_name> - <name>appbar1</name> - <has_progress>True</has_progress> - <has_status>True</has_status> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> -</widget> - -<widget> - <class>GnomeAbout</class> - <name>about_widget</name> - <visible>False</visible> - <modal>True</modal> - <copyright></copyright> - <authors>Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> -</authors> - <comments>This is a very simple program to test Camel</comments> -</widget> - -<widget> - <class>GnomeDialog</class> - <name>new_store_dialog</name> - <visible>False</visible> - <title>New store</title> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>False</allow_grow> - <auto_shrink>False</auto_shrink> - <auto_close>True</auto_close> - <hide_on_close>True</hide_on_close> - - <widget> - <class>GtkVBox</class> - <child_name>GnomeDialog:vbox</child_name> - <name>dialog-vbox1</name> - <homogeneous>False</homogeneous> - <spacing>8</spacing> - <child> - <padding>4</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox1</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>new_store_label</name> - <label>Enter complete store URL</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>29</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GnomeEntry</class> - <name>new-store-entry</name> - <history_id>store_name_history</history_id> - <max_saved>15</max_saved> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GtkEntry</class> - <child_name>GnomeEntry:entry</child_name> - <name>new-store-dialog-combo-entry</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHButtonBox</class> - <child_name>GnomeDialog:action_area</child_name> - <name>dialog-action_area1</name> - <layout_style>GTK_BUTTONBOX_END</layout_style> - <spacing>8</spacing> - <child_min_width>85</child_min_width> - <child_min_height>27</child_min_height> - <child_ipad_x>7</child_ipad_x> - <child_ipad_y>0</child_ipad_y> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - <pack>GTK_PACK_END</pack> - </child> - - <widget> - <class>GtkButton</class> - <name>button1</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> - </widget> - - <widget> - <class>GtkButton</class> - <name>button2</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button> - </widget> - - <widget> - <class>GtkButton</class> - <name>button3</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/widgets/.cvsignore b/widgets/.cvsignore deleted file mode 100644 index 0963d457d9..0000000000 --- a/widgets/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la -table-test diff --git a/widgets/ChangeLog b/widgets/ChangeLog deleted file mode 100644 index 76e918b61d..0000000000 --- a/widgets/ChangeLog +++ /dev/null @@ -1,430 +0,0 @@ -1999-12-01 Miguel de Icaza <miguel@gnu.org> - - * e-cell-text.c (ect_draw): Keep track of the originally allocated - piece of code. - - * e-table-header-item.c (ethi_unrealize): Removed change cursor - from here. - - * e-cell-text.c (ect_draw): Memory leak fix. - - * table-test.c (main): Enhance the demo to load sample.table - automatically, to get memprof working. - - * e-table-header.c (eth_do_remove): Take an argument: do -remove. - - * e-table-header.c (e_table_header_add_column): Sink ETableCol to - own the object. - - * e-table-col.h: Made ETableCol a GtkObject to make reference - counting the lifecycle method for these objects. - - * e-table-col.c (e_table_col_destroy): New API call. - - * e-table-subset.c (e_table_subset_get_toplevel): New API call. - -1999-11-30 Miguel de Icaza <miguel@gnu.org> - - * e-cell-checkbox.c (e_cell_checkbox_new): This one derives from - e-cell-toggle. - - * check-emtpy.xpm, check-filled.xpm: new files. - - * e-cell-toggle.c (etog_draw): Paint in white. - If we have transparency enabled, do the nice alpha computation. - - * test-table.c, test-cols.c: new files; They implement the split - tests. - -1999-11-29 Miguel de Icaza <miguel@gnu.org> - - * e-table-col.c (e_table_col_new): Set etc->resizeable. - - * e-table-header-item.c (ethi_event): Handle non-resizeables - columns; Add support for minimum width. - - * e-cell-toggle.c, e-cell-toggle.h: New file. Implement a - multi-state image toggle cell object. - - * e-cell-text.c (ect_leave_edit): Handle the case of us calling - leave edit manually. - (ect_stop_editing): Leave manually editing here. - (ect_draw): Add one pixel to the border for left and right; - Handle off-screen cursor (must be improved). - (ect_edit_select_all): New function. - (ect_event): Select all text on editing start - - * e-table-item.c (eti_event): Map mouse events and dispatch them. - (eti_event): Add spreadsheet mode for editing; Enter editing only - with visual characters; - Leave editing mode when a different row has been selected. - (eti_get_height): Fix the computation for this; Fix logic for the - length_threshold. - - (eti_draw): Add borders on all sides of the box; - Only draw focus if the cell is not being edited. - -1999-11-28 Miguel de Icaza <miguel@gnu.org> - - * e-table-item.c (eti_draw): Focus inside, not outside. - (eti_realize): Enhance our focus gc. - - * e-cell-text.c (ect_enter_edit, ect_leave_edit): New methods; - They implement editing. - - * e-cell.h: new methods: enter_edit, leave_edit - - * e-table-model.h (set_value_at): make val argument const. - - * e-table-simple.c (simple_set_value_at): Make value argument const; - - * e-table-item.c (eti_set_arg): Add new mode: draw_focus; - -1999-11-27 Miguel de Icaza <miguel@gnu.org> - - * e-table-item.c (eti_event): beginning of the keyboard navigation. - - * e-table-model.c (e_table_model_row_changed): new function. - (e_table_model_cell_changed): new function. - (e_table_model_class_init): New signals. - - * e-table-item.c (eti_request_region_redraw): x2, y2 offsets were - wrong. - (eti_select): Repaint selected region. - (eti_request_region_redraw): Fix range. - (eti_draw): Correct offset computation here. - (e_table_item_class_init): New method: row_selection, handles the - selection. - - Now it implement GTK_SELECTION_SINGLE and GTK_SELECTION_MULTIPLE. - - Focusing and selection should be correct now. - -1999-11-26 Miguel de Icaza <miguel@gnu.org> - - * e-table-item.c (eti_realize): Compute height using the ecell - methods here. - (eti_get_height): new method to compute dimensions. - - * e-cursors.c: use a different cursor. - - * e-table-model.h: kill height and row_height methods. - - * e-cell.c (ec_height): New method. - - * e-cell-text.c (ect_realize): Load the font from the canvas. - (ect_draw): New color setup. - Center in the row. - (ect_height): Implement new method. - -1999-11-26 Michael Meeks <mmeeks@gnu.org> - - * ROADMAP.e-table: small spelling/typo fixes. - -1999-11-25 Miguel de Icaza <miguel@gnu.org> - - * e-table-item.c (eti_event): Work on mouse-button event - propagation to cells. - - * e-cell-text.c (ect_draw): Use CellViews now. - - * e-table-item.c (eti_realize_cell_views): New routine: Realizes - the cell views - (eti_unrealize_cell_views): New routine: unrealizes the cell views. - - * e-table-item.h: Move cell_views array here. - - * table-test.c (value_at): Fix return value. - (main): use new invocation method. - - * e-table-header-item.c (ethi_realize): Realize cells. - - * e-table-item.c (eti_header_dim_changed): redraw before and after. - - * e-table-header-item.c (ethi_event): Add continuous resizing. - -1999-11-24 Miguel de Icaza <miguel@gnu.org> - - * e-table-subset.h, e-table-subset.c: New files, used to implement - subset tables. - - * e-table-sorted.h, e-table-sorted.c: Now they derive from - e-table-subset. - - * e-cell.c, e-cell.h: realize method now return per view instance - data. - -1999-11-20 Miguel de Icaza <miguel@gnu.org> - - * e-table-item.c (eti_draw): WOOOOHOOOOOoO! It took me quite a - while to figure this one out. Fixed. - - * e-table-header-item.c (ethi_set_arg): Compute width, keep track - of it. - (ethi_add_table_header): Monitor changes to the Header model; - Queue updates. - (ethi_draw): Fix the redraw logic here. - - * table-test.c (main): Change the sample code, so we can better - debug this. - - * e-table-item.c (eti_header_structure_changed): Keep track of - width; - (eti_header_dim_changed): ditto. - (eti_draw): Many redraw fixes. - -1999-11-19 Miguel de Icaza <miguel@gnu.org> - - * e-table-item.c (eti_realize): Hook up; Load gcs. - (eti_unrealize): Hook up. - - * e-table-sorted.c: Finished implementing. - -1999-11-18 Miguel de Icaza <miguel@gnu.org> - - * e-table-model.c (e_table_model_class_init): Add model_changed - signal here. - - * e-table-item.c, e-table-item.h: New files. They implement the - view of the ETableModel as Canvas Items. - - * e-table-header-item.c (ethi_set_arg): Ref header here. - (ethi_destroy): Unref it here. - -1999-11-17 Ettore Perazzoli <ettore@gnu.org> - - * e-msg-composer-address-dialog.c: Moved to `$(srcdir)/composer'. - * e-msg-composer-address-dialog.h: Likewise. - * e-msg-composer-address-entry.c: Likewise. - * e-msg-composer-address-entry.h: Likewise. - * e-msg-composer-attachment-bar.c: Likewise. - * e-msg-composer-attachment-bar.h: Likewise. - * e-msg-composer-attachment.c: Likewise. - * e-msg-composer-attachment.h: Likewise. - * e-msg-composer-hdrs.c: Likewise. - * e-msg-composer-hdrs.h: Likewise. - * e-msg-composer.c: Likewise. - * e-msg-composer.h: Likewise. - * e-msg-composer-address-dialog.glade: Likewise. - * e-msg-composer-attachment.glade: Likewise. - * e-msg-composer.glade: Likewise. - * Makefile.am: Updated accordingly. - -Nov 14 1999 Elliot Lee - * Makefile.am: It's libevolutionwidgets.la, not .a - -1999-11-14 Miguel de Icaza <miguel@gnu.org> - - * e-table-header-item.c (is_pointer_on_division): Add resizing - capabilities. - - * e-table-sorted.c: Finish implementation. - -1999-11-13 Miguel de Icaza <miguel@gnu.org> - - * e-table-sorted.c: Implement e-table-sorted object. - -1999-11-12 Miguel de Icaza <miguel@gnu.org> - - * e-table-header-item.c: Make the thing configurable. - - * e-table-header-item.h: Add font field, location, height. - -1999-11-12 Ettore Perazzoli <ettore@gnu.org> - - * e-msg-composer-hdrs.c: New member `tooltips' in `struct - _EMsgComposerHdrsPrivate'. - (init): Initialize it. - (destroy): New function. - (class_init): Install it as the `destroy' GtkObject method. - (add_header): New parameters `tip', `tip_private'. Setup a - tooltip for the entry with them. - (setup_headers): Updated accordingly. - -1999-11-11 Miguel de Icaza <miguel@gnu.org> - - * e-table-header.c (e_table_header_add_column): Update offsets. - (eth_update_offsets): New routine. - - * e-table-col.h, e-table-col.c: New files. - - * e-table-header.h (e_table_header_get_selected_indexes): - Pretify. - - * table-test.c (main): New file; used for testing ETable package. - - * e-table-simple.h: Fix type. - -1999-11-12 Ettore Perazzoli <ettore@gnu.org> - - * e-msg-composer-address-dialog.glade: Cosmetical changes. - - * e-msg-composer-attachment-bar.c (size_to_string): New helper - function. - (update): Put the size in the icon's label using this function. - (ICON_SEPARATORS): Remove '.' to avoid wrapping of the size string - on the decimal dot. But gnome-libs is broken and this has no real - effect! :-( - (e_msg_composer_attachment_bar_new): No longer make text editable. - Use the `GTK_SELECTION_MULTIPLE' selection mode. - (remove_selected): No longer assume only one attachment is - selected. - - * e-msg-composer-attachment.c: #include <sys/stat.h> - (init): Initialize all the members. - (e_msg_composer_attachment_new): Set size using `stat()'. - - * e-msg-composer-attachment.h: New member `size' in `struct - _EMsgComposerAttachment'. - - * e-msg-composer.c (setup_signals): Connect `address_dialog_cb' to - the "show_address_dialog" signal of the header widget. - - * e-msg-composer-hdrs.c (add_address_header): Renamed to - `add_header'. New parameter `addrbook_button': if true, use a - button instead of a label and make it trigger an - "show_address_dialog" signal. - (address_button_clicked_cb): Signal handler to handle this on a - "clicked" signal from the button. - (setup_headers): Updated accordingly. Also, make "Subject" the - last item. (This makes it look more like Outlook and friends.) - - * e-msg-composer-hdrs.c: New signal "show_address_dialog". - * e-msg-composer-hdrs.h: Updated accordingly. - - * e-msg-composer-hdrs.c (add_address_header): Reduce padding - considerably. - - * e-msg-composer.c (e_msg_composer_construct): Do not use any - padding in the main vbox. - - * Makefile.am: Moved the `e-table*' sources to `EXTRA_DIST'. - Compile as a shared library. - -1999-11-08 Ettore Perazzoli <ettore@gnu.org> - - * e-msg-composer-address-dialog.c: Implemented cut & paste for the - recipient lists. - (init): Initialize `cut_buffer'. - (destroy): Free it. - (recipient_clist_selection_get_cb): New function. - (recipient_clist_selection_received_cb): New function. - (recipient_clist_selection_clear_event_cb): New function. - (setup_recipient_list_signals): Install them as signal handlers - for "selection_get", "selection_received" and - "selection_clear_event" respectively. - (copy_recipient_cb): New function implementing the "copy" - operation. - (cut_recipient_cb): New function implementing the "cut" operation. - (paste_recipient_cb): New function implementing the "paste" - operation. - - * e-msg-composer-address-dialog.h: New member `cut_buffer' in - `struct _EMsgComposerAddressDialog'. - -1999-11-07 Ettore Perazzoli <ettore@gnu.org> - - * e-msg-composer-address-dialog.c: New context menu - `recipient_list_popup_info' for the recipient CLists. - (recipient_clist_button_press_cb): New function. - (setup_signals): Install it as the "button_press_event" signal - handler for popping up the CList context menu. - - * e-msg-composer.c (free_string_list): New helper function. - (setup_address_dialog): Setup the initial values in the address - dialog according to the ones in the header widget. - - * e-msg-composer-hdrs.c (e_msg_composer_hdrs_get_to): New function. - (e_msg_composer_hdrs_get_cc): New function. - (e_msg_composer_hdrs_get_bcc): New function. - - * e-msg-composer.c (setup_address_dialog): New helper function. - (address_dialog_cb): Use it. - - * e-msg-composer-address-dialog.c (add_address): Do not set the - row data anymore. Instead, put the full address description - (i.e. complete with the email address, not just the full name) in - the CList. - (add_address): Do nothing if no item is selected in the address - CList. - (get_list): Get the address list from the CList without passing - through the address CList. - (set_list): New helper function. - (e_msg_composer_address_dialog_set_to_list): New function. - (e_msg_composer_address_dialog_set_cc_list): New function. - (e_msg_composer_address_dialog_set_bcc_list): New function. - - * e-msg-composer.c (address_dialog_apply_cb): Apply values from - the address dialog into the composer. - - * e-msg-composer-hdrs.c (e_msg_composer_hdrs_set_to): New function. - (e_msg_composer_hdrs_set_cc): New function. - (e_msg_composer_hdrs_set_bcc): New function. - - * e-msg-composer-address-entry.c - (e_msg_composer_address_entry_set_list): New function. - - * e-msg-composer-address-dialog.c (apply): New helper function. - (clicked): New function, `clicked' method for the `GnomeDialog' - class. - (class_init): Install it. - -1999-11-06 Ettore Perazzoli <ettore@gnu.org> - - * e-msg-composer-attachment-bar.c (destroy): Call the destroy - method of the parent class. - - * e-msg-composer.c: #include "e-msg-composer-address-dialog.h". - (address_dialog_cb): New callback to start the address dialog. - (setup_signals): Connect it to the appropriate button/menu item. - (init): Initialize the new `address_dialog' member to NULL. - (destroy): Destroy the `address_dialog' if not NULL. - - * e-msg-composer.h: New member `address_dialog' in `struct - _EMsgComposer'. - - * e-msg-composer.glade: Added button to activate the address - composition dialog. - - * e-msg-composer-address-dialog.h, e-msg-composer-address-dialog.c: - New files implementing the address composition dialog for Evolution. - - * e-msg-composer-address-dialog.glade: New file. - - * e-msg-composer-attachment.c: `signals' made static. - -1999-11-05 Ettore Perazzoli <ettore@gnu.org> - - * Makefile.am: Compile the new files in a `libevolutionwidgets' - library. - (CPPFLAGS): #define `E_GUIDIR'. - - * e-msg-composer.c, e-msg-composer.h: New files implementing an - initial version of the Evolution message composer widget. - - * e-msg-composer-address-entry.c, e-msg-composer-address-entry.h: - New files implementing a GtkEntry customized for entering email - address lists. - - * e-msg-composer-attachment-bar.c, e-msg-composer-attachment-bar.h: - New files implementing a widget for editing mail attachments. - - * e-msg-composer-attachment.c, e-msg-composer-attachment.h: New - files implementing file attachment objects for the message - composer. - - * e-msg-composer-hdrs.c, e-msg-composer-hdrs.h: New files - implementing a widget for editing of email message headers. - - * e-msg-composer-attachment.glade: New file. - * e-msg-composer.glade: New file. - -1999-10-31 Miguel de Icaza <miguel@gnu.org> - - * widgets/e-table-column.c, e-table-column.h: New file, implements the - e-table-column object. - - * widget/e-table-model.h, e-table-model.c, e-table-simple.c, - e-table-simple.h: New files. Implements the column model and - a simple table wrapper. - diff --git a/widgets/Makefile.am b/widgets/Makefile.am deleted file mode 100644 index 1b237dce70..0000000000 --- a/widgets/Makefile.am +++ /dev/null @@ -1,55 +0,0 @@ -INCLUDES = \ - -I$(top_srcdir)/camel \ - -I$(top_builddir)/camel \ - $(GNOME_INCLUDEDIR) - -noinst_LIBRARIES = \ - libevolutionwidgets.a - -libevolutionwidgets_a_SOURCES = \ - e-cell.c \ - e-cell.h \ - e-cell-checkbox.c \ - e-cell-checkbox.h \ - e-cell-text.c \ - e-cell-text.h \ - e-cell-toggle.c \ - e-cell-toggle.h \ - e-cursors.c \ - e-cursors.h \ - e-table-col.c \ - e-table-col.h \ - e-table-group.c \ - e-table-group.h \ - e-table-header.c \ - e-table-header.h \ - e-table-header-item.c \ - e-table-header-item.h \ - e-table-item.c \ - e-table-item.h \ - e-table-model.c \ - e-table-model.h \ - e-table-simple.c \ - e-table-simple.h \ - e-table-sorted.c \ - e-table-sorted.h - -noinst_PROGRAMS = \ - table-test - -table_test_SOURCES = \ - test-table.c \ - test-check.c \ - test-cols.c \ - table-test.c - -table_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - libevolutionwidgets.a - -table_test_LDFLAGS = `gnome-config --libs gdk_pixbuf` - -EXTRA_DIST = \ - sample.table \ - check-empty.xpm \ - check-filled.xpm diff --git a/widgets/ROADMAP.e-table b/widgets/ROADMAP.e-table deleted file mode 100644 index 08340f433c..0000000000 --- a/widgets/ROADMAP.e-table +++ /dev/null @@ -1,98 +0,0 @@ - -The E-Table package implements an editable table that provides -user-defined rendering, user-defined editing, sorting and grouping of -the objects displayed. - -It is inspired by Java's Swing JTable object. There are models for -the actual table contents and for the table headers; they are the -actual repository of information. - -The objects are rendered by various view objects. In the current code -base, we use we use GnomeCanvasItems to do the rendering. One for -each table and one for the headers. - -* The Models - -All of them are GtkObjects. - -e-table-model.h, e-table-model.c: - - These implement the abstract E-Table-Model class. You - can derive this object to create your own data repository. - - These emits signals to notify the views about selection, and - changes in the model. - -e-table-simple.h, e-table-simple.c: - - A simple implementation of e-table-model that uses callback - routines (you provide the callbacks). For lazy people, like - me. - -e-cell.c, e-cell.h: - - These are actually mis-named. Objects of type e-cell know - about rendering a single cell, and these are attached to the - e-table-cols (described next). - - The user provides the various rendering modes as e-cells (they - are actually column-rendering repositories). - - This is just an abstract class. I will provide various - e-cells: a text cell, a checkbox cell, an image cell, and - perhaps an n-state image cell (one that switches the image when - the cell is clicked). - -e-table-col.h, e-table-col.c: - - Describes a single column (the size, the string displayed, the - rendering function for each row and comparison function for - this field). - - -* The Views - -e-table-header.h, e-table-header.c: - - These implement the ETableHeaderItem canvas item. This item is - used both to control the columns displayed as well as displaying them. - - They describe what columns are shown in the screen and in - which order. - - These emit signals: column-size-changed and structure-changed - (if a column is added/removed) - -e-table-item.c, e-table-item.h - - This is a canvas item that renders the contents of a - ETableModel into the screen. - -e-table-header-item.c, e-table-header-item.h - - This canvas item renders the ETableHeader headings. - -e-cell-text.c, e-cell-text.h - - Not really a view, but actually a derivative of e-cell that - implements text display: supports justification and font - setting. Will add color in the future most likely - - -* The Filters - -e-table-sorted.c, e-table-sorted.h - - This is an ETableModel that can sort an existing ETableModel. - -e-table-subset.c, e-table-subset.h - - Not finished, but it is just an ETableModel that happens to be - a subset of another ETableModel. - -* Everything - -e-table.c, e-table.h - - In the future these guys will implement the whole widget for - doing table editing. Nothing done about these yet. diff --git a/widgets/TODO b/widgets/TODO deleted file mode 100644 index 20d491b4fa..0000000000 --- a/widgets/TODO +++ /dev/null @@ -1,20 +0,0 @@ -Implement e-cell-height -Implement computation of heights from the e-cell-heights -Make sure we compute the height from that -Include spacing in columns and rows for the decoration lines -Add threshold to compute a "global" size -Implement the two methods for row finding: by full thing, or by a factor. - - -Add editing -mouse grabbing for scrolling - - -1. Make sure that all values are updated on header changes and table - model changes (they are slightly out of sync now) - -* Correctness - - * Make sure we can boot and shutdown with no memory leaks. - - * Run Insure on the thing. diff --git a/widgets/check-empty.xpm b/widgets/check-empty.xpm deleted file mode 100644 index 2dd873e137..0000000000 --- a/widgets/check-empty.xpm +++ /dev/null @@ -1,21 +0,0 @@ -/* XPM */ -static char * check_empty_xpm[] = { -"16 16 2 1", -" c None", -". c #000000", -" ", -" ", -" ............ ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" ............ ", -" ", -" "}; diff --git a/widgets/check-filled.xpm b/widgets/check-filled.xpm deleted file mode 100644 index 689d7a7967..0000000000 --- a/widgets/check-filled.xpm +++ /dev/null @@ -1,21 +0,0 @@ -/* XPM */ -static char * check_filled_xpm[] = { -"16 16 2 1", -" c None", -". c #000000", -" ", -" ", -" ............ ", -" . . ", -" . . . ", -" . .. . ", -" . ... . ", -" . . ... . ", -" . .. ... . ", -" . ..... . ", -" . ... . ", -" . . . ", -" . . ", -" ............ ", -" ", -" "}; diff --git a/widgets/e-cell-checkbox.c b/widgets/e-cell-checkbox.c deleted file mode 100644 index 73620b9ce4..0000000000 --- a/widgets/e-cell-checkbox.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * e-cell-checkbox.c: Checkbox cell renderer - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkenums.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtksignal.h> -#include <gdk/gdkkeysyms.h> -#include <libgnomeui/gnome-canvas.h> -#include "e-cell-checkbox.h" -#include "e-util.h" -#include "e-table-item.h" - -#include "check-empty.xpm" -#include "check-filled.xpm" - -#define PARENT_TYPE e_cell_toggle_get_type() - -static GdkPixbuf *checks [2]; - -static void -e_cell_checkbox_class_init (GtkObjectClass *object_class) -{ - checks [0] = gdk_pixbuf_new_from_xpm_data (check_empty_xpm); - checks [1] = gdk_pixbuf_new_from_xpm_data (check_filled_xpm); -} - -E_MAKE_TYPE(e_cell_checkbox, "ECellCheckbox", ECellCheckbox, e_cell_checkbox_class_init, NULL, PARENT_TYPE); - -ECell * -e_cell_checkbox_new (ETableModel *etm) -{ - ECellCheckbox *eccb = gtk_type_new (e_cell_checkbox_get_type ()); - - e_cell_toggle_construct (E_CELL_TOGGLE (eccb), etm, 2, 2, checks); - - return (ECell *) eccb; -} diff --git a/widgets/e-cell-checkbox.h b/widgets/e-cell-checkbox.h deleted file mode 100644 index 6afca6bde2..0000000000 --- a/widgets/e-cell-checkbox.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _E_CELL_CHECKBOX_H_ -#define _E_CELL_CHECKBOX_H_ - -#include "e-cell-toggle.h" - -#define E_CELL_CHECKBOX_TYPE (e_cell_checkbox_get_type ()) -#define E_CELL_CHECKBOX(o) (GTK_CHECK_CAST ((o), E_CELL_CHECKBOX_TYPE, ECellCheckbox)) -#define E_CELL_CHECKBOX_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_CHECKBOX_TYPE, ECellCheckboxClass)) -#define E_IS_CELL_CHECKBOX(o) (GTK_CHECK_TYPE ((o), E_CELL_CHECKBOX_TYPE)) -#define E_IS_CELL_CHECKBOX_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_CHECKBOX_TYPE)) - -typedef struct { - ECellToggle parent; -} ECellCheckbox; - -typedef struct { - ECellToggleClass parent_class; -} ECellCheckboxClass; - -GtkType e_cell_checkbox_get_type (void); -ECell *e_cell_checkbox_new (ETableModel *model); - -#endif /* _E_CELL_CHECKBOX_H_ */ - diff --git a/widgets/e-cell-string.c b/widgets/e-cell-string.c deleted file mode 100644 index 992b1bd10e..0000000000 --- a/widgets/e-cell-string.c +++ /dev/null @@ -1,9 +0,0 @@ -ECell * -e_cell_string_new (void) -{ - ECell *ecell; - - ecell = gtk_type_new (ecell); - - return ecell; -} diff --git a/widgets/e-cell-text.c b/widgets/e-cell-text.c deleted file mode 100644 index d9d8a568db..0000000000 --- a/widgets/e-cell-text.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - * e-cell-text.c: Text cell renderer - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkenums.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtksignal.h> -#include <gdk/gdkkeysyms.h> -#include <libgnomeui/gnome-canvas.h> -#include "e-cell-text.h" -#include "e-util.h" -#include "e-table-item.h" - -#define PARENT_TYPE e_cell_get_type() - -#define TEXT_PAD 2 - -typedef struct { - char *old_text; - GtkWidget *entry_top; - GtkEntry *entry; - - /* - * Where the editing is taking place - */ - int col, row; -} CellEdit; - -typedef struct { - ECellView cell_view; - GdkGC *gc; - GdkFont *font; - GnomeCanvas *canvas; - ETableItem *eti; - - /* - * During edition. - */ - CellEdit *edit; -} ECellTextView; - -static ECellClass *parent_class; - -static void -ect_queue_redraw (ECellTextView *text_view, int col, int row) -{ - e_table_item_redraw_range (text_view->eti, col, row, col, row); -} - -/* - * Accept the currently edited text - */ -static void -ect_accept_edits (ECellTextView *text_view) -{ - const char *text = gtk_entry_get_text (text_view->edit->entry); - CellEdit *edit = text_view->edit; - - e_table_model_set_value_at (text_view->eti->table_model, edit->col, edit->row, text); -} - -/* - * Shuts down the editing process - */ -static void -ect_stop_editing (ECellTextView *text_view) -{ - CellEdit *edit = text_view->edit; - - g_free (edit->old_text); - edit->old_text = NULL; - gtk_widget_destroy (edit->entry_top); - edit->entry_top = NULL; - edit->entry = NULL; - - g_free (edit); - - text_view->edit = NULL; - - e_table_item_leave_edit (text_view->eti); -} - -/* - * Cancels the edits - */ -static void -ect_cancel_edit (ECellTextView *text_view) -{ - ect_queue_redraw (text_view, text_view->edit->col, text_view->edit->row); - ect_stop_editing (text_view); -} - -/* - * ECell::realize method - */ -static ECellView * -ect_realize (ECell *ecell, void *view) -{ - ECellText *ect = E_CELL_TEXT (ecell); - ECellTextView *text_view = g_new0 (ECellTextView, 1); - ETableItem *eti = E_TABLE_ITEM (view); - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - - text_view->cell_view.ecell = ecell; - text_view->gc = gdk_gc_new (GTK_WIDGET (canvas)->window); - if (ect->font_name){ - GdkFont *f; - - f = gdk_fontset_load (ect->font_name); - text_view->font = f; - } - if (!text_view->font){ - text_view->font = GTK_WIDGET (canvas)->style->font; - - gdk_font_ref (text_view->font); - } - - text_view->eti = eti; - text_view->canvas = canvas; - - return (ECellView *)text_view; -} - -/* - * ECell::unrealize method - */ -static void -ect_unrealize (ECellView *ecv) -{ - ECellTextView *text_view = (ECellTextView *) ecv; - - gdk_gc_unref (text_view->gc); - text_view->gc = NULL; - - gdk_font_unref (text_view->font); - text_view->font = NULL; - - g_free (text_view); -} - -/* - * ECell::draw method - */ -static void -ect_draw (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, - int x1, int y1, int x2, int y2) -{ - ECellText *ect = E_CELL_TEXT (ecell_view->ecell); - ECellTextView *text_view = (ECellTextView *) ecell_view; - GtkWidget *w = GTK_WIDGET (text_view->canvas); - GdkRectangle rect; - const char *str = e_table_model_value_at (ecell_view->ecell->table_model, col, row); - GdkFont *font = text_view->font; - const int height = font->ascent + font->descent; - int xoff; - gboolean edit_display = FALSE; - - /* - * Figure if this cell is being edited - */ - if (text_view->edit){ - CellEdit *edit = text_view->edit; - - if ((edit->col == col) && (edit->row == row)) - edit_display = TRUE; - } - - /* - * Be a nice citizen: clip to the region we are supposed to draw on - */ - rect.x = x1; - rect.y = y1; - rect.width = x2 - x1; - rect.height = y2 - y1; - gdk_gc_set_clip_rectangle (text_view->gc, &rect); - - if (edit_display){ - CellEdit *edit = text_view->edit; - const char *text = gtk_entry_get_text (edit->entry); - GdkWChar *p, *text_wc = g_new (GdkWChar, strlen (text) + 1); - int text_wc_len = gdk_mbstowcs (text_wc, text, strlen (text)); - const int cursor_pos = GTK_EDITABLE (edit->entry)->current_pos; - const int left_len = gdk_text_width_wc (text_view->font, text_wc, cursor_pos); - - text_wc [text_wc_len] = 0; - /* - * Paint - */ - gdk_gc_set_foreground (text_view->gc, &w->style->base [GTK_STATE_NORMAL]); - gdk_draw_rectangle (drawable, text_view->gc, TRUE, - rect.x, rect.y, rect.width, rect.height); - gdk_gc_set_foreground (text_view->gc, &w->style->text [GTK_STATE_NORMAL]); - - { - GdkGC *gc = text_view->gc; - const int y = y2 - font->descent - ((y2-y1-height)/2); - int px, i; - - /* - * Border - */ - x1 += 2; - x2--; - - px = x1; - - /* - * If the cursor is outside the visible range - * - * FIXME: we really want a better behaviour. - */ - if ((px + left_len) > x2) - px -= left_len - (x2-x1); - - for (i = 0, p = text_wc; *p; p++, i++){ - gdk_draw_text_wc ( - drawable, font, gc, px, y, p, 1); - - if (i == cursor_pos){ - gdk_draw_line ( - drawable, gc, - px, y - font->ascent, - px, y + font->descent - 1); - } - - px += gdk_text_width_wc (font, p, 1); - } - - if (i == cursor_pos){ - gdk_draw_line ( - drawable, gc, - px, y - font->ascent, - px, y + font->descent - 1); - } - } - g_free (text_wc); - } else { - /* - * Regular cell - */ - GdkColor *background, *foreground; - int width; - - /* - * Border - */ - x1++; - x2--; - - /* - * Compute draw mode - */ - switch (ect->justify){ - case GTK_JUSTIFY_LEFT: - xoff = 1; - break; - - case GTK_JUSTIFY_RIGHT: - width = 1 + gdk_text_width (font, str, strlen (str)); - xoff = (x2 - x1) - width; - break; - - case GTK_JUSTIFY_CENTER: - xoff = ((x2 - x1) - gdk_text_width (font, str, strlen (str))) / 2; - break; - default: - xoff = 0; - g_warning ("Can not handle GTK_JUSTIFY_FILL"); - break; - } - - - if (selected){ - background = &w->style->bg [GTK_STATE_SELECTED]; - foreground = &w->style->text [GTK_STATE_SELECTED]; - } else { - background = &w->style->base [GTK_STATE_NORMAL]; - foreground = &w->style->text [GTK_STATE_NORMAL]; - } - - gdk_gc_set_foreground (text_view->gc, background); - gdk_draw_rectangle (drawable, text_view->gc, TRUE, - rect.x, rect.y, rect.width, rect.height); - gdk_gc_set_foreground (text_view->gc, foreground); - - gdk_draw_string ( - drawable, font, text_view->gc, - x1 + xoff, - y2 - font->descent - ((y2-y1-height)/2), str); - } -} - -/* - * Selects the entire string - */ -static void -ect_edit_select_all (ECellTextView *text_view) -{ - g_assert (text_view->edit); - - gtk_editable_select_region (GTK_EDITABLE (text_view->edit->entry), 0, -1); -} - -/* - * ECell::event method - */ -static gint -ect_event (ECellView *ecell_view, GdkEvent *event, int col, int row) -{ - ECellTextView *text_view = (ECellTextView *) ecell_view; - - switch (event->type){ - case GDK_BUTTON_PRESS: - /* - * Adjust for the border we use - */ - event->button.x++; - - printf ("Button pressed at %g %g\n", event->button.x, event->button.y); - if (text_view->edit){ - printf ("FIXME: Should handle click here\n"); - } else - e_table_item_enter_edit (text_view->eti, col, row); - break; - - case GDK_BUTTON_RELEASE: - /* - * Adjust for the border we use - */ - event->button.x++; - printf ("Button released at %g %g\n", event->button.x, event->button.y); - return TRUE; - - case GDK_KEY_PRESS: - if (event->key.keyval == GDK_Escape){ - ect_cancel_edit (text_view); - return TRUE; - } - - if (!text_view->edit){ - e_table_item_enter_edit (text_view->eti, col, row); - ect_edit_select_all (text_view); - } - - gtk_widget_event (GTK_WIDGET (text_view->edit->entry), event); - ect_queue_redraw (text_view, col, row); - break; - - case GDK_KEY_RELEASE: - break; - - default: - return FALSE; - } - return TRUE; -} - -/* - * ECell::height method - */ -static int -ect_height (ECellView *ecell_view, int col, int row) -{ - ECellTextView *text_view = (ECellTextView *) ecell_view; - - return (text_view->font->ascent + text_view->font->descent) + TEXT_PAD; -} - -/* - * Callback: invoked when the user pressed "enter" on the GtkEntry - */ -static void -ect_entry_activate (GtkEntry *entry, ECellTextView *text_view) -{ - e_table_item_leave_edit (text_view->eti); -} - -/* - * ECellView::enter_edit method - */ -static void * -ect_enter_edit (ECellView *ecell_view, int col, int row) -{ - ECellTextView *text_view = (ECellTextView *) ecell_view; - const char *str = e_table_model_value_at (ecell_view->ecell->table_model, col, row); - CellEdit *edit; - - edit = g_new (CellEdit, 1); - text_view->edit = edit; - - edit->col = col; - edit->row = row; - - edit->entry = (GtkEntry *) gtk_entry_new (); - gtk_entry_set_text (edit->entry, str); - edit->old_text = g_strdup (str); - gtk_signal_connect (GTK_OBJECT (edit->entry), "activate", - GTK_SIGNAL_FUNC (ect_entry_activate), text_view); - - /* - * The hack: create this window off-screen - */ - edit->entry_top = gtk_window_new (GTK_WINDOW_POPUP); - gtk_container_add (GTK_CONTAINER (edit->entry_top), GTK_WIDGET (edit->entry)); - gtk_widget_set_uposition (edit->entry_top, 20000, 20000); - gtk_widget_show_all (edit->entry_top); - - ect_queue_redraw (text_view, col, row); - - return NULL; -} - -/* - * ECellView::leave_edit method - */ -static void -ect_leave_edit (ECellView *ecell_view, int col, int row, void *edit_context) -{ - ECellTextView *text_view = (ECellTextView *) ecell_view; - - if (text_view->edit){ - ect_accept_edits (text_view); - ect_stop_editing (text_view); - } else { - /* - * We did invoke this leave edit internally - */ - } -} - -/* - * GtkObject::destroy method - */ -static void -ect_destroy (GtkObject *object) -{ - ECellText *ect = E_CELL_TEXT (object); - - g_free (ect->font_name); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -static void -e_cell_text_class_init (GtkObjectClass *object_class) -{ - ECellClass *ecc = (ECellClass *) object_class; - - object_class->destroy = ect_destroy; - - ecc->realize = ect_realize; - ecc->unrealize = ect_unrealize; - ecc->draw = ect_draw; - ecc->event = ect_event; - ecc->height = ect_height; - ecc->enter_edit = ect_enter_edit; - ecc->leave_edit = ect_leave_edit; - - parent_class = gtk_type_class (PARENT_TYPE); -} - -E_MAKE_TYPE(e_cell_text, "ECellText", ECellText, e_cell_text_class_init, NULL, PARENT_TYPE); - -ECell * -e_cell_text_new (ETableModel *etm, const char *fontname, GtkJustification justify) -{ - ECellText *ect = gtk_type_new (e_cell_text_get_type ()); - - ect->font_name = g_strdup (fontname); - ect->justify = justify; - E_CELL (ect)->table_model = etm; - - return (ECell *) ect; -} diff --git a/widgets/e-cell-text.h b/widgets/e-cell-text.h deleted file mode 100644 index de9629b97b..0000000000 --- a/widgets/e-cell-text.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _E_CELL_TEXT_H_ -#define _E_CELL_TEXT_H_ - -#include <libgnomeui/gnome-canvas.h> -#include "e-cell.h" - -#define E_CELL_TEXT_TYPE (e_cell_text_get_type ()) -#define E_CELL_TEXT(o) (GTK_CHECK_CAST ((o), E_CELL_TEXT_TYPE, ECellText)) -#define E_CELL_TEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TEXT_TYPE, ECellTextClass)) -#define E_IS_CELL_TEXT(o) (GTK_CHECK_TYPE ((o), E_CELL_TEXT_TYPE)) -#define E_IS_CELL_TEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TEXT_TYPE)) - -typedef struct { - ECell parent; - - GtkJustification justify; - char *font_name; -} ECellText; - -typedef struct { - ECellClass parent_class; -} ECellTextClass; - -GtkType e_cell_text_get_type (void); -ECell *e_cell_text_new (ETableModel *model, const char *fontname, GtkJustification justify); - -#endif /* _E_CELL_TEXT_H_ */ - diff --git a/widgets/e-cell-toggle.c b/widgets/e-cell-toggle.c deleted file mode 100644 index 8e06d8d87d..0000000000 --- a/widgets/e-cell-toggle.c +++ /dev/null @@ -1,285 +0,0 @@ -/* - * e-cell-toggle.c: Multi-state image toggle cell object. - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkenums.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtksignal.h> -#include <gdk/gdkkeysyms.h> -#include <libgnomeui/gnome-canvas.h> -#include "e-cell-toggle.h" -#include "e-util.h" -#include "e-table-item.h" - -#define PARENT_TYPE e_cell_get_type() - -typedef struct { - ECellView cell_view; - GdkGC *gc; - GnomeCanvas *canvas; - ETableItem *eti; -} ECellToggleView; - -static ECellClass *parent_class; - -static void -etog_queue_redraw (ECellToggleView *text_view, int col, int row) -{ - e_table_item_redraw_range (text_view->eti, col, row, col, row); -} - -/* - * ECell::realize method - */ -static ECellView * -etog_realize (ECell *ecell, void *view) -{ - ECellToggle *eccb = E_CELL_TOGGLE (ecell); - ECellToggleView *toggle_view = g_new0 (ECellToggleView, 1); - ETableItem *eti = E_TABLE_ITEM (view); - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - - toggle_view->cell_view.ecell = ecell; - toggle_view->eti = eti; - toggle_view->canvas = canvas; - toggle_view->gc = gdk_gc_new (GTK_WIDGET (canvas)->window); - - return (ECellView *) toggle_view; -} - -/* - * ECell::unrealize method - */ -static void -etog_unrealize (ECellView *ecv) -{ - ECellToggleView *toggle_view = (ECellToggleView *) ecv; - - gdk_gc_unref (toggle_view->gc); - toggle_view->gc = NULL; - - g_free (toggle_view); -} - -/* - * ECell::draw method - */ -static void -etog_draw (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, - int x1, int y1, int x2, int y2) -{ - ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell); - ECellToggleView *toggle_view = (ECellToggleView *) ecell_view; - GdkPixbuf *image; - ArtPixBuf *art; - int x, y, width, height; - gboolean free_image; - const int value = GPOINTER_TO_INT ( - e_table_model_value_at (ecell_view->ecell->table_model, col, row)); - - if (value >= toggle->n_states){ - g_warning ("Value from the table model is %d, the states we support are [0..%d)\n", - value, toggle->n_states); - return; - } - - /* - * Paint the background - */ - gdk_draw_rectangle (drawable, GTK_WIDGET (toggle_view->canvas)->style->white_gc, TRUE, x1, y1, x2 - x1, y2 - y1); - - image = toggle->images [value]; - art = image->art_pixbuf; - - if ((x2 - x1) < art->width){ - x = x1; - width = x2 - x1; - } else { - x = x1 + ((x2 - x1) - art->width) / 2; - width = art->width; - } - - if ((y2 - y1) < art->height){ - y = y1; - height = y2 - y1; - } else { - y = y1 + ((y2 - y1) - art->height) / 2; - height = art->height; - } - - width = y2 - y1; - - if (image->art_pixbuf->has_alpha){ - GdkColor background; - guchar *buffer; - int alpha, ix, iy; - - buffer = g_malloc (art->rowstride * art->height * 3); - - background.red = 255; - background.green = 255; - background.blue = 255; - - for (iy = 0; iy < art->height; iy++){ - unsigned char *dest; - unsigned char *src; - - dest = buffer + (iy * art->rowstride); - src = art->pixels + (iy * art->rowstride); - - for (ix = 0; ix < art->width; ix++){ - alpha = src [3]; - if (alpha == 0){ - *dest++ = background.red; - *dest++ = background.green; - *dest++ = background.blue; - src += 3; - } else if (alpha == 255){ - *dest++ = *src++; - *dest++ = *src++; - *dest++ = *src++; - } else { - *dest++ = (background.red + ((*src++ - background.red) * alpha + 0x80)) >> 8; - *dest++ = (background.green + ((*src++ - background.green) * alpha + 0x80)) >> 8; - *dest++ = (background.blue + ((*src++ - background.blue) * alpha + 0x80)) >> 8; - } - src++; - } - } - - gdk_draw_rgb_image_dithalign ( - drawable, toggle_view->gc, x, y, width, height, - GDK_RGB_DITHER_NORMAL, buffer, art->rowstride, 0, 0); - - g_free (buffer); - } else - gdk_draw_rgb_image_dithalign ( - drawable, toggle_view->gc, x, y, width, height, - GDK_RGB_DITHER_NORMAL, art->pixels, art->rowstride, 0, 0); -} - -static void -etog_set_value (ECellToggleView *toggle_view, int col, int row, int value) -{ - ECell *ecell = toggle_view->cell_view.ecell; - ECellToggle *toggle = E_CELL_TOGGLE (ecell); - - if (value >= toggle->n_states) - value = 0; - - e_table_model_set_value_at (ecell->table_model, col, row, GINT_TO_POINTER (value)); - etog_queue_redraw (toggle_view, col, row); -} - -/* - * ECell::event method - */ -static gint -etog_event (ECellView *ecell_view, GdkEvent *event, int col, int row) -{ - ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell); - ECellToggleView *toggle_view = (ECellToggleView *) ecell_view; - void *_value = e_table_model_value_at (ecell_view->ecell->table_model, col, row); - const int value = GPOINTER_TO_INT (_value); - - switch (event->type){ - case GDK_BUTTON_RELEASE: - etog_set_value (toggle_view, col, row, value + 1); - return TRUE; - - case GDK_KEY_PRESS: - if (event->key.keyval == GDK_space){ - etog_set_value (toggle_view, col, row, value + 1); - return TRUE; - } - return FALSE; - - default: - return FALSE; - } - return TRUE; -} - -/* - * ECell::height method - */ -static int -etog_height (ECellView *ecell_view, int col, int row) -{ - ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell); - - return toggle->height; -} - -static void -etog_destroy (GtkObject *object) -{ - ECellToggle *etog = E_CELL_TOGGLE (object); - int i; - - for (i = 0; i < etog->n_states; i++) - gdk_pixbuf_unref (etog->images [i]); - - g_free (etog->images); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -static void -e_cell_toggle_class_init (GtkObjectClass *object_class) -{ - ECellClass *ecc = (ECellClass *) object_class; - - object_class->destroy = etog_destroy; - - ecc->realize = etog_realize; - ecc->unrealize = etog_unrealize; - ecc->draw = etog_draw; - ecc->event = etog_event; - ecc->height = etog_height; - - parent_class = gtk_type_class (PARENT_TYPE); -} - -E_MAKE_TYPE(e_cell_toggle, "ECellToggle", ECellToggle, e_cell_toggle_class_init, NULL, PARENT_TYPE); - -void -e_cell_toggle_construct (ECellToggle *etog, ETableModel *etm, int border, int n_states, GdkPixbuf **images) -{ - int max_height = 0; - int i; - - E_CELL (etog)->table_model = etm; - - etog->border = border; - etog->n_states = n_states; - - etog->images = g_new (GdkPixbuf *, n_states); - - for (i = 0; i < n_states; i++){ - etog->images [i] = images [i]; - gdk_pixbuf_ref (images [i]); - - if (images [i]->art_pixbuf->height > max_height) - max_height = images [i]->art_pixbuf->height; - } - - etog->height = max_height; -} - -ECell * -e_cell_toggle_new (ETableModel *etm, int border, int n_states, GdkPixbuf **images) -{ - ECellToggle *etog = gtk_type_new (e_cell_toggle_get_type ()); - - e_cell_toggle_construct (etog, etm, border, n_states, images); - - return (ECell *) etog; -} diff --git a/widgets/e-cell-toggle.h b/widgets/e-cell-toggle.h deleted file mode 100644 index 2a5b6adc18..0000000000 --- a/widgets/e-cell-toggle.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _E_CELL_TOGGLE_H_ -#define _E_CELL_TOGGLE_H_ - -#include <libgnomeui/gnome-canvas.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include "e-cell.h" - -#define E_CELL_TOGGLE_TYPE (e_cell_toggle_get_type ()) -#define E_CELL_TOGGLE(o) (GTK_CHECK_CAST ((o), E_CELL_TOGGLE_TYPE, ECellToggle)) -#define E_CELL_TOGGLE_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TOGGLE_TYPE, ECellToggleClass)) -#define E_IS_CELL_TOGGLE(o) (GTK_CHECK_TYPE ((o), E_CELL_TOGGLE_TYPE)) -#define E_IS_CELL_TOGGLE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TOGGLE_TYPE)) - -typedef struct { - ECell parent; - - int border; - int n_states; - GdkPixbuf **images; - - int height; -} ECellToggle; - -typedef struct { - ECellClass parent_class; -} ECellToggleClass; - -GtkType e_cell_toggle_get_type (void); -ECell *e_cell_toggle_new (ETableModel *model, int border, - int n_states, - GdkPixbuf **images); -void e_cell_toggle_construct (ECellToggle *etog, ETableModel *etm, - int border, int n_states, GdkPixbuf **images); - -#endif /* _E_CELL_TOGGLE_H_ */ - - diff --git a/widgets/e-cell.c b/widgets/e-cell.c deleted file mode 100644 index 2bc49f7a45..0000000000 --- a/widgets/e-cell.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * e-cell.c: base class for cell renderers in e-table - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include "e-cell.h" -#include "e-util.h" - -#define PARENT_TYPE gtk_object_get_type() - -static ECellView * -ec_realize (ECell *e_cell, void *view) -{ - return NULL; -} - -static void -ec_unrealize (ECellView *e_cell) -{ -} - -static void -ec_draw (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, - int x1, int y1, int x2, int y2) -{ - g_error ("e-cell-draw invoked\n"); -} - -static gint -ec_event (ECellView *ecell_view, GdkEvent *event, int col, int row) -{ - g_error ("e-cell-event invoked\n"); - return 0; -} - -static gint -ec_height (ECellView *ecell_view, int col, int row) -{ - g_error ("e-cell-event invoked\n"); - return 0; -} - -static void -ec_focus (ECellView *ecell_view, int col, int row, int x1, int y1, int x2, int y2) -{ - ecell_view->focus_col = col; - ecell_view->focus_row = row; - ecell_view->focus_x1 = x1; - ecell_view->focus_y1 = y1; - ecell_view->focus_x2 = x2; - ecell_view->focus_y2 = y2; -} - -static void -ec_unfocus (ECellView *ecell_view) -{ - ecell_view->focus_col = -1; - ecell_view->focus_row = -1; - ecell_view->focus_x1 = -1; - ecell_view->focus_y1 = -1; - ecell_view->focus_x2 = -1; - ecell_view->focus_y2 = -1; -} - -static void -e_cell_class_init (GtkObjectClass *object_class) -{ - ECellClass *ecc = (ECellClass *) object_class; - - ecc->realize = ec_realize; - ecc->unrealize = ec_unrealize; - ecc->draw = ec_draw; - ecc->event = ec_event; - ecc->focus = ec_focus; - ecc->unfocus = ec_unfocus; - ecc->height = ec_height; -} - -static void -e_cell_init (GtkObject *object) -{ - ECell *e_cell = E_CELL (object); -} - -E_MAKE_TYPE(e_cell, "ECell", ECell, e_cell_class_init, e_cell_init, PARENT_TYPE); - - -void -e_cell_event (ECellView *ecell_view, GdkEvent *event, int col, int row) -{ - E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->event ( - ecell_view, event, col, row); -} - -ECellView * -e_cell_realize (ECell *ecell, void *view) -{ - return E_CELL_CLASS (GTK_OBJECT (ecell)->klass)->realize ( - ecell, view); -} - -void -e_cell_unrealize (ECellView *ecell_view) -{ - E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->unrealize (ecell_view); -} - -void -e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, int x1, int y1, int x2, int y2) -{ - E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->draw ( - ecell_view, drawable, col, row, selected, x1, y1, x2, y2); -} - -int -e_cell_height (ECellView *ecell_view, int col, int row) -{ - return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->height ( - ecell_view, col, row); -} - -void * -e_cell_enter_edit (ECellView *ecell_view, int col, int row) -{ - return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->enter_edit ( - ecell_view, col, row); -} - -void -e_cell_leave_edit (ECellView *ecell_view, int col, int row, void *edit_context) -{ - E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->leave_edit ( - ecell_view, col, row, edit_context); -} diff --git a/widgets/e-cell.h b/widgets/e-cell.h deleted file mode 100644 index b0f62d020c..0000000000 --- a/widgets/e-cell.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _E_CELL_H_ -#define _E_CELL_H_ - -#include <gdk/gdktypes.h> -#include "e-table-model.h" - -#define E_CELL_TYPE (e_cell_get_type ()) -#define E_CELL(o) (GTK_CHECK_CAST ((o), E_CELL_TYPE, ECell)) -#define E_CELL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TYPE, ECellClass)) -#define E_IS_CELL(o) (GTK_CHECK_TYPE ((o), E_CELL_TYPE)) -#define E_IS_CELL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TYPE)) - -typedef struct _ECell ECell; -typedef struct _ECellView ECellView; - -struct _ECell { - GtkObject object; - ETableModel *table_model; -}; - -struct _ECellView { - ECell *ecell; - gint focus_x1, focus_y1, focus_x2, focus_y2; - gint focus_col, focus_row; -}; - -#define E_CELL_IS_FOCUSED(ecell_view) (ecell_view->focus_x1 != -1) - -typedef struct { - GtkObjectClass parent_class; - - ECellView *(*realize) (ECell *ecell, void *view); - void (*unrealize) (ECellView *e_cell_view); - void (*draw) (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, int x1, int y1, int x2, int y2); - gint (*event) (ECellView *ecell_view, GdkEvent *event, int col, int row); - void (*focus) (ECellView *ecell_view, int col, int row, int x1, int y1, int x2, int y2); - void (*unfocus) (ECellView *ecell_view); - int (*height) (ECellView *ecell_view, int col, int row); - - void *(*enter_edit)(ECellView *ecell_view, int col, int row); - void (*leave_edit)(ECellView *ecell_view, int col, int row, void *context); -} ECellClass; - -GtkType e_cell_get_type (void); -void e_cell_event (ECellView *ecell_view, GdkEvent *event, int col, int row); -ECellView *e_cell_realize (ECell *ecell, void *view); -void e_cell_unrealize (ECellView *ecell_view); -void e_cell_draw (ECellView *ecell_view, GdkDrawable *dr, - int col, int row, gboolean selected, - int x1, int y1, int x2, int y2); -void e_cell_focus (ECellView *ecell_view, int col, int row, int x1, int y1, int x2, int y2); -void e_cell_unfocus (ECellView *ecell_view); -int e_cell_height (ECellView *ecell_view, int col, int row); - -void *e_cell_enter_edit(ECellView *ecell_view, int col, int row); -void e_cell_leave_edit(ECellView *ecell_view, int col, int row, void *edit_context); - -#endif /* _E_CELL_H_ */ diff --git a/widgets/e-cursors.c b/widgets/e-cursors.c deleted file mode 100644 index 150b84b90a..0000000000 --- a/widgets/e-cursors.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * cursors.c: cursor handling for Evolution. - * copied from Gnumeric. - * - * Authors: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <gnome.h> -#include "e-cursors.h" - -static GdkColor black, white; - -#define GDK_INTERNAL_CURSOR -1 - -typedef struct { - GdkCursor *cursor; - int hot_x, hot_y; - char **xpm; -} CursorDef; - -static CursorDef cursors [] = { - { NULL, GDK_INTERNAL_CURSOR, GDK_CROSSHAIR, NULL }, - { NULL, GDK_INTERNAL_CURSOR, GDK_LEFT_PTR, NULL }, - { NULL, GDK_INTERNAL_CURSOR, GDK_FLEUR, NULL }, - { NULL, GDK_INTERNAL_CURSOR, GDK_SB_H_DOUBLE_ARROW, NULL }, - { NULL, GDK_INTERNAL_CURSOR, GDK_SB_V_DOUBLE_ARROW, NULL }, - { NULL, 0, 0, NULL } -}; - - -static void -create_bitmap_and_mask_from_xpm (GdkBitmap **bitmap, GdkBitmap **mask, gchar **xpm) -{ - int height, width, colors; - char pixmap_buffer [(32 * 32)/8]; - char mask_buffer [(32 * 32)/8]; - int x, y, pix, yofs; - int transparent_color, black_color; - - sscanf (xpm [0], "%d %d %d %d", &height, &width, &colors, &pix); - - g_assert (height == 32); - g_assert (width == 32); - g_assert (colors <= 3); - - transparent_color = ' '; - black_color = '.'; - - yofs = colors + 1; - for (y = 0; y < 32; y++){ - for (x = 0; x < 32;){ - char value = 0, maskv = 0; - - for (pix = 0; pix < 8; pix++, x++){ - if (xpm [y + yofs][x] != transparent_color){ - maskv |= 1 << pix; - - /* - * Invert the colours here because it seems - * to workaround a bug the Matrox G100 Xserver? - * We reverse the foreground & background in the next - * routine to compensate. - */ - if (xpm [y + yofs][x] == black_color){ - value |= 1 << pix; - } - } - } - pixmap_buffer [(y * 4 + x/8)-1] = value; - mask_buffer [(y * 4 + x/8)-1] = maskv; - } - } - *bitmap = gdk_bitmap_create_from_data (NULL, pixmap_buffer, 32, 32); - *mask = gdk_bitmap_create_from_data (NULL, mask_buffer, 32, 32); -} - -void -e_cursors_init (void) -{ - GdkColormap *colormap; - int i; - - colormap = gtk_widget_get_default_colormap (); - gdk_color_white (colormap, &white); - gdk_color_black (colormap, &black); - - for (i = 0; cursors [i].hot_x; i++){ - GdkBitmap *bitmap, *mask; - - if (cursors [i].hot_x < 0) - cursors [i].cursor = gdk_cursor_new (cursors [i].hot_y); - else { - create_bitmap_and_mask_from_xpm (&bitmap, &mask, cursors [i].xpm); - - /* The foreground and background colours are reversed. - * See comment above for explanation. - */ - cursors [i].cursor = - gdk_cursor_new_from_pixmap ( - bitmap, mask, - &black, &white, - cursors [i].hot_x, - cursors [i].hot_y); - } - } - - g_assert (i == E_NUM_CURSORS); -} - -void -e_cursors_shutdown (void) -{ - int i; - - for (i = 0; cursors [i].hot_x; i++) - gdk_cursor_destroy (cursors [i].cursor); -} - - -/* Returns a cursor given its type */ -GdkCursor * -e_cursor_get (ECursorType type) -{ - g_return_val_if_fail (type >= 0 && type < E_NUM_CURSORS, NULL); - - return cursors [type].cursor; -} diff --git a/widgets/e-cursors.h b/widgets/e-cursors.h deleted file mode 100644 index 771e5f6d4d..0000000000 --- a/widgets/e-cursors.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef E_CURSORS_H -#define E_CURSORS_H - -/* Copied from Gnumeric */ - -typedef enum { - E_CURSOR_THIN_CROSS, - E_CURSOR_ARROW, - E_CURSOR_MOVE, - E_CURSOR_SIZE_X, - E_CURSOR_SIZE_Y, - E_NUM_CURSORS -} ECursorType; - -void e_cursors_init (void); -void e_cursors_shutdown (void); - -#define e_cursor_set(win, c) \ -G_STMT_START { \ - if (win) \ - gdk_window_set_cursor (win, e_cursor_get (c)); \ -} G_STMT_END - -#define e_cursor_set_widget(w, c) \ -G_STMT_START { \ - if (GTK_WIDGET (w)->window) \ - gdk_window_set_cursor (GTK_WIDGET (w)->window, e_cursor_get (c)); \ -} G_STMT_END - -GdkCursor *e_cursor_get (ECursorType type); - -#endif /* E_CURSORS_H */ - diff --git a/widgets/e-table-col.c b/widgets/e-table-col.c deleted file mode 100644 index cca7bd13d6..0000000000 --- a/widgets/e-table-col.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * E-table-col.c: ETableCol implementation - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkobject.h> -#include <gtk/gtksignal.h> -#include "e-table-col.h" -#include "e-util.h" - -#define PARENT_TYPE (gtk_object_get_type ()) - -static GtkObjectClass *parent_class; - -static void -etc_destroy (GtkObject *object) -{ - ETableCol *etc = E_TABLE_COL (object); - - printf ("Destroying columns: %s %s\n", etc->id, etc->text); - g_free (etc->id); - g_free (etc->text); - - (*parent_class->destroy)(object); -} - -static void -e_table_col_class_init (GtkObjectClass *object_class) -{ - parent_class = gtk_type_class (PARENT_TYPE); - object_class->destroy = etc_destroy; -} - -E_MAKE_TYPE(e_table_col, "ETableCol", ETableCol, e_table_col_class_init, NULL, PARENT_TYPE); - -ETableCol * -e_table_col_new (const char *id, const char *text, int width, int min_width, - ECell *ecell, GCompareFunc compare, gboolean resizable) -{ - ETableCol *etc; - - g_return_val_if_fail (id != NULL, NULL); - g_return_val_if_fail (width >= 0, NULL); - g_return_val_if_fail (min_width >= 0, NULL); - g_return_val_if_fail (width >= min_width, NULL); - g_return_val_if_fail (compare != NULL, NULL); - - etc = gtk_type_new (E_TABLE_COL_TYPE); - - etc->id = g_strdup (id); - etc->text = g_strdup (text); - etc->width = width; - etc->min_width = min_width; - etc->ecell = ecell; - etc->compare = compare; - - etc->selected = 0; - etc->resizeable = resizable; - - return etc; -} - - diff --git a/widgets/e-table-col.h b/widgets/e-table-col.h deleted file mode 100644 index c8fa6dd581..0000000000 --- a/widgets/e-table-col.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _E_TABLE_COL_H_ -#define _E_TABLE_COL_H_ - -#include "e-cell.h" - -#define E_TABLE_COL_TYPE (e_table_col_get_type ()) -#define E_TABLE_COL(o) (GTK_CHECK_CAST ((o), E_TABLE_COL_TYPE, ETableCol)) -#define E_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_COL_TYPE, ETableColClass)) -#define E_IS_TABLE_COL(o) (GTK_CHECK_TYPE ((o), E_TABLE_COL_TYPE)) -#define E_IS_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_COL_TYPE)) - -typedef struct _ETableCol ETableCol; - -/* - * Information about a single column - */ -struct _ETableCol { - GtkObject base; - char *id, *text; - short width; - short min_width; - short x; - GCompareFunc compare; - unsigned int selected:1; - unsigned int resizeable:1; - - - ECell *ecell; -}; - -typedef struct { - GtkObjectClass parent_class; -} ETableColClass; - -GtkType e_table_col_get_type (void); -ETableCol *e_table_col_new (const char *id, const char *text, - int width, int min_width, - ECell *ecell, GCompareFunc compare, - gboolean resizable); -void e_table_col_destroy (ETableCol *etc); - - -#endif /* _E_TABLE_COL_H_ */ - diff --git a/widgets/e-table-column-item.c b/widgets/e-table-column-item.c deleted file mode 100644 index 0616327a93..0000000000 --- a/widgets/e-table-column-item.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * E-table-column-view.c: A canvas view of the TableColumn. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc. - */ -#include <config.h> -#include "e-table-column.h" -#include "e-table-column-view.h" - -#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type () - -static GnomeCanvasItemClass *etci_parent_class; - -enum { - ARG_0, - ARG_TABLE_COLUMN -}; - -static void -etci_destroy (GtkObject *object) -{ - ETableColumnItem *etcv = E_TABLE_COLUMN_VIEW (object); - - gtk_object_unref (GTK_OBJECT (etcv)); - - if (GTK_OBJECT_CLASS (etcv_parent_class)->destroy) - (*GTK_OBJECT_CLASS (etcv_parent_class)->destroy) (object); -} - -static void -etci_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) -{ - if (GNOME_CANVAS_ITEM_CLASS(item_bar_parent_class)->update) - (*GNOME_CANVAS_ITEM_CLASS(item_bar_parent_class)->update)(item, affine, clip_path, flags); - - item->x1 = 0; - item->y1 = 0; - item->x2 = INT_MAX; - item->y2 = INT_MAX; - gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item); -} - -static void -etci_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ETableColumnItem *etci; - int v; - - item = GNOME_CANVAS_ITEM (o); - etci = E_TABLE_COLUMN_ITEM (o); - - switch (arg_id){ - case ARG_TABLE_COLUMN: - etci->etci = GTK_VALUE_POINTER (*arg); - break; - } - etci_update (item, NULL, NULL, 0); -} - -static void -etci_realize (GnomeCanvasItem *item) -{ - ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item); - GdkWindow *window; - GdkColor c; - - if (GNOME_CANVAS_ITEM_CLASS (etci_parent_class)-> realize) - (*GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->realize)(item); - - window = GTK_WIDGET (item->canvas)->window; - - etci->gc = gdk_gc_new (window); - gnome_canvas_get_color (item->canvas, "black", &c); - gdk_gc_set_foreground (etci->gc, &c); - - etci->normal_cursor = gdk_cursor_new (GDK_ARROW); -} - -static void -etci_unrealize (GnomeCanvasItem *item) -{ - ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item); - - gdk_gc_unref (etci->gc); - etci->gc = NULL; - - gdk_cursor_destroy (etci->change_cursor); - etci->change_cursor = NULL; - - gdk_cursor_destroy (etci->normal_cursor); - etci->normal_cursor = NULL; - - if (GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->unrealize) - (*GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->unrealize)(item); -} - -static void -etci_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x1, int y1, int width, int height) -{ - ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item); - GnomeCanvas *canvas = item->canvas; - GdkGC *gc; - const int cols = e_table_column_count (etci->etc); - int x2 = x1 + width; - int col, total; - - total = 0; - for (col = 0; col < cols; col++){ - ETableCol *col = e_table_column_get_column (etci->etc, col); - const int col_width = col->width; - - if (x1 > total + col_width) - continue; - - if (x2 < total) - return; - - gc = canvas->style->bg_gc [GTK_STATE_ACTIVE]; - gdk_draw_rectangle (drawble, gc, TRUE, - gtk_draw_shadow (canvas->style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT, - x, y, width, height - } -} - -static double -etci_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = *item; - return 0.0; -} - -static void -etci_event (GnomeCanvasItem *item, GdkEvent *e) -{ - switch (e->type){ - default: - return FALSE; - } - return TRUE; -} - -static void -etci_class_init (GtkObjectClass *object_class) -{ - GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class; - - object_class->destroy = etci_destroy; - object_class->set_arg = etci_set_arg; - - item_class->update = etci_update; - item_class->realize = etci_realize; - item_class->unrealize = etci_unrealize; - item_class->draw = etci_draw; - item_class->point = etci_point; - item_class->event = etci_event; - - gtk_object_add_arg_type ("ETableColumnItem::ETableColumn", GTK_TYPE_POINTER, - GTK_ARG_WRITABLE, ARG_TABLE_COLUMN); -} - -static void -etci_init (GnomeCanvasItem *item) -{ - item->x1 = 0; - item->y1 = 0; - item->x2 = 0; - item->y2 = 0; -} - -GtkType -e_table_column_view_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableColumnItem", - sizeof (ETableColumnItem), - sizeof (ETableColumnItemClass), - (GtkClassInitFunc) etci_class_init, - (GtkObjectInitFunc) etci_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_OBJECT_TYPE, &info); - } - - return type; -} - - - diff --git a/widgets/e-table-column-item.h b/widgets/e-table-column-item.h deleted file mode 100644 index fd38681a73..0000000000 --- a/widgets/e-table-column-item.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _E_TABLE_COLUMN_VIEW_H -#defein _E_TABLE_COLUMN_VIEW_H - -#include "e-table-column.h" - -typedef struct { - GnomeCanvasItem parent; - ETableColumn *etc; - - GdkGC *gc; - GdkCursor *change_cursor, *normal_cursor; -} ETableColumnView; - -typedef struct { - GnomeCanvasItemClass parent_class; -} ETableColumnViewClass; - -GtkType e_table_column_item_get_type (void); - -#endif /* _E_TABLE_COLUMN_VIEW_H */ diff --git a/widgets/e-table-column-model.h b/widgets/e-table-column-model.h deleted file mode 100644 index 043dd783ca..0000000000 --- a/widgets/e-table-column-model.h +++ /dev/null @@ -1,5 +0,0 @@ - -class ETableColumnModel { - virtual void add_column (ETableCol *et) = 0; - virtual ETableCol *get_column (int column); - virtual diff --git a/widgets/e-table-column.c b/widgets/e-table-column.c deleted file mode 100644 index d17a285321..0000000000 --- a/widgets/e-table-column.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * e-table-column.c: TableColumn implementation - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include "e-table-column.h" - -enum { - STRUCTURE_CHANGE, - DIMENSION_CHANGE, - LAST_SIGNAL -}; - -static guint etc_signals [LAST_SIGNAL] = { 0, }; - -static GtkObjectClass *e_table_column_parent_class; - -static void -e_table_column_destroy (GtkObject *object) -{ - ETableColumn *etc = E_TABLE_COLUMN (object); - const int cols = etc->col_count; - - /* - * Destroy listeners - */ - for (l = etc->listeners; l; l = l->next) - g_free (l->data); - g_slist_free (etc->listeners); - etc->listeners = NULL; - - /* - * Destroy columns - */ - for (i = 0; i < cols; i++) - e_table_column_remove (etc, i); - - if (e_table_column_parent_class->destroy) - e_table_column_parent_class->destroy (object); -} - -static void -e_table_column_class_init (GtkObjectClass *object_class) -{ - object_class->destroy = e_table_column_destroy; - - e_table_column_parent_class = (gtk_type_class (gtk_object_get_type ())); - - etc_signals [STRUCTURE_CHANGE] = - gtk_signal_new ("structure_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableColumn, structure_change), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - etc_signals [DIMENSION_CHANGE] = - gtk_signal_new ("dimension_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableColumn, dimension_change), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, etc_signals, LAST_SIGNAL); -} - -GtkType -e_table_column_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableColumn", - sizeof (ETableColumn), - sizeof (ETableColumnClass), - (GtkClassInitFunc) e_table_column_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - -static void -etc_do_insert (ETableColumn *etc, int pos, ETableCol *val) -{ - memcpy (&etc->columns [pos+1], &etc->columns [pos], - sizeof (ETableCol *) * (etc->col_count - pos)); - etc->columns [pos] = val; -} - -void -e_table_column_add_column (ETableColumn *etc, ETableCol *tc, int pos) -{ - ETableCol **new_ptr; - - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (tc != NULL); - g_return_if_fail (pos >= 0 && pos < etc->col_count); - - if (pos == -1) - pos = etc->col_count; - etc->columns = g_realloc (etc->columns, sizeof (ETableCol *) * (etc->col_count + 1)); - etc_do_insert (etc, pos, tc); - etc->col_count++; - - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]); -} - -ETableCol * -e_table_column_get_column (ETableColumn *etc, int column) -{ - g_return_val_if_fail (etc != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), NULL); - - if (column < 0) - return NULL; - - if (column >= etc->col_count) - return NULL; - - return etc->columns [column]; -} - -int -e_table_column_count (ETableColumn *etc) -{ - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - return etc->col_count; -} - -int -e_table_column_index (ETableColumn *etc, const char *identifier) -{ - int i; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - g_return_val_if_fail (identifier != NULL, 0); - - for (i = 0; i < etc->col_count; i++){ - ETableCol *tc = etc->columns [i]; - - if (strcmp (i->id, identifier) == 0) - return i; - } - - return -1; -} - -int -e_table_column_get_index_at (ETableColumn *etc, int x_offset) -{ - int i, total; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - g_return_val_if_fail (identifier != NULL, 0); - - total = 0; - for (i = 0; i < etc->col_count; i++){ - total += etc->columns [i]->width; - - if (x_offset < total) - return i; - } - - return -1; -} - -ETableCol ** -e_table_column_get_columns (ETableColumn *etc) -{ - ETableCol **ret; - int i; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - ret = g_new (ETableCol *, etc->col_count + 1); - memcpy (ret, etc->columns, sizeof (ETableCol *) * etc->col_count); - ret [etc->col_count] = NULL; - - return ret; -} - -gboolean -e_table_column_selection_ok (ETableColumn *etc) -{ - g_return_val_if_fail (etc != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), FALSE); - - return etc->selectable; -} - -int -ve_table_column_get_selected (ETableColumn *etc) -{ - int i; - int selected = 0; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - for (i = 0; i < etc->col_count; i++){ - if (etc->columns [i]->selected) - selected++; - } - - return selected; -} - -int -e_table_column_total_width (ETableColumn *etc) -{ - int total; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - total = 0; - for (i = 0; i < etc->col_count; i++) - total += etc->columns [i].width; - - return total; -} - -static void -etc_do_remove (ETableColumn *etc, int idx) -{ - memcpy (&etc->columns [idx], &etc->columns [idx+1], - sizeof (ETableCol *) * etc->col_count - idx); - etc->col_count--; -} - -void -e_table_column_move (ETableColumn *etc, int source_index, int target_index) -{ - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (source_index >= 0); - g_return_if_fail (target_index >= 0); - g_return_if_fail (source_index < etc->col_count); - g_return_if_fail (target_index < etc->col_count); - - old = etc->columns [source_index]; - etc_do_remove (etc, source_index); - etc_do_insert (etc, target_index, old); - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]); -} - -void -e_table_column_remove (ETableColumn *etc, int idx) -{ - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < etc->col_count); - - etc_do_remove (etc, idx); - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]); -} - -void -e_table_column_set_selection (ETableColumn *etc, gboolean allow_selection); -{ -} - -void -e_table_column_set_size (ETableColumn *etc, int idx, int size) -{ - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < etc->col_count); - g_return_if_fail (size > 0); - - etc->columns [idx]->width = size; - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [SIZE_CHANGE], idx); -} diff --git a/widgets/e-table-group.c b/widgets/e-table-group.c deleted file mode 100644 index b1e681d255..0000000000 --- a/widgets/e-table-group.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * E-Table-Group.c: Implements the grouping objects for elements on a table - * - * Author: - * Miguel de Icaza (miguel@gnu.org() - * - * Copyright 1999, Helix Code, Inc. - */ - -#include <config.h> -#include "e-table-group.h" - -void -e_table_group_destroy (ETableGroup *etg) -{ - g_return_if_fail (etg != NULL); - - g_free (etg->title); - - if (etg->is_leaf == 0){ - GSList *l; - - for (l = etg->u.children; l; l = l->next){ - ETableGroup *child = l->data; - - e_table_group_destroy (child); - } - g_slist_free (etg->u.children); - etg->u.children = NULL; - } - g_free (etg); -} - -ETableGroup * -e_table_group_new_leaf (const char *title, ETableModel *table) -{ - ETableGroup *etg; - - g_return_val_if_fail (title != NULL, NULL); - g_return_val_if_fail (table != NULL, NULL); - - etg = g_new (ETableGroup, 1); - - etg->expanded = 0; - etg->is_leaf = 1; - etg->u.table = table; - etg->title = g_strdup (title); - - return etg; -} - -ETableGroup * -e_table_group_new (const char *title) -{ - ETableGroup *etg; - - g_return_val_if_fail (title != NULL, NULL); - - etg = g_new (ETableGroup, 1); - - etg->expanded = 0; - etg->is_leaf = 0; - etg->u.children = NULL; - etg->title = g_strdup (title); - - return etg; -} - -void -e_table_group_append_child (ETableGroup *etg, ETableGroup *child) -{ - g_return_if_fail (etg != NULL); - g_return_if_fail (child != NULL); - g_return_if_fail (etg->is_leaf != 0); - - etg->u.children = g_slist_append (etg->u.children, child); -} - -#if 0 -int -e_table_group_size (ETableGroup *etg) -{ - g_return_val_if_fail (etg != NULL, 0); - - if (etg->is_leaf) - return e_table_model_height (etg->u.table); - else { - GSList *l; - int size = 0; - - for (l = etg->u.children; l; l = l->next){ - ETableGroup *child = l->data; - - size += e_table_group_size (child); - } - return size; - } -} - -#endif diff --git a/widgets/e-table-group.h b/widgets/e-table-group.h deleted file mode 100644 index d673aebd11..0000000000 --- a/widgets/e-table-group.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _E_TABLE_TREE_H_ -#define _E_TABLE_TREE_H_ - -#include "e-table-model.h" - -typedef struct { - char *title; - - union { - ETableModel *table; - GSList *children; - } u; - - guint expanded :1; - guint is_leaf :1; -} ETableGroup; - -ETableGroup *e_table_group_new (const char *title); -ETableGroup *e_table_group_new_leaf (const char *title, ETableModel *table); -void e_table_group_destroy (ETableGroup *etg); - -int e_table_group_size (ETableGroup *egroup); -void e_table_group_append_child (ETableGroup *etg, ETableGroup *child); - -#endif /* _E_TABLE_TREE_H_ */ diff --git a/widgets/e-table-header-item.c b/widgets/e-table-header-item.c deleted file mode 100644 index 378bdf4447..0000000000 --- a/widgets/e-table-header-item.c +++ /dev/null @@ -1,527 +0,0 @@ -/* - * E-table-column-view.c: A canvas item based view of the ETableColumn. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc. - */ -#include <config.h> -#include <gtk/gtksignal.h> -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-cursors.h" - -/* Padding above and below of the string in the header display */ -#define PADDING 4 - -/* Defines the tolerance for proximity of the column division to the cursor position */ -#define TOLERANCE 2 - -#define ETHI_RESIZING(x) ((x)->resize_col != -1) - -#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type () - -static GnomeCanvasItemClass *ethi_parent_class; - -enum { - ARG_0, - ARG_TABLE_HEADER, - ARG_TABLE_X, - ARG_TABLE_Y, - ARG_TABLE_FONTSET -}; - -static void -ethi_destroy (GtkObject *object) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (object); - - gtk_object_unref (GTK_OBJECT (ethi->eth)); - - if (GTK_OBJECT_CLASS (ethi_parent_class)->destroy) - (*GTK_OBJECT_CLASS (ethi_parent_class)->destroy) (object); -} - -static void -ethi_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - - if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update) - (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update)(item, affine, clip_path, flags); - - item->x1 = ethi->x1; - item->y1 = ethi->y1; - item->x2 = ethi->x1 + ethi->width; - item->y2 = ethi->y1 + ethi->height; - - gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item); -} - -static void -ethi_font_load (ETableHeaderItem *ethi, char *font) -{ - if (ethi->font) - gdk_font_unref (ethi->font); - - ethi->font = gdk_fontset_load (font); - if (ethi->font == NULL) - ethi->font = gdk_font_load ("fixed"); - - ethi->height = ethi->font->ascent + ethi->font->descent + PADDING; -} - -static void -ethi_drop_table_header (ETableHeaderItem *ethi) -{ - GtkObject *header; - - if (!ethi->eth) - return; - - header = GTK_OBJECT (ethi->eth); - gtk_signal_disconnect (header, ethi->structure_change_id); - gtk_signal_disconnect (header, ethi->dimension_change_id); - - gtk_object_unref (header); - ethi->eth = NULL; - ethi->width = 0; -} - -static void -structure_changed (ETableHeader *header, ETableHeaderItem *ethi) -{ - ethi->width = e_table_header_total_width (header); - - ethi_update (GNOME_CANVAS_ITEM (ethi), NULL, NULL, 0); -} - -static void -dimension_changed (ETableHeader *header, int col, ETableHeaderItem *ethi) -{ - ethi->width = e_table_header_total_width (header); - - ethi_update (GNOME_CANVAS_ITEM (ethi), NULL, NULL, 0); -} - -static void -ethi_add_table_header (ETableHeaderItem *ethi, ETableHeader *header) -{ - ethi->eth = header; - gtk_object_ref (GTK_OBJECT (ethi->eth)); - ethi->width = e_table_header_total_width (header); - - ethi->structure_change_id = gtk_signal_connect ( - GTK_OBJECT (header), "structure_change", - GTK_SIGNAL_FUNC(structure_changed), ethi); - ethi->dimension_change_id = gtk_signal_connect ( - GTK_OBJECT (header), "dimension_change", - GTK_SIGNAL_FUNC(dimension_changed), ethi); -} - -static void -ethi_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ETableHeaderItem *ethi; - - item = GNOME_CANVAS_ITEM (o); - ethi = E_TABLE_HEADER_ITEM (o); - - switch (arg_id){ - case ARG_TABLE_HEADER: - ethi_drop_table_header (ethi); - ethi_add_table_header (ethi, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_TABLE_X: - ethi->x1 = GTK_VALUE_INT (*arg); - break; - - case ARG_TABLE_Y: - ethi->y1 = GTK_VALUE_INT (*arg); - break; - - case ARG_TABLE_FONTSET: - ethi_font_load (ethi, GTK_VALUE_STRING (*arg)); - break; - - } - ethi_update (item, NULL, NULL, 0); -} - -static void -ethi_realize (GnomeCanvasItem *item) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - GdkWindow *window; - GdkColor c; - - if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)-> realize) - (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->realize)(item); - - window = GTK_WIDGET (item->canvas)->window; - - ethi->gc = gdk_gc_new (window); - gnome_canvas_get_color (item->canvas, "black", &c); - gdk_gc_set_foreground (ethi->gc, &c); - - ethi->normal_cursor = gdk_cursor_new (GDK_ARROW); - - if (!ethi->font) - ethi_font_load (ethi, "fixed"); -} - -static void -ethi_unrealize (GnomeCanvasItem *item) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - - gdk_gc_unref (ethi->gc); - ethi->gc = NULL; - - gdk_cursor_destroy (ethi->normal_cursor); - ethi->normal_cursor = NULL; - - if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->unrealize) - (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->unrealize)(item); -} - -static void -draw_button (ETableHeaderItem *ethi, ETableCol *col, - GdkDrawable *drawable, GdkGC *gc, GtkStyle *style, - int x, int y, int width, int height) -{ - GdkRectangle clip; - int xtra; - - gdk_draw_rectangle ( - drawable, gc, TRUE, - x + 1, y + 1, width - 2, height -2); - - gtk_draw_shadow ( - style, drawable, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - x , y, width, height); - - clip.x = x + 2; - clip.y = y + 2; - clip.width = width - 4; - clip.height = ethi->height; - - gdk_gc_set_clip_rectangle (ethi->gc, &clip); - - /* Center the thing */ - xtra = (clip.width - gdk_string_measure (ethi->font, col->id))/2; - - if (xtra < 0) - xtra = 0; - - /* Skip over border */ - x += xtra + 2; - - gdk_draw_text ( - drawable, ethi->font, - ethi->gc, x, y + ethi->height - PADDING, - col->id, strlen (col->id)); -} - -static void -ethi_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x1, int y1, int width, int height) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - GnomeCanvas *canvas = item->canvas; - GdkGC *gc; - const int cols = e_table_header_count (ethi->eth); - int x2 = x1 + width; - int col, total; - int x; - - total = 0; - x = -x1; - -#if 0 - printf ("My coords are: %g %g %g %g\n", - item->x1, item->y1, item->x2, item->y2); -#endif - - for (col = 0; col < cols; col++){ - ETableCol *ecol = e_table_header_get_column (ethi->eth, col); - int col_width; - - if (col == ethi->resize_col) - col_width = ethi->resize_width; - else - col_width = ecol->width; - - if (x1 > total + col_width){ - total += col_width; - x += col_width; - continue; - } - - if (x2 < total) - return; - - gc = GTK_WIDGET (canvas)->style->bg_gc [GTK_STATE_ACTIVE]; - - draw_button (ethi, ecol, drawable, gc, - GTK_WIDGET (canvas)->style, - x, ethi->y1 - y1, col_width, ethi->height); - - x += col_width; - total += col_width; - } -} - -static double -ethi_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - -/* - * is_pointer_on_division: - * - * Returns whether @pos is a column header division; If @the_total is not NULL, - * then the actual position is returned here. If @return_ecol is not NULL, - * then the ETableCol that actually contains this point is returned here - */ -static gboolean -is_pointer_on_division (ETableHeaderItem *ethi, int pos, int *the_total, int *return_col) -{ - const int cols = e_table_header_count (ethi->eth); - int col, total; - - total = 0; - for (col = 0; col < cols; col++){ - ETableCol *ecol = e_table_header_get_column (ethi->eth, col); - - total += ecol->width; - - if ((total - TOLERANCE < pos ) && (pos < total + TOLERANCE)){ - if (return_col) - *return_col = col; - if (the_total) - *the_total = total; - - return TRUE; - } - - if (total > pos + TOLERANCE) - return FALSE; - } - - return FALSE; -} - -#define convert(c,sx,sy,x,y) gnome_canvas_w2c (c,sx,sy,x,y) - -static void -set_cursor (ETableHeaderItem *ethi, int pos) -{ - GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (ethi)->canvas); - - /* We might be invoked before we are realized */ - if (!canvas->window) - return; - - if (is_pointer_on_division (ethi, pos, NULL, NULL)) - e_cursor_set (canvas->window, E_CURSOR_SIZE_X); - else - e_cursor_set (canvas->window, E_CURSOR_ARROW); -} - -static void -ethi_request_redraw (ETableHeaderItem *ethi) -{ - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (ethi)->canvas; - - /* - * request a redraw - */ - gnome_canvas_request_redraw ( - canvas, ethi->x1, ethi->y1, ethi->x1 + ethi->width, ethi->x1 + ethi->height); -} - -static void -ethi_end_resize (ETableHeaderItem *ethi, int new_size) -{ - e_table_header_set_size (ethi->eth, ethi->resize_col, new_size); - - ethi->resize_col = -1; - ethi_request_redraw (ethi); -} - -/* - * Handles the events on the ETableHeaderItem, particularly it handles resizing - */ -static int -ethi_event (GnomeCanvasItem *item, GdkEvent *e) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - GnomeCanvas *canvas = item->canvas; - const gboolean resizing = ETHI_RESIZING (ethi); - int x, y, start, col; - - switch (e->type){ - case GDK_ENTER_NOTIFY: - convert (canvas, e->crossing.x, e->crossing.y, &x, &y); - set_cursor (ethi, x); - break; - - case GDK_LEAVE_NOTIFY: - e_cursor_set (GTK_WIDGET (canvas)->window, E_CURSOR_ARROW); - break; - - case GDK_MOTION_NOTIFY: - convert (canvas, e->motion.x, e->motion.y, &x, &y); - if (resizing){ - int new_width; - - if (ethi->resize_guide == NULL){ - /* Quick hack until I actually bind the views */ - ethi->resize_guide = GINT_TO_POINTER (1); - gnome_canvas_item_grab (item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK, - e_cursor_get (E_CURSOR_SIZE_X), - e->button.time); - } - - new_width = x - ethi->resize_start_pos; - if (new_width <= 0) - break; - - if (new_width < ethi->resize_min_width) - break; - - ethi_request_redraw (ethi); - - ethi->resize_width = new_width; - e_table_header_set_size (ethi->eth, ethi->resize_col, ethi->resize_width); - - ethi_request_redraw (ethi); - } else - set_cursor (ethi, x); - break; - - case GDK_BUTTON_PRESS: - convert (canvas, e->button.x, e->button.y, &x, &y); - - if (is_pointer_on_division (ethi, x, &start, &col)){ - ETableCol *ecol; - - /* - * Record the important bits. - * - * By setting resize_pos to a non -1 value, - * we know that we are being resized (used in the - * other event handlers). - */ - ecol = e_table_header_get_column (ethi->eth, col); - - if (!ecol->resizeable) - break; - ethi->resize_col = col; - ethi->resize_width = ecol->width; - ethi->resize_start_pos = start - ecol->width; - ethi->resize_min_width = ecol->min_width; - } - break; - - case GDK_2BUTTON_PRESS: - if (!resizing) - break; - - if (e->button.button != 1) - break; - - printf ("Resize this guy\n"); - break; - - case GDK_BUTTON_RELEASE: { - gboolean needs_ungrab = FALSE; - - if (ethi->resize_col != -1){ - needs_ungrab = (ethi->resize_guide != NULL); - ethi_end_resize (ethi, ethi->resize_width); - } - if (needs_ungrab) - gnome_canvas_item_ungrab (item, e->button.time); - - break; - } - - default: - return FALSE; - } - return TRUE; -} - -static void -ethi_class_init (GtkObjectClass *object_class) -{ - GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class; - - ethi_parent_class = gtk_type_class (PARENT_OBJECT_TYPE); - - object_class->destroy = ethi_destroy; - object_class->set_arg = ethi_set_arg; - - item_class->update = ethi_update; - item_class->realize = ethi_realize; - item_class->unrealize = ethi_unrealize; - item_class->draw = ethi_draw; - item_class->point = ethi_point; - item_class->event = ethi_event; - - gtk_object_add_arg_type ("ETableHeaderItem::ETableHeader", GTK_TYPE_POINTER, - GTK_ARG_WRITABLE, ARG_TABLE_HEADER); - gtk_object_add_arg_type ("ETableHeaderItem::x", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_TABLE_X); - gtk_object_add_arg_type ("ETableHeaderItem::y", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_TABLE_Y); - gtk_object_add_arg_type ("ETableHeaderItem::fontset", GTK_TYPE_STRING, - GTK_ARG_WRITABLE, ARG_TABLE_FONTSET); -} - -static void -ethi_init (GnomeCanvasItem *item) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - - ethi->resize_col = -1; - - item->x1 = 0; - item->y1 = 0; - item->x2 = 0; - item->y2 = 0; -} - -GtkType -e_table_header_item_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableHeaderItem", - sizeof (ETableHeaderItem), - sizeof (ETableHeaderItemClass), - (GtkClassInitFunc) ethi_class_init, - (GtkObjectInitFunc) ethi_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_OBJECT_TYPE, &info); - } - - return type; -} - diff --git a/widgets/e-table-header-item.h b/widgets/e-table-header-item.h deleted file mode 100644 index ea2082018f..0000000000 --- a/widgets/e-table-header-item.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _E_TABLE_HEADER_ITEM_H_ -#define _E_TABLE_HEADER_ITEM_H_ - -#include <libgnomeui/gnome-canvas.h> -#include "e-table-header.h" - -#define E_TABLE_HEADER_ITEM_TYPE (e_table_header_item_get_type ()) -#define E_TABLE_HEADER_ITEM(o) (GTK_CHECK_CAST ((o), E_TABLE_HEADER_ITEM_TYPE, ETableHeaderItem)) -#define E_TABLE_HEADER_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_HEADER_ITEM_TYPE, ETableHeaderItemClass)) -#define E_IS_TABLE_HEADER_ITEM(o) (GTK_CHECK_TYPE ((o), E_TABLE_HEADER_ITEM_TYPE)) -#define E_IS_TABLE_HEADER_ITEM_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_HEADER_ITEM_TYPE)) - -typedef struct { - GnomeCanvasItem parent; - ETableHeader *eth; - - GdkGC *gc; - GdkCursor *change_cursor, *normal_cursor; - - short x1, y1, height, width; - GdkFont *font; - - /* - * Used during resizing; Could be shorts - */ - int resize_col; - int resize_width; - int resize_start_pos; - int resize_min_width; - - GtkObject *resize_guide; - - /* - * Ids - */ - int structure_change_id, dimension_change_id; -} ETableHeaderItem; - -typedef struct { - GnomeCanvasItemClass parent_class; -} ETableHeaderItemClass; - -GtkType e_table_header_item_get_type (void); - -#endif /* _E_TABLE_HEADER_ITEM_H_ */ diff --git a/widgets/e-table-header.c b/widgets/e-table-header.c deleted file mode 100644 index e91113bbb9..0000000000 --- a/widgets/e-table-header.c +++ /dev/null @@ -1,325 +0,0 @@ -/* - * E-table-col-head.c: TableColHead implementation - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkobject.h> -#include <gtk/gtksignal.h> -#include "e-table-header.h" - -enum { - STRUCTURE_CHANGE, - DIMENSION_CHANGE, - LAST_SIGNAL -}; - -static guint eth_signals [LAST_SIGNAL] = { 0, }; - -static GtkObjectClass *e_table_header_parent_class; - -static void -e_table_header_destroy (GtkObject *object) -{ - ETableHeader *eth = E_TABLE_HEADER (object); - const int cols = eth->col_count; - int i; - - /* - * Destroy columns - */ - for (i = 0; i < cols; i++){ - e_table_header_remove (eth, i); - } - - if (e_table_header_parent_class->destroy) - e_table_header_parent_class->destroy (object); -} - -static void -e_table_header_class_init (GtkObjectClass *object_class) -{ - object_class->destroy = e_table_header_destroy; - - e_table_header_parent_class = (gtk_type_class (gtk_object_get_type ())); - - eth_signals [STRUCTURE_CHANGE] = - gtk_signal_new ("structure_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableHeaderClass, structure_change), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - eth_signals [DIMENSION_CHANGE] = - gtk_signal_new ("dimension_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableHeaderClass, dimension_change), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, eth_signals, LAST_SIGNAL); -} - -GtkType -e_table_header_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableHeader", - sizeof (ETableHeader), - sizeof (ETableHeaderClass), - (GtkClassInitFunc) e_table_header_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - -ETableHeader * -e_table_header_new (void) -{ - ETableHeader *eth; - - eth = gtk_type_new (e_table_header_get_type ()); - - return eth; -} - -static void -eth_do_insert (ETableHeader *eth, int pos, ETableCol *val) -{ - memcpy (ð->columns [pos+1], ð->columns [pos], - sizeof (ETableCol *) * (eth->col_count - pos)); - eth->columns [pos] = val; -} - -static void -eth_update_offsets (ETableHeader *eth) -{ - int i; - int x = 0; - - for (i = 0; i < eth->col_count; i++){ - ETableCol *etc = eth->columns [i]; - - etc->x = x; - x += etc->width; - } -} - -void -e_table_header_add_column (ETableHeader *eth, ETableCol *tc, int pos) -{ - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (tc != NULL); - g_return_if_fail (E_IS_TABLE_COL (tc)); - g_return_if_fail (pos >= 0 && pos <= eth->col_count); - - if (pos == -1) - pos = eth->col_count; - eth->columns = g_realloc (eth->columns, sizeof (ETableCol *) * (eth->col_count + 1)); - - /* - * We are the primary owners of the column - */ - gtk_object_ref (GTK_OBJECT (tc)); - gtk_object_sink (GTK_OBJECT (tc)); - - eth_do_insert (eth, pos, tc); - eth->col_count++; - eth_update_offsets (eth); - - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); -} - -ETableCol * -e_table_header_get_column (ETableHeader *eth, int column) -{ - g_return_val_if_fail (eth != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), NULL); - - if (column < 0) - return NULL; - - if (column >= eth->col_count) - return NULL; - - return eth->columns [column]; -} - -int -e_table_header_count (ETableHeader *eth) -{ - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - return eth->col_count; -} - -int -e_table_header_index (ETableHeader *eth, const char *identifier) -{ - int i; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - g_return_val_if_fail (identifier != NULL, 0); - - for (i = 0; i < eth->col_count; i++){ - ETableCol *tc = eth->columns [i]; - - if (strcmp (tc->id, identifier) == 0) - return i; - } - - return -1; -} - -int -e_table_header_get_index_at (ETableHeader *eth, int x_offset) -{ - int i, total; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - total = 0; - for (i = 0; i < eth->col_count; i++){ - total += eth->columns [i]->width; - - if (x_offset < total) - return i; - } - - return -1; -} - -ETableCol ** -e_table_header_get_columns (ETableHeader *eth) -{ - ETableCol **ret; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - ret = g_new (ETableCol *, eth->col_count + 1); - memcpy (ret, eth->columns, sizeof (ETableCol *) * eth->col_count); - ret [eth->col_count] = NULL; - - return ret; -} - -gboolean -e_table_header_selection_ok (ETableHeader *eth) -{ - g_return_val_if_fail (eth != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), FALSE); - - return eth->selectable; -} - -int -e_table_header_get_selected (ETableHeader *eth) -{ - int i; - int selected = 0; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - for (i = 0; i < eth->col_count; i++){ - if (eth->columns [i]->selected) - selected++; - } - - return selected; -} - -int -e_table_header_total_width (ETableHeader *eth) -{ - int total, i; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - total = 0; - for (i = 0; i < eth->col_count; i++) - total += eth->columns [i]->width; - - return total; -} - -static void -eth_do_remove (ETableHeader *eth, int idx, gboolean do_unref) -{ - if (do_unref) - gtk_object_unref (GTK_OBJECT (eth->columns [idx])); - - memcpy (ð->columns [idx], ð->columns [idx+1], - sizeof (ETableCol *) * eth->col_count - idx); - eth->col_count--; -} - -void -e_table_header_move (ETableHeader *eth, int source_index, int target_index) -{ - ETableCol *old; - - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (source_index >= 0); - g_return_if_fail (target_index >= 0); - g_return_if_fail (source_index < eth->col_count); - g_return_if_fail (target_index < eth->col_count); - - old = eth->columns [source_index]; - eth_do_remove (eth, source_index, FALSE); - eth_do_insert (eth, target_index, old); - eth_update_offsets (eth); - - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); -} - -void -e_table_header_remove (ETableHeader *eth, int idx) -{ - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < eth->col_count); - - eth_do_remove (eth, idx, TRUE); - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); -} - -void -e_table_header_set_selection (ETableHeader *eth, gboolean allow_selection) -{ -} - -void -e_table_header_set_size (ETableHeader *eth, int idx, int size) -{ - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < eth->col_count); - g_return_if_fail (size > 0); - - eth->columns [idx]->width = size; - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE], idx); -} diff --git a/widgets/e-table-header.h b/widgets/e-table-header.h deleted file mode 100644 index c263c36ad3..0000000000 --- a/widgets/e-table-header.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _E_TABLE_COLUMN_H_ -#define _E_TABLE_COLUMN_H_ - -#include <gtk/gtkobject.h> -#include <gdk/gdk.h> -#include "e-table-col.h" - -typedef struct _ETableHeader ETableHeader; - -#define E_TABLE_HEADER_TYPE (e_table_header_get_type ()) -#define E_TABLE_HEADER(o) (GTK_CHECK_CAST ((o), E_TABLE_HEADER_TYPE, ETableHeader)) -#define E_TABLE_HEADER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_HEADER_TYPE, ETableHeaderClass)) -#define E_IS_TABLE_HEADER(o) (GTK_CHECK_TYPE ((o), E_TABLE_HEADER_TYPE)) -#define E_IS_TABLE_HEADER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_HEADER_TYPE)) - -/* - * A Columnar header. - */ -struct _ETableHeader { - GtkObject base; - - int col_count; - ETableCol **columns; - gboolean selectable; -}; - -typedef struct { - GtkObjectClass parent_class; - - void (*structure_change) (ETableHeader *eth); - void (*dimension_change) (ETableHeader *eth, int col); -} ETableHeaderClass; - -GtkType e_table_header_get_type (void); -ETableHeader *e_table_header_new (void); - -void e_table_header_add_column (ETableHeader *eth, - ETableCol *tc, int pos); -ETableCol * e_table_header_get_column (ETableHeader *eth, - int column); -int e_table_header_count (ETableHeader *eth); -int e_table_header_index (ETableHeader *eth, - const char *identifier); -int e_table_header_get_index_at (ETableHeader *eth, - int x_offset); -ETableCol **e_table_header_get_columns (ETableHeader *eth); -gboolean e_table_header_selection_ok (ETableHeader *eth); -int e_table_header_get_selected (ETableHeader *eth); -int e_table_header_total_width (ETableHeader *eth); -void e_table_header_move (ETableHeader *eth, - int source_index, - int target_index); -void e_table_header_remove (ETableHeader *eth, int idx); -void e_table_header_set_size (ETableHeader *eth, int idx, int size); -void e_table_header_set_selection (ETableHeader *eth, - gboolean allow_selection); - -GList *e_table_header_get_selected_indexes(ETableHeader *eth); - - -#endif /* _E_TABLE_HEADER_H_ */ - diff --git a/widgets/e-table-item.c b/widgets/e-table-item.c deleted file mode 100644 index ceb6adda95..0000000000 --- a/widgets/e-table-item.c +++ /dev/null @@ -1,1151 +0,0 @@ -/* - * E-table-item.c: A GnomeCanvasItem that is a view of an ETableModel. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc. - * - * TODO: - * Add a border to the thing, so that focusing works properly. - * - */ -#include <config.h> -#include <stdio.h> -#include <gtk/gtksignal.h> -#include <gdk/gdkkeysyms.h> -#include "e-table-item.h" -#include "e-cell.h" - -#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type () - -#define FOCUSED_BORDER 2 - -static GnomeCanvasItemClass *eti_parent_class; - -enum { - ROW_SELECTION, - LAST_SIGNAL -}; - -static gint eti_signals [LAST_SIGNAL] = { 0, }; - -enum { - ARG_0, - ARG_TABLE_HEADER, - ARG_TABLE_MODEL, - ARG_TABLE_X, - ARG_TABLE_Y, - ARG_TABLE_DRAW_GRID, - ARG_TABLE_DRAW_FOCUS, - ARG_MODE_SPREADSHEET, - ARG_LENGHT_THRESHOLD -}; - -static gboolean -eti_editing (ETableItem *eti) -{ - if (eti->editing_col == -1) - return FALSE; - else - return TRUE; -} - -/* - * During realization, we have to invoke the per-ecell realize routine - * (On our current setup, we have one e-cell per column. - * - * We might want to optimize this to only realize the unique e-cells: - * ie, a strings-only table, uses the same e-cell for every column, and - * we might want to avoid realizing each e-cell. - */ -static void -eti_realize_cell_views (ETableItem *eti) -{ - int i; - - /* - * Now realize the various ECells - */ - eti->n_cells = eti->cols; - eti->cell_views = g_new (ECellView *, eti->n_cells); - - for (i = 0; i < eti->n_cells; i++){ - ETableCol *col = e_table_header_get_column (eti->header, i); - - eti->cell_views [i] = e_cell_realize (col->ecell, eti); - } -} - -/* - * During unrealization: we invoke every e-cell (one per column in the current - * setup) to dispose all resources allocated - */ -static void -eti_unrealize_cell_views (ETableItem *eti) -{ - int i; - - for (i = 0; i < eti->n_cells; i++){ - e_cell_unrealize (eti->cell_views [i]); - eti->cell_views [i] = NULL; - } - g_free (eti->cell_views); - eti->n_cells = 0; - -} - -/* - * GnomeCanvasItem::update method - */ -static void -eti_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) -{ - ETableItem *eti = E_TABLE_ITEM (item); - - if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update) - (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)(item, affine, clip_path, flags); - - item->x1 = eti->x1; - item->y1 = eti->y1; - item->x2 = eti->x1 + eti->width; - item->y2 = eti->y1 + eti->height; - - gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item); -} - -/* - * eti_remove_table_model: - * - * Invoked to release the table model associated with this ETableItem - */ -static void -eti_remove_table_model (ETableItem *eti) -{ - if (!eti->table_model) - return; - - gtk_signal_disconnect (GTK_OBJECT (eti->table_model), - eti->table_model_change_id); - gtk_object_unref (GTK_OBJECT (eti->table_model)); - - eti->table_model_change_id = 0; - eti->table_model = NULL; -} - -/* - * eti_remove_header_model: - * - * Invoked to release the header model associated with this ETableItem - */ -static void -eti_remove_header_model (ETableItem *eti) -{ - if (!eti->header) - return; - - gtk_signal_disconnect (GTK_OBJECT (eti->header), - eti->header_structure_change_id); - gtk_signal_disconnect (GTK_OBJECT (eti->header), - eti->header_dim_change_id); - gtk_object_unref (GTK_OBJECT (eti->header)); - - eti->header_structure_change_id = 0; - eti->header_dim_change_id = 0; - eti->header = NULL; -} - -/* - * eti_row_height: - * - * Returns the height used by row @row. This does not include the one-pixel - * used as a separator between rows - */ -static int -eti_row_height (ETableItem *eti, int row) -{ - const int cols = e_table_header_count (eti->header); - int col; - int h, max_h; - - max_h = 0; - - for (col = 0; col < cols; col++){ - h = e_cell_height (eti->cell_views [col], col, row); - - if (h > max_h) - max_h = h; - } - return max_h; -} - -/* - * eti_get_height: - * - * Returns the height of the ETableItem. - * - * The ETableItem might compute the whole height by asking every row its - * size. There is a special mode (designed to work when there are too - * many rows in the table that performing the previous step could take - * too long) set by the ETableItem->length_threshold that would determine - * when the height is computed by using the first row as the size for - * every other row in the ETableItem. - */ -static int -eti_get_height (ETableItem *eti) -{ - const int rows = eti->rows; - int row; - int height; - - if (rows == 0) - return 0; - - if (eti->length_threshold != -1){ - if (rows > eti->length_threshold){ - height = (eti_row_height (eti, 0) + 1) * rows; - - /* - * 1 pixel at the top - */ - return height + 1; - } - } - - height = 1; - for (row = 0; row < rows; row++) - height += eti_row_height (eti, row) + 1; - - return height; -} - -/* - * Callback routine: invoked when the ETableModel has suffered a change - */ -static void -eti_table_model_changed (ETableModel *table_model, ETableItem *eti) -{ - eti->cols = e_table_model_column_count (eti->table_model); - eti->rows = e_table_model_row_count (eti->table_model); - - if (eti->cell_views) - eti->height = eti_get_height (eti); - - eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0); -} - -/* - * eti_request_redraw: - * - * Queues a canvas redraw for the entire ETableItem. - */ -static void -eti_request_redraw (ETableItem *eti) -{ - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - - gnome_canvas_request_redraw (canvas, eti->x1, eti->y1, - eti->x1 + eti->width + 1, - eti->y1 + eti->height + 1); -} - -/* - * Computes the distance from @start_col to @end_col in pixels. - */ -static int -eti_col_diff (ETableItem *eti, int start_col, int end_col) -{ - int col, total; - - total = 0; - for (col = start_col; col < end_col; col++){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - total += ecol->width; - } - - return total; -} - -/* - * Computes the distance between @start_row and @end_row in pixels - */ -static int -eti_row_diff (ETableItem *eti, int start_row, int end_row) -{ - int row, total; - - total = 0; - - for (row = start_row; row < end_row; row++) - total += eti_row_height (eti, row) + 1; - - return total; -} - -/* - * eti_request_region_redraw: - * - * Request a canvas redraw on the range (start_col, start_row) to (end_col, end_row). - * This is inclusive (ie, you can use: 0,0-0,0 to redraw the first cell). - * - * The @border argument is a number of pixels around the region that should also be queued - * for redraw. This is typically used by the focus routines to queue a redraw for the - * border as well. - */ -static void -eti_request_region_redraw (ETableItem *eti, - int start_col, int start_row, - int end_col, int end_row, int border) -{ - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - int x1, y1, width, height; - - x1 = eti_col_diff (eti, 0, start_col); - y1 = eti_row_diff (eti, 0, start_row); - width = eti_col_diff (eti, start_col, end_col + 1); - height = eti_row_diff (eti, start_row, end_row + 1); - - gnome_canvas_request_redraw (canvas, - eti->x1 + x1 - border, - eti->y1 + y1 - border, - eti->x1 + x1 + width + 1 + border, - eti->y1 + y1 + height + 1 + border); -} - -void -e_table_item_redraw_range (ETableItem *eti, - int start_col, int start_row, - int end_col, int end_row) -{ - int border; - - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if ((start_col == eti->focused_col) || - (end_col == eti->focused_col) || - (start_row == eti->focused_row) || - (end_row == eti->focused_row)) - border = 2; - else - border = 0; - - eti_request_region_redraw (eti, start_col, start_row, end_col, end_row, border); -} - -static void -eti_add_table_model (ETableItem *eti, ETableModel *table_model) -{ - g_assert (eti->table_model == NULL); - - eti->table_model = table_model; - gtk_object_ref (GTK_OBJECT (eti->table_model)); - - eti->table_model_change_id = gtk_signal_connect ( - GTK_OBJECT (table_model), "model_changed", - GTK_SIGNAL_FUNC (eti_table_model_changed), eti); - eti_table_model_changed (table_model, eti); -} - -static void -eti_header_dim_changed (ETableHeader *eth, int col, ETableItem *eti) -{ - eti_request_redraw (eti); - - eti->width = e_table_header_total_width (eti->header); - eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0); - - eti_request_redraw (eti); -} - -static void -eti_header_structure_changed (ETableHeader *eth, ETableItem *eti) -{ - eti_request_redraw (eti); - - eti->width = e_table_header_total_width (eti->header); - eti_unrealize_cell_views (eti); - eti_realize_cell_views (eti); - eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0); - - eti_request_redraw (eti); -} - -static void -eti_add_header_model (ETableItem *eti, ETableHeader *header) -{ - g_assert (eti->header == NULL); - - eti->header = header; - gtk_object_ref (GTK_OBJECT (header)); - - eti->width = e_table_header_total_width (header); - - eti->header_dim_change_id = gtk_signal_connect ( - GTK_OBJECT (header), "dimension_change", - GTK_SIGNAL_FUNC (eti_header_dim_changed), eti); - - eti->header_structure_change_id = gtk_signal_connect ( - GTK_OBJECT (header), "structure_change", - GTK_SIGNAL_FUNC (eti_header_structure_changed), eti); -} - -/* - * GtkObject::destroy method - */ -static void -eti_destroy (GtkObject *object) -{ - ETableItem *eti = E_TABLE_ITEM (object); - - eti_remove_header_model (eti); - eti_remove_table_model (eti); - - g_slist_free (eti->selection); - - if (GTK_OBJECT_CLASS (eti_parent_class)->destroy) - (*GTK_OBJECT_CLASS (eti_parent_class)->destroy) (object); -} - -static void -eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ETableItem *eti; - - item = GNOME_CANVAS_ITEM (o); - eti = E_TABLE_ITEM (o); - - switch (arg_id){ - case ARG_TABLE_HEADER: - eti_remove_header_model (eti); - eti_add_header_model (eti, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_TABLE_MODEL: - eti_remove_table_model (eti); - eti_add_table_model (eti, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_TABLE_X: - eti->x1 = GTK_VALUE_INT (*arg); - break; - - case ARG_TABLE_Y: - eti->y1 = GTK_VALUE_INT (*arg); - break; - - case ARG_LENGHT_THRESHOLD: - eti->length_threshold = GTK_VALUE_INT (*arg); - break; - - case ARG_TABLE_DRAW_GRID: - eti->draw_grid = GTK_VALUE_BOOL (*arg); - break; - - case ARG_TABLE_DRAW_FOCUS: - eti->draw_focus = GTK_VALUE_BOOL (*arg); - break; - - case ARG_MODE_SPREADSHEET: - eti->mode_spreadsheet = GTK_VALUE_BOOL (*arg); - break; - } - eti_update (item, NULL, NULL, 0); -} - -static void -eti_init (GnomeCanvasItem *item) -{ - ETableItem *eti = E_TABLE_ITEM (item); - - eti->focused_col = -1; - eti->focused_row = -1; - eti->editing_col = -1; - eti->editing_row = -1; - eti->height = 0; - - eti->length_threshold = -1; - - eti->selection_mode = GTK_SELECTION_SINGLE; -} - -#define gray50_width 2 -#define gray50_height 2 -static const char gray50_bits[] = { - 0x02, 0x01, }; - -static void -eti_realize (GnomeCanvasItem *item) -{ - ETableItem *eti = E_TABLE_ITEM (item); - GtkWidget *canvas_widget = GTK_WIDGET (item->canvas); - GdkWindow *window; - - if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize) - (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize)(item); - - /* - * Gdk Resource allocation - */ - window = canvas_widget->window; - - eti->fill_gc = canvas_widget->style->white_gc; - gdk_gc_ref (canvas_widget->style->white_gc); - - eti->grid_gc = gdk_gc_new (window); -#if 0 - /* This sets it to gray */ -/* gdk_gc_set_foreground (eti->grid_gc, &canvas_widget->style->bg [GTK_STATE_NORMAL]); */ -#else - gdk_gc_set_foreground (eti->grid_gc, &canvas_widget->style->black); -#endif - eti->focus_gc = gdk_gc_new (window); - gdk_gc_set_foreground (eti->focus_gc, &canvas_widget->style->bg [GTK_STATE_NORMAL]); - gdk_gc_set_background (eti->focus_gc, &canvas_widget->style->fg [GTK_STATE_NORMAL]); - eti->stipple = gdk_bitmap_create_from_data (NULL, gray50_bits, gray50_width, gray50_height); - gdk_gc_set_ts_origin (eti->focus_gc, 0, 0); - gdk_gc_set_stipple (eti->focus_gc, eti->stipple); - gdk_gc_set_fill (eti->focus_gc, GDK_OPAQUE_STIPPLED); - - /* - * - */ - eti_realize_cell_views (eti); - - eti->height = eti_get_height (eti); - eti_update (item, NULL, NULL, 0); -} - -static void -eti_unrealize (GnomeCanvasItem *item) -{ - ETableItem *eti = E_TABLE_ITEM (item); - - gdk_gc_unref (eti->fill_gc); - eti->fill_gc = NULL; - gdk_gc_unref (eti->grid_gc); - eti->grid_gc = NULL; - gdk_gc_unref (eti->focus_gc); - eti->focus_gc = NULL; - gdk_bitmap_unref (eti->stipple); - eti->stipple = NULL; - - eti_unrealize_cell_views (eti); - - eti->height = 0; - - if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->unrealize) - (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->unrealize)(item); -} - -static void -draw_cell (ETableItem *eti, GdkDrawable *drawable, int col, int row, gboolean selected, - int x1, int y1, int x2, int y2) -{ - ECellView *ecell_view; - - ecell_view = eti->cell_views [col]; - - e_cell_draw (ecell_view, drawable, col, row, selected, x1, y1, x2, y2); - -#if 0 - { - GdkFont *font; - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - - font = GTK_WIDGET (canvas)->style->font; - - sprintf (text, "%d:%d\n", col, row); gdk_draw_line (drawable, eti->grid_gc, x1, y1, x2, y2); - gdk_draw_line (drawable, eti->grid_gc, x1, y2, x2, y1); - - sprintf (text, "%d:%d\n", col, row); - gdk_draw_text (drawable, font, eti->grid_gc, x1, y2, text, strlen (text)); - } -#endif -} - -static void -eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height) -{ - ETableItem *eti = E_TABLE_ITEM (item); - const int rows = eti->rows; - const int cols = eti->cols; - int row, col, y1, y2; - int first_col, last_col, x_offset; - int first_row, last_row, y_offset, yd; - int x1, x2; - int f_x1, f_x2, f_y1, f_y2; - gboolean f_found; - -/* printf ("Rect: %d %d %d %d\n", x, y, width, height); */ - /* - * Clear the background - */ -#if 0 - gdk_draw_rectangle ( - drawable, eti->fill_gc, TRUE, - eti->x1 - x, eti->y1 - y, eti->width, eti->height); -#endif - - /* - * First column to draw, last column to draw - */ - first_col = -1; - last_col = x_offset = 0; - x1 = x2 = eti->x1; - for (col = 0; col < cols; col++, x1 = x2){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - x2 = x1 + ecol->width; - - if (x1 > (x + width)) - break; - if (x2 < x) - continue; - if (first_col == -1){ - x_offset = x1 - x; - first_col = col; - } - } - last_col = col; - - /* - * Nothing to paint - */ - if (first_col == -1) - return; - - /* - * Compute row span. - */ - first_row = -1; - y_offset = 0; - y1 = y2 = eti->y1 + 1; - for (row = 0; row < rows; row++, y1 = y2){ - - y2 += eti_row_height (eti, row) + 1; - - if (y1 > y + height) - break; - - if (y2 < y) - continue; - - if (first_row == -1){ - y_offset = y1 - y; - first_row = row; - } - } - last_row = row; - - if (first_row == -1) - return; - - /* - * Draw cells - */ - yd = y_offset; - f_x1 = f_x2 = f_y1 = f_y2 = -1; - f_found = FALSE; - - if (eti->draw_grid && first_row == 0){ - gdk_draw_line ( - drawable, eti->grid_gc, - eti->x1 - x, yd, eti->x1 + eti->width - x, yd); - } - yd++; - - for (row = first_row; row < last_row; row++){ - int xd, height; - gboolean selected; - - height = eti_row_height (eti, row); - - xd = x_offset; -/* printf ("paint: %d %d\n", yd, yd + height); */ - - selected = g_slist_find (eti->selection, GINT_TO_POINTER (row)) != NULL; - - for (col = first_col; col < last_col; col++){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - draw_cell (eti, drawable, col, row, selected, xd, yd, xd + ecol->width, yd + height); - - if (col == eti->focused_col && row == eti->focused_row){ - f_x1 = xd; - f_x2 = xd + ecol->width; - f_y1 = yd; - f_y2 = yd + height; - f_found = TRUE; - } - - xd += ecol->width; - } - yd += height; - - if (eti->draw_grid) - gdk_draw_line ( - drawable, eti->grid_gc, - eti->x1 - x, yd, eti->x1 + eti->width - x, yd); - yd++; - } - - if (eti->draw_grid){ - int xd = x_offset; - - for (col = first_col; col <= last_col; col++){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - gdk_draw_line ( - drawable, eti->grid_gc, - xd, y_offset, xd, yd - 1); - - /* - * This looks wierd, but it is to draw the last line - */ - if (ecol) - xd += ecol->width; - } - } - - /* - * Draw focus - */ - if (f_found && eti->draw_focus){ - - if (!eti_editing (eti)) - gdk_draw_rectangle ( - drawable, eti->focus_gc, FALSE, - f_x1 + 1, f_y1, f_x2 - f_x1 - 2, f_y2 - f_y1 - 1); - } -} - -static double -eti_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - - return 0.0; -} - -static gboolean -find_cell (ETableItem *eti, double x, double y, int *col_res, int *row_res, gdouble *x1_res, gdouble *y1_res) -{ - const int cols = eti->cols; - const int rows = eti->rows; - gdouble x1, y1, x2, y2; - int col, row; - - /* FIXME: this routine is inneficient, fix later */ - - x -= eti->x1; - y -= eti->y1; - - x1 = 0; - for (col = 0; col < cols; col++, x1 = x2){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - if (x < x1) - return FALSE; - - x2 = x1 + ecol->width; - - if (x > x2) - continue; - - *col_res = col; - if (x1_res) - *x1_res = x - x1; - break; - } - - y1 = y2 = 0; - for (row = 0; row < rows; row++, y1 = y2){ - if (y < y1) - return FALSE; - - y2 += eti_row_height (eti, row) + 1; - - if (y > y2) - continue; - - *row_res = row; - if (y1_res) - *y1_res = y - y1; - break; - } - - return TRUE; -} - -static int -eti_event (GnomeCanvasItem *item, GdkEvent *e) -{ - ETableItem *eti = E_TABLE_ITEM (item); - ECellView *ecell_view; - - switch (e->type){ - case GDK_BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - case GDK_2BUTTON_PRESS: { - int col, row; - gdouble x1, y1; - - if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1)) - return TRUE; - - if (eti->focused_row == row && eti->focused_col == col){ - ecell_view = eti->cell_views [col]; - - /* - * Adjust the event positions - */ - e->button.x = x1; - e->button.y = y1; - - e_cell_event (ecell_view, e, col, row); - } else { - /* - * Focus the cell, and select the row - */ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, col, row); - e_table_item_select_row (eti, row); - } - break; - } - - case GDK_MOTION_NOTIFY: { - int col, row; - double x1, y1; - - if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1)) - return TRUE; - - if (eti->focused_row == row && eti->focused_col == col){ - ecell_view = eti->cell_views [col]; - - /* - * Adjust the event positions - */ - e->button.x -= (x1 + eti->x1); - e->button.y -= (y1 + eti->y1); - - e_cell_event (ecell_view, e, col, row); - } - break; - } - - case GDK_KEY_PRESS: - if (eti->focused_col == -1) - return FALSE; - - switch (e->key.keyval){ - case GDK_Left: - if (!eti->mode_spreadsheet && eti_editing (eti)) - break; - - if (eti->focused_col > 0){ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, eti->focused_col - 1, eti->focused_row); - } - return TRUE; - - case GDK_Right: - if (!eti->mode_spreadsheet && eti_editing (eti)) - break; - - if ((eti->focused_col + 1) < eti->cols){ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, eti->focused_col + 1, eti->focused_row); - } - return TRUE; - - case GDK_Up: - if (eti->focused_row > 0){ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, eti->focused_col, eti->focused_row - 1); - } - return TRUE; - - case GDK_Down: - if ((eti->focused_row + 1) < eti->rows){ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, eti->focused_col, eti->focused_row + 1); - } - return TRUE; - default: - if (!eti_editing (eti)){ - if ((e->key.state & (GDK_MOD1_MASK | GDK_CONTROL_MASK)) != 0) - return 0; - - if (!(e->key.keyval >= 0x20 && e->key.keyval <= 0xff)) - return 0; - } - } - - ecell_view = eti->cell_views [eti->focused_col]; - e_cell_event (ecell_view, e, eti->focused_col, eti->focused_row); - break; - - case GDK_KEY_RELEASE: - if (eti->focused_col == -1) - return FALSE; - - if (eti_editing (eti)){ - ecell_view = eti->cell_views [eti->editing_col]; - e_cell_event (ecell_view, e, eti->editing_col, eti->editing_row); - } - break; - - default: - return FALSE; - } - return TRUE; -} - -/* - * ETableItem::row_selection method - */ -static void -eti_row_selection (ETableItem *eti, int row, gboolean selected) -{ - eti_request_region_redraw (eti, 0, row, eti->cols - 1, row, 0); - - if (selected) - eti->selection = g_slist_prepend (eti->selection, GINT_TO_POINTER (row)); - else - eti->selection = g_slist_remove (eti->selection, GINT_TO_POINTER (row)); - -} - -static void -eti_class_init (GtkObjectClass *object_class) -{ - GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class; - ETableItemClass *eti_class = (ETableItemClass *) object_class; - - eti_parent_class = gtk_type_class (PARENT_OBJECT_TYPE); - - object_class->destroy = eti_destroy; - object_class->set_arg = eti_set_arg; - - item_class->update = eti_update; - item_class->realize = eti_realize; - item_class->unrealize = eti_unrealize; - item_class->draw = eti_draw; - item_class->point = eti_point; - item_class->event = eti_event; - - eti_class->row_selection = eti_row_selection; - - gtk_object_add_arg_type ("ETableItem::ETableHeader", GTK_TYPE_POINTER, - GTK_ARG_WRITABLE, ARG_TABLE_HEADER); - gtk_object_add_arg_type ("ETableItem::ETableModel", GTK_TYPE_POINTER, - GTK_ARG_WRITABLE, ARG_TABLE_MODEL); - gtk_object_add_arg_type ("ETableItem::x", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_TABLE_X); - gtk_object_add_arg_type ("ETableItem::y", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_TABLE_Y); - gtk_object_add_arg_type ("ETableItem::drawgrid", GTK_TYPE_BOOL, - GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID); - gtk_object_add_arg_type ("ETableItem::drawfocus", GTK_TYPE_BOOL, - GTK_ARG_WRITABLE, ARG_TABLE_DRAW_FOCUS); - gtk_object_add_arg_type ("ETableItem::spreadsheet", GTK_TYPE_BOOL, - GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET); - - eti_signals [ROW_SELECTION] = - gtk_signal_new ("row_selection", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableItemClass, row_selection), - gtk_marshal_NONE__INT_INT, - GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, eti_signals, LAST_SIGNAL); - -} - -GtkType -e_table_item_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableItem", - sizeof (ETableItem), - sizeof (ETableItemClass), - (GtkClassInitFunc) eti_class_init, - (GtkObjectInitFunc) eti_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_OBJECT_TYPE, &info); - } - - return type; -} - -void -e_table_item_focus (ETableItem *eti, int col, int row) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (eti->focused_col != -1) - e_table_item_unfocus (eti); - - eti->focused_col = col; - eti->focused_row = row; - - eti_request_region_redraw (eti, col, row, col, row, FOCUSED_BORDER); - - /* - * make sure we have the Gtk Focus - */ - gtk_widget_grab_focus (GTK_WIDGET (GNOME_CANVAS_ITEM (eti)->canvas)); -} - -void -e_table_item_unfocus (ETableItem *eti) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (eti->focused_row == -1) - return; - - { - const int col = eti->focused_col; - const int row = eti->focused_row; - - eti_request_region_redraw (eti, col, row, col, row, FOCUSED_BORDER); - } - eti->focused_col = -1; - eti->focused_row = -1; -} - -const GSList * -e_table_item_get_selection (ETableItem *eti) -{ - g_return_val_if_fail (eti != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_ITEM (eti), NULL); - - return eti->selection; -} - -GtkSelectionMode -e_table_item_get_selection_mode (ETableItem *eti) -{ - g_return_val_if_fail (eti != NULL, GTK_SELECTION_SINGLE); - g_return_val_if_fail (E_IS_TABLE_ITEM (eti), GTK_SELECTION_SINGLE); - - return eti->selection_mode; -} - -void -e_table_item_set_selection_mode (ETableItem *eti, GtkSelectionMode selection_mode) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (selection_mode == GTK_SELECTION_BROWSE || - selection_mode == GTK_SELECTION_EXTENDED){ - g_error ("GTK_SELECTION_BROWSE and GTK_SELECTION_EXTENDED are not implemented"); - } - - eti->selection_mode = selection_mode; -} - -gboolean -e_table_item_is_row_selected (ETableItem *eti, int row) -{ - g_return_val_if_fail (eti != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_ITEM (eti), FALSE); - - if (g_slist_find (eti->selection, GINT_TO_POINTER (row))) - return TRUE; - else - return FALSE; -} - -void -e_table_item_unselect_row (ETableItem *eti, int row) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (e_table_item_is_row_selected (eti, row)){ - gtk_signal_emit ( - GTK_OBJECT (eti), eti_signals [ROW_SELECTION], - row, 0); - } -} - -void -e_table_item_select_row (ETableItem *eti, int row) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - switch (eti->selection_mode){ - case GTK_SELECTION_SINGLE: - if (eti->selection){ - gtk_signal_emit ( - GTK_OBJECT (eti), eti_signals [ROW_SELECTION], - GPOINTER_TO_INT (eti->selection->data), 0); - } - g_slist_free (eti->selection); - eti->selection = NULL; - - gtk_signal_emit ( - GTK_OBJECT (eti), eti_signals [ROW_SELECTION], - GINT_TO_POINTER (row), 1); - break; - - case GTK_SELECTION_MULTIPLE: - if (g_slist_find (eti->selection, GINT_TO_POINTER (row))) - return; - gtk_signal_emit ( - GTK_OBJECT (eti), eti_signals [ROW_SELECTION], - GINT_TO_POINTER (row), 1); - break; - - default: - - } -} - -void -e_table_item_enter_edit (ETableItem *eti, int col, int row) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - eti->editing_col = col; - eti->editing_row = row; - - eti->edit_ctx = e_cell_enter_edit (eti->cell_views [col], col, row); -} - -void -e_table_item_leave_edit (ETableItem *eti) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (!eti_editing (eti)) - return; - - e_cell_leave_edit (eti->cell_views [eti->editing_col], eti->editing_col, eti->editing_row, eti->edit_ctx); - eti->editing_col = -1; - eti->editing_row = -1; - eti->edit_ctx = NULL; -} - diff --git a/widgets/e-table-item.h b/widgets/e-table-item.h deleted file mode 100644 index 6c4d837310..0000000000 --- a/widgets/e-table-item.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef _E_TABLE_ITEM_H_ -#define _E_TABLE_ITEM_H_ - -#include <libgnomeui/gnome-canvas.h> -#include "e-table-model.h" -#include "e-table-header.h" - -#define E_TABLE_ITEM_TYPE (e_table_item_get_type ()) -#define E_TABLE_ITEM(o) (GTK_CHECK_CAST ((o), E_TABLE_ITEM_TYPE, ETableItem)) -#define E_TABLE_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_ITEM_TYPE, ETableItemClass)) -#define E_IS_TABLE_ITEM(o) (GTK_CHECK_TYPE ((o), E_TABLE_ITEM_TYPE)) -#define E_IS_TABLE_ITEM_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_ITEM_TYPE)) - -typedef struct { - GnomeCanvasItem parent; - ETableModel *table_model; - ETableHeader *header; - - int x1, y1; - int width, height; - - int cols, rows; - - /* - * Ids for the signals we connect to - */ - int header_dim_change_id; - int header_structure_change_id; - int table_model_change_id; - - GdkGC *fill_gc; - GdkGC *grid_gc; - GdkGC *focus_gc; - GdkBitmap *stipple; - - unsigned int draw_grid:1; - unsigned int draw_focus:1; - unsigned int mode_spreadsheet:1; - - int focused_col, focused_row; - - /* - * Realized views, per column - */ - ECellView **cell_views; - int n_cells; - - /* - * Lengh Threshold: above this, we stop computing correctly - * the size - */ - int length_threshold; - - GSList *selection; - GtkSelectionMode selection_mode; - - /* - * During edition - */ - int editing_col, editing_row; - void *edit_ctx; -} ETableItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - - void (*row_selection) (ETableItem *eti, int row, gboolean selected); -} ETableItemClass; - -GtkType e_table_item_get_type (void); - -/* - * Focus - */ -void e_table_item_focus (ETableItem *eti, int col, int row); -void e_table_item_unfocus (ETableItem *eti); - -/* - * Selection - */ -void e_table_item_select_row (ETableItem *e_table_Item, int row); -void e_table_item_unselect_row (ETableItem *e_table_Item, int row); - -/* - * Handling the selection - */ -const GSList*e_table_item_get_selection (ETableItem *e_table_Item); - -GtkSelectionMode e_table_item_get_selection_mode (ETableItem *e_table_Item); -void e_table_item_set_selection_mode (ETableItem *e_table_Item, - GtkSelectionMode selection_mode); -gboolean e_table_item_is_row_selected (ETableItem *e_table_Item, - int row); - -void e_table_item_leave_edit (ETableItem *eti); -void e_table_item_enter_edit (ETableItem *eti, int col, int row); - -void e_table_item_redraw_range (ETableItem *eti, - int start_col, int start_row, - int end_col, int end_row); - -#endif /* _E_TABLE_ITEM_H_ */ diff --git a/widgets/e-table-model.c b/widgets/e-table-model.c deleted file mode 100644 index 103bb31b57..0000000000 --- a/widgets/e-table-model.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * e-table-model.c: a Table Model - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc. - */ -#include <config.h> -#include <gtk/gtksignal.h> -#include "e-table-model.h" - -#define ETM_CLASS(e) ((ETableModelClass *)((GtkObject *)e)->klass) - -static GtkObjectClass *e_table_model_parent_class; - -enum { - MODEL_CHANGED, - MODEL_ROW_CHANGED, - MODEL_CELL_CHANGED, - ROW_SELECTION, - LAST_SIGNAL -}; - -static guint e_table_model_signals [LAST_SIGNAL] = { 0, }; - -int -e_table_model_column_count (ETableModel *e_table_model) -{ - g_return_val_if_fail (e_table_model != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), 0); - - return ETM_CLASS (e_table_model)->column_count (e_table_model); -} - -const char * -e_table_model_column_name (ETableModel *e_table_model, int col) -{ - g_return_val_if_fail (e_table_model != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), NULL); - - return ETM_CLASS (e_table_model)->column_name (e_table_model, col); -} - -int -e_table_model_row_count (ETableModel *e_table_model) -{ - g_return_val_if_fail (e_table_model != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), 0); - - return ETM_CLASS (e_table_model)->row_count (e_table_model); -} - -void * -e_table_model_value_at (ETableModel *e_table_model, int col, int row) -{ - g_return_val_if_fail (e_table_model != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), NULL); - - return ETM_CLASS (e_table_model)->value_at (e_table_model, col, row); -} - -void -e_table_model_set_value_at (ETableModel *e_table_model, int col, int row, const void *data) -{ - g_return_if_fail (e_table_model != NULL); - g_return_if_fail (E_IS_TABLE_MODEL (e_table_model)); - - return ETM_CLASS (e_table_model)->set_value_at (e_table_model, col, row, data); -} - -gboolean -e_table_model_is_cell_editable (ETableModel *e_table_model, int col, int row) -{ - g_return_val_if_fail (e_table_model != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), FALSE); - - return ETM_CLASS (e_table_model)->is_cell_editable (e_table_model, col, row); -} - -static void -e_table_model_destroy (GtkObject *object) -{ - if (e_table_model_parent_class->destroy) - (*e_table_model_parent_class->destroy)(object); -} - -static void -e_table_model_class_init (GtkObjectClass *object_class) -{ - e_table_model_parent_class = gtk_type_class (gtk_object_get_type ()); - - object_class->destroy = e_table_model_destroy; - - e_table_model_signals [MODEL_CHANGED] = - gtk_signal_new ("model_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableModelClass, model_changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - e_table_model_signals [MODEL_ROW_CHANGED] = - gtk_signal_new ("model_row_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableModelClass, model_row_changed), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - e_table_model_signals [MODEL_CELL_CHANGED] = - gtk_signal_new ("model_cell_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableModelClass, model_cell_changed), - gtk_marshal_NONE__INT_INT, - GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, e_table_model_signals, LAST_SIGNAL); -} - -GtkType -e_table_model_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableModel", - sizeof (ETableModel), - sizeof (ETableModelClass), - (GtkClassInitFunc) e_table_model_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - -void -e_table_model_changed (ETableModel *e_table_model) -{ - g_return_if_fail (e_table_model != NULL); - g_return_if_fail (E_IS_TABLE_MODEL (e_table_model)); - - gtk_signal_emit (GTK_OBJECT (e_table_model), - e_table_model_signals [MODEL_CHANGED]); -} - -void -e_table_model_row_changed (ETableModel *e_table_model, int row) -{ - g_return_if_fail (e_table_model != NULL); - g_return_if_fail (E_IS_TABLE_MODEL (e_table_model)); - - gtk_signal_emit (GTK_OBJECT (e_table_model), - e_table_model_signals [MODEL_ROW_CHANGED], row); -} - -void -e_table_model_cell_changed (ETableModel *e_table_model, int col, int row) -{ - g_return_if_fail (e_table_model != NULL); - g_return_if_fail (E_IS_TABLE_MODEL (e_table_model)); - - gtk_signal_emit (GTK_OBJECT (e_table_model), - e_table_model_signals [MODEL_CELL_CHANGED], col, row); -} - - diff --git a/widgets/e-table-model.h b/widgets/e-table-model.h deleted file mode 100644 index 22339ae484..0000000000 --- a/widgets/e-table-model.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef _E_TABLE_MODEL_H_ -#define _E_TABLE_MODEL_H_ - -#include <gtk/gtkobject.h> - -#define E_TABLE_MODEL_TYPE (e_table_model_get_type ()) -#define E_TABLE_MODEL(o) (GTK_CHECK_CAST ((o), E_TABLE_MODEL_TYPE, ETableModel)) -#define E_TABLE_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_MODEL_TYPE, ETableModelClass)) -#define E_IS_TABLE_MODEL(o) (GTK_CHECK_TYPE ((o), E_TABLE_MODEL_TYPE)) -#define E_IS_TABLE_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_MODEL_TYPE)) - -typedef struct { - GtkObject base; -} ETableModel; - -typedef struct { - GtkObjectClass parent_class; - - /* - * Virtual methods - */ - int (*column_count) (ETableModel *etm); - const char *(*column_name) (ETableModel *etm, int col); - int (*row_count) (ETableModel *etm); - void *(*value_at) (ETableModel *etm, int col, int row); - void (*set_value_at) (ETableModel *etm, int col, int row, const void *value); - gboolean (*is_cell_editable) (ETableModel *etm, int col, int row); - - /* - * Signals - */ - void (*model_changed) (ETableModel *etm); - void (*model_row_changed) (ETableModel *etm, int row); - void (*model_cell_changed) (ETableModel *etm, int col, int row); -} ETableModelClass; - -GtkType e_table_model_get_type (void); - -int e_table_model_column_count (ETableModel *e_table_model); -const char *e_table_model_column_name (ETableModel *e_table_model, int col); -int e_table_model_row_count (ETableModel *e_table_model); -void *e_table_model_value_at (ETableModel *e_table_model, int col, int row); -void e_table_model_set_value_at (ETableModel *e_table_model, int col, int row, const void *data); -gboolean e_table_model_is_cell_editable (ETableModel *e_table_model, int col, int row); - -/* - * Routines for emitting signals on the e_table - */ -void e_table_model_changed (ETableModel *e_table_model); -void e_table_model_row_changed (ETableModel *e_table_model, int row); -void e_table_model_cell_changed (ETableModel *e_table_model, int col, int row); - -#endif /* _E_TABLE_MODEL_H_ */ - - diff --git a/widgets/e-table-render.c b/widgets/e-table-render.c deleted file mode 100644 index 49d742132b..0000000000 --- a/widgets/e-table-render.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * E-table-render.c: Various renderers - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc. - */ -#include <config.h> -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-col.h" -#include "e-table-render.h" - -void -e_table_render_string (ERenderContext *ctxt) -{ - printf ("Rendering string: %s\n", ctxt->render_data); -} - diff --git a/widgets/e-table-render.h b/widgets/e-table-render.h deleted file mode 100644 index ebc65968f0..0000000000 --- a/widgets/e-table-render.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef E_TABLE_RENDER_H -#define E_TABLE_RENDER_H - -#include <libgnomeui/gnome-canvas.h> - -struct ERenderContext { - ETableCol *etc; - int row; - int base_x, base_y; - GnomeCanvasItem *gnome_canvas_item; - GdkDrawable *drawable; - int drawable_width; - int drawable_height; - void *render_data; - void *closure; -}; - -void e_table_render_string (ERenderContext *ctxt); - - -#endif diff --git a/widgets/e-table-simple.c b/widgets/e-table-simple.c deleted file mode 100644 index 2076e06cef..0000000000 --- a/widgets/e-table-simple.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * e-table-model.c: a simple table model implementation that uses function - * pointers to simplify the creation of new, exotic and colorful tables in - * no time. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc. - */ - -#include <config.h> -#include "e-table-simple.h" - -#define PARENT_TYPE e_table_model_get_type() - -static int -simple_column_count (ETableModel *etm) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->col_count (etm, simple->data); -} - -static const char * -simple_column_name (ETableModel *etm, int col) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->col_name (etm, col, simple->data); -} - -static int -simple_row_count (ETableModel *etm) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->row_count (etm, simple->data); -} - -static void * -simple_value_at (ETableModel *etm, int col, int row) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->value_at (etm, col, row, simple->data); -} - -static void -simple_set_value_at (ETableModel *etm, int col, int row, const void *val) -{ - ETableSimple *simple = (ETableSimple *)etm; - - simple->set_value_at (etm, col, row, val, simple->data); -} - -static gboolean -simple_is_cell_editable (ETableModel *etm, int col, int row) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->is_cell_editable (etm, col, row, simple->data); -} - -static void -e_table_simple_class_init (GtkObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - model_class->column_count = simple_column_count; - model_class->column_name = simple_column_name; - model_class->row_count = simple_row_count; - model_class->value_at = simple_value_at; - model_class->set_value_at = simple_set_value_at; - model_class->is_cell_editable = simple_is_cell_editable; -} - -GtkType -e_table_simple_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableSimple", - sizeof (ETableSimple), - sizeof (ETableSimpleClass), - (GtkClassInitFunc) e_table_simple_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -ETableModel * -e_table_simple_new (ETableSimpleColumnCountFn col_count, - ETableSimpleColumnNameFn col_name, - ETableSimpleRowCountFn row_count, - ETableSimpleValueAtFn value_at, - ETableSimpleSetValueAtFn set_value_at, - ETableSimpleIsCellEditableFn is_cell_editable, - void *data) -{ - ETableSimple *et; - - et = gtk_type_new (e_table_simple_get_type ()); - - et->col_count = col_count; - et->col_name = col_name; - et->row_count = row_count; - et->value_at = value_at; - et->set_value_at = set_value_at; - et->is_cell_editable = is_cell_editable; - - return (ETableModel *) et; -} diff --git a/widgets/e-table-simple.h b/widgets/e-table-simple.h deleted file mode 100644 index 1f7a17aeff..0000000000 --- a/widgets/e-table-simple.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _E_TABLE_SIMPLE_H_ -#define _E_TABLE_SIMPLE_H_ - -#include "e-table-model.h" - -typedef int (*ETableSimpleColumnCountFn) (ETableModel *etm, void *data); -typedef const char *(*ETableSimpleColumnNameFn) (ETableModel *etm, int col, void *data); -typedef int (*ETableSimpleRowCountFn) (ETableModel *etm, void *data); -typedef void *(*ETableSimpleValueAtFn) (ETableModel *etm, int col, int row, void *data); -typedef void (*ETableSimpleSetValueAtFn) (ETableModel *etm, int col, int row, const void *val, void *data); -typedef gboolean (*ETableSimpleIsCellEditableFn) (ETableModel *etm, int col, int row, void *data); - -typedef struct { - ETableModel parent; - - ETableSimpleColumnCountFn col_count; - ETableSimpleColumnNameFn col_name; - ETableSimpleRowCountFn row_count; - ETableSimpleValueAtFn value_at; - ETableSimpleSetValueAtFn set_value_at; - ETableSimpleIsCellEditableFn is_cell_editable; - void *data; -} ETableSimple; - -typedef struct { - ETableModelClass parent_class; -} ETableSimpleClass; - -GtkType e_table_simple_get_type (void); - -ETableModel *e_table_simple_new (ETableSimpleColumnCountFn col_count, - ETableSimpleColumnNameFn col_name, - ETableSimpleRowCountFn row_count, - ETableSimpleValueAtFn value_at, - ETableSimpleSetValueAtFn set_value_at, - ETableSimpleIsCellEditableFn is_cell_editable, - void *data); - -#endif /* _E_TABLE_SIMPLE_H_ */ - diff --git a/widgets/e-table-sorted.c b/widgets/e-table-sorted.c deleted file mode 100644 index 90773e9cdc..0000000000 --- a/widgets/e-table-sorted.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * E-table-sorted.c: Implements a table that sorts another table - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc. - */ -#include <config.h> -#include <stdlib.h> -#include "e-util.h" -#include "e-table-sorted.h" - -#define PARENT_TYPE E_TABLE_SUBSET_TYPE - -static ETableModelClass *ets_parent_class; - -static void -ets_class_init (GtkObjectClass *klass) -{ - ETableModelClass *table_class = (ETableModelClass *) klass; - - ets_parent_class = gtk_type_class (PARENT_TYPE); -} - -E_MAKE_TYPE(e_table_sorted, "ETableSorted", ETableSorted, ets_class_init, NULL, PARENT_TYPE); - -static ETableSorted *sort_ets; - -static int -my_sort (const void *a, const void *b) -{ - ETableModel *source = E_TABLE_SUBSET (sort_ets)->source; - const int *ia = (const int *) a; - const int *ib = (const int *) b; - void *va, *vb; - - va = e_table_model_value_at (source, sort_ets->sort_col, *ia); - vb = e_table_model_value_at (source, sort_ets->sort_col, *ib); - - return (*sort_ets->compare) (va, vb); -} - -static void -do_sort (ETableSorted *ets) -{ - ETableSubset *etss = E_TABLE_SUBSET (ets); - g_assert (sort_ets == NULL); - - sort_ets = ets; - qsort (etss->map_table, etss->n_map, sizeof (unsigned int), my_sort); - sort_ets = NULL; -} - -ETableModel * -e_table_sorted_new (ETableModel *source, int col, GCompareFunc compare) -{ - ETableSorted *ets = gtk_type_new (E_TABLE_SORTED_TYPE); - ETableSubset *etss = E_TABLE_SUBSET (ets); - const int nvals = e_table_model_row_count (source); - int i; - - if (e_table_subset_construct (etss, source, nvals) == NULL){ - gtk_object_destroy (GTK_OBJECT (ets)); - return NULL; - } - - ets->compare = compare; - ets->sort_col = col; - - /* Init */ - for (i = 0; i < nvals; i++) - etss->map_table [i] = i; - - do_sort (ets); - - return (ETableModel *) ets; -} - -void -e_table_sorted_resort (ETableSorted *ets, int col, GCompareFunc compare) -{ - if (col == -1 || compare == NULL) - do_sort (ets); - else { - ets->sort_col = col; - ets->compare = compare; - do_sort (ets); - } -} - diff --git a/widgets/e-table-sorted.h b/widgets/e-table-sorted.h deleted file mode 100644 index 2ec52df2e7..0000000000 --- a/widgets/e-table-sorted.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _E_TABLE_SORTED_H_ -#define _E_TABLE_SORTED_H_ - -#include <gtk/gtkobject.h> -#include "e-table-model.h" -#include "e-table-subset.h" - -#define E_TABLE_SORTED_TYPE (e_table_sorted_get_type ()) -#define E_TABLE_SORTED(o) (GTK_CHECK_CAST ((o), E_TABLE_SORTED_TYPE, ETableSorted)) -#define E_TABLE_SORTED_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_SORTED_TYPE, ETableSortedClass)) -#define E_IS_TABLE_SORTED(o) (GTK_CHECK_TYPE ((o), E_TABLE_SORTED_TYPE)) -#define E_IS_TABLE_SORTED_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_SORTED_TYPE)) - -typedef struct { - ETableSubset base; - - short sort_col; - GCompareFunc compare; -} ETableSorted; - -typedef struct { - ETableSubset parent_class; -} ETableSortedClass; - -GtkType e_table_sorted_get_type (void); -ETableModel *e_table_sorted_new (ETableModel *etm, int col, GCompareFunc compare); -void e_table_sorted_resort (ETableSorted *ets, int col, GCompareFunc compare); - -#endif /* _E_TABLE_SORTED_H_ */ diff --git a/widgets/e-table-subset.c b/widgets/e-table-subset.c deleted file mode 100644 index 41763d309b..0000000000 --- a/widgets/e-table-subset.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * E-table-subset.c: Implements a table that contains a subset of another table. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc. - */ -#include <config.h> -#include "e-util.h" -#include "e-table-subset.h" - -#define PARENT_TYPE E_TABLE_MODEL_TYPE - -static ETableModelClass *etss_parent_class; - -static void -etss_destroy (GtkObject *object) -{ - ETableSubset *etss = E_TABLE_SUBSET (object); - - if (etss->source) - gtk_object_unref (GTK_OBJECT (etss->source)); - - if (etss->map_table) - free (etss->map_table); - - GTK_OBJECT_CLASS (etss_parent_class)->destroy (object); -} - -static int -etss_column_count (ETableModel *etm) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_column_count (etss->source); -} - -static const char * -etss_column_name (ETableModel *etm, int col) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_column_name (etss->source, col); -} - -static int -etss_row_count (ETableModel *etm) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_row_count (etss->source); -} - -static void * -etss_value_at (ETableModel *etm, int col, int row) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_value_at (etss->source, col, etss->map_table [row]); -} - -static void -etss_set_value_at (ETableModel *etm, int col, int row, void *val) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_set_value_at (etss->source, col, etss->map_table [row], val); -} - -static gboolean -etss_is_cell_editable (ETableModel *etm, int col, int row) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_is_cell_editable (etss->source, col, etss->map_table [row]); -} - -static int -etss_row_height (ETableModel *etm, int row) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_row_height (etss->source, etss->map_table [row]); -} - -static void -etss_class_init (GtkObjectClass *klass) -{ - ETableModelClass *table_class = (ETableModelClass *) klass; - - etss_parent_class = gtk_type_class (PARENT_TYPE); - - klass->destroy = etss_destroy; - - table_class->column_count = etss_column_count; - table_class->column_name = etss_column_name; - table_class->row_count = etss_row_count; - table_class->value_at = etss_value_at; - table_class->set_value_at = etss_set_value_at; - table_class->is_cell_editable = etss_is_cell_editable; - table_class->row_height = etss_row_height; - -} - -E_MAKE_TYPE(e_table_subset, "ETableSubset", ETableSubset, etss_class_init, NULL, PARENT_TYPE); - -ETableModel * -e_table_subset_construct (ETableSubset *etss, ETableModel *source, int nvals) -{ - unsigned int *buffer; - int i; - - buffer = (unsigned int *) malloc (sizeof (unsigned int *) * nvals); - if (buffer = NULL) - return NULL; - etss->map_table = buffer; - etss->n_map = nvals; - etss->source = source; - gtk_object_ref (GTK_OBJECT (source)); - - /* Init */ - for (i = 0; i < nvals; i++) - etss->map_table [i] = i; - -} - -ETableModel * -e_table_subset_new (ETableModel *source, const int nvals) -{ - ETableSubset *etss = gtk_type_new (E_TABLE_SUBSET_TYPE); - - if (e_table_subset_construct (etss, source, nvals) == NULL){ - gtk_object_destroy (GTK_OBJECT (etss)); - return NULL; - } - - return (ETableModel *) etss; -} - -ETableModel * -e_table_subset_get_toplevel (ETableSubset *table) -{ - g_return_val_if_fail (table != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_SUBSET (table), NULL); - - if (E_IS_TABLE_SUBSET (table->source)) - return e_table_subset_get_toplevel (E_TABLE_SUBSET (table->source)); - else - return table->subset; -} diff --git a/widgets/e-table-subset.h b/widgets/e-table-subset.h deleted file mode 100644 index 66d11e9658..0000000000 --- a/widgets/e-table-subset.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _E_TABLE_SUBSET_H_ -#define _E_TABLE_SUBSET_H_ - -#include <gtk/gtkobject.h> -#include "e-table-model.h" - -#define E_TABLE_SUBSET_TYPE (e_table_subset_get_type ()) -#define E_TABLE_SUBSET(o) (GTK_CHECK_CAST ((o), E_TABLE_SUBSET_TYPE, ETableSubset)) -#define E_TABLE_SUBSET_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_SUBSET_TYPE, ETableSubsetClass)) -#define E_IS_TABLE_SUBSET(o) (GTK_CHECK_TYPE ((o), E_TABLE_SUBSET_TYPE)) -#define E_IS_TABLE_SUBSET_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_SUBSET_TYPE)) - -typedef struct { - ETableModel base; - - ETableModel *source; - int n_map; - int *map_table; -} ETableSubset; - -typedef struct { - ETableModelClass parent_class; -} ETableSubsetClass; - -GtkType e_table_subset_get_type (void); -ETableModel *e_table_subset_new (ETableModel *etm, int n_vals); -ETableModel *e_table_subset_construct (ETableSubset *ets, ETableModel *source, int nvals); - -ETableModel *e_table_subset_get_toplevel (ETableModel *table_model); - -#endif /* _E_TABLE_SUBSET_H_ */ diff --git a/widgets/e-table-tree.h b/widgets/e-table-tree.h deleted file mode 100644 index e7e125a6af..0000000000 --- a/widgets/e-table-tree.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _E_TABLE_TREE_H_ -#define _E_TABLE_TREE_H_ - -typedef struct { - char *title; - - union { - ETableModel *table; - GList *children; - } u; - - guint expanded :1; - guint is_leaf :1; -} ETableGroup; - -ETableGroup *e_table_group_new (const char *title, ETableModel *table); -ETableGroup *e_table_group_new_leaf (const char *title); - -#endif /* _E_TABLE_TREE_H_ */ diff --git a/widgets/e-table.c b/widgets/e-table.c deleted file mode 100644 index 3b13e87d6b..0000000000 --- a/widgets/e-table.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * E-table-view.c: A graphical view of a Table. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc - */ -#include <config.h> -#include <libgnomeui/gnome-canvas.h> -#include "e-table.h" -#include "e-util.h" - -#define PARENT_OBJECT_TYPE gnome_canvas_get_type () - -E_MAKE_TYPE(e_table, "ETable", ETable, e_table_class_init, NULL, PARENT_TYPE); - -ETable * -e_table_new (ETableHeader *eth, ETableModel *etm) -{ -} - diff --git a/widgets/e-table.h b/widgets/e-table.h deleted file mode 100644 index 0847ddde6c..0000000000 --- a/widgets/e-table.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _E_TABLE_H_ -#define _E_TABLE_H_ - -GtkType e_table_get_type (void); -ETable * -#endif /* _E_TABLE_H_ */ diff --git a/widgets/e-table/.cvsignore b/widgets/e-table/.cvsignore deleted file mode 100644 index 0963d457d9..0000000000 --- a/widgets/e-table/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la -table-test diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog deleted file mode 100644 index 76e918b61d..0000000000 --- a/widgets/e-table/ChangeLog +++ /dev/null @@ -1,430 +0,0 @@ -1999-12-01 Miguel de Icaza <miguel@gnu.org> - - * e-cell-text.c (ect_draw): Keep track of the originally allocated - piece of code. - - * e-table-header-item.c (ethi_unrealize): Removed change cursor - from here. - - * e-cell-text.c (ect_draw): Memory leak fix. - - * table-test.c (main): Enhance the demo to load sample.table - automatically, to get memprof working. - - * e-table-header.c (eth_do_remove): Take an argument: do -remove. - - * e-table-header.c (e_table_header_add_column): Sink ETableCol to - own the object. - - * e-table-col.h: Made ETableCol a GtkObject to make reference - counting the lifecycle method for these objects. - - * e-table-col.c (e_table_col_destroy): New API call. - - * e-table-subset.c (e_table_subset_get_toplevel): New API call. - -1999-11-30 Miguel de Icaza <miguel@gnu.org> - - * e-cell-checkbox.c (e_cell_checkbox_new): This one derives from - e-cell-toggle. - - * check-emtpy.xpm, check-filled.xpm: new files. - - * e-cell-toggle.c (etog_draw): Paint in white. - If we have transparency enabled, do the nice alpha computation. - - * test-table.c, test-cols.c: new files; They implement the split - tests. - -1999-11-29 Miguel de Icaza <miguel@gnu.org> - - * e-table-col.c (e_table_col_new): Set etc->resizeable. - - * e-table-header-item.c (ethi_event): Handle non-resizeables - columns; Add support for minimum width. - - * e-cell-toggle.c, e-cell-toggle.h: New file. Implement a - multi-state image toggle cell object. - - * e-cell-text.c (ect_leave_edit): Handle the case of us calling - leave edit manually. - (ect_stop_editing): Leave manually editing here. - (ect_draw): Add one pixel to the border for left and right; - Handle off-screen cursor (must be improved). - (ect_edit_select_all): New function. - (ect_event): Select all text on editing start - - * e-table-item.c (eti_event): Map mouse events and dispatch them. - (eti_event): Add spreadsheet mode for editing; Enter editing only - with visual characters; - Leave editing mode when a different row has been selected. - (eti_get_height): Fix the computation for this; Fix logic for the - length_threshold. - - (eti_draw): Add borders on all sides of the box; - Only draw focus if the cell is not being edited. - -1999-11-28 Miguel de Icaza <miguel@gnu.org> - - * e-table-item.c (eti_draw): Focus inside, not outside. - (eti_realize): Enhance our focus gc. - - * e-cell-text.c (ect_enter_edit, ect_leave_edit): New methods; - They implement editing. - - * e-cell.h: new methods: enter_edit, leave_edit - - * e-table-model.h (set_value_at): make val argument const. - - * e-table-simple.c (simple_set_value_at): Make value argument const; - - * e-table-item.c (eti_set_arg): Add new mode: draw_focus; - -1999-11-27 Miguel de Icaza <miguel@gnu.org> - - * e-table-item.c (eti_event): beginning of the keyboard navigation. - - * e-table-model.c (e_table_model_row_changed): new function. - (e_table_model_cell_changed): new function. - (e_table_model_class_init): New signals. - - * e-table-item.c (eti_request_region_redraw): x2, y2 offsets were - wrong. - (eti_select): Repaint selected region. - (eti_request_region_redraw): Fix range. - (eti_draw): Correct offset computation here. - (e_table_item_class_init): New method: row_selection, handles the - selection. - - Now it implement GTK_SELECTION_SINGLE and GTK_SELECTION_MULTIPLE. - - Focusing and selection should be correct now. - -1999-11-26 Miguel de Icaza <miguel@gnu.org> - - * e-table-item.c (eti_realize): Compute height using the ecell - methods here. - (eti_get_height): new method to compute dimensions. - - * e-cursors.c: use a different cursor. - - * e-table-model.h: kill height and row_height methods. - - * e-cell.c (ec_height): New method. - - * e-cell-text.c (ect_realize): Load the font from the canvas. - (ect_draw): New color setup. - Center in the row. - (ect_height): Implement new method. - -1999-11-26 Michael Meeks <mmeeks@gnu.org> - - * ROADMAP.e-table: small spelling/typo fixes. - -1999-11-25 Miguel de Icaza <miguel@gnu.org> - - * e-table-item.c (eti_event): Work on mouse-button event - propagation to cells. - - * e-cell-text.c (ect_draw): Use CellViews now. - - * e-table-item.c (eti_realize_cell_views): New routine: Realizes - the cell views - (eti_unrealize_cell_views): New routine: unrealizes the cell views. - - * e-table-item.h: Move cell_views array here. - - * table-test.c (value_at): Fix return value. - (main): use new invocation method. - - * e-table-header-item.c (ethi_realize): Realize cells. - - * e-table-item.c (eti_header_dim_changed): redraw before and after. - - * e-table-header-item.c (ethi_event): Add continuous resizing. - -1999-11-24 Miguel de Icaza <miguel@gnu.org> - - * e-table-subset.h, e-table-subset.c: New files, used to implement - subset tables. - - * e-table-sorted.h, e-table-sorted.c: Now they derive from - e-table-subset. - - * e-cell.c, e-cell.h: realize method now return per view instance - data. - -1999-11-20 Miguel de Icaza <miguel@gnu.org> - - * e-table-item.c (eti_draw): WOOOOHOOOOOoO! It took me quite a - while to figure this one out. Fixed. - - * e-table-header-item.c (ethi_set_arg): Compute width, keep track - of it. - (ethi_add_table_header): Monitor changes to the Header model; - Queue updates. - (ethi_draw): Fix the redraw logic here. - - * table-test.c (main): Change the sample code, so we can better - debug this. - - * e-table-item.c (eti_header_structure_changed): Keep track of - width; - (eti_header_dim_changed): ditto. - (eti_draw): Many redraw fixes. - -1999-11-19 Miguel de Icaza <miguel@gnu.org> - - * e-table-item.c (eti_realize): Hook up; Load gcs. - (eti_unrealize): Hook up. - - * e-table-sorted.c: Finished implementing. - -1999-11-18 Miguel de Icaza <miguel@gnu.org> - - * e-table-model.c (e_table_model_class_init): Add model_changed - signal here. - - * e-table-item.c, e-table-item.h: New files. They implement the - view of the ETableModel as Canvas Items. - - * e-table-header-item.c (ethi_set_arg): Ref header here. - (ethi_destroy): Unref it here. - -1999-11-17 Ettore Perazzoli <ettore@gnu.org> - - * e-msg-composer-address-dialog.c: Moved to `$(srcdir)/composer'. - * e-msg-composer-address-dialog.h: Likewise. - * e-msg-composer-address-entry.c: Likewise. - * e-msg-composer-address-entry.h: Likewise. - * e-msg-composer-attachment-bar.c: Likewise. - * e-msg-composer-attachment-bar.h: Likewise. - * e-msg-composer-attachment.c: Likewise. - * e-msg-composer-attachment.h: Likewise. - * e-msg-composer-hdrs.c: Likewise. - * e-msg-composer-hdrs.h: Likewise. - * e-msg-composer.c: Likewise. - * e-msg-composer.h: Likewise. - * e-msg-composer-address-dialog.glade: Likewise. - * e-msg-composer-attachment.glade: Likewise. - * e-msg-composer.glade: Likewise. - * Makefile.am: Updated accordingly. - -Nov 14 1999 Elliot Lee - * Makefile.am: It's libevolutionwidgets.la, not .a - -1999-11-14 Miguel de Icaza <miguel@gnu.org> - - * e-table-header-item.c (is_pointer_on_division): Add resizing - capabilities. - - * e-table-sorted.c: Finish implementation. - -1999-11-13 Miguel de Icaza <miguel@gnu.org> - - * e-table-sorted.c: Implement e-table-sorted object. - -1999-11-12 Miguel de Icaza <miguel@gnu.org> - - * e-table-header-item.c: Make the thing configurable. - - * e-table-header-item.h: Add font field, location, height. - -1999-11-12 Ettore Perazzoli <ettore@gnu.org> - - * e-msg-composer-hdrs.c: New member `tooltips' in `struct - _EMsgComposerHdrsPrivate'. - (init): Initialize it. - (destroy): New function. - (class_init): Install it as the `destroy' GtkObject method. - (add_header): New parameters `tip', `tip_private'. Setup a - tooltip for the entry with them. - (setup_headers): Updated accordingly. - -1999-11-11 Miguel de Icaza <miguel@gnu.org> - - * e-table-header.c (e_table_header_add_column): Update offsets. - (eth_update_offsets): New routine. - - * e-table-col.h, e-table-col.c: New files. - - * e-table-header.h (e_table_header_get_selected_indexes): - Pretify. - - * table-test.c (main): New file; used for testing ETable package. - - * e-table-simple.h: Fix type. - -1999-11-12 Ettore Perazzoli <ettore@gnu.org> - - * e-msg-composer-address-dialog.glade: Cosmetical changes. - - * e-msg-composer-attachment-bar.c (size_to_string): New helper - function. - (update): Put the size in the icon's label using this function. - (ICON_SEPARATORS): Remove '.' to avoid wrapping of the size string - on the decimal dot. But gnome-libs is broken and this has no real - effect! :-( - (e_msg_composer_attachment_bar_new): No longer make text editable. - Use the `GTK_SELECTION_MULTIPLE' selection mode. - (remove_selected): No longer assume only one attachment is - selected. - - * e-msg-composer-attachment.c: #include <sys/stat.h> - (init): Initialize all the members. - (e_msg_composer_attachment_new): Set size using `stat()'. - - * e-msg-composer-attachment.h: New member `size' in `struct - _EMsgComposerAttachment'. - - * e-msg-composer.c (setup_signals): Connect `address_dialog_cb' to - the "show_address_dialog" signal of the header widget. - - * e-msg-composer-hdrs.c (add_address_header): Renamed to - `add_header'. New parameter `addrbook_button': if true, use a - button instead of a label and make it trigger an - "show_address_dialog" signal. - (address_button_clicked_cb): Signal handler to handle this on a - "clicked" signal from the button. - (setup_headers): Updated accordingly. Also, make "Subject" the - last item. (This makes it look more like Outlook and friends.) - - * e-msg-composer-hdrs.c: New signal "show_address_dialog". - * e-msg-composer-hdrs.h: Updated accordingly. - - * e-msg-composer-hdrs.c (add_address_header): Reduce padding - considerably. - - * e-msg-composer.c (e_msg_composer_construct): Do not use any - padding in the main vbox. - - * Makefile.am: Moved the `e-table*' sources to `EXTRA_DIST'. - Compile as a shared library. - -1999-11-08 Ettore Perazzoli <ettore@gnu.org> - - * e-msg-composer-address-dialog.c: Implemented cut & paste for the - recipient lists. - (init): Initialize `cut_buffer'. - (destroy): Free it. - (recipient_clist_selection_get_cb): New function. - (recipient_clist_selection_received_cb): New function. - (recipient_clist_selection_clear_event_cb): New function. - (setup_recipient_list_signals): Install them as signal handlers - for "selection_get", "selection_received" and - "selection_clear_event" respectively. - (copy_recipient_cb): New function implementing the "copy" - operation. - (cut_recipient_cb): New function implementing the "cut" operation. - (paste_recipient_cb): New function implementing the "paste" - operation. - - * e-msg-composer-address-dialog.h: New member `cut_buffer' in - `struct _EMsgComposerAddressDialog'. - -1999-11-07 Ettore Perazzoli <ettore@gnu.org> - - * e-msg-composer-address-dialog.c: New context menu - `recipient_list_popup_info' for the recipient CLists. - (recipient_clist_button_press_cb): New function. - (setup_signals): Install it as the "button_press_event" signal - handler for popping up the CList context menu. - - * e-msg-composer.c (free_string_list): New helper function. - (setup_address_dialog): Setup the initial values in the address - dialog according to the ones in the header widget. - - * e-msg-composer-hdrs.c (e_msg_composer_hdrs_get_to): New function. - (e_msg_composer_hdrs_get_cc): New function. - (e_msg_composer_hdrs_get_bcc): New function. - - * e-msg-composer.c (setup_address_dialog): New helper function. - (address_dialog_cb): Use it. - - * e-msg-composer-address-dialog.c (add_address): Do not set the - row data anymore. Instead, put the full address description - (i.e. complete with the email address, not just the full name) in - the CList. - (add_address): Do nothing if no item is selected in the address - CList. - (get_list): Get the address list from the CList without passing - through the address CList. - (set_list): New helper function. - (e_msg_composer_address_dialog_set_to_list): New function. - (e_msg_composer_address_dialog_set_cc_list): New function. - (e_msg_composer_address_dialog_set_bcc_list): New function. - - * e-msg-composer.c (address_dialog_apply_cb): Apply values from - the address dialog into the composer. - - * e-msg-composer-hdrs.c (e_msg_composer_hdrs_set_to): New function. - (e_msg_composer_hdrs_set_cc): New function. - (e_msg_composer_hdrs_set_bcc): New function. - - * e-msg-composer-address-entry.c - (e_msg_composer_address_entry_set_list): New function. - - * e-msg-composer-address-dialog.c (apply): New helper function. - (clicked): New function, `clicked' method for the `GnomeDialog' - class. - (class_init): Install it. - -1999-11-06 Ettore Perazzoli <ettore@gnu.org> - - * e-msg-composer-attachment-bar.c (destroy): Call the destroy - method of the parent class. - - * e-msg-composer.c: #include "e-msg-composer-address-dialog.h". - (address_dialog_cb): New callback to start the address dialog. - (setup_signals): Connect it to the appropriate button/menu item. - (init): Initialize the new `address_dialog' member to NULL. - (destroy): Destroy the `address_dialog' if not NULL. - - * e-msg-composer.h: New member `address_dialog' in `struct - _EMsgComposer'. - - * e-msg-composer.glade: Added button to activate the address - composition dialog. - - * e-msg-composer-address-dialog.h, e-msg-composer-address-dialog.c: - New files implementing the address composition dialog for Evolution. - - * e-msg-composer-address-dialog.glade: New file. - - * e-msg-composer-attachment.c: `signals' made static. - -1999-11-05 Ettore Perazzoli <ettore@gnu.org> - - * Makefile.am: Compile the new files in a `libevolutionwidgets' - library. - (CPPFLAGS): #define `E_GUIDIR'. - - * e-msg-composer.c, e-msg-composer.h: New files implementing an - initial version of the Evolution message composer widget. - - * e-msg-composer-address-entry.c, e-msg-composer-address-entry.h: - New files implementing a GtkEntry customized for entering email - address lists. - - * e-msg-composer-attachment-bar.c, e-msg-composer-attachment-bar.h: - New files implementing a widget for editing mail attachments. - - * e-msg-composer-attachment.c, e-msg-composer-attachment.h: New - files implementing file attachment objects for the message - composer. - - * e-msg-composer-hdrs.c, e-msg-composer-hdrs.h: New files - implementing a widget for editing of email message headers. - - * e-msg-composer-attachment.glade: New file. - * e-msg-composer.glade: New file. - -1999-10-31 Miguel de Icaza <miguel@gnu.org> - - * widgets/e-table-column.c, e-table-column.h: New file, implements the - e-table-column object. - - * widget/e-table-model.h, e-table-model.c, e-table-simple.c, - e-table-simple.h: New files. Implements the column model and - a simple table wrapper. - diff --git a/widgets/e-table/Makefile.am b/widgets/e-table/Makefile.am deleted file mode 100644 index 1b237dce70..0000000000 --- a/widgets/e-table/Makefile.am +++ /dev/null @@ -1,55 +0,0 @@ -INCLUDES = \ - -I$(top_srcdir)/camel \ - -I$(top_builddir)/camel \ - $(GNOME_INCLUDEDIR) - -noinst_LIBRARIES = \ - libevolutionwidgets.a - -libevolutionwidgets_a_SOURCES = \ - e-cell.c \ - e-cell.h \ - e-cell-checkbox.c \ - e-cell-checkbox.h \ - e-cell-text.c \ - e-cell-text.h \ - e-cell-toggle.c \ - e-cell-toggle.h \ - e-cursors.c \ - e-cursors.h \ - e-table-col.c \ - e-table-col.h \ - e-table-group.c \ - e-table-group.h \ - e-table-header.c \ - e-table-header.h \ - e-table-header-item.c \ - e-table-header-item.h \ - e-table-item.c \ - e-table-item.h \ - e-table-model.c \ - e-table-model.h \ - e-table-simple.c \ - e-table-simple.h \ - e-table-sorted.c \ - e-table-sorted.h - -noinst_PROGRAMS = \ - table-test - -table_test_SOURCES = \ - test-table.c \ - test-check.c \ - test-cols.c \ - table-test.c - -table_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - libevolutionwidgets.a - -table_test_LDFLAGS = `gnome-config --libs gdk_pixbuf` - -EXTRA_DIST = \ - sample.table \ - check-empty.xpm \ - check-filled.xpm diff --git a/widgets/e-table/ROADMAP.e-table b/widgets/e-table/ROADMAP.e-table deleted file mode 100644 index 08340f433c..0000000000 --- a/widgets/e-table/ROADMAP.e-table +++ /dev/null @@ -1,98 +0,0 @@ - -The E-Table package implements an editable table that provides -user-defined rendering, user-defined editing, sorting and grouping of -the objects displayed. - -It is inspired by Java's Swing JTable object. There are models for -the actual table contents and for the table headers; they are the -actual repository of information. - -The objects are rendered by various view objects. In the current code -base, we use we use GnomeCanvasItems to do the rendering. One for -each table and one for the headers. - -* The Models - -All of them are GtkObjects. - -e-table-model.h, e-table-model.c: - - These implement the abstract E-Table-Model class. You - can derive this object to create your own data repository. - - These emits signals to notify the views about selection, and - changes in the model. - -e-table-simple.h, e-table-simple.c: - - A simple implementation of e-table-model that uses callback - routines (you provide the callbacks). For lazy people, like - me. - -e-cell.c, e-cell.h: - - These are actually mis-named. Objects of type e-cell know - about rendering a single cell, and these are attached to the - e-table-cols (described next). - - The user provides the various rendering modes as e-cells (they - are actually column-rendering repositories). - - This is just an abstract class. I will provide various - e-cells: a text cell, a checkbox cell, an image cell, and - perhaps an n-state image cell (one that switches the image when - the cell is clicked). - -e-table-col.h, e-table-col.c: - - Describes a single column (the size, the string displayed, the - rendering function for each row and comparison function for - this field). - - -* The Views - -e-table-header.h, e-table-header.c: - - These implement the ETableHeaderItem canvas item. This item is - used both to control the columns displayed as well as displaying them. - - They describe what columns are shown in the screen and in - which order. - - These emit signals: column-size-changed and structure-changed - (if a column is added/removed) - -e-table-item.c, e-table-item.h - - This is a canvas item that renders the contents of a - ETableModel into the screen. - -e-table-header-item.c, e-table-header-item.h - - This canvas item renders the ETableHeader headings. - -e-cell-text.c, e-cell-text.h - - Not really a view, but actually a derivative of e-cell that - implements text display: supports justification and font - setting. Will add color in the future most likely - - -* The Filters - -e-table-sorted.c, e-table-sorted.h - - This is an ETableModel that can sort an existing ETableModel. - -e-table-subset.c, e-table-subset.h - - Not finished, but it is just an ETableModel that happens to be - a subset of another ETableModel. - -* Everything - -e-table.c, e-table.h - - In the future these guys will implement the whole widget for - doing table editing. Nothing done about these yet. diff --git a/widgets/e-table/TODO b/widgets/e-table/TODO deleted file mode 100644 index 20d491b4fa..0000000000 --- a/widgets/e-table/TODO +++ /dev/null @@ -1,20 +0,0 @@ -Implement e-cell-height -Implement computation of heights from the e-cell-heights -Make sure we compute the height from that -Include spacing in columns and rows for the decoration lines -Add threshold to compute a "global" size -Implement the two methods for row finding: by full thing, or by a factor. - - -Add editing -mouse grabbing for scrolling - - -1. Make sure that all values are updated on header changes and table - model changes (they are slightly out of sync now) - -* Correctness - - * Make sure we can boot and shutdown with no memory leaks. - - * Run Insure on the thing. diff --git a/widgets/e-table/check-empty.xpm b/widgets/e-table/check-empty.xpm deleted file mode 100644 index 2dd873e137..0000000000 --- a/widgets/e-table/check-empty.xpm +++ /dev/null @@ -1,21 +0,0 @@ -/* XPM */ -static char * check_empty_xpm[] = { -"16 16 2 1", -" c None", -". c #000000", -" ", -" ", -" ............ ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" ............ ", -" ", -" "}; diff --git a/widgets/e-table/check-filled.xpm b/widgets/e-table/check-filled.xpm deleted file mode 100644 index 689d7a7967..0000000000 --- a/widgets/e-table/check-filled.xpm +++ /dev/null @@ -1,21 +0,0 @@ -/* XPM */ -static char * check_filled_xpm[] = { -"16 16 2 1", -" c None", -". c #000000", -" ", -" ", -" ............ ", -" . . ", -" . . . ", -" . .. . ", -" . ... . ", -" . . ... . ", -" . .. ... . ", -" . ..... . ", -" . ... . ", -" . . . ", -" . . ", -" ............ ", -" ", -" "}; diff --git a/widgets/e-table/e-cell-checkbox.c b/widgets/e-table/e-cell-checkbox.c deleted file mode 100644 index 73620b9ce4..0000000000 --- a/widgets/e-table/e-cell-checkbox.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * e-cell-checkbox.c: Checkbox cell renderer - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkenums.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtksignal.h> -#include <gdk/gdkkeysyms.h> -#include <libgnomeui/gnome-canvas.h> -#include "e-cell-checkbox.h" -#include "e-util.h" -#include "e-table-item.h" - -#include "check-empty.xpm" -#include "check-filled.xpm" - -#define PARENT_TYPE e_cell_toggle_get_type() - -static GdkPixbuf *checks [2]; - -static void -e_cell_checkbox_class_init (GtkObjectClass *object_class) -{ - checks [0] = gdk_pixbuf_new_from_xpm_data (check_empty_xpm); - checks [1] = gdk_pixbuf_new_from_xpm_data (check_filled_xpm); -} - -E_MAKE_TYPE(e_cell_checkbox, "ECellCheckbox", ECellCheckbox, e_cell_checkbox_class_init, NULL, PARENT_TYPE); - -ECell * -e_cell_checkbox_new (ETableModel *etm) -{ - ECellCheckbox *eccb = gtk_type_new (e_cell_checkbox_get_type ()); - - e_cell_toggle_construct (E_CELL_TOGGLE (eccb), etm, 2, 2, checks); - - return (ECell *) eccb; -} diff --git a/widgets/e-table/e-cell-checkbox.h b/widgets/e-table/e-cell-checkbox.h deleted file mode 100644 index 6afca6bde2..0000000000 --- a/widgets/e-table/e-cell-checkbox.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _E_CELL_CHECKBOX_H_ -#define _E_CELL_CHECKBOX_H_ - -#include "e-cell-toggle.h" - -#define E_CELL_CHECKBOX_TYPE (e_cell_checkbox_get_type ()) -#define E_CELL_CHECKBOX(o) (GTK_CHECK_CAST ((o), E_CELL_CHECKBOX_TYPE, ECellCheckbox)) -#define E_CELL_CHECKBOX_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_CHECKBOX_TYPE, ECellCheckboxClass)) -#define E_IS_CELL_CHECKBOX(o) (GTK_CHECK_TYPE ((o), E_CELL_CHECKBOX_TYPE)) -#define E_IS_CELL_CHECKBOX_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_CHECKBOX_TYPE)) - -typedef struct { - ECellToggle parent; -} ECellCheckbox; - -typedef struct { - ECellToggleClass parent_class; -} ECellCheckboxClass; - -GtkType e_cell_checkbox_get_type (void); -ECell *e_cell_checkbox_new (ETableModel *model); - -#endif /* _E_CELL_CHECKBOX_H_ */ - diff --git a/widgets/e-table/e-cell-string.c b/widgets/e-table/e-cell-string.c deleted file mode 100644 index 992b1bd10e..0000000000 --- a/widgets/e-table/e-cell-string.c +++ /dev/null @@ -1,9 +0,0 @@ -ECell * -e_cell_string_new (void) -{ - ECell *ecell; - - ecell = gtk_type_new (ecell); - - return ecell; -} diff --git a/widgets/e-table/e-cell-text.c b/widgets/e-table/e-cell-text.c deleted file mode 100644 index d9d8a568db..0000000000 --- a/widgets/e-table/e-cell-text.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - * e-cell-text.c: Text cell renderer - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkenums.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtksignal.h> -#include <gdk/gdkkeysyms.h> -#include <libgnomeui/gnome-canvas.h> -#include "e-cell-text.h" -#include "e-util.h" -#include "e-table-item.h" - -#define PARENT_TYPE e_cell_get_type() - -#define TEXT_PAD 2 - -typedef struct { - char *old_text; - GtkWidget *entry_top; - GtkEntry *entry; - - /* - * Where the editing is taking place - */ - int col, row; -} CellEdit; - -typedef struct { - ECellView cell_view; - GdkGC *gc; - GdkFont *font; - GnomeCanvas *canvas; - ETableItem *eti; - - /* - * During edition. - */ - CellEdit *edit; -} ECellTextView; - -static ECellClass *parent_class; - -static void -ect_queue_redraw (ECellTextView *text_view, int col, int row) -{ - e_table_item_redraw_range (text_view->eti, col, row, col, row); -} - -/* - * Accept the currently edited text - */ -static void -ect_accept_edits (ECellTextView *text_view) -{ - const char *text = gtk_entry_get_text (text_view->edit->entry); - CellEdit *edit = text_view->edit; - - e_table_model_set_value_at (text_view->eti->table_model, edit->col, edit->row, text); -} - -/* - * Shuts down the editing process - */ -static void -ect_stop_editing (ECellTextView *text_view) -{ - CellEdit *edit = text_view->edit; - - g_free (edit->old_text); - edit->old_text = NULL; - gtk_widget_destroy (edit->entry_top); - edit->entry_top = NULL; - edit->entry = NULL; - - g_free (edit); - - text_view->edit = NULL; - - e_table_item_leave_edit (text_view->eti); -} - -/* - * Cancels the edits - */ -static void -ect_cancel_edit (ECellTextView *text_view) -{ - ect_queue_redraw (text_view, text_view->edit->col, text_view->edit->row); - ect_stop_editing (text_view); -} - -/* - * ECell::realize method - */ -static ECellView * -ect_realize (ECell *ecell, void *view) -{ - ECellText *ect = E_CELL_TEXT (ecell); - ECellTextView *text_view = g_new0 (ECellTextView, 1); - ETableItem *eti = E_TABLE_ITEM (view); - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - - text_view->cell_view.ecell = ecell; - text_view->gc = gdk_gc_new (GTK_WIDGET (canvas)->window); - if (ect->font_name){ - GdkFont *f; - - f = gdk_fontset_load (ect->font_name); - text_view->font = f; - } - if (!text_view->font){ - text_view->font = GTK_WIDGET (canvas)->style->font; - - gdk_font_ref (text_view->font); - } - - text_view->eti = eti; - text_view->canvas = canvas; - - return (ECellView *)text_view; -} - -/* - * ECell::unrealize method - */ -static void -ect_unrealize (ECellView *ecv) -{ - ECellTextView *text_view = (ECellTextView *) ecv; - - gdk_gc_unref (text_view->gc); - text_view->gc = NULL; - - gdk_font_unref (text_view->font); - text_view->font = NULL; - - g_free (text_view); -} - -/* - * ECell::draw method - */ -static void -ect_draw (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, - int x1, int y1, int x2, int y2) -{ - ECellText *ect = E_CELL_TEXT (ecell_view->ecell); - ECellTextView *text_view = (ECellTextView *) ecell_view; - GtkWidget *w = GTK_WIDGET (text_view->canvas); - GdkRectangle rect; - const char *str = e_table_model_value_at (ecell_view->ecell->table_model, col, row); - GdkFont *font = text_view->font; - const int height = font->ascent + font->descent; - int xoff; - gboolean edit_display = FALSE; - - /* - * Figure if this cell is being edited - */ - if (text_view->edit){ - CellEdit *edit = text_view->edit; - - if ((edit->col == col) && (edit->row == row)) - edit_display = TRUE; - } - - /* - * Be a nice citizen: clip to the region we are supposed to draw on - */ - rect.x = x1; - rect.y = y1; - rect.width = x2 - x1; - rect.height = y2 - y1; - gdk_gc_set_clip_rectangle (text_view->gc, &rect); - - if (edit_display){ - CellEdit *edit = text_view->edit; - const char *text = gtk_entry_get_text (edit->entry); - GdkWChar *p, *text_wc = g_new (GdkWChar, strlen (text) + 1); - int text_wc_len = gdk_mbstowcs (text_wc, text, strlen (text)); - const int cursor_pos = GTK_EDITABLE (edit->entry)->current_pos; - const int left_len = gdk_text_width_wc (text_view->font, text_wc, cursor_pos); - - text_wc [text_wc_len] = 0; - /* - * Paint - */ - gdk_gc_set_foreground (text_view->gc, &w->style->base [GTK_STATE_NORMAL]); - gdk_draw_rectangle (drawable, text_view->gc, TRUE, - rect.x, rect.y, rect.width, rect.height); - gdk_gc_set_foreground (text_view->gc, &w->style->text [GTK_STATE_NORMAL]); - - { - GdkGC *gc = text_view->gc; - const int y = y2 - font->descent - ((y2-y1-height)/2); - int px, i; - - /* - * Border - */ - x1 += 2; - x2--; - - px = x1; - - /* - * If the cursor is outside the visible range - * - * FIXME: we really want a better behaviour. - */ - if ((px + left_len) > x2) - px -= left_len - (x2-x1); - - for (i = 0, p = text_wc; *p; p++, i++){ - gdk_draw_text_wc ( - drawable, font, gc, px, y, p, 1); - - if (i == cursor_pos){ - gdk_draw_line ( - drawable, gc, - px, y - font->ascent, - px, y + font->descent - 1); - } - - px += gdk_text_width_wc (font, p, 1); - } - - if (i == cursor_pos){ - gdk_draw_line ( - drawable, gc, - px, y - font->ascent, - px, y + font->descent - 1); - } - } - g_free (text_wc); - } else { - /* - * Regular cell - */ - GdkColor *background, *foreground; - int width; - - /* - * Border - */ - x1++; - x2--; - - /* - * Compute draw mode - */ - switch (ect->justify){ - case GTK_JUSTIFY_LEFT: - xoff = 1; - break; - - case GTK_JUSTIFY_RIGHT: - width = 1 + gdk_text_width (font, str, strlen (str)); - xoff = (x2 - x1) - width; - break; - - case GTK_JUSTIFY_CENTER: - xoff = ((x2 - x1) - gdk_text_width (font, str, strlen (str))) / 2; - break; - default: - xoff = 0; - g_warning ("Can not handle GTK_JUSTIFY_FILL"); - break; - } - - - if (selected){ - background = &w->style->bg [GTK_STATE_SELECTED]; - foreground = &w->style->text [GTK_STATE_SELECTED]; - } else { - background = &w->style->base [GTK_STATE_NORMAL]; - foreground = &w->style->text [GTK_STATE_NORMAL]; - } - - gdk_gc_set_foreground (text_view->gc, background); - gdk_draw_rectangle (drawable, text_view->gc, TRUE, - rect.x, rect.y, rect.width, rect.height); - gdk_gc_set_foreground (text_view->gc, foreground); - - gdk_draw_string ( - drawable, font, text_view->gc, - x1 + xoff, - y2 - font->descent - ((y2-y1-height)/2), str); - } -} - -/* - * Selects the entire string - */ -static void -ect_edit_select_all (ECellTextView *text_view) -{ - g_assert (text_view->edit); - - gtk_editable_select_region (GTK_EDITABLE (text_view->edit->entry), 0, -1); -} - -/* - * ECell::event method - */ -static gint -ect_event (ECellView *ecell_view, GdkEvent *event, int col, int row) -{ - ECellTextView *text_view = (ECellTextView *) ecell_view; - - switch (event->type){ - case GDK_BUTTON_PRESS: - /* - * Adjust for the border we use - */ - event->button.x++; - - printf ("Button pressed at %g %g\n", event->button.x, event->button.y); - if (text_view->edit){ - printf ("FIXME: Should handle click here\n"); - } else - e_table_item_enter_edit (text_view->eti, col, row); - break; - - case GDK_BUTTON_RELEASE: - /* - * Adjust for the border we use - */ - event->button.x++; - printf ("Button released at %g %g\n", event->button.x, event->button.y); - return TRUE; - - case GDK_KEY_PRESS: - if (event->key.keyval == GDK_Escape){ - ect_cancel_edit (text_view); - return TRUE; - } - - if (!text_view->edit){ - e_table_item_enter_edit (text_view->eti, col, row); - ect_edit_select_all (text_view); - } - - gtk_widget_event (GTK_WIDGET (text_view->edit->entry), event); - ect_queue_redraw (text_view, col, row); - break; - - case GDK_KEY_RELEASE: - break; - - default: - return FALSE; - } - return TRUE; -} - -/* - * ECell::height method - */ -static int -ect_height (ECellView *ecell_view, int col, int row) -{ - ECellTextView *text_view = (ECellTextView *) ecell_view; - - return (text_view->font->ascent + text_view->font->descent) + TEXT_PAD; -} - -/* - * Callback: invoked when the user pressed "enter" on the GtkEntry - */ -static void -ect_entry_activate (GtkEntry *entry, ECellTextView *text_view) -{ - e_table_item_leave_edit (text_view->eti); -} - -/* - * ECellView::enter_edit method - */ -static void * -ect_enter_edit (ECellView *ecell_view, int col, int row) -{ - ECellTextView *text_view = (ECellTextView *) ecell_view; - const char *str = e_table_model_value_at (ecell_view->ecell->table_model, col, row); - CellEdit *edit; - - edit = g_new (CellEdit, 1); - text_view->edit = edit; - - edit->col = col; - edit->row = row; - - edit->entry = (GtkEntry *) gtk_entry_new (); - gtk_entry_set_text (edit->entry, str); - edit->old_text = g_strdup (str); - gtk_signal_connect (GTK_OBJECT (edit->entry), "activate", - GTK_SIGNAL_FUNC (ect_entry_activate), text_view); - - /* - * The hack: create this window off-screen - */ - edit->entry_top = gtk_window_new (GTK_WINDOW_POPUP); - gtk_container_add (GTK_CONTAINER (edit->entry_top), GTK_WIDGET (edit->entry)); - gtk_widget_set_uposition (edit->entry_top, 20000, 20000); - gtk_widget_show_all (edit->entry_top); - - ect_queue_redraw (text_view, col, row); - - return NULL; -} - -/* - * ECellView::leave_edit method - */ -static void -ect_leave_edit (ECellView *ecell_view, int col, int row, void *edit_context) -{ - ECellTextView *text_view = (ECellTextView *) ecell_view; - - if (text_view->edit){ - ect_accept_edits (text_view); - ect_stop_editing (text_view); - } else { - /* - * We did invoke this leave edit internally - */ - } -} - -/* - * GtkObject::destroy method - */ -static void -ect_destroy (GtkObject *object) -{ - ECellText *ect = E_CELL_TEXT (object); - - g_free (ect->font_name); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -static void -e_cell_text_class_init (GtkObjectClass *object_class) -{ - ECellClass *ecc = (ECellClass *) object_class; - - object_class->destroy = ect_destroy; - - ecc->realize = ect_realize; - ecc->unrealize = ect_unrealize; - ecc->draw = ect_draw; - ecc->event = ect_event; - ecc->height = ect_height; - ecc->enter_edit = ect_enter_edit; - ecc->leave_edit = ect_leave_edit; - - parent_class = gtk_type_class (PARENT_TYPE); -} - -E_MAKE_TYPE(e_cell_text, "ECellText", ECellText, e_cell_text_class_init, NULL, PARENT_TYPE); - -ECell * -e_cell_text_new (ETableModel *etm, const char *fontname, GtkJustification justify) -{ - ECellText *ect = gtk_type_new (e_cell_text_get_type ()); - - ect->font_name = g_strdup (fontname); - ect->justify = justify; - E_CELL (ect)->table_model = etm; - - return (ECell *) ect; -} diff --git a/widgets/e-table/e-cell-text.h b/widgets/e-table/e-cell-text.h deleted file mode 100644 index de9629b97b..0000000000 --- a/widgets/e-table/e-cell-text.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _E_CELL_TEXT_H_ -#define _E_CELL_TEXT_H_ - -#include <libgnomeui/gnome-canvas.h> -#include "e-cell.h" - -#define E_CELL_TEXT_TYPE (e_cell_text_get_type ()) -#define E_CELL_TEXT(o) (GTK_CHECK_CAST ((o), E_CELL_TEXT_TYPE, ECellText)) -#define E_CELL_TEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TEXT_TYPE, ECellTextClass)) -#define E_IS_CELL_TEXT(o) (GTK_CHECK_TYPE ((o), E_CELL_TEXT_TYPE)) -#define E_IS_CELL_TEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TEXT_TYPE)) - -typedef struct { - ECell parent; - - GtkJustification justify; - char *font_name; -} ECellText; - -typedef struct { - ECellClass parent_class; -} ECellTextClass; - -GtkType e_cell_text_get_type (void); -ECell *e_cell_text_new (ETableModel *model, const char *fontname, GtkJustification justify); - -#endif /* _E_CELL_TEXT_H_ */ - diff --git a/widgets/e-table/e-cell-toggle.c b/widgets/e-table/e-cell-toggle.c deleted file mode 100644 index 8e06d8d87d..0000000000 --- a/widgets/e-table/e-cell-toggle.c +++ /dev/null @@ -1,285 +0,0 @@ -/* - * e-cell-toggle.c: Multi-state image toggle cell object. - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkenums.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtksignal.h> -#include <gdk/gdkkeysyms.h> -#include <libgnomeui/gnome-canvas.h> -#include "e-cell-toggle.h" -#include "e-util.h" -#include "e-table-item.h" - -#define PARENT_TYPE e_cell_get_type() - -typedef struct { - ECellView cell_view; - GdkGC *gc; - GnomeCanvas *canvas; - ETableItem *eti; -} ECellToggleView; - -static ECellClass *parent_class; - -static void -etog_queue_redraw (ECellToggleView *text_view, int col, int row) -{ - e_table_item_redraw_range (text_view->eti, col, row, col, row); -} - -/* - * ECell::realize method - */ -static ECellView * -etog_realize (ECell *ecell, void *view) -{ - ECellToggle *eccb = E_CELL_TOGGLE (ecell); - ECellToggleView *toggle_view = g_new0 (ECellToggleView, 1); - ETableItem *eti = E_TABLE_ITEM (view); - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - - toggle_view->cell_view.ecell = ecell; - toggle_view->eti = eti; - toggle_view->canvas = canvas; - toggle_view->gc = gdk_gc_new (GTK_WIDGET (canvas)->window); - - return (ECellView *) toggle_view; -} - -/* - * ECell::unrealize method - */ -static void -etog_unrealize (ECellView *ecv) -{ - ECellToggleView *toggle_view = (ECellToggleView *) ecv; - - gdk_gc_unref (toggle_view->gc); - toggle_view->gc = NULL; - - g_free (toggle_view); -} - -/* - * ECell::draw method - */ -static void -etog_draw (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, - int x1, int y1, int x2, int y2) -{ - ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell); - ECellToggleView *toggle_view = (ECellToggleView *) ecell_view; - GdkPixbuf *image; - ArtPixBuf *art; - int x, y, width, height; - gboolean free_image; - const int value = GPOINTER_TO_INT ( - e_table_model_value_at (ecell_view->ecell->table_model, col, row)); - - if (value >= toggle->n_states){ - g_warning ("Value from the table model is %d, the states we support are [0..%d)\n", - value, toggle->n_states); - return; - } - - /* - * Paint the background - */ - gdk_draw_rectangle (drawable, GTK_WIDGET (toggle_view->canvas)->style->white_gc, TRUE, x1, y1, x2 - x1, y2 - y1); - - image = toggle->images [value]; - art = image->art_pixbuf; - - if ((x2 - x1) < art->width){ - x = x1; - width = x2 - x1; - } else { - x = x1 + ((x2 - x1) - art->width) / 2; - width = art->width; - } - - if ((y2 - y1) < art->height){ - y = y1; - height = y2 - y1; - } else { - y = y1 + ((y2 - y1) - art->height) / 2; - height = art->height; - } - - width = y2 - y1; - - if (image->art_pixbuf->has_alpha){ - GdkColor background; - guchar *buffer; - int alpha, ix, iy; - - buffer = g_malloc (art->rowstride * art->height * 3); - - background.red = 255; - background.green = 255; - background.blue = 255; - - for (iy = 0; iy < art->height; iy++){ - unsigned char *dest; - unsigned char *src; - - dest = buffer + (iy * art->rowstride); - src = art->pixels + (iy * art->rowstride); - - for (ix = 0; ix < art->width; ix++){ - alpha = src [3]; - if (alpha == 0){ - *dest++ = background.red; - *dest++ = background.green; - *dest++ = background.blue; - src += 3; - } else if (alpha == 255){ - *dest++ = *src++; - *dest++ = *src++; - *dest++ = *src++; - } else { - *dest++ = (background.red + ((*src++ - background.red) * alpha + 0x80)) >> 8; - *dest++ = (background.green + ((*src++ - background.green) * alpha + 0x80)) >> 8; - *dest++ = (background.blue + ((*src++ - background.blue) * alpha + 0x80)) >> 8; - } - src++; - } - } - - gdk_draw_rgb_image_dithalign ( - drawable, toggle_view->gc, x, y, width, height, - GDK_RGB_DITHER_NORMAL, buffer, art->rowstride, 0, 0); - - g_free (buffer); - } else - gdk_draw_rgb_image_dithalign ( - drawable, toggle_view->gc, x, y, width, height, - GDK_RGB_DITHER_NORMAL, art->pixels, art->rowstride, 0, 0); -} - -static void -etog_set_value (ECellToggleView *toggle_view, int col, int row, int value) -{ - ECell *ecell = toggle_view->cell_view.ecell; - ECellToggle *toggle = E_CELL_TOGGLE (ecell); - - if (value >= toggle->n_states) - value = 0; - - e_table_model_set_value_at (ecell->table_model, col, row, GINT_TO_POINTER (value)); - etog_queue_redraw (toggle_view, col, row); -} - -/* - * ECell::event method - */ -static gint -etog_event (ECellView *ecell_view, GdkEvent *event, int col, int row) -{ - ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell); - ECellToggleView *toggle_view = (ECellToggleView *) ecell_view; - void *_value = e_table_model_value_at (ecell_view->ecell->table_model, col, row); - const int value = GPOINTER_TO_INT (_value); - - switch (event->type){ - case GDK_BUTTON_RELEASE: - etog_set_value (toggle_view, col, row, value + 1); - return TRUE; - - case GDK_KEY_PRESS: - if (event->key.keyval == GDK_space){ - etog_set_value (toggle_view, col, row, value + 1); - return TRUE; - } - return FALSE; - - default: - return FALSE; - } - return TRUE; -} - -/* - * ECell::height method - */ -static int -etog_height (ECellView *ecell_view, int col, int row) -{ - ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell); - - return toggle->height; -} - -static void -etog_destroy (GtkObject *object) -{ - ECellToggle *etog = E_CELL_TOGGLE (object); - int i; - - for (i = 0; i < etog->n_states; i++) - gdk_pixbuf_unref (etog->images [i]); - - g_free (etog->images); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -static void -e_cell_toggle_class_init (GtkObjectClass *object_class) -{ - ECellClass *ecc = (ECellClass *) object_class; - - object_class->destroy = etog_destroy; - - ecc->realize = etog_realize; - ecc->unrealize = etog_unrealize; - ecc->draw = etog_draw; - ecc->event = etog_event; - ecc->height = etog_height; - - parent_class = gtk_type_class (PARENT_TYPE); -} - -E_MAKE_TYPE(e_cell_toggle, "ECellToggle", ECellToggle, e_cell_toggle_class_init, NULL, PARENT_TYPE); - -void -e_cell_toggle_construct (ECellToggle *etog, ETableModel *etm, int border, int n_states, GdkPixbuf **images) -{ - int max_height = 0; - int i; - - E_CELL (etog)->table_model = etm; - - etog->border = border; - etog->n_states = n_states; - - etog->images = g_new (GdkPixbuf *, n_states); - - for (i = 0; i < n_states; i++){ - etog->images [i] = images [i]; - gdk_pixbuf_ref (images [i]); - - if (images [i]->art_pixbuf->height > max_height) - max_height = images [i]->art_pixbuf->height; - } - - etog->height = max_height; -} - -ECell * -e_cell_toggle_new (ETableModel *etm, int border, int n_states, GdkPixbuf **images) -{ - ECellToggle *etog = gtk_type_new (e_cell_toggle_get_type ()); - - e_cell_toggle_construct (etog, etm, border, n_states, images); - - return (ECell *) etog; -} diff --git a/widgets/e-table/e-cell-toggle.h b/widgets/e-table/e-cell-toggle.h deleted file mode 100644 index 2a5b6adc18..0000000000 --- a/widgets/e-table/e-cell-toggle.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _E_CELL_TOGGLE_H_ -#define _E_CELL_TOGGLE_H_ - -#include <libgnomeui/gnome-canvas.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include "e-cell.h" - -#define E_CELL_TOGGLE_TYPE (e_cell_toggle_get_type ()) -#define E_CELL_TOGGLE(o) (GTK_CHECK_CAST ((o), E_CELL_TOGGLE_TYPE, ECellToggle)) -#define E_CELL_TOGGLE_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TOGGLE_TYPE, ECellToggleClass)) -#define E_IS_CELL_TOGGLE(o) (GTK_CHECK_TYPE ((o), E_CELL_TOGGLE_TYPE)) -#define E_IS_CELL_TOGGLE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TOGGLE_TYPE)) - -typedef struct { - ECell parent; - - int border; - int n_states; - GdkPixbuf **images; - - int height; -} ECellToggle; - -typedef struct { - ECellClass parent_class; -} ECellToggleClass; - -GtkType e_cell_toggle_get_type (void); -ECell *e_cell_toggle_new (ETableModel *model, int border, - int n_states, - GdkPixbuf **images); -void e_cell_toggle_construct (ECellToggle *etog, ETableModel *etm, - int border, int n_states, GdkPixbuf **images); - -#endif /* _E_CELL_TOGGLE_H_ */ - - diff --git a/widgets/e-table/e-cell.c b/widgets/e-table/e-cell.c deleted file mode 100644 index 2bc49f7a45..0000000000 --- a/widgets/e-table/e-cell.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * e-cell.c: base class for cell renderers in e-table - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include "e-cell.h" -#include "e-util.h" - -#define PARENT_TYPE gtk_object_get_type() - -static ECellView * -ec_realize (ECell *e_cell, void *view) -{ - return NULL; -} - -static void -ec_unrealize (ECellView *e_cell) -{ -} - -static void -ec_draw (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, - int x1, int y1, int x2, int y2) -{ - g_error ("e-cell-draw invoked\n"); -} - -static gint -ec_event (ECellView *ecell_view, GdkEvent *event, int col, int row) -{ - g_error ("e-cell-event invoked\n"); - return 0; -} - -static gint -ec_height (ECellView *ecell_view, int col, int row) -{ - g_error ("e-cell-event invoked\n"); - return 0; -} - -static void -ec_focus (ECellView *ecell_view, int col, int row, int x1, int y1, int x2, int y2) -{ - ecell_view->focus_col = col; - ecell_view->focus_row = row; - ecell_view->focus_x1 = x1; - ecell_view->focus_y1 = y1; - ecell_view->focus_x2 = x2; - ecell_view->focus_y2 = y2; -} - -static void -ec_unfocus (ECellView *ecell_view) -{ - ecell_view->focus_col = -1; - ecell_view->focus_row = -1; - ecell_view->focus_x1 = -1; - ecell_view->focus_y1 = -1; - ecell_view->focus_x2 = -1; - ecell_view->focus_y2 = -1; -} - -static void -e_cell_class_init (GtkObjectClass *object_class) -{ - ECellClass *ecc = (ECellClass *) object_class; - - ecc->realize = ec_realize; - ecc->unrealize = ec_unrealize; - ecc->draw = ec_draw; - ecc->event = ec_event; - ecc->focus = ec_focus; - ecc->unfocus = ec_unfocus; - ecc->height = ec_height; -} - -static void -e_cell_init (GtkObject *object) -{ - ECell *e_cell = E_CELL (object); -} - -E_MAKE_TYPE(e_cell, "ECell", ECell, e_cell_class_init, e_cell_init, PARENT_TYPE); - - -void -e_cell_event (ECellView *ecell_view, GdkEvent *event, int col, int row) -{ - E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->event ( - ecell_view, event, col, row); -} - -ECellView * -e_cell_realize (ECell *ecell, void *view) -{ - return E_CELL_CLASS (GTK_OBJECT (ecell)->klass)->realize ( - ecell, view); -} - -void -e_cell_unrealize (ECellView *ecell_view) -{ - E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->unrealize (ecell_view); -} - -void -e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, int x1, int y1, int x2, int y2) -{ - E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->draw ( - ecell_view, drawable, col, row, selected, x1, y1, x2, y2); -} - -int -e_cell_height (ECellView *ecell_view, int col, int row) -{ - return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->height ( - ecell_view, col, row); -} - -void * -e_cell_enter_edit (ECellView *ecell_view, int col, int row) -{ - return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->enter_edit ( - ecell_view, col, row); -} - -void -e_cell_leave_edit (ECellView *ecell_view, int col, int row, void *edit_context) -{ - E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->leave_edit ( - ecell_view, col, row, edit_context); -} diff --git a/widgets/e-table/e-cell.h b/widgets/e-table/e-cell.h deleted file mode 100644 index b0f62d020c..0000000000 --- a/widgets/e-table/e-cell.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _E_CELL_H_ -#define _E_CELL_H_ - -#include <gdk/gdktypes.h> -#include "e-table-model.h" - -#define E_CELL_TYPE (e_cell_get_type ()) -#define E_CELL(o) (GTK_CHECK_CAST ((o), E_CELL_TYPE, ECell)) -#define E_CELL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TYPE, ECellClass)) -#define E_IS_CELL(o) (GTK_CHECK_TYPE ((o), E_CELL_TYPE)) -#define E_IS_CELL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TYPE)) - -typedef struct _ECell ECell; -typedef struct _ECellView ECellView; - -struct _ECell { - GtkObject object; - ETableModel *table_model; -}; - -struct _ECellView { - ECell *ecell; - gint focus_x1, focus_y1, focus_x2, focus_y2; - gint focus_col, focus_row; -}; - -#define E_CELL_IS_FOCUSED(ecell_view) (ecell_view->focus_x1 != -1) - -typedef struct { - GtkObjectClass parent_class; - - ECellView *(*realize) (ECell *ecell, void *view); - void (*unrealize) (ECellView *e_cell_view); - void (*draw) (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, int x1, int y1, int x2, int y2); - gint (*event) (ECellView *ecell_view, GdkEvent *event, int col, int row); - void (*focus) (ECellView *ecell_view, int col, int row, int x1, int y1, int x2, int y2); - void (*unfocus) (ECellView *ecell_view); - int (*height) (ECellView *ecell_view, int col, int row); - - void *(*enter_edit)(ECellView *ecell_view, int col, int row); - void (*leave_edit)(ECellView *ecell_view, int col, int row, void *context); -} ECellClass; - -GtkType e_cell_get_type (void); -void e_cell_event (ECellView *ecell_view, GdkEvent *event, int col, int row); -ECellView *e_cell_realize (ECell *ecell, void *view); -void e_cell_unrealize (ECellView *ecell_view); -void e_cell_draw (ECellView *ecell_view, GdkDrawable *dr, - int col, int row, gboolean selected, - int x1, int y1, int x2, int y2); -void e_cell_focus (ECellView *ecell_view, int col, int row, int x1, int y1, int x2, int y2); -void e_cell_unfocus (ECellView *ecell_view); -int e_cell_height (ECellView *ecell_view, int col, int row); - -void *e_cell_enter_edit(ECellView *ecell_view, int col, int row); -void e_cell_leave_edit(ECellView *ecell_view, int col, int row, void *edit_context); - -#endif /* _E_CELL_H_ */ diff --git a/widgets/e-table/e-table-col.c b/widgets/e-table/e-table-col.c deleted file mode 100644 index cca7bd13d6..0000000000 --- a/widgets/e-table/e-table-col.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * E-table-col.c: ETableCol implementation - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkobject.h> -#include <gtk/gtksignal.h> -#include "e-table-col.h" -#include "e-util.h" - -#define PARENT_TYPE (gtk_object_get_type ()) - -static GtkObjectClass *parent_class; - -static void -etc_destroy (GtkObject *object) -{ - ETableCol *etc = E_TABLE_COL (object); - - printf ("Destroying columns: %s %s\n", etc->id, etc->text); - g_free (etc->id); - g_free (etc->text); - - (*parent_class->destroy)(object); -} - -static void -e_table_col_class_init (GtkObjectClass *object_class) -{ - parent_class = gtk_type_class (PARENT_TYPE); - object_class->destroy = etc_destroy; -} - -E_MAKE_TYPE(e_table_col, "ETableCol", ETableCol, e_table_col_class_init, NULL, PARENT_TYPE); - -ETableCol * -e_table_col_new (const char *id, const char *text, int width, int min_width, - ECell *ecell, GCompareFunc compare, gboolean resizable) -{ - ETableCol *etc; - - g_return_val_if_fail (id != NULL, NULL); - g_return_val_if_fail (width >= 0, NULL); - g_return_val_if_fail (min_width >= 0, NULL); - g_return_val_if_fail (width >= min_width, NULL); - g_return_val_if_fail (compare != NULL, NULL); - - etc = gtk_type_new (E_TABLE_COL_TYPE); - - etc->id = g_strdup (id); - etc->text = g_strdup (text); - etc->width = width; - etc->min_width = min_width; - etc->ecell = ecell; - etc->compare = compare; - - etc->selected = 0; - etc->resizeable = resizable; - - return etc; -} - - diff --git a/widgets/e-table/e-table-col.h b/widgets/e-table/e-table-col.h deleted file mode 100644 index c8fa6dd581..0000000000 --- a/widgets/e-table/e-table-col.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _E_TABLE_COL_H_ -#define _E_TABLE_COL_H_ - -#include "e-cell.h" - -#define E_TABLE_COL_TYPE (e_table_col_get_type ()) -#define E_TABLE_COL(o) (GTK_CHECK_CAST ((o), E_TABLE_COL_TYPE, ETableCol)) -#define E_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_COL_TYPE, ETableColClass)) -#define E_IS_TABLE_COL(o) (GTK_CHECK_TYPE ((o), E_TABLE_COL_TYPE)) -#define E_IS_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_COL_TYPE)) - -typedef struct _ETableCol ETableCol; - -/* - * Information about a single column - */ -struct _ETableCol { - GtkObject base; - char *id, *text; - short width; - short min_width; - short x; - GCompareFunc compare; - unsigned int selected:1; - unsigned int resizeable:1; - - - ECell *ecell; -}; - -typedef struct { - GtkObjectClass parent_class; -} ETableColClass; - -GtkType e_table_col_get_type (void); -ETableCol *e_table_col_new (const char *id, const char *text, - int width, int min_width, - ECell *ecell, GCompareFunc compare, - gboolean resizable); -void e_table_col_destroy (ETableCol *etc); - - -#endif /* _E_TABLE_COL_H_ */ - diff --git a/widgets/e-table/e-table-column-item.c b/widgets/e-table/e-table-column-item.c deleted file mode 100644 index 0616327a93..0000000000 --- a/widgets/e-table/e-table-column-item.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * E-table-column-view.c: A canvas view of the TableColumn. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc. - */ -#include <config.h> -#include "e-table-column.h" -#include "e-table-column-view.h" - -#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type () - -static GnomeCanvasItemClass *etci_parent_class; - -enum { - ARG_0, - ARG_TABLE_COLUMN -}; - -static void -etci_destroy (GtkObject *object) -{ - ETableColumnItem *etcv = E_TABLE_COLUMN_VIEW (object); - - gtk_object_unref (GTK_OBJECT (etcv)); - - if (GTK_OBJECT_CLASS (etcv_parent_class)->destroy) - (*GTK_OBJECT_CLASS (etcv_parent_class)->destroy) (object); -} - -static void -etci_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) -{ - if (GNOME_CANVAS_ITEM_CLASS(item_bar_parent_class)->update) - (*GNOME_CANVAS_ITEM_CLASS(item_bar_parent_class)->update)(item, affine, clip_path, flags); - - item->x1 = 0; - item->y1 = 0; - item->x2 = INT_MAX; - item->y2 = INT_MAX; - gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item); -} - -static void -etci_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ETableColumnItem *etci; - int v; - - item = GNOME_CANVAS_ITEM (o); - etci = E_TABLE_COLUMN_ITEM (o); - - switch (arg_id){ - case ARG_TABLE_COLUMN: - etci->etci = GTK_VALUE_POINTER (*arg); - break; - } - etci_update (item, NULL, NULL, 0); -} - -static void -etci_realize (GnomeCanvasItem *item) -{ - ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item); - GdkWindow *window; - GdkColor c; - - if (GNOME_CANVAS_ITEM_CLASS (etci_parent_class)-> realize) - (*GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->realize)(item); - - window = GTK_WIDGET (item->canvas)->window; - - etci->gc = gdk_gc_new (window); - gnome_canvas_get_color (item->canvas, "black", &c); - gdk_gc_set_foreground (etci->gc, &c); - - etci->normal_cursor = gdk_cursor_new (GDK_ARROW); -} - -static void -etci_unrealize (GnomeCanvasItem *item) -{ - ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item); - - gdk_gc_unref (etci->gc); - etci->gc = NULL; - - gdk_cursor_destroy (etci->change_cursor); - etci->change_cursor = NULL; - - gdk_cursor_destroy (etci->normal_cursor); - etci->normal_cursor = NULL; - - if (GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->unrealize) - (*GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->unrealize)(item); -} - -static void -etci_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x1, int y1, int width, int height) -{ - ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item); - GnomeCanvas *canvas = item->canvas; - GdkGC *gc; - const int cols = e_table_column_count (etci->etc); - int x2 = x1 + width; - int col, total; - - total = 0; - for (col = 0; col < cols; col++){ - ETableCol *col = e_table_column_get_column (etci->etc, col); - const int col_width = col->width; - - if (x1 > total + col_width) - continue; - - if (x2 < total) - return; - - gc = canvas->style->bg_gc [GTK_STATE_ACTIVE]; - gdk_draw_rectangle (drawble, gc, TRUE, - gtk_draw_shadow (canvas->style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT, - x, y, width, height - } -} - -static double -etci_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = *item; - return 0.0; -} - -static void -etci_event (GnomeCanvasItem *item, GdkEvent *e) -{ - switch (e->type){ - default: - return FALSE; - } - return TRUE; -} - -static void -etci_class_init (GtkObjectClass *object_class) -{ - GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class; - - object_class->destroy = etci_destroy; - object_class->set_arg = etci_set_arg; - - item_class->update = etci_update; - item_class->realize = etci_realize; - item_class->unrealize = etci_unrealize; - item_class->draw = etci_draw; - item_class->point = etci_point; - item_class->event = etci_event; - - gtk_object_add_arg_type ("ETableColumnItem::ETableColumn", GTK_TYPE_POINTER, - GTK_ARG_WRITABLE, ARG_TABLE_COLUMN); -} - -static void -etci_init (GnomeCanvasItem *item) -{ - item->x1 = 0; - item->y1 = 0; - item->x2 = 0; - item->y2 = 0; -} - -GtkType -e_table_column_view_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableColumnItem", - sizeof (ETableColumnItem), - sizeof (ETableColumnItemClass), - (GtkClassInitFunc) etci_class_init, - (GtkObjectInitFunc) etci_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_OBJECT_TYPE, &info); - } - - return type; -} - - - diff --git a/widgets/e-table/e-table-column-item.h b/widgets/e-table/e-table-column-item.h deleted file mode 100644 index fd38681a73..0000000000 --- a/widgets/e-table/e-table-column-item.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _E_TABLE_COLUMN_VIEW_H -#defein _E_TABLE_COLUMN_VIEW_H - -#include "e-table-column.h" - -typedef struct { - GnomeCanvasItem parent; - ETableColumn *etc; - - GdkGC *gc; - GdkCursor *change_cursor, *normal_cursor; -} ETableColumnView; - -typedef struct { - GnomeCanvasItemClass parent_class; -} ETableColumnViewClass; - -GtkType e_table_column_item_get_type (void); - -#endif /* _E_TABLE_COLUMN_VIEW_H */ diff --git a/widgets/e-table/e-table-column-model.h b/widgets/e-table/e-table-column-model.h deleted file mode 100644 index 043dd783ca..0000000000 --- a/widgets/e-table/e-table-column-model.h +++ /dev/null @@ -1,5 +0,0 @@ - -class ETableColumnModel { - virtual void add_column (ETableCol *et) = 0; - virtual ETableCol *get_column (int column); - virtual diff --git a/widgets/e-table/e-table-column.c b/widgets/e-table/e-table-column.c deleted file mode 100644 index d17a285321..0000000000 --- a/widgets/e-table/e-table-column.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * e-table-column.c: TableColumn implementation - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include "e-table-column.h" - -enum { - STRUCTURE_CHANGE, - DIMENSION_CHANGE, - LAST_SIGNAL -}; - -static guint etc_signals [LAST_SIGNAL] = { 0, }; - -static GtkObjectClass *e_table_column_parent_class; - -static void -e_table_column_destroy (GtkObject *object) -{ - ETableColumn *etc = E_TABLE_COLUMN (object); - const int cols = etc->col_count; - - /* - * Destroy listeners - */ - for (l = etc->listeners; l; l = l->next) - g_free (l->data); - g_slist_free (etc->listeners); - etc->listeners = NULL; - - /* - * Destroy columns - */ - for (i = 0; i < cols; i++) - e_table_column_remove (etc, i); - - if (e_table_column_parent_class->destroy) - e_table_column_parent_class->destroy (object); -} - -static void -e_table_column_class_init (GtkObjectClass *object_class) -{ - object_class->destroy = e_table_column_destroy; - - e_table_column_parent_class = (gtk_type_class (gtk_object_get_type ())); - - etc_signals [STRUCTURE_CHANGE] = - gtk_signal_new ("structure_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableColumn, structure_change), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - etc_signals [DIMENSION_CHANGE] = - gtk_signal_new ("dimension_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableColumn, dimension_change), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, etc_signals, LAST_SIGNAL); -} - -GtkType -e_table_column_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableColumn", - sizeof (ETableColumn), - sizeof (ETableColumnClass), - (GtkClassInitFunc) e_table_column_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - -static void -etc_do_insert (ETableColumn *etc, int pos, ETableCol *val) -{ - memcpy (&etc->columns [pos+1], &etc->columns [pos], - sizeof (ETableCol *) * (etc->col_count - pos)); - etc->columns [pos] = val; -} - -void -e_table_column_add_column (ETableColumn *etc, ETableCol *tc, int pos) -{ - ETableCol **new_ptr; - - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (tc != NULL); - g_return_if_fail (pos >= 0 && pos < etc->col_count); - - if (pos == -1) - pos = etc->col_count; - etc->columns = g_realloc (etc->columns, sizeof (ETableCol *) * (etc->col_count + 1)); - etc_do_insert (etc, pos, tc); - etc->col_count++; - - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]); -} - -ETableCol * -e_table_column_get_column (ETableColumn *etc, int column) -{ - g_return_val_if_fail (etc != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), NULL); - - if (column < 0) - return NULL; - - if (column >= etc->col_count) - return NULL; - - return etc->columns [column]; -} - -int -e_table_column_count (ETableColumn *etc) -{ - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - return etc->col_count; -} - -int -e_table_column_index (ETableColumn *etc, const char *identifier) -{ - int i; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - g_return_val_if_fail (identifier != NULL, 0); - - for (i = 0; i < etc->col_count; i++){ - ETableCol *tc = etc->columns [i]; - - if (strcmp (i->id, identifier) == 0) - return i; - } - - return -1; -} - -int -e_table_column_get_index_at (ETableColumn *etc, int x_offset) -{ - int i, total; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - g_return_val_if_fail (identifier != NULL, 0); - - total = 0; - for (i = 0; i < etc->col_count; i++){ - total += etc->columns [i]->width; - - if (x_offset < total) - return i; - } - - return -1; -} - -ETableCol ** -e_table_column_get_columns (ETableColumn *etc) -{ - ETableCol **ret; - int i; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - ret = g_new (ETableCol *, etc->col_count + 1); - memcpy (ret, etc->columns, sizeof (ETableCol *) * etc->col_count); - ret [etc->col_count] = NULL; - - return ret; -} - -gboolean -e_table_column_selection_ok (ETableColumn *etc) -{ - g_return_val_if_fail (etc != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), FALSE); - - return etc->selectable; -} - -int -ve_table_column_get_selected (ETableColumn *etc) -{ - int i; - int selected = 0; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - for (i = 0; i < etc->col_count; i++){ - if (etc->columns [i]->selected) - selected++; - } - - return selected; -} - -int -e_table_column_total_width (ETableColumn *etc) -{ - int total; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - total = 0; - for (i = 0; i < etc->col_count; i++) - total += etc->columns [i].width; - - return total; -} - -static void -etc_do_remove (ETableColumn *etc, int idx) -{ - memcpy (&etc->columns [idx], &etc->columns [idx+1], - sizeof (ETableCol *) * etc->col_count - idx); - etc->col_count--; -} - -void -e_table_column_move (ETableColumn *etc, int source_index, int target_index) -{ - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (source_index >= 0); - g_return_if_fail (target_index >= 0); - g_return_if_fail (source_index < etc->col_count); - g_return_if_fail (target_index < etc->col_count); - - old = etc->columns [source_index]; - etc_do_remove (etc, source_index); - etc_do_insert (etc, target_index, old); - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]); -} - -void -e_table_column_remove (ETableColumn *etc, int idx) -{ - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < etc->col_count); - - etc_do_remove (etc, idx); - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]); -} - -void -e_table_column_set_selection (ETableColumn *etc, gboolean allow_selection); -{ -} - -void -e_table_column_set_size (ETableColumn *etc, int idx, int size) -{ - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < etc->col_count); - g_return_if_fail (size > 0); - - etc->columns [idx]->width = size; - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [SIZE_CHANGE], idx); -} diff --git a/widgets/e-table/e-table-group.c b/widgets/e-table/e-table-group.c deleted file mode 100644 index b1e681d255..0000000000 --- a/widgets/e-table/e-table-group.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * E-Table-Group.c: Implements the grouping objects for elements on a table - * - * Author: - * Miguel de Icaza (miguel@gnu.org() - * - * Copyright 1999, Helix Code, Inc. - */ - -#include <config.h> -#include "e-table-group.h" - -void -e_table_group_destroy (ETableGroup *etg) -{ - g_return_if_fail (etg != NULL); - - g_free (etg->title); - - if (etg->is_leaf == 0){ - GSList *l; - - for (l = etg->u.children; l; l = l->next){ - ETableGroup *child = l->data; - - e_table_group_destroy (child); - } - g_slist_free (etg->u.children); - etg->u.children = NULL; - } - g_free (etg); -} - -ETableGroup * -e_table_group_new_leaf (const char *title, ETableModel *table) -{ - ETableGroup *etg; - - g_return_val_if_fail (title != NULL, NULL); - g_return_val_if_fail (table != NULL, NULL); - - etg = g_new (ETableGroup, 1); - - etg->expanded = 0; - etg->is_leaf = 1; - etg->u.table = table; - etg->title = g_strdup (title); - - return etg; -} - -ETableGroup * -e_table_group_new (const char *title) -{ - ETableGroup *etg; - - g_return_val_if_fail (title != NULL, NULL); - - etg = g_new (ETableGroup, 1); - - etg->expanded = 0; - etg->is_leaf = 0; - etg->u.children = NULL; - etg->title = g_strdup (title); - - return etg; -} - -void -e_table_group_append_child (ETableGroup *etg, ETableGroup *child) -{ - g_return_if_fail (etg != NULL); - g_return_if_fail (child != NULL); - g_return_if_fail (etg->is_leaf != 0); - - etg->u.children = g_slist_append (etg->u.children, child); -} - -#if 0 -int -e_table_group_size (ETableGroup *etg) -{ - g_return_val_if_fail (etg != NULL, 0); - - if (etg->is_leaf) - return e_table_model_height (etg->u.table); - else { - GSList *l; - int size = 0; - - for (l = etg->u.children; l; l = l->next){ - ETableGroup *child = l->data; - - size += e_table_group_size (child); - } - return size; - } -} - -#endif diff --git a/widgets/e-table/e-table-group.h b/widgets/e-table/e-table-group.h deleted file mode 100644 index d673aebd11..0000000000 --- a/widgets/e-table/e-table-group.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _E_TABLE_TREE_H_ -#define _E_TABLE_TREE_H_ - -#include "e-table-model.h" - -typedef struct { - char *title; - - union { - ETableModel *table; - GSList *children; - } u; - - guint expanded :1; - guint is_leaf :1; -} ETableGroup; - -ETableGroup *e_table_group_new (const char *title); -ETableGroup *e_table_group_new_leaf (const char *title, ETableModel *table); -void e_table_group_destroy (ETableGroup *etg); - -int e_table_group_size (ETableGroup *egroup); -void e_table_group_append_child (ETableGroup *etg, ETableGroup *child); - -#endif /* _E_TABLE_TREE_H_ */ diff --git a/widgets/e-table/e-table-header-item.c b/widgets/e-table/e-table-header-item.c deleted file mode 100644 index 378bdf4447..0000000000 --- a/widgets/e-table/e-table-header-item.c +++ /dev/null @@ -1,527 +0,0 @@ -/* - * E-table-column-view.c: A canvas item based view of the ETableColumn. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc. - */ -#include <config.h> -#include <gtk/gtksignal.h> -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-cursors.h" - -/* Padding above and below of the string in the header display */ -#define PADDING 4 - -/* Defines the tolerance for proximity of the column division to the cursor position */ -#define TOLERANCE 2 - -#define ETHI_RESIZING(x) ((x)->resize_col != -1) - -#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type () - -static GnomeCanvasItemClass *ethi_parent_class; - -enum { - ARG_0, - ARG_TABLE_HEADER, - ARG_TABLE_X, - ARG_TABLE_Y, - ARG_TABLE_FONTSET -}; - -static void -ethi_destroy (GtkObject *object) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (object); - - gtk_object_unref (GTK_OBJECT (ethi->eth)); - - if (GTK_OBJECT_CLASS (ethi_parent_class)->destroy) - (*GTK_OBJECT_CLASS (ethi_parent_class)->destroy) (object); -} - -static void -ethi_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - - if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update) - (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update)(item, affine, clip_path, flags); - - item->x1 = ethi->x1; - item->y1 = ethi->y1; - item->x2 = ethi->x1 + ethi->width; - item->y2 = ethi->y1 + ethi->height; - - gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item); -} - -static void -ethi_font_load (ETableHeaderItem *ethi, char *font) -{ - if (ethi->font) - gdk_font_unref (ethi->font); - - ethi->font = gdk_fontset_load (font); - if (ethi->font == NULL) - ethi->font = gdk_font_load ("fixed"); - - ethi->height = ethi->font->ascent + ethi->font->descent + PADDING; -} - -static void -ethi_drop_table_header (ETableHeaderItem *ethi) -{ - GtkObject *header; - - if (!ethi->eth) - return; - - header = GTK_OBJECT (ethi->eth); - gtk_signal_disconnect (header, ethi->structure_change_id); - gtk_signal_disconnect (header, ethi->dimension_change_id); - - gtk_object_unref (header); - ethi->eth = NULL; - ethi->width = 0; -} - -static void -structure_changed (ETableHeader *header, ETableHeaderItem *ethi) -{ - ethi->width = e_table_header_total_width (header); - - ethi_update (GNOME_CANVAS_ITEM (ethi), NULL, NULL, 0); -} - -static void -dimension_changed (ETableHeader *header, int col, ETableHeaderItem *ethi) -{ - ethi->width = e_table_header_total_width (header); - - ethi_update (GNOME_CANVAS_ITEM (ethi), NULL, NULL, 0); -} - -static void -ethi_add_table_header (ETableHeaderItem *ethi, ETableHeader *header) -{ - ethi->eth = header; - gtk_object_ref (GTK_OBJECT (ethi->eth)); - ethi->width = e_table_header_total_width (header); - - ethi->structure_change_id = gtk_signal_connect ( - GTK_OBJECT (header), "structure_change", - GTK_SIGNAL_FUNC(structure_changed), ethi); - ethi->dimension_change_id = gtk_signal_connect ( - GTK_OBJECT (header), "dimension_change", - GTK_SIGNAL_FUNC(dimension_changed), ethi); -} - -static void -ethi_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ETableHeaderItem *ethi; - - item = GNOME_CANVAS_ITEM (o); - ethi = E_TABLE_HEADER_ITEM (o); - - switch (arg_id){ - case ARG_TABLE_HEADER: - ethi_drop_table_header (ethi); - ethi_add_table_header (ethi, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_TABLE_X: - ethi->x1 = GTK_VALUE_INT (*arg); - break; - - case ARG_TABLE_Y: - ethi->y1 = GTK_VALUE_INT (*arg); - break; - - case ARG_TABLE_FONTSET: - ethi_font_load (ethi, GTK_VALUE_STRING (*arg)); - break; - - } - ethi_update (item, NULL, NULL, 0); -} - -static void -ethi_realize (GnomeCanvasItem *item) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - GdkWindow *window; - GdkColor c; - - if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)-> realize) - (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->realize)(item); - - window = GTK_WIDGET (item->canvas)->window; - - ethi->gc = gdk_gc_new (window); - gnome_canvas_get_color (item->canvas, "black", &c); - gdk_gc_set_foreground (ethi->gc, &c); - - ethi->normal_cursor = gdk_cursor_new (GDK_ARROW); - - if (!ethi->font) - ethi_font_load (ethi, "fixed"); -} - -static void -ethi_unrealize (GnomeCanvasItem *item) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - - gdk_gc_unref (ethi->gc); - ethi->gc = NULL; - - gdk_cursor_destroy (ethi->normal_cursor); - ethi->normal_cursor = NULL; - - if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->unrealize) - (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->unrealize)(item); -} - -static void -draw_button (ETableHeaderItem *ethi, ETableCol *col, - GdkDrawable *drawable, GdkGC *gc, GtkStyle *style, - int x, int y, int width, int height) -{ - GdkRectangle clip; - int xtra; - - gdk_draw_rectangle ( - drawable, gc, TRUE, - x + 1, y + 1, width - 2, height -2); - - gtk_draw_shadow ( - style, drawable, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - x , y, width, height); - - clip.x = x + 2; - clip.y = y + 2; - clip.width = width - 4; - clip.height = ethi->height; - - gdk_gc_set_clip_rectangle (ethi->gc, &clip); - - /* Center the thing */ - xtra = (clip.width - gdk_string_measure (ethi->font, col->id))/2; - - if (xtra < 0) - xtra = 0; - - /* Skip over border */ - x += xtra + 2; - - gdk_draw_text ( - drawable, ethi->font, - ethi->gc, x, y + ethi->height - PADDING, - col->id, strlen (col->id)); -} - -static void -ethi_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x1, int y1, int width, int height) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - GnomeCanvas *canvas = item->canvas; - GdkGC *gc; - const int cols = e_table_header_count (ethi->eth); - int x2 = x1 + width; - int col, total; - int x; - - total = 0; - x = -x1; - -#if 0 - printf ("My coords are: %g %g %g %g\n", - item->x1, item->y1, item->x2, item->y2); -#endif - - for (col = 0; col < cols; col++){ - ETableCol *ecol = e_table_header_get_column (ethi->eth, col); - int col_width; - - if (col == ethi->resize_col) - col_width = ethi->resize_width; - else - col_width = ecol->width; - - if (x1 > total + col_width){ - total += col_width; - x += col_width; - continue; - } - - if (x2 < total) - return; - - gc = GTK_WIDGET (canvas)->style->bg_gc [GTK_STATE_ACTIVE]; - - draw_button (ethi, ecol, drawable, gc, - GTK_WIDGET (canvas)->style, - x, ethi->y1 - y1, col_width, ethi->height); - - x += col_width; - total += col_width; - } -} - -static double -ethi_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - -/* - * is_pointer_on_division: - * - * Returns whether @pos is a column header division; If @the_total is not NULL, - * then the actual position is returned here. If @return_ecol is not NULL, - * then the ETableCol that actually contains this point is returned here - */ -static gboolean -is_pointer_on_division (ETableHeaderItem *ethi, int pos, int *the_total, int *return_col) -{ - const int cols = e_table_header_count (ethi->eth); - int col, total; - - total = 0; - for (col = 0; col < cols; col++){ - ETableCol *ecol = e_table_header_get_column (ethi->eth, col); - - total += ecol->width; - - if ((total - TOLERANCE < pos ) && (pos < total + TOLERANCE)){ - if (return_col) - *return_col = col; - if (the_total) - *the_total = total; - - return TRUE; - } - - if (total > pos + TOLERANCE) - return FALSE; - } - - return FALSE; -} - -#define convert(c,sx,sy,x,y) gnome_canvas_w2c (c,sx,sy,x,y) - -static void -set_cursor (ETableHeaderItem *ethi, int pos) -{ - GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (ethi)->canvas); - - /* We might be invoked before we are realized */ - if (!canvas->window) - return; - - if (is_pointer_on_division (ethi, pos, NULL, NULL)) - e_cursor_set (canvas->window, E_CURSOR_SIZE_X); - else - e_cursor_set (canvas->window, E_CURSOR_ARROW); -} - -static void -ethi_request_redraw (ETableHeaderItem *ethi) -{ - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (ethi)->canvas; - - /* - * request a redraw - */ - gnome_canvas_request_redraw ( - canvas, ethi->x1, ethi->y1, ethi->x1 + ethi->width, ethi->x1 + ethi->height); -} - -static void -ethi_end_resize (ETableHeaderItem *ethi, int new_size) -{ - e_table_header_set_size (ethi->eth, ethi->resize_col, new_size); - - ethi->resize_col = -1; - ethi_request_redraw (ethi); -} - -/* - * Handles the events on the ETableHeaderItem, particularly it handles resizing - */ -static int -ethi_event (GnomeCanvasItem *item, GdkEvent *e) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - GnomeCanvas *canvas = item->canvas; - const gboolean resizing = ETHI_RESIZING (ethi); - int x, y, start, col; - - switch (e->type){ - case GDK_ENTER_NOTIFY: - convert (canvas, e->crossing.x, e->crossing.y, &x, &y); - set_cursor (ethi, x); - break; - - case GDK_LEAVE_NOTIFY: - e_cursor_set (GTK_WIDGET (canvas)->window, E_CURSOR_ARROW); - break; - - case GDK_MOTION_NOTIFY: - convert (canvas, e->motion.x, e->motion.y, &x, &y); - if (resizing){ - int new_width; - - if (ethi->resize_guide == NULL){ - /* Quick hack until I actually bind the views */ - ethi->resize_guide = GINT_TO_POINTER (1); - gnome_canvas_item_grab (item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK, - e_cursor_get (E_CURSOR_SIZE_X), - e->button.time); - } - - new_width = x - ethi->resize_start_pos; - if (new_width <= 0) - break; - - if (new_width < ethi->resize_min_width) - break; - - ethi_request_redraw (ethi); - - ethi->resize_width = new_width; - e_table_header_set_size (ethi->eth, ethi->resize_col, ethi->resize_width); - - ethi_request_redraw (ethi); - } else - set_cursor (ethi, x); - break; - - case GDK_BUTTON_PRESS: - convert (canvas, e->button.x, e->button.y, &x, &y); - - if (is_pointer_on_division (ethi, x, &start, &col)){ - ETableCol *ecol; - - /* - * Record the important bits. - * - * By setting resize_pos to a non -1 value, - * we know that we are being resized (used in the - * other event handlers). - */ - ecol = e_table_header_get_column (ethi->eth, col); - - if (!ecol->resizeable) - break; - ethi->resize_col = col; - ethi->resize_width = ecol->width; - ethi->resize_start_pos = start - ecol->width; - ethi->resize_min_width = ecol->min_width; - } - break; - - case GDK_2BUTTON_PRESS: - if (!resizing) - break; - - if (e->button.button != 1) - break; - - printf ("Resize this guy\n"); - break; - - case GDK_BUTTON_RELEASE: { - gboolean needs_ungrab = FALSE; - - if (ethi->resize_col != -1){ - needs_ungrab = (ethi->resize_guide != NULL); - ethi_end_resize (ethi, ethi->resize_width); - } - if (needs_ungrab) - gnome_canvas_item_ungrab (item, e->button.time); - - break; - } - - default: - return FALSE; - } - return TRUE; -} - -static void -ethi_class_init (GtkObjectClass *object_class) -{ - GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class; - - ethi_parent_class = gtk_type_class (PARENT_OBJECT_TYPE); - - object_class->destroy = ethi_destroy; - object_class->set_arg = ethi_set_arg; - - item_class->update = ethi_update; - item_class->realize = ethi_realize; - item_class->unrealize = ethi_unrealize; - item_class->draw = ethi_draw; - item_class->point = ethi_point; - item_class->event = ethi_event; - - gtk_object_add_arg_type ("ETableHeaderItem::ETableHeader", GTK_TYPE_POINTER, - GTK_ARG_WRITABLE, ARG_TABLE_HEADER); - gtk_object_add_arg_type ("ETableHeaderItem::x", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_TABLE_X); - gtk_object_add_arg_type ("ETableHeaderItem::y", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_TABLE_Y); - gtk_object_add_arg_type ("ETableHeaderItem::fontset", GTK_TYPE_STRING, - GTK_ARG_WRITABLE, ARG_TABLE_FONTSET); -} - -static void -ethi_init (GnomeCanvasItem *item) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - - ethi->resize_col = -1; - - item->x1 = 0; - item->y1 = 0; - item->x2 = 0; - item->y2 = 0; -} - -GtkType -e_table_header_item_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableHeaderItem", - sizeof (ETableHeaderItem), - sizeof (ETableHeaderItemClass), - (GtkClassInitFunc) ethi_class_init, - (GtkObjectInitFunc) ethi_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_OBJECT_TYPE, &info); - } - - return type; -} - diff --git a/widgets/e-table/e-table-header-item.h b/widgets/e-table/e-table-header-item.h deleted file mode 100644 index ea2082018f..0000000000 --- a/widgets/e-table/e-table-header-item.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _E_TABLE_HEADER_ITEM_H_ -#define _E_TABLE_HEADER_ITEM_H_ - -#include <libgnomeui/gnome-canvas.h> -#include "e-table-header.h" - -#define E_TABLE_HEADER_ITEM_TYPE (e_table_header_item_get_type ()) -#define E_TABLE_HEADER_ITEM(o) (GTK_CHECK_CAST ((o), E_TABLE_HEADER_ITEM_TYPE, ETableHeaderItem)) -#define E_TABLE_HEADER_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_HEADER_ITEM_TYPE, ETableHeaderItemClass)) -#define E_IS_TABLE_HEADER_ITEM(o) (GTK_CHECK_TYPE ((o), E_TABLE_HEADER_ITEM_TYPE)) -#define E_IS_TABLE_HEADER_ITEM_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_HEADER_ITEM_TYPE)) - -typedef struct { - GnomeCanvasItem parent; - ETableHeader *eth; - - GdkGC *gc; - GdkCursor *change_cursor, *normal_cursor; - - short x1, y1, height, width; - GdkFont *font; - - /* - * Used during resizing; Could be shorts - */ - int resize_col; - int resize_width; - int resize_start_pos; - int resize_min_width; - - GtkObject *resize_guide; - - /* - * Ids - */ - int structure_change_id, dimension_change_id; -} ETableHeaderItem; - -typedef struct { - GnomeCanvasItemClass parent_class; -} ETableHeaderItemClass; - -GtkType e_table_header_item_get_type (void); - -#endif /* _E_TABLE_HEADER_ITEM_H_ */ diff --git a/widgets/e-table/e-table-header.c b/widgets/e-table/e-table-header.c deleted file mode 100644 index e91113bbb9..0000000000 --- a/widgets/e-table/e-table-header.c +++ /dev/null @@ -1,325 +0,0 @@ -/* - * E-table-col-head.c: TableColHead implementation - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkobject.h> -#include <gtk/gtksignal.h> -#include "e-table-header.h" - -enum { - STRUCTURE_CHANGE, - DIMENSION_CHANGE, - LAST_SIGNAL -}; - -static guint eth_signals [LAST_SIGNAL] = { 0, }; - -static GtkObjectClass *e_table_header_parent_class; - -static void -e_table_header_destroy (GtkObject *object) -{ - ETableHeader *eth = E_TABLE_HEADER (object); - const int cols = eth->col_count; - int i; - - /* - * Destroy columns - */ - for (i = 0; i < cols; i++){ - e_table_header_remove (eth, i); - } - - if (e_table_header_parent_class->destroy) - e_table_header_parent_class->destroy (object); -} - -static void -e_table_header_class_init (GtkObjectClass *object_class) -{ - object_class->destroy = e_table_header_destroy; - - e_table_header_parent_class = (gtk_type_class (gtk_object_get_type ())); - - eth_signals [STRUCTURE_CHANGE] = - gtk_signal_new ("structure_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableHeaderClass, structure_change), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - eth_signals [DIMENSION_CHANGE] = - gtk_signal_new ("dimension_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableHeaderClass, dimension_change), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, eth_signals, LAST_SIGNAL); -} - -GtkType -e_table_header_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableHeader", - sizeof (ETableHeader), - sizeof (ETableHeaderClass), - (GtkClassInitFunc) e_table_header_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - -ETableHeader * -e_table_header_new (void) -{ - ETableHeader *eth; - - eth = gtk_type_new (e_table_header_get_type ()); - - return eth; -} - -static void -eth_do_insert (ETableHeader *eth, int pos, ETableCol *val) -{ - memcpy (ð->columns [pos+1], ð->columns [pos], - sizeof (ETableCol *) * (eth->col_count - pos)); - eth->columns [pos] = val; -} - -static void -eth_update_offsets (ETableHeader *eth) -{ - int i; - int x = 0; - - for (i = 0; i < eth->col_count; i++){ - ETableCol *etc = eth->columns [i]; - - etc->x = x; - x += etc->width; - } -} - -void -e_table_header_add_column (ETableHeader *eth, ETableCol *tc, int pos) -{ - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (tc != NULL); - g_return_if_fail (E_IS_TABLE_COL (tc)); - g_return_if_fail (pos >= 0 && pos <= eth->col_count); - - if (pos == -1) - pos = eth->col_count; - eth->columns = g_realloc (eth->columns, sizeof (ETableCol *) * (eth->col_count + 1)); - - /* - * We are the primary owners of the column - */ - gtk_object_ref (GTK_OBJECT (tc)); - gtk_object_sink (GTK_OBJECT (tc)); - - eth_do_insert (eth, pos, tc); - eth->col_count++; - eth_update_offsets (eth); - - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); -} - -ETableCol * -e_table_header_get_column (ETableHeader *eth, int column) -{ - g_return_val_if_fail (eth != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), NULL); - - if (column < 0) - return NULL; - - if (column >= eth->col_count) - return NULL; - - return eth->columns [column]; -} - -int -e_table_header_count (ETableHeader *eth) -{ - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - return eth->col_count; -} - -int -e_table_header_index (ETableHeader *eth, const char *identifier) -{ - int i; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - g_return_val_if_fail (identifier != NULL, 0); - - for (i = 0; i < eth->col_count; i++){ - ETableCol *tc = eth->columns [i]; - - if (strcmp (tc->id, identifier) == 0) - return i; - } - - return -1; -} - -int -e_table_header_get_index_at (ETableHeader *eth, int x_offset) -{ - int i, total; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - total = 0; - for (i = 0; i < eth->col_count; i++){ - total += eth->columns [i]->width; - - if (x_offset < total) - return i; - } - - return -1; -} - -ETableCol ** -e_table_header_get_columns (ETableHeader *eth) -{ - ETableCol **ret; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - ret = g_new (ETableCol *, eth->col_count + 1); - memcpy (ret, eth->columns, sizeof (ETableCol *) * eth->col_count); - ret [eth->col_count] = NULL; - - return ret; -} - -gboolean -e_table_header_selection_ok (ETableHeader *eth) -{ - g_return_val_if_fail (eth != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), FALSE); - - return eth->selectable; -} - -int -e_table_header_get_selected (ETableHeader *eth) -{ - int i; - int selected = 0; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - for (i = 0; i < eth->col_count; i++){ - if (eth->columns [i]->selected) - selected++; - } - - return selected; -} - -int -e_table_header_total_width (ETableHeader *eth) -{ - int total, i; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - total = 0; - for (i = 0; i < eth->col_count; i++) - total += eth->columns [i]->width; - - return total; -} - -static void -eth_do_remove (ETableHeader *eth, int idx, gboolean do_unref) -{ - if (do_unref) - gtk_object_unref (GTK_OBJECT (eth->columns [idx])); - - memcpy (ð->columns [idx], ð->columns [idx+1], - sizeof (ETableCol *) * eth->col_count - idx); - eth->col_count--; -} - -void -e_table_header_move (ETableHeader *eth, int source_index, int target_index) -{ - ETableCol *old; - - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (source_index >= 0); - g_return_if_fail (target_index >= 0); - g_return_if_fail (source_index < eth->col_count); - g_return_if_fail (target_index < eth->col_count); - - old = eth->columns [source_index]; - eth_do_remove (eth, source_index, FALSE); - eth_do_insert (eth, target_index, old); - eth_update_offsets (eth); - - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); -} - -void -e_table_header_remove (ETableHeader *eth, int idx) -{ - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < eth->col_count); - - eth_do_remove (eth, idx, TRUE); - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); -} - -void -e_table_header_set_selection (ETableHeader *eth, gboolean allow_selection) -{ -} - -void -e_table_header_set_size (ETableHeader *eth, int idx, int size) -{ - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < eth->col_count); - g_return_if_fail (size > 0); - - eth->columns [idx]->width = size; - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE], idx); -} diff --git a/widgets/e-table/e-table-header.h b/widgets/e-table/e-table-header.h deleted file mode 100644 index c263c36ad3..0000000000 --- a/widgets/e-table/e-table-header.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _E_TABLE_COLUMN_H_ -#define _E_TABLE_COLUMN_H_ - -#include <gtk/gtkobject.h> -#include <gdk/gdk.h> -#include "e-table-col.h" - -typedef struct _ETableHeader ETableHeader; - -#define E_TABLE_HEADER_TYPE (e_table_header_get_type ()) -#define E_TABLE_HEADER(o) (GTK_CHECK_CAST ((o), E_TABLE_HEADER_TYPE, ETableHeader)) -#define E_TABLE_HEADER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_HEADER_TYPE, ETableHeaderClass)) -#define E_IS_TABLE_HEADER(o) (GTK_CHECK_TYPE ((o), E_TABLE_HEADER_TYPE)) -#define E_IS_TABLE_HEADER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_HEADER_TYPE)) - -/* - * A Columnar header. - */ -struct _ETableHeader { - GtkObject base; - - int col_count; - ETableCol **columns; - gboolean selectable; -}; - -typedef struct { - GtkObjectClass parent_class; - - void (*structure_change) (ETableHeader *eth); - void (*dimension_change) (ETableHeader *eth, int col); -} ETableHeaderClass; - -GtkType e_table_header_get_type (void); -ETableHeader *e_table_header_new (void); - -void e_table_header_add_column (ETableHeader *eth, - ETableCol *tc, int pos); -ETableCol * e_table_header_get_column (ETableHeader *eth, - int column); -int e_table_header_count (ETableHeader *eth); -int e_table_header_index (ETableHeader *eth, - const char *identifier); -int e_table_header_get_index_at (ETableHeader *eth, - int x_offset); -ETableCol **e_table_header_get_columns (ETableHeader *eth); -gboolean e_table_header_selection_ok (ETableHeader *eth); -int e_table_header_get_selected (ETableHeader *eth); -int e_table_header_total_width (ETableHeader *eth); -void e_table_header_move (ETableHeader *eth, - int source_index, - int target_index); -void e_table_header_remove (ETableHeader *eth, int idx); -void e_table_header_set_size (ETableHeader *eth, int idx, int size); -void e_table_header_set_selection (ETableHeader *eth, - gboolean allow_selection); - -GList *e_table_header_get_selected_indexes(ETableHeader *eth); - - -#endif /* _E_TABLE_HEADER_H_ */ - diff --git a/widgets/e-table/e-table-item.c b/widgets/e-table/e-table-item.c deleted file mode 100644 index ceb6adda95..0000000000 --- a/widgets/e-table/e-table-item.c +++ /dev/null @@ -1,1151 +0,0 @@ -/* - * E-table-item.c: A GnomeCanvasItem that is a view of an ETableModel. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc. - * - * TODO: - * Add a border to the thing, so that focusing works properly. - * - */ -#include <config.h> -#include <stdio.h> -#include <gtk/gtksignal.h> -#include <gdk/gdkkeysyms.h> -#include "e-table-item.h" -#include "e-cell.h" - -#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type () - -#define FOCUSED_BORDER 2 - -static GnomeCanvasItemClass *eti_parent_class; - -enum { - ROW_SELECTION, - LAST_SIGNAL -}; - -static gint eti_signals [LAST_SIGNAL] = { 0, }; - -enum { - ARG_0, - ARG_TABLE_HEADER, - ARG_TABLE_MODEL, - ARG_TABLE_X, - ARG_TABLE_Y, - ARG_TABLE_DRAW_GRID, - ARG_TABLE_DRAW_FOCUS, - ARG_MODE_SPREADSHEET, - ARG_LENGHT_THRESHOLD -}; - -static gboolean -eti_editing (ETableItem *eti) -{ - if (eti->editing_col == -1) - return FALSE; - else - return TRUE; -} - -/* - * During realization, we have to invoke the per-ecell realize routine - * (On our current setup, we have one e-cell per column. - * - * We might want to optimize this to only realize the unique e-cells: - * ie, a strings-only table, uses the same e-cell for every column, and - * we might want to avoid realizing each e-cell. - */ -static void -eti_realize_cell_views (ETableItem *eti) -{ - int i; - - /* - * Now realize the various ECells - */ - eti->n_cells = eti->cols; - eti->cell_views = g_new (ECellView *, eti->n_cells); - - for (i = 0; i < eti->n_cells; i++){ - ETableCol *col = e_table_header_get_column (eti->header, i); - - eti->cell_views [i] = e_cell_realize (col->ecell, eti); - } -} - -/* - * During unrealization: we invoke every e-cell (one per column in the current - * setup) to dispose all resources allocated - */ -static void -eti_unrealize_cell_views (ETableItem *eti) -{ - int i; - - for (i = 0; i < eti->n_cells; i++){ - e_cell_unrealize (eti->cell_views [i]); - eti->cell_views [i] = NULL; - } - g_free (eti->cell_views); - eti->n_cells = 0; - -} - -/* - * GnomeCanvasItem::update method - */ -static void -eti_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) -{ - ETableItem *eti = E_TABLE_ITEM (item); - - if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update) - (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)(item, affine, clip_path, flags); - - item->x1 = eti->x1; - item->y1 = eti->y1; - item->x2 = eti->x1 + eti->width; - item->y2 = eti->y1 + eti->height; - - gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item); -} - -/* - * eti_remove_table_model: - * - * Invoked to release the table model associated with this ETableItem - */ -static void -eti_remove_table_model (ETableItem *eti) -{ - if (!eti->table_model) - return; - - gtk_signal_disconnect (GTK_OBJECT (eti->table_model), - eti->table_model_change_id); - gtk_object_unref (GTK_OBJECT (eti->table_model)); - - eti->table_model_change_id = 0; - eti->table_model = NULL; -} - -/* - * eti_remove_header_model: - * - * Invoked to release the header model associated with this ETableItem - */ -static void -eti_remove_header_model (ETableItem *eti) -{ - if (!eti->header) - return; - - gtk_signal_disconnect (GTK_OBJECT (eti->header), - eti->header_structure_change_id); - gtk_signal_disconnect (GTK_OBJECT (eti->header), - eti->header_dim_change_id); - gtk_object_unref (GTK_OBJECT (eti->header)); - - eti->header_structure_change_id = 0; - eti->header_dim_change_id = 0; - eti->header = NULL; -} - -/* - * eti_row_height: - * - * Returns the height used by row @row. This does not include the one-pixel - * used as a separator between rows - */ -static int -eti_row_height (ETableItem *eti, int row) -{ - const int cols = e_table_header_count (eti->header); - int col; - int h, max_h; - - max_h = 0; - - for (col = 0; col < cols; col++){ - h = e_cell_height (eti->cell_views [col], col, row); - - if (h > max_h) - max_h = h; - } - return max_h; -} - -/* - * eti_get_height: - * - * Returns the height of the ETableItem. - * - * The ETableItem might compute the whole height by asking every row its - * size. There is a special mode (designed to work when there are too - * many rows in the table that performing the previous step could take - * too long) set by the ETableItem->length_threshold that would determine - * when the height is computed by using the first row as the size for - * every other row in the ETableItem. - */ -static int -eti_get_height (ETableItem *eti) -{ - const int rows = eti->rows; - int row; - int height; - - if (rows == 0) - return 0; - - if (eti->length_threshold != -1){ - if (rows > eti->length_threshold){ - height = (eti_row_height (eti, 0) + 1) * rows; - - /* - * 1 pixel at the top - */ - return height + 1; - } - } - - height = 1; - for (row = 0; row < rows; row++) - height += eti_row_height (eti, row) + 1; - - return height; -} - -/* - * Callback routine: invoked when the ETableModel has suffered a change - */ -static void -eti_table_model_changed (ETableModel *table_model, ETableItem *eti) -{ - eti->cols = e_table_model_column_count (eti->table_model); - eti->rows = e_table_model_row_count (eti->table_model); - - if (eti->cell_views) - eti->height = eti_get_height (eti); - - eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0); -} - -/* - * eti_request_redraw: - * - * Queues a canvas redraw for the entire ETableItem. - */ -static void -eti_request_redraw (ETableItem *eti) -{ - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - - gnome_canvas_request_redraw (canvas, eti->x1, eti->y1, - eti->x1 + eti->width + 1, - eti->y1 + eti->height + 1); -} - -/* - * Computes the distance from @start_col to @end_col in pixels. - */ -static int -eti_col_diff (ETableItem *eti, int start_col, int end_col) -{ - int col, total; - - total = 0; - for (col = start_col; col < end_col; col++){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - total += ecol->width; - } - - return total; -} - -/* - * Computes the distance between @start_row and @end_row in pixels - */ -static int -eti_row_diff (ETableItem *eti, int start_row, int end_row) -{ - int row, total; - - total = 0; - - for (row = start_row; row < end_row; row++) - total += eti_row_height (eti, row) + 1; - - return total; -} - -/* - * eti_request_region_redraw: - * - * Request a canvas redraw on the range (start_col, start_row) to (end_col, end_row). - * This is inclusive (ie, you can use: 0,0-0,0 to redraw the first cell). - * - * The @border argument is a number of pixels around the region that should also be queued - * for redraw. This is typically used by the focus routines to queue a redraw for the - * border as well. - */ -static void -eti_request_region_redraw (ETableItem *eti, - int start_col, int start_row, - int end_col, int end_row, int border) -{ - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - int x1, y1, width, height; - - x1 = eti_col_diff (eti, 0, start_col); - y1 = eti_row_diff (eti, 0, start_row); - width = eti_col_diff (eti, start_col, end_col + 1); - height = eti_row_diff (eti, start_row, end_row + 1); - - gnome_canvas_request_redraw (canvas, - eti->x1 + x1 - border, - eti->y1 + y1 - border, - eti->x1 + x1 + width + 1 + border, - eti->y1 + y1 + height + 1 + border); -} - -void -e_table_item_redraw_range (ETableItem *eti, - int start_col, int start_row, - int end_col, int end_row) -{ - int border; - - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if ((start_col == eti->focused_col) || - (end_col == eti->focused_col) || - (start_row == eti->focused_row) || - (end_row == eti->focused_row)) - border = 2; - else - border = 0; - - eti_request_region_redraw (eti, start_col, start_row, end_col, end_row, border); -} - -static void -eti_add_table_model (ETableItem *eti, ETableModel *table_model) -{ - g_assert (eti->table_model == NULL); - - eti->table_model = table_model; - gtk_object_ref (GTK_OBJECT (eti->table_model)); - - eti->table_model_change_id = gtk_signal_connect ( - GTK_OBJECT (table_model), "model_changed", - GTK_SIGNAL_FUNC (eti_table_model_changed), eti); - eti_table_model_changed (table_model, eti); -} - -static void -eti_header_dim_changed (ETableHeader *eth, int col, ETableItem *eti) -{ - eti_request_redraw (eti); - - eti->width = e_table_header_total_width (eti->header); - eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0); - - eti_request_redraw (eti); -} - -static void -eti_header_structure_changed (ETableHeader *eth, ETableItem *eti) -{ - eti_request_redraw (eti); - - eti->width = e_table_header_total_width (eti->header); - eti_unrealize_cell_views (eti); - eti_realize_cell_views (eti); - eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0); - - eti_request_redraw (eti); -} - -static void -eti_add_header_model (ETableItem *eti, ETableHeader *header) -{ - g_assert (eti->header == NULL); - - eti->header = header; - gtk_object_ref (GTK_OBJECT (header)); - - eti->width = e_table_header_total_width (header); - - eti->header_dim_change_id = gtk_signal_connect ( - GTK_OBJECT (header), "dimension_change", - GTK_SIGNAL_FUNC (eti_header_dim_changed), eti); - - eti->header_structure_change_id = gtk_signal_connect ( - GTK_OBJECT (header), "structure_change", - GTK_SIGNAL_FUNC (eti_header_structure_changed), eti); -} - -/* - * GtkObject::destroy method - */ -static void -eti_destroy (GtkObject *object) -{ - ETableItem *eti = E_TABLE_ITEM (object); - - eti_remove_header_model (eti); - eti_remove_table_model (eti); - - g_slist_free (eti->selection); - - if (GTK_OBJECT_CLASS (eti_parent_class)->destroy) - (*GTK_OBJECT_CLASS (eti_parent_class)->destroy) (object); -} - -static void -eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ETableItem *eti; - - item = GNOME_CANVAS_ITEM (o); - eti = E_TABLE_ITEM (o); - - switch (arg_id){ - case ARG_TABLE_HEADER: - eti_remove_header_model (eti); - eti_add_header_model (eti, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_TABLE_MODEL: - eti_remove_table_model (eti); - eti_add_table_model (eti, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_TABLE_X: - eti->x1 = GTK_VALUE_INT (*arg); - break; - - case ARG_TABLE_Y: - eti->y1 = GTK_VALUE_INT (*arg); - break; - - case ARG_LENGHT_THRESHOLD: - eti->length_threshold = GTK_VALUE_INT (*arg); - break; - - case ARG_TABLE_DRAW_GRID: - eti->draw_grid = GTK_VALUE_BOOL (*arg); - break; - - case ARG_TABLE_DRAW_FOCUS: - eti->draw_focus = GTK_VALUE_BOOL (*arg); - break; - - case ARG_MODE_SPREADSHEET: - eti->mode_spreadsheet = GTK_VALUE_BOOL (*arg); - break; - } - eti_update (item, NULL, NULL, 0); -} - -static void -eti_init (GnomeCanvasItem *item) -{ - ETableItem *eti = E_TABLE_ITEM (item); - - eti->focused_col = -1; - eti->focused_row = -1; - eti->editing_col = -1; - eti->editing_row = -1; - eti->height = 0; - - eti->length_threshold = -1; - - eti->selection_mode = GTK_SELECTION_SINGLE; -} - -#define gray50_width 2 -#define gray50_height 2 -static const char gray50_bits[] = { - 0x02, 0x01, }; - -static void -eti_realize (GnomeCanvasItem *item) -{ - ETableItem *eti = E_TABLE_ITEM (item); - GtkWidget *canvas_widget = GTK_WIDGET (item->canvas); - GdkWindow *window; - - if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize) - (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize)(item); - - /* - * Gdk Resource allocation - */ - window = canvas_widget->window; - - eti->fill_gc = canvas_widget->style->white_gc; - gdk_gc_ref (canvas_widget->style->white_gc); - - eti->grid_gc = gdk_gc_new (window); -#if 0 - /* This sets it to gray */ -/* gdk_gc_set_foreground (eti->grid_gc, &canvas_widget->style->bg [GTK_STATE_NORMAL]); */ -#else - gdk_gc_set_foreground (eti->grid_gc, &canvas_widget->style->black); -#endif - eti->focus_gc = gdk_gc_new (window); - gdk_gc_set_foreground (eti->focus_gc, &canvas_widget->style->bg [GTK_STATE_NORMAL]); - gdk_gc_set_background (eti->focus_gc, &canvas_widget->style->fg [GTK_STATE_NORMAL]); - eti->stipple = gdk_bitmap_create_from_data (NULL, gray50_bits, gray50_width, gray50_height); - gdk_gc_set_ts_origin (eti->focus_gc, 0, 0); - gdk_gc_set_stipple (eti->focus_gc, eti->stipple); - gdk_gc_set_fill (eti->focus_gc, GDK_OPAQUE_STIPPLED); - - /* - * - */ - eti_realize_cell_views (eti); - - eti->height = eti_get_height (eti); - eti_update (item, NULL, NULL, 0); -} - -static void -eti_unrealize (GnomeCanvasItem *item) -{ - ETableItem *eti = E_TABLE_ITEM (item); - - gdk_gc_unref (eti->fill_gc); - eti->fill_gc = NULL; - gdk_gc_unref (eti->grid_gc); - eti->grid_gc = NULL; - gdk_gc_unref (eti->focus_gc); - eti->focus_gc = NULL; - gdk_bitmap_unref (eti->stipple); - eti->stipple = NULL; - - eti_unrealize_cell_views (eti); - - eti->height = 0; - - if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->unrealize) - (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->unrealize)(item); -} - -static void -draw_cell (ETableItem *eti, GdkDrawable *drawable, int col, int row, gboolean selected, - int x1, int y1, int x2, int y2) -{ - ECellView *ecell_view; - - ecell_view = eti->cell_views [col]; - - e_cell_draw (ecell_view, drawable, col, row, selected, x1, y1, x2, y2); - -#if 0 - { - GdkFont *font; - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - - font = GTK_WIDGET (canvas)->style->font; - - sprintf (text, "%d:%d\n", col, row); gdk_draw_line (drawable, eti->grid_gc, x1, y1, x2, y2); - gdk_draw_line (drawable, eti->grid_gc, x1, y2, x2, y1); - - sprintf (text, "%d:%d\n", col, row); - gdk_draw_text (drawable, font, eti->grid_gc, x1, y2, text, strlen (text)); - } -#endif -} - -static void -eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height) -{ - ETableItem *eti = E_TABLE_ITEM (item); - const int rows = eti->rows; - const int cols = eti->cols; - int row, col, y1, y2; - int first_col, last_col, x_offset; - int first_row, last_row, y_offset, yd; - int x1, x2; - int f_x1, f_x2, f_y1, f_y2; - gboolean f_found; - -/* printf ("Rect: %d %d %d %d\n", x, y, width, height); */ - /* - * Clear the background - */ -#if 0 - gdk_draw_rectangle ( - drawable, eti->fill_gc, TRUE, - eti->x1 - x, eti->y1 - y, eti->width, eti->height); -#endif - - /* - * First column to draw, last column to draw - */ - first_col = -1; - last_col = x_offset = 0; - x1 = x2 = eti->x1; - for (col = 0; col < cols; col++, x1 = x2){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - x2 = x1 + ecol->width; - - if (x1 > (x + width)) - break; - if (x2 < x) - continue; - if (first_col == -1){ - x_offset = x1 - x; - first_col = col; - } - } - last_col = col; - - /* - * Nothing to paint - */ - if (first_col == -1) - return; - - /* - * Compute row span. - */ - first_row = -1; - y_offset = 0; - y1 = y2 = eti->y1 + 1; - for (row = 0; row < rows; row++, y1 = y2){ - - y2 += eti_row_height (eti, row) + 1; - - if (y1 > y + height) - break; - - if (y2 < y) - continue; - - if (first_row == -1){ - y_offset = y1 - y; - first_row = row; - } - } - last_row = row; - - if (first_row == -1) - return; - - /* - * Draw cells - */ - yd = y_offset; - f_x1 = f_x2 = f_y1 = f_y2 = -1; - f_found = FALSE; - - if (eti->draw_grid && first_row == 0){ - gdk_draw_line ( - drawable, eti->grid_gc, - eti->x1 - x, yd, eti->x1 + eti->width - x, yd); - } - yd++; - - for (row = first_row; row < last_row; row++){ - int xd, height; - gboolean selected; - - height = eti_row_height (eti, row); - - xd = x_offset; -/* printf ("paint: %d %d\n", yd, yd + height); */ - - selected = g_slist_find (eti->selection, GINT_TO_POINTER (row)) != NULL; - - for (col = first_col; col < last_col; col++){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - draw_cell (eti, drawable, col, row, selected, xd, yd, xd + ecol->width, yd + height); - - if (col == eti->focused_col && row == eti->focused_row){ - f_x1 = xd; - f_x2 = xd + ecol->width; - f_y1 = yd; - f_y2 = yd + height; - f_found = TRUE; - } - - xd += ecol->width; - } - yd += height; - - if (eti->draw_grid) - gdk_draw_line ( - drawable, eti->grid_gc, - eti->x1 - x, yd, eti->x1 + eti->width - x, yd); - yd++; - } - - if (eti->draw_grid){ - int xd = x_offset; - - for (col = first_col; col <= last_col; col++){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - gdk_draw_line ( - drawable, eti->grid_gc, - xd, y_offset, xd, yd - 1); - - /* - * This looks wierd, but it is to draw the last line - */ - if (ecol) - xd += ecol->width; - } - } - - /* - * Draw focus - */ - if (f_found && eti->draw_focus){ - - if (!eti_editing (eti)) - gdk_draw_rectangle ( - drawable, eti->focus_gc, FALSE, - f_x1 + 1, f_y1, f_x2 - f_x1 - 2, f_y2 - f_y1 - 1); - } -} - -static double -eti_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - - return 0.0; -} - -static gboolean -find_cell (ETableItem *eti, double x, double y, int *col_res, int *row_res, gdouble *x1_res, gdouble *y1_res) -{ - const int cols = eti->cols; - const int rows = eti->rows; - gdouble x1, y1, x2, y2; - int col, row; - - /* FIXME: this routine is inneficient, fix later */ - - x -= eti->x1; - y -= eti->y1; - - x1 = 0; - for (col = 0; col < cols; col++, x1 = x2){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - if (x < x1) - return FALSE; - - x2 = x1 + ecol->width; - - if (x > x2) - continue; - - *col_res = col; - if (x1_res) - *x1_res = x - x1; - break; - } - - y1 = y2 = 0; - for (row = 0; row < rows; row++, y1 = y2){ - if (y < y1) - return FALSE; - - y2 += eti_row_height (eti, row) + 1; - - if (y > y2) - continue; - - *row_res = row; - if (y1_res) - *y1_res = y - y1; - break; - } - - return TRUE; -} - -static int -eti_event (GnomeCanvasItem *item, GdkEvent *e) -{ - ETableItem *eti = E_TABLE_ITEM (item); - ECellView *ecell_view; - - switch (e->type){ - case GDK_BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - case GDK_2BUTTON_PRESS: { - int col, row; - gdouble x1, y1; - - if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1)) - return TRUE; - - if (eti->focused_row == row && eti->focused_col == col){ - ecell_view = eti->cell_views [col]; - - /* - * Adjust the event positions - */ - e->button.x = x1; - e->button.y = y1; - - e_cell_event (ecell_view, e, col, row); - } else { - /* - * Focus the cell, and select the row - */ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, col, row); - e_table_item_select_row (eti, row); - } - break; - } - - case GDK_MOTION_NOTIFY: { - int col, row; - double x1, y1; - - if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1)) - return TRUE; - - if (eti->focused_row == row && eti->focused_col == col){ - ecell_view = eti->cell_views [col]; - - /* - * Adjust the event positions - */ - e->button.x -= (x1 + eti->x1); - e->button.y -= (y1 + eti->y1); - - e_cell_event (ecell_view, e, col, row); - } - break; - } - - case GDK_KEY_PRESS: - if (eti->focused_col == -1) - return FALSE; - - switch (e->key.keyval){ - case GDK_Left: - if (!eti->mode_spreadsheet && eti_editing (eti)) - break; - - if (eti->focused_col > 0){ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, eti->focused_col - 1, eti->focused_row); - } - return TRUE; - - case GDK_Right: - if (!eti->mode_spreadsheet && eti_editing (eti)) - break; - - if ((eti->focused_col + 1) < eti->cols){ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, eti->focused_col + 1, eti->focused_row); - } - return TRUE; - - case GDK_Up: - if (eti->focused_row > 0){ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, eti->focused_col, eti->focused_row - 1); - } - return TRUE; - - case GDK_Down: - if ((eti->focused_row + 1) < eti->rows){ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, eti->focused_col, eti->focused_row + 1); - } - return TRUE; - default: - if (!eti_editing (eti)){ - if ((e->key.state & (GDK_MOD1_MASK | GDK_CONTROL_MASK)) != 0) - return 0; - - if (!(e->key.keyval >= 0x20 && e->key.keyval <= 0xff)) - return 0; - } - } - - ecell_view = eti->cell_views [eti->focused_col]; - e_cell_event (ecell_view, e, eti->focused_col, eti->focused_row); - break; - - case GDK_KEY_RELEASE: - if (eti->focused_col == -1) - return FALSE; - - if (eti_editing (eti)){ - ecell_view = eti->cell_views [eti->editing_col]; - e_cell_event (ecell_view, e, eti->editing_col, eti->editing_row); - } - break; - - default: - return FALSE; - } - return TRUE; -} - -/* - * ETableItem::row_selection method - */ -static void -eti_row_selection (ETableItem *eti, int row, gboolean selected) -{ - eti_request_region_redraw (eti, 0, row, eti->cols - 1, row, 0); - - if (selected) - eti->selection = g_slist_prepend (eti->selection, GINT_TO_POINTER (row)); - else - eti->selection = g_slist_remove (eti->selection, GINT_TO_POINTER (row)); - -} - -static void -eti_class_init (GtkObjectClass *object_class) -{ - GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class; - ETableItemClass *eti_class = (ETableItemClass *) object_class; - - eti_parent_class = gtk_type_class (PARENT_OBJECT_TYPE); - - object_class->destroy = eti_destroy; - object_class->set_arg = eti_set_arg; - - item_class->update = eti_update; - item_class->realize = eti_realize; - item_class->unrealize = eti_unrealize; - item_class->draw = eti_draw; - item_class->point = eti_point; - item_class->event = eti_event; - - eti_class->row_selection = eti_row_selection; - - gtk_object_add_arg_type ("ETableItem::ETableHeader", GTK_TYPE_POINTER, - GTK_ARG_WRITABLE, ARG_TABLE_HEADER); - gtk_object_add_arg_type ("ETableItem::ETableModel", GTK_TYPE_POINTER, - GTK_ARG_WRITABLE, ARG_TABLE_MODEL); - gtk_object_add_arg_type ("ETableItem::x", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_TABLE_X); - gtk_object_add_arg_type ("ETableItem::y", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_TABLE_Y); - gtk_object_add_arg_type ("ETableItem::drawgrid", GTK_TYPE_BOOL, - GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID); - gtk_object_add_arg_type ("ETableItem::drawfocus", GTK_TYPE_BOOL, - GTK_ARG_WRITABLE, ARG_TABLE_DRAW_FOCUS); - gtk_object_add_arg_type ("ETableItem::spreadsheet", GTK_TYPE_BOOL, - GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET); - - eti_signals [ROW_SELECTION] = - gtk_signal_new ("row_selection", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableItemClass, row_selection), - gtk_marshal_NONE__INT_INT, - GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, eti_signals, LAST_SIGNAL); - -} - -GtkType -e_table_item_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableItem", - sizeof (ETableItem), - sizeof (ETableItemClass), - (GtkClassInitFunc) eti_class_init, - (GtkObjectInitFunc) eti_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_OBJECT_TYPE, &info); - } - - return type; -} - -void -e_table_item_focus (ETableItem *eti, int col, int row) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (eti->focused_col != -1) - e_table_item_unfocus (eti); - - eti->focused_col = col; - eti->focused_row = row; - - eti_request_region_redraw (eti, col, row, col, row, FOCUSED_BORDER); - - /* - * make sure we have the Gtk Focus - */ - gtk_widget_grab_focus (GTK_WIDGET (GNOME_CANVAS_ITEM (eti)->canvas)); -} - -void -e_table_item_unfocus (ETableItem *eti) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (eti->focused_row == -1) - return; - - { - const int col = eti->focused_col; - const int row = eti->focused_row; - - eti_request_region_redraw (eti, col, row, col, row, FOCUSED_BORDER); - } - eti->focused_col = -1; - eti->focused_row = -1; -} - -const GSList * -e_table_item_get_selection (ETableItem *eti) -{ - g_return_val_if_fail (eti != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_ITEM (eti), NULL); - - return eti->selection; -} - -GtkSelectionMode -e_table_item_get_selection_mode (ETableItem *eti) -{ - g_return_val_if_fail (eti != NULL, GTK_SELECTION_SINGLE); - g_return_val_if_fail (E_IS_TABLE_ITEM (eti), GTK_SELECTION_SINGLE); - - return eti->selection_mode; -} - -void -e_table_item_set_selection_mode (ETableItem *eti, GtkSelectionMode selection_mode) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (selection_mode == GTK_SELECTION_BROWSE || - selection_mode == GTK_SELECTION_EXTENDED){ - g_error ("GTK_SELECTION_BROWSE and GTK_SELECTION_EXTENDED are not implemented"); - } - - eti->selection_mode = selection_mode; -} - -gboolean -e_table_item_is_row_selected (ETableItem *eti, int row) -{ - g_return_val_if_fail (eti != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_ITEM (eti), FALSE); - - if (g_slist_find (eti->selection, GINT_TO_POINTER (row))) - return TRUE; - else - return FALSE; -} - -void -e_table_item_unselect_row (ETableItem *eti, int row) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (e_table_item_is_row_selected (eti, row)){ - gtk_signal_emit ( - GTK_OBJECT (eti), eti_signals [ROW_SELECTION], - row, 0); - } -} - -void -e_table_item_select_row (ETableItem *eti, int row) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - switch (eti->selection_mode){ - case GTK_SELECTION_SINGLE: - if (eti->selection){ - gtk_signal_emit ( - GTK_OBJECT (eti), eti_signals [ROW_SELECTION], - GPOINTER_TO_INT (eti->selection->data), 0); - } - g_slist_free (eti->selection); - eti->selection = NULL; - - gtk_signal_emit ( - GTK_OBJECT (eti), eti_signals [ROW_SELECTION], - GINT_TO_POINTER (row), 1); - break; - - case GTK_SELECTION_MULTIPLE: - if (g_slist_find (eti->selection, GINT_TO_POINTER (row))) - return; - gtk_signal_emit ( - GTK_OBJECT (eti), eti_signals [ROW_SELECTION], - GINT_TO_POINTER (row), 1); - break; - - default: - - } -} - -void -e_table_item_enter_edit (ETableItem *eti, int col, int row) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - eti->editing_col = col; - eti->editing_row = row; - - eti->edit_ctx = e_cell_enter_edit (eti->cell_views [col], col, row); -} - -void -e_table_item_leave_edit (ETableItem *eti) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (!eti_editing (eti)) - return; - - e_cell_leave_edit (eti->cell_views [eti->editing_col], eti->editing_col, eti->editing_row, eti->edit_ctx); - eti->editing_col = -1; - eti->editing_row = -1; - eti->edit_ctx = NULL; -} - diff --git a/widgets/e-table/e-table-item.h b/widgets/e-table/e-table-item.h deleted file mode 100644 index 6c4d837310..0000000000 --- a/widgets/e-table/e-table-item.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef _E_TABLE_ITEM_H_ -#define _E_TABLE_ITEM_H_ - -#include <libgnomeui/gnome-canvas.h> -#include "e-table-model.h" -#include "e-table-header.h" - -#define E_TABLE_ITEM_TYPE (e_table_item_get_type ()) -#define E_TABLE_ITEM(o) (GTK_CHECK_CAST ((o), E_TABLE_ITEM_TYPE, ETableItem)) -#define E_TABLE_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_ITEM_TYPE, ETableItemClass)) -#define E_IS_TABLE_ITEM(o) (GTK_CHECK_TYPE ((o), E_TABLE_ITEM_TYPE)) -#define E_IS_TABLE_ITEM_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_ITEM_TYPE)) - -typedef struct { - GnomeCanvasItem parent; - ETableModel *table_model; - ETableHeader *header; - - int x1, y1; - int width, height; - - int cols, rows; - - /* - * Ids for the signals we connect to - */ - int header_dim_change_id; - int header_structure_change_id; - int table_model_change_id; - - GdkGC *fill_gc; - GdkGC *grid_gc; - GdkGC *focus_gc; - GdkBitmap *stipple; - - unsigned int draw_grid:1; - unsigned int draw_focus:1; - unsigned int mode_spreadsheet:1; - - int focused_col, focused_row; - - /* - * Realized views, per column - */ - ECellView **cell_views; - int n_cells; - - /* - * Lengh Threshold: above this, we stop computing correctly - * the size - */ - int length_threshold; - - GSList *selection; - GtkSelectionMode selection_mode; - - /* - * During edition - */ - int editing_col, editing_row; - void *edit_ctx; -} ETableItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - - void (*row_selection) (ETableItem *eti, int row, gboolean selected); -} ETableItemClass; - -GtkType e_table_item_get_type (void); - -/* - * Focus - */ -void e_table_item_focus (ETableItem *eti, int col, int row); -void e_table_item_unfocus (ETableItem *eti); - -/* - * Selection - */ -void e_table_item_select_row (ETableItem *e_table_Item, int row); -void e_table_item_unselect_row (ETableItem *e_table_Item, int row); - -/* - * Handling the selection - */ -const GSList*e_table_item_get_selection (ETableItem *e_table_Item); - -GtkSelectionMode e_table_item_get_selection_mode (ETableItem *e_table_Item); -void e_table_item_set_selection_mode (ETableItem *e_table_Item, - GtkSelectionMode selection_mode); -gboolean e_table_item_is_row_selected (ETableItem *e_table_Item, - int row); - -void e_table_item_leave_edit (ETableItem *eti); -void e_table_item_enter_edit (ETableItem *eti, int col, int row); - -void e_table_item_redraw_range (ETableItem *eti, - int start_col, int start_row, - int end_col, int end_row); - -#endif /* _E_TABLE_ITEM_H_ */ diff --git a/widgets/e-table/e-table-model.c b/widgets/e-table/e-table-model.c deleted file mode 100644 index 103bb31b57..0000000000 --- a/widgets/e-table/e-table-model.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * e-table-model.c: a Table Model - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc. - */ -#include <config.h> -#include <gtk/gtksignal.h> -#include "e-table-model.h" - -#define ETM_CLASS(e) ((ETableModelClass *)((GtkObject *)e)->klass) - -static GtkObjectClass *e_table_model_parent_class; - -enum { - MODEL_CHANGED, - MODEL_ROW_CHANGED, - MODEL_CELL_CHANGED, - ROW_SELECTION, - LAST_SIGNAL -}; - -static guint e_table_model_signals [LAST_SIGNAL] = { 0, }; - -int -e_table_model_column_count (ETableModel *e_table_model) -{ - g_return_val_if_fail (e_table_model != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), 0); - - return ETM_CLASS (e_table_model)->column_count (e_table_model); -} - -const char * -e_table_model_column_name (ETableModel *e_table_model, int col) -{ - g_return_val_if_fail (e_table_model != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), NULL); - - return ETM_CLASS (e_table_model)->column_name (e_table_model, col); -} - -int -e_table_model_row_count (ETableModel *e_table_model) -{ - g_return_val_if_fail (e_table_model != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), 0); - - return ETM_CLASS (e_table_model)->row_count (e_table_model); -} - -void * -e_table_model_value_at (ETableModel *e_table_model, int col, int row) -{ - g_return_val_if_fail (e_table_model != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), NULL); - - return ETM_CLASS (e_table_model)->value_at (e_table_model, col, row); -} - -void -e_table_model_set_value_at (ETableModel *e_table_model, int col, int row, const void *data) -{ - g_return_if_fail (e_table_model != NULL); - g_return_if_fail (E_IS_TABLE_MODEL (e_table_model)); - - return ETM_CLASS (e_table_model)->set_value_at (e_table_model, col, row, data); -} - -gboolean -e_table_model_is_cell_editable (ETableModel *e_table_model, int col, int row) -{ - g_return_val_if_fail (e_table_model != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), FALSE); - - return ETM_CLASS (e_table_model)->is_cell_editable (e_table_model, col, row); -} - -static void -e_table_model_destroy (GtkObject *object) -{ - if (e_table_model_parent_class->destroy) - (*e_table_model_parent_class->destroy)(object); -} - -static void -e_table_model_class_init (GtkObjectClass *object_class) -{ - e_table_model_parent_class = gtk_type_class (gtk_object_get_type ()); - - object_class->destroy = e_table_model_destroy; - - e_table_model_signals [MODEL_CHANGED] = - gtk_signal_new ("model_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableModelClass, model_changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - e_table_model_signals [MODEL_ROW_CHANGED] = - gtk_signal_new ("model_row_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableModelClass, model_row_changed), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - e_table_model_signals [MODEL_CELL_CHANGED] = - gtk_signal_new ("model_cell_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableModelClass, model_cell_changed), - gtk_marshal_NONE__INT_INT, - GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, e_table_model_signals, LAST_SIGNAL); -} - -GtkType -e_table_model_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableModel", - sizeof (ETableModel), - sizeof (ETableModelClass), - (GtkClassInitFunc) e_table_model_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - -void -e_table_model_changed (ETableModel *e_table_model) -{ - g_return_if_fail (e_table_model != NULL); - g_return_if_fail (E_IS_TABLE_MODEL (e_table_model)); - - gtk_signal_emit (GTK_OBJECT (e_table_model), - e_table_model_signals [MODEL_CHANGED]); -} - -void -e_table_model_row_changed (ETableModel *e_table_model, int row) -{ - g_return_if_fail (e_table_model != NULL); - g_return_if_fail (E_IS_TABLE_MODEL (e_table_model)); - - gtk_signal_emit (GTK_OBJECT (e_table_model), - e_table_model_signals [MODEL_ROW_CHANGED], row); -} - -void -e_table_model_cell_changed (ETableModel *e_table_model, int col, int row) -{ - g_return_if_fail (e_table_model != NULL); - g_return_if_fail (E_IS_TABLE_MODEL (e_table_model)); - - gtk_signal_emit (GTK_OBJECT (e_table_model), - e_table_model_signals [MODEL_CELL_CHANGED], col, row); -} - - diff --git a/widgets/e-table/e-table-model.h b/widgets/e-table/e-table-model.h deleted file mode 100644 index 22339ae484..0000000000 --- a/widgets/e-table/e-table-model.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef _E_TABLE_MODEL_H_ -#define _E_TABLE_MODEL_H_ - -#include <gtk/gtkobject.h> - -#define E_TABLE_MODEL_TYPE (e_table_model_get_type ()) -#define E_TABLE_MODEL(o) (GTK_CHECK_CAST ((o), E_TABLE_MODEL_TYPE, ETableModel)) -#define E_TABLE_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_MODEL_TYPE, ETableModelClass)) -#define E_IS_TABLE_MODEL(o) (GTK_CHECK_TYPE ((o), E_TABLE_MODEL_TYPE)) -#define E_IS_TABLE_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_MODEL_TYPE)) - -typedef struct { - GtkObject base; -} ETableModel; - -typedef struct { - GtkObjectClass parent_class; - - /* - * Virtual methods - */ - int (*column_count) (ETableModel *etm); - const char *(*column_name) (ETableModel *etm, int col); - int (*row_count) (ETableModel *etm); - void *(*value_at) (ETableModel *etm, int col, int row); - void (*set_value_at) (ETableModel *etm, int col, int row, const void *value); - gboolean (*is_cell_editable) (ETableModel *etm, int col, int row); - - /* - * Signals - */ - void (*model_changed) (ETableModel *etm); - void (*model_row_changed) (ETableModel *etm, int row); - void (*model_cell_changed) (ETableModel *etm, int col, int row); -} ETableModelClass; - -GtkType e_table_model_get_type (void); - -int e_table_model_column_count (ETableModel *e_table_model); -const char *e_table_model_column_name (ETableModel *e_table_model, int col); -int e_table_model_row_count (ETableModel *e_table_model); -void *e_table_model_value_at (ETableModel *e_table_model, int col, int row); -void e_table_model_set_value_at (ETableModel *e_table_model, int col, int row, const void *data); -gboolean e_table_model_is_cell_editable (ETableModel *e_table_model, int col, int row); - -/* - * Routines for emitting signals on the e_table - */ -void e_table_model_changed (ETableModel *e_table_model); -void e_table_model_row_changed (ETableModel *e_table_model, int row); -void e_table_model_cell_changed (ETableModel *e_table_model, int col, int row); - -#endif /* _E_TABLE_MODEL_H_ */ - - diff --git a/widgets/e-table/e-table-render.c b/widgets/e-table/e-table-render.c deleted file mode 100644 index 49d742132b..0000000000 --- a/widgets/e-table/e-table-render.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * E-table-render.c: Various renderers - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc. - */ -#include <config.h> -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-col.h" -#include "e-table-render.h" - -void -e_table_render_string (ERenderContext *ctxt) -{ - printf ("Rendering string: %s\n", ctxt->render_data); -} - diff --git a/widgets/e-table/e-table-render.h b/widgets/e-table/e-table-render.h deleted file mode 100644 index ebc65968f0..0000000000 --- a/widgets/e-table/e-table-render.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef E_TABLE_RENDER_H -#define E_TABLE_RENDER_H - -#include <libgnomeui/gnome-canvas.h> - -struct ERenderContext { - ETableCol *etc; - int row; - int base_x, base_y; - GnomeCanvasItem *gnome_canvas_item; - GdkDrawable *drawable; - int drawable_width; - int drawable_height; - void *render_data; - void *closure; -}; - -void e_table_render_string (ERenderContext *ctxt); - - -#endif diff --git a/widgets/e-table/e-table-simple.c b/widgets/e-table/e-table-simple.c deleted file mode 100644 index 2076e06cef..0000000000 --- a/widgets/e-table/e-table-simple.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * e-table-model.c: a simple table model implementation that uses function - * pointers to simplify the creation of new, exotic and colorful tables in - * no time. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc. - */ - -#include <config.h> -#include "e-table-simple.h" - -#define PARENT_TYPE e_table_model_get_type() - -static int -simple_column_count (ETableModel *etm) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->col_count (etm, simple->data); -} - -static const char * -simple_column_name (ETableModel *etm, int col) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->col_name (etm, col, simple->data); -} - -static int -simple_row_count (ETableModel *etm) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->row_count (etm, simple->data); -} - -static void * -simple_value_at (ETableModel *etm, int col, int row) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->value_at (etm, col, row, simple->data); -} - -static void -simple_set_value_at (ETableModel *etm, int col, int row, const void *val) -{ - ETableSimple *simple = (ETableSimple *)etm; - - simple->set_value_at (etm, col, row, val, simple->data); -} - -static gboolean -simple_is_cell_editable (ETableModel *etm, int col, int row) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->is_cell_editable (etm, col, row, simple->data); -} - -static void -e_table_simple_class_init (GtkObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - model_class->column_count = simple_column_count; - model_class->column_name = simple_column_name; - model_class->row_count = simple_row_count; - model_class->value_at = simple_value_at; - model_class->set_value_at = simple_set_value_at; - model_class->is_cell_editable = simple_is_cell_editable; -} - -GtkType -e_table_simple_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableSimple", - sizeof (ETableSimple), - sizeof (ETableSimpleClass), - (GtkClassInitFunc) e_table_simple_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -ETableModel * -e_table_simple_new (ETableSimpleColumnCountFn col_count, - ETableSimpleColumnNameFn col_name, - ETableSimpleRowCountFn row_count, - ETableSimpleValueAtFn value_at, - ETableSimpleSetValueAtFn set_value_at, - ETableSimpleIsCellEditableFn is_cell_editable, - void *data) -{ - ETableSimple *et; - - et = gtk_type_new (e_table_simple_get_type ()); - - et->col_count = col_count; - et->col_name = col_name; - et->row_count = row_count; - et->value_at = value_at; - et->set_value_at = set_value_at; - et->is_cell_editable = is_cell_editable; - - return (ETableModel *) et; -} diff --git a/widgets/e-table/e-table-simple.h b/widgets/e-table/e-table-simple.h deleted file mode 100644 index 1f7a17aeff..0000000000 --- a/widgets/e-table/e-table-simple.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _E_TABLE_SIMPLE_H_ -#define _E_TABLE_SIMPLE_H_ - -#include "e-table-model.h" - -typedef int (*ETableSimpleColumnCountFn) (ETableModel *etm, void *data); -typedef const char *(*ETableSimpleColumnNameFn) (ETableModel *etm, int col, void *data); -typedef int (*ETableSimpleRowCountFn) (ETableModel *etm, void *data); -typedef void *(*ETableSimpleValueAtFn) (ETableModel *etm, int col, int row, void *data); -typedef void (*ETableSimpleSetValueAtFn) (ETableModel *etm, int col, int row, const void *val, void *data); -typedef gboolean (*ETableSimpleIsCellEditableFn) (ETableModel *etm, int col, int row, void *data); - -typedef struct { - ETableModel parent; - - ETableSimpleColumnCountFn col_count; - ETableSimpleColumnNameFn col_name; - ETableSimpleRowCountFn row_count; - ETableSimpleValueAtFn value_at; - ETableSimpleSetValueAtFn set_value_at; - ETableSimpleIsCellEditableFn is_cell_editable; - void *data; -} ETableSimple; - -typedef struct { - ETableModelClass parent_class; -} ETableSimpleClass; - -GtkType e_table_simple_get_type (void); - -ETableModel *e_table_simple_new (ETableSimpleColumnCountFn col_count, - ETableSimpleColumnNameFn col_name, - ETableSimpleRowCountFn row_count, - ETableSimpleValueAtFn value_at, - ETableSimpleSetValueAtFn set_value_at, - ETableSimpleIsCellEditableFn is_cell_editable, - void *data); - -#endif /* _E_TABLE_SIMPLE_H_ */ - diff --git a/widgets/e-table/e-table-sorted.c b/widgets/e-table/e-table-sorted.c deleted file mode 100644 index 90773e9cdc..0000000000 --- a/widgets/e-table/e-table-sorted.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * E-table-sorted.c: Implements a table that sorts another table - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc. - */ -#include <config.h> -#include <stdlib.h> -#include "e-util.h" -#include "e-table-sorted.h" - -#define PARENT_TYPE E_TABLE_SUBSET_TYPE - -static ETableModelClass *ets_parent_class; - -static void -ets_class_init (GtkObjectClass *klass) -{ - ETableModelClass *table_class = (ETableModelClass *) klass; - - ets_parent_class = gtk_type_class (PARENT_TYPE); -} - -E_MAKE_TYPE(e_table_sorted, "ETableSorted", ETableSorted, ets_class_init, NULL, PARENT_TYPE); - -static ETableSorted *sort_ets; - -static int -my_sort (const void *a, const void *b) -{ - ETableModel *source = E_TABLE_SUBSET (sort_ets)->source; - const int *ia = (const int *) a; - const int *ib = (const int *) b; - void *va, *vb; - - va = e_table_model_value_at (source, sort_ets->sort_col, *ia); - vb = e_table_model_value_at (source, sort_ets->sort_col, *ib); - - return (*sort_ets->compare) (va, vb); -} - -static void -do_sort (ETableSorted *ets) -{ - ETableSubset *etss = E_TABLE_SUBSET (ets); - g_assert (sort_ets == NULL); - - sort_ets = ets; - qsort (etss->map_table, etss->n_map, sizeof (unsigned int), my_sort); - sort_ets = NULL; -} - -ETableModel * -e_table_sorted_new (ETableModel *source, int col, GCompareFunc compare) -{ - ETableSorted *ets = gtk_type_new (E_TABLE_SORTED_TYPE); - ETableSubset *etss = E_TABLE_SUBSET (ets); - const int nvals = e_table_model_row_count (source); - int i; - - if (e_table_subset_construct (etss, source, nvals) == NULL){ - gtk_object_destroy (GTK_OBJECT (ets)); - return NULL; - } - - ets->compare = compare; - ets->sort_col = col; - - /* Init */ - for (i = 0; i < nvals; i++) - etss->map_table [i] = i; - - do_sort (ets); - - return (ETableModel *) ets; -} - -void -e_table_sorted_resort (ETableSorted *ets, int col, GCompareFunc compare) -{ - if (col == -1 || compare == NULL) - do_sort (ets); - else { - ets->sort_col = col; - ets->compare = compare; - do_sort (ets); - } -} - diff --git a/widgets/e-table/e-table-sorted.h b/widgets/e-table/e-table-sorted.h deleted file mode 100644 index 2ec52df2e7..0000000000 --- a/widgets/e-table/e-table-sorted.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _E_TABLE_SORTED_H_ -#define _E_TABLE_SORTED_H_ - -#include <gtk/gtkobject.h> -#include "e-table-model.h" -#include "e-table-subset.h" - -#define E_TABLE_SORTED_TYPE (e_table_sorted_get_type ()) -#define E_TABLE_SORTED(o) (GTK_CHECK_CAST ((o), E_TABLE_SORTED_TYPE, ETableSorted)) -#define E_TABLE_SORTED_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_SORTED_TYPE, ETableSortedClass)) -#define E_IS_TABLE_SORTED(o) (GTK_CHECK_TYPE ((o), E_TABLE_SORTED_TYPE)) -#define E_IS_TABLE_SORTED_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_SORTED_TYPE)) - -typedef struct { - ETableSubset base; - - short sort_col; - GCompareFunc compare; -} ETableSorted; - -typedef struct { - ETableSubset parent_class; -} ETableSortedClass; - -GtkType e_table_sorted_get_type (void); -ETableModel *e_table_sorted_new (ETableModel *etm, int col, GCompareFunc compare); -void e_table_sorted_resort (ETableSorted *ets, int col, GCompareFunc compare); - -#endif /* _E_TABLE_SORTED_H_ */ diff --git a/widgets/e-table/e-table-subset.c b/widgets/e-table/e-table-subset.c deleted file mode 100644 index 41763d309b..0000000000 --- a/widgets/e-table/e-table-subset.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * E-table-subset.c: Implements a table that contains a subset of another table. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc. - */ -#include <config.h> -#include "e-util.h" -#include "e-table-subset.h" - -#define PARENT_TYPE E_TABLE_MODEL_TYPE - -static ETableModelClass *etss_parent_class; - -static void -etss_destroy (GtkObject *object) -{ - ETableSubset *etss = E_TABLE_SUBSET (object); - - if (etss->source) - gtk_object_unref (GTK_OBJECT (etss->source)); - - if (etss->map_table) - free (etss->map_table); - - GTK_OBJECT_CLASS (etss_parent_class)->destroy (object); -} - -static int -etss_column_count (ETableModel *etm) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_column_count (etss->source); -} - -static const char * -etss_column_name (ETableModel *etm, int col) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_column_name (etss->source, col); -} - -static int -etss_row_count (ETableModel *etm) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_row_count (etss->source); -} - -static void * -etss_value_at (ETableModel *etm, int col, int row) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_value_at (etss->source, col, etss->map_table [row]); -} - -static void -etss_set_value_at (ETableModel *etm, int col, int row, void *val) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_set_value_at (etss->source, col, etss->map_table [row], val); -} - -static gboolean -etss_is_cell_editable (ETableModel *etm, int col, int row) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_is_cell_editable (etss->source, col, etss->map_table [row]); -} - -static int -etss_row_height (ETableModel *etm, int row) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_row_height (etss->source, etss->map_table [row]); -} - -static void -etss_class_init (GtkObjectClass *klass) -{ - ETableModelClass *table_class = (ETableModelClass *) klass; - - etss_parent_class = gtk_type_class (PARENT_TYPE); - - klass->destroy = etss_destroy; - - table_class->column_count = etss_column_count; - table_class->column_name = etss_column_name; - table_class->row_count = etss_row_count; - table_class->value_at = etss_value_at; - table_class->set_value_at = etss_set_value_at; - table_class->is_cell_editable = etss_is_cell_editable; - table_class->row_height = etss_row_height; - -} - -E_MAKE_TYPE(e_table_subset, "ETableSubset", ETableSubset, etss_class_init, NULL, PARENT_TYPE); - -ETableModel * -e_table_subset_construct (ETableSubset *etss, ETableModel *source, int nvals) -{ - unsigned int *buffer; - int i; - - buffer = (unsigned int *) malloc (sizeof (unsigned int *) * nvals); - if (buffer = NULL) - return NULL; - etss->map_table = buffer; - etss->n_map = nvals; - etss->source = source; - gtk_object_ref (GTK_OBJECT (source)); - - /* Init */ - for (i = 0; i < nvals; i++) - etss->map_table [i] = i; - -} - -ETableModel * -e_table_subset_new (ETableModel *source, const int nvals) -{ - ETableSubset *etss = gtk_type_new (E_TABLE_SUBSET_TYPE); - - if (e_table_subset_construct (etss, source, nvals) == NULL){ - gtk_object_destroy (GTK_OBJECT (etss)); - return NULL; - } - - return (ETableModel *) etss; -} - -ETableModel * -e_table_subset_get_toplevel (ETableSubset *table) -{ - g_return_val_if_fail (table != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_SUBSET (table), NULL); - - if (E_IS_TABLE_SUBSET (table->source)) - return e_table_subset_get_toplevel (E_TABLE_SUBSET (table->source)); - else - return table->subset; -} diff --git a/widgets/e-table/e-table-subset.h b/widgets/e-table/e-table-subset.h deleted file mode 100644 index 66d11e9658..0000000000 --- a/widgets/e-table/e-table-subset.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _E_TABLE_SUBSET_H_ -#define _E_TABLE_SUBSET_H_ - -#include <gtk/gtkobject.h> -#include "e-table-model.h" - -#define E_TABLE_SUBSET_TYPE (e_table_subset_get_type ()) -#define E_TABLE_SUBSET(o) (GTK_CHECK_CAST ((o), E_TABLE_SUBSET_TYPE, ETableSubset)) -#define E_TABLE_SUBSET_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_SUBSET_TYPE, ETableSubsetClass)) -#define E_IS_TABLE_SUBSET(o) (GTK_CHECK_TYPE ((o), E_TABLE_SUBSET_TYPE)) -#define E_IS_TABLE_SUBSET_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_SUBSET_TYPE)) - -typedef struct { - ETableModel base; - - ETableModel *source; - int n_map; - int *map_table; -} ETableSubset; - -typedef struct { - ETableModelClass parent_class; -} ETableSubsetClass; - -GtkType e_table_subset_get_type (void); -ETableModel *e_table_subset_new (ETableModel *etm, int n_vals); -ETableModel *e_table_subset_construct (ETableSubset *ets, ETableModel *source, int nvals); - -ETableModel *e_table_subset_get_toplevel (ETableModel *table_model); - -#endif /* _E_TABLE_SUBSET_H_ */ diff --git a/widgets/e-table/e-table-tree.h b/widgets/e-table/e-table-tree.h deleted file mode 100644 index e7e125a6af..0000000000 --- a/widgets/e-table/e-table-tree.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _E_TABLE_TREE_H_ -#define _E_TABLE_TREE_H_ - -typedef struct { - char *title; - - union { - ETableModel *table; - GList *children; - } u; - - guint expanded :1; - guint is_leaf :1; -} ETableGroup; - -ETableGroup *e_table_group_new (const char *title, ETableModel *table); -ETableGroup *e_table_group_new_leaf (const char *title); - -#endif /* _E_TABLE_TREE_H_ */ diff --git a/widgets/e-table/e-table.c b/widgets/e-table/e-table.c deleted file mode 100644 index 3b13e87d6b..0000000000 --- a/widgets/e-table/e-table.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * E-table-view.c: A graphical view of a Table. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc - */ -#include <config.h> -#include <libgnomeui/gnome-canvas.h> -#include "e-table.h" -#include "e-util.h" - -#define PARENT_OBJECT_TYPE gnome_canvas_get_type () - -E_MAKE_TYPE(e_table, "ETable", ETable, e_table_class_init, NULL, PARENT_TYPE); - -ETable * -e_table_new (ETableHeader *eth, ETableModel *etm) -{ -} - diff --git a/widgets/e-table/e-table.h b/widgets/e-table/e-table.h deleted file mode 100644 index 0847ddde6c..0000000000 --- a/widgets/e-table/e-table.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _E_TABLE_H_ -#define _E_TABLE_H_ - -GtkType e_table_get_type (void); -ETable * -#endif /* _E_TABLE_H_ */ diff --git a/widgets/e-table/image1.png b/widgets/e-table/image1.png Binary files differdeleted file mode 100644 index 8326ac241f..0000000000 --- a/widgets/e-table/image1.png +++ /dev/null diff --git a/widgets/e-table/image2.png b/widgets/e-table/image2.png Binary files differdeleted file mode 100644 index e6a4c75dbe..0000000000 --- a/widgets/e-table/image2.png +++ /dev/null diff --git a/widgets/e-table/image3.png b/widgets/e-table/image3.png Binary files differdeleted file mode 100644 index 50e16e8620..0000000000 --- a/widgets/e-table/image3.png +++ /dev/null diff --git a/widgets/e-table/sample.table b/widgets/e-table/sample.table deleted file mode 100644 index 2cb09d7f1f..0000000000 --- a/widgets/e-table/sample.table +++ /dev/null @@ -1,8 +0,0 @@ -Col1 Col2 Address Title Dorks -c1.a c2.a a.a tit-1 DorkA -c1.b c2.b a.b tit-2 DDork -c1.c c2.c a.c tit-1 DorkB -c1.d c2.d a.d tit-2 ADork -c1.e c2.e a.e tit-1 DorkC -c1.f c2.f a.f tit-2 UDork - diff --git a/widgets/e-table/table-test.c b/widgets/e-table/table-test.c deleted file mode 100644 index 32d726dd06..0000000000 --- a/widgets/e-table/table-test.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Test code for the ETable package - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <fcntl.h> -#include <gnome.h> - -int -main (int argc, char *argv []) -{ - - if (isatty (0)){ - int fd; - - close (0); - fd = open ("sample.table", O_RDONLY); - if (fd == -1){ - fprintf (stderr, "Could not find sample.table, try feeding a table on stdin"); - exit (1); - } - dup2 (fd, 0); - } - - gnome_init ("TableTest", "TableTest", argc, argv); - e_cursors_init (); - - table_browser_test (); - multi_cols_test (); - check_test (); - - gtk_main (); - - e_cursors_shutdown (); - return 0; -} diff --git a/widgets/e-table/test-check.c b/widgets/e-table/test-check.c deleted file mode 100644 index 4573580562..0000000000 --- a/widgets/e-table/test-check.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Test code for the ETable package - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <gnome.h> -#include "e-table-simple.h" -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-item.h" -#include "e-cursors.h" -#include "e-cell-text.h" -#include "e-cell-checkbox.h" - -#define LINES 4 - -static struct { - int value; - char *string; -} my_table [LINES] = { - { 0, "Buy food" }, - { 1, "Breathe " }, - { 0, "Cancel gdb session with shrink" }, - { 1, "Make screenshots" }, -}; -/* - * ETableSimple callbacks - */ -static int -col_count (ETableModel *etc, void *data) -{ - return 2; -} - -static const char * -col_name (ETableModel *etc, int col, void *data) -{ - g_assert (col < 2); - - if (col == 0) - return "flag"; - else - return "text"; -} - -static int -row_count (ETableModel *etc, void *data) -{ - return LINES; -} - -static void * -value_at (ETableModel *etc, int col, int row, void *data) -{ - g_assert (col < 2); - g_assert (row < LINES); - - if (col == 0) - return GINT_TO_POINTER (my_table [row].value); - else - return my_table [row].string; - -} - -static void -set_value_at (ETableModel *etc, int col, int row, const void *val, void *data) -{ - g_assert (col < 2); - g_assert (row < LINES); - - if (col == 0){ - my_table [row].value = GPOINTER_TO_INT (val); - printf ("Value at %d,%d set to %d\n", col, row, GPOINTER_TO_INT (val)); - } else { - my_table [row].string = g_strdup (val); - printf ("Value at %d,%d set to %s\n", col, row, (char *) val); - } -} - -static gboolean -is_cell_editable (ETableModel *etc, int col, int row, void *data) -{ - return TRUE; -} - -static void -set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc) -{ - gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height); -} - -void -check_test (void) -{ - GtkWidget *canvas, *window; - ETableModel *e_table_model; - ETableHeader *e_table_header; - ETableCol *col_0, *col_1; - ECell *cell_left_just, *cell_image_check; - int i; - - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - - e_table_model = e_table_simple_new ( - col_count, col_name, row_count, value_at, - set_value_at, is_cell_editable, NULL); - - /* - * Header - */ - e_table_header = e_table_header_new (); - - cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT); - - cell_image_check = e_cell_checkbox_new (e_table_model); - col_0 = e_table_col_new ("id", "", 18, 18, cell_image_check, g_int_equal, TRUE); - e_table_header_add_column (e_table_header, col_0, 0); - - col_1 = e_table_col_new ("item", "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE); - e_table_header_add_column (e_table_header, col_1, 1); - - /* - * GUI - */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - canvas = gnome_canvas_new (); - - gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate", - GTK_SIGNAL_FUNC (set_canvas_size), NULL); - - gtk_container_add (GTK_CONTAINER (window), canvas); - gtk_widget_show_all (window); - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_header_item_get_type (), - "ETableHeader", e_table_header, - "x", 0, - "y", 0, - NULL); - - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_item_get_type (), - "ETableHeader", e_table_header, - "ETableModel", e_table_model, - "x", 0, - "y", 30, - "drawgrid", TRUE, - "drawfocus", TRUE, - "spreadsheet", TRUE, - NULL); - -} - - - - - diff --git a/widgets/e-table/test-cols.c b/widgets/e-table/test-cols.c deleted file mode 100644 index c4ce0e1b75..0000000000 --- a/widgets/e-table/test-cols.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Test code for the ETable package - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <gnome.h> -#include "e-table-simple.h" -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-item.h" -#include "e-cursors.h" -#include "e-cell-text.h" -#include "e-cell-toggle.h" - -#define LINES 4 - -static struct { - int value; - char *string; -} my_table [LINES] = { - { 0, "You are not" }, - { 1, "A beautiful and unique " }, - { 0, "Snowflake" }, - { 2, "You are not your wallet" }, -}; -/* - * ETableSimple callbacks - */ -static int -col_count (ETableModel *etc, void *data) -{ - return 2; -} - -static const char * -col_name (ETableModel *etc, int col, void *data) -{ - g_assert (col < 2); - - if (col == 0) - return "flag"; - else - return "text"; -} - -static int -row_count (ETableModel *etc, void *data) -{ - return LINES; -} - -static void * -value_at (ETableModel *etc, int col, int row, void *data) -{ - g_assert (col < 2); - g_assert (row < LINES); - - if (col == 0) - return GINT_TO_POINTER (my_table [row].value); - else - return my_table [row].string; - -} - -static void -set_value_at (ETableModel *etc, int col, int row, const void *val, void *data) -{ - g_assert (col < 2); - g_assert (row < LINES); - - if (col == 0){ - my_table [row].value = GPOINTER_TO_INT (val); - printf ("Value at %d,%d set to %d\n", col, row, GPOINTER_TO_INT (val)); - } else { - my_table [row].string = g_strdup (val); - printf ("Value at %d,%d set to %s\n", col, row, (char *) val); - } -} - -static gboolean -is_cell_editable (ETableModel *etc, int col, int row, void *data) -{ - return TRUE; -} - -static void -set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc) -{ - gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height); -} - -void -multi_cols_test (void) -{ - GtkWidget *canvas, *window; - ETableModel *e_table_model; - ETableHeader *e_table_header; - ETableCol *col_0, *col_1; - ECell *cell_left_just, *cell_image_toggle; - int i; - - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - - e_table_model = e_table_simple_new ( - col_count, col_name, row_count, value_at, - set_value_at, is_cell_editable, NULL); - - /* - * Header - */ - e_table_header = e_table_header_new (); - - cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT); - - { - GdkPixbuf **images = g_new (GdkPixbuf *, 3); - int i; - - images [0] = gdk_pixbuf_new_from_file ("image1.png"); - images [1] = gdk_pixbuf_new_from_file ("image2.png"); - images [2] = gdk_pixbuf_new_from_file ("image3.png"); - - cell_image_toggle = e_cell_toggle_new (e_table_model, 0, 3, images); - - for (i = 0; i < 3; i++) - gdk_pixbuf_unref (images [i]); - - g_free (images); - } - - col_0 = e_table_col_new ("id", "A", 48, 48, cell_image_toggle, g_int_equal, TRUE); - e_table_header_add_column (e_table_header, col_0, 0); - - col_1 = e_table_col_new ("item", "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE); - e_table_header_add_column (e_table_header, col_1, 1); - - - /* - * GUI - */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - canvas = gnome_canvas_new (); - - gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate", - GTK_SIGNAL_FUNC (set_canvas_size), NULL); - - gtk_container_add (GTK_CONTAINER (window), canvas); - gtk_widget_show_all (window); - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_header_item_get_type (), - "ETableHeader", e_table_header, - "x", 0, - "y", 0, - NULL); - - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_item_get_type (), - "ETableHeader", e_table_header, - "ETableModel", e_table_model, - "x", 0, - "y", 30, - "drawgrid", TRUE, - "drawfocus", TRUE, - "spreadsheet", TRUE, - NULL); - -} - - - - - diff --git a/widgets/e-table/test-table.c b/widgets/e-table/test-table.c deleted file mode 100644 index be1a1059db..0000000000 --- a/widgets/e-table/test-table.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Test code for the ETable package - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <gnome.h> -#include "e-table-simple.h" -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-item.h" -#include "e-cursors.h" -#include "e-cell-text.h" - -char buffer [1024]; -char **column_labels; -char ***table_data; -int cols = 0; -int lines = 0; -int lines_alloc = 0; - -static void -parse_headers () -{ - char *p, *s; - int in_value = 0, i; - - fgets (buffer, sizeof (buffer)-1, stdin); - - for (p = buffer; *p; p++){ - if (*p == ' ' || *p == '\t'){ - if (in_value){ - cols++; - in_value = 0; - } - } else - in_value = 1; - } - if (in_value) - cols++; - - if (!cols){ - fprintf (stderr, "No columns in first row\n"); - exit (1); - } - - column_labels = g_new0 (char *, cols); - - p = buffer; - for (i = 0; (s = strtok (p, " \t")) != NULL; i++){ - column_labels [i] = g_strdup (s); - p = NULL; - } - - printf ("%d headers:\n", cols); - for (i = 0; i < cols; i++){ - printf ("header %d: %s\n", i, column_labels [i]); - } -} - -static char ** -load_line (char *buffer, int cols) -{ - char **line = g_new0 (char *, cols); - char *p; - int i; - - for (i = 0; i < cols; i++){ - p = strtok (buffer, " \t\n"); - if (p == NULL){ - for (; i < cols; i++) - line [i] = g_strdup (""); - return line; - } else - line [i] = g_strdup (p); - buffer = NULL; - } - return line; -} - -static void -append_line (char **line) -{ - if (lines <= lines_alloc){ - lines_alloc = lines + 50; - table_data = g_renew (char **, table_data, lines_alloc); - } - table_data [lines] = line; - lines++; -} - -static void -load_data () -{ - int i; - - parse_headers (); - - while (fgets (buffer, sizeof (buffer)-1, stdin) != NULL){ - char **line; - - if (buffer [0] == '\n') - continue; - line = load_line (buffer, cols); - append_line (line); - } - - for (i = 0; i < lines; i++){ - int j; - - printf ("Line %d: ", i); - for (j = 0; j < cols; j++) - printf ("[%s] ", table_data [i][j]); - printf ("\n"); - } -} - -/* - * ETableSimple callbacks - */ -static int -col_count (ETableModel *etc, void *data) -{ - return cols; -} - -static const char * -col_name (ETableModel *etc, int col, void *data) -{ - g_assert (col < cols); - - return column_labels [col]; -} - -static int -row_count (ETableModel *etc, void *data) -{ - return lines; -} - -static void * -value_at (ETableModel *etc, int col, int row, void *data) -{ - g_assert (col < cols); - g_assert (row < lines); - - return (void *) table_data [row][col]; -} - -static void -set_value_at (ETableModel *etc, int col, int row, const void *val, void *data) -{ - g_assert (col < cols); - g_assert (row < lines); - - g_free (table_data [row][col]); - table_data [row][col] = g_strdup (val); - - printf ("Value at %d,%d set to %s\n", col, row, (char *) val); -} - -static gboolean -is_cell_editable (ETableModel *etc, int col, int row, void *data) -{ - return TRUE; -} - -static void -set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc) -{ - gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height); -} - -void -table_browser_test (void) -{ - GtkWidget *canvas, *window; - ETableModel *e_table_model; - ETableHeader *e_table_header; - ECell *cell_left_just; - int i; - - load_data (); - - /* - * Data model - */ - e_table_model = e_table_simple_new ( - col_count, col_name, row_count, value_at, - set_value_at, is_cell_editable, NULL); - - /* - * Header - */ - e_table_header = e_table_header_new (); - cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT); - - for (i = 0; i < cols; i++){ - ETableCol *ecol = e_table_col_new ( - column_labels [i], column_labels [i], - 80, 20, cell_left_just, - g_str_equal, TRUE); - - e_table_header_add_column (e_table_header, ecol, i); - } - - /* - * Setup GUI - */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - canvas = gnome_canvas_new (); - - gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate", - GTK_SIGNAL_FUNC (set_canvas_size), NULL); - - gtk_container_add (GTK_CONTAINER (window), canvas); - gtk_widget_show_all (window); - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_header_item_get_type (), - "ETableHeader", e_table_header, - "x", 0, - "y", 0, - NULL); - - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_item_get_type (), - "ETableHeader", e_table_header, - "ETableModel", e_table_model, - "x", 10, - "y", 30, - "drawgrid", TRUE, - "drawfocus", TRUE, - "spreadsheet", TRUE, - NULL); -} - diff --git a/widgets/e-table/test.c b/widgets/e-table/test.c deleted file mode 100644 index 0eece34467..0000000000 --- a/widgets/e-table/test.c +++ /dev/null @@ -1,17 +0,0 @@ -#include <config.h> -#include "e-table-simple.h" - -struct { - char *str; - int val; -} data [] = { - { "Miguel", 10 }, - { "Nat", 20 }, - { NULL, 0 }, -}; - -main () -{ - -} - diff --git a/widgets/e-util.h b/widgets/e-util.h deleted file mode 100644 index ad4d754770..0000000000 --- a/widgets/e-util.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _E_UTIL_H_ -#define _E_UTIL_H_ - -#define E_MAKE_TYPE(l,str,t,ci,i,parent) \ -GtkType l##_get_type(void)\ -{\ - static GtkType type = 0;\ - if (!type){\ - GtkTypeInfo info = {\ - str,\ - sizeof (t),\ - sizeof (t##Class),\ - (GtkClassInitFunc) ci,\ - (GtkObjectInitFunc) i,\ - NULL, /* reserved 1 */\ - NULL, /* reserved 2 */\ - (GtkClassInitFunc) NULL\ - };\ - type = gtk_type_unique (parent, &info);\ - }\ - return type;\ -}\ - -#endif /* _E_UTIL_H_ */ diff --git a/widgets/image1.png b/widgets/image1.png Binary files differdeleted file mode 100644 index 8326ac241f..0000000000 --- a/widgets/image1.png +++ /dev/null diff --git a/widgets/image2.png b/widgets/image2.png Binary files differdeleted file mode 100644 index e6a4c75dbe..0000000000 --- a/widgets/image2.png +++ /dev/null diff --git a/widgets/image3.png b/widgets/image3.png Binary files differdeleted file mode 100644 index 50e16e8620..0000000000 --- a/widgets/image3.png +++ /dev/null diff --git a/widgets/misc/e-colors.c b/widgets/misc/e-colors.c deleted file mode 100644 index 3f1de73784..0000000000 --- a/widgets/misc/e-colors.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * color.c: Color allocation on the Gnumeric spreadsheet - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * We keep our own color context, as the color allocation might take place - * before any of our Canvases are realized. - */ -#include <config.h> -#include <gnome.h> -#include "color.h" - -static int color_inited; -static GdkColorContext *gnumeric_color_context; - -/* Public colors: shared by all of our items in Gnumeric */ -GdkColor gs_white, gs_black, gs_light_gray, gs_dark_gray, gs_red; - -int -color_alloc (gushort red, gushort green, gushort blue) -{ - int failed; - - if (!color_inited) - color_init (); - - return gdk_color_context_get_pixel (gnumeric_color_context, - red, green, blue, &failed); -} - -void -color_alloc_gdk (GdkColor *c) -{ - int failed; - - g_return_if_fail (c != NULL); - - c->pixel = gdk_color_context_get_pixel (gnumeric_color_context, c->red, c->green, c->blue, &failed); -} - -void -color_alloc_name (const char *name, GdkColor *c) -{ - int failed; - - g_return_if_fail (name != NULL); - g_return_if_fail (c != NULL); - - gdk_color_parse (name, c); - c->pixel = 0; - c->pixel = gdk_color_context_get_pixel (gnumeric_color_context, c->red, c->green, c->blue, &failed); -} - -void -color_init (void) -{ - GdkColormap *colormap = gtk_widget_get_default_colormap (); - - /* Initialize the color context */ - gnumeric_color_context = gdk_color_context_new ( - gtk_widget_get_default_visual (), colormap); - - /* Allocate the default colors */ - gdk_color_white (colormap, &gs_white); - gdk_color_black (colormap, &gs_black); - - color_alloc_name ("gray78", &gs_light_gray); - color_alloc_name ("gray20", &gs_dark_gray); - color_alloc_name ("red", &gs_red); - - color_inited = 1; -} diff --git a/widgets/misc/e-colors.h b/widgets/misc/e-colors.h deleted file mode 100644 index b2755a5c6a..0000000000 --- a/widgets/misc/e-colors.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef GNUMERIC_COLOR_H -#define GNUMERIC_COLOR_H - -void color_init (void); - -/* Return the pixel value for the given red, green and blue */ -int color_alloc (gushort red, gushort green, gushort blue); -void color_alloc_name (const char *name, GdkColor *color); -void color_alloc_gdk (GdkColor *color); - -/* Colors used by any GnumericSheet item */ -extern GdkColor gs_white, gs_light_gray, gs_dark_gray, gs_black, gs_red; - -#endif /* GNUMERIC_COLOR_H */ diff --git a/widgets/misc/e-cursors.c b/widgets/misc/e-cursors.c deleted file mode 100644 index 597c3c1787..0000000000 --- a/widgets/misc/e-cursors.c +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef GNUMERIC_CURSORS_H -#define GNUMERIC_CURSORS_H - -typedef enum { - GNUMERIC_CURSOR_FAT_CROSS, - GNUMERIC_CURSOR_THIN_CROSS, - GNUMERIC_CURSOR_ARROW, - GNUMERIC_CURSOR_MOVE, - GNUMERIC_CURSOR_ZOOM_IN, - GNUMERIC_CURSOR_ZOOM_OUT, - GNUMERIC_CURSOR_SIZE_X, - GNUMERIC_CURSOR_SIZE_Y, - GNUMERIC_CURSOR_SIZE_TL, - GNUMERIC_CURSOR_SIZE_TR, - GNUMERIC_CURSOR_PRESS, - GNUMERIC_CURSOR_HAND_OPEN, - GNUMERIC_CURSOR_HAND_CLOSED, - GNUMERIC_CURSOR_NUM_CURSORS -} CursorType; - -void cursors_init (void); -void cursors_shutdown (void); - -#define cursor_set(win, c) \ -G_STMT_START { \ - if (win) \ - gdk_window_set_cursor (win, cursor_get (c)); \ -} G_STMT_END - -#define cursor_set_widget(w, c) \ -G_STMT_START { \ - if (GTK_WIDGET (w)->window) \ - gdk_window_set_cursor (GTK_WIDGET (w)->window, cursor_get (c)); \ -} G_STMT_END - -GdkCursor *cursor_get (CursorType type); - -#endif /* GNUMERIC_CURSORS_H */ diff --git a/widgets/misc/e-cursors.h b/widgets/misc/e-cursors.h deleted file mode 100644 index 597c3c1787..0000000000 --- a/widgets/misc/e-cursors.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef GNUMERIC_CURSORS_H -#define GNUMERIC_CURSORS_H - -typedef enum { - GNUMERIC_CURSOR_FAT_CROSS, - GNUMERIC_CURSOR_THIN_CROSS, - GNUMERIC_CURSOR_ARROW, - GNUMERIC_CURSOR_MOVE, - GNUMERIC_CURSOR_ZOOM_IN, - GNUMERIC_CURSOR_ZOOM_OUT, - GNUMERIC_CURSOR_SIZE_X, - GNUMERIC_CURSOR_SIZE_Y, - GNUMERIC_CURSOR_SIZE_TL, - GNUMERIC_CURSOR_SIZE_TR, - GNUMERIC_CURSOR_PRESS, - GNUMERIC_CURSOR_HAND_OPEN, - GNUMERIC_CURSOR_HAND_CLOSED, - GNUMERIC_CURSOR_NUM_CURSORS -} CursorType; - -void cursors_init (void); -void cursors_shutdown (void); - -#define cursor_set(win, c) \ -G_STMT_START { \ - if (win) \ - gdk_window_set_cursor (win, cursor_get (c)); \ -} G_STMT_END - -#define cursor_set_widget(w, c) \ -G_STMT_START { \ - if (GTK_WIDGET (w)->window) \ - gdk_window_set_cursor (GTK_WIDGET (w)->window, cursor_get (c)); \ -} G_STMT_END - -GdkCursor *cursor_get (CursorType type); - -#endif /* GNUMERIC_CURSORS_H */ diff --git a/widgets/misc/pixmaps/cursor_cross.xpm b/widgets/misc/pixmaps/cursor_cross.xpm deleted file mode 100644 index f00e57f78c..0000000000 --- a/widgets/misc/pixmaps/cursor_cross.xpm +++ /dev/null @@ -1,38 +0,0 @@ -/* XPM */ -static char * cursor_cross_xpm[] = { -"32 32 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ....... ", -" .+++++.. ", -" .+++++.. ", -" .+++++.. ", -" .+++++.. ", -" ......+++++...... ", -" .+++++++++++++++.. ", -" .+++++++++++++++.. ", -" .+++++++++++++++.. ", -" .+++++++++++++++.. ", -" .+++++++++++++++.. ", -" ......+++++....... ", -" .+++++....... ", -" .+++++.. ", -" .+++++.. ", -" .+++++.. ", -" ........ ", -" ....... ", -" ", -" ", -" ", -" ", -" ", -" ", -" "}; diff --git a/widgets/misc/pixmaps/cursor_hand_closed.xpm b/widgets/misc/pixmaps/cursor_hand_closed.xpm deleted file mode 100644 index 61a6de4b88..0000000000 --- a/widgets/misc/pixmaps/cursor_hand_closed.xpm +++ /dev/null @@ -1,38 +0,0 @@ -/* XPM */ -static char * cursor_hand_closed_xpm[] = { -"32 32 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" ", -" ", -" ", -" ", -" ", -" .. ", -" ..++... ", -" .+++++++.. ", -" .+++++++++. ", -" ...+++++++++. ", -" .++.+++++++++. ", -" .++++++++++++. ", -" .+++++++++++. ", -" .++++++++++. ", -" .+++++++++. ", -" .+++++++. ", -" .++++++. ", -" .++++++. ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" "}; diff --git a/widgets/misc/pixmaps/cursor_hand_open.xpm b/widgets/misc/pixmaps/cursor_hand_open.xpm deleted file mode 100644 index 048acc8054..0000000000 --- a/widgets/misc/pixmaps/cursor_hand_open.xpm +++ /dev/null @@ -1,38 +0,0 @@ -/* XPM */ -static char * cursor_hand_open_xpm[] = { -"32 32 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" ", -" ", -" .. ", -" .. .++... ", -" .++..++.++. ", -" .++..++.++. . ", -" .++.++.++..+. ", -" .++.++.++.++. ", -" .. .+++++++.++. ", -" .++..++++++++++. ", -" .+++.+++++++++. ", -" .++++++++++++. ", -" .+++++++++++. ", -" .++++++++++. ", -" .+++++++++. ", -" .+++++++. ", -" .++++++. ", -" .++++++. ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" "}; diff --git a/widgets/misc/pixmaps/cursor_zoom_in.xpm b/widgets/misc/pixmaps/cursor_zoom_in.xpm deleted file mode 100644 index 1caf9e3e2a..0000000000 --- a/widgets/misc/pixmaps/cursor_zoom_in.xpm +++ /dev/null @@ -1,37 +0,0 @@ -/* XPM */ -static char * cursor_zoom_in_xpm[] = { -"32 32 2 1", -" c None", -". c #000000", -" ", -" ", -" ", -" ", -" ", -" ", -" ...... ", -" .. .. ", -" .. .. ", -" . . ", -" . ... . ", -" . ... . ", -" . ....... . ", -" . ....... . ", -" . ... . ", -" . ... .. ", -" .. . . ", -" .. . . . ", -" ........ . . ", -" ..... . . . ", -" . . . ", -" . . . ", -" . . . ", -" . . . ", -" . . ", -" . . ", -" .. ", -" ", -" ", -" ", -" ", -" "}; diff --git a/widgets/misc/pixmaps/cursor_zoom_out.xpm b/widgets/misc/pixmaps/cursor_zoom_out.xpm deleted file mode 100644 index af1b698521..0000000000 --- a/widgets/misc/pixmaps/cursor_zoom_out.xpm +++ /dev/null @@ -1,37 +0,0 @@ -/* XPM */ -static char * cursor_zoom_out_xpm[] = { -"32 32 2 1", -" c None", -". c #000000", -" ", -" ", -" ", -" ", -" ", -" ", -" ...... ", -" .. .. ", -" .. .. ", -" . . ", -" . . ", -" . . ", -" . ....... . ", -" . ....... . ", -" . . ", -" . .. ", -" .. . . ", -" .. . . . ", -" ........ . . ", -" ..... . . . ", -" . . . ", -" . . . ", -" . . . ", -" . . . ", -" . . ", -" . . ", -" .. ", -" ", -" ", -" ", -" ", -" "}; diff --git a/widgets/sample.table b/widgets/sample.table deleted file mode 100644 index 2cb09d7f1f..0000000000 --- a/widgets/sample.table +++ /dev/null @@ -1,8 +0,0 @@ -Col1 Col2 Address Title Dorks -c1.a c2.a a.a tit-1 DorkA -c1.b c2.b a.b tit-2 DDork -c1.c c2.c a.c tit-1 DorkB -c1.d c2.d a.d tit-2 ADork -c1.e c2.e a.e tit-1 DorkC -c1.f c2.f a.f tit-2 UDork - diff --git a/widgets/table-test.c b/widgets/table-test.c deleted file mode 100644 index 32d726dd06..0000000000 --- a/widgets/table-test.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Test code for the ETable package - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <fcntl.h> -#include <gnome.h> - -int -main (int argc, char *argv []) -{ - - if (isatty (0)){ - int fd; - - close (0); - fd = open ("sample.table", O_RDONLY); - if (fd == -1){ - fprintf (stderr, "Could not find sample.table, try feeding a table on stdin"); - exit (1); - } - dup2 (fd, 0); - } - - gnome_init ("TableTest", "TableTest", argc, argv); - e_cursors_init (); - - table_browser_test (); - multi_cols_test (); - check_test (); - - gtk_main (); - - e_cursors_shutdown (); - return 0; -} diff --git a/widgets/table/.cvsignore b/widgets/table/.cvsignore deleted file mode 100644 index 0963d457d9..0000000000 --- a/widgets/table/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la -table-test diff --git a/widgets/table/check-empty.xpm b/widgets/table/check-empty.xpm deleted file mode 100644 index 2dd873e137..0000000000 --- a/widgets/table/check-empty.xpm +++ /dev/null @@ -1,21 +0,0 @@ -/* XPM */ -static char * check_empty_xpm[] = { -"16 16 2 1", -" c None", -". c #000000", -" ", -" ", -" ............ ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" ............ ", -" ", -" "}; diff --git a/widgets/table/check-filled.xpm b/widgets/table/check-filled.xpm deleted file mode 100644 index 689d7a7967..0000000000 --- a/widgets/table/check-filled.xpm +++ /dev/null @@ -1,21 +0,0 @@ -/* XPM */ -static char * check_filled_xpm[] = { -"16 16 2 1", -" c None", -". c #000000", -" ", -" ", -" ............ ", -" . . ", -" . . . ", -" . .. . ", -" . ... . ", -" . . ... . ", -" . .. ... . ", -" . ..... . ", -" . ... . ", -" . . . ", -" . . ", -" ............ ", -" ", -" "}; diff --git a/widgets/table/e-cell-checkbox.c b/widgets/table/e-cell-checkbox.c deleted file mode 100644 index 73620b9ce4..0000000000 --- a/widgets/table/e-cell-checkbox.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * e-cell-checkbox.c: Checkbox cell renderer - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkenums.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtksignal.h> -#include <gdk/gdkkeysyms.h> -#include <libgnomeui/gnome-canvas.h> -#include "e-cell-checkbox.h" -#include "e-util.h" -#include "e-table-item.h" - -#include "check-empty.xpm" -#include "check-filled.xpm" - -#define PARENT_TYPE e_cell_toggle_get_type() - -static GdkPixbuf *checks [2]; - -static void -e_cell_checkbox_class_init (GtkObjectClass *object_class) -{ - checks [0] = gdk_pixbuf_new_from_xpm_data (check_empty_xpm); - checks [1] = gdk_pixbuf_new_from_xpm_data (check_filled_xpm); -} - -E_MAKE_TYPE(e_cell_checkbox, "ECellCheckbox", ECellCheckbox, e_cell_checkbox_class_init, NULL, PARENT_TYPE); - -ECell * -e_cell_checkbox_new (ETableModel *etm) -{ - ECellCheckbox *eccb = gtk_type_new (e_cell_checkbox_get_type ()); - - e_cell_toggle_construct (E_CELL_TOGGLE (eccb), etm, 2, 2, checks); - - return (ECell *) eccb; -} diff --git a/widgets/table/e-cell-checkbox.h b/widgets/table/e-cell-checkbox.h deleted file mode 100644 index 6afca6bde2..0000000000 --- a/widgets/table/e-cell-checkbox.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _E_CELL_CHECKBOX_H_ -#define _E_CELL_CHECKBOX_H_ - -#include "e-cell-toggle.h" - -#define E_CELL_CHECKBOX_TYPE (e_cell_checkbox_get_type ()) -#define E_CELL_CHECKBOX(o) (GTK_CHECK_CAST ((o), E_CELL_CHECKBOX_TYPE, ECellCheckbox)) -#define E_CELL_CHECKBOX_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_CHECKBOX_TYPE, ECellCheckboxClass)) -#define E_IS_CELL_CHECKBOX(o) (GTK_CHECK_TYPE ((o), E_CELL_CHECKBOX_TYPE)) -#define E_IS_CELL_CHECKBOX_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_CHECKBOX_TYPE)) - -typedef struct { - ECellToggle parent; -} ECellCheckbox; - -typedef struct { - ECellToggleClass parent_class; -} ECellCheckboxClass; - -GtkType e_cell_checkbox_get_type (void); -ECell *e_cell_checkbox_new (ETableModel *model); - -#endif /* _E_CELL_CHECKBOX_H_ */ - diff --git a/widgets/table/e-cell-string.c b/widgets/table/e-cell-string.c deleted file mode 100644 index 992b1bd10e..0000000000 --- a/widgets/table/e-cell-string.c +++ /dev/null @@ -1,9 +0,0 @@ -ECell * -e_cell_string_new (void) -{ - ECell *ecell; - - ecell = gtk_type_new (ecell); - - return ecell; -} diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c deleted file mode 100644 index d9d8a568db..0000000000 --- a/widgets/table/e-cell-text.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - * e-cell-text.c: Text cell renderer - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkenums.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtksignal.h> -#include <gdk/gdkkeysyms.h> -#include <libgnomeui/gnome-canvas.h> -#include "e-cell-text.h" -#include "e-util.h" -#include "e-table-item.h" - -#define PARENT_TYPE e_cell_get_type() - -#define TEXT_PAD 2 - -typedef struct { - char *old_text; - GtkWidget *entry_top; - GtkEntry *entry; - - /* - * Where the editing is taking place - */ - int col, row; -} CellEdit; - -typedef struct { - ECellView cell_view; - GdkGC *gc; - GdkFont *font; - GnomeCanvas *canvas; - ETableItem *eti; - - /* - * During edition. - */ - CellEdit *edit; -} ECellTextView; - -static ECellClass *parent_class; - -static void -ect_queue_redraw (ECellTextView *text_view, int col, int row) -{ - e_table_item_redraw_range (text_view->eti, col, row, col, row); -} - -/* - * Accept the currently edited text - */ -static void -ect_accept_edits (ECellTextView *text_view) -{ - const char *text = gtk_entry_get_text (text_view->edit->entry); - CellEdit *edit = text_view->edit; - - e_table_model_set_value_at (text_view->eti->table_model, edit->col, edit->row, text); -} - -/* - * Shuts down the editing process - */ -static void -ect_stop_editing (ECellTextView *text_view) -{ - CellEdit *edit = text_view->edit; - - g_free (edit->old_text); - edit->old_text = NULL; - gtk_widget_destroy (edit->entry_top); - edit->entry_top = NULL; - edit->entry = NULL; - - g_free (edit); - - text_view->edit = NULL; - - e_table_item_leave_edit (text_view->eti); -} - -/* - * Cancels the edits - */ -static void -ect_cancel_edit (ECellTextView *text_view) -{ - ect_queue_redraw (text_view, text_view->edit->col, text_view->edit->row); - ect_stop_editing (text_view); -} - -/* - * ECell::realize method - */ -static ECellView * -ect_realize (ECell *ecell, void *view) -{ - ECellText *ect = E_CELL_TEXT (ecell); - ECellTextView *text_view = g_new0 (ECellTextView, 1); - ETableItem *eti = E_TABLE_ITEM (view); - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - - text_view->cell_view.ecell = ecell; - text_view->gc = gdk_gc_new (GTK_WIDGET (canvas)->window); - if (ect->font_name){ - GdkFont *f; - - f = gdk_fontset_load (ect->font_name); - text_view->font = f; - } - if (!text_view->font){ - text_view->font = GTK_WIDGET (canvas)->style->font; - - gdk_font_ref (text_view->font); - } - - text_view->eti = eti; - text_view->canvas = canvas; - - return (ECellView *)text_view; -} - -/* - * ECell::unrealize method - */ -static void -ect_unrealize (ECellView *ecv) -{ - ECellTextView *text_view = (ECellTextView *) ecv; - - gdk_gc_unref (text_view->gc); - text_view->gc = NULL; - - gdk_font_unref (text_view->font); - text_view->font = NULL; - - g_free (text_view); -} - -/* - * ECell::draw method - */ -static void -ect_draw (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, - int x1, int y1, int x2, int y2) -{ - ECellText *ect = E_CELL_TEXT (ecell_view->ecell); - ECellTextView *text_view = (ECellTextView *) ecell_view; - GtkWidget *w = GTK_WIDGET (text_view->canvas); - GdkRectangle rect; - const char *str = e_table_model_value_at (ecell_view->ecell->table_model, col, row); - GdkFont *font = text_view->font; - const int height = font->ascent + font->descent; - int xoff; - gboolean edit_display = FALSE; - - /* - * Figure if this cell is being edited - */ - if (text_view->edit){ - CellEdit *edit = text_view->edit; - - if ((edit->col == col) && (edit->row == row)) - edit_display = TRUE; - } - - /* - * Be a nice citizen: clip to the region we are supposed to draw on - */ - rect.x = x1; - rect.y = y1; - rect.width = x2 - x1; - rect.height = y2 - y1; - gdk_gc_set_clip_rectangle (text_view->gc, &rect); - - if (edit_display){ - CellEdit *edit = text_view->edit; - const char *text = gtk_entry_get_text (edit->entry); - GdkWChar *p, *text_wc = g_new (GdkWChar, strlen (text) + 1); - int text_wc_len = gdk_mbstowcs (text_wc, text, strlen (text)); - const int cursor_pos = GTK_EDITABLE (edit->entry)->current_pos; - const int left_len = gdk_text_width_wc (text_view->font, text_wc, cursor_pos); - - text_wc [text_wc_len] = 0; - /* - * Paint - */ - gdk_gc_set_foreground (text_view->gc, &w->style->base [GTK_STATE_NORMAL]); - gdk_draw_rectangle (drawable, text_view->gc, TRUE, - rect.x, rect.y, rect.width, rect.height); - gdk_gc_set_foreground (text_view->gc, &w->style->text [GTK_STATE_NORMAL]); - - { - GdkGC *gc = text_view->gc; - const int y = y2 - font->descent - ((y2-y1-height)/2); - int px, i; - - /* - * Border - */ - x1 += 2; - x2--; - - px = x1; - - /* - * If the cursor is outside the visible range - * - * FIXME: we really want a better behaviour. - */ - if ((px + left_len) > x2) - px -= left_len - (x2-x1); - - for (i = 0, p = text_wc; *p; p++, i++){ - gdk_draw_text_wc ( - drawable, font, gc, px, y, p, 1); - - if (i == cursor_pos){ - gdk_draw_line ( - drawable, gc, - px, y - font->ascent, - px, y + font->descent - 1); - } - - px += gdk_text_width_wc (font, p, 1); - } - - if (i == cursor_pos){ - gdk_draw_line ( - drawable, gc, - px, y - font->ascent, - px, y + font->descent - 1); - } - } - g_free (text_wc); - } else { - /* - * Regular cell - */ - GdkColor *background, *foreground; - int width; - - /* - * Border - */ - x1++; - x2--; - - /* - * Compute draw mode - */ - switch (ect->justify){ - case GTK_JUSTIFY_LEFT: - xoff = 1; - break; - - case GTK_JUSTIFY_RIGHT: - width = 1 + gdk_text_width (font, str, strlen (str)); - xoff = (x2 - x1) - width; - break; - - case GTK_JUSTIFY_CENTER: - xoff = ((x2 - x1) - gdk_text_width (font, str, strlen (str))) / 2; - break; - default: - xoff = 0; - g_warning ("Can not handle GTK_JUSTIFY_FILL"); - break; - } - - - if (selected){ - background = &w->style->bg [GTK_STATE_SELECTED]; - foreground = &w->style->text [GTK_STATE_SELECTED]; - } else { - background = &w->style->base [GTK_STATE_NORMAL]; - foreground = &w->style->text [GTK_STATE_NORMAL]; - } - - gdk_gc_set_foreground (text_view->gc, background); - gdk_draw_rectangle (drawable, text_view->gc, TRUE, - rect.x, rect.y, rect.width, rect.height); - gdk_gc_set_foreground (text_view->gc, foreground); - - gdk_draw_string ( - drawable, font, text_view->gc, - x1 + xoff, - y2 - font->descent - ((y2-y1-height)/2), str); - } -} - -/* - * Selects the entire string - */ -static void -ect_edit_select_all (ECellTextView *text_view) -{ - g_assert (text_view->edit); - - gtk_editable_select_region (GTK_EDITABLE (text_view->edit->entry), 0, -1); -} - -/* - * ECell::event method - */ -static gint -ect_event (ECellView *ecell_view, GdkEvent *event, int col, int row) -{ - ECellTextView *text_view = (ECellTextView *) ecell_view; - - switch (event->type){ - case GDK_BUTTON_PRESS: - /* - * Adjust for the border we use - */ - event->button.x++; - - printf ("Button pressed at %g %g\n", event->button.x, event->button.y); - if (text_view->edit){ - printf ("FIXME: Should handle click here\n"); - } else - e_table_item_enter_edit (text_view->eti, col, row); - break; - - case GDK_BUTTON_RELEASE: - /* - * Adjust for the border we use - */ - event->button.x++; - printf ("Button released at %g %g\n", event->button.x, event->button.y); - return TRUE; - - case GDK_KEY_PRESS: - if (event->key.keyval == GDK_Escape){ - ect_cancel_edit (text_view); - return TRUE; - } - - if (!text_view->edit){ - e_table_item_enter_edit (text_view->eti, col, row); - ect_edit_select_all (text_view); - } - - gtk_widget_event (GTK_WIDGET (text_view->edit->entry), event); - ect_queue_redraw (text_view, col, row); - break; - - case GDK_KEY_RELEASE: - break; - - default: - return FALSE; - } - return TRUE; -} - -/* - * ECell::height method - */ -static int -ect_height (ECellView *ecell_view, int col, int row) -{ - ECellTextView *text_view = (ECellTextView *) ecell_view; - - return (text_view->font->ascent + text_view->font->descent) + TEXT_PAD; -} - -/* - * Callback: invoked when the user pressed "enter" on the GtkEntry - */ -static void -ect_entry_activate (GtkEntry *entry, ECellTextView *text_view) -{ - e_table_item_leave_edit (text_view->eti); -} - -/* - * ECellView::enter_edit method - */ -static void * -ect_enter_edit (ECellView *ecell_view, int col, int row) -{ - ECellTextView *text_view = (ECellTextView *) ecell_view; - const char *str = e_table_model_value_at (ecell_view->ecell->table_model, col, row); - CellEdit *edit; - - edit = g_new (CellEdit, 1); - text_view->edit = edit; - - edit->col = col; - edit->row = row; - - edit->entry = (GtkEntry *) gtk_entry_new (); - gtk_entry_set_text (edit->entry, str); - edit->old_text = g_strdup (str); - gtk_signal_connect (GTK_OBJECT (edit->entry), "activate", - GTK_SIGNAL_FUNC (ect_entry_activate), text_view); - - /* - * The hack: create this window off-screen - */ - edit->entry_top = gtk_window_new (GTK_WINDOW_POPUP); - gtk_container_add (GTK_CONTAINER (edit->entry_top), GTK_WIDGET (edit->entry)); - gtk_widget_set_uposition (edit->entry_top, 20000, 20000); - gtk_widget_show_all (edit->entry_top); - - ect_queue_redraw (text_view, col, row); - - return NULL; -} - -/* - * ECellView::leave_edit method - */ -static void -ect_leave_edit (ECellView *ecell_view, int col, int row, void *edit_context) -{ - ECellTextView *text_view = (ECellTextView *) ecell_view; - - if (text_view->edit){ - ect_accept_edits (text_view); - ect_stop_editing (text_view); - } else { - /* - * We did invoke this leave edit internally - */ - } -} - -/* - * GtkObject::destroy method - */ -static void -ect_destroy (GtkObject *object) -{ - ECellText *ect = E_CELL_TEXT (object); - - g_free (ect->font_name); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -static void -e_cell_text_class_init (GtkObjectClass *object_class) -{ - ECellClass *ecc = (ECellClass *) object_class; - - object_class->destroy = ect_destroy; - - ecc->realize = ect_realize; - ecc->unrealize = ect_unrealize; - ecc->draw = ect_draw; - ecc->event = ect_event; - ecc->height = ect_height; - ecc->enter_edit = ect_enter_edit; - ecc->leave_edit = ect_leave_edit; - - parent_class = gtk_type_class (PARENT_TYPE); -} - -E_MAKE_TYPE(e_cell_text, "ECellText", ECellText, e_cell_text_class_init, NULL, PARENT_TYPE); - -ECell * -e_cell_text_new (ETableModel *etm, const char *fontname, GtkJustification justify) -{ - ECellText *ect = gtk_type_new (e_cell_text_get_type ()); - - ect->font_name = g_strdup (fontname); - ect->justify = justify; - E_CELL (ect)->table_model = etm; - - return (ECell *) ect; -} diff --git a/widgets/table/e-cell-text.h b/widgets/table/e-cell-text.h deleted file mode 100644 index de9629b97b..0000000000 --- a/widgets/table/e-cell-text.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _E_CELL_TEXT_H_ -#define _E_CELL_TEXT_H_ - -#include <libgnomeui/gnome-canvas.h> -#include "e-cell.h" - -#define E_CELL_TEXT_TYPE (e_cell_text_get_type ()) -#define E_CELL_TEXT(o) (GTK_CHECK_CAST ((o), E_CELL_TEXT_TYPE, ECellText)) -#define E_CELL_TEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TEXT_TYPE, ECellTextClass)) -#define E_IS_CELL_TEXT(o) (GTK_CHECK_TYPE ((o), E_CELL_TEXT_TYPE)) -#define E_IS_CELL_TEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TEXT_TYPE)) - -typedef struct { - ECell parent; - - GtkJustification justify; - char *font_name; -} ECellText; - -typedef struct { - ECellClass parent_class; -} ECellTextClass; - -GtkType e_cell_text_get_type (void); -ECell *e_cell_text_new (ETableModel *model, const char *fontname, GtkJustification justify); - -#endif /* _E_CELL_TEXT_H_ */ - diff --git a/widgets/table/e-cell-toggle.c b/widgets/table/e-cell-toggle.c deleted file mode 100644 index 8e06d8d87d..0000000000 --- a/widgets/table/e-cell-toggle.c +++ /dev/null @@ -1,285 +0,0 @@ -/* - * e-cell-toggle.c: Multi-state image toggle cell object. - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkenums.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtksignal.h> -#include <gdk/gdkkeysyms.h> -#include <libgnomeui/gnome-canvas.h> -#include "e-cell-toggle.h" -#include "e-util.h" -#include "e-table-item.h" - -#define PARENT_TYPE e_cell_get_type() - -typedef struct { - ECellView cell_view; - GdkGC *gc; - GnomeCanvas *canvas; - ETableItem *eti; -} ECellToggleView; - -static ECellClass *parent_class; - -static void -etog_queue_redraw (ECellToggleView *text_view, int col, int row) -{ - e_table_item_redraw_range (text_view->eti, col, row, col, row); -} - -/* - * ECell::realize method - */ -static ECellView * -etog_realize (ECell *ecell, void *view) -{ - ECellToggle *eccb = E_CELL_TOGGLE (ecell); - ECellToggleView *toggle_view = g_new0 (ECellToggleView, 1); - ETableItem *eti = E_TABLE_ITEM (view); - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - - toggle_view->cell_view.ecell = ecell; - toggle_view->eti = eti; - toggle_view->canvas = canvas; - toggle_view->gc = gdk_gc_new (GTK_WIDGET (canvas)->window); - - return (ECellView *) toggle_view; -} - -/* - * ECell::unrealize method - */ -static void -etog_unrealize (ECellView *ecv) -{ - ECellToggleView *toggle_view = (ECellToggleView *) ecv; - - gdk_gc_unref (toggle_view->gc); - toggle_view->gc = NULL; - - g_free (toggle_view); -} - -/* - * ECell::draw method - */ -static void -etog_draw (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, - int x1, int y1, int x2, int y2) -{ - ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell); - ECellToggleView *toggle_view = (ECellToggleView *) ecell_view; - GdkPixbuf *image; - ArtPixBuf *art; - int x, y, width, height; - gboolean free_image; - const int value = GPOINTER_TO_INT ( - e_table_model_value_at (ecell_view->ecell->table_model, col, row)); - - if (value >= toggle->n_states){ - g_warning ("Value from the table model is %d, the states we support are [0..%d)\n", - value, toggle->n_states); - return; - } - - /* - * Paint the background - */ - gdk_draw_rectangle (drawable, GTK_WIDGET (toggle_view->canvas)->style->white_gc, TRUE, x1, y1, x2 - x1, y2 - y1); - - image = toggle->images [value]; - art = image->art_pixbuf; - - if ((x2 - x1) < art->width){ - x = x1; - width = x2 - x1; - } else { - x = x1 + ((x2 - x1) - art->width) / 2; - width = art->width; - } - - if ((y2 - y1) < art->height){ - y = y1; - height = y2 - y1; - } else { - y = y1 + ((y2 - y1) - art->height) / 2; - height = art->height; - } - - width = y2 - y1; - - if (image->art_pixbuf->has_alpha){ - GdkColor background; - guchar *buffer; - int alpha, ix, iy; - - buffer = g_malloc (art->rowstride * art->height * 3); - - background.red = 255; - background.green = 255; - background.blue = 255; - - for (iy = 0; iy < art->height; iy++){ - unsigned char *dest; - unsigned char *src; - - dest = buffer + (iy * art->rowstride); - src = art->pixels + (iy * art->rowstride); - - for (ix = 0; ix < art->width; ix++){ - alpha = src [3]; - if (alpha == 0){ - *dest++ = background.red; - *dest++ = background.green; - *dest++ = background.blue; - src += 3; - } else if (alpha == 255){ - *dest++ = *src++; - *dest++ = *src++; - *dest++ = *src++; - } else { - *dest++ = (background.red + ((*src++ - background.red) * alpha + 0x80)) >> 8; - *dest++ = (background.green + ((*src++ - background.green) * alpha + 0x80)) >> 8; - *dest++ = (background.blue + ((*src++ - background.blue) * alpha + 0x80)) >> 8; - } - src++; - } - } - - gdk_draw_rgb_image_dithalign ( - drawable, toggle_view->gc, x, y, width, height, - GDK_RGB_DITHER_NORMAL, buffer, art->rowstride, 0, 0); - - g_free (buffer); - } else - gdk_draw_rgb_image_dithalign ( - drawable, toggle_view->gc, x, y, width, height, - GDK_RGB_DITHER_NORMAL, art->pixels, art->rowstride, 0, 0); -} - -static void -etog_set_value (ECellToggleView *toggle_view, int col, int row, int value) -{ - ECell *ecell = toggle_view->cell_view.ecell; - ECellToggle *toggle = E_CELL_TOGGLE (ecell); - - if (value >= toggle->n_states) - value = 0; - - e_table_model_set_value_at (ecell->table_model, col, row, GINT_TO_POINTER (value)); - etog_queue_redraw (toggle_view, col, row); -} - -/* - * ECell::event method - */ -static gint -etog_event (ECellView *ecell_view, GdkEvent *event, int col, int row) -{ - ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell); - ECellToggleView *toggle_view = (ECellToggleView *) ecell_view; - void *_value = e_table_model_value_at (ecell_view->ecell->table_model, col, row); - const int value = GPOINTER_TO_INT (_value); - - switch (event->type){ - case GDK_BUTTON_RELEASE: - etog_set_value (toggle_view, col, row, value + 1); - return TRUE; - - case GDK_KEY_PRESS: - if (event->key.keyval == GDK_space){ - etog_set_value (toggle_view, col, row, value + 1); - return TRUE; - } - return FALSE; - - default: - return FALSE; - } - return TRUE; -} - -/* - * ECell::height method - */ -static int -etog_height (ECellView *ecell_view, int col, int row) -{ - ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell); - - return toggle->height; -} - -static void -etog_destroy (GtkObject *object) -{ - ECellToggle *etog = E_CELL_TOGGLE (object); - int i; - - for (i = 0; i < etog->n_states; i++) - gdk_pixbuf_unref (etog->images [i]); - - g_free (etog->images); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -static void -e_cell_toggle_class_init (GtkObjectClass *object_class) -{ - ECellClass *ecc = (ECellClass *) object_class; - - object_class->destroy = etog_destroy; - - ecc->realize = etog_realize; - ecc->unrealize = etog_unrealize; - ecc->draw = etog_draw; - ecc->event = etog_event; - ecc->height = etog_height; - - parent_class = gtk_type_class (PARENT_TYPE); -} - -E_MAKE_TYPE(e_cell_toggle, "ECellToggle", ECellToggle, e_cell_toggle_class_init, NULL, PARENT_TYPE); - -void -e_cell_toggle_construct (ECellToggle *etog, ETableModel *etm, int border, int n_states, GdkPixbuf **images) -{ - int max_height = 0; - int i; - - E_CELL (etog)->table_model = etm; - - etog->border = border; - etog->n_states = n_states; - - etog->images = g_new (GdkPixbuf *, n_states); - - for (i = 0; i < n_states; i++){ - etog->images [i] = images [i]; - gdk_pixbuf_ref (images [i]); - - if (images [i]->art_pixbuf->height > max_height) - max_height = images [i]->art_pixbuf->height; - } - - etog->height = max_height; -} - -ECell * -e_cell_toggle_new (ETableModel *etm, int border, int n_states, GdkPixbuf **images) -{ - ECellToggle *etog = gtk_type_new (e_cell_toggle_get_type ()); - - e_cell_toggle_construct (etog, etm, border, n_states, images); - - return (ECell *) etog; -} diff --git a/widgets/table/e-cell-toggle.h b/widgets/table/e-cell-toggle.h deleted file mode 100644 index 2a5b6adc18..0000000000 --- a/widgets/table/e-cell-toggle.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _E_CELL_TOGGLE_H_ -#define _E_CELL_TOGGLE_H_ - -#include <libgnomeui/gnome-canvas.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include "e-cell.h" - -#define E_CELL_TOGGLE_TYPE (e_cell_toggle_get_type ()) -#define E_CELL_TOGGLE(o) (GTK_CHECK_CAST ((o), E_CELL_TOGGLE_TYPE, ECellToggle)) -#define E_CELL_TOGGLE_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TOGGLE_TYPE, ECellToggleClass)) -#define E_IS_CELL_TOGGLE(o) (GTK_CHECK_TYPE ((o), E_CELL_TOGGLE_TYPE)) -#define E_IS_CELL_TOGGLE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TOGGLE_TYPE)) - -typedef struct { - ECell parent; - - int border; - int n_states; - GdkPixbuf **images; - - int height; -} ECellToggle; - -typedef struct { - ECellClass parent_class; -} ECellToggleClass; - -GtkType e_cell_toggle_get_type (void); -ECell *e_cell_toggle_new (ETableModel *model, int border, - int n_states, - GdkPixbuf **images); -void e_cell_toggle_construct (ECellToggle *etog, ETableModel *etm, - int border, int n_states, GdkPixbuf **images); - -#endif /* _E_CELL_TOGGLE_H_ */ - - diff --git a/widgets/table/e-cell.c b/widgets/table/e-cell.c deleted file mode 100644 index 2bc49f7a45..0000000000 --- a/widgets/table/e-cell.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * e-cell.c: base class for cell renderers in e-table - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include "e-cell.h" -#include "e-util.h" - -#define PARENT_TYPE gtk_object_get_type() - -static ECellView * -ec_realize (ECell *e_cell, void *view) -{ - return NULL; -} - -static void -ec_unrealize (ECellView *e_cell) -{ -} - -static void -ec_draw (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, - int x1, int y1, int x2, int y2) -{ - g_error ("e-cell-draw invoked\n"); -} - -static gint -ec_event (ECellView *ecell_view, GdkEvent *event, int col, int row) -{ - g_error ("e-cell-event invoked\n"); - return 0; -} - -static gint -ec_height (ECellView *ecell_view, int col, int row) -{ - g_error ("e-cell-event invoked\n"); - return 0; -} - -static void -ec_focus (ECellView *ecell_view, int col, int row, int x1, int y1, int x2, int y2) -{ - ecell_view->focus_col = col; - ecell_view->focus_row = row; - ecell_view->focus_x1 = x1; - ecell_view->focus_y1 = y1; - ecell_view->focus_x2 = x2; - ecell_view->focus_y2 = y2; -} - -static void -ec_unfocus (ECellView *ecell_view) -{ - ecell_view->focus_col = -1; - ecell_view->focus_row = -1; - ecell_view->focus_x1 = -1; - ecell_view->focus_y1 = -1; - ecell_view->focus_x2 = -1; - ecell_view->focus_y2 = -1; -} - -static void -e_cell_class_init (GtkObjectClass *object_class) -{ - ECellClass *ecc = (ECellClass *) object_class; - - ecc->realize = ec_realize; - ecc->unrealize = ec_unrealize; - ecc->draw = ec_draw; - ecc->event = ec_event; - ecc->focus = ec_focus; - ecc->unfocus = ec_unfocus; - ecc->height = ec_height; -} - -static void -e_cell_init (GtkObject *object) -{ - ECell *e_cell = E_CELL (object); -} - -E_MAKE_TYPE(e_cell, "ECell", ECell, e_cell_class_init, e_cell_init, PARENT_TYPE); - - -void -e_cell_event (ECellView *ecell_view, GdkEvent *event, int col, int row) -{ - E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->event ( - ecell_view, event, col, row); -} - -ECellView * -e_cell_realize (ECell *ecell, void *view) -{ - return E_CELL_CLASS (GTK_OBJECT (ecell)->klass)->realize ( - ecell, view); -} - -void -e_cell_unrealize (ECellView *ecell_view) -{ - E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->unrealize (ecell_view); -} - -void -e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, int x1, int y1, int x2, int y2) -{ - E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->draw ( - ecell_view, drawable, col, row, selected, x1, y1, x2, y2); -} - -int -e_cell_height (ECellView *ecell_view, int col, int row) -{ - return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->height ( - ecell_view, col, row); -} - -void * -e_cell_enter_edit (ECellView *ecell_view, int col, int row) -{ - return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->enter_edit ( - ecell_view, col, row); -} - -void -e_cell_leave_edit (ECellView *ecell_view, int col, int row, void *edit_context) -{ - E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->leave_edit ( - ecell_view, col, row, edit_context); -} diff --git a/widgets/table/e-cell.h b/widgets/table/e-cell.h deleted file mode 100644 index b0f62d020c..0000000000 --- a/widgets/table/e-cell.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _E_CELL_H_ -#define _E_CELL_H_ - -#include <gdk/gdktypes.h> -#include "e-table-model.h" - -#define E_CELL_TYPE (e_cell_get_type ()) -#define E_CELL(o) (GTK_CHECK_CAST ((o), E_CELL_TYPE, ECell)) -#define E_CELL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CELL_TYPE, ECellClass)) -#define E_IS_CELL(o) (GTK_CHECK_TYPE ((o), E_CELL_TYPE)) -#define E_IS_CELL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CELL_TYPE)) - -typedef struct _ECell ECell; -typedef struct _ECellView ECellView; - -struct _ECell { - GtkObject object; - ETableModel *table_model; -}; - -struct _ECellView { - ECell *ecell; - gint focus_x1, focus_y1, focus_x2, focus_y2; - gint focus_col, focus_row; -}; - -#define E_CELL_IS_FOCUSED(ecell_view) (ecell_view->focus_x1 != -1) - -typedef struct { - GtkObjectClass parent_class; - - ECellView *(*realize) (ECell *ecell, void *view); - void (*unrealize) (ECellView *e_cell_view); - void (*draw) (ECellView *ecell_view, GdkDrawable *drawable, - int col, int row, gboolean selected, int x1, int y1, int x2, int y2); - gint (*event) (ECellView *ecell_view, GdkEvent *event, int col, int row); - void (*focus) (ECellView *ecell_view, int col, int row, int x1, int y1, int x2, int y2); - void (*unfocus) (ECellView *ecell_view); - int (*height) (ECellView *ecell_view, int col, int row); - - void *(*enter_edit)(ECellView *ecell_view, int col, int row); - void (*leave_edit)(ECellView *ecell_view, int col, int row, void *context); -} ECellClass; - -GtkType e_cell_get_type (void); -void e_cell_event (ECellView *ecell_view, GdkEvent *event, int col, int row); -ECellView *e_cell_realize (ECell *ecell, void *view); -void e_cell_unrealize (ECellView *ecell_view); -void e_cell_draw (ECellView *ecell_view, GdkDrawable *dr, - int col, int row, gboolean selected, - int x1, int y1, int x2, int y2); -void e_cell_focus (ECellView *ecell_view, int col, int row, int x1, int y1, int x2, int y2); -void e_cell_unfocus (ECellView *ecell_view); -int e_cell_height (ECellView *ecell_view, int col, int row); - -void *e_cell_enter_edit(ECellView *ecell_view, int col, int row); -void e_cell_leave_edit(ECellView *ecell_view, int col, int row, void *edit_context); - -#endif /* _E_CELL_H_ */ diff --git a/widgets/table/e-table-col.c b/widgets/table/e-table-col.c deleted file mode 100644 index cca7bd13d6..0000000000 --- a/widgets/table/e-table-col.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * E-table-col.c: ETableCol implementation - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkobject.h> -#include <gtk/gtksignal.h> -#include "e-table-col.h" -#include "e-util.h" - -#define PARENT_TYPE (gtk_object_get_type ()) - -static GtkObjectClass *parent_class; - -static void -etc_destroy (GtkObject *object) -{ - ETableCol *etc = E_TABLE_COL (object); - - printf ("Destroying columns: %s %s\n", etc->id, etc->text); - g_free (etc->id); - g_free (etc->text); - - (*parent_class->destroy)(object); -} - -static void -e_table_col_class_init (GtkObjectClass *object_class) -{ - parent_class = gtk_type_class (PARENT_TYPE); - object_class->destroy = etc_destroy; -} - -E_MAKE_TYPE(e_table_col, "ETableCol", ETableCol, e_table_col_class_init, NULL, PARENT_TYPE); - -ETableCol * -e_table_col_new (const char *id, const char *text, int width, int min_width, - ECell *ecell, GCompareFunc compare, gboolean resizable) -{ - ETableCol *etc; - - g_return_val_if_fail (id != NULL, NULL); - g_return_val_if_fail (width >= 0, NULL); - g_return_val_if_fail (min_width >= 0, NULL); - g_return_val_if_fail (width >= min_width, NULL); - g_return_val_if_fail (compare != NULL, NULL); - - etc = gtk_type_new (E_TABLE_COL_TYPE); - - etc->id = g_strdup (id); - etc->text = g_strdup (text); - etc->width = width; - etc->min_width = min_width; - etc->ecell = ecell; - etc->compare = compare; - - etc->selected = 0; - etc->resizeable = resizable; - - return etc; -} - - diff --git a/widgets/table/e-table-col.h b/widgets/table/e-table-col.h deleted file mode 100644 index c8fa6dd581..0000000000 --- a/widgets/table/e-table-col.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _E_TABLE_COL_H_ -#define _E_TABLE_COL_H_ - -#include "e-cell.h" - -#define E_TABLE_COL_TYPE (e_table_col_get_type ()) -#define E_TABLE_COL(o) (GTK_CHECK_CAST ((o), E_TABLE_COL_TYPE, ETableCol)) -#define E_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_COL_TYPE, ETableColClass)) -#define E_IS_TABLE_COL(o) (GTK_CHECK_TYPE ((o), E_TABLE_COL_TYPE)) -#define E_IS_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_COL_TYPE)) - -typedef struct _ETableCol ETableCol; - -/* - * Information about a single column - */ -struct _ETableCol { - GtkObject base; - char *id, *text; - short width; - short min_width; - short x; - GCompareFunc compare; - unsigned int selected:1; - unsigned int resizeable:1; - - - ECell *ecell; -}; - -typedef struct { - GtkObjectClass parent_class; -} ETableColClass; - -GtkType e_table_col_get_type (void); -ETableCol *e_table_col_new (const char *id, const char *text, - int width, int min_width, - ECell *ecell, GCompareFunc compare, - gboolean resizable); -void e_table_col_destroy (ETableCol *etc); - - -#endif /* _E_TABLE_COL_H_ */ - diff --git a/widgets/table/e-table-column-item.c b/widgets/table/e-table-column-item.c deleted file mode 100644 index 0616327a93..0000000000 --- a/widgets/table/e-table-column-item.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * E-table-column-view.c: A canvas view of the TableColumn. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc. - */ -#include <config.h> -#include "e-table-column.h" -#include "e-table-column-view.h" - -#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type () - -static GnomeCanvasItemClass *etci_parent_class; - -enum { - ARG_0, - ARG_TABLE_COLUMN -}; - -static void -etci_destroy (GtkObject *object) -{ - ETableColumnItem *etcv = E_TABLE_COLUMN_VIEW (object); - - gtk_object_unref (GTK_OBJECT (etcv)); - - if (GTK_OBJECT_CLASS (etcv_parent_class)->destroy) - (*GTK_OBJECT_CLASS (etcv_parent_class)->destroy) (object); -} - -static void -etci_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) -{ - if (GNOME_CANVAS_ITEM_CLASS(item_bar_parent_class)->update) - (*GNOME_CANVAS_ITEM_CLASS(item_bar_parent_class)->update)(item, affine, clip_path, flags); - - item->x1 = 0; - item->y1 = 0; - item->x2 = INT_MAX; - item->y2 = INT_MAX; - gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item); -} - -static void -etci_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ETableColumnItem *etci; - int v; - - item = GNOME_CANVAS_ITEM (o); - etci = E_TABLE_COLUMN_ITEM (o); - - switch (arg_id){ - case ARG_TABLE_COLUMN: - etci->etci = GTK_VALUE_POINTER (*arg); - break; - } - etci_update (item, NULL, NULL, 0); -} - -static void -etci_realize (GnomeCanvasItem *item) -{ - ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item); - GdkWindow *window; - GdkColor c; - - if (GNOME_CANVAS_ITEM_CLASS (etci_parent_class)-> realize) - (*GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->realize)(item); - - window = GTK_WIDGET (item->canvas)->window; - - etci->gc = gdk_gc_new (window); - gnome_canvas_get_color (item->canvas, "black", &c); - gdk_gc_set_foreground (etci->gc, &c); - - etci->normal_cursor = gdk_cursor_new (GDK_ARROW); -} - -static void -etci_unrealize (GnomeCanvasItem *item) -{ - ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item); - - gdk_gc_unref (etci->gc); - etci->gc = NULL; - - gdk_cursor_destroy (etci->change_cursor); - etci->change_cursor = NULL; - - gdk_cursor_destroy (etci->normal_cursor); - etci->normal_cursor = NULL; - - if (GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->unrealize) - (*GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->unrealize)(item); -} - -static void -etci_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x1, int y1, int width, int height) -{ - ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item); - GnomeCanvas *canvas = item->canvas; - GdkGC *gc; - const int cols = e_table_column_count (etci->etc); - int x2 = x1 + width; - int col, total; - - total = 0; - for (col = 0; col < cols; col++){ - ETableCol *col = e_table_column_get_column (etci->etc, col); - const int col_width = col->width; - - if (x1 > total + col_width) - continue; - - if (x2 < total) - return; - - gc = canvas->style->bg_gc [GTK_STATE_ACTIVE]; - gdk_draw_rectangle (drawble, gc, TRUE, - gtk_draw_shadow (canvas->style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT, - x, y, width, height - } -} - -static double -etci_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = *item; - return 0.0; -} - -static void -etci_event (GnomeCanvasItem *item, GdkEvent *e) -{ - switch (e->type){ - default: - return FALSE; - } - return TRUE; -} - -static void -etci_class_init (GtkObjectClass *object_class) -{ - GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class; - - object_class->destroy = etci_destroy; - object_class->set_arg = etci_set_arg; - - item_class->update = etci_update; - item_class->realize = etci_realize; - item_class->unrealize = etci_unrealize; - item_class->draw = etci_draw; - item_class->point = etci_point; - item_class->event = etci_event; - - gtk_object_add_arg_type ("ETableColumnItem::ETableColumn", GTK_TYPE_POINTER, - GTK_ARG_WRITABLE, ARG_TABLE_COLUMN); -} - -static void -etci_init (GnomeCanvasItem *item) -{ - item->x1 = 0; - item->y1 = 0; - item->x2 = 0; - item->y2 = 0; -} - -GtkType -e_table_column_view_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableColumnItem", - sizeof (ETableColumnItem), - sizeof (ETableColumnItemClass), - (GtkClassInitFunc) etci_class_init, - (GtkObjectInitFunc) etci_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_OBJECT_TYPE, &info); - } - - return type; -} - - - diff --git a/widgets/table/e-table-column-item.h b/widgets/table/e-table-column-item.h deleted file mode 100644 index fd38681a73..0000000000 --- a/widgets/table/e-table-column-item.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _E_TABLE_COLUMN_VIEW_H -#defein _E_TABLE_COLUMN_VIEW_H - -#include "e-table-column.h" - -typedef struct { - GnomeCanvasItem parent; - ETableColumn *etc; - - GdkGC *gc; - GdkCursor *change_cursor, *normal_cursor; -} ETableColumnView; - -typedef struct { - GnomeCanvasItemClass parent_class; -} ETableColumnViewClass; - -GtkType e_table_column_item_get_type (void); - -#endif /* _E_TABLE_COLUMN_VIEW_H */ diff --git a/widgets/table/e-table-column-model.h b/widgets/table/e-table-column-model.h deleted file mode 100644 index 043dd783ca..0000000000 --- a/widgets/table/e-table-column-model.h +++ /dev/null @@ -1,5 +0,0 @@ - -class ETableColumnModel { - virtual void add_column (ETableCol *et) = 0; - virtual ETableCol *get_column (int column); - virtual diff --git a/widgets/table/e-table-column.c b/widgets/table/e-table-column.c deleted file mode 100644 index d17a285321..0000000000 --- a/widgets/table/e-table-column.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * e-table-column.c: TableColumn implementation - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include "e-table-column.h" - -enum { - STRUCTURE_CHANGE, - DIMENSION_CHANGE, - LAST_SIGNAL -}; - -static guint etc_signals [LAST_SIGNAL] = { 0, }; - -static GtkObjectClass *e_table_column_parent_class; - -static void -e_table_column_destroy (GtkObject *object) -{ - ETableColumn *etc = E_TABLE_COLUMN (object); - const int cols = etc->col_count; - - /* - * Destroy listeners - */ - for (l = etc->listeners; l; l = l->next) - g_free (l->data); - g_slist_free (etc->listeners); - etc->listeners = NULL; - - /* - * Destroy columns - */ - for (i = 0; i < cols; i++) - e_table_column_remove (etc, i); - - if (e_table_column_parent_class->destroy) - e_table_column_parent_class->destroy (object); -} - -static void -e_table_column_class_init (GtkObjectClass *object_class) -{ - object_class->destroy = e_table_column_destroy; - - e_table_column_parent_class = (gtk_type_class (gtk_object_get_type ())); - - etc_signals [STRUCTURE_CHANGE] = - gtk_signal_new ("structure_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableColumn, structure_change), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - etc_signals [DIMENSION_CHANGE] = - gtk_signal_new ("dimension_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableColumn, dimension_change), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, etc_signals, LAST_SIGNAL); -} - -GtkType -e_table_column_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableColumn", - sizeof (ETableColumn), - sizeof (ETableColumnClass), - (GtkClassInitFunc) e_table_column_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - -static void -etc_do_insert (ETableColumn *etc, int pos, ETableCol *val) -{ - memcpy (&etc->columns [pos+1], &etc->columns [pos], - sizeof (ETableCol *) * (etc->col_count - pos)); - etc->columns [pos] = val; -} - -void -e_table_column_add_column (ETableColumn *etc, ETableCol *tc, int pos) -{ - ETableCol **new_ptr; - - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (tc != NULL); - g_return_if_fail (pos >= 0 && pos < etc->col_count); - - if (pos == -1) - pos = etc->col_count; - etc->columns = g_realloc (etc->columns, sizeof (ETableCol *) * (etc->col_count + 1)); - etc_do_insert (etc, pos, tc); - etc->col_count++; - - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]); -} - -ETableCol * -e_table_column_get_column (ETableColumn *etc, int column) -{ - g_return_val_if_fail (etc != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), NULL); - - if (column < 0) - return NULL; - - if (column >= etc->col_count) - return NULL; - - return etc->columns [column]; -} - -int -e_table_column_count (ETableColumn *etc) -{ - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - return etc->col_count; -} - -int -e_table_column_index (ETableColumn *etc, const char *identifier) -{ - int i; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - g_return_val_if_fail (identifier != NULL, 0); - - for (i = 0; i < etc->col_count; i++){ - ETableCol *tc = etc->columns [i]; - - if (strcmp (i->id, identifier) == 0) - return i; - } - - return -1; -} - -int -e_table_column_get_index_at (ETableColumn *etc, int x_offset) -{ - int i, total; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - g_return_val_if_fail (identifier != NULL, 0); - - total = 0; - for (i = 0; i < etc->col_count; i++){ - total += etc->columns [i]->width; - - if (x_offset < total) - return i; - } - - return -1; -} - -ETableCol ** -e_table_column_get_columns (ETableColumn *etc) -{ - ETableCol **ret; - int i; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - ret = g_new (ETableCol *, etc->col_count + 1); - memcpy (ret, etc->columns, sizeof (ETableCol *) * etc->col_count); - ret [etc->col_count] = NULL; - - return ret; -} - -gboolean -e_table_column_selection_ok (ETableColumn *etc) -{ - g_return_val_if_fail (etc != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), FALSE); - - return etc->selectable; -} - -int -ve_table_column_get_selected (ETableColumn *etc) -{ - int i; - int selected = 0; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - for (i = 0; i < etc->col_count; i++){ - if (etc->columns [i]->selected) - selected++; - } - - return selected; -} - -int -e_table_column_total_width (ETableColumn *etc) -{ - int total; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - total = 0; - for (i = 0; i < etc->col_count; i++) - total += etc->columns [i].width; - - return total; -} - -static void -etc_do_remove (ETableColumn *etc, int idx) -{ - memcpy (&etc->columns [idx], &etc->columns [idx+1], - sizeof (ETableCol *) * etc->col_count - idx); - etc->col_count--; -} - -void -e_table_column_move (ETableColumn *etc, int source_index, int target_index) -{ - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (source_index >= 0); - g_return_if_fail (target_index >= 0); - g_return_if_fail (source_index < etc->col_count); - g_return_if_fail (target_index < etc->col_count); - - old = etc->columns [source_index]; - etc_do_remove (etc, source_index); - etc_do_insert (etc, target_index, old); - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]); -} - -void -e_table_column_remove (ETableColumn *etc, int idx) -{ - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < etc->col_count); - - etc_do_remove (etc, idx); - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]); -} - -void -e_table_column_set_selection (ETableColumn *etc, gboolean allow_selection); -{ -} - -void -e_table_column_set_size (ETableColumn *etc, int idx, int size) -{ - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < etc->col_count); - g_return_if_fail (size > 0); - - etc->columns [idx]->width = size; - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [SIZE_CHANGE], idx); -} diff --git a/widgets/table/e-table-group.c b/widgets/table/e-table-group.c deleted file mode 100644 index b1e681d255..0000000000 --- a/widgets/table/e-table-group.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * E-Table-Group.c: Implements the grouping objects for elements on a table - * - * Author: - * Miguel de Icaza (miguel@gnu.org() - * - * Copyright 1999, Helix Code, Inc. - */ - -#include <config.h> -#include "e-table-group.h" - -void -e_table_group_destroy (ETableGroup *etg) -{ - g_return_if_fail (etg != NULL); - - g_free (etg->title); - - if (etg->is_leaf == 0){ - GSList *l; - - for (l = etg->u.children; l; l = l->next){ - ETableGroup *child = l->data; - - e_table_group_destroy (child); - } - g_slist_free (etg->u.children); - etg->u.children = NULL; - } - g_free (etg); -} - -ETableGroup * -e_table_group_new_leaf (const char *title, ETableModel *table) -{ - ETableGroup *etg; - - g_return_val_if_fail (title != NULL, NULL); - g_return_val_if_fail (table != NULL, NULL); - - etg = g_new (ETableGroup, 1); - - etg->expanded = 0; - etg->is_leaf = 1; - etg->u.table = table; - etg->title = g_strdup (title); - - return etg; -} - -ETableGroup * -e_table_group_new (const char *title) -{ - ETableGroup *etg; - - g_return_val_if_fail (title != NULL, NULL); - - etg = g_new (ETableGroup, 1); - - etg->expanded = 0; - etg->is_leaf = 0; - etg->u.children = NULL; - etg->title = g_strdup (title); - - return etg; -} - -void -e_table_group_append_child (ETableGroup *etg, ETableGroup *child) -{ - g_return_if_fail (etg != NULL); - g_return_if_fail (child != NULL); - g_return_if_fail (etg->is_leaf != 0); - - etg->u.children = g_slist_append (etg->u.children, child); -} - -#if 0 -int -e_table_group_size (ETableGroup *etg) -{ - g_return_val_if_fail (etg != NULL, 0); - - if (etg->is_leaf) - return e_table_model_height (etg->u.table); - else { - GSList *l; - int size = 0; - - for (l = etg->u.children; l; l = l->next){ - ETableGroup *child = l->data; - - size += e_table_group_size (child); - } - return size; - } -} - -#endif diff --git a/widgets/table/e-table-group.h b/widgets/table/e-table-group.h deleted file mode 100644 index d673aebd11..0000000000 --- a/widgets/table/e-table-group.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _E_TABLE_TREE_H_ -#define _E_TABLE_TREE_H_ - -#include "e-table-model.h" - -typedef struct { - char *title; - - union { - ETableModel *table; - GSList *children; - } u; - - guint expanded :1; - guint is_leaf :1; -} ETableGroup; - -ETableGroup *e_table_group_new (const char *title); -ETableGroup *e_table_group_new_leaf (const char *title, ETableModel *table); -void e_table_group_destroy (ETableGroup *etg); - -int e_table_group_size (ETableGroup *egroup); -void e_table_group_append_child (ETableGroup *etg, ETableGroup *child); - -#endif /* _E_TABLE_TREE_H_ */ diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c deleted file mode 100644 index 378bdf4447..0000000000 --- a/widgets/table/e-table-header-item.c +++ /dev/null @@ -1,527 +0,0 @@ -/* - * E-table-column-view.c: A canvas item based view of the ETableColumn. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc. - */ -#include <config.h> -#include <gtk/gtksignal.h> -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-cursors.h" - -/* Padding above and below of the string in the header display */ -#define PADDING 4 - -/* Defines the tolerance for proximity of the column division to the cursor position */ -#define TOLERANCE 2 - -#define ETHI_RESIZING(x) ((x)->resize_col != -1) - -#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type () - -static GnomeCanvasItemClass *ethi_parent_class; - -enum { - ARG_0, - ARG_TABLE_HEADER, - ARG_TABLE_X, - ARG_TABLE_Y, - ARG_TABLE_FONTSET -}; - -static void -ethi_destroy (GtkObject *object) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (object); - - gtk_object_unref (GTK_OBJECT (ethi->eth)); - - if (GTK_OBJECT_CLASS (ethi_parent_class)->destroy) - (*GTK_OBJECT_CLASS (ethi_parent_class)->destroy) (object); -} - -static void -ethi_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - - if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update) - (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update)(item, affine, clip_path, flags); - - item->x1 = ethi->x1; - item->y1 = ethi->y1; - item->x2 = ethi->x1 + ethi->width; - item->y2 = ethi->y1 + ethi->height; - - gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item); -} - -static void -ethi_font_load (ETableHeaderItem *ethi, char *font) -{ - if (ethi->font) - gdk_font_unref (ethi->font); - - ethi->font = gdk_fontset_load (font); - if (ethi->font == NULL) - ethi->font = gdk_font_load ("fixed"); - - ethi->height = ethi->font->ascent + ethi->font->descent + PADDING; -} - -static void -ethi_drop_table_header (ETableHeaderItem *ethi) -{ - GtkObject *header; - - if (!ethi->eth) - return; - - header = GTK_OBJECT (ethi->eth); - gtk_signal_disconnect (header, ethi->structure_change_id); - gtk_signal_disconnect (header, ethi->dimension_change_id); - - gtk_object_unref (header); - ethi->eth = NULL; - ethi->width = 0; -} - -static void -structure_changed (ETableHeader *header, ETableHeaderItem *ethi) -{ - ethi->width = e_table_header_total_width (header); - - ethi_update (GNOME_CANVAS_ITEM (ethi), NULL, NULL, 0); -} - -static void -dimension_changed (ETableHeader *header, int col, ETableHeaderItem *ethi) -{ - ethi->width = e_table_header_total_width (header); - - ethi_update (GNOME_CANVAS_ITEM (ethi), NULL, NULL, 0); -} - -static void -ethi_add_table_header (ETableHeaderItem *ethi, ETableHeader *header) -{ - ethi->eth = header; - gtk_object_ref (GTK_OBJECT (ethi->eth)); - ethi->width = e_table_header_total_width (header); - - ethi->structure_change_id = gtk_signal_connect ( - GTK_OBJECT (header), "structure_change", - GTK_SIGNAL_FUNC(structure_changed), ethi); - ethi->dimension_change_id = gtk_signal_connect ( - GTK_OBJECT (header), "dimension_change", - GTK_SIGNAL_FUNC(dimension_changed), ethi); -} - -static void -ethi_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ETableHeaderItem *ethi; - - item = GNOME_CANVAS_ITEM (o); - ethi = E_TABLE_HEADER_ITEM (o); - - switch (arg_id){ - case ARG_TABLE_HEADER: - ethi_drop_table_header (ethi); - ethi_add_table_header (ethi, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_TABLE_X: - ethi->x1 = GTK_VALUE_INT (*arg); - break; - - case ARG_TABLE_Y: - ethi->y1 = GTK_VALUE_INT (*arg); - break; - - case ARG_TABLE_FONTSET: - ethi_font_load (ethi, GTK_VALUE_STRING (*arg)); - break; - - } - ethi_update (item, NULL, NULL, 0); -} - -static void -ethi_realize (GnomeCanvasItem *item) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - GdkWindow *window; - GdkColor c; - - if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)-> realize) - (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->realize)(item); - - window = GTK_WIDGET (item->canvas)->window; - - ethi->gc = gdk_gc_new (window); - gnome_canvas_get_color (item->canvas, "black", &c); - gdk_gc_set_foreground (ethi->gc, &c); - - ethi->normal_cursor = gdk_cursor_new (GDK_ARROW); - - if (!ethi->font) - ethi_font_load (ethi, "fixed"); -} - -static void -ethi_unrealize (GnomeCanvasItem *item) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - - gdk_gc_unref (ethi->gc); - ethi->gc = NULL; - - gdk_cursor_destroy (ethi->normal_cursor); - ethi->normal_cursor = NULL; - - if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->unrealize) - (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->unrealize)(item); -} - -static void -draw_button (ETableHeaderItem *ethi, ETableCol *col, - GdkDrawable *drawable, GdkGC *gc, GtkStyle *style, - int x, int y, int width, int height) -{ - GdkRectangle clip; - int xtra; - - gdk_draw_rectangle ( - drawable, gc, TRUE, - x + 1, y + 1, width - 2, height -2); - - gtk_draw_shadow ( - style, drawable, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - x , y, width, height); - - clip.x = x + 2; - clip.y = y + 2; - clip.width = width - 4; - clip.height = ethi->height; - - gdk_gc_set_clip_rectangle (ethi->gc, &clip); - - /* Center the thing */ - xtra = (clip.width - gdk_string_measure (ethi->font, col->id))/2; - - if (xtra < 0) - xtra = 0; - - /* Skip over border */ - x += xtra + 2; - - gdk_draw_text ( - drawable, ethi->font, - ethi->gc, x, y + ethi->height - PADDING, - col->id, strlen (col->id)); -} - -static void -ethi_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x1, int y1, int width, int height) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - GnomeCanvas *canvas = item->canvas; - GdkGC *gc; - const int cols = e_table_header_count (ethi->eth); - int x2 = x1 + width; - int col, total; - int x; - - total = 0; - x = -x1; - -#if 0 - printf ("My coords are: %g %g %g %g\n", - item->x1, item->y1, item->x2, item->y2); -#endif - - for (col = 0; col < cols; col++){ - ETableCol *ecol = e_table_header_get_column (ethi->eth, col); - int col_width; - - if (col == ethi->resize_col) - col_width = ethi->resize_width; - else - col_width = ecol->width; - - if (x1 > total + col_width){ - total += col_width; - x += col_width; - continue; - } - - if (x2 < total) - return; - - gc = GTK_WIDGET (canvas)->style->bg_gc [GTK_STATE_ACTIVE]; - - draw_button (ethi, ecol, drawable, gc, - GTK_WIDGET (canvas)->style, - x, ethi->y1 - y1, col_width, ethi->height); - - x += col_width; - total += col_width; - } -} - -static double -ethi_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - -/* - * is_pointer_on_division: - * - * Returns whether @pos is a column header division; If @the_total is not NULL, - * then the actual position is returned here. If @return_ecol is not NULL, - * then the ETableCol that actually contains this point is returned here - */ -static gboolean -is_pointer_on_division (ETableHeaderItem *ethi, int pos, int *the_total, int *return_col) -{ - const int cols = e_table_header_count (ethi->eth); - int col, total; - - total = 0; - for (col = 0; col < cols; col++){ - ETableCol *ecol = e_table_header_get_column (ethi->eth, col); - - total += ecol->width; - - if ((total - TOLERANCE < pos ) && (pos < total + TOLERANCE)){ - if (return_col) - *return_col = col; - if (the_total) - *the_total = total; - - return TRUE; - } - - if (total > pos + TOLERANCE) - return FALSE; - } - - return FALSE; -} - -#define convert(c,sx,sy,x,y) gnome_canvas_w2c (c,sx,sy,x,y) - -static void -set_cursor (ETableHeaderItem *ethi, int pos) -{ - GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (ethi)->canvas); - - /* We might be invoked before we are realized */ - if (!canvas->window) - return; - - if (is_pointer_on_division (ethi, pos, NULL, NULL)) - e_cursor_set (canvas->window, E_CURSOR_SIZE_X); - else - e_cursor_set (canvas->window, E_CURSOR_ARROW); -} - -static void -ethi_request_redraw (ETableHeaderItem *ethi) -{ - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (ethi)->canvas; - - /* - * request a redraw - */ - gnome_canvas_request_redraw ( - canvas, ethi->x1, ethi->y1, ethi->x1 + ethi->width, ethi->x1 + ethi->height); -} - -static void -ethi_end_resize (ETableHeaderItem *ethi, int new_size) -{ - e_table_header_set_size (ethi->eth, ethi->resize_col, new_size); - - ethi->resize_col = -1; - ethi_request_redraw (ethi); -} - -/* - * Handles the events on the ETableHeaderItem, particularly it handles resizing - */ -static int -ethi_event (GnomeCanvasItem *item, GdkEvent *e) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - GnomeCanvas *canvas = item->canvas; - const gboolean resizing = ETHI_RESIZING (ethi); - int x, y, start, col; - - switch (e->type){ - case GDK_ENTER_NOTIFY: - convert (canvas, e->crossing.x, e->crossing.y, &x, &y); - set_cursor (ethi, x); - break; - - case GDK_LEAVE_NOTIFY: - e_cursor_set (GTK_WIDGET (canvas)->window, E_CURSOR_ARROW); - break; - - case GDK_MOTION_NOTIFY: - convert (canvas, e->motion.x, e->motion.y, &x, &y); - if (resizing){ - int new_width; - - if (ethi->resize_guide == NULL){ - /* Quick hack until I actually bind the views */ - ethi->resize_guide = GINT_TO_POINTER (1); - gnome_canvas_item_grab (item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK, - e_cursor_get (E_CURSOR_SIZE_X), - e->button.time); - } - - new_width = x - ethi->resize_start_pos; - if (new_width <= 0) - break; - - if (new_width < ethi->resize_min_width) - break; - - ethi_request_redraw (ethi); - - ethi->resize_width = new_width; - e_table_header_set_size (ethi->eth, ethi->resize_col, ethi->resize_width); - - ethi_request_redraw (ethi); - } else - set_cursor (ethi, x); - break; - - case GDK_BUTTON_PRESS: - convert (canvas, e->button.x, e->button.y, &x, &y); - - if (is_pointer_on_division (ethi, x, &start, &col)){ - ETableCol *ecol; - - /* - * Record the important bits. - * - * By setting resize_pos to a non -1 value, - * we know that we are being resized (used in the - * other event handlers). - */ - ecol = e_table_header_get_column (ethi->eth, col); - - if (!ecol->resizeable) - break; - ethi->resize_col = col; - ethi->resize_width = ecol->width; - ethi->resize_start_pos = start - ecol->width; - ethi->resize_min_width = ecol->min_width; - } - break; - - case GDK_2BUTTON_PRESS: - if (!resizing) - break; - - if (e->button.button != 1) - break; - - printf ("Resize this guy\n"); - break; - - case GDK_BUTTON_RELEASE: { - gboolean needs_ungrab = FALSE; - - if (ethi->resize_col != -1){ - needs_ungrab = (ethi->resize_guide != NULL); - ethi_end_resize (ethi, ethi->resize_width); - } - if (needs_ungrab) - gnome_canvas_item_ungrab (item, e->button.time); - - break; - } - - default: - return FALSE; - } - return TRUE; -} - -static void -ethi_class_init (GtkObjectClass *object_class) -{ - GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class; - - ethi_parent_class = gtk_type_class (PARENT_OBJECT_TYPE); - - object_class->destroy = ethi_destroy; - object_class->set_arg = ethi_set_arg; - - item_class->update = ethi_update; - item_class->realize = ethi_realize; - item_class->unrealize = ethi_unrealize; - item_class->draw = ethi_draw; - item_class->point = ethi_point; - item_class->event = ethi_event; - - gtk_object_add_arg_type ("ETableHeaderItem::ETableHeader", GTK_TYPE_POINTER, - GTK_ARG_WRITABLE, ARG_TABLE_HEADER); - gtk_object_add_arg_type ("ETableHeaderItem::x", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_TABLE_X); - gtk_object_add_arg_type ("ETableHeaderItem::y", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_TABLE_Y); - gtk_object_add_arg_type ("ETableHeaderItem::fontset", GTK_TYPE_STRING, - GTK_ARG_WRITABLE, ARG_TABLE_FONTSET); -} - -static void -ethi_init (GnomeCanvasItem *item) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - - ethi->resize_col = -1; - - item->x1 = 0; - item->y1 = 0; - item->x2 = 0; - item->y2 = 0; -} - -GtkType -e_table_header_item_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableHeaderItem", - sizeof (ETableHeaderItem), - sizeof (ETableHeaderItemClass), - (GtkClassInitFunc) ethi_class_init, - (GtkObjectInitFunc) ethi_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_OBJECT_TYPE, &info); - } - - return type; -} - diff --git a/widgets/table/e-table-header-item.h b/widgets/table/e-table-header-item.h deleted file mode 100644 index ea2082018f..0000000000 --- a/widgets/table/e-table-header-item.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _E_TABLE_HEADER_ITEM_H_ -#define _E_TABLE_HEADER_ITEM_H_ - -#include <libgnomeui/gnome-canvas.h> -#include "e-table-header.h" - -#define E_TABLE_HEADER_ITEM_TYPE (e_table_header_item_get_type ()) -#define E_TABLE_HEADER_ITEM(o) (GTK_CHECK_CAST ((o), E_TABLE_HEADER_ITEM_TYPE, ETableHeaderItem)) -#define E_TABLE_HEADER_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_HEADER_ITEM_TYPE, ETableHeaderItemClass)) -#define E_IS_TABLE_HEADER_ITEM(o) (GTK_CHECK_TYPE ((o), E_TABLE_HEADER_ITEM_TYPE)) -#define E_IS_TABLE_HEADER_ITEM_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_HEADER_ITEM_TYPE)) - -typedef struct { - GnomeCanvasItem parent; - ETableHeader *eth; - - GdkGC *gc; - GdkCursor *change_cursor, *normal_cursor; - - short x1, y1, height, width; - GdkFont *font; - - /* - * Used during resizing; Could be shorts - */ - int resize_col; - int resize_width; - int resize_start_pos; - int resize_min_width; - - GtkObject *resize_guide; - - /* - * Ids - */ - int structure_change_id, dimension_change_id; -} ETableHeaderItem; - -typedef struct { - GnomeCanvasItemClass parent_class; -} ETableHeaderItemClass; - -GtkType e_table_header_item_get_type (void); - -#endif /* _E_TABLE_HEADER_ITEM_H_ */ diff --git a/widgets/table/e-table-header.c b/widgets/table/e-table-header.c deleted file mode 100644 index e91113bbb9..0000000000 --- a/widgets/table/e-table-header.c +++ /dev/null @@ -1,325 +0,0 @@ -/* - * E-table-col-head.c: TableColHead implementation - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc - */ -#include <config.h> -#include <gtk/gtkobject.h> -#include <gtk/gtksignal.h> -#include "e-table-header.h" - -enum { - STRUCTURE_CHANGE, - DIMENSION_CHANGE, - LAST_SIGNAL -}; - -static guint eth_signals [LAST_SIGNAL] = { 0, }; - -static GtkObjectClass *e_table_header_parent_class; - -static void -e_table_header_destroy (GtkObject *object) -{ - ETableHeader *eth = E_TABLE_HEADER (object); - const int cols = eth->col_count; - int i; - - /* - * Destroy columns - */ - for (i = 0; i < cols; i++){ - e_table_header_remove (eth, i); - } - - if (e_table_header_parent_class->destroy) - e_table_header_parent_class->destroy (object); -} - -static void -e_table_header_class_init (GtkObjectClass *object_class) -{ - object_class->destroy = e_table_header_destroy; - - e_table_header_parent_class = (gtk_type_class (gtk_object_get_type ())); - - eth_signals [STRUCTURE_CHANGE] = - gtk_signal_new ("structure_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableHeaderClass, structure_change), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - eth_signals [DIMENSION_CHANGE] = - gtk_signal_new ("dimension_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableHeaderClass, dimension_change), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, eth_signals, LAST_SIGNAL); -} - -GtkType -e_table_header_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableHeader", - sizeof (ETableHeader), - sizeof (ETableHeaderClass), - (GtkClassInitFunc) e_table_header_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - -ETableHeader * -e_table_header_new (void) -{ - ETableHeader *eth; - - eth = gtk_type_new (e_table_header_get_type ()); - - return eth; -} - -static void -eth_do_insert (ETableHeader *eth, int pos, ETableCol *val) -{ - memcpy (ð->columns [pos+1], ð->columns [pos], - sizeof (ETableCol *) * (eth->col_count - pos)); - eth->columns [pos] = val; -} - -static void -eth_update_offsets (ETableHeader *eth) -{ - int i; - int x = 0; - - for (i = 0; i < eth->col_count; i++){ - ETableCol *etc = eth->columns [i]; - - etc->x = x; - x += etc->width; - } -} - -void -e_table_header_add_column (ETableHeader *eth, ETableCol *tc, int pos) -{ - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (tc != NULL); - g_return_if_fail (E_IS_TABLE_COL (tc)); - g_return_if_fail (pos >= 0 && pos <= eth->col_count); - - if (pos == -1) - pos = eth->col_count; - eth->columns = g_realloc (eth->columns, sizeof (ETableCol *) * (eth->col_count + 1)); - - /* - * We are the primary owners of the column - */ - gtk_object_ref (GTK_OBJECT (tc)); - gtk_object_sink (GTK_OBJECT (tc)); - - eth_do_insert (eth, pos, tc); - eth->col_count++; - eth_update_offsets (eth); - - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); -} - -ETableCol * -e_table_header_get_column (ETableHeader *eth, int column) -{ - g_return_val_if_fail (eth != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), NULL); - - if (column < 0) - return NULL; - - if (column >= eth->col_count) - return NULL; - - return eth->columns [column]; -} - -int -e_table_header_count (ETableHeader *eth) -{ - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - return eth->col_count; -} - -int -e_table_header_index (ETableHeader *eth, const char *identifier) -{ - int i; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - g_return_val_if_fail (identifier != NULL, 0); - - for (i = 0; i < eth->col_count; i++){ - ETableCol *tc = eth->columns [i]; - - if (strcmp (tc->id, identifier) == 0) - return i; - } - - return -1; -} - -int -e_table_header_get_index_at (ETableHeader *eth, int x_offset) -{ - int i, total; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - total = 0; - for (i = 0; i < eth->col_count; i++){ - total += eth->columns [i]->width; - - if (x_offset < total) - return i; - } - - return -1; -} - -ETableCol ** -e_table_header_get_columns (ETableHeader *eth) -{ - ETableCol **ret; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - ret = g_new (ETableCol *, eth->col_count + 1); - memcpy (ret, eth->columns, sizeof (ETableCol *) * eth->col_count); - ret [eth->col_count] = NULL; - - return ret; -} - -gboolean -e_table_header_selection_ok (ETableHeader *eth) -{ - g_return_val_if_fail (eth != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), FALSE); - - return eth->selectable; -} - -int -e_table_header_get_selected (ETableHeader *eth) -{ - int i; - int selected = 0; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - for (i = 0; i < eth->col_count; i++){ - if (eth->columns [i]->selected) - selected++; - } - - return selected; -} - -int -e_table_header_total_width (ETableHeader *eth) -{ - int total, i; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - total = 0; - for (i = 0; i < eth->col_count; i++) - total += eth->columns [i]->width; - - return total; -} - -static void -eth_do_remove (ETableHeader *eth, int idx, gboolean do_unref) -{ - if (do_unref) - gtk_object_unref (GTK_OBJECT (eth->columns [idx])); - - memcpy (ð->columns [idx], ð->columns [idx+1], - sizeof (ETableCol *) * eth->col_count - idx); - eth->col_count--; -} - -void -e_table_header_move (ETableHeader *eth, int source_index, int target_index) -{ - ETableCol *old; - - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (source_index >= 0); - g_return_if_fail (target_index >= 0); - g_return_if_fail (source_index < eth->col_count); - g_return_if_fail (target_index < eth->col_count); - - old = eth->columns [source_index]; - eth_do_remove (eth, source_index, FALSE); - eth_do_insert (eth, target_index, old); - eth_update_offsets (eth); - - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); -} - -void -e_table_header_remove (ETableHeader *eth, int idx) -{ - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < eth->col_count); - - eth_do_remove (eth, idx, TRUE); - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); -} - -void -e_table_header_set_selection (ETableHeader *eth, gboolean allow_selection) -{ -} - -void -e_table_header_set_size (ETableHeader *eth, int idx, int size) -{ - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < eth->col_count); - g_return_if_fail (size > 0); - - eth->columns [idx]->width = size; - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE], idx); -} diff --git a/widgets/table/e-table-header.h b/widgets/table/e-table-header.h deleted file mode 100644 index c263c36ad3..0000000000 --- a/widgets/table/e-table-header.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _E_TABLE_COLUMN_H_ -#define _E_TABLE_COLUMN_H_ - -#include <gtk/gtkobject.h> -#include <gdk/gdk.h> -#include "e-table-col.h" - -typedef struct _ETableHeader ETableHeader; - -#define E_TABLE_HEADER_TYPE (e_table_header_get_type ()) -#define E_TABLE_HEADER(o) (GTK_CHECK_CAST ((o), E_TABLE_HEADER_TYPE, ETableHeader)) -#define E_TABLE_HEADER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_HEADER_TYPE, ETableHeaderClass)) -#define E_IS_TABLE_HEADER(o) (GTK_CHECK_TYPE ((o), E_TABLE_HEADER_TYPE)) -#define E_IS_TABLE_HEADER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_HEADER_TYPE)) - -/* - * A Columnar header. - */ -struct _ETableHeader { - GtkObject base; - - int col_count; - ETableCol **columns; - gboolean selectable; -}; - -typedef struct { - GtkObjectClass parent_class; - - void (*structure_change) (ETableHeader *eth); - void (*dimension_change) (ETableHeader *eth, int col); -} ETableHeaderClass; - -GtkType e_table_header_get_type (void); -ETableHeader *e_table_header_new (void); - -void e_table_header_add_column (ETableHeader *eth, - ETableCol *tc, int pos); -ETableCol * e_table_header_get_column (ETableHeader *eth, - int column); -int e_table_header_count (ETableHeader *eth); -int e_table_header_index (ETableHeader *eth, - const char *identifier); -int e_table_header_get_index_at (ETableHeader *eth, - int x_offset); -ETableCol **e_table_header_get_columns (ETableHeader *eth); -gboolean e_table_header_selection_ok (ETableHeader *eth); -int e_table_header_get_selected (ETableHeader *eth); -int e_table_header_total_width (ETableHeader *eth); -void e_table_header_move (ETableHeader *eth, - int source_index, - int target_index); -void e_table_header_remove (ETableHeader *eth, int idx); -void e_table_header_set_size (ETableHeader *eth, int idx, int size); -void e_table_header_set_selection (ETableHeader *eth, - gboolean allow_selection); - -GList *e_table_header_get_selected_indexes(ETableHeader *eth); - - -#endif /* _E_TABLE_HEADER_H_ */ - diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c deleted file mode 100644 index ceb6adda95..0000000000 --- a/widgets/table/e-table-item.c +++ /dev/null @@ -1,1151 +0,0 @@ -/* - * E-table-item.c: A GnomeCanvasItem that is a view of an ETableModel. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc. - * - * TODO: - * Add a border to the thing, so that focusing works properly. - * - */ -#include <config.h> -#include <stdio.h> -#include <gtk/gtksignal.h> -#include <gdk/gdkkeysyms.h> -#include "e-table-item.h" -#include "e-cell.h" - -#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type () - -#define FOCUSED_BORDER 2 - -static GnomeCanvasItemClass *eti_parent_class; - -enum { - ROW_SELECTION, - LAST_SIGNAL -}; - -static gint eti_signals [LAST_SIGNAL] = { 0, }; - -enum { - ARG_0, - ARG_TABLE_HEADER, - ARG_TABLE_MODEL, - ARG_TABLE_X, - ARG_TABLE_Y, - ARG_TABLE_DRAW_GRID, - ARG_TABLE_DRAW_FOCUS, - ARG_MODE_SPREADSHEET, - ARG_LENGHT_THRESHOLD -}; - -static gboolean -eti_editing (ETableItem *eti) -{ - if (eti->editing_col == -1) - return FALSE; - else - return TRUE; -} - -/* - * During realization, we have to invoke the per-ecell realize routine - * (On our current setup, we have one e-cell per column. - * - * We might want to optimize this to only realize the unique e-cells: - * ie, a strings-only table, uses the same e-cell for every column, and - * we might want to avoid realizing each e-cell. - */ -static void -eti_realize_cell_views (ETableItem *eti) -{ - int i; - - /* - * Now realize the various ECells - */ - eti->n_cells = eti->cols; - eti->cell_views = g_new (ECellView *, eti->n_cells); - - for (i = 0; i < eti->n_cells; i++){ - ETableCol *col = e_table_header_get_column (eti->header, i); - - eti->cell_views [i] = e_cell_realize (col->ecell, eti); - } -} - -/* - * During unrealization: we invoke every e-cell (one per column in the current - * setup) to dispose all resources allocated - */ -static void -eti_unrealize_cell_views (ETableItem *eti) -{ - int i; - - for (i = 0; i < eti->n_cells; i++){ - e_cell_unrealize (eti->cell_views [i]); - eti->cell_views [i] = NULL; - } - g_free (eti->cell_views); - eti->n_cells = 0; - -} - -/* - * GnomeCanvasItem::update method - */ -static void -eti_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) -{ - ETableItem *eti = E_TABLE_ITEM (item); - - if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update) - (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)(item, affine, clip_path, flags); - - item->x1 = eti->x1; - item->y1 = eti->y1; - item->x2 = eti->x1 + eti->width; - item->y2 = eti->y1 + eti->height; - - gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item); -} - -/* - * eti_remove_table_model: - * - * Invoked to release the table model associated with this ETableItem - */ -static void -eti_remove_table_model (ETableItem *eti) -{ - if (!eti->table_model) - return; - - gtk_signal_disconnect (GTK_OBJECT (eti->table_model), - eti->table_model_change_id); - gtk_object_unref (GTK_OBJECT (eti->table_model)); - - eti->table_model_change_id = 0; - eti->table_model = NULL; -} - -/* - * eti_remove_header_model: - * - * Invoked to release the header model associated with this ETableItem - */ -static void -eti_remove_header_model (ETableItem *eti) -{ - if (!eti->header) - return; - - gtk_signal_disconnect (GTK_OBJECT (eti->header), - eti->header_structure_change_id); - gtk_signal_disconnect (GTK_OBJECT (eti->header), - eti->header_dim_change_id); - gtk_object_unref (GTK_OBJECT (eti->header)); - - eti->header_structure_change_id = 0; - eti->header_dim_change_id = 0; - eti->header = NULL; -} - -/* - * eti_row_height: - * - * Returns the height used by row @row. This does not include the one-pixel - * used as a separator between rows - */ -static int -eti_row_height (ETableItem *eti, int row) -{ - const int cols = e_table_header_count (eti->header); - int col; - int h, max_h; - - max_h = 0; - - for (col = 0; col < cols; col++){ - h = e_cell_height (eti->cell_views [col], col, row); - - if (h > max_h) - max_h = h; - } - return max_h; -} - -/* - * eti_get_height: - * - * Returns the height of the ETableItem. - * - * The ETableItem might compute the whole height by asking every row its - * size. There is a special mode (designed to work when there are too - * many rows in the table that performing the previous step could take - * too long) set by the ETableItem->length_threshold that would determine - * when the height is computed by using the first row as the size for - * every other row in the ETableItem. - */ -static int -eti_get_height (ETableItem *eti) -{ - const int rows = eti->rows; - int row; - int height; - - if (rows == 0) - return 0; - - if (eti->length_threshold != -1){ - if (rows > eti->length_threshold){ - height = (eti_row_height (eti, 0) + 1) * rows; - - /* - * 1 pixel at the top - */ - return height + 1; - } - } - - height = 1; - for (row = 0; row < rows; row++) - height += eti_row_height (eti, row) + 1; - - return height; -} - -/* - * Callback routine: invoked when the ETableModel has suffered a change - */ -static void -eti_table_model_changed (ETableModel *table_model, ETableItem *eti) -{ - eti->cols = e_table_model_column_count (eti->table_model); - eti->rows = e_table_model_row_count (eti->table_model); - - if (eti->cell_views) - eti->height = eti_get_height (eti); - - eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0); -} - -/* - * eti_request_redraw: - * - * Queues a canvas redraw for the entire ETableItem. - */ -static void -eti_request_redraw (ETableItem *eti) -{ - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - - gnome_canvas_request_redraw (canvas, eti->x1, eti->y1, - eti->x1 + eti->width + 1, - eti->y1 + eti->height + 1); -} - -/* - * Computes the distance from @start_col to @end_col in pixels. - */ -static int -eti_col_diff (ETableItem *eti, int start_col, int end_col) -{ - int col, total; - - total = 0; - for (col = start_col; col < end_col; col++){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - total += ecol->width; - } - - return total; -} - -/* - * Computes the distance between @start_row and @end_row in pixels - */ -static int -eti_row_diff (ETableItem *eti, int start_row, int end_row) -{ - int row, total; - - total = 0; - - for (row = start_row; row < end_row; row++) - total += eti_row_height (eti, row) + 1; - - return total; -} - -/* - * eti_request_region_redraw: - * - * Request a canvas redraw on the range (start_col, start_row) to (end_col, end_row). - * This is inclusive (ie, you can use: 0,0-0,0 to redraw the first cell). - * - * The @border argument is a number of pixels around the region that should also be queued - * for redraw. This is typically used by the focus routines to queue a redraw for the - * border as well. - */ -static void -eti_request_region_redraw (ETableItem *eti, - int start_col, int start_row, - int end_col, int end_row, int border) -{ - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - int x1, y1, width, height; - - x1 = eti_col_diff (eti, 0, start_col); - y1 = eti_row_diff (eti, 0, start_row); - width = eti_col_diff (eti, start_col, end_col + 1); - height = eti_row_diff (eti, start_row, end_row + 1); - - gnome_canvas_request_redraw (canvas, - eti->x1 + x1 - border, - eti->y1 + y1 - border, - eti->x1 + x1 + width + 1 + border, - eti->y1 + y1 + height + 1 + border); -} - -void -e_table_item_redraw_range (ETableItem *eti, - int start_col, int start_row, - int end_col, int end_row) -{ - int border; - - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if ((start_col == eti->focused_col) || - (end_col == eti->focused_col) || - (start_row == eti->focused_row) || - (end_row == eti->focused_row)) - border = 2; - else - border = 0; - - eti_request_region_redraw (eti, start_col, start_row, end_col, end_row, border); -} - -static void -eti_add_table_model (ETableItem *eti, ETableModel *table_model) -{ - g_assert (eti->table_model == NULL); - - eti->table_model = table_model; - gtk_object_ref (GTK_OBJECT (eti->table_model)); - - eti->table_model_change_id = gtk_signal_connect ( - GTK_OBJECT (table_model), "model_changed", - GTK_SIGNAL_FUNC (eti_table_model_changed), eti); - eti_table_model_changed (table_model, eti); -} - -static void -eti_header_dim_changed (ETableHeader *eth, int col, ETableItem *eti) -{ - eti_request_redraw (eti); - - eti->width = e_table_header_total_width (eti->header); - eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0); - - eti_request_redraw (eti); -} - -static void -eti_header_structure_changed (ETableHeader *eth, ETableItem *eti) -{ - eti_request_redraw (eti); - - eti->width = e_table_header_total_width (eti->header); - eti_unrealize_cell_views (eti); - eti_realize_cell_views (eti); - eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0); - - eti_request_redraw (eti); -} - -static void -eti_add_header_model (ETableItem *eti, ETableHeader *header) -{ - g_assert (eti->header == NULL); - - eti->header = header; - gtk_object_ref (GTK_OBJECT (header)); - - eti->width = e_table_header_total_width (header); - - eti->header_dim_change_id = gtk_signal_connect ( - GTK_OBJECT (header), "dimension_change", - GTK_SIGNAL_FUNC (eti_header_dim_changed), eti); - - eti->header_structure_change_id = gtk_signal_connect ( - GTK_OBJECT (header), "structure_change", - GTK_SIGNAL_FUNC (eti_header_structure_changed), eti); -} - -/* - * GtkObject::destroy method - */ -static void -eti_destroy (GtkObject *object) -{ - ETableItem *eti = E_TABLE_ITEM (object); - - eti_remove_header_model (eti); - eti_remove_table_model (eti); - - g_slist_free (eti->selection); - - if (GTK_OBJECT_CLASS (eti_parent_class)->destroy) - (*GTK_OBJECT_CLASS (eti_parent_class)->destroy) (object); -} - -static void -eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ETableItem *eti; - - item = GNOME_CANVAS_ITEM (o); - eti = E_TABLE_ITEM (o); - - switch (arg_id){ - case ARG_TABLE_HEADER: - eti_remove_header_model (eti); - eti_add_header_model (eti, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_TABLE_MODEL: - eti_remove_table_model (eti); - eti_add_table_model (eti, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_TABLE_X: - eti->x1 = GTK_VALUE_INT (*arg); - break; - - case ARG_TABLE_Y: - eti->y1 = GTK_VALUE_INT (*arg); - break; - - case ARG_LENGHT_THRESHOLD: - eti->length_threshold = GTK_VALUE_INT (*arg); - break; - - case ARG_TABLE_DRAW_GRID: - eti->draw_grid = GTK_VALUE_BOOL (*arg); - break; - - case ARG_TABLE_DRAW_FOCUS: - eti->draw_focus = GTK_VALUE_BOOL (*arg); - break; - - case ARG_MODE_SPREADSHEET: - eti->mode_spreadsheet = GTK_VALUE_BOOL (*arg); - break; - } - eti_update (item, NULL, NULL, 0); -} - -static void -eti_init (GnomeCanvasItem *item) -{ - ETableItem *eti = E_TABLE_ITEM (item); - - eti->focused_col = -1; - eti->focused_row = -1; - eti->editing_col = -1; - eti->editing_row = -1; - eti->height = 0; - - eti->length_threshold = -1; - - eti->selection_mode = GTK_SELECTION_SINGLE; -} - -#define gray50_width 2 -#define gray50_height 2 -static const char gray50_bits[] = { - 0x02, 0x01, }; - -static void -eti_realize (GnomeCanvasItem *item) -{ - ETableItem *eti = E_TABLE_ITEM (item); - GtkWidget *canvas_widget = GTK_WIDGET (item->canvas); - GdkWindow *window; - - if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize) - (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize)(item); - - /* - * Gdk Resource allocation - */ - window = canvas_widget->window; - - eti->fill_gc = canvas_widget->style->white_gc; - gdk_gc_ref (canvas_widget->style->white_gc); - - eti->grid_gc = gdk_gc_new (window); -#if 0 - /* This sets it to gray */ -/* gdk_gc_set_foreground (eti->grid_gc, &canvas_widget->style->bg [GTK_STATE_NORMAL]); */ -#else - gdk_gc_set_foreground (eti->grid_gc, &canvas_widget->style->black); -#endif - eti->focus_gc = gdk_gc_new (window); - gdk_gc_set_foreground (eti->focus_gc, &canvas_widget->style->bg [GTK_STATE_NORMAL]); - gdk_gc_set_background (eti->focus_gc, &canvas_widget->style->fg [GTK_STATE_NORMAL]); - eti->stipple = gdk_bitmap_create_from_data (NULL, gray50_bits, gray50_width, gray50_height); - gdk_gc_set_ts_origin (eti->focus_gc, 0, 0); - gdk_gc_set_stipple (eti->focus_gc, eti->stipple); - gdk_gc_set_fill (eti->focus_gc, GDK_OPAQUE_STIPPLED); - - /* - * - */ - eti_realize_cell_views (eti); - - eti->height = eti_get_height (eti); - eti_update (item, NULL, NULL, 0); -} - -static void -eti_unrealize (GnomeCanvasItem *item) -{ - ETableItem *eti = E_TABLE_ITEM (item); - - gdk_gc_unref (eti->fill_gc); - eti->fill_gc = NULL; - gdk_gc_unref (eti->grid_gc); - eti->grid_gc = NULL; - gdk_gc_unref (eti->focus_gc); - eti->focus_gc = NULL; - gdk_bitmap_unref (eti->stipple); - eti->stipple = NULL; - - eti_unrealize_cell_views (eti); - - eti->height = 0; - - if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->unrealize) - (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->unrealize)(item); -} - -static void -draw_cell (ETableItem *eti, GdkDrawable *drawable, int col, int row, gboolean selected, - int x1, int y1, int x2, int y2) -{ - ECellView *ecell_view; - - ecell_view = eti->cell_views [col]; - - e_cell_draw (ecell_view, drawable, col, row, selected, x1, y1, x2, y2); - -#if 0 - { - GdkFont *font; - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (eti)->canvas; - - font = GTK_WIDGET (canvas)->style->font; - - sprintf (text, "%d:%d\n", col, row); gdk_draw_line (drawable, eti->grid_gc, x1, y1, x2, y2); - gdk_draw_line (drawable, eti->grid_gc, x1, y2, x2, y1); - - sprintf (text, "%d:%d\n", col, row); - gdk_draw_text (drawable, font, eti->grid_gc, x1, y2, text, strlen (text)); - } -#endif -} - -static void -eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height) -{ - ETableItem *eti = E_TABLE_ITEM (item); - const int rows = eti->rows; - const int cols = eti->cols; - int row, col, y1, y2; - int first_col, last_col, x_offset; - int first_row, last_row, y_offset, yd; - int x1, x2; - int f_x1, f_x2, f_y1, f_y2; - gboolean f_found; - -/* printf ("Rect: %d %d %d %d\n", x, y, width, height); */ - /* - * Clear the background - */ -#if 0 - gdk_draw_rectangle ( - drawable, eti->fill_gc, TRUE, - eti->x1 - x, eti->y1 - y, eti->width, eti->height); -#endif - - /* - * First column to draw, last column to draw - */ - first_col = -1; - last_col = x_offset = 0; - x1 = x2 = eti->x1; - for (col = 0; col < cols; col++, x1 = x2){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - x2 = x1 + ecol->width; - - if (x1 > (x + width)) - break; - if (x2 < x) - continue; - if (first_col == -1){ - x_offset = x1 - x; - first_col = col; - } - } - last_col = col; - - /* - * Nothing to paint - */ - if (first_col == -1) - return; - - /* - * Compute row span. - */ - first_row = -1; - y_offset = 0; - y1 = y2 = eti->y1 + 1; - for (row = 0; row < rows; row++, y1 = y2){ - - y2 += eti_row_height (eti, row) + 1; - - if (y1 > y + height) - break; - - if (y2 < y) - continue; - - if (first_row == -1){ - y_offset = y1 - y; - first_row = row; - } - } - last_row = row; - - if (first_row == -1) - return; - - /* - * Draw cells - */ - yd = y_offset; - f_x1 = f_x2 = f_y1 = f_y2 = -1; - f_found = FALSE; - - if (eti->draw_grid && first_row == 0){ - gdk_draw_line ( - drawable, eti->grid_gc, - eti->x1 - x, yd, eti->x1 + eti->width - x, yd); - } - yd++; - - for (row = first_row; row < last_row; row++){ - int xd, height; - gboolean selected; - - height = eti_row_height (eti, row); - - xd = x_offset; -/* printf ("paint: %d %d\n", yd, yd + height); */ - - selected = g_slist_find (eti->selection, GINT_TO_POINTER (row)) != NULL; - - for (col = first_col; col < last_col; col++){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - draw_cell (eti, drawable, col, row, selected, xd, yd, xd + ecol->width, yd + height); - - if (col == eti->focused_col && row == eti->focused_row){ - f_x1 = xd; - f_x2 = xd + ecol->width; - f_y1 = yd; - f_y2 = yd + height; - f_found = TRUE; - } - - xd += ecol->width; - } - yd += height; - - if (eti->draw_grid) - gdk_draw_line ( - drawable, eti->grid_gc, - eti->x1 - x, yd, eti->x1 + eti->width - x, yd); - yd++; - } - - if (eti->draw_grid){ - int xd = x_offset; - - for (col = first_col; col <= last_col; col++){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - gdk_draw_line ( - drawable, eti->grid_gc, - xd, y_offset, xd, yd - 1); - - /* - * This looks wierd, but it is to draw the last line - */ - if (ecol) - xd += ecol->width; - } - } - - /* - * Draw focus - */ - if (f_found && eti->draw_focus){ - - if (!eti_editing (eti)) - gdk_draw_rectangle ( - drawable, eti->focus_gc, FALSE, - f_x1 + 1, f_y1, f_x2 - f_x1 - 2, f_y2 - f_y1 - 1); - } -} - -static double -eti_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - - return 0.0; -} - -static gboolean -find_cell (ETableItem *eti, double x, double y, int *col_res, int *row_res, gdouble *x1_res, gdouble *y1_res) -{ - const int cols = eti->cols; - const int rows = eti->rows; - gdouble x1, y1, x2, y2; - int col, row; - - /* FIXME: this routine is inneficient, fix later */ - - x -= eti->x1; - y -= eti->y1; - - x1 = 0; - for (col = 0; col < cols; col++, x1 = x2){ - ETableCol *ecol = e_table_header_get_column (eti->header, col); - - if (x < x1) - return FALSE; - - x2 = x1 + ecol->width; - - if (x > x2) - continue; - - *col_res = col; - if (x1_res) - *x1_res = x - x1; - break; - } - - y1 = y2 = 0; - for (row = 0; row < rows; row++, y1 = y2){ - if (y < y1) - return FALSE; - - y2 += eti_row_height (eti, row) + 1; - - if (y > y2) - continue; - - *row_res = row; - if (y1_res) - *y1_res = y - y1; - break; - } - - return TRUE; -} - -static int -eti_event (GnomeCanvasItem *item, GdkEvent *e) -{ - ETableItem *eti = E_TABLE_ITEM (item); - ECellView *ecell_view; - - switch (e->type){ - case GDK_BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - case GDK_2BUTTON_PRESS: { - int col, row; - gdouble x1, y1; - - if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1)) - return TRUE; - - if (eti->focused_row == row && eti->focused_col == col){ - ecell_view = eti->cell_views [col]; - - /* - * Adjust the event positions - */ - e->button.x = x1; - e->button.y = y1; - - e_cell_event (ecell_view, e, col, row); - } else { - /* - * Focus the cell, and select the row - */ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, col, row); - e_table_item_select_row (eti, row); - } - break; - } - - case GDK_MOTION_NOTIFY: { - int col, row; - double x1, y1; - - if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1)) - return TRUE; - - if (eti->focused_row == row && eti->focused_col == col){ - ecell_view = eti->cell_views [col]; - - /* - * Adjust the event positions - */ - e->button.x -= (x1 + eti->x1); - e->button.y -= (y1 + eti->y1); - - e_cell_event (ecell_view, e, col, row); - } - break; - } - - case GDK_KEY_PRESS: - if (eti->focused_col == -1) - return FALSE; - - switch (e->key.keyval){ - case GDK_Left: - if (!eti->mode_spreadsheet && eti_editing (eti)) - break; - - if (eti->focused_col > 0){ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, eti->focused_col - 1, eti->focused_row); - } - return TRUE; - - case GDK_Right: - if (!eti->mode_spreadsheet && eti_editing (eti)) - break; - - if ((eti->focused_col + 1) < eti->cols){ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, eti->focused_col + 1, eti->focused_row); - } - return TRUE; - - case GDK_Up: - if (eti->focused_row > 0){ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, eti->focused_col, eti->focused_row - 1); - } - return TRUE; - - case GDK_Down: - if ((eti->focused_row + 1) < eti->rows){ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, eti->focused_col, eti->focused_row + 1); - } - return TRUE; - default: - if (!eti_editing (eti)){ - if ((e->key.state & (GDK_MOD1_MASK | GDK_CONTROL_MASK)) != 0) - return 0; - - if (!(e->key.keyval >= 0x20 && e->key.keyval <= 0xff)) - return 0; - } - } - - ecell_view = eti->cell_views [eti->focused_col]; - e_cell_event (ecell_view, e, eti->focused_col, eti->focused_row); - break; - - case GDK_KEY_RELEASE: - if (eti->focused_col == -1) - return FALSE; - - if (eti_editing (eti)){ - ecell_view = eti->cell_views [eti->editing_col]; - e_cell_event (ecell_view, e, eti->editing_col, eti->editing_row); - } - break; - - default: - return FALSE; - } - return TRUE; -} - -/* - * ETableItem::row_selection method - */ -static void -eti_row_selection (ETableItem *eti, int row, gboolean selected) -{ - eti_request_region_redraw (eti, 0, row, eti->cols - 1, row, 0); - - if (selected) - eti->selection = g_slist_prepend (eti->selection, GINT_TO_POINTER (row)); - else - eti->selection = g_slist_remove (eti->selection, GINT_TO_POINTER (row)); - -} - -static void -eti_class_init (GtkObjectClass *object_class) -{ - GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class; - ETableItemClass *eti_class = (ETableItemClass *) object_class; - - eti_parent_class = gtk_type_class (PARENT_OBJECT_TYPE); - - object_class->destroy = eti_destroy; - object_class->set_arg = eti_set_arg; - - item_class->update = eti_update; - item_class->realize = eti_realize; - item_class->unrealize = eti_unrealize; - item_class->draw = eti_draw; - item_class->point = eti_point; - item_class->event = eti_event; - - eti_class->row_selection = eti_row_selection; - - gtk_object_add_arg_type ("ETableItem::ETableHeader", GTK_TYPE_POINTER, - GTK_ARG_WRITABLE, ARG_TABLE_HEADER); - gtk_object_add_arg_type ("ETableItem::ETableModel", GTK_TYPE_POINTER, - GTK_ARG_WRITABLE, ARG_TABLE_MODEL); - gtk_object_add_arg_type ("ETableItem::x", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_TABLE_X); - gtk_object_add_arg_type ("ETableItem::y", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_TABLE_Y); - gtk_object_add_arg_type ("ETableItem::drawgrid", GTK_TYPE_BOOL, - GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID); - gtk_object_add_arg_type ("ETableItem::drawfocus", GTK_TYPE_BOOL, - GTK_ARG_WRITABLE, ARG_TABLE_DRAW_FOCUS); - gtk_object_add_arg_type ("ETableItem::spreadsheet", GTK_TYPE_BOOL, - GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET); - - eti_signals [ROW_SELECTION] = - gtk_signal_new ("row_selection", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableItemClass, row_selection), - gtk_marshal_NONE__INT_INT, - GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, eti_signals, LAST_SIGNAL); - -} - -GtkType -e_table_item_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableItem", - sizeof (ETableItem), - sizeof (ETableItemClass), - (GtkClassInitFunc) eti_class_init, - (GtkObjectInitFunc) eti_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_OBJECT_TYPE, &info); - } - - return type; -} - -void -e_table_item_focus (ETableItem *eti, int col, int row) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (eti->focused_col != -1) - e_table_item_unfocus (eti); - - eti->focused_col = col; - eti->focused_row = row; - - eti_request_region_redraw (eti, col, row, col, row, FOCUSED_BORDER); - - /* - * make sure we have the Gtk Focus - */ - gtk_widget_grab_focus (GTK_WIDGET (GNOME_CANVAS_ITEM (eti)->canvas)); -} - -void -e_table_item_unfocus (ETableItem *eti) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (eti->focused_row == -1) - return; - - { - const int col = eti->focused_col; - const int row = eti->focused_row; - - eti_request_region_redraw (eti, col, row, col, row, FOCUSED_BORDER); - } - eti->focused_col = -1; - eti->focused_row = -1; -} - -const GSList * -e_table_item_get_selection (ETableItem *eti) -{ - g_return_val_if_fail (eti != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_ITEM (eti), NULL); - - return eti->selection; -} - -GtkSelectionMode -e_table_item_get_selection_mode (ETableItem *eti) -{ - g_return_val_if_fail (eti != NULL, GTK_SELECTION_SINGLE); - g_return_val_if_fail (E_IS_TABLE_ITEM (eti), GTK_SELECTION_SINGLE); - - return eti->selection_mode; -} - -void -e_table_item_set_selection_mode (ETableItem *eti, GtkSelectionMode selection_mode) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (selection_mode == GTK_SELECTION_BROWSE || - selection_mode == GTK_SELECTION_EXTENDED){ - g_error ("GTK_SELECTION_BROWSE and GTK_SELECTION_EXTENDED are not implemented"); - } - - eti->selection_mode = selection_mode; -} - -gboolean -e_table_item_is_row_selected (ETableItem *eti, int row) -{ - g_return_val_if_fail (eti != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_ITEM (eti), FALSE); - - if (g_slist_find (eti->selection, GINT_TO_POINTER (row))) - return TRUE; - else - return FALSE; -} - -void -e_table_item_unselect_row (ETableItem *eti, int row) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (e_table_item_is_row_selected (eti, row)){ - gtk_signal_emit ( - GTK_OBJECT (eti), eti_signals [ROW_SELECTION], - row, 0); - } -} - -void -e_table_item_select_row (ETableItem *eti, int row) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - switch (eti->selection_mode){ - case GTK_SELECTION_SINGLE: - if (eti->selection){ - gtk_signal_emit ( - GTK_OBJECT (eti), eti_signals [ROW_SELECTION], - GPOINTER_TO_INT (eti->selection->data), 0); - } - g_slist_free (eti->selection); - eti->selection = NULL; - - gtk_signal_emit ( - GTK_OBJECT (eti), eti_signals [ROW_SELECTION], - GINT_TO_POINTER (row), 1); - break; - - case GTK_SELECTION_MULTIPLE: - if (g_slist_find (eti->selection, GINT_TO_POINTER (row))) - return; - gtk_signal_emit ( - GTK_OBJECT (eti), eti_signals [ROW_SELECTION], - GINT_TO_POINTER (row), 1); - break; - - default: - - } -} - -void -e_table_item_enter_edit (ETableItem *eti, int col, int row) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - eti->editing_col = col; - eti->editing_row = row; - - eti->edit_ctx = e_cell_enter_edit (eti->cell_views [col], col, row); -} - -void -e_table_item_leave_edit (ETableItem *eti) -{ - g_return_if_fail (eti != NULL); - g_return_if_fail (E_IS_TABLE_ITEM (eti)); - - if (!eti_editing (eti)) - return; - - e_cell_leave_edit (eti->cell_views [eti->editing_col], eti->editing_col, eti->editing_row, eti->edit_ctx); - eti->editing_col = -1; - eti->editing_row = -1; - eti->edit_ctx = NULL; -} - diff --git a/widgets/table/e-table-item.h b/widgets/table/e-table-item.h deleted file mode 100644 index 6c4d837310..0000000000 --- a/widgets/table/e-table-item.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef _E_TABLE_ITEM_H_ -#define _E_TABLE_ITEM_H_ - -#include <libgnomeui/gnome-canvas.h> -#include "e-table-model.h" -#include "e-table-header.h" - -#define E_TABLE_ITEM_TYPE (e_table_item_get_type ()) -#define E_TABLE_ITEM(o) (GTK_CHECK_CAST ((o), E_TABLE_ITEM_TYPE, ETableItem)) -#define E_TABLE_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_ITEM_TYPE, ETableItemClass)) -#define E_IS_TABLE_ITEM(o) (GTK_CHECK_TYPE ((o), E_TABLE_ITEM_TYPE)) -#define E_IS_TABLE_ITEM_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_ITEM_TYPE)) - -typedef struct { - GnomeCanvasItem parent; - ETableModel *table_model; - ETableHeader *header; - - int x1, y1; - int width, height; - - int cols, rows; - - /* - * Ids for the signals we connect to - */ - int header_dim_change_id; - int header_structure_change_id; - int table_model_change_id; - - GdkGC *fill_gc; - GdkGC *grid_gc; - GdkGC *focus_gc; - GdkBitmap *stipple; - - unsigned int draw_grid:1; - unsigned int draw_focus:1; - unsigned int mode_spreadsheet:1; - - int focused_col, focused_row; - - /* - * Realized views, per column - */ - ECellView **cell_views; - int n_cells; - - /* - * Lengh Threshold: above this, we stop computing correctly - * the size - */ - int length_threshold; - - GSList *selection; - GtkSelectionMode selection_mode; - - /* - * During edition - */ - int editing_col, editing_row; - void *edit_ctx; -} ETableItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - - void (*row_selection) (ETableItem *eti, int row, gboolean selected); -} ETableItemClass; - -GtkType e_table_item_get_type (void); - -/* - * Focus - */ -void e_table_item_focus (ETableItem *eti, int col, int row); -void e_table_item_unfocus (ETableItem *eti); - -/* - * Selection - */ -void e_table_item_select_row (ETableItem *e_table_Item, int row); -void e_table_item_unselect_row (ETableItem *e_table_Item, int row); - -/* - * Handling the selection - */ -const GSList*e_table_item_get_selection (ETableItem *e_table_Item); - -GtkSelectionMode e_table_item_get_selection_mode (ETableItem *e_table_Item); -void e_table_item_set_selection_mode (ETableItem *e_table_Item, - GtkSelectionMode selection_mode); -gboolean e_table_item_is_row_selected (ETableItem *e_table_Item, - int row); - -void e_table_item_leave_edit (ETableItem *eti); -void e_table_item_enter_edit (ETableItem *eti, int col, int row); - -void e_table_item_redraw_range (ETableItem *eti, - int start_col, int start_row, - int end_col, int end_row); - -#endif /* _E_TABLE_ITEM_H_ */ diff --git a/widgets/table/e-table-model.c b/widgets/table/e-table-model.c deleted file mode 100644 index 103bb31b57..0000000000 --- a/widgets/table/e-table-model.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * e-table-model.c: a Table Model - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc. - */ -#include <config.h> -#include <gtk/gtksignal.h> -#include "e-table-model.h" - -#define ETM_CLASS(e) ((ETableModelClass *)((GtkObject *)e)->klass) - -static GtkObjectClass *e_table_model_parent_class; - -enum { - MODEL_CHANGED, - MODEL_ROW_CHANGED, - MODEL_CELL_CHANGED, - ROW_SELECTION, - LAST_SIGNAL -}; - -static guint e_table_model_signals [LAST_SIGNAL] = { 0, }; - -int -e_table_model_column_count (ETableModel *e_table_model) -{ - g_return_val_if_fail (e_table_model != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), 0); - - return ETM_CLASS (e_table_model)->column_count (e_table_model); -} - -const char * -e_table_model_column_name (ETableModel *e_table_model, int col) -{ - g_return_val_if_fail (e_table_model != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), NULL); - - return ETM_CLASS (e_table_model)->column_name (e_table_model, col); -} - -int -e_table_model_row_count (ETableModel *e_table_model) -{ - g_return_val_if_fail (e_table_model != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), 0); - - return ETM_CLASS (e_table_model)->row_count (e_table_model); -} - -void * -e_table_model_value_at (ETableModel *e_table_model, int col, int row) -{ - g_return_val_if_fail (e_table_model != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), NULL); - - return ETM_CLASS (e_table_model)->value_at (e_table_model, col, row); -} - -void -e_table_model_set_value_at (ETableModel *e_table_model, int col, int row, const void *data) -{ - g_return_if_fail (e_table_model != NULL); - g_return_if_fail (E_IS_TABLE_MODEL (e_table_model)); - - return ETM_CLASS (e_table_model)->set_value_at (e_table_model, col, row, data); -} - -gboolean -e_table_model_is_cell_editable (ETableModel *e_table_model, int col, int row) -{ - g_return_val_if_fail (e_table_model != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), FALSE); - - return ETM_CLASS (e_table_model)->is_cell_editable (e_table_model, col, row); -} - -static void -e_table_model_destroy (GtkObject *object) -{ - if (e_table_model_parent_class->destroy) - (*e_table_model_parent_class->destroy)(object); -} - -static void -e_table_model_class_init (GtkObjectClass *object_class) -{ - e_table_model_parent_class = gtk_type_class (gtk_object_get_type ()); - - object_class->destroy = e_table_model_destroy; - - e_table_model_signals [MODEL_CHANGED] = - gtk_signal_new ("model_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableModelClass, model_changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - e_table_model_signals [MODEL_ROW_CHANGED] = - gtk_signal_new ("model_row_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableModelClass, model_row_changed), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - e_table_model_signals [MODEL_CELL_CHANGED] = - gtk_signal_new ("model_cell_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableModelClass, model_cell_changed), - gtk_marshal_NONE__INT_INT, - GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, e_table_model_signals, LAST_SIGNAL); -} - -GtkType -e_table_model_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableModel", - sizeof (ETableModel), - sizeof (ETableModelClass), - (GtkClassInitFunc) e_table_model_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - -void -e_table_model_changed (ETableModel *e_table_model) -{ - g_return_if_fail (e_table_model != NULL); - g_return_if_fail (E_IS_TABLE_MODEL (e_table_model)); - - gtk_signal_emit (GTK_OBJECT (e_table_model), - e_table_model_signals [MODEL_CHANGED]); -} - -void -e_table_model_row_changed (ETableModel *e_table_model, int row) -{ - g_return_if_fail (e_table_model != NULL); - g_return_if_fail (E_IS_TABLE_MODEL (e_table_model)); - - gtk_signal_emit (GTK_OBJECT (e_table_model), - e_table_model_signals [MODEL_ROW_CHANGED], row); -} - -void -e_table_model_cell_changed (ETableModel *e_table_model, int col, int row) -{ - g_return_if_fail (e_table_model != NULL); - g_return_if_fail (E_IS_TABLE_MODEL (e_table_model)); - - gtk_signal_emit (GTK_OBJECT (e_table_model), - e_table_model_signals [MODEL_CELL_CHANGED], col, row); -} - - diff --git a/widgets/table/e-table-model.h b/widgets/table/e-table-model.h deleted file mode 100644 index 22339ae484..0000000000 --- a/widgets/table/e-table-model.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef _E_TABLE_MODEL_H_ -#define _E_TABLE_MODEL_H_ - -#include <gtk/gtkobject.h> - -#define E_TABLE_MODEL_TYPE (e_table_model_get_type ()) -#define E_TABLE_MODEL(o) (GTK_CHECK_CAST ((o), E_TABLE_MODEL_TYPE, ETableModel)) -#define E_TABLE_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_MODEL_TYPE, ETableModelClass)) -#define E_IS_TABLE_MODEL(o) (GTK_CHECK_TYPE ((o), E_TABLE_MODEL_TYPE)) -#define E_IS_TABLE_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_MODEL_TYPE)) - -typedef struct { - GtkObject base; -} ETableModel; - -typedef struct { - GtkObjectClass parent_class; - - /* - * Virtual methods - */ - int (*column_count) (ETableModel *etm); - const char *(*column_name) (ETableModel *etm, int col); - int (*row_count) (ETableModel *etm); - void *(*value_at) (ETableModel *etm, int col, int row); - void (*set_value_at) (ETableModel *etm, int col, int row, const void *value); - gboolean (*is_cell_editable) (ETableModel *etm, int col, int row); - - /* - * Signals - */ - void (*model_changed) (ETableModel *etm); - void (*model_row_changed) (ETableModel *etm, int row); - void (*model_cell_changed) (ETableModel *etm, int col, int row); -} ETableModelClass; - -GtkType e_table_model_get_type (void); - -int e_table_model_column_count (ETableModel *e_table_model); -const char *e_table_model_column_name (ETableModel *e_table_model, int col); -int e_table_model_row_count (ETableModel *e_table_model); -void *e_table_model_value_at (ETableModel *e_table_model, int col, int row); -void e_table_model_set_value_at (ETableModel *e_table_model, int col, int row, const void *data); -gboolean e_table_model_is_cell_editable (ETableModel *e_table_model, int col, int row); - -/* - * Routines for emitting signals on the e_table - */ -void e_table_model_changed (ETableModel *e_table_model); -void e_table_model_row_changed (ETableModel *e_table_model, int row); -void e_table_model_cell_changed (ETableModel *e_table_model, int col, int row); - -#endif /* _E_TABLE_MODEL_H_ */ - - diff --git a/widgets/table/e-table-render.c b/widgets/table/e-table-render.c deleted file mode 100644 index 49d742132b..0000000000 --- a/widgets/table/e-table-render.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * E-table-render.c: Various renderers - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc. - */ -#include <config.h> -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-col.h" -#include "e-table-render.h" - -void -e_table_render_string (ERenderContext *ctxt) -{ - printf ("Rendering string: %s\n", ctxt->render_data); -} - diff --git a/widgets/table/e-table-render.h b/widgets/table/e-table-render.h deleted file mode 100644 index ebc65968f0..0000000000 --- a/widgets/table/e-table-render.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef E_TABLE_RENDER_H -#define E_TABLE_RENDER_H - -#include <libgnomeui/gnome-canvas.h> - -struct ERenderContext { - ETableCol *etc; - int row; - int base_x, base_y; - GnomeCanvasItem *gnome_canvas_item; - GdkDrawable *drawable; - int drawable_width; - int drawable_height; - void *render_data; - void *closure; -}; - -void e_table_render_string (ERenderContext *ctxt); - - -#endif diff --git a/widgets/table/e-table-simple.c b/widgets/table/e-table-simple.c deleted file mode 100644 index 2076e06cef..0000000000 --- a/widgets/table/e-table-simple.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * e-table-model.c: a simple table model implementation that uses function - * pointers to simplify the creation of new, exotic and colorful tables in - * no time. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc. - */ - -#include <config.h> -#include "e-table-simple.h" - -#define PARENT_TYPE e_table_model_get_type() - -static int -simple_column_count (ETableModel *etm) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->col_count (etm, simple->data); -} - -static const char * -simple_column_name (ETableModel *etm, int col) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->col_name (etm, col, simple->data); -} - -static int -simple_row_count (ETableModel *etm) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->row_count (etm, simple->data); -} - -static void * -simple_value_at (ETableModel *etm, int col, int row) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->value_at (etm, col, row, simple->data); -} - -static void -simple_set_value_at (ETableModel *etm, int col, int row, const void *val) -{ - ETableSimple *simple = (ETableSimple *)etm; - - simple->set_value_at (etm, col, row, val, simple->data); -} - -static gboolean -simple_is_cell_editable (ETableModel *etm, int col, int row) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->is_cell_editable (etm, col, row, simple->data); -} - -static void -e_table_simple_class_init (GtkObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - model_class->column_count = simple_column_count; - model_class->column_name = simple_column_name; - model_class->row_count = simple_row_count; - model_class->value_at = simple_value_at; - model_class->set_value_at = simple_set_value_at; - model_class->is_cell_editable = simple_is_cell_editable; -} - -GtkType -e_table_simple_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableSimple", - sizeof (ETableSimple), - sizeof (ETableSimpleClass), - (GtkClassInitFunc) e_table_simple_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -ETableModel * -e_table_simple_new (ETableSimpleColumnCountFn col_count, - ETableSimpleColumnNameFn col_name, - ETableSimpleRowCountFn row_count, - ETableSimpleValueAtFn value_at, - ETableSimpleSetValueAtFn set_value_at, - ETableSimpleIsCellEditableFn is_cell_editable, - void *data) -{ - ETableSimple *et; - - et = gtk_type_new (e_table_simple_get_type ()); - - et->col_count = col_count; - et->col_name = col_name; - et->row_count = row_count; - et->value_at = value_at; - et->set_value_at = set_value_at; - et->is_cell_editable = is_cell_editable; - - return (ETableModel *) et; -} diff --git a/widgets/table/e-table-simple.h b/widgets/table/e-table-simple.h deleted file mode 100644 index 1f7a17aeff..0000000000 --- a/widgets/table/e-table-simple.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _E_TABLE_SIMPLE_H_ -#define _E_TABLE_SIMPLE_H_ - -#include "e-table-model.h" - -typedef int (*ETableSimpleColumnCountFn) (ETableModel *etm, void *data); -typedef const char *(*ETableSimpleColumnNameFn) (ETableModel *etm, int col, void *data); -typedef int (*ETableSimpleRowCountFn) (ETableModel *etm, void *data); -typedef void *(*ETableSimpleValueAtFn) (ETableModel *etm, int col, int row, void *data); -typedef void (*ETableSimpleSetValueAtFn) (ETableModel *etm, int col, int row, const void *val, void *data); -typedef gboolean (*ETableSimpleIsCellEditableFn) (ETableModel *etm, int col, int row, void *data); - -typedef struct { - ETableModel parent; - - ETableSimpleColumnCountFn col_count; - ETableSimpleColumnNameFn col_name; - ETableSimpleRowCountFn row_count; - ETableSimpleValueAtFn value_at; - ETableSimpleSetValueAtFn set_value_at; - ETableSimpleIsCellEditableFn is_cell_editable; - void *data; -} ETableSimple; - -typedef struct { - ETableModelClass parent_class; -} ETableSimpleClass; - -GtkType e_table_simple_get_type (void); - -ETableModel *e_table_simple_new (ETableSimpleColumnCountFn col_count, - ETableSimpleColumnNameFn col_name, - ETableSimpleRowCountFn row_count, - ETableSimpleValueAtFn value_at, - ETableSimpleSetValueAtFn set_value_at, - ETableSimpleIsCellEditableFn is_cell_editable, - void *data); - -#endif /* _E_TABLE_SIMPLE_H_ */ - diff --git a/widgets/table/e-table-sorted.c b/widgets/table/e-table-sorted.c deleted file mode 100644 index 90773e9cdc..0000000000 --- a/widgets/table/e-table-sorted.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * E-table-sorted.c: Implements a table that sorts another table - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc. - */ -#include <config.h> -#include <stdlib.h> -#include "e-util.h" -#include "e-table-sorted.h" - -#define PARENT_TYPE E_TABLE_SUBSET_TYPE - -static ETableModelClass *ets_parent_class; - -static void -ets_class_init (GtkObjectClass *klass) -{ - ETableModelClass *table_class = (ETableModelClass *) klass; - - ets_parent_class = gtk_type_class (PARENT_TYPE); -} - -E_MAKE_TYPE(e_table_sorted, "ETableSorted", ETableSorted, ets_class_init, NULL, PARENT_TYPE); - -static ETableSorted *sort_ets; - -static int -my_sort (const void *a, const void *b) -{ - ETableModel *source = E_TABLE_SUBSET (sort_ets)->source; - const int *ia = (const int *) a; - const int *ib = (const int *) b; - void *va, *vb; - - va = e_table_model_value_at (source, sort_ets->sort_col, *ia); - vb = e_table_model_value_at (source, sort_ets->sort_col, *ib); - - return (*sort_ets->compare) (va, vb); -} - -static void -do_sort (ETableSorted *ets) -{ - ETableSubset *etss = E_TABLE_SUBSET (ets); - g_assert (sort_ets == NULL); - - sort_ets = ets; - qsort (etss->map_table, etss->n_map, sizeof (unsigned int), my_sort); - sort_ets = NULL; -} - -ETableModel * -e_table_sorted_new (ETableModel *source, int col, GCompareFunc compare) -{ - ETableSorted *ets = gtk_type_new (E_TABLE_SORTED_TYPE); - ETableSubset *etss = E_TABLE_SUBSET (ets); - const int nvals = e_table_model_row_count (source); - int i; - - if (e_table_subset_construct (etss, source, nvals) == NULL){ - gtk_object_destroy (GTK_OBJECT (ets)); - return NULL; - } - - ets->compare = compare; - ets->sort_col = col; - - /* Init */ - for (i = 0; i < nvals; i++) - etss->map_table [i] = i; - - do_sort (ets); - - return (ETableModel *) ets; -} - -void -e_table_sorted_resort (ETableSorted *ets, int col, GCompareFunc compare) -{ - if (col == -1 || compare == NULL) - do_sort (ets); - else { - ets->sort_col = col; - ets->compare = compare; - do_sort (ets); - } -} - diff --git a/widgets/table/e-table-sorted.h b/widgets/table/e-table-sorted.h deleted file mode 100644 index 2ec52df2e7..0000000000 --- a/widgets/table/e-table-sorted.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _E_TABLE_SORTED_H_ -#define _E_TABLE_SORTED_H_ - -#include <gtk/gtkobject.h> -#include "e-table-model.h" -#include "e-table-subset.h" - -#define E_TABLE_SORTED_TYPE (e_table_sorted_get_type ()) -#define E_TABLE_SORTED(o) (GTK_CHECK_CAST ((o), E_TABLE_SORTED_TYPE, ETableSorted)) -#define E_TABLE_SORTED_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_SORTED_TYPE, ETableSortedClass)) -#define E_IS_TABLE_SORTED(o) (GTK_CHECK_TYPE ((o), E_TABLE_SORTED_TYPE)) -#define E_IS_TABLE_SORTED_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_SORTED_TYPE)) - -typedef struct { - ETableSubset base; - - short sort_col; - GCompareFunc compare; -} ETableSorted; - -typedef struct { - ETableSubset parent_class; -} ETableSortedClass; - -GtkType e_table_sorted_get_type (void); -ETableModel *e_table_sorted_new (ETableModel *etm, int col, GCompareFunc compare); -void e_table_sorted_resort (ETableSorted *ets, int col, GCompareFunc compare); - -#endif /* _E_TABLE_SORTED_H_ */ diff --git a/widgets/table/e-table-subset.c b/widgets/table/e-table-subset.c deleted file mode 100644 index 41763d309b..0000000000 --- a/widgets/table/e-table-subset.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * E-table-subset.c: Implements a table that contains a subset of another table. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc. - */ -#include <config.h> -#include "e-util.h" -#include "e-table-subset.h" - -#define PARENT_TYPE E_TABLE_MODEL_TYPE - -static ETableModelClass *etss_parent_class; - -static void -etss_destroy (GtkObject *object) -{ - ETableSubset *etss = E_TABLE_SUBSET (object); - - if (etss->source) - gtk_object_unref (GTK_OBJECT (etss->source)); - - if (etss->map_table) - free (etss->map_table); - - GTK_OBJECT_CLASS (etss_parent_class)->destroy (object); -} - -static int -etss_column_count (ETableModel *etm) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_column_count (etss->source); -} - -static const char * -etss_column_name (ETableModel *etm, int col) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_column_name (etss->source, col); -} - -static int -etss_row_count (ETableModel *etm) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_row_count (etss->source); -} - -static void * -etss_value_at (ETableModel *etm, int col, int row) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_value_at (etss->source, col, etss->map_table [row]); -} - -static void -etss_set_value_at (ETableModel *etm, int col, int row, void *val) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_set_value_at (etss->source, col, etss->map_table [row], val); -} - -static gboolean -etss_is_cell_editable (ETableModel *etm, int col, int row) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_is_cell_editable (etss->source, col, etss->map_table [row]); -} - -static int -etss_row_height (ETableModel *etm, int row) -{ - ETableSubset *etss = (ETableSubset *)etm; - - return e_table_model_row_height (etss->source, etss->map_table [row]); -} - -static void -etss_class_init (GtkObjectClass *klass) -{ - ETableModelClass *table_class = (ETableModelClass *) klass; - - etss_parent_class = gtk_type_class (PARENT_TYPE); - - klass->destroy = etss_destroy; - - table_class->column_count = etss_column_count; - table_class->column_name = etss_column_name; - table_class->row_count = etss_row_count; - table_class->value_at = etss_value_at; - table_class->set_value_at = etss_set_value_at; - table_class->is_cell_editable = etss_is_cell_editable; - table_class->row_height = etss_row_height; - -} - -E_MAKE_TYPE(e_table_subset, "ETableSubset", ETableSubset, etss_class_init, NULL, PARENT_TYPE); - -ETableModel * -e_table_subset_construct (ETableSubset *etss, ETableModel *source, int nvals) -{ - unsigned int *buffer; - int i; - - buffer = (unsigned int *) malloc (sizeof (unsigned int *) * nvals); - if (buffer = NULL) - return NULL; - etss->map_table = buffer; - etss->n_map = nvals; - etss->source = source; - gtk_object_ref (GTK_OBJECT (source)); - - /* Init */ - for (i = 0; i < nvals; i++) - etss->map_table [i] = i; - -} - -ETableModel * -e_table_subset_new (ETableModel *source, const int nvals) -{ - ETableSubset *etss = gtk_type_new (E_TABLE_SUBSET_TYPE); - - if (e_table_subset_construct (etss, source, nvals) == NULL){ - gtk_object_destroy (GTK_OBJECT (etss)); - return NULL; - } - - return (ETableModel *) etss; -} - -ETableModel * -e_table_subset_get_toplevel (ETableSubset *table) -{ - g_return_val_if_fail (table != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_SUBSET (table), NULL); - - if (E_IS_TABLE_SUBSET (table->source)) - return e_table_subset_get_toplevel (E_TABLE_SUBSET (table->source)); - else - return table->subset; -} diff --git a/widgets/table/e-table-subset.h b/widgets/table/e-table-subset.h deleted file mode 100644 index 66d11e9658..0000000000 --- a/widgets/table/e-table-subset.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _E_TABLE_SUBSET_H_ -#define _E_TABLE_SUBSET_H_ - -#include <gtk/gtkobject.h> -#include "e-table-model.h" - -#define E_TABLE_SUBSET_TYPE (e_table_subset_get_type ()) -#define E_TABLE_SUBSET(o) (GTK_CHECK_CAST ((o), E_TABLE_SUBSET_TYPE, ETableSubset)) -#define E_TABLE_SUBSET_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_SUBSET_TYPE, ETableSubsetClass)) -#define E_IS_TABLE_SUBSET(o) (GTK_CHECK_TYPE ((o), E_TABLE_SUBSET_TYPE)) -#define E_IS_TABLE_SUBSET_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_SUBSET_TYPE)) - -typedef struct { - ETableModel base; - - ETableModel *source; - int n_map; - int *map_table; -} ETableSubset; - -typedef struct { - ETableModelClass parent_class; -} ETableSubsetClass; - -GtkType e_table_subset_get_type (void); -ETableModel *e_table_subset_new (ETableModel *etm, int n_vals); -ETableModel *e_table_subset_construct (ETableSubset *ets, ETableModel *source, int nvals); - -ETableModel *e_table_subset_get_toplevel (ETableModel *table_model); - -#endif /* _E_TABLE_SUBSET_H_ */ diff --git a/widgets/table/e-table-tree.h b/widgets/table/e-table-tree.h deleted file mode 100644 index e7e125a6af..0000000000 --- a/widgets/table/e-table-tree.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _E_TABLE_TREE_H_ -#define _E_TABLE_TREE_H_ - -typedef struct { - char *title; - - union { - ETableModel *table; - GList *children; - } u; - - guint expanded :1; - guint is_leaf :1; -} ETableGroup; - -ETableGroup *e_table_group_new (const char *title, ETableModel *table); -ETableGroup *e_table_group_new_leaf (const char *title); - -#endif /* _E_TABLE_TREE_H_ */ diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c deleted file mode 100644 index 3b13e87d6b..0000000000 --- a/widgets/table/e-table.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * E-table-view.c: A graphical view of a Table. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc - */ -#include <config.h> -#include <libgnomeui/gnome-canvas.h> -#include "e-table.h" -#include "e-util.h" - -#define PARENT_OBJECT_TYPE gnome_canvas_get_type () - -E_MAKE_TYPE(e_table, "ETable", ETable, e_table_class_init, NULL, PARENT_TYPE); - -ETable * -e_table_new (ETableHeader *eth, ETableModel *etm) -{ -} - diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h deleted file mode 100644 index 0847ddde6c..0000000000 --- a/widgets/table/e-table.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _E_TABLE_H_ -#define _E_TABLE_H_ - -GtkType e_table_get_type (void); -ETable * -#endif /* _E_TABLE_H_ */ diff --git a/widgets/table/image1.png b/widgets/table/image1.png Binary files differdeleted file mode 100644 index 8326ac241f..0000000000 --- a/widgets/table/image1.png +++ /dev/null diff --git a/widgets/table/image2.png b/widgets/table/image2.png Binary files differdeleted file mode 100644 index e6a4c75dbe..0000000000 --- a/widgets/table/image2.png +++ /dev/null diff --git a/widgets/table/image3.png b/widgets/table/image3.png Binary files differdeleted file mode 100644 index 50e16e8620..0000000000 --- a/widgets/table/image3.png +++ /dev/null diff --git a/widgets/table/sample.table b/widgets/table/sample.table deleted file mode 100644 index 2cb09d7f1f..0000000000 --- a/widgets/table/sample.table +++ /dev/null @@ -1,8 +0,0 @@ -Col1 Col2 Address Title Dorks -c1.a c2.a a.a tit-1 DorkA -c1.b c2.b a.b tit-2 DDork -c1.c c2.c a.c tit-1 DorkB -c1.d c2.d a.d tit-2 ADork -c1.e c2.e a.e tit-1 DorkC -c1.f c2.f a.f tit-2 UDork - diff --git a/widgets/table/table-test.c b/widgets/table/table-test.c deleted file mode 100644 index 32d726dd06..0000000000 --- a/widgets/table/table-test.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Test code for the ETable package - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <fcntl.h> -#include <gnome.h> - -int -main (int argc, char *argv []) -{ - - if (isatty (0)){ - int fd; - - close (0); - fd = open ("sample.table", O_RDONLY); - if (fd == -1){ - fprintf (stderr, "Could not find sample.table, try feeding a table on stdin"); - exit (1); - } - dup2 (fd, 0); - } - - gnome_init ("TableTest", "TableTest", argc, argv); - e_cursors_init (); - - table_browser_test (); - multi_cols_test (); - check_test (); - - gtk_main (); - - e_cursors_shutdown (); - return 0; -} diff --git a/widgets/table/test-check.c b/widgets/table/test-check.c deleted file mode 100644 index 4573580562..0000000000 --- a/widgets/table/test-check.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Test code for the ETable package - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <gnome.h> -#include "e-table-simple.h" -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-item.h" -#include "e-cursors.h" -#include "e-cell-text.h" -#include "e-cell-checkbox.h" - -#define LINES 4 - -static struct { - int value; - char *string; -} my_table [LINES] = { - { 0, "Buy food" }, - { 1, "Breathe " }, - { 0, "Cancel gdb session with shrink" }, - { 1, "Make screenshots" }, -}; -/* - * ETableSimple callbacks - */ -static int -col_count (ETableModel *etc, void *data) -{ - return 2; -} - -static const char * -col_name (ETableModel *etc, int col, void *data) -{ - g_assert (col < 2); - - if (col == 0) - return "flag"; - else - return "text"; -} - -static int -row_count (ETableModel *etc, void *data) -{ - return LINES; -} - -static void * -value_at (ETableModel *etc, int col, int row, void *data) -{ - g_assert (col < 2); - g_assert (row < LINES); - - if (col == 0) - return GINT_TO_POINTER (my_table [row].value); - else - return my_table [row].string; - -} - -static void -set_value_at (ETableModel *etc, int col, int row, const void *val, void *data) -{ - g_assert (col < 2); - g_assert (row < LINES); - - if (col == 0){ - my_table [row].value = GPOINTER_TO_INT (val); - printf ("Value at %d,%d set to %d\n", col, row, GPOINTER_TO_INT (val)); - } else { - my_table [row].string = g_strdup (val); - printf ("Value at %d,%d set to %s\n", col, row, (char *) val); - } -} - -static gboolean -is_cell_editable (ETableModel *etc, int col, int row, void *data) -{ - return TRUE; -} - -static void -set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc) -{ - gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height); -} - -void -check_test (void) -{ - GtkWidget *canvas, *window; - ETableModel *e_table_model; - ETableHeader *e_table_header; - ETableCol *col_0, *col_1; - ECell *cell_left_just, *cell_image_check; - int i; - - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - - e_table_model = e_table_simple_new ( - col_count, col_name, row_count, value_at, - set_value_at, is_cell_editable, NULL); - - /* - * Header - */ - e_table_header = e_table_header_new (); - - cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT); - - cell_image_check = e_cell_checkbox_new (e_table_model); - col_0 = e_table_col_new ("id", "", 18, 18, cell_image_check, g_int_equal, TRUE); - e_table_header_add_column (e_table_header, col_0, 0); - - col_1 = e_table_col_new ("item", "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE); - e_table_header_add_column (e_table_header, col_1, 1); - - /* - * GUI - */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - canvas = gnome_canvas_new (); - - gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate", - GTK_SIGNAL_FUNC (set_canvas_size), NULL); - - gtk_container_add (GTK_CONTAINER (window), canvas); - gtk_widget_show_all (window); - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_header_item_get_type (), - "ETableHeader", e_table_header, - "x", 0, - "y", 0, - NULL); - - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_item_get_type (), - "ETableHeader", e_table_header, - "ETableModel", e_table_model, - "x", 0, - "y", 30, - "drawgrid", TRUE, - "drawfocus", TRUE, - "spreadsheet", TRUE, - NULL); - -} - - - - - diff --git a/widgets/table/test-cols.c b/widgets/table/test-cols.c deleted file mode 100644 index c4ce0e1b75..0000000000 --- a/widgets/table/test-cols.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Test code for the ETable package - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <gnome.h> -#include "e-table-simple.h" -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-item.h" -#include "e-cursors.h" -#include "e-cell-text.h" -#include "e-cell-toggle.h" - -#define LINES 4 - -static struct { - int value; - char *string; -} my_table [LINES] = { - { 0, "You are not" }, - { 1, "A beautiful and unique " }, - { 0, "Snowflake" }, - { 2, "You are not your wallet" }, -}; -/* - * ETableSimple callbacks - */ -static int -col_count (ETableModel *etc, void *data) -{ - return 2; -} - -static const char * -col_name (ETableModel *etc, int col, void *data) -{ - g_assert (col < 2); - - if (col == 0) - return "flag"; - else - return "text"; -} - -static int -row_count (ETableModel *etc, void *data) -{ - return LINES; -} - -static void * -value_at (ETableModel *etc, int col, int row, void *data) -{ - g_assert (col < 2); - g_assert (row < LINES); - - if (col == 0) - return GINT_TO_POINTER (my_table [row].value); - else - return my_table [row].string; - -} - -static void -set_value_at (ETableModel *etc, int col, int row, const void *val, void *data) -{ - g_assert (col < 2); - g_assert (row < LINES); - - if (col == 0){ - my_table [row].value = GPOINTER_TO_INT (val); - printf ("Value at %d,%d set to %d\n", col, row, GPOINTER_TO_INT (val)); - } else { - my_table [row].string = g_strdup (val); - printf ("Value at %d,%d set to %s\n", col, row, (char *) val); - } -} - -static gboolean -is_cell_editable (ETableModel *etc, int col, int row, void *data) -{ - return TRUE; -} - -static void -set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc) -{ - gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height); -} - -void -multi_cols_test (void) -{ - GtkWidget *canvas, *window; - ETableModel *e_table_model; - ETableHeader *e_table_header; - ETableCol *col_0, *col_1; - ECell *cell_left_just, *cell_image_toggle; - int i; - - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - - e_table_model = e_table_simple_new ( - col_count, col_name, row_count, value_at, - set_value_at, is_cell_editable, NULL); - - /* - * Header - */ - e_table_header = e_table_header_new (); - - cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT); - - { - GdkPixbuf **images = g_new (GdkPixbuf *, 3); - int i; - - images [0] = gdk_pixbuf_new_from_file ("image1.png"); - images [1] = gdk_pixbuf_new_from_file ("image2.png"); - images [2] = gdk_pixbuf_new_from_file ("image3.png"); - - cell_image_toggle = e_cell_toggle_new (e_table_model, 0, 3, images); - - for (i = 0; i < 3; i++) - gdk_pixbuf_unref (images [i]); - - g_free (images); - } - - col_0 = e_table_col_new ("id", "A", 48, 48, cell_image_toggle, g_int_equal, TRUE); - e_table_header_add_column (e_table_header, col_0, 0); - - col_1 = e_table_col_new ("item", "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE); - e_table_header_add_column (e_table_header, col_1, 1); - - - /* - * GUI - */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - canvas = gnome_canvas_new (); - - gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate", - GTK_SIGNAL_FUNC (set_canvas_size), NULL); - - gtk_container_add (GTK_CONTAINER (window), canvas); - gtk_widget_show_all (window); - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_header_item_get_type (), - "ETableHeader", e_table_header, - "x", 0, - "y", 0, - NULL); - - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_item_get_type (), - "ETableHeader", e_table_header, - "ETableModel", e_table_model, - "x", 0, - "y", 30, - "drawgrid", TRUE, - "drawfocus", TRUE, - "spreadsheet", TRUE, - NULL); - -} - - - - - diff --git a/widgets/table/test-table.c b/widgets/table/test-table.c deleted file mode 100644 index be1a1059db..0000000000 --- a/widgets/table/test-table.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Test code for the ETable package - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <gnome.h> -#include "e-table-simple.h" -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-item.h" -#include "e-cursors.h" -#include "e-cell-text.h" - -char buffer [1024]; -char **column_labels; -char ***table_data; -int cols = 0; -int lines = 0; -int lines_alloc = 0; - -static void -parse_headers () -{ - char *p, *s; - int in_value = 0, i; - - fgets (buffer, sizeof (buffer)-1, stdin); - - for (p = buffer; *p; p++){ - if (*p == ' ' || *p == '\t'){ - if (in_value){ - cols++; - in_value = 0; - } - } else - in_value = 1; - } - if (in_value) - cols++; - - if (!cols){ - fprintf (stderr, "No columns in first row\n"); - exit (1); - } - - column_labels = g_new0 (char *, cols); - - p = buffer; - for (i = 0; (s = strtok (p, " \t")) != NULL; i++){ - column_labels [i] = g_strdup (s); - p = NULL; - } - - printf ("%d headers:\n", cols); - for (i = 0; i < cols; i++){ - printf ("header %d: %s\n", i, column_labels [i]); - } -} - -static char ** -load_line (char *buffer, int cols) -{ - char **line = g_new0 (char *, cols); - char *p; - int i; - - for (i = 0; i < cols; i++){ - p = strtok (buffer, " \t\n"); - if (p == NULL){ - for (; i < cols; i++) - line [i] = g_strdup (""); - return line; - } else - line [i] = g_strdup (p); - buffer = NULL; - } - return line; -} - -static void -append_line (char **line) -{ - if (lines <= lines_alloc){ - lines_alloc = lines + 50; - table_data = g_renew (char **, table_data, lines_alloc); - } - table_data [lines] = line; - lines++; -} - -static void -load_data () -{ - int i; - - parse_headers (); - - while (fgets (buffer, sizeof (buffer)-1, stdin) != NULL){ - char **line; - - if (buffer [0] == '\n') - continue; - line = load_line (buffer, cols); - append_line (line); - } - - for (i = 0; i < lines; i++){ - int j; - - printf ("Line %d: ", i); - for (j = 0; j < cols; j++) - printf ("[%s] ", table_data [i][j]); - printf ("\n"); - } -} - -/* - * ETableSimple callbacks - */ -static int -col_count (ETableModel *etc, void *data) -{ - return cols; -} - -static const char * -col_name (ETableModel *etc, int col, void *data) -{ - g_assert (col < cols); - - return column_labels [col]; -} - -static int -row_count (ETableModel *etc, void *data) -{ - return lines; -} - -static void * -value_at (ETableModel *etc, int col, int row, void *data) -{ - g_assert (col < cols); - g_assert (row < lines); - - return (void *) table_data [row][col]; -} - -static void -set_value_at (ETableModel *etc, int col, int row, const void *val, void *data) -{ - g_assert (col < cols); - g_assert (row < lines); - - g_free (table_data [row][col]); - table_data [row][col] = g_strdup (val); - - printf ("Value at %d,%d set to %s\n", col, row, (char *) val); -} - -static gboolean -is_cell_editable (ETableModel *etc, int col, int row, void *data) -{ - return TRUE; -} - -static void -set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc) -{ - gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height); -} - -void -table_browser_test (void) -{ - GtkWidget *canvas, *window; - ETableModel *e_table_model; - ETableHeader *e_table_header; - ECell *cell_left_just; - int i; - - load_data (); - - /* - * Data model - */ - e_table_model = e_table_simple_new ( - col_count, col_name, row_count, value_at, - set_value_at, is_cell_editable, NULL); - - /* - * Header - */ - e_table_header = e_table_header_new (); - cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT); - - for (i = 0; i < cols; i++){ - ETableCol *ecol = e_table_col_new ( - column_labels [i], column_labels [i], - 80, 20, cell_left_just, - g_str_equal, TRUE); - - e_table_header_add_column (e_table_header, ecol, i); - } - - /* - * Setup GUI - */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - canvas = gnome_canvas_new (); - - gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate", - GTK_SIGNAL_FUNC (set_canvas_size), NULL); - - gtk_container_add (GTK_CONTAINER (window), canvas); - gtk_widget_show_all (window); - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_header_item_get_type (), - "ETableHeader", e_table_header, - "x", 0, - "y", 0, - NULL); - - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_item_get_type (), - "ETableHeader", e_table_header, - "ETableModel", e_table_model, - "x", 10, - "y", 30, - "drawgrid", TRUE, - "drawfocus", TRUE, - "spreadsheet", TRUE, - NULL); -} - diff --git a/widgets/table/test.c b/widgets/table/test.c deleted file mode 100644 index 0eece34467..0000000000 --- a/widgets/table/test.c +++ /dev/null @@ -1,17 +0,0 @@ -#include <config.h> -#include "e-table-simple.h" - -struct { - char *str; - int val; -} data [] = { - { "Miguel", 10 }, - { "Nat", 20 }, - { NULL, 0 }, -}; - -main () -{ - -} - diff --git a/widgets/test-check.c b/widgets/test-check.c deleted file mode 100644 index 4573580562..0000000000 --- a/widgets/test-check.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Test code for the ETable package - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <gnome.h> -#include "e-table-simple.h" -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-item.h" -#include "e-cursors.h" -#include "e-cell-text.h" -#include "e-cell-checkbox.h" - -#define LINES 4 - -static struct { - int value; - char *string; -} my_table [LINES] = { - { 0, "Buy food" }, - { 1, "Breathe " }, - { 0, "Cancel gdb session with shrink" }, - { 1, "Make screenshots" }, -}; -/* - * ETableSimple callbacks - */ -static int -col_count (ETableModel *etc, void *data) -{ - return 2; -} - -static const char * -col_name (ETableModel *etc, int col, void *data) -{ - g_assert (col < 2); - - if (col == 0) - return "flag"; - else - return "text"; -} - -static int -row_count (ETableModel *etc, void *data) -{ - return LINES; -} - -static void * -value_at (ETableModel *etc, int col, int row, void *data) -{ - g_assert (col < 2); - g_assert (row < LINES); - - if (col == 0) - return GINT_TO_POINTER (my_table [row].value); - else - return my_table [row].string; - -} - -static void -set_value_at (ETableModel *etc, int col, int row, const void *val, void *data) -{ - g_assert (col < 2); - g_assert (row < LINES); - - if (col == 0){ - my_table [row].value = GPOINTER_TO_INT (val); - printf ("Value at %d,%d set to %d\n", col, row, GPOINTER_TO_INT (val)); - } else { - my_table [row].string = g_strdup (val); - printf ("Value at %d,%d set to %s\n", col, row, (char *) val); - } -} - -static gboolean -is_cell_editable (ETableModel *etc, int col, int row, void *data) -{ - return TRUE; -} - -static void -set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc) -{ - gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height); -} - -void -check_test (void) -{ - GtkWidget *canvas, *window; - ETableModel *e_table_model; - ETableHeader *e_table_header; - ETableCol *col_0, *col_1; - ECell *cell_left_just, *cell_image_check; - int i; - - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - - e_table_model = e_table_simple_new ( - col_count, col_name, row_count, value_at, - set_value_at, is_cell_editable, NULL); - - /* - * Header - */ - e_table_header = e_table_header_new (); - - cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT); - - cell_image_check = e_cell_checkbox_new (e_table_model); - col_0 = e_table_col_new ("id", "", 18, 18, cell_image_check, g_int_equal, TRUE); - e_table_header_add_column (e_table_header, col_0, 0); - - col_1 = e_table_col_new ("item", "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE); - e_table_header_add_column (e_table_header, col_1, 1); - - /* - * GUI - */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - canvas = gnome_canvas_new (); - - gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate", - GTK_SIGNAL_FUNC (set_canvas_size), NULL); - - gtk_container_add (GTK_CONTAINER (window), canvas); - gtk_widget_show_all (window); - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_header_item_get_type (), - "ETableHeader", e_table_header, - "x", 0, - "y", 0, - NULL); - - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_item_get_type (), - "ETableHeader", e_table_header, - "ETableModel", e_table_model, - "x", 0, - "y", 30, - "drawgrid", TRUE, - "drawfocus", TRUE, - "spreadsheet", TRUE, - NULL); - -} - - - - - diff --git a/widgets/test-cols.c b/widgets/test-cols.c deleted file mode 100644 index c4ce0e1b75..0000000000 --- a/widgets/test-cols.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Test code for the ETable package - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <gnome.h> -#include "e-table-simple.h" -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-item.h" -#include "e-cursors.h" -#include "e-cell-text.h" -#include "e-cell-toggle.h" - -#define LINES 4 - -static struct { - int value; - char *string; -} my_table [LINES] = { - { 0, "You are not" }, - { 1, "A beautiful and unique " }, - { 0, "Snowflake" }, - { 2, "You are not your wallet" }, -}; -/* - * ETableSimple callbacks - */ -static int -col_count (ETableModel *etc, void *data) -{ - return 2; -} - -static const char * -col_name (ETableModel *etc, int col, void *data) -{ - g_assert (col < 2); - - if (col == 0) - return "flag"; - else - return "text"; -} - -static int -row_count (ETableModel *etc, void *data) -{ - return LINES; -} - -static void * -value_at (ETableModel *etc, int col, int row, void *data) -{ - g_assert (col < 2); - g_assert (row < LINES); - - if (col == 0) - return GINT_TO_POINTER (my_table [row].value); - else - return my_table [row].string; - -} - -static void -set_value_at (ETableModel *etc, int col, int row, const void *val, void *data) -{ - g_assert (col < 2); - g_assert (row < LINES); - - if (col == 0){ - my_table [row].value = GPOINTER_TO_INT (val); - printf ("Value at %d,%d set to %d\n", col, row, GPOINTER_TO_INT (val)); - } else { - my_table [row].string = g_strdup (val); - printf ("Value at %d,%d set to %s\n", col, row, (char *) val); - } -} - -static gboolean -is_cell_editable (ETableModel *etc, int col, int row, void *data) -{ - return TRUE; -} - -static void -set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc) -{ - gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height); -} - -void -multi_cols_test (void) -{ - GtkWidget *canvas, *window; - ETableModel *e_table_model; - ETableHeader *e_table_header; - ETableCol *col_0, *col_1; - ECell *cell_left_just, *cell_image_toggle; - int i; - - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - - e_table_model = e_table_simple_new ( - col_count, col_name, row_count, value_at, - set_value_at, is_cell_editable, NULL); - - /* - * Header - */ - e_table_header = e_table_header_new (); - - cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT); - - { - GdkPixbuf **images = g_new (GdkPixbuf *, 3); - int i; - - images [0] = gdk_pixbuf_new_from_file ("image1.png"); - images [1] = gdk_pixbuf_new_from_file ("image2.png"); - images [2] = gdk_pixbuf_new_from_file ("image3.png"); - - cell_image_toggle = e_cell_toggle_new (e_table_model, 0, 3, images); - - for (i = 0; i < 3; i++) - gdk_pixbuf_unref (images [i]); - - g_free (images); - } - - col_0 = e_table_col_new ("id", "A", 48, 48, cell_image_toggle, g_int_equal, TRUE); - e_table_header_add_column (e_table_header, col_0, 0); - - col_1 = e_table_col_new ("item", "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE); - e_table_header_add_column (e_table_header, col_1, 1); - - - /* - * GUI - */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - canvas = gnome_canvas_new (); - - gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate", - GTK_SIGNAL_FUNC (set_canvas_size), NULL); - - gtk_container_add (GTK_CONTAINER (window), canvas); - gtk_widget_show_all (window); - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_header_item_get_type (), - "ETableHeader", e_table_header, - "x", 0, - "y", 0, - NULL); - - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_item_get_type (), - "ETableHeader", e_table_header, - "ETableModel", e_table_model, - "x", 0, - "y", 30, - "drawgrid", TRUE, - "drawfocus", TRUE, - "spreadsheet", TRUE, - NULL); - -} - - - - - diff --git a/widgets/test-table.c b/widgets/test-table.c deleted file mode 100644 index be1a1059db..0000000000 --- a/widgets/test-table.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Test code for the ETable package - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <gnome.h> -#include "e-table-simple.h" -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-item.h" -#include "e-cursors.h" -#include "e-cell-text.h" - -char buffer [1024]; -char **column_labels; -char ***table_data; -int cols = 0; -int lines = 0; -int lines_alloc = 0; - -static void -parse_headers () -{ - char *p, *s; - int in_value = 0, i; - - fgets (buffer, sizeof (buffer)-1, stdin); - - for (p = buffer; *p; p++){ - if (*p == ' ' || *p == '\t'){ - if (in_value){ - cols++; - in_value = 0; - } - } else - in_value = 1; - } - if (in_value) - cols++; - - if (!cols){ - fprintf (stderr, "No columns in first row\n"); - exit (1); - } - - column_labels = g_new0 (char *, cols); - - p = buffer; - for (i = 0; (s = strtok (p, " \t")) != NULL; i++){ - column_labels [i] = g_strdup (s); - p = NULL; - } - - printf ("%d headers:\n", cols); - for (i = 0; i < cols; i++){ - printf ("header %d: %s\n", i, column_labels [i]); - } -} - -static char ** -load_line (char *buffer, int cols) -{ - char **line = g_new0 (char *, cols); - char *p; - int i; - - for (i = 0; i < cols; i++){ - p = strtok (buffer, " \t\n"); - if (p == NULL){ - for (; i < cols; i++) - line [i] = g_strdup (""); - return line; - } else - line [i] = g_strdup (p); - buffer = NULL; - } - return line; -} - -static void -append_line (char **line) -{ - if (lines <= lines_alloc){ - lines_alloc = lines + 50; - table_data = g_renew (char **, table_data, lines_alloc); - } - table_data [lines] = line; - lines++; -} - -static void -load_data () -{ - int i; - - parse_headers (); - - while (fgets (buffer, sizeof (buffer)-1, stdin) != NULL){ - char **line; - - if (buffer [0] == '\n') - continue; - line = load_line (buffer, cols); - append_line (line); - } - - for (i = 0; i < lines; i++){ - int j; - - printf ("Line %d: ", i); - for (j = 0; j < cols; j++) - printf ("[%s] ", table_data [i][j]); - printf ("\n"); - } -} - -/* - * ETableSimple callbacks - */ -static int -col_count (ETableModel *etc, void *data) -{ - return cols; -} - -static const char * -col_name (ETableModel *etc, int col, void *data) -{ - g_assert (col < cols); - - return column_labels [col]; -} - -static int -row_count (ETableModel *etc, void *data) -{ - return lines; -} - -static void * -value_at (ETableModel *etc, int col, int row, void *data) -{ - g_assert (col < cols); - g_assert (row < lines); - - return (void *) table_data [row][col]; -} - -static void -set_value_at (ETableModel *etc, int col, int row, const void *val, void *data) -{ - g_assert (col < cols); - g_assert (row < lines); - - g_free (table_data [row][col]); - table_data [row][col] = g_strdup (val); - - printf ("Value at %d,%d set to %s\n", col, row, (char *) val); -} - -static gboolean -is_cell_editable (ETableModel *etc, int col, int row, void *data) -{ - return TRUE; -} - -static void -set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc) -{ - gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height); -} - -void -table_browser_test (void) -{ - GtkWidget *canvas, *window; - ETableModel *e_table_model; - ETableHeader *e_table_header; - ECell *cell_left_just; - int i; - - load_data (); - - /* - * Data model - */ - e_table_model = e_table_simple_new ( - col_count, col_name, row_count, value_at, - set_value_at, is_cell_editable, NULL); - - /* - * Header - */ - e_table_header = e_table_header_new (); - cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT); - - for (i = 0; i < cols; i++){ - ETableCol *ecol = e_table_col_new ( - column_labels [i], column_labels [i], - 80, 20, cell_left_just, - g_str_equal, TRUE); - - e_table_header_add_column (e_table_header, ecol, i); - } - - /* - * Setup GUI - */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - canvas = gnome_canvas_new (); - - gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate", - GTK_SIGNAL_FUNC (set_canvas_size), NULL); - - gtk_container_add (GTK_CONTAINER (window), canvas); - gtk_widget_show_all (window); - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_header_item_get_type (), - "ETableHeader", e_table_header, - "x", 0, - "y", 0, - NULL); - - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_item_get_type (), - "ETableHeader", e_table_header, - "ETableModel", e_table_model, - "x", 10, - "y", 30, - "drawgrid", TRUE, - "drawfocus", TRUE, - "spreadsheet", TRUE, - NULL); -} - diff --git a/widgets/test.c b/widgets/test.c deleted file mode 100644 index 0eece34467..0000000000 --- a/widgets/test.c +++ /dev/null @@ -1,17 +0,0 @@ -#include <config.h> -#include "e-table-simple.h" - -struct { - char *str; - int val; -} data [] = { - { "Miguel", 10 }, - { "Nat", 20 }, - { NULL, 0 }, -}; - -main () -{ - -} - |