From 981c854914d44d8723f715dcfae40ec6cfa1c063 Mon Sep 17 00:00:00 2001 From: Aral Balkan Date: Fri, 8 Oct 2021 13:05:49 +0100 Subject: [PATCH] Initial commit --- .gitignore | 3 + CHANGELOG.md | 11 + LICENSE | 225 +++++++++++++ README.md | 234 +++++++++++++ template/.editorconfig | 17 + template/.github/workflows/main.yml | 37 ++ template/.gitignore | 3 + template/.vscode/extensions.json | 9 + template/.vscode/launch.json | 25 ++ template/CHANGELOG.md | 11 + template/LICENSE | 225 +++++++++++++ template/README.md | 110 ++++++ template/com.github.ORG.APP.yml | 22 ++ template/data/128.svg | 502 ++++++++++++++++++++++++++++ template/data/16.svg | 382 +++++++++++++++++++++ template/data/24.svg | 412 +++++++++++++++++++++++ template/data/32.svg | 414 +++++++++++++++++++++++ template/data/48.svg | 428 ++++++++++++++++++++++++ template/data/64.svg | 413 +++++++++++++++++++++++ template/data/APP.appdata.xml.in | 17 + template/data/APP.desktop.in | 12 + template/data/gresource.xml | 11 + template/data/gschema.xml | 25 ++ template/data/meson.build | 5 + template/meson.build | 72 ++++ template/meson/post_install.py | 11 + template/po/LINGUAS | 2 + template/po/POTFILES | 3 + template/po/meson.build | 5 + template/src/Application.vala | 37 ++ template/src/MainWindow.vala | 216 ++++++++++++ template/src/Widgets/HeaderBar.vala | 12 + template/task/build | 12 + template/task/install | 131 ++++++++ template/task/run | 8 + template/task/update-translations | 16 + watson | 276 +++++++++++++++ 37 files changed, 4354 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 template/.editorconfig create mode 100644 template/.github/workflows/main.yml create mode 100644 template/.gitignore create mode 100644 template/.vscode/extensions.json create mode 100644 template/.vscode/launch.json create mode 100644 template/CHANGELOG.md create mode 100644 template/LICENSE create mode 100644 template/README.md create mode 100644 template/com.github.ORG.APP.yml create mode 100644 template/data/128.svg create mode 100644 template/data/16.svg create mode 100644 template/data/24.svg create mode 100644 template/data/32.svg create mode 100644 template/data/48.svg create mode 100644 template/data/64.svg create mode 100644 template/data/APP.appdata.xml.in create mode 100644 template/data/APP.desktop.in create mode 100644 template/data/gresource.xml create mode 100644 template/data/gschema.xml create mode 100644 template/data/meson.build create mode 100644 template/meson.build create mode 100644 template/meson/post_install.py create mode 100644 template/po/LINGUAS create mode 100644 template/po/POTFILES create mode 100644 template/po/meson.build create mode 100644 template/src/Application.vala create mode 100644 template/src/MainWindow.vala create mode 100644 template/src/Widgets/HeaderBar.vala create mode 100755 template/task/build create mode 100755 template/task/install create mode 100755 template/task/run create mode 100755 template/task/update-translations create mode 100755 watson diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..41eb75d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build/ +builddir/ +.flatpak-builder/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9f496ef --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.0.0] - YYYY-MM-DD (In progress…) + +### Added + + - Initial release. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d51a540 --- /dev/null +++ b/LICENSE @@ -0,0 +1,225 @@ +GNU GENERAL PUBLIC LICENSE + +Version 3, 29 June 2007 + +Copyright © 2007 Free Software Foundation, Inc. + +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. + + + Copyright (C) + + 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 . + +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: + + Copyright (C) + 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 . + +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 . diff --git a/README.md b/README.md new file mode 100644 index 0000000..fbfeadb --- /dev/null +++ b/README.md @@ -0,0 +1,234 @@ +# Watson + +> “It’s elementary, my dear…” + +__Watson is a best-practices application template for elementary OS 6 (Odin).__ + +[![Looping GIF of a snippet of Aral Balkan’s video introducing Watson.](https://videoapi-muybridge.vimeocdn.com/animated-thumbnails/image/9710a275-8b39-40f9-b8c1-1c720883f364.gif?ClientID=vimeo-core-prod&Date=1633623413&Signature=b1d86a2778a3aa9e4ca472047355a6d4f43009be)](https://vimeo.com/625472483) + +[Watch the introductory screencast](https://vimeo.com/625472483). + +___Status: Alpha.__ Looking for feedback and input from the elementary OS community._ + + - _For feedback, ideas, and suggestions, please see [Discussions](https://github.com/small-tech/watson/discussions)._ + - _For bug reports for Watson and generated projects, please [open an issue](https://github.com/small-tech/watson/issues)._ + - __Want to jump right in? See [Getting Started](#getting-started).__ + +[Want the wallpaper?](#get-the-wallpaper) + +## What Watson is (and what Watson is not). + +Watson gets you up and running quickly with a bare-bones single-window elementary OS 6 (Odin) app that is based on the [elementary OS Developer Documentation](https://docs.elementary.io/develop/) as well as a review of the conventions employed by the core apps that ship with elementary OS (like [Code](https://github.com/elementary/code/) and [Calculator](https://github.com/elementary/calculator)). + +It also makes it equally easy for developers to build and run your application on their own machines after they clone your project’s repository. + +When deciding what to include and what to leave out of the generated app, the guiding principle is to include base functionality expected of any elementary OS 6 app. The goal is for you to only have to add to the generated template, not remove from it or change the generated code for common types of apps (with the understanding that multi-window applications and highly custom apps might require a bit of fiddling). + +__Most importantly, the generated skeletal app complies with the [elementary OS Human Interface Guidelines](https://docs.elementary.io/hig/) and follows other recommended elementary OS 6 conventions like [coding style](https://docs.elementary.io/develop/writing-apps/code-style).__ _If you haven’t already done so, please read through both of those important resources before continuing. Also, to refer to language or library details during development, bookmark [Valadoc](https://valadoc.org/)._ + +Once you’ve made the generated app your own by customising it and adding to it, you can submit it for inclusion in the elementary OS [AppCenter](https://docs.elementary.io/develop/appcenter/publishing-requirements) as a curated app. + +___Watson is not a substitute for knowing what you’re doing.__ Watson is meant to lower the barrier of entry to creating an elementary OS application by automating the start of a new project to ensure you do not misconfigure your project or leave out important aspects (like window state preservation or translations). So, again, please read the above documents before starting to develop apps for elementary OS._ + +## Goals + +1. The time from when a developer decides to make an elementary OS app to when they have a working project using Watson should be < 60 seconds. + +2. The time from when a developer clones a Watson-generated elementary OS application to when they have it up and running on their own machine should be < 60 seconds. + +Furthermore, the generated project must: + + - Adhere to platform [human interface guidelines](https://docs.elementary.io/hig/), [conventions](https://docs.elementary.io/develop/writing-apps/code-style), and [other recommended practices](https://docs.elementary.io/develop/). + + - Be [maintainable](https://www.oreilly.com/content/what-is-maintainability/). + + - Adhere to [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) (Don’t Repeat Yourself) principles. + +## Getting started + +### On GitHub: + +1. __Press the green [“Use this template” button](https://github.com/small-tech/watson#repo-content-pjax-container)__ for this repository to create your new project’s repository using Watson as the template. + +### On your development machine: + +2. __Clone your project__ and switch to its directory in Terminal: + + ```shell + git clone git@github.com:/.git + cd + ``` + +3. __Initialise your project__: + + ```shell + ./watson + ``` + +> __Note on the GitHub-centric workflow:__ The elementary OS AppCenter currently ties application bundle IDs and the directory structure for assets, etc., to the GitHub project. So your project’s application bundle ID will be something like com.github.small_tech.comet (the init script will automatically convert dashes to underscores as per flatpak’s naming requirements). I have raised my concerns about this both from a legal perspective [as it is a trademark violation](https://github.com/elementary/appcenter/discussions/1622) and, more generally, [because it gives Microsoft a de-facto veto right on what apps are allowed on elementary OS](https://github.com/elementary/houston/issues/436#issuecomment-905554984). I do hope that this decision will be reviewed going forward. In the meanwhile, however, Watson is designed to make full use of the current system to make setting up a new elementary OS project as simple as possible while following all relevant platform guidelines and encouraging good practices. – [Aral](https://ar.al) + +## What to expect + +### Interactive app configuration screens + +Watson will ask for your app details in a series of graphical dialogue windows and update the necessary bits of the template files (application bundle IDs, asset paths, etc.) to customise them for your project based on your answers. + +It will also replace this README and the CHANGELOG with your application’s versions, recreate the git repository (so you start with a fresh history), make an initial commit, and set up your git remote so `origin` points to your repository. + +Next, Watson will run the install task (`task/install`). + +> The install task is also what developers who clone your project will run to ensure that they can build and run your project. + +### The install task + +The install task first checks whether you have the [elementary OS development libraries](https://docs.elementary.io/develop/writing-apps/the-basic-setup#development-libraries) installed and asks you to install them if it can’t find them. + +> The elementary OS development libraries – also known as the elementary OS Software Development Kit (SDK) – are a [metapackage of elementary OS libraries](https://github.com/elementary/metapackages) required when creating apps for elementary OS. You can see which libraries are included in the SDK based on the architecture of your development machine by reviewing the following metapackage definitions: [AMD64](https://github.com/elementary/metapackages/blob/master/elementary-sdk-amd64), [ARM64](https://github.com/elementary/metapackages/blob/master/elementary-sdk-arm64), [ARMHF](https://github.com/elementary/metapackages/blob/master/elementary-sdk-armhf). + +Next, Watson will check if you have [VSCodium](https://vscodium.com) installed. If you do, it will check whether or not you have useful set of VSCodium extensions for elementary OS development installed and ask you to install them if you don’t. + +> You do _not_ need to use VSCodium to create elementary OS apps. You can, for instance, use elementary OS [Code](https://docs.elementary.io/develop/writing-apps/the-basic-setup#code), which comes preinstalled, or a different third-party editor like [Builder](https://apps.gnome.org/en/app/org.gnome.Builder/). However, if you do have VSCodium installed, there are a number of extensions that will make creating your elementary OS app easier ([Vala](https://github.com/Prince781/vala-vscode), [Meson](https://github.com/asabil/vscode-meson), [CodeLLDB](https://github.com/vadimcn/vscode-lldb), [XML](https://github.com/redhat-developer/vscode-xml), [YAML](https://github.com/redhat-developer/vscode-yaml)). If Watson cannot find these extensions installed, it will ask you if you’d like to install them now. With these extensions installed, once you’ve initialised your project, you can simple open it in VSCodium and hit F5 to run/debug it and Ctrl + Shift + B → _Build all targets_ to rebuild it after making changes. You will also get code intelligence, etc., for all your source files. Finally, your project will also inform VSCodium of the set of recommended extensions for your project so even if you choose not to install them now, you can easily find and install them later yourself. + +### Post install + +Once the install task is done, Watson will delete itself, leaving only your project behind. + +It will also commit and push the changes to your git repository. + +___And that’s it!___ + +At this point, your project is ready and you can customise the template further to create your own unique and wonderful app, knowing you have a base that adheres to elementary OS guidelines. + +You can also run your project using the run script: + +``` +task/run +``` + +Or, if you’re using VSCodium, just open your project and hit F5 to run/debug it and Ctrl + Shift + B → _Build all targets_ to rebuild it after making changes. + +You can find more task scripts in the `task` folder of your project and the workflow is also documented in the README file that’s generated for your project. + +Here’s hoping Watson will make it easier for you to start building and maintaining excellent apps for elementary OS. + +## What’s included? + + - A prompt to install the [elementary OS development libraries](https://docs.elementary.io/develop/writing-apps/the-basic-setup#development-libraries) if they don’t already exist on your machine. + + - A prompt to install recommended [VSCodium](https://vscodium.com/) Vala development and debugging extensions ([Vala](https://github.com/Prince781/vala-vscode), [Meson](https://github.com/asabil/vscode-meson), [CodeLLDB](https://github.com/vadimcn/vscode-lldb), [XML](https://github.com/redhat-developer/vscode-xml), [YAML](https://github.com/redhat-developer/vscode-yaml)) if you have VSCodium installed and are missing any of them. + + - VSCodium [launch.json](https://charlesagile.com/vscode-launch-json-and-the-debug-console) for [CodeLLDB](https://github.com/vadimcn/vscode-lldb) (press F5 to run/debug your project in VSCodium). + + - A basic `Application` class that instantiates a single window (`MainWindow`). + + - A basic [Handy application window](https://gnome.pages.gitlab.gnome.org/libhandy/) (`MainWindow`). (While this is not yet reflected in the [elementary OS Developer Documentation](https://docs.elementary.io/develop/), the core apps that ship with elementary OS – like Code and Calculator – all use the [Handy library](https://gnome.pages.gitlab.gnome.org/libhandy/) so I’ve based the template on them.) + + - A basic [Handy header bar](https://gnome.pages.gitlab.gnome.org/libhandy/doc/1-latest/HdyHeaderBar.html), as part of the basic window. + + - [Actions](https://docs.elementary.io/develop/apis/actions#glib-simpleaction) wired up for quit and fullscreen with keyboard shortcut accelerators (Ctrl+Q, and F11, respectively). The code is set up so you can easily expand the list of actions and accelerators with your own in a maintainable manner. + + - [Granite](https://valadoc.org/granite/Granite.html) library for application [launchers](https://docs.elementary.io/develop/apis/launchers), [badges](https://docs.elementary.io/develop/apis/launchers#badges), [progress bars](https://docs.elementary.io/develop/apis/launchers#progress-bars), etc. + + - [Window state preservation](https://docs.elementary.io/develop/apis/state-saving) using a [gschema.xml](https://docs.elementary.io/develop/apis/state-saving#define-settings-keys) file and [GSettings](https://valadoc.org/gio-2.0/GLib.Settings.html). Set up to automatically save and restore the last window state (dimensions, location, and whether it is maximised or fullscreen). + + - Set up for [custom resources](https://docs.elementary.io/develop/apis/gresource) ([custom icons](https://docs.elementary.io/develop/apis/gresource#icons), etc.). No custom resources are provided but you can easily add your own to the `data/` directory and declare them in the provided [gresource.xml](https://docs.elementary.io/develop/apis/gresource) file. + + - [Colour scheme](https://docs.elementary.io/develop/apis/color-scheme) support (automatically uses person’s dark/light mode preference and updates the app’s appearance should they change it while the app is running). + + - [.desktop](https://docs.elementary.io/develop/writing-apps/our-first-app#the-desktop-file) file for information about your app that’s displayed in the Application Menu and Dock. + + - [AppData.xml](https://docs.elementary.io/develop/writing-apps/our-first-app#appdata-xml) file for information need to list your app in AppCenter. + + - [LICENSE](https://docs.elementary.io/develop/writing-apps/our-first-app#legal-stuff) file for the GNU GPL license. + + - [Meson configuration files](https://docs.elementary.io/develop/writing-apps/our-first-app/the-build-system) and a build script. + + - [Support for translations](https://docs.elementary.io/develop/writing-apps/our-first-app/translations) with [GNU gettext via Meson](https://mesonbuild.com/Localisation.html). + + - Placeholder [app icon](https://docs.elementary.io/develop/writing-apps/our-first-app/icons). Just replace the provided ones with your own custom icon. + + - [Flatpak manifest](https://docs.elementary.io/develop/writing-apps/our-first-app/packaging) for packaging your application. + + - [Continuous Integration](https://docs.elementary.io/develop/writing-apps/our-first-app/continuous-integration) GitHub workflow. + + - The recommended [EditorConfig](https://docs.elementary.io/develop/writing-apps/code-style#editorconfig) for elementary OS Code and other compatible editors for enforcing the suggested [code style](https://docs.elementary.io/develop/writing-apps/code-style). + + - Basic [.gitignore file](https://git-scm.com/docs/gitignore) that ensures build directories are not accidentally added to your project. + +## What’s _not_ included? + +Watson creates a basic single-window elementary OS application using good practices. + +Watson’s goal with the generated app is that you should only have to either customise existing functionality (e.g., replace the app logo SVGs with your own), use existing functionality (e.g., add your custom icons or your own translations), or add specialised logic to the generated app. So you shouldn’t have to _remove_ any of the generated functionality. This is why there are no sample widgets or even basic layout generated as that will differ from app to app. + +The generated skeleton is just that, the structure you need to quickly get you started with building your own application. + +In other words, Watson does _not_ generate a sample app. For widget demos of the underlying libraries, see the Granite demo (`sudo apt install granite-demo && granite-demo`) and Gtk+ 3 examples/demo (`sudo apt install gtk-3-examples && gtk3-demo`). + +Watson is also not meant to teach you how to build an elementary OS app (see the [elementary OS Developer Documentation](https://docs.elementary.io/develop/)) and is not a substitute for knowing and applying the [elementary OS Human Interface Guidelines](https://docs.elementary.io/hig/) as you develop your app. + +Finally, while Watson will install the elementary OS development tools and even the recommended VSCodium extensions for you if you ask it to, __you need to configure your GitHub account and set up git on your machine yourself.__ For instructions on how to do this, please see the [Basic Setup](https://docs.elementary.io/develop/writing-apps/the-basic-setup) section of the [elementary OS Developer Documentation](https://docs.elementary.io/develop/). + +## Common functionality you might want to add to your app + +Here are some quick links showing you how to add common functionality to your app after you’ve generated it: + + - [Notifications](https://docs.elementary.io/develop/apis/notifications) + - [Launchers (dock integration; badges, progress bars, etc.)](https://docs.elementary.io/develop/apis/launchers) + +## General resources + +At the risk of sounding like a broken record, please work your way through the [elementary OS Developer Documentation](https://docs.elementary.io/develop/)) and [elementary OS Human Interface Guidelines](https://docs.elementary.io/hig/) before starting to create an app for elementary OS 6. + +Also please review the AppCenter [publishing requirements](https://docs.elementary.io/develop/appcenter/publishing-requirements) before you [submit your app](https://developer.elementary.io/). + + +Other important references include: + + - [Vala documentation](https://valadoc.org/) + - [Handy documentation](https://gnome.pages.gitlab.gnome.org/libhandy/) + - [Gtk3 documentation](https://docs.gtk.org/gtk3/) + - [Gtk4 documentation]() (elementary OS does not use Gtk4 yet but since elementary OS apps are Flatpaks, you can, if you like, use it in your own apps. Note that this will currently result in a large download if the person downloading your app doesn’t already have the Gtk4 platform image installed. Here’s [a good guide if you want to use Gtk4 in your apps today](https://mrmonkington.github.io/how-to-build-an-only-slightly-less-than-trivial-gtk4-app-using-flatpak.html). Bear in mind that elementary OS will move to Gtk4 eventually so it’s good to start learning about it today.) + - The elementary OS core projects – [Code](https://github.com/elementary/code/), [Calculator](https://github.com/elementary/calculator), [Tasks](https://github.com/elementary/tasks), [Calendar](https://github.com/elementary/calendar), etc. – are a valuable learning resource. Read through the code to see how they do things. (See [elementary OS on GitHub](https://github.com/elementary) for more.) + +## Similar projects + + - [Valdo](https://github.com/Prince781/valdo) by [Princeton Ferro](https://github.com/Prince781) (of Vala Language Server fame. Make sure you watch his excellent [elementary Developer Weekend](https://edw.elementary.io) talk on [Improving App Development in Vala](https://edw.elementary.io/#improving-app-development-in-vala-by-princeton-ferro)). Valdo is an app that helps you create a new Vala project from a repository of templates. Valdo is not designed specifically for elementary OS but it does feature an elementary OS app template. + + - [Develop](https://github.com/alcadica/develop) is an app for elementary OS 5 (Hera) that has starters for apps, [Switchboard](https://github.com/elementary/switchboard) [Plugs](https://github.com/elementary?q=switchboard-plug#org-repositories), and [Wingpanel](https://github.com/elementary/wingpanel) indicators. + +## Get the wallpaper + +The wallpaper you see in the screencast was commissioned for Watson from the singular [Margo de Weerdt](https://www.margodeweerdt.com/). And you’re welcome to download and use it in all its 4K glory on your own computer if you like. + +There are three versions: The one you see in the header has a very shallow depth of field (what the cool kids call “bokeh”) There is also one with less bokeh as well as the original illustration by Margo without any of Aral’s meddling. + +All three are released under the [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-nc-sa/4.0/). Please credit [Margo de Weerdt](https://www.margodeweerdt.com/) and [Watson](https://github.com/small-tech/watson) by [Small Technology Foundation](https://small-tech.org). + +### Original + +![Illustration, Sherlock Holmes, Watson, Enola Holmes and the three cats from Catts are in a swamp full of alligators. Sherlock is standing on a makeshift wooden bridge examining a bird (one foot on an alligator’s nose). Watson is in the swamp gathering more wood for the bridge. Enola and the blue cat are in a row boat in the background. The purple and green cats are on branches.](https://small-tech.org/downloads/watson/wallpaper/watson-wallpaper-4k-by-margo-de-weerdt-small-technology-foundation.jpg) + +### Shallower depth of field + +![The same illustration as described in the original one, above, but with the background blurred.](https://small-tech.org/downloads/watson/wallpaper/watson-wallpaper-4k-shallow-depth-of-field-by-margo-de-weerdt-small-technology-foundation.jpg) + +### Even shallower depth of field (did someone say bokeh?) + +![The same illustration as described in the shallower depth of field version, above, but with even shallower depth of field.](https://small-tech.org/downloads/watson/wallpaper/watson-wallpaper-4k-even-shallower-depth-of-field-by-margo-de-weerdt-and-aral-balkan-small-technology-foundation.jpg) + + + +## Like this? Fund us! + +[Small Technology Foundation](https://small-tech.org) is a tiny, independent not-for-profit. + +We exist in part thanks to patronage by people like you. If you share [our vision](https://small-tech.org/about/#small-technology) and want to support our work, please [become a patron or donate to us](https://small-tech.org/fund-us) today and help us continue to exist. + +## Copyright + +© 2021-present [Aral Balkan](https://ar.al), [Small Technology Foundation](https://small-tech.org). + +## License + +[GPL version 3.0](./LICENSE) diff --git a/template/.editorconfig b/template/.editorconfig new file mode 100644 index 0000000..7a05377 --- /dev/null +++ b/template/.editorconfig @@ -0,0 +1,17 @@ +# EditorConfig +# Based on https://docs.elementary.io/develop/writing-apps/code-style#editorconfig +root = true + +# elementary defaults +[*] +charset = utf-8 +end_of_line = lf +indent_size = tab +indent_style = space +insert_final_newline = true +max_line_length = 80 +tab_width = 4 + +# Markup files +[{*.html,*.xml,*.xml.in,*.yml}] +tab_width = 2 diff --git a/template/.github/workflows/main.yml b/template/.github/workflows/main.yml new file mode 100644 index 0000000..46de4d1 --- /dev/null +++ b/template/.github/workflows/main.yml @@ -0,0 +1,37 @@ +name: CI + +# This workflow will run for any pull request or pushed commit +on: [push, pull_request] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "flatpak" + flatpak: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # This job runs in a special container designed for building Flatpaks for AppCenter + container: + image: ghcr.io/elementary/flatpak-platform/runtime:6 + options: --privileged + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so the job can access it + - uses: actions/checkout@v2 + + # Builds your flatpak manifest using the Flatpak Builder action + - uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v3 + with: + # This is the name of the Bundle file we're building and can be anything you like + bundle: {APP.NAMESPACE}.flatpak + # This uses your app's RDNN ID + manifest-path: com.github.{GITHUB.ORG}.{GITHUB.APP}.yml + + # You can automatically run any of the tests you've created as part of this workflow + run-tests: true + + # These lines specify the location of the elementary Runtime and Sdk + repository-name: appcenter + repository-url: https://flatpak.elementary.io/repo.flatpakrepo + cache-key: "flatpak-builder-${{ github.sha }}" diff --git a/template/.gitignore b/template/.gitignore new file mode 100644 index 0000000..41eb75d --- /dev/null +++ b/template/.gitignore @@ -0,0 +1,3 @@ +build/ +builddir/ +.flatpak-builder/ diff --git a/template/.vscode/extensions.json b/template/.vscode/extensions.json new file mode 100644 index 0000000..fda0f11 --- /dev/null +++ b/template/.vscode/extensions.json @@ -0,0 +1,9 @@ +{ + "recommendations": [ + "prince781.vala", + "asabil.meson", + "vadimcn.vscode-lldb", + "redhat.vscode-xml", + "redhat.vscode-yaml" + ] +} diff --git a/template/.vscode/launch.json b/template/.vscode/launch.json new file mode 100644 index 0000000..4b1e93f --- /dev/null +++ b/template/.vscode/launch.json @@ -0,0 +1,25 @@ +{ + // To launch and debug your app in VSCodium, press F5 + // (or press the start debugging/play button on + // the Run and Debug view.) + // + // Note: you must install the CodeLLDB VSCodium + // ===== extension and have run the Meson: Build task + // for this to work. (To install all necessary + // extensions, including Meson and Vala, run the + // tasks/setup-vscodium task.) + // + // For more information on Launch configurations, see: + // https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug", + "program": "${workspaceFolder}/build/com.github.{GITHUB.ORG}.{GITHUB.APP}", + "args": [], + "cwd": "${workspaceFolder}" + } + ] +} diff --git a/template/CHANGELOG.md b/template/CHANGELOG.md new file mode 100644 index 0000000..9f496ef --- /dev/null +++ b/template/CHANGELOG.md @@ -0,0 +1,11 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.0.0] - YYYY-MM-DD (In progress…) + +### Added + + - Initial release. diff --git a/template/LICENSE b/template/LICENSE new file mode 100644 index 0000000..d51a540 --- /dev/null +++ b/template/LICENSE @@ -0,0 +1,225 @@ +GNU GENERAL PUBLIC LICENSE + +Version 3, 29 June 2007 + +Copyright © 2007 Free Software Foundation, Inc. + +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. + + + Copyright (C) + + 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 . + +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: + + Copyright (C) + 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 . + +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 . diff --git a/template/README.md b/template/README.md new file mode 100644 index 0000000..e4bfa64 --- /dev/null +++ b/template/README.md @@ -0,0 +1,110 @@ +# {APP.NAME} + +![{APP.NAME} icon](./data/128.svg) + +{APP.DESCRIPTION} + +[![Get it on AppCenter](https://appcenter.elementary.io/badge.svg)](https://appcenter.elementary.io/com.github.{GITHUB.ORG}.{GITHUB.APP}]) + +## System requirements + + - [Elementary OS](https://elementary.io) 6 (Odin) + +## Developer notes + +### Getting started + +Clone this repository and run the install task: + +```shell +task/install +``` + +You can now run the app from either the _Applications Menu_ or using the run task: + +```shell +task/run +``` + +### About + +This project is written in [Vala](https://valadoc.org/) and follows the following elementary OS guidelines: + + - [Human Interface Guidelines](https://docs.elementary.io/hig/) + - [Developer Guidelines](https://docs.elementary.io/develop/) + - [Coding style](https://docs.elementary.io/develop/writing-apps/code-style) + +Please take some time to familiarise yourself with those documents before continuing. + +To get your system ready to develop for elementary OS, please see the [Basic Setup](https://docs.elementary.io/develop/writing-apps/the-basic-setup) section of the [elementary OS Developer Documentation](https://docs.elementary.io/develop/). + +### Tasks + +#### Install + +Configures and runs the build, installing settings-relateds features and also refreshing the icon cache. + +Run this after you clone this repository to get a working build. + +```shell +task/install +``` + +#### Build + +Builds the project. + +```shell +task/build +``` + + +#### Run + +Builds and runs the executable. + +```shell +task/run +``` + +#### Pack + +Creates a Flatpak distribution. + +```shell +task/pack +``` + +### VSCodium + +You do _not_ need to use [VSCodium](https://vscodium.com) to create elementary OS apps. + +You can, for instance, use elementary OS [Code](https://docs.elementary.io/develop/writing-apps/the-basic-setup#code), which comes preinstalled, or a different third-party editor like [Builder](https://apps.gnome.org/en/app/org.gnome.Builder/). + +However, if you do have VSCodium installed, there are a number of extensions that will make creating your elementary OS app easier: + + - [Vala](https://github.com/Prince781/vala-vscode) (`codium --install-extension prince781.vala`) + - [Meson](https://github.com/asabil/vscode-meson) (`codium --install-extension asabil.meson`) + - [CodeLLDB](https://github.com/vadimcn/vscode-lldb) (`codium --install-extension vadimcn.vscode-lldb`) + - [XML](https://github.com/redhat-developer/vscode-xml) (`codium --install-extension redhat.vscode-xml`) + - [YAML](https://github.com/redhat-developer/vscode-yaml) (`codium --install-extension redhat.vscode-yaml`) + +If you have the Meson and CodeLLDB extensions installed, you can run and debug the app using the Run and Debug feature (or just hit F5.) + +## Continuous integration + +[Continuous Integration](https://docs.elementary.io/develop/writing-apps/our-first-app/continuous-integration) is set up for this repository. + +## Submitting the app + +Please make sure you [review the AppCenter publishing requirements](https://docs.elementary.io/develop/appcenter/publishing-requirements) before [submitting the app](https://developer.elementary.io/) to the [elementary OS AppCenter](https://appcenter.elementary.io/). + +## It’s elementary, my dear… + +This project was initially generated by [Watson](https://github.com/small-tech/watson), a tool for quickly setting up a new elementary OS 6 app that follows platform [human interface](https://docs.elementary.io/hig/) and [development](https://docs.elementary.io/develop/) guidelines. + +## Copyright and license + +Copyright © {COPYRIGHT.YEAR}-present {COPYRIGHT.NAME} + +Licensed under [GNU GPL version 3.0](./LICENSE). diff --git a/template/com.github.ORG.APP.yml b/template/com.github.ORG.APP.yml new file mode 100644 index 0000000..5362a52 --- /dev/null +++ b/template/com.github.ORG.APP.yml @@ -0,0 +1,22 @@ +app-id: com.github.{GITHUB.ORG}.{GITHUB.APP} + +runtime: io.elementary.Platform +runtime-version: '6' +sdk: io.elementary.Sdk + +command: com.github.{GITHUB.ORG}.{GITHUB.APP} + +finish-args: + - '--share=ipc' + - '--socket=fallback-x11' + - '--socket=wayland' + + # Needed to read prefer-color-scheme with Granite.Settings + - '--system-talk-name=org.freedesktop.Accounts' + +modules: + - name: {GITHUB.APP} + buildsystem: meson + sources: + - type: dir + path: . diff --git a/template/data/128.svg b/template/data/128.svg new file mode 100644 index 0000000..ffc11e8 --- /dev/null +++ b/template/data/128.svg @@ -0,0 +1,502 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/template/data/16.svg b/template/data/16.svg new file mode 100644 index 0000000..ebad831 --- /dev/null +++ b/template/data/16.svg @@ -0,0 +1,382 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/template/data/24.svg b/template/data/24.svg new file mode 100644 index 0000000..b72f0c1 --- /dev/null +++ b/template/data/24.svg @@ -0,0 +1,412 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/template/data/32.svg b/template/data/32.svg new file mode 100644 index 0000000..7ce7538 --- /dev/null +++ b/template/data/32.svg @@ -0,0 +1,414 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/template/data/48.svg b/template/data/48.svg new file mode 100644 index 0000000..d935433 --- /dev/null +++ b/template/data/48.svg @@ -0,0 +1,428 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/template/data/64.svg b/template/data/64.svg new file mode 100644 index 0000000..6172541 --- /dev/null +++ b/template/data/64.svg @@ -0,0 +1,413 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/template/data/APP.appdata.xml.in b/template/data/APP.appdata.xml.in new file mode 100644 index 0000000..1cc2c63 --- /dev/null +++ b/template/data/APP.appdata.xml.in @@ -0,0 +1,17 @@ + + + + com.github.{GITHUB.ORG}.{GITHUB.APP} + CC0 + + + {APP.NAME} + {APP.DESCRIPTION} + +

{APP.DESCRIPTION}

+
+
diff --git a/template/data/APP.desktop.in b/template/data/APP.desktop.in new file mode 100644 index 0000000..4bf77e9 --- /dev/null +++ b/template/data/APP.desktop.in @@ -0,0 +1,12 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name={APP.NAME} +GenericName={APP.GENERIC_NAME} +Comment={APP.COMMENT} +Categories={APP.CATEGORIES} +Exec=com.github.{GITHUB.ORG}.{GITHUB.APP} +Icon=com.github.{GITHUB.ORG}.{GITHUB.APP} +Terminal=false +Keywords={APP.KEYWORDS} +X-GNOME-UsesNotifications=true diff --git a/template/data/gresource.xml b/template/data/gresource.xml new file mode 100644 index 0000000..57fbb7d --- /dev/null +++ b/template/data/gresource.xml @@ -0,0 +1,11 @@ + + + + diff --git a/template/data/gschema.xml b/template/data/gschema.xml new file mode 100644 index 0000000..f94e6cf --- /dev/null +++ b/template/data/gschema.xml @@ -0,0 +1,25 @@ + + + + + + + + + + "Normal" + The saved state of the window. + The saved state of the window. + + + (-1, -1) + Window position + Most recent window position (x, y) + + + (420, 420) + Most recent window size + Most recent window size (width, height) + + + diff --git a/template/data/meson.build b/template/data/meson.build new file mode 100644 index 0000000..15d1e09 --- /dev/null +++ b/template/data/meson.build @@ -0,0 +1,5 @@ +install_data ( + 'gschema.xml', + install_dir: get_option('datadir') / 'glib-2.0' / 'schemas', + rename: meson.project_name() + '.gschema.xml' +) diff --git a/template/meson.build b/template/meson.build new file mode 100644 index 0000000..36005b6 --- /dev/null +++ b/template/meson.build @@ -0,0 +1,72 @@ +project('com.github.{GITHUB.ORG}.{GITHUB.APP}', 'vala', 'c') + +i18n = import('i18n') +gnome = import('gnome') + +add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), language: 'c') + +# Custom resource support. +# Place custom icons, etc. in the data/ directory +# and add them to data/gresource.xml. +gresource = gnome.compile_resources( + 'gresource', + 'data' / 'gresource.xml', + source_dir: 'data' +) + +executable( + meson.project_name(), + gresource, + 'src' / 'Application.vala', + 'src' / 'MainWindow.vala', + 'src' / 'Widgets' / 'HeaderBar.vala', + dependencies: [ + dependency('granite', version: '>=5.2.4'), + dependency('gtk+-3.0'), + dependency('libhandy-1', version: '>=0.90.0'), + meson.get_compiler('vala').find_library('posix') + ], + install: true +) + +# Translate and install our .desktop file. +i18n.merge_file( + input: 'data' / '{GITHUB.APP}.desktop.in', + output: meson.project_name() + '.desktop', + po_dir: meson.source_root() / 'po', + type: 'desktop', + install: true, + install_dir: get_option('datadir') / 'applications' +) + +# Translate and install our .appdata file. +i18n.merge_file( + input: 'data' / '{GITHUB.APP}.appdata.xml.in', + output: meson.project_name() + '.appdata.xml', + po_dir: meson.source_root() / 'po', + install: true, + install_dir: get_option('datadir') / 'metainfo' +) + +icon_sizes = ['16', '24', '32', '48', '64', '128'] + +foreach i : icon_sizes + install_data( + 'data' / i + '.svg', + install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i / 'apps', + rename: meson.project_name() + '.svg' + ) + install_data( + 'data' / i + '.svg', + install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i + '@2' / 'apps', + rename: meson.project_name() + '.svg' + ) +endforeach + +# Also execute the build files from the translation +# and data subdirectories. +subdir('po') +subdir('data') + +# Execute post install script to compile gsettings schemas. +meson.add_install_script('meson/post_install.py') diff --git a/template/meson/post_install.py b/template/meson/post_install.py new file mode 100644 index 0000000..e5f0da5 --- /dev/null +++ b/template/meson/post_install.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +import os +import subprocess +print(os.environ) + +schemadir = os.path.join(os.environ['MESON_INSTALL_PREFIX'], 'share', 'glib-2.0', 'schemas') + +if not os.environ.get('DESTDIR'): + print('Compiling gsettings schemas…') + subprocess.call(['glib-compile-schemas', schemadir]) diff --git a/template/po/LINGUAS b/template/po/LINGUAS new file mode 100644 index 0000000..d4e2759 --- /dev/null +++ b/template/po/LINGUAS @@ -0,0 +1,2 @@ +fr +tr diff --git a/template/po/POTFILES b/template/po/POTFILES new file mode 100644 index 0000000..0ace8ae --- /dev/null +++ b/template/po/POTFILES @@ -0,0 +1,3 @@ +src/Application.vala +data/{GITHUB.APP}.desktop.in +data/{GITHUB.APP}.appdata.xml.in diff --git a/template/po/meson.build b/template/po/meson.build new file mode 100644 index 0000000..cf8fe0b --- /dev/null +++ b/template/po/meson.build @@ -0,0 +1,5 @@ +i18n.gettext( + meson.project_name(), + args: '--directory=' + meson.source_root(), + preset: 'glib' +) diff --git a/template/src/Application.vala b/template/src/Application.vala new file mode 100644 index 0000000..df59f00 --- /dev/null +++ b/template/src/Application.vala @@ -0,0 +1,37 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: {COPYRIGHT.YEAR} {COPYRIGHT.NAME} <{COPYRIGHT.EMAIL}> + */ + +namespace {APP.NAMESPACE} { + public GLib.Settings saved_state; + + public class Application : Gtk.Application { + + public Application () { + Object( + application_id: "com.github.{GITHUB.ORG}.{GITHUB.APP}", + flags: ApplicationFlags.FLAGS_NONE + ); + + saved_state = new GLib.Settings ("com.github.{GITHUB.ORG}.{GITHUB.APP}.saved-state"); + } + + protected override void activate () { + // Ensure there is only one window and show it. + MainWindow window; + unowned List windows = get_windows (); + if (windows.length () > 0) { + window = windows.last ().data as MainWindow; + window.present (); + } else { + window = new MainWindow (this); + window.show (); + }; + } + + public static int main (string[] commandline_arguments) { + return new Application ().run (commandline_arguments); + } + } +} diff --git a/template/src/MainWindow.vala b/template/src/MainWindow.vala new file mode 100644 index 0000000..68f56ca --- /dev/null +++ b/template/src/MainWindow.vala @@ -0,0 +1,216 @@ +namespace {APP.NAMESPACE} { + public class MainWindow : Hdy.ApplicationWindow { + public weak {APP.NAMESPACE}.Application app { get; construct; } + + // Widgets + public {APP.NAMESPACE}.Widgets.HeaderBar toolbar; + + public const string ACTION_PREFIX = "win."; + public const string ACTION_FULLSCREEN = "action_fullscreen"; + public const string ACTION_QUIT = "action_quit"; + + public SimpleActionGroup actions { get; set; } + public static Gee.MultiMap action_accelerators = new Gee.HashMultiMap (); + + public enum WindowState { + NORMAL = 0, + MAXIMIZED = 1, + FULLSCREEN = 2 + } + + private const ActionEntry[] ACTION_ENTRIES = { + { ACTION_FULLSCREEN, action_fullscreen }, + { ACTION_QUIT, action_quit }, + }; + + private static void define_action_accelerators () { + // Define action accelerators (keyboard shortcuts). + action_accelerators.set (ACTION_FULLSCREEN, "F11"); + action_accelerators.set (ACTION_QUIT, "q"); + } + + public MainWindow ({APP.NAMESPACE}.Application application) { + Object ( + // We must set the inherited application property for Hdy.ApplicationWindow + // to initialise properly. However, this is not a set-type property (get; set;) + // so the assignment is made after construction, which means that we cannot + // reference the application during the construct method. This is why we also + // declare a property called app that is construct-type (get; construct;) which + // is assigned before the constructors are run. + // + // So use the app property when referencing the application instance from + // the constructors. Anywhere else, they can be used interchangably. + app: application, + application: application, // DON’T use in constructors; won’t have been assigned yet. + height_request: 420, + width_request: 420, + hide_titlebar_when_maximized: true, // FIXME: This does not seem to have an effect. Why not? + icon_name: "com.github.{GITHUB.ORG}.{GITHUB.APP}" + ); + } + + // This constructor is guaranteed to be run only once during the lifetime of the application. + static construct { + // Initialise the Handy library. + // https://gnome.pages.gitlab.gnome.org/libhandy/ + // (Apps in elementary OS 6 use the Handy library extensions + // instead of GTKApplicationWindow, etc., directly.) + Hdy.init(); + + // Define acclerators (keyboard shortcuts) for actions. + MainWindow.define_action_accelerators (); + } + + // This constructor will be called every time an instance of this class is created. + construct { + // Use the person’s preferred color scheme. + // See: https://docs.elementary.io/develop/apis/color-scheme + use_preferred_color_scheme (); + + // State preservation: save window dimensions and location on window close. + // See: https://docs.elementary.io/hig/user-workflow/closing + set_up_state_preservation (); + + // State preservation: restore window dimensions and location from last run. + // See https://docs.elementary.io/hig/user-workflow/normal-launch#state + restore_window_state (); + + // Create window layout. + create_layout (); + + // Set up actions (with accelerators) for full screen, quit, etc. + set_up_actions (); + + // Make all widgets (the interface) visible. + show_all (); + } + + // Layout. + + private void create_layout () { + // Unlike GTK, in Handy, the header bar is added to the window’s content area. + // See https://gnome.pages.gitlab.gnome.org/libhandy/doc/1-latest/HdyHeaderBar.html + toolbar = new {APP.NAMESPACE}.Widgets.HeaderBar (); + var grid = new Gtk.Grid (); + grid.attach (toolbar, 0, 0); + + // Add other components to go under the toolbar here. + + add (grid); + } + + // State preservation. + + private void set_up_state_preservation () { + // Before the window is deleted, preserve its state. + delete_event.connect (() => { + preserve_window_state (); + return false; + }); + + // Quit gracefully (ensuring state is preserved) when SIGINT or SIGTERM is received + // (e.g., when run from terminal and terminated using Ctrl+C). + Unix.signal_add (Posix.Signal.INT, quit_gracefully, Priority.HIGH); + Unix.signal_add (Posix.Signal.TERM, quit_gracefully, Priority.HIGH); + } + + private void restore_window_state () { + var rect = Gdk.Rectangle (); + {APP.NAMESPACE}.saved_state.get ("window-size", "(ii)", out rect.width, out rect.height); + + default_width = rect.width; + default_height = rect.height; + + var window_state = {APP.NAMESPACE}.saved_state.get_enum ("window-state"); + switch (window_state) { + case WindowState.MAXIMIZED: + maximize (); + break; + case WindowState.FULLSCREEN: + fullscreen (); + break; + default: + {APP.NAMESPACE}.saved_state.get ("window-position", "(ii)", out rect.x, out rect.y); + if (rect.x != -1 && rect.y != -1) { + move (rect.x, rect.y); + } + break; + } + } + + private void preserve_window_state () { + // Persist window dimensions and location. + var state = get_window ().get_state (); + if (Gdk.WindowState.MAXIMIZED in state) { + {APP.NAMESPACE}.saved_state.set_enum ("window-state", WindowState.MAXIMIZED); + } else if (Gdk.WindowState.FULLSCREEN in state) { + {APP.NAMESPACE}.saved_state.set_enum ("window-state", WindowState.FULLSCREEN); + } else { + {APP.NAMESPACE}.saved_state.set_enum ("window-state", WindowState.NORMAL); + // Save window size + int width, height; + get_size (out width, out height); + {APP.NAMESPACE}.saved_state.set ("window-size", "(ii)", width, height); + } + + int x, y; + get_position (out x, out y); + {APP.NAMESPACE}.saved_state.set ("window-position", "(ii)", x, y); + } + + // Color scheme. + + private void use_preferred_color_scheme () { + // Set color scheme of app based on person’s preference. + var granite_settings = Granite.Settings.get_default (); + var gtk_settings = Gtk.Settings.get_default (); + gtk_settings.gtk_application_prefer_dark_theme + = granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK; + + // Listen for changes in person’s color scheme settings + // and update color scheme of app accordingly. + granite_settings.notify["prefers-color-scheme"].connect (() => { + gtk_settings.gtk_application_prefer_dark_theme + = granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK; + }); + } + + // Actions. + + private void set_up_actions () { + // Setup actions and their accelerators. + actions = new SimpleActionGroup (); + actions.add_action_entries (ACTION_ENTRIES, this); + insert_action_group ("win", actions); + + foreach (var action in action_accelerators.get_keys ()) { + var accels_array = action_accelerators[action].to_array (); + accels_array += null; + + app.set_accels_for_action (ACTION_PREFIX + action, accels_array); + } + } + + // Action handlers. + + private void action_fullscreen () { + if (Gdk.WindowState.FULLSCREEN in get_window ().get_state ()) { + unfullscreen (); + } else { + fullscreen (); + } + } + + private void action_quit () { + preserve_window_state (); + destroy (); + } + + // Graceful shutdown. + + public bool quit_gracefully () { + action_quit (); + return false; + } + } +} diff --git a/template/src/Widgets/HeaderBar.vala b/template/src/Widgets/HeaderBar.vala new file mode 100644 index 0000000..408c4ba --- /dev/null +++ b/template/src/Widgets/HeaderBar.vala @@ -0,0 +1,12 @@ +namespace {APP.NAMESPACE}.Widgets { + public class HeaderBar : Hdy.HeaderBar { + public HeaderBar () { + Object ( + title: _("{APP.NAME}"), + has_subtitle: false, + show_close_button: true, + hexpand: true + ); + } + } +} diff --git a/template/task/build b/template/task/build new file mode 100755 index 0000000..98e4fda --- /dev/null +++ b/template/task/build @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -eu -o pipefail + +pushd build +ninja +popd + +echo '{APP.NAME} is built.' +echo '' +echo 'Run it with:' +echo 'build/com.github.{GITHUB.ORG}.{GITHUB.APP}' diff --git a/template/task/install b/template/task/install new file mode 100755 index 0000000..94fd1cf --- /dev/null +++ b/template/task/install @@ -0,0 +1,131 @@ +#!/usr/bin/env bash + +###################################################################### +# +# Intended usage for onboarding developers: +# +# 1. Clone this repository +# 2. Run task/install +# 3. Run task/run +# +# And you should see this project running successfully on your machine. +# (If you do not, please file an issue and let us know.) +# +# The install task: +# +# - Asks to install the elementary OS development libraries +# if they don’t already exist on your machine. +# +# - Asks to install recommended VSCodium Vala development and debugging +# extensions (Vala, Meson, CodeLLDB, XML, YAML) if you have VSCodium +# installed and are missing any of them. +# +# - Installs all required dependencies for the project to compile. +# +# - Configures the Meson build. +# +# - Builds and installs the application using Ninja. +# +# - Updates your system’s icon cache so the application icon displays +# properly in the Applications Menu and elsewhere. +# +###################################################################### + +set -eu -o pipefail + +# Ask to install the elementary OS development libraries +# if they don’t already exist on your machine. + +elementary_sdk_status=$(/usr/bin/dpkg-query --show --showformat='${db:Status-Status}\n' 'elementary-sdk' 2> /dev/null) +if [[ $elementary_sdk_status != 'installed' ]]; then + install_elementary_sdk_question=$(zenity --question --text='The elementary OS development libraries are not installed.\n\nInstall them now?' --title='Watson' --width=250 --icon-name=applications-development) + install_extensions=$? + if [[ $install_extensions == 0 ]]; then + sudo apt install elementary-sdk + fi +else + echo '✓ elementary OS development libraries found.' +fi + +# Ask to install recommended VSCodium Vala development and debugging +# extensions (Vala, Meson, CodeLLDB, XML, YAML) if you have VSCodium +# installed and are missing any of them. + +which_vscodium=$(which codium) +vscodium_exists=$? +if [[ ${vscodium_exists} == 0 ]]; then + # VSCodium is installed. Are all the extensions already installed? If so, + # we don’t need to bother the person with this. + already_installed_extensions_count=$(codium --list-extensions | grep -E "prince781.vala|asabil.meson|vadimcn.vscode-lldb|redhat.vscode-xml|redhat.vscode-yaml" | wc -l) + if [[ ${already_installed_extensions_count} != 5 ]]; then + # VSCodium is installed but one or more of the extensions that would + # make the person’s life easier aren’t. Ask the person if they’d + # like to have Watson install them. + install_extensions_question=$(zenity --question --text='Install VSCodium extensions?\n\n(This will install the Vala, Meson, CodeLLDB debugger, XML, and YAML extensions. With the extensions installed, press F5 in VSCodium to run/debug your app.)' --title='Watson' --width=250 --icon-name=extension) + install_extensions=$? + if [[ $install_extensions == 0 ]]; then + # Vala + # https://github.com/Prince781/vala-vscode + codium --install-extension prince781.vala + + # Meson + # https://github.com/asabil/vscode-meson + codium --install-extension asabil.meson + + # CodeLLDB: a native debugger extension based on LLDB. + # https://github.com/vadimcn/vscode-lldb + codium --install-extension vadimcn.vscode-lldb + + # XML + # https://github.com/redhat-developer/vscode-xml + codium --install-extension redhat.vscode-xml + + # YAML + # https://github.com/redhat-developer/vscode-yaml + codium --install-extension redhat.vscode-yaml + fi + else + echo '✓ VSCodium and all recommended extensions already installed.' + fi +else + echo 'ℹ️ VSCodium not installed; skipping recommended extensions check.' +fi + +# Install dependencies. + +# If your app has any third-party dependencies that are not included in +# the elementary OS Software Development Kit (SDK) metapackage, add installation +# commands for them here. +# +# For a list of the packages that are included in the elementary OS SDK, see +# https://github.com/elementary/metapackages/blob/master/elementary-sdk-amd64 +# https://github.com/elementary/metapackages/blob/master/elementary-sdk-arm64 +# https://github.com/elementary/metapackages/blob/master/elementary-sdk-armhf + + + +# Configure build. +meson build --prefix=/usr + +# Create translations. + +# (This only needs to be done on initial project generation, otherwise it +# results in a dirty git repository due to timestamps if run after a clone. +# The default is not to create/update translations on install.) +if [[ ${1-'do-not-create-translations'} == '--create-translations' ]]; then + task/update-translations --no-status + echo '✓ Created translations.' +fi + +# Run build and install assets. +pushd build +ninja +ninja install +popd + +# Clear icon caches. +sudo update-icon-caches /usr/share/icons/* + +echo '{APP.NAME} is installed.' +echo '' +echo 'You can run it from the Applications Menu or using the task/run script.' diff --git a/template/task/run b/template/task/run new file mode 100755 index 0000000..5032f3a --- /dev/null +++ b/template/task/run @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -eu -o pipefail + +pushd build +ninja +popd +build/com.github.{GITHUB.ORG}.{GITHUB.APP} diff --git a/template/task/update-translations b/template/task/update-translations new file mode 100755 index 0000000..17a458b --- /dev/null +++ b/template/task/update-translations @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -eu -o pipefail + +pushd build +ninja com.github.{GITHUB.ORG}.{GITHUB.APP}-pot +ninja com.github.{GITHUB.ORG}.{GITHUB.APP}-update-po +popd +if [[ $1 != '--no-status' ]]; then + git status +fi + +echo 'Translations updated.' +echo '' +echo 'Don’t forget to add and commit any' +echo 'new/changed files to your repository.' diff --git a/watson b/watson new file mode 100755 index 0000000..2b37110 --- /dev/null +++ b/watson @@ -0,0 +1,276 @@ +#!/usr/bin/env bash + +###################################################################### +# +# Watson version 1.0 +# +# “It’s elementary, my dear…” +# +# Watson helps you set up your new elementary OS Vala app. +# +# For details, please see: +# https://github.com/small-tech/watson +# +# Follows the Community Bash Style Guide. +# https://github.com/azet/community_bash_style_guide +# +# Copyright ⓒ 2021-present Aral Balkan (https://ar.al) +# Small Technology Foundation (https://small-tech.org) +# +# Like this? Fund us! +# https://small-tech.org/fund-us +# +# Released under GNU GPL version 3.0. +# +###################################################################### + +# set -eu -o pipefail + +function show_usage { + echo 'Usage: watson [--dryrun|-d|--help|-h]' +} + +function show_error { + message=$1 + show_clone_instructions=$2 + if [[ $show_clone_instructions == '--teach-how-to-use' ]]; then + show_usage + fi + echo '' + echo -e "❌ \033[41mERROR\033[0m ${message}" + if [[ $show_clone_instructions == '--teach-how-to-use' ]]; then + echo '' + echo 'To use Watson:' + echo '' + echo '1. Go to https://github.com/small-tech/watson' + echo '2. Press the green “Use this template” button to create a new repository from Watson.' + echo '3. Clone your new repository.' + echo '4. Switch to that repository.' + echo '5. Run ./watson' + fi + exit +} + +function show_help { + show_usage + exit +} + +function show_validation_error { + show_error 'All fields are required. Please re-run Watson and try again.' +} + +dryRun=false + +# Get the GitHub details from git itself. +gitRemote=($(git remote -v 2> /dev/null)) + +# Ensure current directory is a git working copy. +if [[ "$?" == "128" ]]; then + show_error 'The current directory is not a git working copy.' --teach-how-to-use +fi + +gitUrl=${gitRemote[1]} + +# This regular expression extracts the organisation +# and app from a GitHub remote URL (works on both SSH +# and HTTPS URLs.) +gitUrlRegExp='.*?github\.com.(.*?)/(.*?)\.git' + +# Execute the regular expression. +[[ $gitUrl =~ $gitUrlRegExp ]] + +# Get the GitHub organisation and app name from the +# regular expression results. +github_organisation_original="${BASH_REMATCH[1]}" +github_app_original="${BASH_REMATCH[2]}" + +# Ensure the developer hasn’t accidentally cloned +# The Watson repository instead of creating their own +# using the “use this template” button on GitHub to +# create their own repository based on Watson. +if [[ "${github_organisation_original}" == "small-tech" && "${github_app_original}" == "watson" ]]; then + show_error 'You currently have the original Watson repository cloned.' --teach-how-to-use +fi + +function dry_run { + dryRun=true + echo '⧼⧼⧼⧼⧼ Dry run ⧽⧽⧽⧽⧽' + echo '' + echo "Carries out substitutions, presents diff, reverts changes, and exits." +} + +# Apply flags, if any. +[[ $1 == '--dry-run' || $1 == '-d' ]] && dry_run +[[ $1 == '--help' || $1 == '-h' ]] && show_help + +current_step=1 +steps=('App Details (1/2)' 'App Details (2/2)' 'Copyright Details' 'Parse responses' 'Perform substitutions' 'Rename files' 'Configure, build, and install' 'Delete self' 'Commit and push changes' 'Exit') + +# Trap errors and handle them gracefully. +# +# $1: Line number of error. +# $2: Exit code of command that failed. +function handle_error { + printf "Step %d (%s)" $(( ${current_step} + 1 )) "${steps[${current_step}]}" + if (( current_step > 2 && current_step < 6 )); then + printf " cancelled.\n" + else + printf " failed on line $1.\n" + fi + exit $2 +} +trap 'handle_error ${LINENO} $? ' ERR + +# Constants + +readonly copyright_year=$(date '+%Y') + +# STEP 1: Get app details (1/2). + +app_details_pipe_separated=$(zenity --forms --height=260 --title="Watson" --text="\n App details (1/2)" --add-entry="Name:" --add-entry="Generic Name (e.g., Web Browser):" --add-entry="Description" --add-entry="Tooltip text (comment)" --add-entry="Keywords (separated;by;semicolons)") + +app_details_validator='^.+\|.+\|.+\|.+\|.+$' +[[ $app_details_pipe_separated =~ $app_details_validator ]] || show_validation_error + +current_step=$(( current_step + 1 )) + +# STEP 2: Get app details (2/2) – categories (multi-select list). + +app_categories=$(zenity --list --width=400 --height=460 --multiple --separator=";" --title="Watson" --text="\n App Details (2/2)\n\n You may select more than one.\n" --column="Category" "AudioVideo" "Audio" "Video" "Development" "Education" "Game" "Graphics" "Network" "Office" "Science" "Settings" "System" "Utility") + +app_categories_validator='^.+$' +[[ $app_categories =~ $app_categories_validator ]] || show_validation_error + +current_step=$(( current_step + 1 )) + +# STEP 3: Get copyright details. + +copyright_details_pipe_separated=$(zenity --forms --width=300 --title="Watson" --text="\n Copyright Details \n\n Copyright ⓒ ${copyright_year}-present ‹Name› ‹Email›\n" --add-entry="Name" --add-entry="Email") + +copyright_details_validator='^.+\|.+$' +[[ $copyright_details_pipe_separated =~ $copyright_details_validator ]] || show_validation_error + +current_step=$(( current_step + 1 )) + +# STEP 4: Parse responses. + +# Parse the pipe-separated results returned from the Zenity dialogues into bash arrays. +IFS='|' read -ra app_details <<< "${app_details_pipe_separated}" +IFS='|' read -ra copyright_details <<< "${copyright_details_pipe_separated}" + +# We replace any dashes in the desktop entry names with underscores for +# compatibility with D-Bus names. See: +# https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s02.html +# +# TODO: Also handle edge case of names that begin with numbers? (Prefix with an underscore.) +github_organisation=${github_organisation_original//'-'/'_'} +github_app=${github_app_original//'-'/'_'} + +app_name=${app_details[0]} +app_generic_name=${app_details[1]} +app_description=${app_details[2]} +app_comment=${app_details[3]} +app_keywords=${app_details[4]} + +# The namespace is calculated by removing spaces from the app name. +# As app names are capitalised by convention, this should lead to a namespace +# that conforms to Vala naming conventions on elementary OS. +app_namespace=$(echo "${app_name}" | sed s/[[:space:]]//g) + +copyright_name=${copyright_details[0]} +copyright_email=${copyright_details[1]} + +current_step=$(( current_step + 1 )) + +# STEP 5: Perform substitutions. + +# This is the list of files to carry out substituions in. +# These files are all in the template/ directory. +files=('com.github.ORG.APP.yml' 'meson.build' 'README.md' 'src/Widgets/HeaderBar.vala' 'src/Application.vala' 'src/MainWindow.vala' 'data/APP.appdata.xml.in' 'data/APP.desktop.in' 'data/gresource.xml' 'data/gschema.xml' 'po/POTFILES' 'task/build' 'task/install' 'task/run' 'task/update-translations' '.github/workflows/main.yml' '.vscode/launch.json') + +# Switch to the template directory. +pushd template + +# Carry out substitutions in configuration files and source code. +for file in "${files[@]}"; do + sed -i "s/{GITHUB.ORG}/${github_organisation}/g" "${file}" + sed -i "s/{GITHUB.APP}/${github_app}/g" "${file}" + sed -i "s/{APP.NAMESPACE}/${app_namespace}/g" "${file}" + sed -i "s/{APP.NAME}/${app_name}/g" "${file}" + sed -i "s/{APP.GENERIC_NAME}/${app_generic_name}/g" "${file}" + sed -i "s/{APP.DESCRIPTION}/${app_description}/g" "${file}" + sed -i "s/{APP.COMMENT}/${app_comment}/g" "${file}" + sed -i "s/{APP.CATEGORIES}/${app_categories}/g" "${file}" + sed -i "s/{APP.KEYWORDS}/${app_keywords}/g" "${file}" + sed -i "s/{COPYRIGHT.YEAR}/${copyright_year}/g" "${file}" + sed -i "s/{COPYRIGHT.NAME}/${copyright_name}/g" "${file}" + sed -i "s/{COPYRIGHT.EMAIL}/${copyright_email}/g" "${file}" +done + +# Commit our changes (so we can always see a clean diff of the substitutions). +git add --all +git commit -m "Carry out template substitutions" + +current_step=$(( current_step + 1 )) + +# STEP 6: Rename files. + +mv com.github.ORG.APP.yml "com.github.${github_organisation}.${github_app}.yml" +mv data/APP.appdata.xml.in "data/${github_app}.appdata.xml.in" +mv data/APP.desktop.in "data/${github_app}.desktop.in" + +# Switch back to the main directory, move all the files in the +# template directory to the main directory (overriding Watson’s +# own README, CHANGELOG, .gitignore, etc., in the process), and +# delete the now-empty template directory, thereby leaving the +# new app ready to be built in the next step. +popd +mv template/* . +mv template/.vscode . +mv template/.github . +mv template/.editorconfig . +rm -r template + +current_step=$(( current_step + 1 )) + +# STEP 7: Configure, build and install. + +task/install --create-translations + +current_step=$(( current_step + 1 )) + +# If this is a dry run (useful when developing/testing Watson itself), +# then display the git status and information on how to revert the changes, +# and exit without removing watson or replacing the git repository. +if ${dryRun}; then + git status + echo '' + echo '⧼⧼⧼⧼⧼ Dry run: complete. ⧽⧽⧽⧽⧽' + echo '' + echo 'See changes:' + echo 'git diff' + echo '' + echo 'Revert changes:' + echo 'git reset --hard HEAD && git clean -d -f' + exit +fi + +# Step 8: Delete self (goodbye, cruel world!) + +rm watson + +current_step=$(( current_step + 1 )) + +# Step 9: Commit and push changes. + +git add --all +git commit -m "Finish customising app template" +git push + +current_step=$(( current_step + 1 )) + +# Step 10: Exit. + +# That’s it! Goodbye :) +exit 0