diff options
| author | Jesse van den Kieboom <jesse@icecrew.nl> | 2008-06-23 22:04:20 (GMT) |
|---|---|---|
| committer | Jesse van den Kieboom <jesse@icecrew.nl> | 2008-06-23 22:04:20 (GMT) |
| commit | 11fc353c7beabe456723fe46ce0683c36b3bc070 (patch) | |
| tree | 2f037af7aad926bc267b4663f8c7e79d9c2689e2 | |
| download | gitg-11fc353c7beabe456723fe46ce0683c36b3bc070.zip gitg-11fc353c7beabe456723fe46ce0683c36b3bc070.tar.xz | |
Initial import
| -rw-r--r-- | AUTHORS | 0 | ||||
| -rw-r--r-- | COPYING | 674 | ||||
| -rw-r--r-- | ChangeLog | 0 | ||||
| -rw-r--r-- | INSTALL | 237 | ||||
| -rw-r--r-- | Makefile.am | 14 | ||||
| -rw-r--r-- | NEWS | 0 | ||||
| -rw-r--r-- | README | 0 | ||||
| -rwxr-xr-x | autogen.sh | 22 | ||||
| -rw-r--r-- | configure.ac | 71 | ||||
| -rw-r--r-- | data/Makefile.am | 14 | ||||
| -rw-r--r-- | data/gitg.1 | 14 | ||||
| -rw-r--r-- | data/gitg.desktop.in.in | 12 | ||||
| -rw-r--r-- | gitg/Makefile.am | 33 | ||||
| -rw-r--r-- | gitg/gitg-loader.c | 148 | ||||
| -rw-r--r-- | gitg/gitg-loader.h | 46 | ||||
| -rw-r--r-- | gitg/gitg-revision.c | 134 | ||||
| -rw-r--r-- | gitg/gitg-revision.h | 45 | ||||
| -rw-r--r-- | gitg/gitg-runner.c | 291 | ||||
| -rw-r--r-- | gitg/gitg-runner.h | 42 | ||||
| -rw-r--r-- | gitg/gitg-rv-model.c | 200 | ||||
| -rw-r--r-- | gitg/gitg-rv-model.h | 39 | ||||
| -rw-r--r-- | gitg/gitg-ui.xml | 287 | ||||
| -rw-r--r-- | gitg/gitg-utils.c | 54 | ||||
| -rw-r--r-- | gitg/gitg-utils.h | 12 | ||||
| -rw-r--r-- | gitg/gitg.c | 490 | ||||
| -rw-r--r-- | po/ChangeLog | 0 | ||||
| -rw-r--r-- | po/LINGUAS | 5 | ||||
| -rw-r--r-- | po/Makefile.in.in | 218 | ||||
| -rw-r--r-- | po/POTFILES.in | 3 | ||||
| -rw-r--r-- | po/nl.po | 3 |
30 files changed, 3108 insertions, 0 deletions
@@ -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>. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,237 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007 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. + +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. + +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 the options to `configure', and exit. + +`--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. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..a3dfe54 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,14 @@ +## Process this file with automake to produce Makefile.in + +SUBDIRS = gitg data po + +DISTCLEANFILES = \ + intltool-extract \ + intltool-merge \ + intltool-update + +EXTRA_DIST = \ + autogen.sh \ + intltool-extract.in \ + intltool-merge.in \ + intltool-update.in diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..b904324 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# Run this to generate all the initial makefiles, etc. + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +PKG_NAME="gitg" + +(test -f $srcdir/configure.ac \ + && test -f $srcdir/README \ + && test -d $srcdir/$PKG_NAME) || { + echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" + echo " top-level $PKG_NAME directory" + exit 1 +} + +which gnome-autogen.sh || { + echo "You need to install gnome-common from the GNOME CVS" + exit 1 +} + +ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I m4" REQUIRED_AUTOMAKE_VERSION=1.8 USE_GNOME2_MACROS=1 USE_COMMON_DOC_BUILD=yes . gnome-autogen.sh diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..313d590 --- /dev/null +++ b/configure.ac @@ -0,0 +1,71 @@ +dnl Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.59) + +m4_define(gitg_major_version, 0) +m4_define(gitg_minor_version, 0) +m4_define(gitg_micro_version, 1) +m4_define(gitg_version, gitg_major_version.gitg_minor_version.gitg_micro_version) + +AC_INIT(gitg, gitg_version, http://www.icecrew.nl) +AC_CONFIG_SRCDIR(gitg/gitg.c) +AC_CONFIG_MACRO_DIR([m4]) + +AC_DEFINE(GITG_MAJOR_VERSION, gitg_major_version, [GitG major version]) +AC_SUBST(GITG_MAJOR_VERSION, gitg_major_version) +AC_DEFINE(GITG_MINOR_VERSION, gitg_minor_version, [GitG minor version]) +AC_SUBST(GITG_MINOR_VERSION, gitg_minor_version) +AC_DEFINE(GITG_MICRO_VERSION, gitg_micro_version, [GitG micro version]) +AC_SUBST(GITG_MICRO_VERSION, gitg_micro_version) + +AM_INIT_AUTOMAKE([1.8 dist-bzip2 no-dist-gzip]) + +AM_MAINTAINER_MODE +AC_CONFIG_HEADERS(config.h) + +IT_PROG_INTLTOOL([0.35.0]) +AC_PROG_LIBTOOL + +AC_ISC_POSIX +AC_PROG_CC +AC_PROG_INSTALL +AC_PROG_MAKE_SET +AC_PATH_PROG(GZIP, gzip) + +dnl make sure we keep ACLOCAL_FLAGS around for maintainer builds to work +AC_SUBST(ACLOCAL_AMFLAGS, "$ACLOCAL_FLAGS -I m4") + +GETTEXT_PACKAGE=gitg +AC_SUBST(GETTEXT_PACKAGE) +AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package]) + +AM_GLIB_GNU_GETTEXT + +PKG_CHECK_MODULES(PACKAGE, [ + gtk+-2.0 >= 2.8.0 + gthread-2.0 + gtksourceview-2.0 +]) + +AC_SUBST(PACKAGE_CFLAGS) +AC_SUBST(PACKAGE_LIBS) + +AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal) + +AC_CONFIG_FILES([ +Makefile +gitg/Makefile +data/Makefile +data/gitg.desktop.in +po/Makefile.in +]) + +AC_OUTPUT + +echo " + +Configuration: + + Source code location: ${srcdir} + Compiler: ${CC} +" diff --git a/data/Makefile.am b/data/Makefile.am new file mode 100644 index 0000000..a0309cc --- /dev/null +++ b/data/Makefile.am @@ -0,0 +1,14 @@ +desktopdir = $(datadir)/applications +desktop_in_files = gitg.desktop.in +desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) +@INTLTOOL_DESKTOP_RULE@ + +man_MANS = gitg.1 + +EXTRA_DIST = \ + $(desktop_in_files) \ + $(man_MANS) + +CLEANFILES = \ + $(desktop_DATA) + diff --git a/data/gitg.1 b/data/gitg.1 new file mode 100644 index 0000000..9c2139d --- /dev/null +++ b/data/gitg.1 @@ -0,0 +1,14 @@ +.TH GITG 1 "22 Jun 2008" +.SH NAME +\gitg\fP \- Git repository viewer + +.SH SYNOPSIS +.B gitg +.RI [path] +.SH DESCRIPTION +.B gitg +is a git repository viewer for GNOME + +.SH AUTHORS +Jesse van den Kieboom (jesse@icecrew.nl) + diff --git a/data/gitg.desktop.in.in b/data/gitg.desktop.in.in new file mode 100644 index 0000000..dde09b7 --- /dev/null +++ b/data/gitg.desktop.in.in @@ -0,0 +1,12 @@ +[Desktop Entry] +Encoding=UTF-8 +_Name=GitG +_Comment=Browser git repositories +Exec=gitg %U +Terminal=false +Type=Application +StartupNotify=true +MimeType=text/plain; +#Icon= +Categories=GNOME;GTK;Utility; +#X-GNOME-DocPath=gitg/gitg.xml diff --git a/gitg/Makefile.am b/gitg/Makefile.am new file mode 100644 index 0000000..9b91571 --- /dev/null +++ b/gitg/Makefile.am @@ -0,0 +1,33 @@ +bin_PROGRAMS = gitg + +INCLUDES = \ + -I$(top_srcdir) \ + -I$(srcdir) \ + $(PACKAGE_CFLAGS) \ + $(WARN_CFLAGS) \ + $(DISABLE_DEPRECATED_CFLAGS) \ + -DDATADIR=\""$(datadir)"\" \ + -DGITG_DATADIR=\""$(datadir)/gitg"\" \ + -DGITG_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ + -DGITG_UI_DIR=\""$(datadir)/gitg/ui/"\" \ + -DGITG_ICONDIR=\""$(datadir)/gitg/icons"\" + +gitg_SOURCES = \ + gitg.c \ + gitg-revision.c \ + gitg-rv-model.c \ + gitg-loader.c \ + gitg-runner.c \ + gitg-utils.c + +gitg_LDADD = $(PACKAGE_LIBS) +gitg_LDFLAGS = + +uidir = $(datadir)/gitg/ui/ +ui_DATA = gitg-ui.xml + +update-ui: + gtk-builder-convert gitg.glade gitg-ui.xml + +EXTRA_DIST = \ + $(ui_DATA) diff --git a/gitg/gitg-loader.c b/gitg/gitg-loader.c new file mode 100644 index 0000000..b2e0034 --- /dev/null +++ b/gitg/gitg-loader.c @@ -0,0 +1,148 @@ +#include "gitg-loader.h" + +#define GITG_LOADER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_LOADER, GitgLoaderPrivate)) + +static void impl_update(GitgRunner *runner, gchar **buffer); + +/* Signals */ +enum +{ + REVISIONS_ADDED, + LAST_SIGNAL +}; + +static guint loader_signals[LAST_SIGNAL] = { 0 }; + +struct _GitgLoaderPrivate +{ + GitgRevision **buffer; + GitgRvModel *store; +}; + +G_DEFINE_TYPE(GitgLoader, gitg_loader, GITG_TYPE_RUNNER) + +static void +gitg_loader_finalize(GObject *object) +{ + GitgLoader *loader = GITG_LOADER(object); + guint size = gitg_runner_get_buffer_size(GITG_RUNNER(loader)); + + g_slice_free1(sizeof(GitgRevision *) * (size + 1), loader->priv->buffer); + G_OBJECT_CLASS(gitg_loader_parent_class)->finalize(object); +} + +static GObject * +gitg_loader_constructor(GType type, guint n_construct_properties, + GObjectConstructParam *construct_properties) +{ + GObject *object; + + { + object = G_OBJECT_CLASS(gitg_loader_parent_class)->constructor(type, n_construct_properties, construct_properties); + } + + GitgLoader *loader = GITG_LOADER(object); + + guint bs = gitg_runner_get_buffer_size(GITG_RUNNER(loader)); + loader->priv->buffer = g_slice_alloc(sizeof(GitgRevision *) * (bs + 1)); + loader->priv->buffer[0] = NULL; + + return object; +} + +static void +gitg_loader_class_init(GitgLoaderClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + GitgRunnerClass *runner_class = GITG_RUNNER_CLASS(klass); + + object_class->finalize = gitg_loader_finalize; + object_class->constructor = gitg_loader_constructor; + + runner_class->update = impl_update; + + loader_signals[REVISIONS_ADDED] = + g_signal_new ("revisions-added", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GitgLoaderClass, revisions_added), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, + 1, + G_TYPE_POINTER); + + g_type_class_add_private(object_class, sizeof(GitgLoaderPrivate)); +} + +static void +gitg_loader_init(GitgLoader *self) +{ + self->priv = GITG_LOADER_GET_PRIVATE(self); +} + +static void +impl_update(GitgRunner *runner, gchar **buffer) +{ + GitgLoader *loader = GITG_LOADER(runner); + gchar *line; + GitgRevision **ptr = loader->priv->buffer; + + while ((line = *buffer++)) + { + // New line is read + gchar **components = g_strsplit(line, "\01", 0); + + if (g_strv_length(components) < 5) + { + g_strfreev(components); + continue; + } + + // components -> [hash, author, subject, parents ([1 2 3]), timestamp] + gint64 timestamp = g_ascii_strtoll(components[4], NULL, 0); + + *ptr++ = gitg_revision_new(components[0], components[1], components[2], components[3], timestamp); + + g_strfreev(components); + } + + *ptr = NULL; + g_signal_emit(loader, loader_signals[REVISIONS_ADDED], 0, loader->priv->buffer); + + /* Make sure to unref all the revision objects */ + GitgRevision *rv; + ptr = loader->priv->buffer; + + while ((rv = *ptr++)) + g_object_unref(rv); + + loader->priv->buffer[0] = NULL; +} + +GitgLoader* +gitg_loader_new() +{ + return GITG_LOADER(g_object_new(GITG_TYPE_LOADER, "buffer_size", 3000, NULL)); +} + +gboolean +gitg_loader_load(GitgLoader *loader, gchar const *path, GError **error) +{ + g_return_val_if_fail(GITG_IS_LOADER(loader), FALSE); + g_return_val_if_fail(loader->priv != NULL, FALSE); + g_return_val_if_fail(path != NULL, FALSE); + + gchar *argv[] = { + "git", + "--git-dir", + path, + "log", + "--topo-order", + "--pretty=format:%H\01%an\01%s\01%P\01%at", + "HEAD", + NULL + }; + + return gitg_runner_run(GITG_RUNNER(loader), argv, error); +} diff --git a/gitg/gitg-loader.h b/gitg/gitg-loader.h new file mode 100644 index 0000000..c2ee31f --- /dev/null +++ b/gitg/gitg-loader.h @@ -0,0 +1,46 @@ +#include "gitg-rv-model.h" + +#ifndef __GITG_LOADER_H__ +#define __GITG_LOADER_H__ + +#include <glib-object.h> +#include "gitg-revision.h" +#include "gitg-runner.h" + +G_BEGIN_DECLS + +#define GITG_TYPE_LOADER (gitg_loader_get_type ()) +#define GITG_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_LOADER, GitgLoader)) +#define GITG_LOADER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_LOADER, GitgLoader const)) +#define GITG_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_LOADER, GitgLoaderClass)) +#define GITG_IS_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_LOADER)) +#define GITG_IS_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_LOADER)) +#define GITG_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_LOADER, GitgLoaderClass)) + +typedef struct _GitgLoader GitgLoader; +typedef struct _GitgLoaderClass GitgLoaderClass; +typedef struct _GitgLoaderPrivate GitgLoaderPrivate; + +struct _GitgLoader { + GitgRunner parent; + + GitgLoaderPrivate *priv; +}; + +struct _GitgLoaderClass { + GitgRunnerClass parent_class; + + void (* revisions_added) (GitgLoader *loader, GitgRevision **revisions); +}; + +GType gitg_loader_get_type (void) G_GNUC_CONST; +GitgLoader *gitg_loader_new(); + +void gitg_loader_set_store(GitgLoader *loader, GitgRvModel *store); +GitgRvModel *gitg_loader_get_store(GitgLoader *loader); + +gboolean gitg_loader_load(GitgLoader *loader, gchar const *path, GError **error); + +G_END_DECLS + +#endif /* __GITG_LOADER_H__ */ diff --git a/gitg/gitg-revision.c b/gitg/gitg-revision.c new file mode 100644 index 0000000..61810b0 --- /dev/null +++ b/gitg/gitg-revision.c @@ -0,0 +1,134 @@ +#include "gitg-revision.h" +#include "gitg-utils.h" + +#define GITG_REVISION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_REVISION, GitgRevisionPrivate)) + +typedef gchar Hash[20]; + +struct _GitgRevisionPrivate +{ + Hash hash; + gchar *author; + gchar *subject; + Hash *parents; + guint num_parents; + + gint64 timestamp; +}; + +G_DEFINE_TYPE(GitgRevision, gitg_revision, G_TYPE_OBJECT) + +static void +gitg_revision_finalize(GObject *object) +{ + GitgRevision *rv = GITG_REVISION(object); + + g_free(rv->priv->author); + g_free(rv->priv->subject); + g_free(rv->priv->parents); + + G_OBJECT_CLASS(gitg_revision_parent_class)->finalize(object); +} + +static void +gitg_revision_class_init(GitgRevisionClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + object_class->finalize = gitg_revision_finalize; + + g_type_class_add_private(object_class, sizeof(GitgRevisionPrivate)); +} + +static void +gitg_revision_init(GitgRevision *self) +{ + self->priv = GITG_REVISION_GET_PRIVATE(self); +} + +GitgRevision *gitg_revision_new(gchar const *sha, + gchar const *author, + gchar const *subject, + gchar const *parents, + gint64 timestamp) +{ + GitgRevision *rv = g_object_new(GITG_TYPE_REVISION, NULL); + + gitg_utils_sha1_to_hash(sha, rv->priv->hash); + rv->priv->author = g_strdup(author); + rv->priv->subject = g_strdup(subject); + rv->priv->timestamp = timestamp; + + gchar **shas = g_strsplit(parents, " ", 0); + gint num = g_strv_length(shas); + rv->priv->parents = g_new(Hash, num + 1); + + int i; + for (i = 0; i < num; ++i) + gitg_utils_sha1_to_hash(shas[i], rv->priv->parents[i]); + + g_strfreev(shas); + rv->priv->num_parents = num; + + return rv; +} + +gchar const * +gitg_revision_get_author(GitgRevision *revision) +{ + g_return_val_if_fail(GITG_IS_REVISION(revision), NULL); + return revision->priv->author; +} + +gchar const * +gitg_revision_get_subject(GitgRevision *revision) +{ + g_return_val_if_fail(GITG_IS_REVISION(revision), NULL); + return revision->priv->subject; +} + +guint64 +gitg_revision_get_timestamp(GitgRevision *revision) +{ + g_return_val_if_fail(GITG_IS_REVISION(revision), 0); + return revision->priv->timestamp; +} + +gchar const * +gitg_revision_get_hash(GitgRevision *revision) +{ + g_return_val_if_fail(GITG_IS_REVISION(revision), NULL); + return revision->priv->hash; +} + +gchar * +gitg_revision_get_sha1(GitgRevision *revision) +{ + g_return_val_if_fail(GITG_IS_REVISION(revision), NULL); + + char res[40]; + gitg_utils_hash_to_sha1(revision->priv->hash, res); + + return g_strndup(res, 40); +} + +gchar ** +gitg_revision_get_parents(GitgRevision *revision) +{ + g_return_val_if_fail(GITG_IS_REVISION(revision), NULL); + + gchar **ret = g_new(gchar *, revision->priv->num_parents + 1); + + int i; + for (i = 0; i < revision->priv->num_parents; ++i) + { + ret[i] = g_new(gchar, 41); + gitg_utils_hash_to_sha1(revision->priv->parents[i], ret[i]); + + ret[i][40] = '\0'; + } + + ret[revision->priv->num_parents] = NULL; + + return ret; +} diff --git a/gitg/gitg-revision.h b/gitg/gitg-revision.h new file mode 100644 index 0000000..78014ef --- /dev/null +++ b/gitg/gitg-revision.h @@ -0,0 +1,45 @@ +#ifndef __GITG_REVISION_H__ +#define __GITG_REVISION_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +#define GITG_TYPE_REVISION (gitg_revision_get_type ()) +#define GITG_REVISION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_REVISION, GitgRevision)) +#define GITG_REVISION_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_REVISION, GitgRevision const)) +#define GITG_REVISION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_REVISION, GitgRevisionClass)) +#define GITG_IS_REVISION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_REVISION)) +#define GITG_IS_REVISION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_REVISION)) +#define GITG_REVISION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_REVISION, GitgRevisionClass)) + +typedef struct _GitgRevision GitgRevision; +typedef struct _GitgRevisionClass GitgRevisionClass; +typedef struct _GitgRevisionPrivate GitgRevisionPrivate; + +struct _GitgRevision { + GObject parent; + + GitgRevisionPrivate *priv; +}; + +struct _GitgRevisionClass { + GObjectClass parent_class; +}; + +GType gitg_revision_get_type (void) G_GNUC_CONST; + +GitgRevision *gitg_revision_new(gchar const *hash, + gchar const *author, gchar const *subject, gchar const *parents, gint64 timestamp); + +inline gchar const *gitg_revision_get_author(GitgRevision *revision); +inline gchar const *gitg_revision_get_subject(GitgRevision *revision); +inline guint64 gitg_revision_get_timestamp(GitgRevision *revision); +inline gchar const *gitg_revision_get_hash(GitgRevision *revision); + +gchar *gitg_revision_get_sha1(GitgRevision *revision); +gchar **gitg_revision_get_parents(GitgRevision *revision); + +G_END_DECLS + +#endif /* __GITG_REVISION_H__ */ diff --git a/gitg/gitg-runner.c b/gitg/gitg-runner.c new file mode 100644 index 0000000..9f2ca75 --- /dev/null +++ b/gitg/gitg-runner.c @@ -0,0 +1,291 @@ +#include "gitg-runner.h" + + +#define GITG_RUNNER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_RUNNER, GitgRunnerPrivate)) + +/* Signals */ +enum +{ + BEGIN_LOADING, + UPDATE, + END_LOADING, + LAST_SIGNAL +}; + +static guint runner_signals[LAST_SIGNAL] = { 0 }; + +/* Properties */ +enum { + PROP_0, + + PROP_BUFFER_SIZE +}; + +struct _GitgRunnerPrivate +{ + GPid pid; + GThread *thread; + GCond *cond; + GMutex *cond_mutex; + GMutex *mutex; + gint output_fd; + + guint buffer_size; + gchar **buffer; + gboolean done; +}; + +G_DEFINE_TYPE(GitgRunner, gitg_runner, G_TYPE_OBJECT) + +static void +runner_io_exit(GPid pid, int status, gpointer userdata) +{ + g_spawn_close_pid(pid); +} + +static void +gitg_runner_finalize(GObject *object) +{ + GitgRunner *runner = GITG_RUNNER(object); + + if (runner->priv->pid) + runner_io_exit(runner->priv->pid, 0, runner); + + // Cancel possible running thread + gitg_runner_cancel(runner); + + // Free mutex and condition + g_mutex_free(runner->priv->mutex); + g_cond_free(runner->priv->cond); + g_mutex_free(runner->priv->cond_mutex); + + // Remove buffer slice + g_slice_free1(sizeof(gchar *) * (runner->priv->buffer_size + 1), runner->priv->buffer); + + G_OBJECT_CLASS(gitg_runner_parent_class)->finalize(object); +} + +static void +gitg_runner_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + GitgRunner *runner = GITG_RUNNER(object); + + switch (prop_id) + { + case PROP_BUFFER_SIZE: + g_value_set_uint (value, runner->priv->buffer_size); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +set_buffer_size(GitgRunner *runner, guint buffer_size) +{ + runner->priv->buffer_size = buffer_size; + runner->priv->buffer = g_slice_alloc(sizeof(gchar *) * (runner->priv->buffer_size + 1)); + runner->priv->buffer[0] = NULL; +} + +static void +gitg_runner_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +{ + GitgRunner *runner = GITG_RUNNER(object); + + switch (prop_id) + { + case PROP_BUFFER_SIZE: + set_buffer_size(runner, g_value_get_uint(value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gitg_runner_class_init(GitgRunnerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + object_class->finalize = gitg_runner_finalize; + + object_class->get_property = gitg_runner_get_property; + object_class->set_property = gitg_runner_set_property; + + g_object_class_install_property (object_class, PROP_BUFFER_SIZE, + g_param_spec_uint ("buffer_size", + "BUFFER SIZE", + "The runners buffer size", + 1, + G_MAXUINT, + 1, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + runner_signals[BEGIN_LOADING] = + g_signal_new ("begin-loading", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GitgRunnerClass, begin_loading), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + + runner_signals[UPDATE] = + g_signal_new ("update", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GitgRunnerClass, update), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, + 1, + G_TYPE_POINTER); + + runner_signals[END_LOADING] = + g_signal_new ("end-loading", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GitgRunnerClass, end_loading), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + + g_type_class_add_private(object_class, sizeof(GitgRunnerPrivate)); +} + +static void +gitg_runner_init(GitgRunner *self) +{ + self->priv = GITG_RUNNER_GET_PRIVATE(self); + + self->priv->cond = g_cond_new(); + self->priv->mutex = g_mutex_new(); + self->priv->cond_mutex = g_mutex_new(); + + self->priv->done = TRUE; +} + +static gboolean +emit_update_sync(GitgRunner *runner) +{ + // Emit signal + g_signal_emit(runner, runner_signals[UPDATE], 0, runner->priv->buffer); + + if (runner->priv->done) + g_signal_emit(runner, runner_signals[END_LOADING], 0); + + g_cond_signal(runner->priv->cond); + return FALSE; +} + +static void +sync_buffer(GitgRunner *runner, guint num) +{ + // NULL terminate the buffer and add idle callback + runner->priv->buffer[num] = NULL; + + g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, (GSourceFunc)emit_update_sync, runner, NULL); + g_cond_wait(runner->priv->cond, runner->priv->cond_mutex); + g_mutex_unlock(runner->priv->cond_mutex); +} + +static gpointer +output_reader_thread(gpointer userdata) +{ + GitgRunner *runner = GITG_RUNNER(userdata); + GIOChannel *channel = g_io_channel_unix_new(runner->priv->output_fd); + g_io_channel_set_encoding(channel, NULL, NULL); + + guint num = 0; + gchar *line; + gsize len; + GError *error = NULL; + gboolean cancel = FALSE; + + while (g_io_channel_read_line(channel, &line, &len, NULL, &error) == G_IO_STATUS_NORMAL) + { + runner->priv->buffer[num++] = line; + + g_mutex_lock(runner->priv->mutex); + gboolean cancel = runner->priv->done; + g_mutex_unlock(runner->priv->mutex); + + if (cancel) + break; + + if (num == runner->priv->buffer_size) + { + sync_buffer(runner, num); + + num = 0; + } + } + + runner->priv->done = TRUE; + + if (!cancel) + sync_buffer(runner, num); + + g_io_channel_shutdown(channel, TRUE, NULL); + g_io_channel_unref(channel); + + return NULL; +} + + +GitgRunner* +gitg_runner_new(guint buffer_size) +{ + g_assert(buffer_size > 0); + + return GITG_RUNNER(g_object_new(GITG_TYPE_RUNNER, "buffer_size", buffer_size, NULL)); +} + +gboolean +gitg_runner_run(GitgRunner *runner, gchar **argv, GError **error) +{ + g_return_if_fail(GITG_IS_RUNNER(runner)); + + gint stdout; + gboolean ret = g_spawn_async_with_pipes(NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &(runner->priv->pid), NULL, &stdout, NULL, error); + + if (!ret) + { + runner->priv->pid = 0; + return FALSE; + } + + runner->priv->done = FALSE; + runner->priv->output_fd = stdout; + + runner->priv->thread = g_thread_create(output_reader_thread, runner, TRUE, NULL); + g_child_watch_add(runner->priv->pid, runner_io_exit, runner); + + // Emit begin-loading signal + g_signal_emit(runner, runner_signals[BEGIN_LOADING], 0); +} + +guint +gitg_runner_get_buffer_size(GitgRunner *runner) +{ + g_return_if_fail(GITG_IS_RUNNER(runner)); + return runner->priv->buffer_size; +} + +void +gitg_runner_cancel(GitgRunner *runner) +{ + g_mutex_lock(runner->priv->mutex); + gboolean done = runner->priv->done; + runner->priv->done = TRUE; + g_mutex_unlock(runner->priv->mutex); + + runner->priv->thread = NULL; + runner->priv->pid = 0; +} diff --git a/gitg/gitg-runner.h b/gitg/gitg-runner.h new file mode 100644 index 0000000..dd87836 --- /dev/null +++ b/gitg/gitg-runner.h @@ -0,0 +1,42 @@ +#ifndef __GITG_RUNNER_H__ +#define __GITG_RUNNER_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +#define GITG_TYPE_RUNNER (gitg_runner_get_type ()) +#define GITG_RUNNER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_RUNNER, GitgRunner)) +#define GITG_RUNNER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_RUNNER, GitgRunner const)) +#define GITG_RUNNER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_RUNNER, GitgRunnerClass)) +#define GITG_IS_RUNNER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_RUNNER)) +#define GITG_IS_RUNNER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_RUNNER)) +#define GITG_RUNNER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_RUNNER, GitgRunnerClass)) + +typedef struct _GitgRunner GitgRunner; +typedef struct _GitgRunnerClass GitgRunnerClass; +typedef struct _GitgRunnerPrivate GitgRunnerPrivate; + +struct _GitgRunner { + GObject parent; + + GitgRunnerPrivate *priv; +}; + +struct _GitgRunnerClass { + GObjectClass parent_class; + + void (* begin_loading) (GitgRunner *runner); + void (* update) (GitgRunner *runner, gchar **buffer); + void (* end_loading) (GitgRunner *runner); +}; + +GType gitg_runner_get_type (void) G_GNUC_CONST; +GitgRunner *gitg_runner_new(guint buffer_size); +guint gitg_runner_get_buffer_size(GitgRunner *runner); +gboolean gitg_runner_run(GitgRunner *runner, gchar **argv, GError **error); +void gitg_runner_cancel(GitgRunner *runner); + +G_END_DECLS + +#endif /* __GITG_RUNNER_H__ */ diff --git a/gitg/gitg-rv-model.c b/gitg/gitg-rv-model.c new file mode 100644 index 0000000..0d2ebe4 --- /dev/null +++ b/gitg/gitg-rv-model.c @@ -0,0 +1,200 @@ +#include "gitg-rv-model.h" +#include <time.h> + +#define GITG_RV_MODEL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GITG_TYPE_RV_MODEL, GitgRvModelPrivate)) + +static void gitg_rv_model_tree_model_iface_init(GtkTreeModelIface *iface); + +G_DEFINE_TYPE_EXTENDED (GitgRvModel, gitg_rv_model, GTK_TYPE_LIST_STORE, 0, + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, gitg_rv_model_tree_model_iface_init)); + +enum +{ + OBJECT_COLUMN, + SUBJECT_COLUMN, + AUTHOR_COLUMN, + DATE_COLUMN, + N_COLUMNS +}; + +static GtkTreeModelIface parent_iface = { 0, }; + +static int +gitg_rv_model_get_n_columns (GtkTreeModel *self) +{ + /* validate our parameters */ + g_return_val_if_fail(GITG_RV_MODEL(self), 0); + + return N_COLUMNS; +} + +static GType +gitg_rv_model_get_column_type(GtkTreeModel *self, int column) +{ + GType types[] = { + GITG_TYPE_REVISION, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING + }; + + /* validate our parameters */ + g_return_val_if_fail(GITG_IS_RV_MODEL(self), G_TYPE_INVALID); + g_return_val_if_fail(column >= 0 && column < N_COLUMNS, G_TYPE_INVALID); + + return types[column]; +} + +/* retreive an object from our parent's data storage, + * unref the returned object when done */ +static GitgRevision * +gitg_rv_model_get_object(GitgRvModel *self, GtkTreeIter *iter) +{ + GValue value = { 0, }; + GitgRevision *obj; + + /* validate our parameters */ + g_return_val_if_fail(GITG_IS_RV_MODEL(self), NULL); + g_return_val_if_fail(iter != NULL, NULL); + + /* retreive the object using our parent's interface, take our own + * reference to it */ + parent_iface.get_value(GTK_TREE_MODEL(self), iter, 0, &value); + obj = GITG_REVISION(g_value_dup_object(&value)); + + g_value_unset (&value); + + return obj; +} + +static gchar * +timestamp_to_str(guint64 timestamp) +{ + struct tm *tms = localtime((time_t *)×tamp); + char buf[255]; + + strftime(buf, 255, "%Y-%m-%d %H:%M:%S", tms); + return g_strdup(buf); +} + +static void +gitg_rv_model_get_value(GtkTreeModel *self, GtkTreeIter *iter, int column, + GValue *value) +{ + GitgRevision *obj; + + /* validate our parameters */ + g_return_if_fail(GITG_IS_RV_MODEL(self)); + g_return_if_fail(iter != NULL); + g_return_if_fail(column >= 0 && column < N_COLUMNS); + g_return_if_fail(value != NULL); + + /* get the object from our parent's storage */ + obj = gitg_rv_model_get_object(GITG_RV_MODEL(self), iter); + + /* initialise our GValue to the required type */ + g_value_init(value, gitg_rv_model_get_column_type(GTK_TREE_MODEL(self), column)); + + switch (column) + { + case OBJECT_COLUMN: + /* the object itself was requested */ + g_value_set_object(value, obj); + break; + case AUTHOR_COLUMN: + g_value_set_string(value, gitg_revision_get_author(obj)); + break; + case SUBJECT_COLUMN: + g_value_set_string(value, gitg_revision_get_subject(obj)); + break; + case DATE_COLUMN: + g_value_take_string(value, timestamp_to_str(gitg_revision_get_timestamp(obj))); + break; + default: + g_assert_not_reached(); + } + + /* release the reference gained from gitg_rv_model _get_object() */ + g_object_unref(obj); +} + +static void +gitg_rv_model_tree_model_iface_init(GtkTreeModelIface *iface) +{ + parent_iface = *iface; + + iface->get_n_columns = gitg_rv_model_get_n_columns; + iface->get_column_type = gitg_rv_model_get_column_type; + iface->get_value = gitg_rv_model_get_value; +} + +static void +gitg_rv_model_finalize(GObject *object) +{ + G_OBJECT_CLASS (gitg_rv_model_parent_class)->finalize(object); +} + +static void +gitg_rv_model_class_init(GitgRvModelClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + object_class->finalize = gitg_rv_model_finalize; +} + +static void +gitg_rv_model_init(GitgRvModel *object) +{ + //self->priv = GITG_RV_MODEL_GET_PRIVATE(self); + GType types[] = { GITG_TYPE_REVISION }; + + gtk_list_store_set_column_types(GTK_LIST_STORE(object), 1, types); +} + +void +gitg_rv_model_add(GitgRvModel *self, GitgRevision *obj, GtkTreeIter *iter) +{ + GtkTreeIter iter1; + + /* validate our parameters */ + g_return_if_fail(GITG_IS_RV_MODEL(self)); + g_return_if_fail(GITG_IS_REVISION(obj)); + + /* put this object in our data storage */ + gtk_list_store_append(GTK_LIST_STORE(self), &iter1); + gtk_list_store_set(GTK_LIST_STORE(self), &iter1, 0, obj, -1); + + /* here you would connect up signals (e.g. ::notify) to notice when your + * object has changed */ + + /* return the iter if the user cares */ + if (iter) + *iter = iter1; +} + +GitgRvModel * +gitg_rv_model_new() +{ + return g_object_new(GITG_TYPE_RV_MODEL, NULL); +} + +gboolean +gitg_rv_model_find_by_hash(GitgRvModel *store, gchar const *hash, GtkTreeIter *iter) +{ + g_return_val_if_fail(GITG_IS_RV_MODEL(store), FALSE); + + if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), iter)) + { + do + { + GitgRevision *rv; + gtk_tree_model_get(GTK_TREE_MODEL(store), iter, 0, &rv, -1); + gchar const *phash = gitg_revision_get_hash(rv); + g_object_unref(rv); + + if (strncmp(hash, phash, 20) == 0) + return TRUE; + } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), iter)); + } + + return FALSE; +} diff --git a/gitg/gitg-rv-model.h b/gitg/gitg-rv-model.h new file mode 100644 index 0000000..aeb3e8f --- /dev/null +++ b/gitg/gitg-rv-model.h @@ -0,0 +1,39 @@ +#ifndef __GITG_RV_MODEL_H__ +#define __GITG_RV_MODEL_H__ + +#include <gtk/gtkliststore.h> +#include "gitg-revision.h" + +G_BEGIN_DECLS + +#define GITG_TYPE_RV_MODEL (gitg_rv_model_get_type ()) +#define GITG_RV_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_RV_MODEL, GitgRvModel)) +#define GITG_RV_MODEL_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_RV_MODEL, GitgRvModel const)) +#define GITG_RV_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_RV_MODEL, GitgRvModelClass)) +#define GITG_IS_RV_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_RV_MODEL)) +#define GITG_IS_RV_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_RV_MODEL)) +#define GITG_RV_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_RV_MODEL, GitgRvModelClass)) + +typedef struct _GitgRvModel GitgRvModel; +typedef struct _GitgRvModelClass GitgRvModelClass; +typedef struct _GitgRvModelPrivate GitgRvModelPrivate; + +struct _GitgRvModel { + GtkListStore parent; + + GitgRvModelPrivate *priv; +}; + +struct _GitgRvModelClass { + GtkListStoreClass parent_class; +}; + +GType gitg_rv_model_get_type (void) G_GNUC_CONST; +GitgRvModel *gitg_rv_model_new(void); + +void gitg_rv_model_add(GitgRvModel *self, GitgRevision *obj, GtkTreeIter *iter); +gboolean gitg_rv_model_find_by_hash(GitgRvModel *self, gchar const *hash, GtkTreeIter *iter); + +G_END_DECLS + +#endif /* __GITG_RV_MODEL_H__ */ diff --git a/gitg/gitg-ui.xml b/gitg/gitg-ui.xml new file mode 100644 index 0000000..98e1b93 --- /dev/null +++ b/gitg/gitg-ui.xml @@ -0,0 +1,287 @@ +<?xml version="1.0"?> +<!--Generated with glade3 3.4.5 on Mon Jun 23 22:39:43 2008 --> +<interface> + <object class="GtkWindow" id="window"> + <property name="title" translatable="yes">GitG</property> + <property name="default_width">800</property> + <property name="default_height">600</property> + <child> + <object class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <child> + <object class="GtkVPaned" id="vpaned1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="position">300</property> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> + <child> + <object class="GtkTreeView" id="tree_view_rv"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_clickable">True</property> + <property name="rules_hint">True</property> + <property name="search_column">1</property> + <property name="fixed_height_mode">True</property> + </object> + </child> + </object> + <packing> + <property name="resize">True</property> + <property name="shrink">True</property> + </packing> + </child> + <child> + <object class="GtkNotebook" id="notebook"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkVBox" id="vbox_details"> + <property name="visible">True</property> + <property name="spacing">3</property> + <child> + <object class="GtkTable" id="table1"> + <property name="visible">True</property> + <property name="n_rows">5</property> + <property name="n_columns">2</property> + <property name="column_spacing">3</property> + <property name="row_spacing">2</property> + <child> + <object class="GtkEventBox" id="event_box_parent"> + <property name="visible">True</property> + <child> + <object class="GtkVBox" id="vbox_parents"> + <property name="visible">True</property> + </object> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_subject"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="use_markup">True</property> + <property name="selectable">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_date"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="use_markup">True</property> + <property name="selectable">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_author"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="use_markup">True</property> + <property name="selectable">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_sha"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="use_markup">True</property> + <property name="selectable">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_parent_lbl"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="yalign">0</property> + <property name="label" translatable="yes">Parent:</property> + </object> + <packing> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_subject_lbl"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">Subject:</property> + </object> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_date_lbl"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">Date:</property> + </object> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_author_lbl"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">Author:</property> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_sha_lbl"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">SHA:</property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="padding">3</property> + </packing> + </child> + <child> + <object class="GtkHSeparator" id="hseparator1"> + <property name="visible">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolled_window_details"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + </object> + </child> + <child type="tab"> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Details</property> + </object> + <packing> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolled_window_raw"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <child> + <placeholder/> + </child> + </object> + </child> + <child type="tab"> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes">Raw</property> + </object> + <packing> + <property name="position">1</property> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child type="tab"> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes">Tree</property> + </object> + <packing> + <property name="position">2</property> + <property name="tab_fill">False</property> + </packing> + </child> + </object> + <packing> + <property name="resize">True</property> + <property name="shrink">True</property> + </packing> + </child> + </object> + </child> + <child> + <object class="GtkStatusbar" id="statusbar"> + <property name="visible">True</property> + <property name="spacing">2</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/gitg/gitg-utils.c b/gitg/gitg-utils.c new file mode 100644 index 0000000..9ed4f5c --- /dev/null +++ b/gitg/gitg-utils.c @@ -0,0 +1,54 @@ +#include "gitg-utils.h" + +inline static guint8 +atoh(gchar c) +{ + if (c >= 'a') + return c - 'a' + 10; + if (c >= 'A') + return c - 'A' + 10; + + return c - '0'; +} + +void +gitg_utils_sha1_to_hash(gchar const *sha, gchar *hash) +{ + int i; + + for (i = 0; i < 20; ++i) + hash[i] = (atoh(*sha++) << 4) | atoh(*sha++); +} + +void +gitg_utils_hash_to_sha1(gchar const *hash, gchar *sha) +{ + char const *repr = "0123456789abcdef"; + int i; + int pos = 0; + + for (i = 0; i < 20; ++i) + { + sha[pos++] = repr[(hash[i] >> 4) & 0x0f]; + sha[pos++] = repr[(hash[i] & 0x0f)]; + } +} + +gchar * +gitg_utils_hash_to_sha1_new(gchar const *hash) +{ + gchar *ret = g_new(gchar, 41); + gitg_utils_hash_to_sha1(hash, ret); + + ret[40] = '\0'; + return ret; +} + +gchar * +gitg_utils_sha1_to_hash_new(gchar const *sha1) +{ + gchar *ret = g_new(gchar, 20); + gitg_utils_sha1_to_hash(sha1, ret); + + return ret; +} diff --git a/gitg/gitg-utils.h b/gitg/gitg-utils.h new file mode 100644 index 0000000..d8bf8ee --- /dev/null +++ b/gitg/gitg-utils.h @@ -0,0 +1,12 @@ +#ifndef __GITG_UTILS_H__ +#define __GITG_UTILS_H__ + +#include <glib.h> + +void gitg_utils_sha1_to_hash(gchar const *sha, gchar *hash); +void gitg_utils_hash_to_sha1(gchar const *hash, gchar *sha); + +gchar *gitg_utils_sha1_to_hash_new(gchar const *sha); +gchar *gitg_utils_hash_to_sha1_new(gchar const *hash); + +#endif /* __GITG_UTILS_H__ */ diff --git a/gitg/gitg.c b/gitg/gitg.c new file mode 100644 index 0000000..62f6f62 --- /dev/null +++ b/gitg/gitg.c @@ -0,0 +1,490 @@ +#include <gtk/gtk.h> +#include <glib.h> +#include <glib/gi18n.h> +#include <stdlib.h> +#include <string.h> +#include <gtksourceview/gtksourceview.h> +#include <gtksourceview/gtksourcelanguagemanager.h> + +#include "gitg-rv-model.h" +#include "gitg-utils.h" +#include "gitg-loader.h" +#include "config.h" + +static GOptionEntry entries[] = +{ + { NULL } +}; + +static GtkBuilder *builder; +static GtkTreeView *tree_view; +static GitgRvModel *store; +static GtkStatusbar *statusbar; +static GitgRunner *diff_runner; +static GtkSourceView *diff_view; +static gchar *gitdir; + +void +parse_options(int *argc, char ***argv) +{ + GError *error = NULL; + GOptionContext *context; + + context = g_option_context_new(_("- git repository viewer")); + g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE); + g_option_context_add_group(context, gtk_get_option_group (TRUE)); + + if (!g_option_context_parse(context, argc, argv, &error)) + { + g_print("option parsing failed: %s\n", error->message); + g_error_free(error); + exit(1); + } +} + +static gboolean +on_window_delete_event(GtkWidget *widget, GdkEvent *event, gpointer userdata) +{ + gitg_runner_cancel(diff_runner); + + gtk_tree_view_set_model(tree_view, NULL); + g_object_unref(builder); + gtk_main_quit(); +} + +static gint +string_compare(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) +{ + gint col = GPOINTER_TO_INT(userdata); + gchar *s1; + gchar *s2; + + gtk_tree_model_get(model, a, col, &s1, -1); + gtk_tree_model_get(model, b, col, &s2, -1); + + /*gchar *c1 = g_utf8_casefold(s1, -1); + gchar *c2 = g_utf8_casefold(s2, -1); + + gint ret = g_utf8_collate(c1, c2); + + g_free(c1); + g_free(c2);*/ + + //gint ret = g_strcmp0(s1, s2); + + //g_free(s1); + //g_free(s2); + + return 0; +} + +static gchar * +format_sha(GitgRevision *revision, gpointer data) +{ + return gitg_revision_get_sha1(revision); +} + +static gchar * +make_bold(GitgRevision *revision, gpointer data) +{ + return g_strconcat("<b>", (gchar*)data, "</b>", NULL); +} + +static gchar * +format_date(GitgRevision *revision, gpointer data) +{ + guint64 timestamp = gitg_revision_get_timestamp(revision); + + // Remove newline + char *c = ctime((time_t *)×tamp); + return g_strndup(c, strlen(c) - 1); +} + +typedef gchar * (*TransformFunc)(GitgRevision *revision, gpointer data); +typedef struct +{ + GObject *object; + gint column; + gchar const *property; + TransformFunc transform; +} Binding; + +static void +on_selection_binding_changed(GtkTreeSelection *selection, Binding *binding) +{ + GtkTreeModel *model; + GtkTreeIter iter; + + GValue value = {0,}; + g_value_init(&value, G_TYPE_STRING); + + if (gtk_tree_selection_get_selected(selection, &model, &iter)) + { + gchar *res; + + if (binding->transform) + { + GitgRevision *rv; + gpointer ptr; + + gtk_tree_model_get(model, &iter, 0, &rv, binding->column, &ptr, -1); + res = binding->transform(rv, ptr); + g_object_unref(rv); + + if (binding->column != -1) + g_free(ptr); + } + else + { + gtk_tree_model_get(model, &iter, binding->column, &res, -1); + } + + g_value_take_string(&value, res); + } + else + { + g_value_set_string(&value, ""); + } + + g_object_set_property(binding->object, binding->property, &value); + g_value_unset(&value); +} + +static void +bind(GtkTreeSelection *selection, gint column, GObject *object, gchar const *property, TransformFunc cb) +{ + Binding *b = g_new0(Binding, 1); + b->column = column; + b->object = object; + b->property = property; + b->transform = cb; + + g_signal_connect_data(selection, "changed", G_CALLBACK(on_selection_binding_changed), b, (GClosureNotify)g_free, 0); +} + +static void +update_markup(GObject *object) +{ + GtkLabel *label = GTK_LABEL(object); + gchar const *text = gtk_label_get_text(label); + + gchar *newtext = g_strconcat("<span weight='bold' foreground='#777'>", text, "</span>", NULL); + + gtk_label_set_markup(label, newtext); + g_free(newtext); +} + +static gboolean +on_parent_clicked(GtkWidget *ev, GdkEventButton *event, gpointer userdata) +{ + if (event->button != 1) + return FALSE; + + GtkTreeIter iter; + if (gitg_rv_model_find_by_hash(store, (gchar *)userdata, &iter)) + gtk_tree_selection_select_iter(gtk_tree_view_get_selection(tree_view), &iter); + + return TRUE; +} + +static GtkWidget * +make_parent_label(gchar *hash) +{ + GtkWidget *ev = gtk_event_box_new(); + GtkWidget *lbl = gtk_label_new(NULL); + + gchar *markup = g_strconcat("<span underline='single' foreground='#00f'>", hash, "</span>", NULL); + gtk_label_set_markup(GTK_LABEL(lbl), markup); + g_free(markup); + + gtk_misc_set_alignment(GTK_MISC(lbl), 0.0, 0.5); + gtk_container_add(GTK_CONTAINER(ev), lbl); + + gtk_widget_show(ev); + gtk_widget_show(lbl); + + + g_signal_connect_data(ev, "button-release-event", G_CALLBACK(on_parent_clicked), gitg_utils_sha1_to_hash_new(hash), (GClosureNotify)g_free, 0); + + return ev; +} + +static void +on_update_parents(GtkTreeSelection *selection, GtkVBox *container) +{ + GList *children = gtk_container_get_children(GTK_CONTAINER(container)); + GList *item; + + for (item = children; item; item = item->next) + gtk_container_remove(GTK_CONTAINER(container), GTK_WIDGET(item->data)); + + g_list_free(children); + + GtkTreeModel *model; + GtkTreeIter iter; + + if (!gtk_tree_selection_get_selected(selection, &model, &iter)) + return; + + GitgRevision *rv; + gtk_tree_model_get(model, &iter, 0, &rv, -1); + + gchar **parents = gitg_revision_get_parents(rv); + gchar **ptr; + + for (ptr = parents; *ptr; ++ptr) + { + GtkWidget *widget = make_parent_label(*ptr); + gtk_box_pack_start(GTK_BOX(container), widget, FALSE, TRUE, 0); + + gtk_widget_realize(widget); + GdkCursor *cursor = gdk_cursor_new(GDK_HAND1); + gdk_window_set_cursor(widget->window, cursor); + gdk_cursor_unref(cursor); + } + + g_strfreev(parents); + g_object_unref(rv); +} + +static void +on_update_diff(GtkTreeSelection *selection, GtkVBox *container) +{ + // First cancel a possibly still running diff + gitg_runner_cancel(diff_runner); + + // Clear the buffer + GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(diff_view)); + gtk_text_buffer_set_text(buffer, "", 0); + GtkTreeModel *model; + GtkTreeIter iter; + + if (!gtk_tree_selection_get_selected(selection, &model, &iter)) + return; + + GitgRevision *rv; + gtk_tree_model_get(model, &iter, 0, &rv, -1); + gchar *hash = gitg_revision_get_sha1(rv); + + gchar *argv[] = { + "git", + "--git-dir", + gitdir, + "show", + "--pretty=format:%s%n%n%b", + "--encoding=UTF-8", + hash, + NULL + }; + + gitg_runner_run(diff_runner, argv, NULL); + g_object_unref(rv); + g_free(hash); +} + +static void +build_tree_view() +{ + tree_view = GTK_TREE_VIEW(gtk_builder_get_object(builder, "tree_view_rv")); + store = gitg_rv_model_new(); + + gtk_tree_view_insert_column_with_attributes(tree_view, + 0, _("Subject"), gtk_cell_renderer_text_new(), "text", 1, NULL); + + gtk_tree_view_insert_column_with_attributes(tree_view, + 1, _("Author"), gtk_cell_renderer_text_new(), "text", 2, NULL); + + gtk_tree_view_insert_column_with_attributes(tree_view, + 2, _("Date"), gtk_cell_renderer_text_new(), "text", 3, NULL); + + int i; + GtkTreeViewColumn *column; + + guint cw[] = {400, 200, 200}; + + for (i = 0; i < 3; ++i) + { + column = gtk_tree_view_get_column(tree_view, i); + gtk_tree_view_column_set_sort_column_id(column, i + 1); + gtk_tree_view_column_set_resizable(column, TRUE); + gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); + gtk_tree_view_column_set_fixed_width(column, cw[i]); + + gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), i + 1, string_compare, GINT_TO_POINTER(i + 1), NULL); + } + + GtkTreeSelection *selection = gtk_tree_view_get_selection(tree_view); + + bind(selection, 1, gtk_builder_get_object(builder, "label_subject"), "label", make_bold); + bind(selection, 2, gtk_builder_get_object(builder, "label_author"), "label", NULL); + bind(selection, -1, gtk_builder_get_object(builder, "label_date"), "label", format_date); + bind(selection, -1, gtk_builder_get_object(builder, "label_sha"), "label", format_sha); + + g_signal_connect(selection, "changed", G_CALLBACK(on_update_parents), gtk_builder_get_object(builder, "vbox_parents")); + g_signal_connect(selection, "changed", G_CALLBACK(on_update_diff), NULL); + + gchar const *lbls[] = { + "label_subject_lbl", + "label_author_lbl", + "label_sha_lbl", + "label_date_lbl", + "label_parent_lbl" + }; + + for (i = 0; i < sizeof(lbls) / sizeof(gchar *); ++i) + update_markup(gtk_builder_get_object(builder, lbls[i])); +} + +static void +build_diff_view() +{ + GtkWidget *box = GTK_WIDGET(gtk_builder_get_object(builder, "scrolled_window_details")); + diff_view = GTK_SOURCE_VIEW(gtk_source_view_new()); + + gtk_text_view_set_editable(GTK_TEXT_VIEW(diff_view), FALSE); + gtk_source_view_set_tab_width(diff_view, 4); + + GtkSourceLanguageManager *manager = gtk_source_language_manager_get_default(); + GtkSourceLanguage *language = gtk_source_language_manager_get_language(manager, "diff"); + gtk_source_buffer_set_language(GTK_SOURCE_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(diff_view))), language); + + gtk_widget_show(GTK_WIDGET(diff_view)); + gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(diff_view)); +} + +static void +build_ui() +{ + GError *error = NULL; + builder = gtk_builder_new(); + + if (!gtk_builder_add_from_file(builder, GITG_UI_DIR "/gitg-ui.xml", &error)) + { + g_critical("Could not open UI file: %s (%s)", GITG_UI_DIR "/gitg-ui.xml", error->message); + g_error_free(error); + exit(1); + } + + GtkWindow *window = GTK_WINDOW(gtk_builder_get_object(builder, "window")); + gtk_widget_show_all(GTK_WIDGET(window)); + + build_tree_view(); + build_diff_view(); + + g_signal_connect(window, "delete-event", G_CALLBACK(on_window_delete_event), NULL); + statusbar = GTK_STATUSBAR(gtk_builder_get_object(builder, "statusbar")); +} + +static void +on_diff_begin_loading(GitgRunner *runner, gpointer userdata) +{ + GdkCursor *cursor = gdk_cursor_new(GDK_WATCH); + gdk_window_set_cursor(GTK_WIDGET(diff_view)->window, cursor); + gdk_cursor_unref(cursor); +} + +static void +on_diff_end_loading(GitgRunner *runner, gpointer userdata) +{ + gdk_window_set_cursor(GTK_WIDGET(diff_view)->window, NULL); +} + +static void +on_diff_update(GitgRunner *runner, gchar **buffer, gpointer userdata) +{ + gchar *line; + GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(diff_view)); + GtkTextIter iter; + + gtk_text_buffer_get_end_iter(buf, &iter); + + while ((line = *buffer++)) + gtk_text_buffer_insert(buf, &iter, line, -1); +} + +static void +on_begin_loading(GitgLoader *loader, gpointer userdata) +{ + GdkCursor *cursor = gdk_cursor_new(GDK_WATCH); + gdk_window_set_cursor(GTK_WIDGET(tree_view)->window, cursor); + gdk_cursor_unref(cursor); + + gtk_statusbar_push(statusbar, 0, _("Begin loading repository")); +} + +static void +on_end_loading(GitgLoader *loader, gpointer userdata) +{ + gchar *msg = g_strdup_printf(_("Loaded %d revisions"), gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL)); + + gtk_statusbar_push(statusbar, 0, msg); + + g_free(msg); + + gtk_tree_view_set_model(tree_view, GTK_TREE_MODEL(store)); + + gdk_window_set_cursor(GTK_WIDGET(tree_view)->window, NULL); +} + +static void +on_update(GitgLoader *loader, GitgRevision **revisions) +{ + GitgRevision *rv; + + gtk_tree_view_set_model(tree_view, NULL); + + while ((rv = *revisions++)) + gitg_rv_model_add(store, rv, NULL); + + gchar *msg = g_strdup_printf(_("Loading %d revisions..."), gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL)); + + gtk_statusbar_push(statusbar, 0, msg); + g_free(msg); + + //gtk_tree_view_set_model(tree_view, GTK_TREE_MODEL(store)); +} + +static gchar * +append_dot_git(gchar *path) +{ + gchar *res = g_build_filename(path, ".git", NULL); + g_free(path); + + return res; +} + +int +main(int argc, char **argv) +{ + bindtextdomain (GETTEXT_PACKAGE, GITG_LOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + + // Parse gtk options + g_thread_init(NULL); + + gtk_init(&argc, &argv); + parse_options(&argc, &argv); + + gitdir = append_dot_git(argc > 1 ? g_strdup(argv[1]) : g_get_current_dir()); + build_ui(); + + GitgLoader *loader = gitg_loader_new(store); + diff_runner = gitg_runner_new(2000); + + g_signal_connect(diff_runner, "begin-loading", G_CALLBACK(on_diff_begin_loading), NULL); + g_signal_connect(diff_runner, "update", G_CALLBACK(on_diff_update), NULL); + g_signal_connect(diff_runner, "end-loading", G_CALLBACK(on_diff_end_loading), NULL); + + g_signal_connect(loader, "begin-loading", G_CALLBACK(on_begin_loading), NULL); + g_signal_connect(loader, "revisions-added", G_CALLBACK(on_update), NULL); + g_signal_connect(loader, "end-loading", G_CALLBACK(on_end_loading), NULL); + + gitg_loader_load(loader, gitdir, NULL); + + gtk_main(); + + g_free(gitdir); + + return 0; +} diff --git a/po/ChangeLog b/po/ChangeLog new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/po/ChangeLog diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 0000000..97f7045 --- /dev/null +++ b/po/LINGUAS @@ -0,0 +1,5 @@ +# gitg translations +# +# please keep this list sorted alphabetically +# +nl diff --git a/po/Makefile.in.in b/po/Makefile.in.in new file mode 100644 index 0000000..6891e8f --- /dev/null +++ b/po/Makefile.in.in @@ -0,0 +1,218 @@ +# Makefile for program source directory in GNU NLS utilities package. +# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper <drepper@gnu.ai.mit.edu> +# Copyright (C) 2004-2008 Rodney Dawes <dobey.pwns@gmail.com> +# +# This file may be copied and used freely without restrictions. It may +# be used in projects which are not available under a GNU Public License, +# but which still want to provide support for the GNU gettext functionality. +# +# - Modified by Owen Taylor <otaylor@redhat.com> to use GETTEXT_PACKAGE +# instead of PACKAGE and to look for po2tbl in ./ not in intl/ +# +# - Modified by jacob berkman <jacob@ximian.com> to install +# Makefile.in.in and po2tbl.sed.in for use with glib-gettextize +# +# - Modified by Rodney Dawes <dobey.pwns@gmail.com> for use with intltool +# +# We have the following line for use by intltoolize: +# INTLTOOL_MAKEFILE + +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +datadir = @datadir@ +datarootdir = @datarootdir@ +libdir = @libdir@ +DATADIRNAME = @DATADIRNAME@ +itlocaledir = $(prefix)/$(DATADIRNAME)/locale +subdir = po +install_sh = @install_sh@ +# Automake >= 1.8 provides @mkdir_p@. +# Until it can be supposed, use the safe fallback: +mkdir_p = $(install_sh) -d + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ + +GMSGFMT = @GMSGFMT@ +MSGFMT = @MSGFMT@ +XGETTEXT = @XGETTEXT@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +MSGMERGE = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist +GENPOT = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --pot + +ALL_LINGUAS = @ALL_LINGUAS@ + +PO_LINGUAS=$(shell if test -r $(srcdir)/LINGUAS; then grep -v "^\#" $(srcdir)/LINGUAS; fi) + +USER_LINGUAS=$(shell if test -n "$(LINGUAS)"; then LLINGUAS="$(LINGUAS)"; ALINGUAS="$(ALL_LINGUAS)"; for lang in $$LLINGUAS; do if test -n "`grep ^$$lang$$ $(srcdir)/LINGUAS`" -o -n "`echo $$ALINGUAS|grep ' ?$$lang ?'`"; then printf "$$lang "; fi; done; fi) + +USE_LINGUAS=$(shell if test -n "$(USER_LINGUAS)"; then LLINGUAS="$(USER_LINGUAS)"; else if test -n "$(PO_LINGUAS)"; then LLINGUAS="$(PO_LINGUAS)"; else LLINGUAS="$(ALL_LINGUAS)"; fi; fi; for lang in $$LLINGUAS; do printf "$$lang "; done) + +POFILES=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.po "; done) + +DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(POFILES) +EXTRA_DISTFILES = POTFILES.skip Makevars LINGUAS + +POTFILES = \ +# This comment gets stripped out + +CATALOGS=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.gmo "; done) + +.SUFFIXES: +.SUFFIXES: .po .pox .gmo .mo .msg .cat + +.po.pox: + $(MAKE) $(GETTEXT_PACKAGE).pot + $(MSGMERGE) $< $(GETTEXT_PACKAGE).pot -o $*.pox + +.po.mo: + $(MSGFMT) -o $@ $< + +.po.gmo: + file=`echo $* | sed 's,.*/,,'`.gmo \ + && rm -f $$file && $(GMSGFMT) -o $$file $< + +.po.cat: + sed -f ../intl/po2msg.sed < $< > $*.msg \ + && rm -f $@ && gencat $@ $*.msg + + +all: all-@USE_NLS@ + +all-yes: $(CATALOGS) +all-no: + +$(GETTEXT_PACKAGE).pot: $(POTFILES) + $(GENPOT) + +install: install-data +install-data: install-data-@USE_NLS@ +install-data-no: all +install-data-yes: all + $(mkdir_p) $(DESTDIR)$(itlocaledir) + linguas="$(USE_LINGUAS)"; \ + for lang in $$linguas; do \ + dir=$(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES; \ + $(mkdir_p) $$dir; \ + if test -r $$lang.gmo; then \ + $(INSTALL_DATA) $$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \ + echo "installing $$lang.gmo as $$dir/$(GETTEXT_PACKAGE).mo"; \ + else \ + $(INSTALL_DATA) $(srcdir)/$$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \ + echo "installing $(srcdir)/$$lang.gmo as" \ + "$$dir/$(GETTEXT_PACKAGE).mo"; \ + fi; \ + if test -r $$lang.gmo.m; then \ + $(INSTALL_DATA) $$lang.gmo.m $$dir/$(GETTEXT_PACKAGE).mo.m; \ + echo "installing $$lang.gmo.m as $$dir/$(GETTEXT_PACKAGE).mo.m"; \ + else \ + if test -r $(srcdir)/$$lang.gmo.m ; then \ + $(INSTALL_DATA) $(srcdir)/$$lang.gmo.m \ + $$dir/$(GETTEXT_PACKAGE).mo.m; \ + echo "installing $(srcdir)/$$lang.gmo.m as" \ + "$$dir/$(GETTEXT_PACKAGE).mo.m"; \ + else \ + true; \ + fi; \ + fi; \ + done + +# Empty stubs to satisfy archaic automake needs +dvi info tags TAGS ID: + +# Define this as empty until I found a useful application. +install-exec installcheck: + +uninstall: + linguas="$(USE_LINGUAS)"; \ + for lang in $$linguas; do \ + rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \ + rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \ + done + +check: all $(GETTEXT_PACKAGE).pot + rm -f missing notexist + srcdir=$(srcdir) $(INTLTOOL_UPDATE) -m + if [ -r missing -o -r notexist ]; then \ + exit 1; \ + fi + +mostlyclean: + rm -f *.pox $(GETTEXT_PACKAGE).pot *.old.po cat-id-tbl.tmp + rm -f .intltool-merge-cache + +clean: mostlyclean + +distclean: clean + rm -f Makefile Makefile.in POTFILES stamp-it + rm -f *.mo *.msg *.cat *.cat.m *.gmo + +maintainer-clean: distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + rm -f Makefile.in.in + +distdir = ../$(PACKAGE)-$(VERSION)/$(subdir) +dist distdir: $(DISTFILES) + dists="$(DISTFILES)"; \ + extra_dists="$(EXTRA_DISTFILES)"; \ + for file in $$extra_dists; do \ + test -f $(srcdir)/$$file && dists="$$dists $(srcdir)/$$file"; \ + done; \ + for file in $$dists; do \ + test -f $$file || file="$(srcdir)/$$file"; \ + ln $$file $(distdir) 2> /dev/null \ + || cp -p $$file $(distdir); \ + done + +update-po: Makefile + $(MAKE) $(GETTEXT_PACKAGE).pot + tmpdir=`pwd`; \ + linguas="$(USE_LINGUAS)"; \ + for lang in $$linguas; do \ + echo "$$lang:"; \ + result="`$(MSGMERGE) -o $$tmpdir/$$lang.new.po $$lang`"; \ + if $$result; then \ + if cmp $(srcdir)/$$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ + rm -f $$tmpdir/$$lang.new.po; \ + else \ + if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ + :; \ + else \ + echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ + rm -f $$tmpdir/$$lang.new.po; \ + exit 1; \ + fi; \ + fi; \ + else \ + echo "msgmerge for $$lang.gmo failed!"; \ + rm -f $$tmpdir/$$lang.new.po; \ + fi; \ + done + +Makefile POTFILES: stamp-it + @if test ! -f $@; then \ + rm -f stamp-it; \ + $(MAKE) stamp-it; \ + fi + +stamp-it: Makefile.in.in $(top_builddir)/config.status POTFILES.in + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/Makefile.in CONFIG_HEADERS= CONFIG_LINKS= \ + $(SHELL) ./config.status + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 0000000..4dbcd8f --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,3 @@ +# List of source files containing translatable strings. +[encoding: UTF-8] +gitg/gitg.c diff --git a/po/nl.po b/po/nl.po new file mode 100644 index 0000000..bd22c84 --- /dev/null +++ b/po/nl.po @@ -0,0 +1,3 @@ +#: ../gitg/gitg.c:18 +msgid "- git repository viewer" +msgstr "- git repository bekijker" |
