[Goodies-commits] r7058 - in xfbib/trunk: . po src
Jesper Karlsson
zarper at xfce.org
Mon Mar 30 22:18:57 CEST 2009
Author: zarper
Date: 2009-03-30 20:18:56 +0000 (Mon, 30 Mar 2009)
New Revision: 7058
Added:
xfbib/trunk/AUTHORS
xfbib/trunk/COPYING
xfbib/trunk/ChangeLog
xfbib/trunk/INSTALL
xfbib/trunk/Makefile.am
xfbib/trunk/NEWS
xfbib/trunk/README
xfbib/trunk/TODO
xfbib/trunk/autogen.sh
xfbib/trunk/configure.ac.in
xfbib/trunk/icons/
xfbib/trunk/pixmaps/
xfbib/trunk/po/
xfbib/trunk/po/POTFILES.in
xfbib/trunk/po/xfbib.pot
xfbib/trunk/src/
xfbib/trunk/src/main.c
xfbib/trunk/src/xfbib-bibtex-field.c
xfbib/trunk/src/xfbib-bibtex-field.h
xfbib/trunk/src/xfbib-bibtex-string.c
xfbib/trunk/src/xfbib-bibtex-string.h
xfbib/trunk/src/xfbib-bibtex-value.c
xfbib/trunk/src/xfbib-bibtex.c
xfbib/trunk/src/xfbib-entry-edit-dialog.c
xfbib/trunk/src/xfbib-entry-tree-view.c
xfbib/trunk/src/xfbib-file-io.c
xfbib/trunk/src/xfbib-file-io.h
xfbib/trunk/src/xfbib-input-dialog.c
xfbib/trunk/src/xfbib-menu-bar.c
xfbib/trunk/src/xfbib-multiple-input.c
xfbib/trunk/src/xfbib-string-tree-view.c
xfbib/trunk/src/xfbib-string.c
xfbib/trunk/src/xfbib-string.h
xfbib/trunk/src/xfbib-toolbar.c
xfbib/trunk/src/xfbib-window.c
xfbib/trunk/tests/
xfbib/trunk/xfbib.desktop.in
Removed:
xfbib/trunk/po/POTFILES.in
xfbib/trunk/src/main.c
xfbib/trunk/src/xfbib-bibtex-field.c
xfbib/trunk/src/xfbib-bibtex-field.h
xfbib/trunk/src/xfbib-bibtex-string.c
xfbib/trunk/src/xfbib-bibtex-string.h
xfbib/trunk/src/xfbib-bibtex-value.c
xfbib/trunk/src/xfbib-bibtex.c
xfbib/trunk/src/xfbib-entry-edit-dialog.c
xfbib/trunk/src/xfbib-entry-tree-view.c
xfbib/trunk/src/xfbib-file-io.c
xfbib/trunk/src/xfbib-file-io.h
xfbib/trunk/src/xfbib-input-dialog.c
xfbib/trunk/src/xfbib-menu-bar.c
xfbib/trunk/src/xfbib-multiple-input.c
xfbib/trunk/src/xfbib-string-tree-view.c
xfbib/trunk/src/xfbib-string.c
xfbib/trunk/src/xfbib-string.h
xfbib/trunk/src/xfbib-toolbar.c
xfbib/trunk/src/xfbib-window.c
Log:
Moving gobject branch into trunk
Copied: xfbib/trunk/AUTHORS (from rev 6996, xfbib/branches/gobject/AUTHORS)
===================================================================
--- xfbib/trunk/AUTHORS (rev 0)
+++ xfbib/trunk/AUTHORS 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,2 @@
+David Gustafsson <david.s.gustafsson at gmail.com>
+Jesper Karlsson <zarper at gmail.com>
Copied: xfbib/trunk/COPYING (from rev 6996, xfbib/branches/gobject/COPYING)
===================================================================
--- xfbib/trunk/COPYING (rev 0)
+++ xfbib/trunk/COPYING 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. 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
+them 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 prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. 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.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey 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;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If 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 convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU 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 that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ 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.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+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.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ 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
+state 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 3 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, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program 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, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU 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 Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
Copied: xfbib/trunk/ChangeLog (from rev 7054, xfbib/branches/gobject/ChangeLog)
===================================================================
--- xfbib/trunk/ChangeLog (rev 0)
+++ xfbib/trunk/ChangeLog 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,12 @@
+2009-03-30 gettextize <bug-gnu-gettext at gnu.org>
+
+ * Makefile.am (SUBDIRS): Add intl.
+ * configure.ac (AC_OUTPUT): Add intl/Makefile.
+
+2009-03-30 gettextize <bug-gnu-gettext at gnu.org>
+
+ * Makefile.am (SUBDIRS): Add intl.
+ (ACLOCAL_AMFLAGS): New variable.
+ (EXTRA_DIST): Add config.rpath, m4/ChangeLog.
+ * configure.ac (AC_OUTPUT): Add intl/Makefile.
+
Copied: xfbib/trunk/INSTALL (from rev 6996, xfbib/branches/gobject/INSTALL)
===================================================================
--- xfbib/trunk/INSTALL (rev 0)
+++ xfbib/trunk/INSTALL 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,291 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008 Free Software Foundation, Inc.
+
+ This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+ Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package. The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+ 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, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+ 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 you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You need `configure.ac' 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.
+
+ Running `configure' might take a while. 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.
+
+ 6. Often, you can also type `make uninstall' to remove the installed
+ files again.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
+
+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
+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 can use 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 `..'.
+
+ With a non-GNU `make', it is safer 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.
+
+ On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor. Like
+this:
+
+ ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CPP="gcc -E" CXXCPP="g++ -E"
+
+ This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
+Installation Names
+==================
+
+ By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc. You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' 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.
+
+Particular systems
+==================
+
+ On HP-UX, the default C compiler is not ANSI C compatible. If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+ ./configure CC="cc -Ae"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+ On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file. The option `-nodtk' can be used as
+a workaround. If GNU CC is not installed, it is therefore recommended
+to try
+
+ ./configure CC="cc"
+
+and if that doesn't work, try
+
+ ./configure CC="cc -nodtk"
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on. Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS KERNEL-OS
+
+ 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 machine type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+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.
+
+Defining Variables
+==================
+
+ Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug. Until the bug is fixed you can use this workaround:
+
+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+ Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+ Print a summary of the options unique to this package's
+ `configure', and exit. The `short' variant lists options used
+ only in the top level, while the `recursive' variant lists options
+ also present in any nested packages.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--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.
+
+`--prefix=DIR'
+ Use DIR as the installation prefix. *Note Installation Names::
+ for more details, including other options available for fine-tuning
+ the installation locations.
+
+`--no-create'
+`-n'
+ Run the configure checks, but stop before creating any output
+ files.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
+
Copied: xfbib/trunk/Makefile.am (from rev 7054, xfbib/branches/gobject/Makefile.am)
===================================================================
--- xfbib/trunk/Makefile.am (rev 0)
+++ xfbib/trunk/Makefile.am 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,36 @@
+SUBDIRS = \
+ po \
+ src \
+ tests \
+ icons \
+ pixmaps
+
+desktopdir = $(datadir)/applications
+desktop_in_files = xfbib.desktop.in
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+ at INTLTOOL_DESKTOP_RULE@
+
+AUTOMAKE_OPTIONS = \
+ 1.8 \
+ dist-bzip2
+
+EXTRA_DIST = config.rpath m4/ChangeLog \
+ autogen.sh \
+ intltool-extract.in \
+ intltool-merge.in \
+ intltool-update.in \
+ $(desktop_in_files) \
+ $(pixmaps_DATA)
+
+DISTCLEANFILES = \
+ intltool-extract \
+ intltool-merge \
+ intltool-update \
+ $(desktop_DATA)
+
+
+
+distclean-local:
+ -rm -rf *.cache *~
+
+ACLOCAL_AMFLAGS = -I m4
Copied: xfbib/trunk/TODO (from rev 6996, xfbib/branches/gobject/TODO)
===================================================================
--- xfbib/trunk/TODO (rev 0)
+++ xfbib/trunk/TODO 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,11 @@
+Complete the following tasks before merging the branch into trunk
+ * Complete the code for parsing preamble, string, entry, fields
+ and complete bibtex files.
+ * Complete the testsuite for the parser-
+ * Update the icons.
+ * Fix the native language support.
+ * Support for non volatile configuration.
+ * Update the README file.
+ * Make the entries editable.
+ * Add funtionality so that bibtex files can be merged.
+ * Make the list sortable.
Copied: xfbib/trunk/autogen.sh (from rev 6996, xfbib/branches/gobject/autogen.sh)
===================================================================
--- xfbib/trunk/autogen.sh (rev 0)
+++ xfbib/trunk/autogen.sh 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# $Id: autogen.sh 23241 2006-09-29 19:05:15Z kelnos $
+#
+# Copyright (c) 2002-2005
+# The Xfce development team. All rights reserved.
+#
+# Written for Xfce by Benedikt Meurer <benny at xfce.org>.
+#
+
+(type xdt-autogen) >/dev/null 2>&1 || {
+ cat >&2 <<EOF
+autogen.sh: You don't seem to have the Xfce development tools installed on
+ your system, which are required to build this software.
+ Please install the xfce4-dev-tools package first, available from
+ http://xfce.org/~benny/projects/xfce4-dev-tools/.
+EOF
+ exit 1
+}
+
+# verify that po/LINGUAS is present
+(test -f po/LINGUAS) >/dev/null 2>&1 || {
+ cat >&2 <<EOF
+autogen.sh: The file po/LINGUAS could not be found. Please check your snapshot
+ or try to checkout again.
+EOF
+ exit 1
+}
+
+echo 'dnl *** This file is automatically generated from configure.ac.in ***' \
+ >configure.ac
+echo 'dnl *** DO NOT EDIT! ***' >>configure.ac
+echo >>configure.ac
+
+# substitute revision and linguas
+linguas=$(sed -e '/^#/d' po/LINGUAS)
+if [ -d .git/svn ]; then
+ revision=$(git-svn log | head -n 2 | tail -n 1 | cut -d' ' -f1 | cut -dr -f2)
+elif [ -d .svn ]; then
+ revision=$(LC_ALL=C svn info $0 | awk '/^Revision: / {printf "%05d\n", $2}')
+else
+ revision=UNKNOWN
+fi
+sed -e "s/@LINGUAS@/${linguas}/g" \
+ -e "s/@REVISION@/${revision}/g" \
+ < "configure.ac.in" >> "configure.ac"
+
+xdt-autogen $@
+
+# vi:set ts=2 sw=2 et ai:
Copied: xfbib/trunk/configure.ac.in (from rev 6996, xfbib/branches/gobject/configure.ac.in)
===================================================================
--- xfbib/trunk/configure.ac.in (rev 0)
+++ xfbib/trunk/configure.ac.in 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,96 @@
+dnl configure.ac
+dnl
+dnl xfbib - A BibTeX editor written for the Xfce Dessktop environment
+dnl
+dnl Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+dnl All rights reserved.
+
+
+dnl version info
+m4_define([xfbib_version_major], [0])
+m4_define([xfbib_version_minor], [1])
+m4_define([xfbib_version_micro], [0])
+m4_define([xfbib_version_build], [r at REVISION@])
+m4_define([xfbib_version_tag], [svn])
+m4_define([xfbib_version], [xfbib_version_major().xfbib_version_minor().xfbib_version_micro()ifelse(xfbib_version_tag(), [svn], [xfbib_version_tag()-xfbib_version_build()], [xfbib_version_tag()])])
+
+dnl init autoconf
+AC_INIT([Xfbib], [xfbib_version], [david.s.gustafsson at gmail.com])
+AC_PREREQ([2.50])
+
+dnl init automake
+XFTEST_VERSION=xfbib_version
+AM_INIT_AUTOMAKE()
+AM_CONFIG_HEADER([config.h])
+AC_DEFINE([WEBSITE], ["http://goodies.xfce.org/projects/applications/xfbib"],
+ [Location of the xfbib website])
+AM_MAINTAINER_MODE
+
+dnl check for UNIX variants
+AC_AIX
+AC_ISC_POSIX
+AC_MINIX
+
+dnl check for basic programs
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_INSTALL
+AC_PROG_LIBTOOL
+AC_PROG_INTLTOOL([0.31], [no-xml])
+AC_PROG_MAKE_SET
+
+dnl check for standard header files
+AC_HEADER_STDC
+AC_CHECK_HEADERS([errno.h stdlib.h string.h unistd.h])
+AC_CHECK_FUNCS([exit strdup malloc])
+
+dnl get svn revision
+SVN=`which svn`
+if test "$SVN" -a -x "$SVN"; then
+ dir="`dirname $0`"
+ SVN_REVISION=`LC_ALL=C svn info "$dir" | awk '/^Revision: / {printf "%05d\n", $2}'`
+fi
+if test -z "$SVN_REVISION"; then
+ SVN_REVISION="@REVISION@"
+fi
+AC_DEFINE_UNQUOTED([SVN_REVISION], "$REVISION", [subversion revision number])
+AC_SUBST([SVN_REVISION])
+
+dnl Check for i18n support
+XDT_I18N([@LINGUAS@])
+
+dnl Check for X11 installed
+XDT_CHECK_LIBX11_REQUIRE
+XDT_CHECK_LIBSM
+
+dnl required
+XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.10.0])
+XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.12.0])
+XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [2.12.0])
+dnl XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [0])
+XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.4.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0])
+
+dnl check for debugging support
+XDT_FEATURE_DEBUG
+ if test "x$enable_debug" = "xfull"; then
+ if test "x$CC" = "xgcc"; then
+ CFLAGS="$CFLAGS -fno-strict-aliasing -pg"
+ fi
+ fi
+
+AC_OUTPUT([
+Makefile
+src/Makefile
+tests/Makefile
+po/Makefile.in
+icons/Makefile
+icons/16x16/Makefile
+icons/22x22/Makefile
+icons/24x24/Makefile
+icons/32x32/Makefile
+icons/36x36/Makefile
+icons/48x48/Makefile
+icons/scalable/Makefile
+pixmaps/Makefile
+])
Copied: xfbib/trunk/po/POTFILES.in (from rev 7054, xfbib/branches/gobject/po/POTFILES.in)
===================================================================
--- xfbib/trunk/po/POTFILES.in (rev 0)
+++ xfbib/trunk/po/POTFILES.in 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,15 @@
+src/main.c
+src/xfbib-bibtex.c
+src/xfbib-bibtex-field.c
+src/xfbib-bibtex-string.c
+src/xfbib-bibtex-value.c
+src/xfbib-entry-edit-dialog.c
+src/xfbib-entry-tree-view.c
+src/xfbib-file-io.c
+src/xfbib-input-dialog.c
+src/xfbib-menu-bar.c
+src/xfbib-multiple-input.c
+src/xfbib-string.c
+src/xfbib-string-tree-view.c
+src/xfbib-toolbar.c
+src/xfbib-window.c
Copied: xfbib/trunk/po/xfbib.pot (from rev 7054, xfbib/branches/gobject/po/xfbib.pot)
===================================================================
--- xfbib/trunk/po/xfbib.pot (rev 0)
+++ xfbib/trunk/po/xfbib.pot 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,379 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL at ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-03-30 22:05+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../src/main.c:70
+msgid "main_entries"
+msgstr ""
+
+#: ../src/main.c:71
+msgid "Report bugs to http://bugs.xfce.org/\n"
+msgstr ""
+
+#: ../src/main.c:73
+#, c-format
+msgid "Error parsing: %s\n"
+msgstr ""
+
+#: ../src/main.c:112
+msgid "Error merging files, no output file specified\n"
+msgstr ""
+
+#: ../src/xfbib-bibtex.c:129 ../src/xfbib-bibtex.c:244
+#, c-format
+msgid "Error, on line %d(TODO)\n"
+msgstr ""
+
+#: ../src/xfbib-bibtex.c:148
+msgid "Error, could not parse wrong entry type (TODO)\n"
+msgstr ""
+
+#: ../src/xfbib-bibtex-field.c:96
+msgid "No equal sign found in definition of Field\n"
+msgstr ""
+
+#: ../src/xfbib-bibtex-string.c:125
+msgid "No equal sign found in definition of String\n"
+msgstr ""
+
+#: ../src/xfbib-bibtex-value.c:121
+#, c-format
+msgid "Braced string contains @: %s\n"
+msgstr ""
+
+#: ../src/xfbib-bibtex-value.c:134
+#, c-format
+msgid "Quote not inside braces in string: %s\n"
+msgstr ""
+
+#: ../src/xfbib-bibtex-value.c:141
+#, c-format
+msgid "Braces not balanced in field string: %s\n"
+msgstr ""
+
+#: ../src/xfbib-bibtex-value.c:151
+msgid "Variable contains double quote\n"
+msgstr ""
+
+#: ../src/xfbib-bibtex-value.c:164
+msgid "TODO: Add a character in number warning\n"
+msgstr ""
+
+#: ../src/xfbib-entry-edit-dialog.c:123
+msgid "Edit compund string"
+msgstr ""
+
+#: ../src/xfbib-entry-edit-dialog.c:134
+msgid "Text/String key"
+msgstr ""
+
+#: ../src/xfbib-entry-edit-dialog.c:178
+#, c-format
+msgid "Button icon missing: %s"
+msgstr ""
+
+#: ../src/xfbib-entry-edit-dialog.c:224
+msgid "Type:"
+msgstr ""
+
+#: ../src/xfbib-entry-edit-dialog.c:231
+msgid "Key:"
+msgstr ""
+
+#: ../src/xfbib-entry-edit-dialog.c:327 ../src/xfbib-multiple-input.c:168
+msgid "Title"
+msgstr ""
+
+#: ../src/xfbib-entry-edit-dialog.c:328
+msgid "Author/Editor"
+msgstr ""
+
+#: ../src/xfbib-entry-edit-dialog.c:329
+msgid "Publication"
+msgstr ""
+
+#: ../src/xfbib-entry-edit-dialog.c:330
+msgid "Publisher"
+msgstr ""
+
+#: ../src/xfbib-entry-edit-dialog.c:331
+msgid "Misc"
+msgstr ""
+
+#: ../src/xfbib-entry-edit-dialog.c:484
+msgid "A BibTeX type is required!"
+msgstr ""
+
+#: ../src/xfbib-entry-edit-dialog.c:488
+msgid "BibTex key is required!"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:172
+msgid "Address of publisher"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:173
+msgid "Annotation for annotated bibliography styles"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:174
+msgid "Name(s) of the author(s), separated by 'and' if more than one"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:175
+msgid "Title of the book, if only part of it is being cited"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:176
+msgid "Chapter number"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:177
+msgid "Citation key of the cross-referenced entry"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:178
+msgid "Edition of the book (such as \"first\" or \"second\")"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:179
+msgid "Name(s) of the editor(s), separated by 'and' if more than one"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:180
+msgid "Specification of electronic publication"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:181
+msgid "Publishing method if the method is nonstandard"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:182
+msgid "Institution that was involved in the publishing"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:183
+msgid "Journal or magazine in which the work was published"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:184
+msgid ""
+"Hidden field used for specifying or overriding the alphabetical order of "
+"entries"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:185
+msgid "Month of publication or creation if unpublished"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:186
+msgid "Miscellaneous extra information"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:187
+msgid "Number of journal, magazine, or tech-report"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:188
+msgid "Sponsor of the conference"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:189
+msgid "Page numbers separated by commas or double-hyphens"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:190
+msgid "Name of publisher"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:191
+msgid "School where thesis was written"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:192
+msgid "Series of books in which the book was published"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:193
+msgid "Title of the work"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:194
+msgid "Type of technical report"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:195
+msgid "Internet address"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:196
+msgid "Number of the volume"
+msgstr ""
+
+#: ../src/xfbib-entry-tree-view.c:197
+msgid "Year of publication or creation if unpublished"
+msgstr ""
+
+#: ../src/xfbib-file-io.c:75
+msgid "Open"
+msgstr ""
+
+#: ../src/xfbib-file-io.c:83
+msgid "BibTeX files"
+msgstr ""
+
+#: ../src/xfbib-file-io.c:99 ../src/xfbib-file-io.c:141
+#, c-format
+msgid "An error occured when opening the file: %s\n"
+msgstr ""
+
+#: ../src/xfbib-file-io.c:146
+#, c-format
+msgid "An error occured when writing to the file: %s\n"
+msgstr ""
+
+#: ../src/xfbib-file-io.c:162
+msgid "Save as\n"
+msgstr ""
+
+#: ../src/xfbib-file-io.c:167
+msgid "Save As"
+msgstr ""
+
+#: ../src/xfbib-file-io.c:206
+#, c-format
+msgid "printing bibtex string to file\n"
+msgstr ""
+
+#: ../src/xfbib-file-io.c:227
+#, c-format
+msgid "Unknown object!\n"
+msgstr ""
+
+#: ../src/xfbib-input-dialog.c:92
+msgid "String key:"
+msgstr ""
+
+#: ../src/xfbib-input-dialog.c:93
+msgid "Text:"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:66
+msgid "File/New\n"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:74
+msgid "File/Open\n"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:88
+msgid "File/Save\n"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:97
+msgid "File/Save As\n"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:114
+msgid "Entry/Add\n"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:143
+msgid "Entry/Remove\n"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:153 ../src/xfbib-menu-bar.c:234
+msgid "No row has been selected for removal"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:166
+msgid "Entry/Edit\n"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:189 ../src/xfbib-menu-bar.c:266
+msgid "No row has been selected for edit"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:200
+msgid "Variable/add\n"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:224
+msgid "Variable/Remove\n"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:247
+msgid "Variable/Edit\n"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:285
+msgid "Xfbib is a BibTeX editor for the Xfce Desktop Environment."
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:373
+msgid "File"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:398 ../src/xfbib-window.c:113
+msgid "Entry"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:422 ../src/xfbib-window.c:121
+msgid "Variable"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:446
+msgid "Show Toolbar"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:449
+msgid "Show Status Bar"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:452
+msgid "View"
+msgstr ""
+
+#: ../src/xfbib-menu-bar.c:465
+msgid "Help"
+msgstr ""
+
+#: ../src/xfbib-multiple-input.c:81
+#, c-format
+msgid "Add %s"
+msgstr ""
+
+#: ../src/xfbib-string.c:95
+#, c-format
+msgid "Setting string: <%s>\n"
+msgstr ""
+
+#: ../src/xfbib-string-tree-view.c:213
+msgid "Value"
+msgstr ""
+
+#: ../src/xfbib-toolbar.c:57
+msgid "Toolbar_Open\n"
+msgstr ""
+
+#: ../src/xfbib-toolbar.c:71
+msgid "Toolbar_Save\n"
+msgstr ""
+
+#: ../src/xfbib-window.c:152
+msgid "(Untitled)"
+msgstr ""
Copied: xfbib/trunk/src/main.c (from rev 7054, xfbib/branches/gobject/src/main.c)
===================================================================
--- xfbib/trunk/src/main.c (rev 0)
+++ xfbib/trunk/src/main.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <gtk/gtk.h>
+#include <libxfcegui4/libxfcegui4.h>
+
+#include "xfbib-bibtex.h"
+#include "xfbib-state.h"
+#include "xfbib-window.h"
+#include "xfbib-file-io.h"
+
+gboolean
+cb_window_destroy_event (GtkWidget *widget, GdkEvent *event, gpointer user_data)
+{
+ gtk_main_quit();
+ return FALSE;
+}
+
+int
+main (int argc, char **argv)
+{
+ XfbibState *state;
+ XfbibBibtex *elements;
+ GtkWidget *window;
+ GError *error = NULL;
+ gboolean version = FALSE;
+ gchar **input_files = NULL, *output_file = NULL;
+ gint n, i;
+ GOptionContext *opt_contxt;
+ GOptionEntry options[] = {
+ { "version", 'V', 0, G_OPTION_ARG_NONE, &version, "Print program version", NULL },
+ { "output-file", 'o', 0, G_OPTION_ARG_FILENAME, &output_file,
+ "Filename of the output file when merging multiple files", NULL },
+ { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &input_files, "Filename" },
+ { NULL, 0, 0, 0, 0, NULL, NULL },
+ };
+
+ setlocale( LC_MESSAGES, "");
+ bindtextdomain( PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
+
+ gtk_init(&argc, &argv);
+
+ /**/
+// g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
+ /**/
+
+ opt_contxt = g_option_context_new(NULL);
+ g_option_context_add_main_entries(opt_contxt, options, _("main_entries"));
+ g_option_context_set_description(opt_contxt, _("Report bugs to http://bugs.xfce.org/\n"));
+ if (!g_option_context_parse(opt_contxt, &argc, &argv, &error)) {
+ g_printerr(_("Error parsing: %s\n"), error->message);
+ g_error_free(error);
+ g_option_context_free(opt_contxt);
+ return EXIT_FAILURE;
+ }
+
+ g_option_context_free(opt_contxt);
+
+ if (version) {
+ g_print(PACKAGE_STRING "\n");
+ return EXIT_SUCCESS;
+ }
+
+ state = xfbib_state_new();
+
+ elements = xfbib_bibtex_new();
+ xfbib_state_set_bibtex_elements(state, elements);
+
+ window = xfbib_window_new();
+ xfbib_window_set_title(XFBIB_WINDOW(window), NULL);
+
+ g_signal_connect (G_OBJECT(window), "destroy",
+ G_CALLBACK(cb_window_destroy_event), NULL);
+
+ xfbib_state_set_window(state, window);
+
+
+ if (input_files != NULL) {
+ n = g_strv_length(input_files);
+
+ if (n == 1) {
+ if ((output_file = xfbib_file_io_open(input_files[0])) != NULL) {
+ xfbib_state_set_filename(state, output_file);
+ xfbib_window_set_title(XFBIB_WINDOW(window), output_file);
+ }
+ } else {
+ /* Multiple files */
+ /* TODO: Check that output file is present */
+ if (output_file == NULL) {
+ g_print(_("Error merging files, no output file specified\n"));
+ return EXIT_FAILURE;
+ }
+ xfbib_state_set_filename(state, output_file);
+ xfbib_window_set_title(XFBIB_WINDOW(window), output_file);
+
+ for (i = 0; i < n; i++) {
+ xfbib_file_io_open(input_files[i]);
+ }
+ }
+ g_strfreev(input_files);
+
+ }
+
+ gtk_widget_show_all(window);
+ gtk_main();
+
+ return EXIT_SUCCESS;
+}
Copied: xfbib/trunk/src/xfbib-bibtex-field.c (from rev 7054, xfbib/branches/gobject/src/xfbib-bibtex-field.c)
===================================================================
--- xfbib/trunk/src/xfbib-bibtex-field.c (rev 0)
+++ xfbib/trunk/src/xfbib-bibtex-field.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gtk/gtk.h>
+
+#include "xfbib-bibtex-field.h"
+#include "xfbib-bibtex-value.h"
+
+struct _XfbibBibtexField
+{
+ GObject parent;
+ GObject *owner;
+ gchar *variable;
+ XfbibBibtexValue *value;
+};
+
+typedef struct _XfbibBibtexFieldClass
+{
+ GObjectClass parent;
+} XfbibBibtexFieldClass;
+
+static void xfbib_bibtex_field_class_init(XfbibBibtexFieldClass *klass);
+
+static void xfbib_bibtex_field_init(XfbibBibtexField *instance);
+static void xfbib_bibtex_field_finalize(GObject *obj);
+
+G_DEFINE_TYPE(XfbibBibtexField, xfbib_bibtex_field, G_TYPE_OBJECT)
+
+static void
+xfbib_bibtex_field_class_init(XfbibBibtexFieldClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *)klass;
+ object_class->finalize = xfbib_bibtex_field_finalize;
+}
+
+static void
+xfbib_bibtex_field_init(XfbibBibtexField *instance)
+{
+ instance->variable = NULL;
+ instance->value = xfbib_bibtex_value_new(G_OBJECT(instance));
+}
+
+static void
+xfbib_bibtex_field_finalize(GObject *obj)
+{
+ g_free(XFBIB_BIBTEX_FIELD(obj)->variable);
+ G_OBJECT_CLASS(xfbib_bibtex_field_parent_class)->finalize(obj);
+}
+
+XfbibBibtexField *
+xfbib_bibtex_field_new(GObject *obj)
+{
+ XfbibBibtexField *field;
+ field = g_object_new(XFBIB_TYPE_BIBTEX_FIELD, NULL);
+ field->owner = obj;
+ return field;
+}
+
+
+GObject *
+xfbib_bibtex_field_get_owner(XfbibBibtexField *field)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_FIELD(field), NULL);
+ return field->owner;
+}
+
+gboolean
+xfbib_bibtex_field_parse(XfbibBibtexField *field, const gchar *str)
+{
+ gchar **split = NULL;
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_FIELD(field), FALSE);
+
+ split = g_strsplit(str, "=", 2);
+
+ if (split[1] == NULL) {
+ /* Equal sign missing */
+ g_warning(_("No equal sign found in definition of Field\n"));
+ g_strfreev(split);
+ return FALSE;
+ }
+
+ /* Variable */
+ g_free(field->variable);
+ g_strstrip(split[0]);
+ field->variable = g_strdup(split[0]);
+
+ /* Value */
+ if (!xfbib_bibtex_value_parse(field->value, split[1])) {
+ g_strfreev(split);
+ return FALSE;
+ }
+
+ g_strfreev(split);
+ return TRUE;
+}
+
+const gchar *
+xfbib_bibtex_field_get_variable(XfbibBibtexField *field)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_FIELD(field), NULL);
+ return field->variable;
+}
+
+void
+xfbib_bibtex_field_set_variable(XfbibBibtexField *field, const gchar *str)
+{
+ g_return_if_fail(XFBIB_IS_BIBTEX_FIELD(field));
+
+ g_free(field->variable);
+ field->variable = g_strdup(str);
+}
+
+XfbibBibtexValue *
+xfbib_bibtex_field_get_value(XfbibBibtexField *field)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_FIELD(field), NULL);
+ return field->value;
+}
+
+void
+xfbib_bibtex_field_set_value(XfbibBibtexField *field, XfbibBibtexValue *value)
+{
+ g_return_if_fail(XFBIB_IS_BIBTEX_FIELD(field));
+ g_object_unref(field->value);
+ field->value = value;
+}
+
Copied: xfbib/trunk/src/xfbib-bibtex-field.h (from rev 7054, xfbib/branches/gobject/src/xfbib-bibtex-field.h)
===================================================================
--- xfbib/trunk/src/xfbib-bibtex-field.h (rev 0)
+++ xfbib/trunk/src/xfbib-bibtex-field.h 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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 __XFBIB_BIBTEX_FIELD_H
+#define __XFBIB_BIBTEX_FIELD_H
+
+#include <glib-object.h>
+#include <libxfcegui4/libxfcegui4.h>
+#include "xfbib-bibtex-value.h"
+
+#define XFBIB_TYPE_BIBTEX_FIELD (xfbib_bibtex_field_get_type())
+#define XFBIB_BIBTEX_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XFBIB_TYPE_BIBTEX_FIELD, XfbibBibtexField))
+#define XFBIB_IS_BIBTEX_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XFBIB_TYPE_BIBTEX_FIELD))
+#define XFBIB_BIBTEX_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XFBIB_TYPE_BIBTEX_FIELD, XfbibBibtexFieldClass))
+#define XFBIB_IS_BIBTEX_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), XFBIB_TYPE_BIBTEX_FIELD))
+#define XFBIB_BIBTEX_FIELD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XFBIB_TYPE_BIBTEX_FIELD, XfbibBibtexFieldClass))
+
+G_BEGIN_DECLS
+
+enum {
+ XFBIB_BIBTEX_FIELD_ADDRESS = 0,
+ XFBIB_BIBTEX_FIELD_ANNOTE,
+ XFBIB_BIBTEX_FIELD_AUTHOR,
+ XFBIB_BIBTEX_FIELD_BOOKTITLE,
+ XFBIB_BIBTEX_FIELD_CHAPTER,
+ XFBIB_BIBTEX_FIELD_CROSSREF,
+ XFBIB_BIBTEX_FIELD_EDITION,
+ XFBIB_BIBTEX_FIELD_EDITOR,
+ XFBIB_BIBTEX_FIELD_EPRINT,
+ XFBIB_BIBTEX_FIELD_HOWPUBLISHED,
+ XFBIB_BIBTEX_FIELD_INSTITUTION,
+ XFBIB_BIBTEX_FIELD_JOURNAL,
+ XFBIB_BIBTEX_FIELD_KEY,
+ XFBIB_BIBTEX_FIELD_MONTH,
+ XFBIB_BIBTEX_FIELD_NOTE,
+ XFBIB_BIBTEX_FIELD_NUMBER,
+ XFBIB_BIBTEX_FIELD_ORGANIZATION,
+ XFBIB_BIBTEX_FIELD_PAGES,
+ XFBIB_BIBTEX_FIELD_PUBLISHER,
+ XFBIB_BIBTEX_FIELD_SCHOOL,
+ XFBIB_BIBTEX_FIELD_SERIES,
+ XFBIB_BIBTEX_FIELD_TITLE,
+ XFBIB_BIBTEX_FIELD_TYPE,
+ XFBIB_BIBTEX_FIELD_URL,
+ XFBIB_BIBTEX_FIELD_VOLUME,
+ XFBIB_BIBTEX_FIELD_YEAR,
+ XFBIB_BIBTEX_FIELD_N_FIELDS,
+};
+
+static struct {
+ gchar *label;
+ gchar *tooltip;
+ /* TODO: Make translateable, but need to be inside a function */
+}xfbib_bibtex_field_constants[] = {
+ {"Address", ("Address of publisher")},
+ {"Annote", ("Annotation for annotated bibliography styles")},
+ {"Author", ("Name(s) of the author(s), separated by 'and' if more than one")},
+ {"Booktitle", ("Title of the book, if only part of it is being cited")},
+ {"Chapter", ("Chapter number")},
+ {"Crossref", ("Citation key of the cross-referenced entry")},
+ {"Edition", ("Edition of the book (such as \"first\" or \"second\")")},
+ {"Editor", ("Name(s) of the editor(s), separated by 'and' if more than one")},
+ {"E-print", ("Specification of electronic publication")},
+ {"HowPublished", ("Publishing method if the method is nonstandard")},
+ {"Institution", ("Institution that was involved in the publishing")},
+ {"Journal", ("Journal or magazine in which the work was published")},
+ {"Key", ("Hidden field used for specifying or overriding the alphabetical order of entries")},
+ {"Month", ("Month of publication or creation if unpublished")},
+ {"Note", ("Miscellaneous extra information")},
+ {"Number", ("Number of journal, magazine, or tech-report")},
+ {"Organization", ("Sponsor of the conference")},
+ {"Pages", ("Page numbers separated by commas or double-hyphens")},
+ {"Publisher", ("Name of publisher")},
+ {"School", ("School where thesis was written")},
+ {"Series", ("Series of books in which the book was published")},
+ {"Title", ("Title of the work")},
+ {"Type", ("Type of technical report")},
+ {"URL", ("Internet address")},
+ {"Volume", ("Number of the volume")},
+ {"Year", ("Year of publication or creation if unpublished")}
+};
+
+typedef struct _XfbibBibtexField XfbibBibtexField;
+
+GType xfbib_field_get_type() G_GNUC_CONST;
+
+XfbibBibtexField *xfbib_bibtex_field_new(GObject *);
+GObject *xfbib_bibtex_field_get_owner(XfbibBibtexField *);
+gboolean xfbib_bibtex_field_parse(XfbibBibtexField *, const gchar *);
+const gchar *xfbib_bibtex_field_get_variable(XfbibBibtexField *);
+void xfbib_bibtex_field_set_variable(XfbibBibtexField *, const gchar *);
+XfbibBibtexValue *xfbib_bibtex_field_get_value(XfbibBibtexField *);
+void xfbib_bibtex_field_set_value(XfbibBibtexField *, XfbibBibtexValue *);
+#if 0
+const gchar *xfbib_bibtex_field_get_value_str(XfbibBibtexField *);
+void xfbib_bibtex_field_set_variable(XfbibBibtexField *, const gchar *);
+void xfbib_bibtex_field_set_value(XfbibBibtexField *, XfbibBibtexValue *);
+gboolean xfbib_bibtex_field_is_column(XfbibBibtexField *, gint);
+#endif
+G_END_DECLS
+
+#endif //__XFBIB_BIBTEX_FIELD_H
+
Copied: xfbib/trunk/src/xfbib-bibtex-string.c (from rev 7054, xfbib/branches/gobject/src/xfbib-bibtex-string.c)
===================================================================
--- xfbib/trunk/src/xfbib-bibtex-string.c (rev 0)
+++ xfbib/trunk/src/xfbib-bibtex-string.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gtk/gtk.h>
+#include <string.h>
+#include <libxfcegui4/libxfcegui4.h>
+
+#include "xfbib-bibtex-string.h"
+#include "xfbib-bibtex-value.h"
+
+struct _XfbibBibtexString
+{
+ GObject parent;
+ GObject *owner;
+ gint internal;
+ gchar separator;
+ gchar *variable;
+ XfbibBibtexValue *value;
+};
+
+typedef struct _XfbibBibtexStringClass
+{
+ GObjectClass parent;
+} XfbibBibtexStringClass;
+
+static void xfbib_bibtex_string_class_init(XfbibBibtexStringClass *klass);
+
+static void xfbib_bibtex_string_init(XfbibBibtexString *instance);
+static void xfbib_bibtex_string_finalize(GObject *obj);
+
+G_DEFINE_TYPE(XfbibBibtexString, xfbib_bibtex_string, G_TYPE_OBJECT)
+
+static void
+xfbib_bibtex_string_class_init(XfbibBibtexStringClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *)klass;
+ object_class->finalize = xfbib_bibtex_string_finalize;
+}
+
+static void
+xfbib_bibtex_string_init(XfbibBibtexString *instance)
+{
+ instance->separator = '\0';
+ instance->internal = 0;
+ instance->variable = NULL;
+ instance->value = xfbib_bibtex_value_new(G_OBJECT(instance));
+}
+
+static void
+xfbib_bibtex_string_finalize(GObject *obj)
+{
+ G_OBJECT_CLASS(xfbib_bibtex_string_parent_class)->finalize(obj);
+}
+
+XfbibBibtexString *
+xfbib_bibtex_string_new(GObject *obj)
+{
+ XfbibBibtexString *string;
+ string = g_object_new(XFBIB_TYPE_BIBTEX_STRING, NULL);
+ string->owner = obj;
+ return string;
+}
+
+
+GObject *
+xfbib_bibtex_string_get_owner(XfbibBibtexString *string)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_STRING(string), NULL);
+ return string->owner;
+}
+
+const gchar *
+xfbib_bibtex_string_get_variable(XfbibBibtexString *string)
+{
+ return string->variable;
+}
+
+void
+xfbib_bibtex_string_set_variable(XfbibBibtexString *string, const gchar *variable)
+{
+ g_free(string->variable);
+ string->variable = g_strdup(variable);
+}
+
+XfbibBibtexValue *
+xfbib_bibtex_string_get_value(XfbibBibtexString *string)
+{
+ return string->value;
+}
+
+void
+xfbib_bibtex_string_set_value(XfbibBibtexString *string, XfbibBibtexValue *value)
+{
+ string->value = value;
+}
+
+gboolean
+xfbib_bibtex_string_parse(XfbibBibtexString *string, const gchar *str)
+{
+ gchar **split = NULL, *tmp;
+
+ split = g_strsplit(str, "=", 2);
+
+ if (split[1] == NULL) {
+ /* Equal sign missing */
+ g_warning(_("No equal sign found in definition of String\n"));
+ g_strfreev(split);
+ return FALSE;
+ }
+
+ g_free(string->variable);
+ g_strstrip(split[0] + 7);
+
+ /* Separator */
+ string->separator = split[0][7];
+
+ /* Variable */
+ string->variable = g_strdup(split[0] + 8);
+
+ /* Value */
+ tmp = g_strndup(split[1], strlen(split[1]) - 1);
+ if (!xfbib_bibtex_value_parse(string->value, tmp)) {
+ g_free(tmp);
+ g_strfreev(split);
+ return FALSE;
+ }
+ g_free(tmp);
+
+ g_strfreev(split);
+ return TRUE;
+}
+
+gchar
+xfbib_bibtex_string_get_separator(XfbibBibtexString *string)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_STRING(string), '\0');
+ return string->separator;
+}
+
+gint
+xfbib_bibtex_string_get_internal(XfbibBibtexString *string)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_STRING(string), -1);
+ return string->internal;
+}
+
+void
+xfbib_bibtex_string_set_internal(XfbibBibtexString *string, gint value)
+{
+ string->internal = value;
+}
Copied: xfbib/trunk/src/xfbib-bibtex-string.h (from rev 7052, xfbib/branches/gobject/src/xfbib-bibtex-string.h)
===================================================================
--- xfbib/trunk/src/xfbib-bibtex-string.h (rev 0)
+++ xfbib/trunk/src/xfbib-bibtex-string.h 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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 __XFBIB_BIBTEX_STRING_H
+#define __XFBIB_BIBTEX_STRING_H
+
+#include <glib-object.h>
+#include "xfbib-bibtex-value.h"
+
+#define XFBIB_TYPE_BIBTEX_STRING (xfbib_bibtex_string_get_type())
+#define XFBIB_BIBTEX_STRING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XFBIB_TYPE_BIBTEX_STRING, XfbibBibtexString))
+#define XFBIB_IS_BIBTEX_STRING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XFBIB_TYPE_BIBTEX_STRING))
+#define XFBIB_BIBTEX_STRING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XFBIB_TYPE_BIBTEX_STRING, XfbibBibtexStringClass))
+#define XFBIB_IS_BIBTEX_STRING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), XFBIB_TYPE_BIBTEX_STRING))
+#define XFBIB_BIBTEX_STRING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XFBIB_TYPE_BIBTEX_STRING, XfbibBibtexStringClass))
+
+G_BEGIN_DECLS
+
+enum {
+ XFBIB_BIBTEX_STRING_VARIABLE = 0,
+ XFBIB_BIBTEX_STRING_VALUE,
+ XFBIB_BIBTEX_STRING_N_STRINGS,
+};
+
+typedef struct _XfbibBibtexString XfbibBibtexString;
+
+GType xfbib_bibtex_string_get_type() G_GNUC_CONST;
+
+XfbibBibtexString *xfbib_bibtex_string_new(GObject *);
+GObject *xfbib_bibtex_string_get_owner(XfbibBibtexString *);
+const gchar *xfbib_bibtex_string_get_variable(XfbibBibtexString *);
+void xfbib_bibtex_string_set_variable(XfbibBibtexString *, const gchar *);
+XfbibBibtexValue *xfbib_bibtex_string_get_value(XfbibBibtexString *);
+void xfbib_bibtex_string_set_value(XfbibBibtexString *, XfbibBibtexValue *);
+gboolean xfbib_bibtex_string_parse(XfbibBibtexString *, const gchar *);
+gchar xfbib_bibtex_string_get_separator(XfbibBibtexString *);
+gint xfbib_bibtex_string_get_internal(XfbibBibtexString *);
+void xfbib_bibtex_string_set_internal(XfbibBibtexString *, gint);
+
+G_END_DECLS
+
+#endif //__XFBIB_BIBTEX_STRING_H
+
Copied: xfbib/trunk/src/xfbib-bibtex-value.c (from rev 7054, xfbib/branches/gobject/src/xfbib-bibtex-value.c)
===================================================================
--- xfbib/trunk/src/xfbib-bibtex-value.c (rev 0)
+++ xfbib/trunk/src/xfbib-bibtex-value.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,262 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gtk/gtk.h>
+#include <string.h>
+
+#include "xfbib-bibtex-value.h"
+#include "xfbib-bibtex-string.h"
+#include "xfbib-bibtex-preamble.h"
+#include "xfbib-bibtex.h"
+#include "xfbib-string.h"
+#include "xfbib-integer.h"
+
+static gint bibtex_string_cmp(gconstpointer, gconstpointer);
+
+struct _XfbibBibtexValue
+{
+ GObject parent;
+ GObject *owner;
+ GList *list;
+};
+
+typedef struct _XfbibBibtexValueClass
+{
+ GObjectClass parent;
+} XfbibBibtexValueClass;
+
+static void xfbib_bibtex_value_class_init(XfbibBibtexValueClass *klass);
+
+static void xfbib_bibtex_value_init(XfbibBibtexValue *instance);
+static void xfbib_bibtex_value_finalize(GObject *obj);
+
+G_DEFINE_TYPE(XfbibBibtexValue, xfbib_bibtex_value, G_TYPE_OBJECT)
+
+static void
+xfbib_bibtex_value_class_init(XfbibBibtexValueClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *)klass;
+ object_class->finalize = xfbib_bibtex_value_finalize;
+}
+
+static void
+xfbib_bibtex_value_init(XfbibBibtexValue *instance)
+{
+ instance->list = NULL;
+}
+
+static void
+xfbib_bibtex_value_finalize(GObject *obj)
+{
+ XfbibBibtexValue *value;
+ g_return_if_fail(XFBIB_IS_BIBTEX_VALUE(obj));
+
+ value = XFBIB_BIBTEX_VALUE(obj);
+ g_list_foreach (value->list, (GFunc) g_object_unref, NULL);
+ g_list_free (value->list);
+ value->list = NULL;
+ G_OBJECT_CLASS(xfbib_bibtex_value_parent_class)->finalize(obj);
+}
+
+XfbibBibtexValue *
+xfbib_bibtex_value_new(GObject *obj)
+{
+ XfbibBibtexValue *value;
+ value = g_object_new(XFBIB_TYPE_BIBTEX_VALUE, NULL);
+ value->owner = obj;
+ return value;
+}
+
+GObject *
+xfbib_bibtex_value_get_owner(XfbibBibtexValue *value)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_VALUE(value), NULL);
+ return value->owner;
+}
+
+gboolean
+xfbib_bibtex_value_parse(XfbibBibtexValue *value, const gchar *str)
+{
+ gint i, j, len, braces;
+ gchar **split = NULL;
+ GObject *obj;
+ XfbibBibtex *elements;
+
+ if (XFBIB_IS_BIBTEX_STRING(value->owner)) {
+ elements = XFBIB_BIBTEX(xfbib_bibtex_string_get_owner(XFBIB_BIBTEX_STRING(value->owner)));
+ } else if (XFBIB_IS_BIBTEX_FIELD(value->owner)) {
+ elements = XFBIB_BIBTEX(xfbib_bibtex_entry_get_owner(
+ XFBIB_BIBTEX_ENTRY(xfbib_bibtex_field_get_owner(XFBIB_BIBTEX_FIELD(value->owner)))));
+ } else if (XFBIB_IS_BIBTEX_PREAMBLE(value->owner)) {
+ elements = XFBIB_BIBTEX(xfbib_bibtex_preamble_get_owner(XFBIB_BIBTEX_PREAMBLE(value->owner)));
+ }
+
+ /* TODO: Free all elements of the list */
+ value->list = NULL;
+
+ split = g_strsplit(str, "#", 0);
+
+ for (i = 0; split[i] != NULL; i++) {
+ /*
+ * Check the type of the string to parse.
+ *
+ * If the string starts with " or { it is a string,
+ * if the string starts with a alphabetic character
+ * it is a variable or if it contains all numbers it
+ * is an integer.
+ */
+ g_strstrip(split[i]);
+ if (split[i][0] == '"' || split[i][0] == '{') {
+ /* String */
+
+ len = strlen(split[i]);
+
+ if (split[i][0] == '"' && split[i][len - 1] != '"')
+ return FALSE;
+ else if (split[i][0] == '{' && split[i][len - 1] != '}')
+ return FALSE;
+
+ if (split[i][0] == '{' && strchr(split[i], '@') != NULL) {
+ /* Braced string contains @ */
+ g_warning(_("Braced string contains @: %s\n"), split[i]);
+ return FALSE;
+ }
+
+ braces = 0;
+ len = strlen(split[i]) - 1;
+ for (j = 1; j < len; j++) {
+ /* Check if the braces are balanced and quotes are inside braces*/
+ if (split[i][j] == '{')
+ braces++;
+ else if (split[i][j] == '}')
+ braces--;
+ else if (split[i][0] == '"' && split[i][j] == '"' && braces == 0) {
+ g_warning(_("Quote not inside braces in string: %s\n"), split[i]);
+ return FALSE;
+ }
+ }
+
+ if (braces != 0) {
+ /* Braces was not balanced */
+ g_warning(_("Braces not balanced in field string: %s\n"), split[i]);
+ return FALSE;
+ }
+
+ obj = G_OBJECT(xfbib_string_new(G_OBJECT(value)));
+ xfbib_string_parse(XFBIB_STRING(obj), split[i]);
+ value->list = g_list_prepend(value->list, obj);
+ } else if(g_ascii_isalpha(split[i][0])) {
+ /* Variable */
+ if (strstr(split[i], "\"") != NULL) {
+ g_warning(_("Variable contains double quote\n"));
+ return FALSE;
+ }
+
+ obj = xfbib_bibtex_find(elements, bibtex_string_cmp, split[i]);
+ if(obj != NULL) {
+ value->list = g_list_prepend(value->list, obj);
+ }
+ } else {
+ len = strlen(split[i]);
+ for (j = 0; j < len; j++) {
+ if (!g_ascii_isdigit(split[i][j])) {
+ /* Character was not a number between 0 and 9 */
+ g_warning(_("TODO: Add a character in number warning\n"));
+ return FALSE;
+ }
+ }
+ /* Integer */
+ obj = G_OBJECT(xfbib_integer_new(G_OBJECT(value)));
+ xfbib_integer_set(XFBIB_INTEGER(obj), split[i]);
+ value->list = g_list_prepend(value->list, obj);
+ }
+ }
+
+ g_strfreev(split);
+
+
+ value->list = g_list_reverse(value->list);
+ return TRUE;
+}
+
+GList *
+xfbib_bibtex_value_get(XfbibBibtexValue *value)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_VALUE(value), NULL);
+
+ return value->list;
+}
+
+
+void
+xfbib_bibtex_value_set(XfbibBibtexValue *value, GList *list)
+{
+ g_return_if_fail(XFBIB_IS_BIBTEX_VALUE(value));
+
+ /* Remove all values */
+ g_list_foreach (value->list, (GFunc) g_object_unref, NULL);
+ g_list_free (value->list);
+
+ value->list = list;
+}
+
+/*
+ * Returned string must be freed
+ */
+gchar *
+xfbib_bibtex_value_get_str(XfbibBibtexValue *value)
+{
+ XfbibBibtexValue *val;
+ GString *str;
+ GList *list;
+ gchar *tmp;
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_VALUE(value), NULL);
+
+ str = g_string_new(NULL);
+
+ for (list = value->list; list != NULL; list = g_list_next(list)) {
+ if (XFBIB_IS_STRING(list->data)) {
+ /* regular string */
+ g_string_append(str, xfbib_string_get(XFBIB_STRING(list->data)));
+ } else if (XFBIB_IS_INTEGER(list->data)) {
+ /* integer value */
+ g_string_append(str, xfbib_integer_get(XFBIB_INTEGER(list->data)));
+ } else if (XFBIB_IS_BIBTEX_STRING(list->data)) {
+ /* variable */
+ val = xfbib_bibtex_string_get_value(XFBIB_BIBTEX_STRING(list->data));
+ tmp = xfbib_bibtex_value_get_str(val);
+ g_string_append(str, tmp);
+ g_free(tmp);
+ }
+ }
+ return g_string_free(str, FALSE);
+}
+
+/*
+ * Remove all values in the list and set the first value to str
+ */
+void
+xfbib_bibtex_value_set_str(XfbibBibtexValue *value, const gchar *str)
+{
+ XfbibString *string;
+ g_return_if_fail(XFBIB_IS_BIBTEX_VALUE(value));
+
+ /* Remove all values */
+ g_list_foreach (value->list, (GFunc) g_object_unref, NULL);
+ g_list_free (value->list);
+ value->list = NULL;
+
+ string = xfbib_string_new(G_OBJECT(value));
+ xfbib_string_set(string, str);
+ value->list = g_list_append(value->list, G_OBJECT(string));
+}
+
+static gint
+bibtex_string_cmp(gconstpointer a, gconstpointer b)
+{
+ g_return_val_if_fail(a != NULL, -1);
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_STRING(b), 1);
+
+ return strcmp(a, xfbib_bibtex_string_get_variable((XfbibBibtexString *)b));
+}
+
Copied: xfbib/trunk/src/xfbib-bibtex.c (from rev 7054, xfbib/branches/gobject/src/xfbib-bibtex.c)
===================================================================
--- xfbib/trunk/src/xfbib-bibtex.c (rev 0)
+++ xfbib/trunk/src/xfbib-bibtex.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,553 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <string.h>
+#include <gtk/gtk.h>
+
+#include "xfbib-bibtex.h"
+#include "xfbib-bibtex-entry.h"
+#include "xfbib-bibtex-comment.h"
+#include "xfbib-bibtex-preamble.h"
+#include "xfbib-bibtex-string.h"
+
+#ifndef G_SEQUENCE
+#define G_SEQUENCE GLIB_CHECK_VERSION (2, 14, 0)
+#endif
+
+
+#define CURLY_BRACKET 0
+#define ROUND_BRACKET 1
+
+struct _XfbibBibtex
+{
+ GObject parent;
+ gint n_entries;
+ gint n_strings;
+#if G_SEQUENCE
+ GSequence *seq;
+#else
+ GList *list;
+#endif
+};
+
+typedef struct _XfbibBibtexClass
+{
+ GObjectClass parent;
+} XfbibBibtexClass;
+
+static void xfbib_bibtex_class_init(XfbibBibtexClass *klass);
+
+static void xfbib_bibtex_init(XfbibBibtex *instance);
+static void xfbib_bibtex_finalize(GObject *obj);
+
+G_DEFINE_TYPE(XfbibBibtex, xfbib_bibtex, G_TYPE_OBJECT)
+
+static void
+xfbib_bibtex_class_init(XfbibBibtexClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *)klass;
+ object_class->finalize = xfbib_bibtex_finalize;
+}
+
+static void
+xfbib_bibtex_init(XfbibBibtex *instance)
+{
+#if G_SEQUENCE
+ instance->seq = g_sequence_new(g_object_unref);
+#else
+ instance->list = NULL;
+#endif
+ instance->n_entries = 0;
+ instance->n_strings = 0;
+
+}
+
+static void
+xfbib_bibtex_finalize(GObject *obj)
+{
+ /* Free the Bibtex List/Sequence */
+ xfbib_bibtex_remove_all(XFBIB_BIBTEX(obj));
+ G_OBJECT_CLASS(xfbib_bibtex_parent_class)->finalize(obj);
+}
+
+XfbibBibtex *
+xfbib_bibtex_new()
+{
+ XfbibBibtex *elements;
+ XfbibBibtexString *string;
+ gchar months[12][32] = {
+ "@String{jan = \"january\"}",
+ "@String{feb = \"february\"}",
+ "@String{mar = \"march\"}",
+ "@String{apr = \"april\"}",
+ "@String{may = \"may\"}",
+ "@String{jun = \"june\"}",
+ "@String{jul = \"july\"}",
+ "@String{aug = \"august\"}",
+ "@String{sep = \"september\"}",
+ "@String{oct = \"october\"}",
+ "@String{nov = \"november\"}",
+ "@String{dec = \"december\"}"};
+ gint n;
+
+ elements = g_object_new(XFBIB_TYPE_BIBTEX, NULL);
+
+ /* Add default bibtex strings */
+ for(n = 0; n < 12; n++) {
+ string = xfbib_bibtex_string_new(G_OBJECT(elements));
+ if (xfbib_bibtex_string_parse(string, months[n])) {
+ xfbib_bibtex_string_set_internal(string, 1);
+ elements->n_strings++;
+#if G_SEQUENCE
+ g_sequence_append(elements->seq, string);
+#else
+ elements->list = g_list_append(elements->list, string);
+#endif
+ }
+ }
+
+ return elements;
+}
+
+
+static gboolean
+parse_balanced_brackets(GString *buf, const gchar *str, gint *i)
+{
+ gint brackets;
+ gchar bracket_type;
+
+ while (str[(*i)] != '{' && str[(*i)] != '(') {
+ buf = g_string_append_c(buf, str[(*i)]);
+ (*i)++;
+ }
+
+ if (str[(*i)] == '{') {
+ bracket_type = CURLY_BRACKET;
+ } else if (str[(*i)] == '(') {
+ bracket_type = ROUND_BRACKET;
+ } else {
+ g_warning(_("Error, on line %d(TODO)\n"), __LINE__);
+ return FALSE;
+ }
+
+ buf = g_string_append_c(buf, str[(*i)]);
+ (*i)++;
+
+ for (brackets = 1; brackets > 0; (*i)++) {
+ if (bracket_type == CURLY_BRACKET) {
+ if (str[(*i)] == '{')
+ brackets++;
+ else if(str[(*i)] == '}')
+ brackets--;
+ } else if (bracket_type == ROUND_BRACKET) {
+ if (str[(*i)] == '(')
+ brackets++;
+ else if(str[(*i)] == ')')
+ brackets--;
+ } else {
+ g_warning(_("Error, could not parse wrong entry type (TODO)\n"));
+ return FALSE;;
+ /* Strange */
+ }
+ buf = g_string_append_c(buf, str[(*i)]);
+ }
+ return TRUE;
+}
+
+
+gboolean
+xfbib_bibtex_parse(XfbibBibtex *elements, const gchar *str)
+{
+ gint i, len;
+ GRegex *regex;
+ GObject *obj;
+ GString *buf;
+
+ buf = g_string_new("");
+
+ /* Compile the regex for the entry types */
+ regex = g_regex_new("^@(article|book|booklet|conference|inbook|incollection|inproceedings|manual|"
+ "mastersthesis|misc|phdthesis|proceedings|techreport|unpublished)({|\\s|[(])",
+ G_REGEX_CASELESS, 0, NULL);
+
+ len = strlen(str);
+ for (i = 0; i < len; i++) {
+ if (str[i] == '@') {
+ if (buf->len > 0) {
+ /* The comment ended put it in the list */
+ obj = G_OBJECT(xfbib_bibtex_comment_new(G_OBJECT(elements), buf->str));
+#if G_SEQUENCE
+ g_sequence_append(elements->seq, obj);
+#else
+ elements->list = g_list_append(elements->list, obj);
+#endif
+ buf = g_string_erase(buf, 0, -1);
+ }
+ if (g_ascii_strncasecmp(&str[i], "@comment", 8) == 0) {
+ /* Comment */
+ for (; str[i] != '\n'; i++)
+ buf = g_string_append_c(buf, str[i]);
+
+ /* Dont forget the newline character */
+ buf = g_string_append_c(buf, str[i]);
+
+ obj = G_OBJECT(xfbib_bibtex_comment_new(G_OBJECT(elements), buf->str));
+#if G_SEQUENCE
+ g_sequence_append(elements->seq, obj);
+#else
+ elements->list = g_list_append(elements->list, obj);
+#endif
+ buf = g_string_erase(buf, 0, -1);
+ } else if (g_ascii_strncasecmp(&str[i], "@preamble", 9) == 0) {
+ /* Preamble */
+ if (parse_balanced_brackets(buf, str, &i)) {
+ obj = G_OBJECT(xfbib_bibtex_preamble_new(G_OBJECT(elements)));
+ if (xfbib_bibtex_preamble_parse(XFBIB_BIBTEX_PREAMBLE(obj), buf->str)) {
+#if G_SEQUENCE
+ g_sequence_append(elements->seq, obj);
+#else
+ elements->list = g_list_append(elements->list, obj);
+#endif
+ }
+ }
+ buf = g_string_erase(buf, 0, -1);
+ } else if (g_ascii_strncasecmp(&str[i], "@string", 7) == 0) {
+ /* String */
+ if (parse_balanced_brackets(buf, str, &i)) {
+ obj = G_OBJECT(xfbib_bibtex_string_new(G_OBJECT(elements)));
+ if (xfbib_bibtex_string_parse(XFBIB_BIBTEX_STRING(obj), buf->str)) {
+ elements->n_strings++;
+#if G_SEQUENCE
+ g_sequence_append(elements->seq, obj);
+#else
+ elements->list = g_list_append(elements->list, obj);
+#endif
+ }
+ }
+ buf = g_string_erase(buf, 0, -1);
+ } else if (g_regex_match (regex, &str[i], 0, NULL)) {
+ /* Entry */
+ if (parse_balanced_brackets(buf, str, &i)) {
+ obj = G_OBJECT(xfbib_bibtex_entry_new(G_OBJECT(elements)));
+ if (xfbib_bibtex_entry_parse(XFBIB_BIBTEX_ENTRY(obj), buf->str)) {
+ elements->n_entries++;
+#if G_SEQUENCE
+ g_sequence_append(elements->seq, obj);
+#else
+ elements->list = g_list_append(elements->list, obj);
+#endif
+ }
+ }
+ buf = g_string_erase(buf, 0, -1);
+ } else {
+ /* Error */
+ g_warning(_("Error, on line %d(TODO)\n"), __LINE__);
+ while (str[++i] != '@')
+ continue;
+ }
+ } else {
+ buf = g_string_append_c(buf, str[i]);
+ }
+ }
+
+ g_string_free(buf, TRUE);
+ g_regex_unref(regex);
+ return TRUE;
+}
+
+void
+xfbib_bibtex_foreach(XfbibBibtex *elements, GFunc func, gpointer data)
+{
+ g_return_if_fail(XFBIB_IS_BIBTEX(elements) && func != NULL);
+#if G_SEQUENCE
+ g_sequence_foreach(elements->seq, func, data);
+#else
+ g_list_foreach(elements->list, func, data);
+#endif
+}
+
+gint
+xfbib_bibtex_get_n(XfbibBibtex *elements, enum XFBIB_BIBTEX_TYPE type)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX(elements), 0);
+ if (type == TYPE_ENTRY)
+ return elements->n_entries;
+ else if (type == TYPE_STRING)
+ return elements->n_strings;
+ return 0;
+}
+
+GObject *
+xfbib_bibtex_get_nth(XfbibBibtex *elements, gint n, enum XFBIB_BIBTEX_TYPE type)
+{
+ GObject *tmp;
+ gint found;
+ g_return_val_if_fail(XFBIB_IS_BIBTEX(elements) &&
+ ((type == TYPE_ENTRY && n < elements->n_entries) ||
+ (type == TYPE_STRING && n < elements->n_strings)), NULL);
+
+#if G_SEQUENCE
+ GSequenceIter *iter;
+ for (iter = g_sequence_get_begin_iter(elements->seq), found = -1;
+ !g_sequence_iter_is_end(iter); iter = g_sequence_iter_next(iter)) {
+ tmp = g_sequence_get(iter);
+ if (type == TYPE_ENTRY && XFBIB_IS_BIBTEX_ENTRY(tmp)) {
+ if (++found == n) {
+ return tmp;
+ }
+ } else if (type == TYPE_STRING && XFBIB_IS_BIBTEX_STRING(tmp)) {
+ if (++found == n) {
+ return tmp;
+ }
+ }
+ }
+#else
+ gint i, len;
+ len = g_list_length(elements->list);
+ for (i = 0, found = -1; i < len; i++) {
+ tmp = g_list_nth_data(elements->list, i);
+ if (type == TYPE_ENTRY && XFBIB_IS_BIBTEX_ENTRY(tmp)) {
+ if (++found == n) {
+ return tmp;
+ }
+ } else if (type == TYPE_STRING && XFBIB_IS_BIBTEX_STRING(tmp)) {
+ if (++found == n) {
+ return tmp;
+ }
+ }
+ }
+#endif
+ return NULL;
+}
+
+
+gint
+xfbib_bibtex_get_position(XfbibBibtex *elements, GObject *obj)
+{
+ GObject *tmp;
+ gint n;
+ g_return_val_if_fail(XFBIB_IS_BIBTEX(elements), -1);
+
+#if G_SEQUENCE
+ GSequenceIter *iter;
+ for (iter = g_sequence_get_begin_iter(elements->seq), n = -1;
+ !g_sequence_iter_is_end(iter); iter = g_sequence_iter_next(iter)) {
+ tmp = g_sequence_get(iter);
+ if (XFBIB_IS_BIBTEX_ENTRY(obj) && XFBIB_IS_BIBTEX_ENTRY(tmp)) {
+ n++;
+ if (G_OBJECT(tmp) == obj) {
+ return n;
+ }
+ } else if (XFBIB_IS_BIBTEX_STRING(obj) && XFBIB_IS_BIBTEX_STRING(tmp)) {
+ n++;
+ if (G_OBJECT(tmp) == obj) {
+ return n;
+ }
+ }
+ }
+#else
+ gint i, len;
+ len = g_list_length(elements->list);
+ for (i = 0, n = -1; i < len; i++) {
+ tmp = g_list_nth_data(elements->list, i);
+ if (XFBIB_IS_BIBTEX_ENTRY(obj) && XFBIB_IS_BIBTEX_ENTRY(tmp)) {
+ n++;
+ if (G_OBJECT(tmp) == obj) {
+ return n;
+ }
+ } else if (XFBIB_IS_BIBTEX_STRING(obj) && XFBIB_IS_BIBTEX_STRING(tmp)) {
+ n++;
+ if (G_OBJECT(tmp) == obj) {
+ return n;
+ }
+ }
+ }
+#endif
+ return -1;
+}
+
+GObject *
+xfbib_bibtex_get_next(XfbibBibtex *elements, GObject *obj)
+{
+ GObject *tmp;
+ g_return_val_if_fail(XFBIB_IS_BIBTEX(elements), NULL);
+
+#if G_SEQUENCE
+ GSequenceIter *iter;
+ for (iter = g_sequence_get_begin_iter(elements->seq);
+ !g_sequence_iter_is_end(iter); iter = g_sequence_iter_next(iter)) {
+ tmp = g_sequence_get(iter);
+ if (tmp == obj) {
+ for (iter = g_sequence_iter_next(iter); !g_sequence_iter_is_end(iter);
+ iter = g_sequence_iter_next(iter)) {
+ tmp = g_sequence_get(iter);
+ if (XFBIB_IS_BIBTEX_ENTRY(obj) && XFBIB_IS_BIBTEX_ENTRY(tmp)) {
+ return tmp;
+ } else if (XFBIB_IS_BIBTEX_STRING(obj) && XFBIB_IS_BIBTEX_STRING(tmp)) {
+ return tmp;
+ }
+ }
+ }
+ }
+#else
+ gint i, len;
+ len = g_list_length(elements->list);
+ for (i = 0; i < len; i++) {
+ tmp = g_list_nth_data(elements->list, i);
+ if (tmp == obj) {
+ for (i++; i < len; i++) {
+ tmp = g_list_nth_data(elements->list, i);
+ if (XFBIB_IS_BIBTEX_ENTRY(obj) && XFBIB_IS_BIBTEX_ENTRY(tmp)) {
+ return tmp;
+ } else if (XFBIB_IS_BIBTEX_STRING(obj) && XFBIB_IS_BIBTEX_STRING(tmp)) {
+ return tmp;
+ }
+ }
+ }
+ }
+#endif
+ return NULL;
+}
+
+
+void
+xfbib_bibtex_remove(XfbibBibtex *elements, GObject *data)
+{
+ GObject *obj;
+ g_return_if_fail(XFBIB_IS_BIBTEX(elements));
+#if G_SEQUENCE
+ GSequenceIter *iter;
+ for (iter = g_sequence_get_begin_iter(elements->seq);
+ !g_sequence_iter_is_end(iter); iter = g_sequence_iter_next(iter)) {
+ if ((obj = g_sequence_get(iter)) == data) {
+ if(XFBIB_IS_BIBTEX_ENTRY(obj))
+ elements->n_entries--;
+ else if(XFBIB_IS_BIBTEX_STRING(obj))
+ elements->n_strings--;
+ g_sequence_remove(iter);
+ }
+ }
+#else
+ gint i, len;
+ len = g_list_length(elements->list);
+ for (i = 0; i < len; i++) {
+ if ((obj = g_list_nth_data(elements->list, i)) == data) {
+ if(XFBIB_IS_BIBTEX_ENTRY(obj))
+ elements->n_entries--;
+ else if(XFBIB_IS_BIBTEX_STRINGS(obj))
+ elements->n_strings--;
+ elements->list = g_list_remove(elements->list, obj);
+ g_object_unref(obj);
+ }
+ }
+#endif
+}
+
+void
+xfbib_bibtex_remove_all(XfbibBibtex *elements)
+{
+ g_return_if_fail(XFBIB_IS_BIBTEX(elements));
+#if G_SEQUENCE
+ g_sequence_remove_range(g_sequence_get_begin_iter(elements->seq),
+ g_sequence_get_end_iter(elements->seq));
+ elements->seq = g_sequence_new(g_object_unref);
+#else
+ g_list_foreach (elements->list, (GFunc) g_object_unref, NULL);
+ g_list_free (elements->list);
+ elements->list = NULL;
+#endif
+ elements->n_entries = 0;
+ elements->n_strings = 0;
+}
+
+void
+xfbib_bibtex_add(XfbibBibtex *elements, GObject *obj)
+{
+ g_return_if_fail(XFBIB_IS_BIBTEX(elements));
+ g_return_if_fail(XFBIB_IS_BIBTEX_ENTRY(obj) || XFBIB_IS_BIBTEX_STRING(obj));
+
+#if G_SEQUENCE
+ g_sequence_append(elements->seq, G_OBJECT(obj));
+#else
+ elements->list = g_list_append(elements->list, G_OBJECT(obj));
+#endif
+ if (XFBIB_IS_BIBTEX_ENTRY(obj))
+ elements->n_entries++;
+ else if (XFBIB_IS_BIBTEX_STRING(obj))
+ elements->n_strings++;
+}
+
+/*
+ * Return the position of the new object, counting from 0
+ */
+gint
+xfbib_bibtex_replace(XfbibBibtex *elements, GObject *old_obj, GObject *new_obj)
+{
+ GObject *obj;
+ gint n = 0;
+ g_return_val_if_fail(XFBIB_IS_BIBTEX(elements) &&
+ ((XFBIB_IS_BIBTEX_ENTRY(old_obj) &&
+ XFBIB_IS_BIBTEX_ENTRY(new_obj)) ||
+ (XFBIB_IS_BIBTEX_STRING(old_obj) &&
+ XFBIB_IS_BIBTEX_STRING(new_obj))), -1);
+
+#if G_SEQUENCE
+ GSequenceIter *iter;
+ for (iter = g_sequence_get_begin_iter(elements->seq);
+ !g_sequence_iter_is_end(iter); iter = g_sequence_iter_next(iter)) {
+ obj = g_sequence_get(iter);
+ if ((XFBIB_IS_BIBTEX_ENTRY(old_obj) && XFBIB_IS_BIBTEX_ENTRY(obj)) ||
+ (XFBIB_IS_BIBTEX_STRING(old_obj) && XFBIB_IS_BIBTEX_STRING(obj))) {
+ n++;
+ }
+
+ if (obj == old_obj) {
+ g_sequence_insert_before(iter, new_obj);
+ g_sequence_remove(iter);
+ return n;
+ }
+ }
+#else
+ gint i, len;
+ len = g_list_length(elements->list);
+ for (i = 0; i < len; i++) {
+ obj = g_list_nth(elements->list, i);
+ if (XFBIB_IS_BIBTEX_ENTRY(old_obj) && XFBIB_IS_BIBTEX_ENTRY(obj))
+ n++;
+ else if (XFBIB_IS_BIBTEX_STRING(old_obj) && XFBIB_IS_BIBTEX_STRING(obj))
+ n++;
+
+ if (obj->data == old_obj) {
+ elements->list = g_list_insert_before(elements->list, obj, new_obj);
+ elements->list = g_list_remove(elements->list, obj);
+ return n;
+ }
+ }
+#endif
+ return -1;
+}
+
+GObject *
+xfbib_bibtex_find(XfbibBibtex *elements, GCompareFunc func, gconstpointer ptr)
+{
+ GObject *tmp;
+ g_return_val_if_fail(XFBIB_IS_BIBTEX(elements), NULL);
+
+#if G_SEQUENCE
+ GSequenceIter *iter;
+ for (iter = g_sequence_get_begin_iter(elements->seq);
+ !g_sequence_iter_is_end(iter); iter = g_sequence_iter_next(iter)) {
+ tmp = g_sequence_get(iter);
+#else
+ gint i, len;
+ len = g_list_length(elements->list);
+ for (i = 0, n = -1; i < len; i++) {
+ tmp = g_list_nth_data(elements->list, i);
+#endif
+ if (!func(ptr, tmp)) {
+ return tmp;
+ }
+ }
+ return NULL;
+}
+
Copied: xfbib/trunk/src/xfbib-entry-edit-dialog.c (from rev 7054, xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c)
===================================================================
--- xfbib/trunk/src/xfbib-entry-edit-dialog.c (rev 0)
+++ xfbib/trunk/src/xfbib-entry-edit-dialog.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,494 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gtk/gtk.h>
+#include <libxfcegui4/libxfcegui4.h>
+#include <string.h>
+#include <glib.h>
+
+#include "xfbib-entry-edit-dialog.h"
+#include "xfbib-multiple-input.h"
+#include "xfbib-bibtex-field.h"
+#include "xfbib-bibtex-entry.h"
+#include "xfbib-state.h"
+
+static struct {
+ gchar *text;
+}xfbib_type_constants[] = {
+ {"Article"},
+ {"Book"},
+ {"Booklet"},
+ {"Conference"},
+ {"Inbook"},
+ {"Incollection"},
+ {"Inproceedings"},
+ {"Manual"},
+ {"Mastersthesis"},
+ {"Misc"},
+ {"PhdThesis"},
+ {"Proceedings"},
+ {"Techreport"},
+ {"Unpublished"},
+ {NULL}
+};
+
+struct input {
+ GtkWidget *label; /* Label and NULL objects */
+ GtkWidget *input; /* Entry and multiple inputs */
+ GtkWidget *button;
+ GList *gl; /* Used for compound strings */
+};
+
+struct _XfbibEntryEditDialog
+{
+ XfceTitledDialog parent;
+ GtkWidget *type_label;
+ GtkWidget *type_combo_box;
+ GtkWidget *key_label;
+ GtkWidget *key_entry;
+ GtkWidget *key_button;
+ struct input inputs[XFBIB_BIBTEX_FIELD_N_FIELDS];
+ GtkWidget *note_boxes[5];
+ GtkWidget *notebook;
+};
+
+typedef struct _XfbibEntryEditDialogClass
+{
+ XfceTitledDialogClass parent;
+} XfbibEntryEditDialogClass;
+
+static void xfbib_entry_edit_dialog_class_init(XfbibEntryEditDialogClass *klass);
+
+static void xfbib_entry_edit_dialog_init(XfbibEntryEditDialog *instance);
+static void xfbib_entry_edit_dialog_finalize(GObject *obj);
+
+static GObjectClass *xfbib_entry_edit_dialog_parent_class = NULL;
+
+static void
+cb_generate_clicked (GtkButton *button, gpointer user_data)
+{
+ g_printf("cb_generate_clicked\n");
+ /* Generate BibTeX key */
+ /* Suggested format: Last name of first author, year of publication, first word in title appended together */
+ GString *str;
+ const gchar *lastname, *title;
+ gchar **split;
+ char *tmp;
+ str = g_string_new("");
+
+ lastname = xfbib_multiple_input_get_nth_row_ith_column(XFBIB_MULTIPLE_INPUT (XFBIB_ENTRY_EDIT_DIALOG (user_data)->inputs[XFBIB_BIBTEX_FIELD_AUTHOR].input),0,0);
+ if(lastname != NULL) {
+ tmp = strrchr(lastname, ' ') + 1;
+ g_string_append(str, tmp);
+ }
+
+ g_string_append(str, (gtk_entry_get_text(GTK_ENTRY (XFBIB_ENTRY_EDIT_DIALOG (user_data)->inputs[XFBIB_BIBTEX_FIELD_YEAR].input)) + 2));
+
+ title = gtk_entry_get_text(GTK_ENTRY (XFBIB_ENTRY_EDIT_DIALOG (user_data)->inputs[XFBIB_BIBTEX_FIELD_TITLE].input));
+ split = g_strsplit(title, " ", 2);
+ title = split[0];
+ g_string_append(str, title);
+
+ gtk_entry_set_text(GTK_ENTRY (XFBIB_ENTRY_EDIT_DIALOG (user_data)->key_entry), str->str);
+ g_string_free(str, TRUE);
+}
+
+static void
+cb_edit_compound_string_clicked (GtkButton *button, struct input *inputs)
+{
+ g_printf("cb_compound_string_clicked\n");
+
+ GtkWidget *multiple_input;
+ const gchar *str;
+
+ GtkWidget *dialog = xfce_titled_dialog_new_with_buttons(_("Edit compund string"),
+ NULL,
+ GTK_DIALOG_MODAL & GTK_DIALOG_DESTROY_WITH_PARENT,
+ NULL);
+ gtk_window_set_icon_name(GTK_WINDOW(dialog), "xfbib");
+
+ /* Add OK and cancel button */
+ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_OK);
+ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+
+ multiple_input = xfbib_multiple_input_new(_("Text/String key"), "TODO"); /* TODO: Fix the tooltip */
+ if(GTK_WIDGET_IS_SENSITIVE(inputs->input)) {
+ if(strcmp(gtk_entry_get_text(GTK_ENTRY(inputs->input)), "") != 0) {
+ xfbib_multiple_input_set_text(XFBIB_MULTIPLE_INPUT(multiple_input), gtk_entry_get_text(GTK_ENTRY(inputs->input)));
+ }
+ } else {
+ xfbib_multiple_input_set(XFBIB_MULTIPLE_INPUT(multiple_input), inputs->gl);
+ }
+
+ gtk_box_pack_start(GTK_BOX (GTK_DIALOG(dialog)->vbox), multiple_input, TRUE, TRUE, 6);
+ gtk_widget_show_all(GTK_WIDGET(dialog));
+
+ if(gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
+ str = xfbib_multiple_input_get_str(XFBIB_MULTIPLE_INPUT (multiple_input));
+ if(str != NULL) {
+ gtk_widget_set_sensitive(GTK_WIDGET(inputs->input), TRUE);
+ gtk_entry_set_text(GTK_ENTRY(inputs->input), str);
+ } else {
+ gtk_widget_set_sensitive(GTK_WIDGET(inputs->input), FALSE);
+ gtk_entry_set_text(GTK_ENTRY(inputs->input), "");
+ inputs->gl = xfbib_multiple_input_get(XFBIB_MULTIPLE_INPUT (multiple_input));
+ }
+ }
+
+ gtk_widget_destroy(dialog);
+}
+
+static GtkWidget*
+xfbib_get_image (gchar *filename)
+{
+ GtkWidget *image;
+ GString *path;
+ GdkPixbuf *pixbuf = NULL;
+
+ path = g_string_new("");
+ g_string_append(path, DATADIR);
+ g_string_append(path, "/pixmaps/xfbib/");
+ g_string_append(path, filename);
+
+ /* TODO: Fix the error handling */
+ pixbuf = gdk_pixbuf_new_from_file(path->str, NULL);
+ g_string_free(path, TRUE);
+
+ if(pixbuf == NULL){
+ g_warning(_("Button icon missing: %s"), filename);
+ image = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_BUTTON);
+ }else{
+ image = gtk_image_new_from_pixbuf(pixbuf);
+ }
+
+ return image;
+}
+
+GType
+xfbib_entry_edit_dialog_get_type (void)
+{
+ static GType type = 0;
+ if (type == 0) {
+ static const GTypeInfo info = {
+ sizeof (XfbibEntryEditDialogClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) xfbib_entry_edit_dialog_class_init, /* class_init */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (XfbibEntryEditDialog),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) xfbib_entry_edit_dialog_init /* instance_init */
+ };
+ type = g_type_register_static (XFCE_TYPE_TITLED_DIALOG, "XfbibEntryEditDialog", &info, 0);
+ }
+ return type;
+}
+
+static void
+xfbib_entry_edit_dialog_class_init(XfbibEntryEditDialogClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *)klass;
+
+ xfbib_entry_edit_dialog_parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = xfbib_entry_edit_dialog_finalize;
+}
+
+static void
+xfbib_entry_edit_dialog_init(XfbibEntryEditDialog *instance)
+{
+ gint i, row[5] = {0, 0, 0, 0, 0}, box;
+ GtkWidget *top_box;
+
+ instance->type_label = gtk_label_new(_("Type:"));
+ instance->type_combo_box = gtk_combo_box_new_text();
+ for (i = 0; xfbib_type_constants[i].text != NULL; i++) {
+ gtk_combo_box_append_text(GTK_COMBO_BOX(instance->type_combo_box),
+ xfbib_type_constants[i].text);
+ }
+
+ instance->key_label = gtk_label_new(_("Key:"));
+ instance->key_entry = gtk_entry_new();
+ instance->key_button = gtk_button_new();
+ gtk_container_add(GTK_CONTAINER(instance->key_button), xfbib_get_image("xfbib-generate.png"));
+ g_signal_connect(G_OBJECT (instance->key_button), "clicked", G_CALLBACK (cb_generate_clicked), instance);
+
+ top_box = gtk_hbox_new(FALSE, 12);
+
+ gtk_container_set_border_width(GTK_CONTAINER (top_box), 6);
+
+ gtk_box_pack_start(GTK_BOX(top_box), instance->type_label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(top_box), instance->type_combo_box, FALSE, FALSE, 0);
+
+ gtk_box_pack_end(GTK_BOX(top_box), instance->key_button, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(top_box), instance->key_entry, TRUE, TRUE, 0);
+ gtk_box_pack_end(GTK_BOX(top_box), instance->key_label, FALSE, FALSE, 0);
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (instance)->vbox), top_box, FALSE, FALSE, 0);
+
+ gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(instance)->vbox), 0); // 0 due to top_box border width
+
+ for (i = 0; i < 5; i++) {
+ instance->note_boxes[i] = gtk_table_new(1, 1, FALSE);
+ gtk_table_set_row_spacings(GTK_TABLE(instance->note_boxes[i]), 6);
+ gtk_table_set_col_spacings(GTK_TABLE(instance->note_boxes[i]), 12);
+ gtk_container_set_border_width(GTK_CONTAINER (instance->note_boxes[i]), 6);
+ }
+
+ for (i = 0; i < XFBIB_BIBTEX_FIELD_N_FIELDS; i++) {
+ /* Create the Input object */
+ if (i == XFBIB_BIBTEX_FIELD_AUTHOR || i == XFBIB_BIBTEX_FIELD_EDITOR) {
+ instance->inputs[i].input = xfbib_multiple_input_new(xfbib_bibtex_field_constants[i].label, xfbib_bibtex_field_constants[i].tooltip);
+ } else {
+ instance->inputs[i].label = gtk_label_new(xfbib_bibtex_field_constants[i].label);
+ gtk_misc_set_alignment(GTK_MISC(instance->inputs[i].label), 0, 0.5);
+
+ instance->inputs[i].input = gtk_entry_new();
+ gtk_widget_set_tooltip_text(instance->inputs[i].input, xfbib_bibtex_field_constants[i].tooltip);
+
+ instance->inputs[i].button = gtk_button_new();
+ gtk_container_add(GTK_CONTAINER(instance->inputs[i].button), xfbib_get_image("xfbib-compound-string.png"));
+ g_signal_connect(G_OBJECT (instance->inputs[i].button), "clicked", G_CALLBACK (cb_edit_compound_string_clicked), &(instance->inputs[i]));
+ }
+
+ /* Add the input object to the correct box */
+ switch (i) {
+ case XFBIB_BIBTEX_FIELD_INSTITUTION:
+ case XFBIB_BIBTEX_FIELD_ORGANIZATION:
+ case XFBIB_BIBTEX_FIELD_SCHOOL:
+ case XFBIB_BIBTEX_FIELD_TITLE:
+ case XFBIB_BIBTEX_FIELD_TYPE:
+ box = 0;
+ break;
+ case XFBIB_BIBTEX_FIELD_AUTHOR:
+ case XFBIB_BIBTEX_FIELD_EDITOR:
+ box = 1;
+ break;
+ case XFBIB_BIBTEX_FIELD_BOOKTITLE:
+ case XFBIB_BIBTEX_FIELD_CHAPTER:
+ case XFBIB_BIBTEX_FIELD_EDITION:
+ case XFBIB_BIBTEX_FIELD_MONTH:
+ case XFBIB_BIBTEX_FIELD_NUMBER:
+ case XFBIB_BIBTEX_FIELD_PAGES:
+ case XFBIB_BIBTEX_FIELD_VOLUME:
+ case XFBIB_BIBTEX_FIELD_YEAR:
+ box = 2;
+ break;
+ case XFBIB_BIBTEX_FIELD_ADDRESS:
+ case XFBIB_BIBTEX_FIELD_HOWPUBLISHED:
+ case XFBIB_BIBTEX_FIELD_JOURNAL:
+ case XFBIB_BIBTEX_FIELD_PUBLISHER:
+ case XFBIB_BIBTEX_FIELD_SERIES:
+ box = 3;
+ break;
+ case XFBIB_BIBTEX_FIELD_ANNOTE:
+ case XFBIB_BIBTEX_FIELD_CROSSREF:
+ case XFBIB_BIBTEX_FIELD_EPRINT:
+ case XFBIB_BIBTEX_FIELD_KEY:
+ case XFBIB_BIBTEX_FIELD_NOTE:
+ case XFBIB_BIBTEX_FIELD_URL:
+ box = 4;
+ break;
+ }
+ if (i == XFBIB_BIBTEX_FIELD_AUTHOR || i == XFBIB_BIBTEX_FIELD_EDITOR) {
+ gtk_table_attach_defaults(GTK_TABLE(instance->note_boxes[box]), instance->inputs[i].input, row[box], row[box]+1, 0, 1);
+ } else {
+ gtk_table_attach(GTK_TABLE(instance->note_boxes[box]), instance->inputs[i].label, 0, 1, row[box], row[box]+1, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(instance->note_boxes[box]), instance->inputs[i].input, 1, 2, row[box], row[box]+1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(instance->note_boxes[box]), instance->inputs[i].button, 2, 3, row[box], row[box]+1, GTK_FILL, GTK_FILL, 0, 0);
+ }
+ row[box]++;
+ }
+
+ instance->notebook = gtk_notebook_new ();
+ gtk_container_set_border_width(GTK_CONTAINER (instance->notebook), 6);
+ gtk_notebook_set_tab_pos (GTK_NOTEBOOK (instance->notebook), GTK_POS_TOP);
+ gtk_notebook_append_page (GTK_NOTEBOOK (instance->notebook), instance->note_boxes[0], gtk_label_new(_("Title")));
+ gtk_notebook_append_page (GTK_NOTEBOOK (instance->notebook), instance->note_boxes[1], gtk_label_new(_("Author/Editor")));
+ gtk_notebook_append_page (GTK_NOTEBOOK (instance->notebook), instance->note_boxes[2], gtk_label_new(_("Publication")));
+ gtk_notebook_append_page (GTK_NOTEBOOK (instance->notebook), instance->note_boxes[3], gtk_label_new(_("Publisher")));
+ gtk_notebook_append_page (GTK_NOTEBOOK (instance->notebook), instance->note_boxes[4], gtk_label_new(_("Misc")));
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (instance)->vbox), instance->notebook, TRUE, TRUE, 0);
+
+ /* Add OK and cancel button */
+ gtk_dialog_add_button (GTK_DIALOG (instance), GTK_STOCK_OK, GTK_RESPONSE_OK);
+ gtk_dialog_add_button (GTK_DIALOG (instance), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (instance), GTK_RESPONSE_CANCEL);
+ gtk_window_set_icon_name(GTK_WINDOW(instance), "xfbib");
+ gtk_widget_show_all(GTK_WIDGET(instance));
+}
+
+static void
+xfbib_entry_edit_dialog_finalize(GObject *obj)
+{
+ G_OBJECT_CLASS(xfbib_entry_edit_dialog_parent_class)->finalize(obj);
+}
+
+GtkWidget *
+xfbib_entry_edit_dialog_new(XfbibBibtexEntry *entry)
+{
+ XfbibBibtexField *field;
+ XfbibBibtexValue *value;
+ const gchar *bibtype;
+ GList *list;
+ int n, i;
+
+ XfbibEntryEditDialog *entry_edit_dialog;
+ entry_edit_dialog = g_object_new(XFBIB_TYPE_ENTRY_EDIT_DIALOG,
+ "destroy-with-parent", ((GTK_DIALOG_MODAL & GTK_DIALOG_DESTROY_WITH_PARENT) != 0),
+ "has-separator", ((GTK_DIALOG_MODAL & GTK_DIALOG_NO_SEPARATOR) == 0),
+ "modal", ((GTK_DIALOG_MODAL & GTK_DIALOG_MODAL) != 0),
+ "title", (entry == NULL) ? "Add new entry" : "Edit existing entry",
+ NULL);
+
+ if (entry != NULL) {
+ bibtype = xfbib_bibtex_entry_get_bibtype(entry);
+ for (n = 0; xfbib_type_constants[n].text != NULL; n++) {
+ if (strcasecmp(xfbib_type_constants[n].text, bibtype) == 0) {
+ gtk_combo_box_set_active(GTK_COMBO_BOX (entry_edit_dialog->type_combo_box), n);
+ break;
+ }
+ }
+
+ gtk_entry_set_text(GTK_ENTRY (entry_edit_dialog->key_entry), xfbib_bibtex_entry_get_key(entry));
+
+ for (n = 0; n < XFBIB_BIBTEX_FIELD_N_FIELDS; n++) {
+ list = xfbib_bibtex_entry_get_fields(entry);
+
+ for (i = 0, value = NULL; i < g_list_length(list); i++) {
+ field = g_list_nth_data(list, i);
+ if (strcasecmp(xfbib_bibtex_field_get_variable(field),
+ xfbib_bibtex_field_constants[n].label) == 0) {
+ value = xfbib_bibtex_field_get_value(field);
+ break;
+ }
+ }
+ if (value == NULL) {
+ /* Did not find a matching field */
+ continue;
+ }
+
+ if (g_list_length(xfbib_bibtex_value_get(value)) == 1) {
+ /* Single value */
+ if (n == XFBIB_BIBTEX_FIELD_AUTHOR || n == XFBIB_BIBTEX_FIELD_EDITOR) {
+ xfbib_multiple_input_set_text (XFBIB_MULTIPLE_INPUT (entry_edit_dialog->inputs[n].input),
+ xfbib_bibtex_value_get_str(value));
+ } else {
+ gtk_entry_set_text(GTK_ENTRY (entry_edit_dialog->inputs[n].input),
+ xfbib_bibtex_value_get_str(value));
+ }
+ } else {
+ if (n == XFBIB_BIBTEX_FIELD_AUTHOR || n == XFBIB_BIBTEX_FIELD_EDITOR) {
+ xfbib_multiple_input_set(XFBIB_MULTIPLE_INPUT(entry_edit_dialog->inputs[n].input),
+ xfbib_bibtex_value_get(value));
+ } else {
+ gtk_widget_set_sensitive(entry_edit_dialog->inputs[n].input, FALSE);
+ entry_edit_dialog->inputs[n].gl = xfbib_bibtex_value_get(value);
+ }
+ }
+ }
+ }
+
+ return GTK_WIDGET(entry_edit_dialog);
+}
+
+XfbibBibtexEntry *
+xfbib_entry_edit_dialog_get_entry(XfbibEntryEditDialog *entry_edit_dialog)
+{
+ XfbibBibtexEntry *entry;
+ XfbibBibtexField *field;
+ GList *field_list = NULL;
+ XfbibBibtexValue *value;
+ XfbibState *state;
+ int n;
+ const gchar *str;
+
+ state = xfbib_state_new();
+
+ entry = xfbib_bibtex_entry_new(G_OBJECT(xfbib_state_get_bibtex_elements(state))/* TODO: Elements */);
+ xfbib_bibtex_entry_set_separator(entry, '{'); /* TODO: Should the separator be "taken" from somewhere or is it arbitrary? */
+ xfbib_bibtex_entry_set_key(entry, gtk_entry_get_text(GTK_ENTRY(entry_edit_dialog->key_entry)));
+ xfbib_bibtex_entry_set_bibtype(entry, gtk_combo_box_get_active_text(GTK_COMBO_BOX(entry_edit_dialog->type_combo_box)));
+ for (n = 0; n < XFBIB_BIBTEX_FIELD_N_FIELDS; n++) {
+ if ((n == XFBIB_BIBTEX_FIELD_AUTHOR) || (n == XFBIB_BIBTEX_FIELD_EDITOR)) {
+ str = xfbib_multiple_input_get_str(XFBIB_MULTIPLE_INPUT(entry_edit_dialog->inputs[n].input));
+ if(str != NULL) {
+ if(strcmp(str, "") == 0) {
+ continue;
+ }
+ field = xfbib_bibtex_field_new(G_OBJECT(entry));
+ xfbib_bibtex_field_set_variable(field, xfbib_bibtex_field_constants[n].label);
+ value = xfbib_bibtex_value_new(G_OBJECT(field));
+ xfbib_bibtex_value_set_str(value, str);
+ } else {
+ field = xfbib_bibtex_field_new(G_OBJECT(entry));
+ xfbib_bibtex_field_set_variable(field, xfbib_bibtex_field_constants[n].label);
+ value = xfbib_bibtex_value_new(G_OBJECT(field));
+ xfbib_bibtex_value_set(value, xfbib_multiple_input_get(XFBIB_MULTIPLE_INPUT(entry_edit_dialog->inputs[n].input)));
+ }
+ field_list = g_list_append(field_list, field);
+ xfbib_bibtex_field_set_value(field, value);
+ } else {
+ if(GTK_WIDGET_IS_SENSITIVE(GTK_ENTRY(entry_edit_dialog->inputs[n].input))) {
+ if(strcmp(gtk_entry_get_text(GTK_ENTRY(entry_edit_dialog->inputs[n].input)), "") == 0) {
+ continue;
+ }
+ /* TODO: check if they are integers or strings(variables), don't assume text */
+ field = xfbib_bibtex_field_new(G_OBJECT(entry));
+ xfbib_bibtex_field_set_variable(field, xfbib_bibtex_field_constants[n].label);
+ value = xfbib_bibtex_value_new(G_OBJECT(field));
+ xfbib_bibtex_value_set_str(value, gtk_entry_get_text(GTK_ENTRY(entry_edit_dialog->inputs[n].input)));
+ xfbib_bibtex_field_set_value(field, value);
+ field_list = g_list_append(field_list, field);
+ } else {
+ field = xfbib_bibtex_field_new(G_OBJECT(entry));
+ xfbib_bibtex_field_set_variable(field, xfbib_bibtex_field_constants[n].label);
+ value = xfbib_bibtex_value_new(G_OBJECT(field));
+ xfbib_bibtex_value_set(value, entry_edit_dialog->inputs[n].gl);
+ xfbib_bibtex_field_set_value(field, value);
+ field_list = g_list_append(field_list, field);
+ }
+ }
+ }
+ xfbib_bibtex_entry_set_fields(entry, field_list);
+ return entry;
+}
+
+gboolean
+xfbib_entry_edit_dialog_valid_entry(XfbibEntryEditDialog *entry_edit_dialog)
+{
+ if(gtk_combo_box_get_active(GTK_COMBO_BOX(entry_edit_dialog->type_combo_box)) == -1) {
+ xfce_warn(_("A BibTeX type is required!"));
+ return FALSE;
+ }
+ if(strcmp(gtk_entry_get_text(GTK_ENTRY(entry_edit_dialog->key_entry)), "") == 0) {
+ xfce_warn(_("BibTex key is required!"));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
Copied: xfbib/trunk/src/xfbib-entry-tree-view.c (from rev 7054, xfbib/branches/gobject/src/xfbib-entry-tree-view.c)
===================================================================
--- xfbib/trunk/src/xfbib-entry-tree-view.c (rev 0)
+++ xfbib/trunk/src/xfbib-entry-tree-view.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gtk/gtk.h>
+
+#include "xfbib-list-store.h"
+#include "xfbib-entry-tree-view.h"
+#include "xfbib-bibtex.h"
+#include "xfbib-state.h"
+#include "xfbib-bibtex-entry.h"
+#include "xfbib-entry-edit-dialog.h"
+
+struct _XfbibEntryTreeView
+{
+ GtkTreeView parent;
+};
+
+typedef struct _XfbibEntryTreeViewClass
+{
+ GtkTreeViewClass parent;
+} XfbibEntryTreeViewClass;
+
+static void xfbib_entry_tree_view_class_init(XfbibEntryTreeViewClass *klass);
+
+static void xfbib_entry_tree_view_init(XfbibEntryTreeView *instance);
+static void xfbib_entry_tree_view_finalize(GObject *obj);
+
+static GObjectClass *xfbib_entry_tree_view_parent_class = NULL;
+
+static void
+cb_row_activated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
+{
+ g_print("cb_row_activated\n");
+ XfbibState *state;
+ XfbibBibtexEntry *entry, *new_entry;
+ GtkWidget *dialog;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ state = xfbib_state_new();
+ model = gtk_tree_view_get_model(tree_view);
+
+ if (gtk_tree_model_get_iter(model, &iter, path)) {
+ entry = XFBIB_BIBTEX_ENTRY(xfbib_list_store_get(XFBIB_LIST_STORE(model), &iter));
+ dialog = xfbib_entry_edit_dialog_new(entry);
+ for(;;) {
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ if(xfbib_entry_edit_dialog_valid_entry(dialog)) {
+ new_entry = xfbib_entry_edit_dialog_get_entry(XFBIB_ENTRY_EDIT_DIALOG(dialog));
+ xfbib_list_store_replace(XFBIB_LIST_STORE(model), G_OBJECT(entry), G_OBJECT(new_entry));
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+ gtk_widget_destroy(dialog);
+ }
+}
+
+static gboolean
+cb_button_press (GtkWidget *tree_view, GdkEventButton *event, gpointer data)
+{
+ g_print("cb_button_press\n");
+ XfbibBibtexEntry *new_entry;
+ GtkTreeModel *model;
+ GtkWidget *dialog;
+
+ if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
+ /* single click with the right mouse button */
+ /* TODO: Add a context menu here */
+ } else if (event->type == GDK_2BUTTON_PRESS && event->button == 1) {
+ /* double click with the left mouse button */
+
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
+
+ /* Check if any row has been selected */
+ if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection
+ (GTK_TREE_VIEW(tree_view)), NULL, NULL)) {
+ /*
+ * A row is selected Let the other cb_row_activated()
+ * function take care of the rest.
+ */
+ /* TODO: Take care of the event here instead */
+ return FALSE;
+ }
+
+ dialog = xfbib_entry_edit_dialog_new(NULL);
+
+ for(;;) {
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ if(xfbib_entry_edit_dialog_valid_entry(dialog)) {
+ new_entry = xfbib_entry_edit_dialog_get_entry(XFBIB_ENTRY_EDIT_DIALOG(dialog));
+ xfbib_list_store_add(XFBIB_LIST_STORE(model), G_OBJECT(new_entry));
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+ gtk_widget_destroy(dialog);
+
+ } else {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+GType
+xfbib_entry_tree_view_get_type (void)
+{
+ static GType type = 0;
+ if (type == 0) {
+ static const GTypeInfo info = {
+ sizeof (XfbibEntryTreeViewClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) xfbib_entry_tree_view_class_init, /* class_init */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (XfbibEntryTreeView),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) xfbib_entry_tree_view_init /* instance_init */
+ };
+ type = g_type_register_static (GTK_TYPE_TREE_VIEW, "XfbibEntryTreeView", &info, 0);
+ }
+ return type;
+}
+
+
+static void
+xfbib_entry_tree_view_class_init(XfbibEntryTreeViewClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *)klass;
+
+ xfbib_entry_tree_view_parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = xfbib_entry_tree_view_finalize;
+}
+
+static void
+xfbib_entry_tree_view_init(XfbibEntryTreeView *instance)
+{
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GtkTreeModel *model;
+ gint i;
+ struct {
+ gchar *label;
+ gchar *tooltip;
+ }xfbib_field_constants[] = {
+ {"Address", _("Address of publisher")},
+ {"Annote", _("Annotation for annotated bibliography styles")},
+ {"Author", _("Name(s) of the author(s), separated by 'and' if more than one")},
+ {"Booktitle", _("Title of the book, if only part of it is being cited")},
+ {"Chapter", _("Chapter number")},
+ {"Crossref", _("Citation key of the cross-referenced entry")},
+ {"Edition", _("Edition of the book (such as \"first\" or \"second\")")},
+ {"Editor", _("Name(s) of the editor(s), separated by 'and' if more than one")},
+ {"E-print", _("Specification of electronic publication")},
+ {"HowPublished", _("Publishing method if the method is nonstandard")},
+ {"Institution", _("Institution that was involved in the publishing")},
+ {"Journal", _("Journal or magazine in which the work was published")},
+ {"Key", _("Hidden field used for specifying or overriding the alphabetical order of entries")},
+ {"Month", _("Month of publication or creation if unpublished")},
+ {"Note", _("Miscellaneous extra information")},
+ {"Number", _("Number of journal, magazine, or tech-report")},
+ {"Organization", _("Sponsor of the conference")},
+ {"Pages", _("Page numbers separated by commas or double-hyphens")},
+ {"Publisher", _("Name of publisher")},
+ {"School", _("School where thesis was written")},
+ {"Series", _("Series of books in which the book was published")},
+ {"Title", _("Title of the work")},
+ {"Type", _("Type of technical report")},
+ {"URL", _("Internet address")},
+ {"Volume", _("Number of the volume")},
+ {"Year", _("Year of publication or creation if unpublished")}
+ };
+
+ /* Connect the double-click on a row to a callback function */
+ g_signal_connect(GTK_TREE_VIEW(instance), "row-activated", (GCallback) cb_row_activated, NULL);
+ /* Connect the double-click NOT on a row to a callback function */
+ g_signal_connect(GTK_WIDGET(instance), "button-press-event", (GCallback) cb_button_press, NULL);
+
+ for (i = 0; i < XFBIB_BIBTEX_FIELD_N_FIELDS; i++) {
+ switch (i) {
+ case XFBIB_BIBTEX_FIELD_ANNOTE:
+ case XFBIB_BIBTEX_FIELD_BOOKTITLE:
+ case XFBIB_BIBTEX_FIELD_CHAPTER:
+ case XFBIB_BIBTEX_FIELD_CROSSREF:
+ case XFBIB_BIBTEX_FIELD_EDITION:
+ case XFBIB_BIBTEX_FIELD_EDITOR:
+ case XFBIB_BIBTEX_FIELD_EPRINT:
+ case XFBIB_BIBTEX_FIELD_HOWPUBLISHED:
+ case XFBIB_BIBTEX_FIELD_INSTITUTION:
+ case XFBIB_BIBTEX_FIELD_JOURNAL:
+ case XFBIB_BIBTEX_FIELD_KEY:
+ case XFBIB_BIBTEX_FIELD_MONTH:
+ case XFBIB_BIBTEX_FIELD_NOTE:
+ case XFBIB_BIBTEX_FIELD_NUMBER:
+ case XFBIB_BIBTEX_FIELD_ORGANIZATION:
+ case XFBIB_BIBTEX_FIELD_PAGES:
+ case XFBIB_BIBTEX_FIELD_PUBLISHER:
+ case XFBIB_BIBTEX_FIELD_SCHOOL:
+ case XFBIB_BIBTEX_FIELD_SERIES:
+ case XFBIB_BIBTEX_FIELD_TYPE:
+ case XFBIB_BIBTEX_FIELD_URL:
+ case XFBIB_BIBTEX_FIELD_VOLUME:
+ continue;
+ break;
+ }
+ column = gtk_tree_view_column_new();
+
+ gtk_tree_view_column_set_title(column, xfbib_field_constants[i].label);
+
+ /* pack tree view column into tree view */
+ gtk_tree_view_append_column(GTK_TREE_VIEW(instance), column);
+
+ renderer = gtk_cell_renderer_text_new();
+
+ /* pack cell renderer into tree view column */
+ gtk_tree_view_column_pack_start(column, renderer, TRUE);
+
+ /*
+ * connect 'text' property of the cell renderer to
+ * model column that contains the first name
+ */
+ gtk_tree_view_column_add_attribute(column, renderer, "text", i);
+ }
+
+ model = GTK_TREE_MODEL(xfbib_list_store_new(TYPE_ENTRY));
+ gtk_tree_view_set_model(GTK_TREE_VIEW(instance), model);
+ g_object_unref(model); /* destroy model automatically with view */
+}
+
+static void
+xfbib_entry_tree_view_finalize(GObject *obj)
+{
+ G_OBJECT_CLASS(xfbib_entry_tree_view_parent_class)->finalize(obj);
+}
+
+GtkWidget *
+xfbib_entry_tree_view_new()
+{
+ XfbibEntryTreeView *tree_view;
+ tree_view = g_object_new(XFBIB_TYPE_ENTRY_TREE_VIEW, NULL);
+ return GTK_WIDGET(tree_view);
+}
+
Copied: xfbib/trunk/src/xfbib-file-io.c (from rev 7054, xfbib/branches/gobject/src/xfbib-file-io.c)
===================================================================
--- xfbib/trunk/src/xfbib-file-io.c (rev 0)
+++ xfbib/trunk/src/xfbib-file-io.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,300 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <gtk/gtk.h>
+#include <libxfcegui4/libxfcegui4.h>
+#include <stdlib.h>
+
+#include "xfbib-file-io.h"
+#include "xfbib-state.h"
+#include "xfbib-bibtex.h"
+#include "xfbib-bibtex-field.h"
+#include "xfbib-bibtex-entry.h"
+#include "xfbib-bibtex-comment.h"
+#include "xfbib-bibtex-preamble.h"
+#include "xfbib-bibtex-string.h"
+#include "xfbib-bibtex-value.h"
+#include "xfbib-string.h"
+#include "xfbib-integer.h"
+#include "xfbib-window.h"
+#include "xfbib-list-store.h"
+
+static void foreach_bibtex_element(gpointer, gpointer);
+static void foreach_field(gpointer, gpointer);
+static void foreach_value(GList *, GString *);
+
+/*
+ * Opens a file and returns NULL if something went wrong otherwise it returns
+ * the filename of the file that was parsed
+ */
+gchar *
+xfbib_file_io_open(gchar *filename)
+{
+ XfbibState *state;
+ XfbibBibtex *elements;
+ GtkTreeModel *list_store_entries, *list_store_strings;
+ gchar *contents, *name;
+ gsize length;
+ gint i, ret, n_entries, n_strings;
+ GError *err = NULL;
+ GtkWidget *dialog, *window;
+ GtkFileFilter *filter;
+
+ state = xfbib_state_new();
+
+ window = xfbib_state_get_window(state);
+ elements = xfbib_state_get_bibtex_elements(state);
+ list_store_entries = gtk_tree_view_get_model(GTK_TREE_VIEW(xfbib_window_get_tree_view(XFBIB_WINDOW(window), TYPE_ENTRY)));
+ list_store_strings = gtk_tree_view_get_model(GTK_TREE_VIEW(xfbib_window_get_tree_view(XFBIB_WINDOW(window), TYPE_STRING)));
+
+ name = filename;
+
+ if (name == NULL) {
+ dialog = gtk_file_chooser_dialog_new(_("Open"),
+ GTK_WINDOW(xfbib_state_get_window(state)),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL);
+
+ filter = gtk_file_filter_new();
+ gtk_file_filter_set_name(filter, _("BibTeX files"));
+ gtk_file_filter_add_pattern(filter, "*.bib");
+ gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
+ if ((ret = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)) {
+ xfbib_list_store_clear(XFBIB_LIST_STORE(list_store_entries));
+ xfbib_list_store_clear(XFBIB_LIST_STORE(list_store_strings));
+ name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+ } else {
+ gtk_widget_destroy(dialog);
+ return NULL;
+ }
+ gtk_widget_destroy(dialog);
+ }
+
+
+ if (!g_file_get_contents(name, &contents, &length, &err)) {
+ xfce_err(_("An error occured when opening the file: %s\n"), err->message);
+ g_error_free(err);
+ return NULL;
+ } else {
+ n_entries = xfbib_bibtex_get_n(elements, TYPE_ENTRY);
+ n_strings = xfbib_bibtex_get_n(elements, TYPE_STRING);
+ /* Parse the file and update the tree view */
+ if (xfbib_bibtex_parse(elements, contents)) {
+ for (i = n_entries; i < xfbib_bibtex_get_n(elements, TYPE_ENTRY); i++)
+ xfbib_list_store_row_inserted(XFBIB_LIST_STORE(list_store_entries), i);
+ /* TODO: Update the string tree_view */
+ for (i = n_strings; i < xfbib_bibtex_get_n(elements, TYPE_STRING); i++)
+ xfbib_list_store_row_inserted(XFBIB_LIST_STORE(list_store_strings), i);
+
+ }
+ }
+
+ return name;
+}
+
+
+gboolean
+xfbib_file_io_save(gchar *name)
+{
+ FILE *fd;
+ XfbibState *state;
+ XfbibBibtex *elements;
+ GString *str;
+
+ if (name == NULL) {
+ /* No filename, redirect to save as */
+ return xfbib_file_io_save_as();
+ }
+
+ state = xfbib_state_new();
+ elements = xfbib_state_get_bibtex_elements(state);
+
+ str = g_string_new("");
+
+ xfbib_bibtex_foreach(elements, foreach_bibtex_element, str);
+
+ if ((fd = fopen(name, "w")) == NULL) {
+ xfce_err(_("An error occured when opening the file: %s\n"), strerror(errno));
+ return FALSE;
+ }
+
+ if(fputs(str->str, fd) == EOF) {
+ xfce_err(_("An error occured when writing to the file: %s\n"), name);
+ return FALSE;
+ }
+
+ g_string_free(str, TRUE);
+ fclose(fd);
+ return TRUE;
+}
+
+
+gboolean
+xfbib_file_io_save_as(void)
+{
+ GtkWidget *dialog;
+ gchar *name;
+ XfbibState *state;
+ g_print(_("Save as\n"));
+
+
+ state = xfbib_state_new();
+
+ dialog = gtk_file_chooser_dialog_new(_("Save As"),
+ GTK_WINDOW(xfbib_state_get_window(state)),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_OK,
+ NULL);
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+ if (xfbib_file_io_save(name)) {
+ xfbib_state_set_filename(state, name);
+ xfbib_window_set_title(XFBIB_WINDOW(xfbib_state_get_window(state)), name);
+ }
+ }
+
+ gtk_widget_destroy(dialog);
+ return TRUE;
+}
+
+
+static void
+foreach_bibtex_element(gpointer _obj, gpointer _str)
+{
+ GObject *obj = _obj;
+ GString *str = _str;
+ gchar separator;
+
+ if (XFBIB_IS_BIBTEX_ENTRY(obj)) {
+ separator = xfbib_bibtex_entry_get_separator(XFBIB_BIBTEX_ENTRY(obj));
+ g_string_append_c(str, '@');
+ g_string_append(str, xfbib_bibtex_entry_get_bibtype(XFBIB_BIBTEX_ENTRY(obj)));
+ g_string_append_c(str, separator);
+ g_string_append(str, xfbib_bibtex_entry_get_key(XFBIB_BIBTEX_ENTRY(obj)));
+ g_string_append(str, ",\n");
+ /* XfbibBibtexField */
+ g_list_foreach(xfbib_bibtex_entry_get_fields(XFBIB_BIBTEX_ENTRY(obj)), foreach_field, str);
+ g_string_append_c(str, (separator == '{') ? '}' : ')');
+ g_string_append_c(str, '\n');
+ } else if (XFBIB_IS_BIBTEX_STRING(obj)) {
+ printf(_("printing bibtex string to file\n"));
+ separator = xfbib_bibtex_string_get_separator(XFBIB_BIBTEX_STRING(obj));
+ g_string_append(str, "@string ");
+ g_string_append_c(str, separator);
+ g_string_append(str, xfbib_bibtex_string_get_variable(XFBIB_BIBTEX_STRING(obj)));
+ g_string_append(str, " = ");
+ /* XfbibBibtexValue */
+ foreach_value(xfbib_bibtex_value_get(xfbib_bibtex_string_get_value(XFBIB_BIBTEX_STRING(obj))), str);
+ g_string_append_c(str, (separator == '{') ? '}' : ')');
+ g_string_append_c(str, '\n');
+ } else if (XFBIB_IS_BIBTEX_COMMENT(obj)) {
+ g_string_append(str, xfbib_bibtex_comment_get(XFBIB_BIBTEX_COMMENT(obj)));
+ } else if (XFBIB_IS_BIBTEX_PREAMBLE(obj)) {
+ separator = xfbib_bibtex_preamble_get_separator(XFBIB_BIBTEX_PREAMBLE(obj));
+ g_string_append(str, "@preamble ");
+ g_string_append_c(str, separator);
+ /* XfbibBibtexValue */
+ foreach_value(xfbib_bibtex_value_get(xfbib_bibtex_preamble_get_value(XFBIB_BIBTEX_PREAMBLE(obj))), str);
+ g_string_append_c(str, (separator == '{') ? '}' : ')');
+ g_string_append_c(str, '\n');
+ } else {
+ printf(_("Unknown object!\n"));
+ }
+}
+
+
+static void
+foreach_field(gpointer obj, gpointer _str)
+{
+ XfbibBibtexField *field = obj;
+ GString *str = _str;
+
+ g_string_append_c(str, '\t');
+ g_string_append(str, xfbib_bibtex_field_get_variable(XFBIB_BIBTEX_FIELD(obj)));
+ g_string_append(str, " = ");
+ /* XfbibBibtexValue */
+ foreach_value(xfbib_bibtex_value_get(xfbib_bibtex_field_get_value(field)), str);
+ g_string_append(str, ",\n");
+}
+
+
+static void
+foreach_value(GList *list, GString *str)
+{
+ GList *obj;
+ gchar separator;
+
+ for (obj = g_list_first(list); obj != NULL; obj = g_list_next(obj)) {
+ if (XFBIB_IS_STRING(obj->data)) {
+ separator = xfbib_string_get_separator(XFBIB_STRING(obj->data));
+ g_string_append_c(str, separator);
+ g_string_append(str, xfbib_file_io_escape_commands(xfbib_string_get(XFBIB_STRING(obj->data))));
+ g_string_append_c(str, (separator == '{') ? '}' : '"');
+ } else if (XFBIB_IS_INTEGER(obj->data)) {
+ g_string_append(str, xfbib_integer_get(XFBIB_INTEGER(obj->data)));
+ } else if (XFBIB_IS_BIBTEX_STRING(obj->data)) {
+ g_string_append(str, xfbib_bibtex_string_get_variable(XFBIB_BIBTEX_STRING(obj->data)));
+ }
+
+ if (g_list_last(list) != obj) {
+ g_string_append(str, " # ");
+ }
+ }
+}
+
+gchar *
+xfbib_file_io_escape_commands(gchar *str)
+{
+ int len, new_len, n, i;
+ gchar *new_str;
+
+ len = new_len = strlen(str) + 1;
+ new_str = malloc(len);
+
+ n = i = 0;
+ while(n < len) {
+ switch(str[n]) {
+ case '&':
+ case '%':
+ new_len++;
+ new_str = realloc(new_str, new_len);
+ new_str[i] = '\\';
+ i++;
+ new_str[i] = str[n];
+ i++;
+ n++;
+ break;
+ default:
+ new_str[i] = str[n];
+ i++;
+ n++;
+ }
+ }
+ return new_str;
+}
Copied: xfbib/trunk/src/xfbib-file-io.h (from rev 6997, xfbib/branches/gobject/src/xfbib-file-io.h)
===================================================================
--- xfbib/trunk/src/xfbib-file-io.h (rev 0)
+++ xfbib/trunk/src/xfbib-file-io.h 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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 __XFBIB_FILE_IO_H
+#define __XFBIB_FILE_IO_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+gchar *xfbib_file_io_open(gchar *);
+gboolean xfbib_file_io_save(gchar *);
+gboolean xfbib_file_io_save_as(void);
+gchar *xfbib_file_io_escape_commands(gchar *);
+
+G_END_DECLS
+
+#endif //__XFBIB_FILE_IO_H
Copied: xfbib/trunk/src/xfbib-input-dialog.c (from rev 7054, xfbib/branches/gobject/src/xfbib-input-dialog.c)
===================================================================
--- xfbib/trunk/src/xfbib-input-dialog.c (rev 0)
+++ xfbib/trunk/src/xfbib-input-dialog.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gtk/gtk.h>
+#include <libxfcegui4/libxfcegui4.h>
+
+#include "xfbib-input-dialog.h"
+
+struct _XfbibInputDialog
+{
+ XfceTitledDialog parent;
+ GtkWidget *string_key_label;
+ GtkWidget *text_label;
+ GtkWidget *string_key_entry;
+ GtkWidget *text_entry;
+};
+
+typedef struct _XfbibInputDialogClass
+{
+ XfceTitledDialogClass parent;
+} XfbibInputDialogClass;
+
+static void xfbib_input_dialog_class_init(XfbibInputDialogClass *klass);
+
+static void xfbib_input_dialog_init(XfbibInputDialog *instance);
+static void xfbib_input_dialog_finalize(GObject *obj);
+
+static GObjectClass *xfbib_input_dialog_parent_class = NULL;
+
+GType
+xfbib_input_dialog_get_type (void)
+{
+ static GType type = 0;
+ if (type == 0) {
+ static const GTypeInfo info = {
+ sizeof (XfbibInputDialogClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) xfbib_input_dialog_class_init, /* class_init */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (XfbibInputDialog),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) xfbib_input_dialog_init /* instance_init */
+ };
+ type = g_type_register_static (XFCE_TYPE_TITLED_DIALOG, "XfbibInputDialog", &info, 0);
+ }
+ return type;
+}
+
+
+static void
+xfbib_input_dialog_class_init(XfbibInputDialogClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *)klass;
+
+ xfbib_input_dialog_parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = xfbib_input_dialog_finalize;
+}
+
+static void
+xfbib_input_dialog_init(XfbibInputDialog *instance)
+{
+ GtkWidget *table;
+
+ table = gtk_table_new(2,2,FALSE);
+
+ gtk_table_set_row_spacings(GTK_TABLE(table), 6);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 12);
+ gtk_container_set_border_width(GTK_CONTAINER (table), 6);
+
+ instance->string_key_label = gtk_label_new(_("String key:"));
+ instance->text_label = gtk_label_new(_("Text:"));
+
+ instance->string_key_entry = gtk_combo_box_entry_new();
+ instance->text_entry = gtk_entry_new();
+
+ gtk_table_attach(GTK_TABLE(table), instance->string_key_label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), instance->text_label, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
+
+ gtk_table_attach_defaults(GTK_TABLE(table), instance->string_key_entry, 0, 1, 0, 1);
+ gtk_table_attach_defaults(GTK_TABLE(table), instance->text_entry, 1, 2, 0, 1);
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (instance)->vbox), table, FALSE, TRUE, 6);
+
+ /* Add OK and cancel button */
+ gtk_dialog_add_button (GTK_DIALOG (instance), GTK_STOCK_OK, GTK_RESPONSE_OK);
+ gtk_dialog_add_button (GTK_DIALOG (instance), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (instance), GTK_RESPONSE_CANCEL);
+ gtk_window_set_icon_name(GTK_WINDOW(instance), "xfbib");
+ gtk_widget_show_all(GTK_WIDGET(instance));
+}
+
+static void
+xfbib_input_dialog_finalize(GObject *obj)
+{
+ G_OBJECT_CLASS(xfbib_input_dialog_parent_class)->finalize(obj);
+}
+
+GtkWidget *
+xfbib_input_dialog_new(gchar *title, const gchar *label)
+{
+ XfbibInputDialog *input_dialog;
+ gchar *lbl;
+ input_dialog = g_object_new(XFBIB_TYPE_INPUT_DIALOG,
+ "destroy-with-parent", ((GTK_DIALOG_MODAL & GTK_DIALOG_DESTROY_WITH_PARENT) != 0),
+ "has-separator", ((GTK_DIALOG_MODAL & GTK_DIALOG_NO_SEPARATOR) == 0),
+ "modal", ((GTK_DIALOG_MODAL & GTK_DIALOG_MODAL) != 0),
+ "title", title,
+ NULL);
+
+ //lbl = g_strdup_printf("%s:", label);
+ //gtk_label_set_text(GTK_LABEL(input_dialog->label), lbl);
+ //g_free(lbl);
+ return GTK_WIDGET(input_dialog);
+}
+
+const gchar *xfbib_input_dialog_get_string_key(XfbibInputDialog *instance)
+{
+ return gtk_combo_box_get_active_text(GTK_COMBO_BOX(instance->string_key_entry));
+}
+
+const gchar *xfbib_input_dialog_get_text(XfbibInputDialog *instance)
+{
+ return gtk_entry_get_text(GTK_ENTRY(instance->text_entry));
+}
+
Copied: xfbib/trunk/src/xfbib-menu-bar.c (from rev 7054, xfbib/branches/gobject/src/xfbib-menu-bar.c)
===================================================================
--- xfbib/trunk/src/xfbib-menu-bar.c (rev 0)
+++ xfbib/trunk/src/xfbib-menu-bar.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,485 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <libxfcegui4/libxfcegui4.h>
+#include <stdio.h>
+
+#include "xfbib-entry-edit-dialog.h"
+#include "xfbib-menu-bar.h"
+#include "xfbib-bibtex-field.h"
+#include "xfbib-bibtex-string.h"
+#include "xfbib-bibtex.h"
+#include "xfbib-file-io.h"
+#include "xfbib-state.h"
+#include "xfbib-list-store.h"
+
+struct _XfbibMenuBar
+{
+ GtkMenuBar parent;
+ GtkWidget *file;
+ GtkWidget *entry;
+ GtkWidget *variable;
+ GtkWidget *view;
+ GtkWidget *view_columns;
+ GtkWidget *help;
+};
+
+static XfbibWindow *window;
+
+typedef struct _XfbibMenuBarClass
+{
+ GtkMenuBarClass parent;
+} XfbibMenuBarClass;
+
+static void xfbib_menu_bar_class_init(XfbibMenuBarClass *klass);
+
+static void xfbib_menu_bar_init(XfbibMenuBar *instance);
+static void xfbib_menu_bar_finalize(GObject *obj);
+
+static GObjectClass *xfbib_menu_bar_parent_class = NULL;
+
+
+static void
+cb_file_new_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+ g_print(_("File/New\n"));
+}
+
+static void
+cb_file_open_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+ XfbibState *state;
+ gchar *filename;
+ g_print(_("File/Open\n"));
+
+ state = xfbib_state_new();
+
+ if ((filename = xfbib_file_io_open(NULL)) != NULL) {
+ xfbib_state_set_filename(state, filename);
+ xfbib_window_set_title(XFBIB_WINDOW(xfbib_state_get_window(state)), filename);
+ }
+}
+
+static void
+cb_file_save_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+ XfbibState *state;
+ g_print(_("File/Save\n"));
+ state = xfbib_state_new();
+
+ xfbib_file_io_save(xfbib_state_get_filename(state));
+}
+
+static void
+cb_file_save_as_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+ g_print(_("File/Save As\n"));
+ xfbib_file_io_save_as();
+}
+
+static void
+cb_file_quit_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+ gtk_widget_destroy(GTK_WIDGET(window));
+}
+
+static void
+cb_entry_add_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+ XfbibState *state;
+ XfbibBibtexEntry *new_entry;
+ GtkTreeModel *model;
+ GtkWidget *dialog;
+ g_print(_("Entry/Add\n"));
+
+ state = xfbib_state_new();
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(xfbib_window_get_tree_view(
+ XFBIB_WINDOW(xfbib_state_get_window(state)), TYPE_ENTRY)));
+
+ dialog = xfbib_entry_edit_dialog_new(NULL);
+
+ for(;;) {
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ if(xfbib_entry_edit_dialog_valid_entry(dialog)) {
+ new_entry = xfbib_entry_edit_dialog_get_entry(XFBIB_ENTRY_EDIT_DIALOG(dialog));
+ xfbib_list_store_add(XFBIB_LIST_STORE(model), G_OBJECT(new_entry));
+ }
+ } else {
+ break;
+ }
+ }
+ gtk_widget_destroy(dialog);
+}
+
+static void
+cb_entry_remove_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+ XfbibState *state;
+ GtkWidget *tree_view;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ g_print(_("Entry/Remove\n"));
+
+ state = xfbib_state_new();
+ tree_view = GTK_WIDGET(xfbib_window_get_tree_view(XFBIB_WINDOW(xfbib_state_get_window(state)), TYPE_ENTRY));
+
+ /* This will only work in single or browse selection mode! */
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+ if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ xfbib_list_store_remove(XFBIB_LIST_STORE(model), &iter);
+ } else {
+ xfce_err(_("No row has been selected for removal"));
+ }
+}
+
+static void
+cb_entry_edit_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+ XfbibState *state;
+ XfbibBibtexEntry *entry, *new_entry;
+ GtkWidget *tree_view, *dialog;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ g_print(_("Entry/Edit\n"));
+
+ state = xfbib_state_new();
+ tree_view = GTK_WIDGET(xfbib_window_get_tree_view(XFBIB_WINDOW(xfbib_state_get_window(state)), TYPE_ENTRY));
+
+ /* This will only work in single or browse selection mode! */
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+ if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ entry = XFBIB_BIBTEX_ENTRY(xfbib_list_store_get(XFBIB_LIST_STORE(model), &iter));
+
+ dialog = xfbib_entry_edit_dialog_new(entry);
+ for(;;) {
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ if(xfbib_entry_edit_dialog_valid_entry(dialog)) {
+ new_entry = xfbib_entry_edit_dialog_get_entry(XFBIB_ENTRY_EDIT_DIALOG(dialog));
+ xfbib_list_store_replace(XFBIB_LIST_STORE(model), G_OBJECT(entry), G_OBJECT(new_entry));
+ }
+ } else {
+ break;
+ }
+ }
+ gtk_widget_destroy(dialog);
+ } else {
+ xfce_err(_("No row has been selected for edit"));
+ }
+}
+
+static void
+cb_variable_add_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+ XfbibState *state;
+ XfbibBibtexString *new_string;
+ GtkTreeModel *model;
+ GtkWidget *dialog;
+ g_print(_("Variable/add\n"));
+
+ state = xfbib_state_new();
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(xfbib_window_get_tree_view(
+ XFBIB_WINDOW(xfbib_state_get_window(state)), TYPE_STRING)));
+#if 0
+ dialog = xfbib_entry_edit_dialog_new(NULL);
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ new_string = xfbib_entry_edit_dialog_get_entry(XFBIB_ENTRY_EDIT_DIALOG(dialog));
+ xfbib_list_store_add(XFBIB_LIST_STORE(model), G_OBJECT(new_string));
+ }
+ gtk_widget_destroy(dialog);
+#endif
+}
+
+static void
+cb_variable_remove_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+ XfbibState *state;
+ GtkWidget *tree_view;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ g_print(_("Variable/Remove\n"));
+
+ state = xfbib_state_new();
+ tree_view = GTK_WIDGET(xfbib_window_get_tree_view(XFBIB_WINDOW(xfbib_state_get_window(state)), TYPE_STRING));
+
+ /* This will only work in single or browse selection mode! */
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+ if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ xfbib_list_store_remove(XFBIB_LIST_STORE(model), &iter);
+ } else {
+ xfce_err(_("No row has been selected for removal"));
+ }
+}
+
+static void
+cb_variable_edit_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+ XfbibState *state;
+ XfbibBibtexString *string, *new_string;
+ GtkWidget *tree_view, *dialog;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ g_print(_("Variable/Edit\n"));
+
+ state = xfbib_state_new();
+ tree_view = GTK_WIDGET(xfbib_window_get_tree_view(XFBIB_WINDOW(xfbib_state_get_window(state)), TYPE_STRING));
+
+ /* This will only work in single or browse selection mode! */
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+ if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ string = XFBIB_BIBTEX_STRING(xfbib_list_store_get(XFBIB_LIST_STORE(model), &iter));
+
+#if 0
+ dialog = xfbib_entry_edit_dialog_new(string);
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ new_string = xfbib_entry_edit_dialog_get_entry(XFBIB_ENTRY_EDIT_DIALOG(dialog));
+ xfbib_list_store_replace(XFBIB_LIST_STORE(model), G_OBJECT(string), G_OBJECT(new_string));
+ }
+ gtk_widget_destroy(dialog);
+#endif
+ } else {
+ xfce_err(_("No row has been selected for edit"));
+ }
+
+}
+
+static void
+cb_help_about_activate (GtkMenuItem *menuitem, gpointer ignored)
+{
+ gchar* xfbib_authors[] = {N_("David Gustafsson <david.s.gustafsson at gmail.com>"),
+ N_("Jesper Karlsson <zarper at gmail.com>"),
+ NULL};
+
+/*
+ * From the GtkAboutDialog documentation:
+ * Note that prior to GTK+ 2.12, the "program-name" property was called "name".
+ * This was changed to avoid the conflict with the "name" property.
+ */
+ gtk_show_about_dialog(GTK_WINDOW(window),
+ "authors", xfbib_authors,
+ "comments", _("Xfbib is a BibTeX editor for the Xfce Desktop Environment."),
+ "copyright", XFCE_COPYRIGHT_TEXT("2008", "Jesper Karlsson & David Gustafsson"),
+ "license", XFCE_LICENSE_GPL,
+ "logo-icon-name", PACKAGE,
+#if GTK_CHECK_VERSION(2,12,0)
+ "program-name", PACKAGE_NAME,
+#else
+ "name", PACKAGE_NAME,
+#endif
+ "title", "About " PACKAGE_NAME,
+ "version", VERSION,
+ "website", WEBSITE,
+ NULL);
+}
+
+GType
+xfbib_menu_bar_get_type (void)
+{
+ static GType type = 0;
+ if (type == 0) {
+ static const GTypeInfo info = {
+ sizeof (XfbibMenuBarClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) xfbib_menu_bar_class_init, /* class_init */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (XfbibMenuBar),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) xfbib_menu_bar_init /* instance_init */
+ };
+ type = g_type_register_static (GTK_TYPE_MENU_BAR, "XfbibMenuBar", &info, 0);
+ }
+ return type;
+}
+
+static void
+xfbib_menu_bar_class_init(XfbibMenuBarClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *)klass;
+
+ xfbib_menu_bar_parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = xfbib_menu_bar_finalize;
+}
+
+static void
+xfbib_menu_bar_init(XfbibMenuBar *instance)
+{
+ GtkWidget *item;
+ GtkAccelGroup *accel;
+
+ accel = gtk_accel_group_new();
+
+ /* File menu */
+ instance->file = gtk_menu_new();
+ /* Add things to menu */
+
+ /* New */
+ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, accel);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance->file), item);
+ g_signal_connect_swapped (G_OBJECT (item), "activate",
+ G_CALLBACK (cb_file_new_activate), "new");
+
+ /* Open */
+ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, accel);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance->file), item);
+ g_signal_connect (G_OBJECT (item), "activate",
+ G_CALLBACK (cb_file_open_activate), NULL);
+
+ /* Save */
+ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_SAVE, accel);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance->file), item);
+ g_signal_connect_swapped (G_OBJECT (item), "activate",
+ G_CALLBACK (cb_file_save_activate), "save");
+
+ /* Save as */
+ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_SAVE_AS, accel);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance->file), item);
+ g_signal_connect_swapped (G_OBJECT (item), "activate",
+ G_CALLBACK (cb_file_save_as_activate), "save_as");
+
+ /* Quit */
+ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, accel);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance->file), item);
+ g_signal_connect_swapped (G_OBJECT (item), "activate",
+ G_CALLBACK (cb_file_quit_activate), instance);
+
+ item = gtk_menu_item_new_with_label(_("File"));
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), instance->file);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance), item);
+
+ /* Entry menu */
+ instance->entry = gtk_menu_new();
+ /* Add things to menu */
+ /* Add */
+ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ADD, accel);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance->entry), item);
+ g_signal_connect_swapped (G_OBJECT (item), "activate",
+ G_CALLBACK (cb_entry_add_activate), instance);
+ /* Remove */
+ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_REMOVE, accel);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance->entry), item);
+ g_signal_connect_swapped (G_OBJECT (item), "activate",
+ G_CALLBACK (cb_entry_remove_activate), instance);
+
+ /* Edit */
+ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_EDIT, accel);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance->entry), item);
+ g_signal_connect_swapped (G_OBJECT (item), "activate",
+ G_CALLBACK (cb_entry_edit_activate), instance);
+
+
+ item = gtk_menu_item_new_with_label(_("Entry"));
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), instance->entry);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance), item);
+
+ /* Variable menu */
+ instance->variable = gtk_menu_new();
+ /* Add things to menu */
+ /* Add */
+ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ADD, accel);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance->variable), item);
+ g_signal_connect_swapped (G_OBJECT (item), "activate",
+ G_CALLBACK (cb_variable_add_activate), instance);
+ /* Remove */
+ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_REMOVE, accel);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance->variable), item);
+ g_signal_connect_swapped (G_OBJECT (item), "activate",
+ G_CALLBACK (cb_variable_remove_activate), instance);
+
+ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_EDIT, accel);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance->variable), item);
+ g_signal_connect_swapped (G_OBJECT (item), "activate",
+ G_CALLBACK (cb_variable_edit_activate), instance);
+
+
+ item = gtk_menu_item_new_with_label(_("Variable"));
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), instance->variable);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance), item);
+
+ /* View menu */
+ instance->view = gtk_menu_new();
+ /* Add things to menu */
+ instance->view_columns = gtk_menu_new();
+ /*
+ item = gtk_menu_item_new_with_label("Show Columns");
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), instance->view_columns);
+ gtk_menu_shell_append(GTK_MENU_SHELL (instance->view), item);
+ */
+
+ /* Columns submenu */
+ /*
+ for (i = 0; i < XFBIB_BIBTEX_FIELD_N_FIELDS; i++) {
+ str = g_strdup_printf("Show %s", xfbib_field_get_column_name(i));
+ item = gtk_check_menu_item_new_with_mnemonic(str);
+ g_free(str);
+ gtk_menu_shell_append(GTK_MENU_SHELL (instance->view_columns), item);
+ }
+ */
+
+ item = gtk_check_menu_item_new_with_mnemonic(_("Show Toolbar"));
+ gtk_menu_shell_append(GTK_MENU_SHELL (instance->view), item);
+
+ item = gtk_check_menu_item_new_with_mnemonic(_("Show Status Bar"));
+ gtk_menu_shell_append(GTK_MENU_SHELL (instance->view), item);
+
+ item = gtk_menu_item_new_with_label(_("View"));
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), instance->view);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance), item);
+
+ /* Help menu */
+ instance->help = gtk_menu_new();
+ /* Add things to menu */
+ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, accel);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance->help), item);
+ g_signal_connect_swapped (G_OBJECT (item), "activate",
+ G_CALLBACK (cb_help_about_activate), "about");
+
+ /* Create the button on the menu bar */
+ item = gtk_menu_item_new_with_label(_("Help"));
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), instance->help);
+ gtk_menu_shell_append(GTK_MENU_SHELL(instance), item);
+
+}
+
+static void
+xfbib_menu_bar_finalize(GObject *obj)
+{
+ G_OBJECT_CLASS(xfbib_menu_bar_parent_class)->finalize(obj);
+}
+
+GtkWidget *
+xfbib_menu_bar_new(XfbibWindow *w)
+{
+ XfbibMenuBar *menu_bar;
+ menu_bar = g_object_new(XFBIB_TYPE_MENU_BAR, NULL);
+ window = w;
+ return GTK_WIDGET(menu_bar);
+}
+
Copied: xfbib/trunk/src/xfbib-multiple-input.c (from rev 7054, xfbib/branches/gobject/src/xfbib-multiple-input.c)
===================================================================
--- xfbib/trunk/src/xfbib-multiple-input.c (rev 0)
+++ xfbib/trunk/src/xfbib-multiple-input.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,351 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gtk/gtk.h>
+#include <glib.h>
+
+#include "xfbib-multiple-input.h"
+#include "xfbib-input-dialog.h"
+#include "xfbib-bibtex-string.h"
+#include "xfbib-bibtex-value.h"
+#include "xfbib-string.h"
+#include "xfbib-integer.h"
+#include "xfbib-state.h"
+
+struct _XfbibMultipleInput
+{
+ GtkVBox parent;
+ GtkWidget *tree_view;
+ GtkWidget *add_button;
+ GtkWidget *remove_button;
+};
+
+typedef struct _XfbibMultipleInputClass
+{
+ GtkVBoxClass parent;
+} XfbibMultipleInputClass;
+
+static void xfbib_multiple_input_class_init(XfbibMultipleInputClass *klass);
+
+static void xfbib_multiple_input_init(XfbibMultipleInput *instance);
+static void xfbib_multiple_input_finalize(GObject *obj);
+static void cb_cell_edited_event(GtkCellRendererText *renderer, char *path,
+ char *new_text, GtkTreeView *treeview);
+static void cb_add_button_clicked_event(GtkWidget *ptr);
+static void cb_remove_button_clicked_event(GtkWidget *ptr);
+
+static GObjectClass *xfbib_multiple_input_parent_class = NULL;
+
+static void cb_cell_edited_event (GtkCellRendererText *renderer, char *path,
+ char *text, GtkTreeView *treeview)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ if (strcasecmp (text, "") != 0) {
+ model = gtk_tree_view_get_model (treeview);
+ if (gtk_tree_model_get_iter_from_string (model, &iter, path))
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, text, -1);
+ }
+}
+
+static void cb_add_button_clicked_event(GtkWidget *tree_view)
+{
+ g_printf("cb_add_button_clicked_event\n");
+ GtkWidget *dialog;
+ GtkListStore *list;
+ GtkTreeIter iter;
+ GtkTreeViewColumn *column;
+ const gchar *string_key, *text;
+ gchar *str;
+
+ column = gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view), 0);
+ str = g_strdup_printf(_("Add %s"), g_ascii_strdown(gtk_tree_view_column_get_title(column), -1));
+ dialog = xfbib_input_dialog_new(str, gtk_tree_view_column_get_title(column));
+ g_free(str);
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ string_key = xfbib_input_dialog_get_string_key(XFBIB_INPUT_DIALOG(dialog));
+ text = xfbib_input_dialog_get_text(XFBIB_INPUT_DIALOG(dialog));
+ if ((strcasecmp (string_key, "") != 0) || (strcasecmp (text, "") != 0)) {
+ list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view)));
+ gtk_list_store_append(list, &iter);
+ if (strcasecmp (string_key, "") != 0) {
+ gtk_list_store_set(list, &iter, 0, string_key, 1, text, -1);
+ } else {
+ gtk_list_store_set(list, &iter, 0, text, -1);
+ }
+ /* TODO: Update colors */
+ }
+ }
+ gtk_widget_destroy(dialog);
+}
+
+static void cb_remove_button_clicked_event(GtkWidget *tree_view)
+{
+ g_printf("cb_remove_button_clicked_event\n");
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+ if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
+ /* TODO: Update colors */
+ }
+}
+
+GType
+xfbib_multiple_input_get_type (void)
+{
+ static GType type = 0;
+ if (type == 0) {
+ static const GTypeInfo info = {
+ sizeof (XfbibMultipleInputClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) xfbib_multiple_input_class_init, /* class_init */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (XfbibMultipleInput),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) xfbib_multiple_input_init /* instance_init */
+ };
+ type = g_type_register_static (GTK_TYPE_VBOX, "XfbibMultipleInput", &info, 0);
+ }
+ return type;
+}
+
+static void
+xfbib_multiple_input_class_init(XfbibMultipleInputClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *)klass;
+
+ xfbib_multiple_input_parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = xfbib_multiple_input_finalize;
+}
+
+static void
+xfbib_multiple_input_init(XfbibMultipleInput *instance)
+{
+ GtkWidget *button_box;
+ GtkListStore *list;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkWidget *scrolled_window;
+
+ gtk_box_set_spacing(GTK_BOX(instance), 12);
+
+ button_box = gtk_hbox_new(FALSE, 12);
+
+ /* Tree view */
+ instance->tree_view = gtk_tree_view_new();
+
+ renderer = gtk_cell_renderer_text_new();
+ g_object_set(renderer, "editable", TRUE, NULL);
+ g_signal_connect(renderer, "edited", (GCallback) cb_cell_edited_event, instance->tree_view);
+
+ column = gtk_tree_view_column_new_with_attributes(_("Title"), renderer, "text", 0, NULL);
+ gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE);
+ gtk_tree_view_column_set_min_width(GTK_TREE_VIEW_COLUMN(column), 100);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(instance->tree_view), column);
+
+ list = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+
+ gtk_tree_view_set_model(GTK_TREE_VIEW(instance->tree_view), GTK_TREE_MODEL(list));
+ g_object_unref(list);
+
+ scrolled_window = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_OUT);
+
+ instance->add_button = gtk_button_new_from_stock(GTK_STOCK_ADD);
+ g_signal_connect_swapped(G_OBJECT(instance->add_button), "clicked",
+ G_CALLBACK(cb_add_button_clicked_event), instance->tree_view);
+
+ instance->remove_button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
+ g_signal_connect_swapped(G_OBJECT(instance->remove_button), "clicked",
+ G_CALLBACK(cb_remove_button_clicked_event), instance->tree_view);
+
+ gtk_box_pack_start(GTK_BOX(button_box), instance->add_button, TRUE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(button_box), instance->remove_button, TRUE, FALSE, 0);
+
+ gtk_container_add (GTK_CONTAINER (scrolled_window), instance->tree_view);
+
+ gtk_box_pack_start(GTK_BOX(instance), scrolled_window, TRUE, TRUE, 0);
+ gtk_box_pack_end(GTK_BOX(instance), button_box, FALSE, TRUE, 0);
+ gtk_widget_show_all(GTK_WIDGET(instance));
+}
+
+static void
+xfbib_multiple_input_finalize(GObject *obj)
+{
+ G_OBJECT_CLASS(xfbib_multiple_input_parent_class)->finalize(obj);
+}
+
+GtkWidget *
+xfbib_multiple_input_new(gchar *title, gchar *tooltip)
+{
+ GtkTreeViewColumn *column;
+ XfbibMultipleInput *multiple_input;
+ multiple_input = g_object_new(XFBIB_TYPE_MULTIPLE_INPUT, NULL);
+
+ column = gtk_tree_view_get_column(GTK_TREE_VIEW(multiple_input->tree_view), 0);
+ gtk_tree_view_column_set_title(column, title);
+
+ gtk_widget_set_tooltip_text(multiple_input->tree_view, tooltip);
+
+ return GTK_WIDGET(multiple_input);
+}
+
+void
+xfbib_multiple_input_set_text(XfbibMultipleInput *multiple_input, const gchar *text)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreeViewColumn *column;
+ gchar **split = NULL;
+ const gchar *title;
+ gint n;
+
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW (multiple_input->tree_view));
+ column = gtk_tree_view_get_column(GTK_TREE_VIEW(multiple_input->tree_view), 0);
+ title = gtk_tree_view_column_get_title(column);
+
+ if(strcasecmp(title, "author") == 0) {
+ split = g_strsplit(text, " and ", 0);
+ for (n = 0; split[n] != NULL; n++) {
+ gtk_list_store_append(GTK_LIST_STORE (model), &iter);
+ gtk_list_store_set(GTK_LIST_STORE (model), &iter, 0, split[n], -1);
+ }
+ } else {
+ gtk_list_store_append(GTK_LIST_STORE (model), &iter);
+ gtk_list_store_set(GTK_LIST_STORE (model), &iter, 0, text, -1);
+ }
+}
+
+void
+xfbib_multiple_input_set(XfbibMultipleInput *multiple_input, GList *gl)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gint n, len;
+ GObject *obj;
+
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW (multiple_input->tree_view));
+
+ len = g_list_length(gl);
+ for (n = 0; n < len; n++) {
+ gtk_list_store_append(GTK_LIST_STORE (model), &iter);
+ obj = g_list_nth_data(gl, n);
+ if(XFBIB_IS_STRING(obj)) {
+ gtk_list_store_set(GTK_LIST_STORE (model), &iter, 0, xfbib_string_get(XFBIB_STRING(obj)), -1);
+ } else if(XFBIB_IS_BIBTEX_STRING(obj)){
+ gtk_list_store_set(GTK_LIST_STORE (model), &iter, 0, xfbib_bibtex_string_get_variable(XFBIB_BIBTEX_STRING(obj)),
+ 1, xfbib_bibtex_value_get_str(xfbib_bibtex_string_get_value(XFBIB_BIBTEX_STRING(obj))), -1);
+ } else if(XFBIB_IS_INTEGER(obj)) {
+ gtk_list_store_set(GTK_LIST_STORE (model), &iter, 0, xfbib_integer_get(XFBIB_INTEGER(obj)), -1);
+ }
+ }
+}
+
+const gchar *
+xfbib_multiple_input_get_nth_row_ith_column(XfbibMultipleInput *multiple_input, gint row, gint column)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gint n = 0;
+ const gchar *tmp;
+
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW (multiple_input->tree_view));
+ if(gtk_tree_model_get_iter_first(model, &iter)) {
+ while((n < row) && gtk_tree_model_iter_next(model, &iter)) {
+ n++;
+ }
+ if(n == row) {
+ gtk_tree_model_get(model, &iter, column, &tmp, -1);
+ return tmp;
+ }
+ }
+ return NULL;
+}
+
+const gchar *
+xfbib_multiple_input_get_str(XfbibMultipleInput *multiple_input)
+{
+ GString *strbuf;
+ const gchar *str;
+ int n;
+
+ for(n = 0; xfbib_multiple_input_get_nth_row_ith_column(multiple_input, n, 0) != NULL; n++) {
+ str = xfbib_multiple_input_get_nth_row_ith_column(multiple_input, n, 1);
+ if(str != NULL) {
+ /* Atleast one bibtex string found, needs to be handled by xfbib_multiple_input_get */
+ return NULL;
+ }
+ }
+ /* Only text in multiple input, create one long string and return it */
+ strbuf = g_string_new("");
+ for(n = 0; (str = xfbib_multiple_input_get_nth_row_ith_column(multiple_input, n, 0)) != NULL; n++) {
+ if(n != 0) {
+ g_string_append(strbuf, " and ");
+ }
+ g_string_append(strbuf, str);
+ }
+ return g_string_free(strbuf, FALSE);
+}
+
+GList *
+xfbib_multiple_input_get(XfbibMultipleInput *multiple_input)
+{
+ GList *list = NULL;
+ XfbibString *str;
+ XfbibState *state;
+ XfbibBibtexString *string;
+ XfbibBibtexValue *value;
+ const gchar *bibstr, *text;
+ gint n;
+
+ state = xfbib_state_new();
+
+ for(n = 0; (text = xfbib_multiple_input_get_nth_row_ith_column(multiple_input, n, 0)) != NULL; n++) {
+ bibstr = xfbib_multiple_input_get_nth_row_ith_column(multiple_input, n, 1);
+ if(bibstr != NULL) {
+ string = xfbib_bibtex_string_new(G_OBJECT(xfbib_state_get_bibtex_elements(state)));
+ value = xfbib_bibtex_value_new(G_OBJECT(string));
+
+ xfbib_bibtex_string_set_variable(string, bibstr);
+ xfbib_bibtex_value_set_str(value, text);
+ xfbib_bibtex_string_set_value(string, value);
+
+ list = g_list_append(list, G_OBJECT(string));
+ } else {
+ str = xfbib_string_new(G_OBJECT(xfbib_state_get_bibtex_elements(state)));
+ xfbib_string_set(str, text);
+ list = g_list_append(list, G_OBJECT(str));
+ }
+ }
+ return list;
+}
+
Copied: xfbib/trunk/src/xfbib-string-tree-view.c (from rev 7054, xfbib/branches/gobject/src/xfbib-string-tree-view.c)
===================================================================
--- xfbib/trunk/src/xfbib-string-tree-view.c (rev 0)
+++ xfbib/trunk/src/xfbib-string-tree-view.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,243 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gtk/gtk.h>
+
+#include "xfbib-list-store.h"
+#include "xfbib-string-tree-view.h"
+#include "xfbib-bibtex.h"
+#include "xfbib-state.h"
+#include "xfbib-bibtex-string.h"
+#include "xfbib-entry-edit-dialog.h"
+
+/*static struct {
+ gchar *label;
+ gchar *tooltip;
+}xfbib_field_constants[] = {
+ {"Address", _("Address of publisher")},
+ {"Annote", _("Annotation for annotated bibliography styles")},
+ {"Author", _("Name(s) of the author(s), separated by 'and' if more than one")},
+ {"Booktitle", _("Title of the book, if only part of it is being cited")},
+ {"Chapter", _("Chapter number")},
+ {"Crossref", _("Citation key of the cross-referenced entry")},
+ {"Edition", _("Edition of the book (such as \"first\" or \"second\")")},
+ {"Editor", _("Name(s) of the editor(s), separated by 'and' if more than one")},
+ {"E-print", _("Specification of electronic publication")},
+ {"HowPublished", _("Publishing method if the method is nonstandard")},
+ {"Institution", _("Institution that was involved in the publishing")},
+ {"Journal", _("Journal or magazine in which the work was published")},
+ {"Key", _("Hidden field used for specifying or overriding the alphabetical order of entries")},
+ {"Month", _("Month of publication or creation if unpublished")},
+ {"Note", _("Miscellaneous extra information")},
+ {"Number", _("Number of journal, magazine, or tech-report")},
+ {"Organization", _("Sponsor of the conference")},
+ {"Pages", _("Page numbers separated by commas or double-hyphens")},
+ {"Publisher", _("Name of publisher")},
+ {"School", _("School where thesis was written")},
+ {"Series", _("Series of books in which the book was published")},
+ {"Title", _("Title of the work")},
+ {"Type", _("Type of technical report")},
+ {"URL", _("Internet address")},
+ {"Volume", _("Number of the volume")},
+ {"Year", _("Year of publication or creation if unpublished")}
+};*/
+
+struct _XfbibStringTreeView
+{
+ GtkTreeView parent;
+};
+
+typedef struct _XfbibStringTreeViewClass
+{
+ GtkTreeViewClass parent;
+} XfbibStringTreeViewClass;
+
+static void xfbib_string_tree_view_class_init(XfbibStringTreeViewClass *klass);
+
+static void xfbib_string_tree_view_init(XfbibStringTreeView *instance);
+static void xfbib_string_tree_view_finalize(GObject *obj);
+
+static GObjectClass *xfbib_string_tree_view_parent_class = NULL;
+
+static void
+cb_row_activated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
+{
+ g_print("cb_row_activated\n");
+ XfbibState *state;
+ XfbibBibtexString *string, *new_string;
+ GtkWidget *dialog;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ state = xfbib_state_new();
+ model = gtk_tree_view_get_model(tree_view);
+
+ if (gtk_tree_model_get_iter(model, &iter, path)) {
+ string = XFBIB_BIBTEX_STRING(xfbib_list_store_get(XFBIB_LIST_STORE(model), &iter));
+#if 0
+ dialog = xfbib_string_edit_dialog_new(string);
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ new_string = xfbib_string_edit_dialog_get(XFBIB_STRING_EDIT_DIALOG(dialog));
+ xfbib_list_store_replace(XFBIB_LIST_STORE(model), string, new_string);
+ }
+ gtk_widget_destroy(dialog);
+#endif
+ }
+}
+
+static gboolean
+cb_button_press (GtkWidget *tree_view, GdkEventButton *event, gpointer data)
+{
+ g_print("cb_button_press\n");
+ XfbibBibtexString *new_string;
+ GtkTreeModel *model;
+ GtkWidget *dialog;
+
+ if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
+ /* single click with the right mouse button */
+ /* TODO: Add a context menu here */
+ } else if (event->type == GDK_2BUTTON_PRESS && event->button == 1) {
+ /* double click with the left mouse button */
+
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
+
+ /* Check if any row has been selected */
+ if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection
+ (GTK_TREE_VIEW(tree_view)), NULL, NULL)) {
+ /*
+ * A row is selected Let the other cb_row_activated()
+ * function take care of the rest.
+ */
+ /* TODO: Take care of the event here instead */
+ return FALSE;
+ }
+#if 0
+
+ dialog = xfbib_string_edit_dialog_new(NULL);
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ new_entry = xfbib_string_edit_dialog_get_entry(XFBIB_STRING_EDIT_DIALOG(dialog));
+ xfbib_list_store_add(XFBIB_LIST_STORE(model), G_OBJECT(new_entry));
+ }
+ gtk_widget_destroy(dialog);
+#endif
+
+ } else {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+GType
+xfbib_string_tree_view_get_type (void)
+{
+ static GType type = 0;
+ if (type == 0) {
+ static const GTypeInfo info = {
+ sizeof (XfbibStringTreeViewClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) xfbib_string_tree_view_class_init, /* class_init */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (XfbibStringTreeView),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) xfbib_string_tree_view_init /* instance_init */
+ };
+ type = g_type_register_static (GTK_TYPE_TREE_VIEW, "XfbibStringTreeView", &info, 0);
+ }
+ return type;
+}
+
+
+static void
+xfbib_string_tree_view_class_init(XfbibStringTreeViewClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *)klass;
+
+ xfbib_string_tree_view_parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = xfbib_string_tree_view_finalize;
+}
+
+static void
+xfbib_string_tree_view_init(XfbibStringTreeView *instance)
+{
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GtkTreeModel *model;
+
+ /* Connect the double-click on a row to a callback function */
+ g_signal_connect(GTK_TREE_VIEW(instance), "row-activated", (GCallback) cb_row_activated, NULL);
+ /* Connect the double-click NOT on a row to a callback function */
+ g_signal_connect(GTK_WIDGET(instance), "button-press-event", (GCallback) cb_button_press, NULL);
+
+ /* Variable Column */
+ column = gtk_tree_view_column_new();
+ gtk_tree_view_column_set_visible(column, TRUE);
+ gtk_tree_view_column_set_clickable(column, TRUE);
+ gtk_tree_view_column_set_title(column, "Variable" );
+ /* pack tree view column into tree view */
+ gtk_tree_view_append_column(GTK_TREE_VIEW(instance), column);
+ renderer = gtk_cell_renderer_text_new();
+ /* pack cell renderer into tree view column */
+ gtk_tree_view_column_pack_start(column, renderer, TRUE);
+ /*
+ * connect 'text' property of the cell renderer to
+ * model column that contains the first name
+ */
+ gtk_tree_view_column_add_attribute(column, renderer, "text", 0);
+
+ /* Value Column */
+ column = gtk_tree_view_column_new();
+ gtk_tree_view_column_set_title(column, _("Value") );
+ /* pack tree view column into tree view */
+ gtk_tree_view_append_column(GTK_TREE_VIEW(instance), column);
+ renderer = gtk_cell_renderer_text_new();
+ /* pack cell renderer into tree view column */
+ gtk_tree_view_column_pack_start(column, renderer, TRUE);
+ /*
+ * connect 'text' property of the cell renderer to
+ * model column that contains the first name
+ */
+ gtk_tree_view_column_add_attribute(column, renderer, "text", 1);
+
+ model = GTK_TREE_MODEL(xfbib_list_store_new(TYPE_STRING));
+ gtk_tree_view_set_model(GTK_TREE_VIEW(instance), model);
+ g_object_unref(model); /* destroy model automatically with view */
+}
+
+static void
+xfbib_string_tree_view_finalize(GObject *obj)
+{
+ G_OBJECT_CLASS(xfbib_string_tree_view_parent_class)->finalize(obj);
+}
+
+GtkWidget *
+xfbib_string_tree_view_new()
+{
+ XfbibStringTreeView *tree_view;
+ tree_view = g_object_new(XFBIB_TYPE_STRING_TREE_VIEW, NULL);
+ return GTK_WIDGET(tree_view);
+}
+
Copied: xfbib/trunk/src/xfbib-string.c (from rev 7054, xfbib/branches/gobject/src/xfbib-string.c)
===================================================================
--- xfbib/trunk/src/xfbib-string.c (rev 0)
+++ xfbib/trunk/src/xfbib-string.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <string.h>
+#include <gtk/gtk.h>
+#include <stdlib.h>
+#include <libxfcegui4/libxfcegui4.h>
+
+#include "xfbib-string.h"
+
+struct _XfbibString
+{
+ GObject parent;
+ gchar separator;
+ gchar *str;
+};
+
+typedef struct _XfbibStringClass
+{
+ GObjectClass parent;
+} XfbibStringClass;
+
+static void xfbib_string_class_init(XfbibStringClass *klass);
+
+static void xfbib_string_init(XfbibString *instance);
+static void xfbib_string_finalize(GObject *obj);
+
+G_DEFINE_TYPE(XfbibString, xfbib_string, G_TYPE_OBJECT)
+
+static void
+xfbib_string_class_init(XfbibStringClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *)klass;
+ object_class->finalize = xfbib_string_finalize;
+}
+
+static void
+xfbib_string_init(XfbibString *instance)
+{
+ instance->separator = '\0';
+ instance->str = NULL;
+}
+
+static void
+xfbib_string_finalize(GObject *obj)
+{
+ G_OBJECT_CLASS(xfbib_string_parent_class)->finalize(obj);
+}
+
+XfbibString *
+xfbib_string_new()
+{
+ XfbibString *string;
+ string = g_object_new(XFBIB_TYPE_STRING, NULL);
+ return string;
+}
+
+gboolean
+xfbib_string_parse(XfbibString *string, const gchar *str)
+{
+ string->separator = str[0];
+ string->str = xfbib_string_parse_commands(g_strndup(str+1, strlen(str)-2));
+ return TRUE;
+}
+
+gchar *
+xfbib_string_get(XfbibString *string)
+{
+ return string->str;
+}
+
+void
+xfbib_string_set(XfbibString *string, const gchar *str)
+{
+ g_free(string->str);
+ g_print(_("Setting string: <%s>\n"), str);
+ string->str = g_strdup(str);
+}
+
+gchar
+xfbib_string_get_separator(XfbibString *string)
+{
+ /* TODO: fix a xfbib_string_set_separator function */
+ if(string->separator == '\0') {
+ return '{';
+ } else {
+ return string->separator;
+ }
+}
+
+gchar *
+xfbib_string_parse_commands(gchar *str)
+{
+ int len, old_len, n, i;
+ gchar *old_str;
+
+ len = old_len = strlen(str) + 1;
+ old_str = g_strdup(str);
+
+ n = i = 0;
+ while(n < len) {
+ switch(old_str[i]) {
+ case '\\':
+ switch(old_str[i+1]) {
+ case '&':
+ case '%':
+ len--;
+ str = realloc(str, len);
+ i++;
+ str[n] = old_str[i];
+ i++;
+ n++;
+ break;
+ default:
+ str[n] = old_str[i];
+ i++;
+ n++;
+ }
+ break;
+ case '\n':
+ len--;
+ str = realloc(str, len);
+ i++;
+ break;
+ case '\t':
+ str[n] = ' ';
+ i++;
+ n++;
+ break;
+ default:
+ str[n] = old_str[i];
+ i++;
+ n++;
+ }
+ }
+ free(old_str);
+ return str;
+}
Copied: xfbib/trunk/src/xfbib-string.h (from rev 6997, xfbib/branches/gobject/src/xfbib-string.h)
===================================================================
--- xfbib/trunk/src/xfbib-string.h (rev 0)
+++ xfbib/trunk/src/xfbib-string.h 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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 __XFBIB_STRING_H
+#define __XFBIB_STRING_H
+
+#include <glib-object.h>
+
+#define XFBIB_TYPE_STRING (xfbib_string_get_type())
+#define XFBIB_STRING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XFBIB_TYPE_STRING, XfbibString))
+#define XFBIB_IS_STRING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XFBIB_TYPE_STRING))
+#define XFBIB_STRING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XFBIB_TYPE_STRING, XfbibStringClass))
+#define XFBIB_IS_STRING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), XFBIB_TYPE_STRING))
+#define XFBIB_STRING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XFBIB_TYPE_STRING, XfbibStringClass))
+
+G_BEGIN_DECLS
+
+typedef struct _XfbibString XfbibString;
+
+GType xfbib_string_get_type() G_GNUC_CONST;
+
+XfbibString *xfbib_string_new();
+gboolean xfbib_string_parse(XfbibString *, const gchar *);
+gchar *xfbib_string_get(XfbibString *);
+void xfbib_string_set(XfbibString *, const gchar *);
+gchar xfbib_string_get_separator(XfbibString *);
+gchar *xfbib_string_parse_commands(gchar *);
+
+G_END_DECLS
+
+#endif //__XFBIB_STRING_H
+
Copied: xfbib/trunk/src/xfbib-toolbar.c (from rev 7054, xfbib/branches/gobject/src/xfbib-toolbar.c)
===================================================================
--- xfbib/trunk/src/xfbib-toolbar.c (rev 0)
+++ xfbib/trunk/src/xfbib-toolbar.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gtk/gtk.h>
+
+#include "xfbib-toolbar.h"
+#include "xfbib-file-io.h"
+#include "xfbib-window.h"
+#include "xfbib-state.h"
+
+struct _XfbibToolbar
+{
+ GtkToolbar parent;
+ GtkToolItem *open;
+ GtkToolItem *save;
+};
+
+static XfbibWindow *window;
+
+typedef struct _XfbibToolbarClass
+{
+ GtkToolbarClass parent;
+} XfbibToolbarClass;
+
+static void xfbib_toolbar_class_init(XfbibToolbarClass *klass);
+
+static void xfbib_toolbar_init(XfbibToolbar *instance);
+static void xfbib_toolbar_finalize(GObject *obj);
+
+static GObjectClass *xfbib_toolbar_parent_class = NULL;
+
+static void
+cb_open_clicked (GtkButton *buttonitem, gpointer user_data)
+{
+
+ XfbibState *state;
+ gchar *filename;
+ g_print(_("Toolbar_Open\n"));
+
+ state = xfbib_state_new();
+
+ if ((filename = xfbib_file_io_open(NULL)) != NULL) {
+ xfbib_state_set_filename(state, filename);
+ xfbib_window_set_title(XFBIB_WINDOW(xfbib_state_get_window(state)), filename);
+ }
+}
+
+static void
+cb_save_clicked (GtkButton *buttonitem, gpointer user_data)
+{
+ XfbibState *state;
+ g_print(_("Toolbar_Save\n"));
+ state = xfbib_state_new();
+
+ xfbib_file_io_save(xfbib_state_get_filename(state));
+}
+
+GType
+xfbib_toolbar_get_type (void)
+{
+ static GType type = 0;
+ if (type == 0) {
+ static const GTypeInfo info = {
+ sizeof (XfbibToolbarClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) xfbib_toolbar_class_init, /* class_init */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (XfbibToolbar),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) xfbib_toolbar_init /* instance_init */
+ };
+ type = g_type_register_static (GTK_TYPE_TOOLBAR, "XfbibToolbar", &info, 0);
+ }
+ return type;
+}
+
+
+static void
+xfbib_toolbar_class_init(XfbibToolbarClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *)klass;
+
+ xfbib_toolbar_parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = xfbib_toolbar_finalize;
+}
+
+static void
+xfbib_toolbar_init(XfbibToolbar *instance)
+{
+ gtk_toolbar_set_orientation (GTK_TOOLBAR (instance), GTK_ORIENTATION_HORIZONTAL);
+
+ instance->open = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
+ gtk_toolbar_insert (GTK_TOOLBAR (instance), instance->open, -1);
+ g_signal_connect (G_OBJECT (instance->open), "clicked", G_CALLBACK (cb_open_clicked), NULL);
+
+ instance->save = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE);
+ gtk_toolbar_insert (GTK_TOOLBAR (instance), instance->save, -1);
+ g_signal_connect (G_OBJECT (instance->save), "clicked", G_CALLBACK (cb_save_clicked), NULL);
+}
+
+static void
+xfbib_toolbar_finalize(GObject *obj)
+{
+ G_OBJECT_CLASS(xfbib_toolbar_parent_class)->finalize(obj);
+}
+
+GtkWidget *
+xfbib_toolbar_new(XfbibWindow *w)
+{
+ XfbibToolbar *toolbar;
+ toolbar = g_object_new(XFBIB_TYPE_TOOLBAR, NULL);
+ window = w;
+ return GTK_WIDGET(toolbar);
+}
+
Copied: xfbib/trunk/src/xfbib-window.c (from rev 7054, xfbib/branches/gobject/src/xfbib-window.c)
===================================================================
--- xfbib/trunk/src/xfbib-window.c (rev 0)
+++ xfbib/trunk/src/xfbib-window.c 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
+ * All rights reserved.
+ *
+ * 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gtk/gtk.h>
+
+#include "xfbib-window.h"
+#include "xfbib-menu-bar.h"
+#include "xfbib-toolbar.h"
+#include "xfbib-entry-tree-view.h"
+#include "xfbib-string-tree-view.h"
+#include "xfbib-statusbar.h"
+#include "xfbib-file-io.h"
+
+struct _XfbibWindow
+{
+ GtkWindow parent;
+ GtkWidget *vbox;
+ GtkWidget *menu_bar;
+ GtkWidget *toolbar;
+ GtkWidget *notebook;
+ GtkWidget *entry_scrolled_window;
+ GtkWidget *entry_tree_view;
+ GtkWidget *string_scrolled_window;
+ GtkWidget *string_tree_view;
+ GtkWidget *status_bar;
+};
+
+typedef struct _XfbibWindowClass
+{
+ GtkWindowClass parent;
+} XfbibWindowClass;
+
+static void xfbib_window_class_init(XfbibWindowClass *klass);
+
+static void xfbib_window_init(XfbibWindow *instance);
+static void xfbib_window_finalize(GObject *obj);
+
+static GObjectClass *xfbib_window_parent_class = NULL;
+
+GType
+xfbib_window_get_type (void)
+{
+ static GType type = 0;
+ if (type == 0) {
+ static const GTypeInfo info = {
+ sizeof (XfbibWindowClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) xfbib_window_class_init, /* class_init */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (XfbibWindow),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) xfbib_window_init /* instance_init */
+ };
+ type = g_type_register_static (GTK_TYPE_WINDOW, "XfbibWindow", &info, 0);
+ }
+ return type;
+}
+
+
+static void
+xfbib_window_class_init(XfbibWindowClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *)klass;
+
+ xfbib_window_parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = xfbib_window_finalize;
+}
+
+static void
+xfbib_window_init(XfbibWindow *instance)
+{
+ instance->vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(instance), instance->vbox);
+
+ instance->menu_bar = xfbib_menu_bar_new(instance);
+ gtk_box_pack_start(GTK_BOX(instance->vbox), instance->menu_bar, FALSE, FALSE, 0);
+
+ instance->toolbar = xfbib_toolbar_new(instance);
+ gtk_box_pack_start(GTK_BOX(instance->vbox), instance->toolbar, FALSE, FALSE, 0);
+
+
+ instance->notebook = gtk_notebook_new ();
+ gtk_container_set_border_width(GTK_CONTAINER (instance->notebook), 0);
+ gtk_notebook_set_tab_pos (GTK_NOTEBOOK (instance->notebook), GTK_POS_TOP);
+ gtk_box_pack_start(GTK_BOX(instance->vbox), instance->notebook, TRUE , TRUE, 0);
+
+
+ instance->entry_scrolled_window = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (instance->entry_scrolled_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_notebook_append_page (GTK_NOTEBOOK (instance->notebook), instance->entry_scrolled_window, gtk_label_new(_("Entry")));
+
+ instance->entry_tree_view = xfbib_entry_tree_view_new();
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(instance->entry_scrolled_window), instance->entry_tree_view);
+
+ instance->string_scrolled_window = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (instance->string_scrolled_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_notebook_append_page (GTK_NOTEBOOK (instance->notebook), instance->string_scrolled_window, gtk_label_new(_("Variable")));
+
+ instance->string_tree_view = xfbib_string_tree_view_new();
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(instance->string_scrolled_window), instance->string_tree_view);
+
+
+ instance->status_bar = xfbib_statusbar_new();
+ gtk_box_pack_end(GTK_BOX(instance->vbox), instance->status_bar, FALSE, FALSE, 0);
+
+ gtk_window_set_icon_name(GTK_WINDOW(instance), "xfbib");
+}
+
+static void
+xfbib_window_finalize(GObject *obj)
+{
+ G_OBJECT_CLASS(xfbib_window_parent_class)->finalize(obj);
+}
+
+GtkWidget *
+xfbib_window_new()
+{
+ XfbibWindow *window;
+ window = g_object_new(XFBIB_TYPE_WINDOW, NULL);
+ return GTK_WIDGET(window);
+}
+
+void
+xfbib_window_set_title(XfbibWindow *window, gchar *name)
+{
+ char *str;
+ g_return_if_fail(XFBIB_IS_WINDOW(window));
+ str = g_strdup_printf("%s - %s", (name == NULL) ? _("(Untitled)") : name, PACKAGE_NAME);
+ gtk_window_set_title(GTK_WINDOW(window), str);
+ g_free(str);
+}
+
+GtkWidget *
+xfbib_window_get_tree_view(XfbibWindow *window, enum XFBIB_BIBTEX_TYPE type)
+{
+ g_return_val_if_fail(XFBIB_IS_WINDOW(window), NULL);
+ if (type == TYPE_ENTRY)
+ return window->entry_tree_view;
+ else if (type == TYPE_STRING)
+ return window->string_tree_view;
+ return NULL;
+}
Copied: xfbib/trunk/xfbib.desktop.in (from rev 6996, xfbib/branches/gobject/xfbib.desktop.in)
===================================================================
--- xfbib/trunk/xfbib.desktop.in (rev 0)
+++ xfbib/trunk/xfbib.desktop.in 2009-03-30 20:18:56 UTC (rev 7058)
@@ -0,0 +1,12 @@
+[Desktop Entry]
+Version=1.0
+Type=Application
+_Name=Xfbib
+_Comment=A BibTeX editor for xfce
+_GenericName=BibTeX Editor
+Exec=xfbib %f
+Icon=xfbib
+Terminal=false
+MimeType=text/x-bibtex;
+Categories=X-XFCE;Office;GTK;
+StartupNotify=false
More information about the Goodies-commits
mailing list