├── .gitignore ├── COPYING ├── README.md ├── meson.build ├── src ├── config.vala.in ├── expression.vala ├── main.vala ├── meson.build ├── template.vala ├── templateengine.vala └── variable.vala └── templates ├── eos ├── .editorconfig ├── .github │ └── workflows │ │ └── ci.yml ├── README.md ├── com.github.${USERNAME}.${PROGRAM_NAME}.yml ├── data │ ├── 128.svg │ ├── 16.svg │ ├── 24.svg │ ├── 32.svg │ ├── 48.svg │ ├── 64.svg │ ├── com.github.${USERNAME}.${PROGRAM_NAME}.appdata.xml │ └── com.github.${USERNAME}.${PROGRAM_NAME}.desktop ├── meson.build ├── src │ └── Application.vala └── template.json ├── gnome ├── .editorconfig ├── .gitignore.in ├── COPYING ├── README.md ├── build-aux │ ├── flatpak │ │ └── ${APP_ID}.yaml │ └── meson │ │ ├── build-and-run.sh │ │ └── postinstall.py ├── data │ ├── ${APP_ID}.appdata.xml.in.in │ ├── ${APP_ID}.desktop.in.in │ ├── ${APP_ID}.gschema.xml.in │ ├── icons │ │ └── hicolor │ │ │ ├── scalable │ │ │ └── apps │ │ │ │ └── ${APP_ID}.svg │ │ │ └── symbolic │ │ │ └── apps │ │ │ └── ${APP_ID}-symbolic.svg │ └── meson.build ├── meson.build ├── po │ ├── LINGUAS │ ├── POTFILES │ └── meson.build ├── resources │ ├── ${APP_NAME}.gresource.xml │ ├── meson.build │ ├── style.css │ └── ui │ │ └── MainWindow.ui ├── src │ ├── Application.vala │ ├── MainWindow.vala │ └── meson.build ├── subprojects │ └── libadwaita.wrap ├── template.json └── vapi │ └── config.vapi ├── gtk ├── .editorconfig ├── README.md ├── meson.build ├── src │ ├── Main.vala │ ├── MainWindow.vala │ └── meson.build └── template.json ├── gtk3 ├── .editorconfig ├── README.md ├── meson.build ├── src │ ├── App.vala │ ├── MainWindow.vala │ └── meson.build ├── template.json └── ui │ ├── main-window.ui │ ├── meson.build │ └── resources.xml ├── lib ├── .editorconfig ├── README.md ├── meson.build ├── meson_options.txt ├── src │ ├── library.vala │ └── meson.build └── template.json ├── meson.build └── new ├── .editorconfig ├── README.md ├── meson.build ├── src ├── main.vala └── meson.build └── template.json /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | *.o 3 | *~ 4 | .vscode 5 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 489 | 490 | Also add information on how to contact you by electronic and paper mail. 491 | 492 | You should also get your employer (if you work as a programmer) or your 493 | school, if any, to sign a "copyright disclaimer" for the library, if 494 | necessary. Here is a sample; alter the names: 495 | 496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 498 | 499 | , 1 April 1990 500 | Ty Coon, President of Vice 501 | 502 | That's all there is to it! 503 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Valdo 2 | 3 | _(like "**Val**a **Do**", pronounced like "Waldo")_ 4 | 5 | Create a new Vala project from a repository of templates. 6 | 7 | ## Installation 8 | 9 | Packages are available for Fedora, Ubuntu, Debian, and more via 10 | [OBS](https://software.opensuse.org//download.html?project=home%3APrince781&package=valdo). 11 | 12 | To install from source, clone this repository and run: 13 | `meson build && meson install -C build` 14 | 15 | ## Example use 16 | 17 | `valdo new` - initializes a new project (from a template `new`) in the current directory 18 | 19 | `valdo gtk` - initializes a new GTK app 20 | 21 | `valdo lib` - initializes a new library 22 | 23 | `valdo` - lists all available templates 24 | 25 | ## Creating a new a template 26 | 27 | Templates should be added here so that they can be used by everyone. 28 | 29 | Fork this repository and add a new directory under `templates/`. The name of 30 | the directory is the template name. Then you need to add a `template.json` 31 | describing the template, the variables it uses, and the files that need to be 32 | substituted. 33 | 34 | Here is what a template might look like: 35 | 36 | ``` 37 | . 38 | ├── meson.build 39 | ├── README.md 40 | ├── src 41 | │   ├── main.vala 42 | │   └── meson.build 43 | └── template.json 44 | 45 | 1 directory, 5 files 46 | ``` 47 | 48 | Your `template.json` may start off looking like: 49 | 50 | ```json 51 | { 52 | "description": "a bare app, with minimal dependencies", 53 | "variables": { 54 | "PROGRAM_NAME": { 55 | "summary": "the name of the program", 56 | "default": "main" 57 | } 58 | }, 59 | "templates": [ 60 | "src/meson.build", 61 | "meson.build", 62 | "README.md" 63 | ] 64 | } 65 | ``` 66 | 67 | `"templates"` is a list of template files, containing variables to be 68 | substituted. 69 | 70 | `"variables"` is a dictionary mapping each variable name to a short 71 | description. Having a default value for a variable is optional. There are at 72 | least two variables every template uses, `PROJECT_NAME` and `PROJECT_VERSION`, 73 | which you don't have to specify. 74 | 75 | For every variable listed, the template engine will substitute 76 | `${VARIABLE_NAME}` in each templated file. If a variable does not have a 77 | default value, Valdo will prompt the user. The rest of the files in the 78 | template directory will be copied over unmodified. 79 | 80 | **Once you're done, submit a PR to https://github.com/vala-lang/valdo** 81 | 82 | ### Advanced template features 83 | 84 | #### Variable substitution 85 | 86 | You can define a variable's default value in terms of another variable like so: 87 | 88 | ```json 89 | { 90 | "variables": { 91 | "API_NAMESPACE": { 92 | "summary": "the API namespace", 93 | "default": "MyLib", 94 | "pattern": "^[A-Za-z][[:word:]]*$" 95 | }, 96 | "LIBRARY_NAME": { 97 | "summary": "the name of the library", 98 | "default": "/${API_NAMESPACE}/\\w+/\\L\\g<0>\\E/", 99 | "pattern": "^[[:word:]][[:word:]-]*$" 100 | }, 101 | "APP_ID": { 102 | "summary": "the application ID", 103 | "default": "com.${USERNAME}.${API_NAMESPACE}", 104 | "pattern": "^\\w+(\\.\\w+)*$" 105 | } 106 | } 107 | } 108 | ``` 109 | 110 | Here, this means that `LIBRARY_NAME` will be auto-generated from the namespace 111 | name, unless the user enters something different in a prompt [^1]. In this case, if 112 | the user enters nothing for `API_NAMESPACE` and `LIBRARY_NAME`, the result will 113 | be `mylib`. 114 | 115 | The syntax is to write the variable name, then a regular expression that 116 | matches something you want to replace, then a regular expression for the 117 | replacement. Here, `\L` says "make lowercase", `\g<0>` matches group 0 or the 118 | entire string matched, and `\E` ends the conversion. Consult the [docs for 119 | GLib.Regex.replace()](https://valadoc.org/glib-2.0/GLib.Regex.replace.html) for 120 | more information about how regex syntax is used in GLib. 121 | 122 | If you wanted to substitute another pattern in the text, you just have to add 123 | another pair of regexes separated by a `/`. For example: 124 | 125 | ``` 126 | "default": "/${API_NAMESPACE}/\\w+/\\L\\g<0>\\E/bob/greta/" 127 | ``` 128 | 129 | After converting everything to lowercase, then substitute "bob" for "greta". 130 | The substitutions will be applied in the order they appear, one after another. 131 | 132 | [^1]: You can specify `"auto": true` for the variable to make it completely 133 | automatic, so there's no prompting the user. This is useful when generating 134 | variable names in build scripts, for example. 135 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project('valdo', 'vala', 'c', 2 | version: '2022.04.14', 3 | license: 'LGPL-2.1-only') 4 | 5 | valac = meson.get_compiler('vala') 6 | 7 | deps = [ 8 | dependency('glib-2.0'), 9 | dependency('gobject-2.0'), 10 | dependency('gio-2.0'), 11 | dependency('json-glib-1.0') 12 | ] 13 | 14 | add_project_arguments([ 15 | '--fatal-warnings', 16 | '--enable-experimental', 17 | '--enable-experimental-non-null', 18 | ], language: 'vala') 19 | 20 | templates_dir = get_option('prefix') / get_option('datadir') / 'valdo' / 'templates' 21 | 22 | subdir('templates') 23 | subdir('src') 24 | -------------------------------------------------------------------------------- /src/config.vala.in: -------------------------------------------------------------------------------- 1 | namespace Config { 2 | const string TEMPLATES_DIR = "@DATA_DIR@"; 3 | const string VERSION = "@VCS_TAG@"; 4 | } 5 | -------------------------------------------------------------------------------- /src/expression.vala: -------------------------------------------------------------------------------- 1 | /* expression.vala 2 | * 3 | * Copyright 2021 Princeton Ferro 4 | * Copyright 2021 Gleb Smirnov 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 2.1 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | namespace Valdo.Expression { 21 | /** 22 | * Expand variables in string 23 | * 24 | * Variables must be in that form: ${}. 25 | * To prevent variable expansion 26 | * add another $ before. 27 | * 28 | * @param str string containing variables to expand 29 | * 30 | * @return string with variable values instead of variable names 31 | */ 32 | public string expand_variables (string str, 33 | HashTable variables) { 34 | var res = str; 35 | try { 36 | /* Expand variables */ 37 | res = /(? { 38 | var variable = (!) match.fetch (1); 39 | 40 | if (!(variable in variables)) { 41 | critical ("Variable \'%s\' doesn't exists", variable); 42 | return false; 43 | } 44 | 45 | builder.append (variables[variable]); 46 | 47 | return false; 48 | }); 49 | 50 | /* Unespace escaped variables */ 51 | res = /\$(\$\{(\w+)\})/.replace (res, res.length, 0, "\\1"); 52 | } catch (RegexError e) { 53 | critical ("Can't expand variables: %s", e.message); 54 | } 55 | 56 | return res; 57 | } 58 | 59 | 60 | /** 61 | * Evaluate expression in string 62 | * 63 | * Expression must have this form: 64 | * `value/regex/replacement/regex/replacement/...` 65 | * 66 | * Also variables can be used in expression. 67 | * 68 | * @param expression expression to evaluate 69 | * @param variables hash table of variable names and values 70 | * 71 | * @return result of expression evaluating 72 | */ 73 | public string evaluate (string expression, 74 | HashTable variables) { 75 | var res = expression; 76 | /* Evaluate regular expressions */ 77 | try { 78 | if (res[0] == '/' && res[res.length - 1] == '/') 79 | res = res[1:-1]; 80 | else 81 | return res; 82 | 83 | var replacement_regex = /(?(\\\/|[^\/])*)\/(?(\\\/|[^\/])*)\/(?(\\\/|[^\/])*)/; 84 | 85 | var matches = true; 86 | while (matches) { 87 | matches = false; 88 | res = replacement_regex.replace_eval ( 89 | res, 90 | res.length, 91 | 0, 92 | 0, 93 | (match, builder) => { 94 | matches = true; 95 | 96 | var input_string = expand_variables (((!) match.fetch_named ("input")).replace ("\\/", "/"), variables); 97 | var regex_string = ((!) match.fetch_named ("regex")).replace ("\\/", "/"); 98 | var replacement = expand_variables (((!) match.fetch_named ("replacement")).replace ("\\/", "/"), variables); 99 | 100 | try { 101 | var regex = new Regex (regex_string); 102 | builder.append (regex.replace (input_string, input_string.length, 0, replacement, 0)); 103 | } catch (RegexError e) { 104 | error ( 105 | "Can't do replacement `%s/%s/%s`: %s", 106 | input_string, 107 | regex_string, 108 | replacement, 109 | e.message 110 | ); 111 | } 112 | 113 | return true; 114 | } 115 | ); 116 | } 117 | } catch (RegexError e) { 118 | error ("Can't evaluate expression \'%s\': %s", expression, e.message); 119 | } 120 | 121 | return res; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/main.vala: -------------------------------------------------------------------------------- 1 | /* main.vala 2 | * 3 | * Copyright 2021 Princeton Ferro 4 | * Copyright 2021 Gleb Smirnov 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 2.1 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | namespace Valdo.Main { 21 | /** 22 | * Application name retrieved from arguments 23 | */ 24 | static string APP_NAME; 25 | 26 | /** 27 | * Command-line options 28 | */ 29 | private const OptionEntry[] ENTRIES = { 30 | { "version", 'v', OptionFlags.NONE, OptionArg.NONE, ref option_version, "Display version number", null }, 31 | 32 | /* Non-named argument is treated as name of template to use */ 33 | { OPTION_REMAINING, 0, OptionFlags.NONE, OptionArg.STRING_ARRAY, ref non_option_arguments, (string) null, "TEMPLATE" }, 34 | 35 | /* Array terminator */ 36 | { } 37 | }; 38 | 39 | /** 40 | * Whether --version option is used 41 | */ 42 | private bool option_version; 43 | 44 | /** 45 | * Non-option command-line arguments 46 | * 47 | * There should be only one such argument 48 | * representing template name to use 49 | */ 50 | [CCode (array_length = false, array_null_terminated = true)] 51 | private string[] non_option_arguments; 52 | 53 | /** 54 | * Initialize project from template 55 | * 56 | * @param template_name the name of template to use 57 | * 58 | * @return {@link true} on success, {@link false} otherwise 59 | */ 60 | bool initialize_project (string template_name) { 61 | var template_dir = File.new_build_filename (Config.TEMPLATES_DIR, template_name); 62 | 63 | if (!template_dir.query_exists ()) { 64 | stderr.printf ("Error: '%s' is not an available template.\n\n", template_name); 65 | stderr.printf ("Run '%s' to see a list of available templates.\n", APP_NAME); 66 | return false; 67 | } 68 | 69 | try { 70 | var variables = new HashTable (str_hash, str_equal); 71 | var template = Valdo.Template.new_from_directory (template_dir); 72 | 73 | stdout.printf ("Creating %s\n", template.description); 74 | 75 | var vars = Variable.list_pre_defined (); 76 | foreach (var variable in template.variables.data) 77 | vars.append_val (variable); 78 | 79 | foreach (var variable in vars.data) { 80 | string value; 81 | string? default_value; 82 | if (variable.default == null) 83 | default_value = null; 84 | else { 85 | default_value = Valdo.Expression.expand_variables ( 86 | Valdo.Expression.evaluate ( 87 | (!) variable.default, 88 | variables 89 | ), 90 | variables 91 | ); 92 | } 93 | 94 | while (true) { 95 | /* Print prompt */ 96 | if (!variable.auto) { 97 | stdout.printf ("Enter %s", variable.summary); 98 | if (default_value != null) 99 | stdout.printf (" [default=%s]", (!) default_value); 100 | stdout.printf (": "); 101 | } 102 | 103 | /* Don't ask for auto variables */ 104 | if (variable.auto) { 105 | if (default_value == null) 106 | error ("Can't get variable '%s': auto variables must have default value", variable.name); 107 | value = (!) default_value; 108 | break; 109 | } 110 | 111 | var user_input = stdin.read_line (); 112 | 113 | /* User sent EOF */ 114 | if (user_input == null) { 115 | stderr.printf ("\nProject initialization was terminated by user\n"); 116 | return false; 117 | } 118 | user_input = ((!) user_input).strip (); 119 | 120 | /* Use default if 121 | value not specified */ 122 | if (((!) user_input).length == 0) { 123 | if (default_value == null) { 124 | stderr.printf ("Please, specify %s\n", variable.summary); 125 | continue; 126 | } 127 | value = (!) default_value; 128 | } else { 129 | value = (!) user_input; 130 | } 131 | 132 | /* Verify input */ 133 | if (!new Regex (variable.pattern ?? "").match (value)) { 134 | stderr.printf ("Error: your entry must match the pattern: %s\n", (!) variable.pattern); 135 | continue; 136 | } 137 | 138 | break; 139 | } 140 | 141 | variables[variable.name] = value; 142 | } 143 | 144 | /* Now apply the template to the new directory */ 145 | string project_name = variables["PROJECT_DIR"]; 146 | return Valdo.TemplateEngine.apply_template ( 147 | template, 148 | File.new_for_path (Environment.get_current_dir ()), 149 | project_name, 150 | variables 151 | ); 152 | } catch (Error e) { 153 | error ("Can't initialize project from template: %s", e.message); 154 | } 155 | } 156 | 157 | /** 158 | * List available templates 159 | */ 160 | void list_templates () { 161 | var templates_dir = File.new_for_path (Config.TEMPLATES_DIR); 162 | var templates = new HashTable (str_hash, str_equal); 163 | int max_template_name_len = 0; 164 | 165 | try { 166 | var enumerator = templates_dir.enumerate_children ( 167 | FileAttribute.ID_FILE, 168 | FileQueryInfoFlags.NONE 169 | ); 170 | 171 | FileInfo? fileinfo; 172 | while ((fileinfo = enumerator.next_file ()) != null) { 173 | var template_name = ((!) fileinfo).get_name (); 174 | var template = Valdo.Template.new_from_directory (File.new_build_filename ( 175 | Config.TEMPLATES_DIR, template_name 176 | )); 177 | templates[template_name] = template.description; 178 | if (max_template_name_len < template_name.length) 179 | max_template_name_len = template_name.length; 180 | } 181 | } catch (Error e) { 182 | error ("Can't enumerate templates: %s", e.message); 183 | } 184 | 185 | if (templates.length != 0) { 186 | stdout.printf ("Available templates:\n"); 187 | stdout.printf ("--------------------\n"); 188 | 189 | foreach (unowned string name in templates.get_keys_as_array ()) 190 | print ("%s%s - %s\n", name, string.nfill (max_template_name_len - name.length, ' '), templates[name]); 191 | } else { 192 | stdout.printf ("There are no templates available.\n"); 193 | } 194 | } 195 | 196 | /** 197 | * Application entry point 198 | * 199 | * @param args command-line arguments 200 | * 201 | * @return result code 202 | */ 203 | int main (string[] args) { 204 | APP_NAME = args.length > 0 ? args[0] : "valdo"; 205 | 206 | /* Parse command-line options */ 207 | var ctx = new OptionContext ("- create a Vala project from a template"); 208 | 209 | ctx.set_summary (@"Run $(APP_NAME) without any args to list all available templates"); 210 | ctx.set_description ("Report bugs to https://github.com/Prince781/valdo/issues"); 211 | ctx.add_main_entries (ENTRIES, null); 212 | 213 | try { 214 | ctx.parse (ref args); 215 | } catch (Error e) { 216 | stderr.printf ("%s\n", e.message); 217 | stderr.printf ("Try '%s --help' for more information\n", APP_NAME); 218 | return 1; 219 | } 220 | 221 | /* --version/-v */ 222 | if (option_version) { 223 | stdout.printf ("%s %s\n", APP_NAME, Config.VERSION); 224 | return 0; 225 | } 226 | 227 | /* List tempaltes when are no arguments provided */ 228 | if (non_option_arguments.length == 0) { 229 | list_templates (); 230 | return 0; 231 | } 232 | 233 | /* Quit if not one template specified */ 234 | if (non_option_arguments.length > 1) { 235 | stderr.printf ("Usage: %s [TEMPLATE NAME]\n", APP_NAME); 236 | stderr.printf ("Try '%s --help' for more information\n", APP_NAME); 237 | return 1; 238 | } 239 | 240 | if (initialize_project (non_option_arguments[0])) 241 | return 0; 242 | else 243 | return 1; 244 | } 245 | } 246 | -------------------------------------------------------------------------------- /src/meson.build: -------------------------------------------------------------------------------- 1 | conf_data = configuration_data() 2 | conf_data.set('DATA_DIR', templates_dir) 3 | conf_data.set('VCS_TAG', '@VCS_TAG@') 4 | 5 | config_vala = vcs_tag( 6 | input: configure_file( 7 | input: 'config.vala.in', 8 | output: 'config.vala.in', 9 | configuration: conf_data 10 | ), 11 | output: 'config.vala', 12 | command: ['git', 'describe', '--tags', '--dirty'] 13 | ) 14 | 15 | executable('valdo', 16 | config_vala, 17 | 'main.vala', 18 | 'template.vala', 19 | 'templateengine.vala', 20 | 'expression.vala', 21 | 'variable.vala', 22 | dependencies: [deps], 23 | install: true) 24 | -------------------------------------------------------------------------------- /src/template.vala: -------------------------------------------------------------------------------- 1 | /* template.vala 2 | * 3 | * Copyright 2021 Princeton Ferro 4 | * Copyright 2021 Gleb Smirnov 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 2.1 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | /** 21 | * An error that occurred during the construction of a template. 22 | */ 23 | errordomain Valdo.TemplateError { 24 | COULD_NOT_GET_PATH, 25 | EMPTY_TEMPLATE_FILE, 26 | DESERIALIZATION_FAILED 27 | } 28 | 29 | /** 30 | * A template record is a JSON file containing a description of a project, 31 | * substitutions, and any additional commands needed to install the project. 32 | */ 33 | class Valdo.Template : Object, Json.Serializable { 34 | /** 35 | * The directory where this template resides 36 | */ 37 | public File directory { get; protected set; } 38 | 39 | /** 40 | * A short description of the template 41 | */ 42 | public string description { get; protected set; } 43 | 44 | /** 45 | * Array of template-specific variables 46 | */ 47 | public Array variables { get; protected set; } 48 | 49 | /** 50 | * Array of files that must be treated as templates 51 | */ 52 | public string[] templates { get; protected set; } 53 | 54 | /** 55 | * Deserializes a {@link Valdo.Template} from a JSON file located at 56 | * `/template.json` 57 | * 58 | * @param template_dir directory containing the template 59 | * 60 | * @return loaded template 61 | */ 62 | public static Template new_from_directory (File template_dir) throws Error { 63 | var template_json = template_dir.get_child ("template.json"); 64 | var path = template_json.get_path (); 65 | if (path == null) 66 | throw new TemplateError.COULD_NOT_GET_PATH ("%s does not have a path", template_json.get_uri ()); 67 | 68 | var parser = new Json.Parser (); 69 | parser.load_from_file ((!) path); 70 | 71 | if (parser.get_root () == null) 72 | throw new TemplateError.EMPTY_TEMPLATE_FILE ("%s: no root node", (!) path); 73 | 74 | var object = Json.gobject_deserialize (typeof (Template), (!) parser.get_root ()); 75 | if (!(object is Template)) 76 | throw new TemplateError.DESERIALIZATION_FAILED ("%s: failed to deserialize", (!) path); 77 | 78 | /* Set template directory */ 79 | ((Template) object).directory = template_dir; 80 | return (Template) object; 81 | } 82 | 83 | public override bool deserialize_property (string property_name, 84 | out Value value, 85 | ParamSpec pspec, 86 | Json.Node node) { 87 | switch (property_name) { 88 | case "variables": 89 | var variable_array = new Array (); 90 | value = variable_array; 91 | 92 | var variables = node.get_node_type () == OBJECT 93 | ? node.get_object () 94 | : null; 95 | 96 | if (variables == null) { 97 | critical ("expected dictionary for '%s' property", property_name); 98 | return false; 99 | } 100 | 101 | ((!) variables).foreach_member ((_, name, node) => { 102 | var variable_obj = Json.gobject_deserialize (typeof (Variable), node) as Variable; 103 | 104 | if (variable_obj == null) { 105 | critical ("failed to deserialize variable '%s'", name); 106 | return; 107 | } 108 | 109 | var variable = (!) variable_obj; 110 | variable.name = name; 111 | 112 | variable_array.append_val (variable); 113 | }); 114 | return true; 115 | 116 | case "templates": // workaround for Json-GLib < 1.5.2 (Ubuntu 20.04 / eOS 6.1) 117 | if (node.get_node_type() != ARRAY) { 118 | critical ("expected array for '%s' property", property_name); 119 | value = new string[]{}; 120 | return false; 121 | } 122 | string[] templates = {}; 123 | var elements = node.get_array (); 124 | ((!) elements).foreach_element ((_, index, elem) => { 125 | if (elem.get_value_type () != typeof (string)) { 126 | critical ("expected string in array '%s'", property_name); 127 | return; 128 | } 129 | templates += (!) elem.get_string (); 130 | }); 131 | value = templates; 132 | return true; 133 | 134 | case "description": // workaround for Json-GLib < 1.5.2 (Ubuntu 20.04 / eOS 6.1) 135 | if (node.get_value_type () != typeof (string)) { 136 | critical ("expected string for '%s' property", property_name); 137 | value = new string[]{}; 138 | return false; 139 | } 140 | value = (!) node.get_string (); 141 | return true; 142 | 143 | default: 144 | return default_deserialize_property (property_name, out value, pspec, node); 145 | } 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /src/templateengine.vala: -------------------------------------------------------------------------------- 1 | /* templateengine.vala 2 | * 3 | * Copyright 2021 Princeton Ferro 4 | * Copyright 2021 Gleb Smirnov 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 2.1 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | namespace Valdo.TemplateEngine { 21 | /** 22 | * Lists all files in a directory recursively. 23 | * 24 | * @param dir directory 25 | * @param found files that are already found 26 | * 27 | * @return hash table containing found files and their info 28 | */ 29 | public HashTable list_files (File dir, 30 | HashTable found = new HashTable (null, null)) throws Error { 31 | FileEnumerator enumerator = dir.enumerate_children ( 32 | FileAttribute.ID_FILE, 33 | FileQueryInfoFlags.NOFOLLOW_SYMLINKS 34 | ); 35 | 36 | try { 37 | FileInfo? finfo; 38 | while ((finfo = enumerator.next_file ()) != null) { 39 | var fileinfo = (!) finfo; 40 | if (fileinfo.get_file_type () == DIRECTORY) { 41 | list_files ( 42 | enumerator.get_child (fileinfo), 43 | found 44 | ); 45 | } 46 | found[fileinfo] = enumerator.get_child (fileinfo); 47 | } 48 | } catch (Error e) { 49 | warning ("Could not get next file in dir %s", (!) dir.get_path ()); 50 | } 51 | 52 | return found; 53 | } 54 | 55 | 56 | /** 57 | * Apply the template to the current directory, with the substitutions. 58 | * A new directory will be created with the project name. 59 | * 60 | * @param template the template to apply 61 | * @param current_dir the current directory 62 | * @param project_name the new project's name 63 | * @param variables the variable substitutions (variables => their new values) 64 | * 65 | * @return is succesful 66 | */ 67 | bool apply_template (Template template, 68 | File current_dir, 69 | string project_name, 70 | HashTable variables) throws Error { 71 | /* Create the new project directory */ 72 | var project_dir = current_dir.get_child (project_name); 73 | if (project_dir.query_exists ()) { 74 | stderr.printf ("Directory already exists\n"); 75 | return false; 76 | } 77 | project_dir.make_directory (); 78 | 79 | /* Convert list of templates to hashmap 80 | for more efficiency */ 81 | var template_files = new GenericSet (str_hash, str_equal); 82 | foreach (var file in template.templates) 83 | template_files.add (file); 84 | 85 | /* Copy everything into it */ 86 | var files_list = list_files (template.directory); 87 | foreach (var fileinfo in files_list.get_keys_as_array ()) { 88 | var file_type = ((!) fileinfo).get_file_type (); 89 | if (!(file_type == REGULAR || file_type == SYMBOLIC_LINK || 90 | file_type == SHORTCUT || file_type == DIRECTORY)) 91 | continue; 92 | 93 | var template_file = files_list[fileinfo]; 94 | var relative_path = (!) template.directory.get_relative_path (template_file); 95 | 96 | if (relative_path == "template.json") 97 | continue; // Don't copy over template.json 98 | 99 | /* Substitute path name */ 100 | var project_file = project_dir.resolve_relative_path ( 101 | Expression.expand_variables (relative_path, variables) 102 | ); 103 | 104 | if (file_type == DIRECTORY) { 105 | /* Create an empty directory */ 106 | DirUtils.create_with_parents ((!) project_file.get_path (), 0755); 107 | continue; 108 | } 109 | 110 | /* Create the parent directory of the file */ 111 | var parentdir = project_file.get_parent (); 112 | if (parentdir != null) { 113 | DirUtils.create_with_parents ((!) ((!) parentdir).get_path (), 0755); 114 | } 115 | 116 | if (relative_path in template_files) { 117 | /* Perform template substitutions */ 118 | string file_contents; 119 | FileUtils.get_contents ((!) template_file.get_path (), out file_contents); 120 | 121 | file_contents = Expression.expand_variables (file_contents, variables); 122 | 123 | project_file.create (FileCreateFlags.NONE).write_all (file_contents.data, null); 124 | } else { 125 | /* Just copy file if it's not template */ 126 | template_file.copy (project_file, FileCopyFlags.TARGET_DEFAULT_PERMS); 127 | } 128 | } 129 | 130 | /* Finally, initialize the git repository (we don't care if this part fails) */ 131 | if (Environment.find_program_in_path ("git") != null) { 132 | try { 133 | Process.spawn_sync ( 134 | project_dir.get_path (), 135 | {"git", "init"}, 136 | Environ.get (), 137 | SpawnFlags.SEARCH_PATH | SpawnFlags.SEARCH_PATH_FROM_ENVP, 138 | null 139 | ); 140 | /* Create a new gitignore for meson and c files */ 141 | project_dir.get_child (".gitignore").create (FileCreateFlags.NONE).write_all ("build/\n*~".data, null); 142 | } catch (Error e) { 143 | warning ("could not initialize a git repository - %s", e.message); 144 | } 145 | } 146 | 147 | return true; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /src/variable.vala: -------------------------------------------------------------------------------- 1 | /* variable.vala 2 | * 3 | * Copyright 2021 Princeton Ferro 4 | * Copyright 2021 Gleb Smirnov 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 2.1 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | /** 21 | * Represents a variable to be substituted in a template. 22 | */ 23 | class Valdo.Variable : Object, Json.Serializable { 24 | /** 25 | * The variable name to substitute 26 | */ 27 | public string name { get; construct set; } 28 | 29 | /** 30 | * A short description of the variable's meaning 31 | */ 32 | public string summary { get; construct; default = ""; } 33 | 34 | /** 35 | * The variable's default value, or `null` 36 | */ 37 | public string? @default { get; construct; } 38 | 39 | /** 40 | * The pattern that the string must match, or `null` if any string is 41 | * accepted. 42 | */ 43 | public string? pattern { get; construct; } 44 | 45 | public bool auto { get; construct; } 46 | 47 | /** 48 | * Creates a new variable for substitutions. 49 | * 50 | * @param name the variable name 51 | * @param summary a short description of the variable's meaning 52 | * @param default the default value, or `null` 53 | * @param pattern the pattern that the string must match 54 | */ 55 | public Variable (string name, string summary, string? @default = null, string? pattern = null) { 56 | Object ( 57 | name: name, 58 | summary: summary, 59 | @default: @default, 60 | pattern: pattern 61 | ); 62 | } 63 | 64 | /** 65 | * Regex used to validate email 66 | * 67 | * See https://stackoverflow.com/questions/201323/how-can-i-validate-an-email-address-using-a-regular-expression 68 | */ 69 | const string EMAIL_REGEX = "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"; 70 | 71 | /** 72 | * Get list of pre-defined variables 73 | * 74 | * @return array of pre-defined variables 75 | */ 76 | public static Array list_pre_defined () { 77 | var variables = new Array (); 78 | 79 | /* Project info */ 80 | variables.append_val (new Variable ("PROJECT_NAME", "the project name", null, "^[^\\\\\\/#?'\"\\n]+$")); 81 | variables.append_val (new Variable ("PROJECT_VERSION", "the project version", "0.0.1", "^\\d+(\\.\\d+)*$")); 82 | variables.append_val (new Variable ("PROJECT_DIR", "the folder name", "/${PROJECT_NAME}/\\w+/\\L\\0\\E/\\W+/-/")); 83 | 84 | /* User's email */ 85 | var username = Environment.get_user_name (); 86 | string email = @"$username@$(Environment.get_host_name ())"; 87 | try { 88 | string git_email; 89 | Process.spawn_command_line_sync ("git config --get user.email", out git_email); 90 | git_email = git_email.strip (); 91 | if (git_email.length > 0) 92 | email = git_email; 93 | } catch (SpawnError e) { 94 | /* do nothing */ 95 | } 96 | variables.append_val (new Variable ("USERADDR", "the user email", email, EMAIL_REGEX)); 97 | 98 | /* Username */ 99 | variables.append_val (new Variable ("USERNAME", "the user name", username)); 100 | 101 | /* Get user's real name */ 102 | string realname = Environment.get_real_name (); 103 | try { 104 | string git_realname; 105 | Process.spawn_command_line_sync ("git config --get user.name", out git_realname); 106 | git_realname = git_realname.strip (); 107 | if (git_realname.length > 0) 108 | realname = git_realname; 109 | } catch (SpawnError e) { 110 | /* do nothing */ 111 | } 112 | variables.append_val (new Variable ("AUTHOR", "the authors's real name", realname)); 113 | 114 | return variables; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /templates/eos/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig 2 | root = true 3 | 4 | # elementary defaults 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | indent_size = tab 9 | indent_style = space 10 | insert_final_newline = true 11 | max_line_length = 80 12 | tab_width = 4 13 | 14 | # Markup files 15 | [{*.html,*.xml,*.xml.in,*.yml}] 16 | tab_width = 2 17 | -------------------------------------------------------------------------------- /templates/eos/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | 7 | pull_request: 8 | branches: [ main ] 9 | types: 10 | - opened 11 | - reopened 12 | - synchronize 13 | 14 | jobs: 15 | flatpak: 16 | name: Flatpak 17 | runs-on: ubuntu-latest 18 | 19 | container: 20 | image: ghcr.io/elementary/flatpak-platform/runtime:daily 21 | options: --privileged 22 | 23 | steps: 24 | - name: Checkout 25 | uses: actions/checkout@v2 26 | 27 | - name: Build 28 | uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4 29 | with: 30 | bundle: ${PROGRAM_NAME}.flatpak 31 | manifest-path: com.github.${USERNAME}.${PROGRAM_NAME}.yml 32 | run-tests: true 33 | repository-name: appcenter 34 | repository-url: https://flatpak.elementary.io/repo.flatpakrepo 35 | cache-key: "flatpak-builder-${{ github.sha }}" 36 | 37 | lint: 38 | name: Lint 39 | runs-on: ubuntu-latest 40 | 41 | container: 42 | image: valalang/lint 43 | 44 | steps: 45 | - name: Checkout 46 | uses: actions/checkout@v2 47 | 48 | - name: Lint 49 | run: io.elementary.vala-lint -d . 50 | -------------------------------------------------------------------------------- /templates/eos/README.md: -------------------------------------------------------------------------------- 1 | # ${PROJECT_NAME} 2 | 3 | ${PROJECT_SUMMARY} 4 | 5 | ## Building, Testing, and Installation 6 | 7 | You'll need the following dependencies to build: 8 | * libgtk-3-dev 9 | * meson 10 | * valac 11 | 12 | Run `meson build` to configure the build environment and run `ninja` to build 13 | ```Bash 14 | meson build --prefix=/usr 15 | cd build 16 | ninja 17 | ``` 18 | To install, use `ninja install`, then execute with `com.${USERNAME}.${PROGRAM_NAME}` 19 | ```Bash 20 | sudo ninja install 21 | com.github.${USERNAME}.${PROGRAM_NAME} 22 | ``` 23 | -------------------------------------------------------------------------------- /templates/eos/com.github.${USERNAME}.${PROGRAM_NAME}.yml: -------------------------------------------------------------------------------- 1 | # This is the same ID that you've used in meson.build and other files 2 | app-id: com.github.${USERNAME}.${PROGRAM_NAME} 3 | 4 | # Instead of manually specifying a long list of build and runtime dependencies, 5 | # we can use a convenient pre-made runtime and SDK. For this example, we'll be 6 | # using the runtime and SDK provided by elementary. 7 | runtime: io.elementary.Platform 8 | runtime-version: '6' 9 | sdk: io.elementary.Sdk 10 | 11 | # This should match the exec line in your .desktop file and usually is the same 12 | # as your app ID 13 | command: com.github.${USERNAME}.${PROGRAM_NAME} 14 | 15 | # Here we can specify the kinds of permissions our app needs to run. Since we're 16 | # not using hardware like webcams, making sound, or reading external files, we 17 | # only need permission to draw our app on screen using either X11 or Wayland. 18 | finish-args: 19 | - '--share=ipc' 20 | - '--socket=fallback-x11' 21 | - '--socket=wayland' 22 | 23 | # Needed to read prefers-color-scheme with Granite.Settings 24 | - '--system-talk-name=org.freedesktop.Accounts' 25 | 26 | # This section is where you list all the source code required to build your app. 27 | # If we had external dependencies that weren't included in our SDK, we would list 28 | # them here. 29 | modules: 30 | - name: ${PROGRAM_NAME} 31 | buildsystem: meson 32 | sources: 33 | - type: dir 34 | path: . 35 | -------------------------------------------------------------------------------- /templates/eos/data/128.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 38 | 42 | 49 | 50 | 52 | 54 | 58 | 62 | 63 | 65 | 69 | 73 | 77 | 81 | 85 | 89 | 90 | 92 | 96 | 100 | 101 | 110 | 112 | 116 | 120 | 124 | 128 | 129 | 139 | 141 | 145 | 149 | 150 | 160 | 169 | 171 | 175 | 179 | 183 | 187 | 191 | 195 | 199 | 200 | 209 | 211 | 215 | 219 | 223 | 227 | 231 | 235 | 239 | 243 | 247 | 251 | 252 | 261 | 263 | 267 | 271 | 275 | 279 | 283 | 287 | 291 | 292 | 301 | 303 | 307 | 311 | 315 | 319 | 323 | 327 | 331 | 332 | 341 | 350 | 352 | 356 | 360 | 364 | 368 | 372 | 373 | 383 | 393 | 403 | 413 | 423 | 433 | 443 | 453 | 462 | 463 | 465 | 466 | 468 | image/svg+xml 469 | 471 | 472 | 473 | 474 | 475 | 478 | 483 | 488 | 489 | 494 | 498 | 502 | 503 | -------------------------------------------------------------------------------- /templates/eos/data/16.svg: -------------------------------------------------------------------------------- 1 | 2 | 18 | 39 | 43 | 50 | 51 | 53 | 55 | 59 | 63 | 64 | 66 | 70 | 74 | 75 | 78 | 82 | 83 | 85 | 89 | 93 | 97 | 101 | 102 | 111 | 120 | 122 | 126 | 130 | 134 | 138 | 142 | 146 | 147 | 156 | 158 | 162 | 166 | 170 | 174 | 178 | 182 | 186 | 190 | 191 | 200 | 202 | 206 | 210 | 214 | 218 | 222 | 226 | 227 | 236 | 238 | 242 | 246 | 250 | 254 | 258 | 262 | 266 | 267 | 276 | 285 | 287 | 291 | 295 | 299 | 303 | 307 | 308 | 318 | 328 | 338 | 348 | 357 | 358 | 360 | 361 | 363 | image/svg+xml 364 | 366 | 367 | 368 | 369 | 370 | 374 | 378 | 382 | 383 | -------------------------------------------------------------------------------- /templates/eos/data/24.svg: -------------------------------------------------------------------------------- 1 | 2 | 18 | 39 | 43 | 50 | 51 | 53 | 55 | 59 | 63 | 64 | 66 | 70 | 74 | 75 | 77 | 81 | 85 | 89 | 90 | 93 | 97 | 98 | 100 | 104 | 108 | 112 | 116 | 117 | 126 | 135 | 137 | 141 | 145 | 149 | 153 | 157 | 161 | 162 | 171 | 173 | 177 | 181 | 185 | 189 | 193 | 197 | 201 | 205 | 206 | 215 | 217 | 221 | 225 | 229 | 233 | 237 | 241 | 242 | 251 | 253 | 257 | 261 | 265 | 269 | 273 | 277 | 281 | 282 | 291 | 300 | 302 | 306 | 310 | 314 | 318 | 322 | 323 | 333 | 343 | 353 | 363 | 373 | 382 | 383 | 385 | 386 | 388 | image/svg+xml 389 | 391 | 392 | 393 | 394 | 395 | 400 | 404 | 408 | 412 | 413 | -------------------------------------------------------------------------------- /templates/eos/data/32.svg: -------------------------------------------------------------------------------- 1 | 2 | 18 | 39 | 43 | 50 | 51 | 53 | 55 | 59 | 63 | 64 | 66 | 70 | 74 | 75 | 77 | 81 | 85 | 89 | 90 | 93 | 97 | 98 | 100 | 104 | 108 | 112 | 116 | 117 | 126 | 136 | 145 | 147 | 151 | 155 | 159 | 163 | 167 | 171 | 172 | 181 | 183 | 187 | 191 | 195 | 199 | 203 | 207 | 211 | 215 | 216 | 225 | 227 | 231 | 235 | 239 | 243 | 247 | 251 | 252 | 261 | 263 | 267 | 271 | 275 | 279 | 283 | 287 | 291 | 292 | 301 | 310 | 312 | 316 | 320 | 324 | 328 | 332 | 333 | 343 | 353 | 363 | 373 | 382 | 383 | 385 | 386 | 388 | image/svg+xml 389 | 391 | 392 | 393 | 394 | 395 | 399 | 404 | 409 | 414 | 415 | -------------------------------------------------------------------------------- /templates/eos/data/48.svg: -------------------------------------------------------------------------------- 1 | 2 | 18 | 39 | 43 | 50 | 51 | 53 | 55 | 59 | 63 | 64 | 66 | 70 | 74 | 78 | 82 | 86 | 87 | 89 | 93 | 97 | 101 | 105 | 109 | 113 | 117 | 118 | 120 | 124 | 128 | 129 | 131 | 135 | 139 | 143 | 147 | 151 | 155 | 156 | 158 | 162 | 166 | 170 | 174 | 178 | 182 | 186 | 190 | 191 | 193 | 197 | 201 | 205 | 209 | 213 | 217 | 218 | 227 | 236 | 245 | 254 | 256 | 260 | 264 | 268 | 272 | 273 | 276 | 280 | 281 | 291 | 301 | 311 | 320 | 330 | 339 | 348 | 357 | 367 | 369 | 373 | 377 | 378 | 388 | 389 | 391 | 392 | 394 | image/svg+xml 395 | 397 | 398 | 399 | 400 | 401 | 405 | 410 | 415 | 416 | 420 | 424 | 428 | 429 | -------------------------------------------------------------------------------- /templates/eos/data/64.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 38 | 42 | 49 | 50 | 52 | 54 | 58 | 62 | 63 | 65 | 69 | 73 | 74 | 83 | 85 | 89 | 93 | 97 | 101 | 102 | 112 | 114 | 118 | 122 | 123 | 133 | 142 | 144 | 148 | 152 | 156 | 160 | 164 | 168 | 169 | 178 | 180 | 184 | 188 | 192 | 196 | 200 | 204 | 208 | 212 | 213 | 222 | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 249 | 258 | 260 | 264 | 268 | 272 | 276 | 280 | 284 | 288 | 289 | 298 | 307 | 309 | 313 | 317 | 321 | 325 | 329 | 330 | 340 | 350 | 360 | 370 | 379 | 380 | 382 | 383 | 385 | image/svg+xml 386 | 388 | 389 | 390 | 391 | 392 | 397 | 401 | 405 | 409 | 413 | 414 | -------------------------------------------------------------------------------- /templates/eos/data/com.github.${USERNAME}.${PROGRAM_NAME}.appdata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | com.github.${USERNAME}.${PROGRAM_NAME} 5 | CC0 6 | ${PROJECT_NAME} 7 | ${PROJECT_SUMMARY} 8 | 9 |

A quick summary of your app's main selling points and features. Just a couple sentences per paragraph is best.

10 |
11 |
12 | -------------------------------------------------------------------------------- /templates/eos/data/com.github.${USERNAME}.${PROGRAM_NAME}.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=${PROJECT_NAME} 3 | GenericName=${PROJECT_NAME} App 4 | Comment=${PROJECT_SUMMARY} 5 | Categories=${PROJECT_CATEGORIES} 6 | Exec=com.github.${USERNAME}.${PROGRAM_NAME} 7 | Icon=com.github.${USERNAME}.${PROGRAM_NAME} 8 | Terminal=false 9 | Type=Application 10 | Keywords=${PROJECT_KEYWORDS} 11 | -------------------------------------------------------------------------------- /templates/eos/meson.build: -------------------------------------------------------------------------------- 1 | # project name and programming language 2 | project('com.github.${USERNAME}.${PROGRAM_NAME}', 'vala', 'c') 3 | 4 | # Create a new executable, list the files we want to compile, list the dependencies we need, and install 5 | executable( 6 | meson.project_name(), 7 | 'src' / 'Application.vala', 8 | dependencies: [ 9 | dependency('gtk+-3.0'), 10 | dependency('granite') 11 | ], 12 | install: true 13 | ) 14 | 15 | # Install our .desktop file so the Applications Menu will see it 16 | install_data( 17 | 'data' / 'com.github.${USERNAME}.${PROGRAM_NAME}.desktop', 18 | install_dir: get_option('datadir') / 'applications', 19 | rename: meson.project_name() + '.desktop' 20 | ) 21 | 22 | # Install our .appdata.xml file so AppCenter will see it 23 | install_data( 24 | 'data' / 'com.github.${USERNAME}.${PROGRAM_NAME}.appdata.xml', 25 | install_dir: get_option('datadir') / 'metainfo', 26 | rename: meson.project_name() + '.appdata.xml' 27 | ) 28 | 29 | # Install our icons in all the required sizes 30 | icon_sizes = ['16', '24', '32', '48', '64', '128'] 31 | 32 | foreach i : icon_sizes 33 | install_data( 34 | 'data' / i + '.svg', 35 | install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i / 'apps', 36 | rename: meson.project_name() + '.svg' 37 | ) 38 | install_data( 39 | 'data' / i + '.svg', 40 | install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i + '@2' / 'apps', 41 | rename: meson.project_name() + '.svg' 42 | ) 43 | endforeach 44 | -------------------------------------------------------------------------------- /templates/eos/src/Application.vala: -------------------------------------------------------------------------------- 1 | public class MyApp : Gtk.Application { 2 | public MyApp () { 3 | Object ( 4 | application_id: "com.github.${USERNAME}.${PROGRAM_NAME}", 5 | flags: ApplicationFlags.FLAGS_NONE 6 | ); 7 | } 8 | 9 | protected override void activate () { 10 | var main_window = new Gtk.ApplicationWindow (this) { 11 | default_height = 300, 12 | default_width = 300, 13 | title = "Hello World" 14 | }; 15 | 16 | var gtk_settings = Gtk.Settings.get_default (); 17 | var granite_settings = Granite.Settings.get_default (); 18 | 19 | gtk_settings.gtk_application_prefer_dark_theme = ( 20 | granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK 21 | ); 22 | 23 | granite_settings.notify["prefers-color-scheme"].connect (() => { 24 | gtk_settings.gtk_application_prefer_dark_theme = ( 25 | granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK 26 | ); 27 | }); 28 | 29 | main_window.show_all (); 30 | } 31 | 32 | public static int main (string[] args) { 33 | return new MyApp ().run (args); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /templates/eos/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "a starter elementary OS app", 3 | "variables": { 4 | "PROGRAM_NAME": { 5 | "summary": "the name of the program", 6 | "default": "/${PROJECT_NAME}/\\w+/\\u\\0/(\\w)?\\W+(\\w)?(\\w*)/\\1\\u\\2\\L\\3\\E/^\\w/\\u\\0/", 7 | "pattern": "^[[:word:]-]+$" 8 | }, 9 | "PROJECT_SUMMARY": { 10 | "summary": "a very short summary of the project", 11 | "default": "a new app for elementary OS" 12 | }, 13 | "PROJECT_CATEGORIES": { 14 | "summary": "categories (semicolon-separated)", 15 | "pattern": "^((AudioVideo|Audio|Video|Development|Education|Game|Graphics|Network|Office|Science|Settings|System|Utility);)+$" 16 | }, 17 | "PROJECT_KEYWORDS": { 18 | "summary": "keywords (semicolon-separated)", 19 | "default": "/${PROJECT_NAME}/\\W+/;/^;+//\\w+/\\L\\0\\E/[^;]$/\\0;/", 20 | "pattern": "^(\\w+;)+$" 21 | } 22 | }, 23 | "templates": [ 24 | "com.github.${USERNAME}.${PROGRAM_NAME}.yml", 25 | "meson.build", 26 | "README.md", 27 | "data/com.github.${USERNAME}.${PROGRAM_NAME}.appdata.xml", 28 | "data/com.github.${USERNAME}.${PROGRAM_NAME}.desktop", 29 | "src/Application.vala" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /templates/gnome/.editorconfig: -------------------------------------------------------------------------------- 1 | # taken from gitg 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.vala] 11 | indent_size = 4 12 | indent_style = tab 13 | insert_final_newline = true 14 | max_line_length = 100 15 | 16 | [*.{c,h}] 17 | indent_size = 2 18 | indent_style = space 19 | insert_final_newline = true 20 | max_line_length = 100 21 | 22 | [*.css] 23 | indent_size = 2 24 | indent_style = space 25 | 26 | [*.{ui,xml,xml.in}] 27 | indent_size = 2 28 | indent_style = space 29 | 30 | [*.py] 31 | indent_size = 4 32 | indent_style = space 33 | 34 | [*.json] 35 | indent_style = space 36 | indent_size = 4 37 | 38 | [meson.build] 39 | indent_size = 2 40 | indent_style = space 41 | 42 | -------------------------------------------------------------------------------- /templates/gnome/.gitignore.in: -------------------------------------------------------------------------------- 1 | /_build 2 | /app 3 | /.flatpak 4 | /.flatpak-builder 5 | /subprojects/**/ 6 | -------------------------------------------------------------------------------- /templates/gnome/README.md: -------------------------------------------------------------------------------- 1 | # ${PROJECT_NAME} 2 | 3 | ${APP_SUMMARY} 4 | -------------------------------------------------------------------------------- /templates/gnome/build-aux/flatpak/${APP_ID}.yaml: -------------------------------------------------------------------------------- 1 | app-id: ${APP_ID} 2 | runtime: org.gnome.Platform 3 | runtime-version: master 4 | sdk: org.gnome.Sdk 5 | 6 | sdk-extensions: 7 | - org.freedesktop.Sdk.Extension.vala 8 | build-options: 9 | prepend-path: /usr/lib/sdk/vala/bin/ 10 | prepend-ld-library-path: /usr/lib/sdk/vala/lib 11 | 12 | command: ${APP_EXE} 13 | finish-args: 14 | - --share=ipc 15 | - --socket=fallback-x11 16 | - --socket=wayland 17 | - --device=dri 18 | 19 | cleanup: 20 | - /include 21 | - /lib/pkgconfig 22 | - /share/pkgconfig 23 | - /man 24 | - /share/doc 25 | - /share/vala 26 | - /share/vala-* 27 | - '*.la' 28 | - '*.a' 29 | 30 | modules: 31 | 32 | # Biography itself 33 | 34 | - name: ${APP_NAME} 35 | builddir: true 36 | buildsystem: meson 37 | sources: 38 | - type: dir 39 | path: ../.. 40 | -------------------------------------------------------------------------------- /templates/gnome/build-aux/meson/build-and-run.sh: -------------------------------------------------------------------------------- 1 | if [ ! -e _build ] 2 | then 3 | meson _build -Dprefix=$(pwd)/app 4 | fi \ 5 | && ninja -C _build \ 6 | && ninja -C _build install \ 7 | && env \ 8 | GSETTINGS_SCHEMA_DIR=./app/share/glib-2.0/schemas \ 9 | LD_LIBRARY_PATH=./app/lib64/${APP_NAME} \ 10 | ./app/bin/${APP_NAME} 11 | -------------------------------------------------------------------------------- /templates/gnome/build-aux/meson/postinstall.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from os import environ, path 4 | from subprocess import call 5 | 6 | prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local') 7 | datadir = path.join(prefix, 'share') 8 | destdir = environ.get('DESTDIR', '') 9 | 10 | # Package managers set this so we don't need to run 11 | if not destdir: 12 | print('Updating icon cache...') 13 | call(['gtk-update-icon-cache', '-qtf', 14 | path.join(datadir, 'icons', 'hicolor')]) 15 | 16 | print('Updating desktop database...') 17 | call(['update-desktop-database', '-q', 18 | path.join(datadir, 'applications')]) 19 | 20 | print('Compiling GSettings schemas...') 21 | call(['glib-compile-schemas', 22 | path.join(datadir, 'glib-2.0', 'schemas')]) 23 | -------------------------------------------------------------------------------- /templates/gnome/data/${APP_ID}.appdata.xml.in.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | @APP_ID@ 4 | @APP_NAME@ 5 | @APP_SUMMARY@ 6 | 7 |

Some useful description

8 |
9 | CC0-1.0 10 | GPL-3.0-or-later 11 | 12 | @APP_EXE@ 13 | 14 | ${AUTHOR} 15 | https://link.to/your/project 16 | https://link.to/your/project/issues 17 | 18 | 19 | 20 |
21 | -------------------------------------------------------------------------------- /templates/gnome/data/${APP_ID}.desktop.in.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=${PROJECT_NAME} 3 | Icon=@APP_ID@ 4 | Exec=@APP_EXE@ 5 | Terminal=false 6 | Type=Application 7 | Categories=Utility;GNOME;GTK; 8 | StartupNotify=true 9 | -------------------------------------------------------------------------------- /templates/gnome/data/${APP_ID}.gschema.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /templates/gnome/data/icons/hicolor/scalable/apps/${APP_ID}.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 18 | 29 | 30 | 33 | 44 | 45 | 46 | 48 | 49 | 51 | image/svg+xml 52 | 54 | 55 | 56 | 57 | 58 | 61 | 65 | application-x-executable 67 | 71 | 75 | 79 | 90 | 97 | 104 | 108 | 112 | 113 | 114 | 120 | 121 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /templates/gnome/data/icons/hicolor/symbolic/apps/${APP_ID}-symbolic.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /templates/gnome/data/meson.build: -------------------------------------------------------------------------------- 1 | desktop_file = i18n.merge_file( 2 | input: configure_file( 3 | input: f'@app_id@.desktop.in.in', 4 | output: f'@app_id@.desktop.in', 5 | configuration: conf_data 6 | ), 7 | output: f'@app_id@.desktop', 8 | type: 'desktop', 9 | po_dir: '..' / 'po', 10 | install: true, 11 | install_dir: get_option('datadir') / 'applications' 12 | ) 13 | 14 | desktop_utils = find_program('desktop-file-validate', required: false) 15 | if desktop_utils.found() 16 | test('Validate desktop file', desktop_utils, 17 | args: [desktop_file] 18 | ) 19 | endif 20 | 21 | appstream_file = i18n.merge_file( 22 | input: configure_file( 23 | input: f'@app_id@.appdata.xml.in.in', 24 | output: f'@app_id@.appdata.xml.in', 25 | configuration: conf_data 26 | ), 27 | output: f'@app_id@.appdata.xml', 28 | po_dir: '../po', 29 | install: true, 30 | install_dir: get_option('datadir') / 'appdata' 31 | ) 32 | 33 | appstream_util = find_program('appstream-util', required: false) 34 | if appstream_util.found() 35 | test('Validate appstream file', appstream_util, 36 | args: ['validate', appstream_file] 37 | ) 38 | endif 39 | 40 | gschema_file = configure_file( 41 | input: f'@app_id@.gschema.xml.in', 42 | output: f'@app_id@.gschema.xml', 43 | configuration: conf_data, 44 | install_dir: get_option('datadir') / 'glib-2.0' / 'schemas' 45 | ) 46 | 47 | compile_schemas = find_program('glib-compile-schemas', required: false) 48 | if compile_schemas.found() 49 | test('Validate schema file', compile_schemas, 50 | args: ['--strict', '--dry-run', meson.current_build_dir()] 51 | ) 52 | endif 53 | 54 | scalable_dir = 'icons' / 'hicolor' / 'scalable' / 'apps' 55 | install_data( 56 | scalable_dir / f'@app_id@.svg', 57 | install_dir: get_option('datadir') / scalable_dir 58 | ) 59 | 60 | symbolic_dir = 'icons' / 'hicolor' / 'symbolic' / 'apps' 61 | install_data( 62 | symbolic_dir / f'@app_id@-symbolic.svg', 63 | install_dir: get_option('datadir') / symbolic_dir 64 | ) 65 | -------------------------------------------------------------------------------- /templates/gnome/meson.build: -------------------------------------------------------------------------------- 1 | project('${APP_NAME}', ['c', 'vala'], 2 | version: '${PROJECT_VERSION}', 3 | meson_version: '>= 0.58.0', 4 | default_options: [ 'warning_level=2', 5 | ], 6 | ) 7 | 8 | pkgdata_dir = get_option('prefix') / get_option('datadir') / meson.project_name() 9 | 10 | app_exe = '${APP_EXE}' 11 | app_summary = '${APP_SUMMARY}' 12 | 13 | app_id = '${APP_ID}' 14 | app_name = meson.project_name() 15 | 16 | conf_data = configuration_data() 17 | conf_data.set('APP_ID', app_id) 18 | conf_data.set('APP_PATH', '/' + app_id.replace('.', '/') + '/') 19 | conf_data.set('APP_NAME', app_name) 20 | 21 | conf_data.set('APP_EXE', app_exe) 22 | conf_data.set('APP_SUMMARY', app_summary) 23 | 24 | ${APP_NAME}_sources = [] 25 | 26 | valac = meson.get_compiler('vala') 27 | vapi_dir = meson.project_source_root() / 'vapi' 28 | 29 | # Dependencies 30 | 31 | libadwaita_dep = dependency('libadwaita-1', 32 | version: '>= 1.0.0-alpha.2', 33 | required: false, 34 | ) 35 | 36 | if not libadwaita_dep.found() 37 | libadwaita = subproject( 38 | 'libadwaita', 39 | default_options: [ 40 | 'examples=false', 41 | f'package_subdir=@app_name@', 42 | 'tests=false' 43 | ] 44 | ) 45 | libadwaita_dep = declare_dependency( 46 | dependencies: [ 47 | libadwaita.get_variable('libadwaita_dep'), 48 | libadwaita.get_variable('libadwaita_vapi') 49 | ] 50 | ) 51 | endif 52 | 53 | ${APP_NAME}_deps = [ 54 | dependency('gio-2.0', version: '>= 2.50'), 55 | dependency('gtk4', version: '>= 4.2'), 56 | libadwaita_dep, 57 | valac.find_library('config', dirs: vapi_dir), 58 | ] 59 | 60 | i18n = import('i18n') 61 | 62 | subdir('data') 63 | subdir('resources') 64 | subdir('src') 65 | subdir('po') 66 | 67 | meson.add_install_script('build-aux' / 'meson' / 'postinstall.py') 68 | -------------------------------------------------------------------------------- /templates/gnome/po/LINGUAS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vala-lang/valdo/cfae16a4d145833e6a63528d64c279e2c5be8228/templates/gnome/po/LINGUAS -------------------------------------------------------------------------------- /templates/gnome/po/POTFILES: -------------------------------------------------------------------------------- 1 | data/${APP_ID}.desktop.in.in 2 | data/${APP_ID}.appdata.xml.in.in 3 | data/${APP_ID}.gschema.xml.in 4 | resources/ui/MainWindow.ui 5 | -------------------------------------------------------------------------------- /templates/gnome/po/meson.build: -------------------------------------------------------------------------------- 1 | i18n.gettext(meson.project_name(), preset: 'glib') 2 | -------------------------------------------------------------------------------- /templates/gnome/resources/${APP_NAME}.gresource.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | style.css 5 | 6 | ui/MainWindow.ui 7 | 8 | 9 | -------------------------------------------------------------------------------- /templates/gnome/resources/meson.build: -------------------------------------------------------------------------------- 1 | gnome = import('gnome') 2 | ${APP_NAME}_sources += gnome.compile_resources('${APP_NAME}-resources', 3 | f'@app_name@.gresource.xml', 4 | source_dir: 'resources', 5 | c_name: app_name 6 | ) 7 | -------------------------------------------------------------------------------- /templates/gnome/resources/style.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vala-lang/valdo/cfae16a4d145833e6a63528d64c279e2c5be8228/templates/gnome/resources/style.css -------------------------------------------------------------------------------- /templates/gnome/resources/ui/MainWindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 37 | 38 | 39 |
40 | 41 | _About ${PROJECT_NAME} 42 | app.about 43 | 44 |
45 |
46 |
47 | -------------------------------------------------------------------------------- /templates/gnome/src/Application.vala: -------------------------------------------------------------------------------- 1 | namespace ${APP_NAMESPACE} { 2 | class Application : Adw.Application { 3 | 4 | struct AccelEntry { 5 | string action_name; 6 | string[] accels; 7 | } 8 | 9 | static ActionEntry[] ACTION_ENTRIES = { 10 | { "quit", quit }, 11 | { "about", on_about_action } 12 | }; 13 | 14 | static AccelEntry[] ACCEL_ENTRIES = { 15 | { "app.quit", {"q"} }, 16 | { "window.close", {"w"} } 17 | }; 18 | 19 | public Application () { 20 | Object ( 21 | flags: ApplicationFlags.FLAGS_NONE, 22 | application_id: Config.APP_ID 23 | ); 24 | } 25 | 26 | protected override void startup () { 27 | base.startup (); 28 | 29 | add_action_entries (ACTION_ENTRIES, this); 30 | 31 | foreach (var accel in ACCEL_ENTRIES) 32 | set_accels_for_action (accel.action_name, accel.accels); 33 | } 34 | 35 | protected override void activate () { 36 | var win = active_window; 37 | if (win == null) { 38 | win = new ${APP_NAMESPACE}.MainWindow (this); 39 | } 40 | win.present (); 41 | } 42 | 43 | private void on_about_action () { 44 | const string? COPYRIGHT = "Copyright \xc2\xa9 ${AUTHOR}"; 45 | 46 | const string? AUTHORS[] = { 47 | "${AUTHOR}<${USERADDR}>", 48 | null 49 | }; 50 | 51 | Gtk.show_about_dialog (active_window, 52 | "program_name", "${PROJECT_NAME}", 53 | "logo-icon-name", Config.APP_ID, 54 | "copyright", COPYRIGHT, 55 | "version", Config.VERSION, 56 | "authors", AUTHORS, 57 | /// TRANSLATORS: Write your Name here 58 | "translator-credits", _("translator-credits"), 59 | null 60 | ); 61 | } 62 | 63 | static int main (string[] args) { 64 | Intl.bindtextdomain ( 65 | Config.GETTEXT_PACKAGE, 66 | Config.GNOMELOCALEDIR 67 | ); 68 | Intl.bind_textdomain_codeset ( 69 | Config.GETTEXT_PACKAGE, 70 | Config.GNOMELOCALEDIR 71 | ); 72 | Intl.textdomain (Config.GETTEXT_PACKAGE); 73 | 74 | return new ${APP_NAMESPACE}.Application ().run (args); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /templates/gnome/src/MainWindow.vala: -------------------------------------------------------------------------------- 1 | namespace ${APP_NAMESPACE} { 2 | [GtkTemplate (ui = "${APP_PATH}ui/MainWindow.ui")] 3 | class MainWindow : Adw.ApplicationWindow { 4 | [GtkChild] 5 | private unowned Gtk.Label label; 6 | public MainWindow (Application app) { 7 | Object ( 8 | application: app 9 | ); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /templates/gnome/src/meson.build: -------------------------------------------------------------------------------- 1 | ${APP_NAME}_sources += [ 2 | 'Application.vala', 3 | 'MainWindow.vala' 4 | ] 5 | 6 | executable(app_exe, ${APP_NAME}_sources, 7 | vala_args: [ 8 | '--target-glib=2.50', 9 | '--vapidir', vapi_dir, 10 | '--enable-experimental' 11 | ], 12 | c_args: [ 13 | '-DVERSION="' + meson.project_version() + '"', 14 | '-DGETTEXT_PACKAGE="' + app_name + '"', 15 | '-DGNOMELOCALEDIR="' + get_option('prefix') / get_option('localedir') + '"', 16 | '-DAPP_ID="' + app_id + '"', 17 | ], 18 | dependencies: ${APP_NAME}_deps, 19 | install: true 20 | ) 21 | -------------------------------------------------------------------------------- /templates/gnome/subprojects/libadwaita.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://gitlab.gnome.org/GNOME/libadwaita 3 | revision = main 4 | 5 | [provide] 6 | dependency_names = libadwaita-1 7 | 8 | -------------------------------------------------------------------------------- /templates/gnome/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "a modern GNOME app using GTK4 and libadwaita", 3 | "variables": { 4 | "APP_NAME": { 5 | "auto": true, 6 | "default": "/${PROJECT_NAME}/\\s+//" 7 | }, 8 | "APP_EXE": { 9 | "summary": "application binary name", 10 | "pattern": "[A-Za-z ]+" 11 | }, 12 | "APP_ID": { 13 | "summary": "application ID", 14 | "pattern": "[a-z]{2,}(\\.\\w+){3}", 15 | "default": "io.github.${USERNAME}.${APP_NAME}" 16 | }, 17 | "APP_NAMESPACE": { 18 | "summary": "application namespace", 19 | "pattern": "[A-Z]\\w{2,}", 20 | "default": "/${PROJECT_NAME}/\\s+//" 21 | }, 22 | "APP_PATH": { 23 | "auto": true, 24 | "default": "/${APP_ID}/(\\.|^|$)/\\//" 25 | }, 26 | "APP_SUMMARY": { 27 | "summary": "application summary", 28 | "default": "Do some cool stuff" 29 | } 30 | }, 31 | "templates": [ 32 | "build-aux/flatpak/${APP_ID}.yaml", 33 | "build-aux/meson/build-and-run.sh", 34 | "build-aux/meson/postinstall.py", 35 | "data/icons/hicolor/scalable/apps/${APP_ID}.svg", 36 | "data/icons/hicolor/symbolic/apps/${APP_ID}-symbolic.svg", 37 | "data/${APP_ID}.appdata.xml.in.in", 38 | "data/${APP_ID}.desktop.in.in", 39 | "data/${APP_ID}.gschema.xml.in", 40 | "data/meson.build", 41 | "po/LINGUAS", 42 | "po/meson.build", 43 | "po/POTFILES", 44 | "resources/ui/MainWindow.ui", 45 | "resources/${APP_NAME}.gresource.xml", 46 | "resources/meson.build", 47 | "resources/style.css", 48 | "src/Application.vala", 49 | "src/MainWindow.vala", 50 | "src/meson.build", 51 | "subprojects/libadwaita.wrap", 52 | "vapi/config.vapi", 53 | "COPYING", 54 | "meson.build", 55 | "README.md" 56 | ] 57 | } 58 | -------------------------------------------------------------------------------- /templates/gnome/vapi/config.vapi: -------------------------------------------------------------------------------- 1 | [CCode (cprefix = "", lower_case_cprefix = "")] 2 | namespace Config { 3 | public const string VERSION; 4 | public const string APP_ID; 5 | public const string GETTEXT_PACKAGE; 6 | public const string GNOMELOCALEDIR; 7 | } 8 | -------------------------------------------------------------------------------- /templates/gtk/.editorconfig: -------------------------------------------------------------------------------- 1 | # taken from gitg 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.vala] 11 | indent_size = 4 12 | indent_style = tab 13 | insert_final_newline = true 14 | max_line_length = 100 15 | 16 | [*.{c,h}] 17 | indent_size = 2 18 | indent_style = space 19 | insert_final_newline = true 20 | max_line_length = 100 21 | 22 | [*.css] 23 | indent_size = 2 24 | indent_style = space 25 | 26 | [*.{ui,xml,xml.in}] 27 | indent_size = 2 28 | indent_style = space 29 | 30 | [*.py] 31 | indent_size = 4 32 | indent_style = space 33 | 34 | [*.json] 35 | indent_style = space 36 | indent_size = 4 37 | 38 | [meson.build] 39 | indent_size = 2 40 | indent_style = space 41 | 42 | -------------------------------------------------------------------------------- /templates/gtk/README.md: -------------------------------------------------------------------------------- 1 | # ${PROJECT_NAME} 2 | 3 | A shiny new GTK app. 4 | 5 | ## Build instructions: 6 | 7 | ```Bash 8 | $ meson build 9 | $ ninja -C build 10 | $ build/${PROGRAM_NAME} 11 | ``` 12 | -------------------------------------------------------------------------------- /templates/gtk/meson.build: -------------------------------------------------------------------------------- 1 | project( 2 | '${PROJECT_NAME}', 3 | 'vala', 'c', 4 | version: '${PROJECT_VERSION}' 5 | ) 6 | 7 | add_project_arguments(['--enable-experimental'], language: 'vala') 8 | 9 | subdir('src') 10 | -------------------------------------------------------------------------------- /templates/gtk/src/Main.vala: -------------------------------------------------------------------------------- 1 | public class ${NAMESPACE}.App : Gtk.Application { 2 | // Member variables 3 | 4 | // Constructor 5 | public App () { 6 | Object (application_id: "${APP_ID}", 7 | flags : GLib.ApplicationFlags.FLAGS_NONE 8 | ); 9 | } 10 | 11 | protected override void activate () { 12 | var win = this.get_active_window (); 13 | if (win == null) { 14 | win = new MainWindow (this); 15 | } 16 | win.present (); 17 | } 18 | 19 | protected override void open (GLib.File[] files, string hint) { 20 | } 21 | } 22 | 23 | int main (string[] args) { 24 | var my_app = new ${NAMESPACE}.App (); 25 | return my_app.run (args); 26 | } 27 | -------------------------------------------------------------------------------- /templates/gtk/src/MainWindow.vala: -------------------------------------------------------------------------------- 1 | public class ${NAMESPACE}.MainWindow : Gtk.ApplicationWindow { 2 | // GLib.ListStore clocks_list_store; 3 | public MainWindow (Gtk.Application app) { 4 | Object (application: app); 5 | 6 | this.default_height = 400; 7 | this.default_width = 600; 8 | 9 | var header = new Gtk.HeaderBar (); 10 | this.set_titlebar (header); 11 | 12 | var label = new Gtk.Label ("Hello World!"); 13 | label.hexpand = label.vexpand = true; 14 | 15 | var button = new Gtk.Button.with_label ("Click Me!"); 16 | 17 | button.clicked.connect (() => { 18 | var str = label.label; 19 | var temp_str = str.reverse (); 20 | label.label = temp_str; 21 | }); 22 | 23 | var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 10); 24 | box.append (label); 25 | box.append (button); 26 | 27 | this.child = box; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /templates/gtk/src/meson.build: -------------------------------------------------------------------------------- 1 | sources = files( 2 | 'Main.vala', 3 | 'MainWindow.vala', 4 | ) 5 | 6 | dependencies = [ 7 | dependency('glib-2.0'), 8 | dependency('gobject-2.0'), 9 | dependency('gtk4'), 10 | ] 11 | 12 | executable( 13 | '${PROGRAM_NAME}', 14 | sources, 15 | dependencies: dependencies, 16 | install: true 17 | ) 18 | -------------------------------------------------------------------------------- /templates/gtk/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "a starter GTK4 app", 3 | "variables": { 4 | "PROGRAM_NAME": { 5 | "summary": "the name of the program", 6 | "default": "/${PROJECT_NAME}/\\w+/\\L\\0\\E/\\W+/-/", 7 | "pattern": "^[[:word:]-]+$" 8 | }, 9 | "NAMESPACE": { 10 | "summary": "the namespace to use for the application", 11 | "default": "/${PROJECT_NAME}/\\w+/\\u\\0/(\\w)?\\W+(\\w)?(\\w*)/\\1\\u\\2\\L\\3\\E/^\\w/\\u\\0/", 12 | "pattern": "^[A-Za-z_]\\w*$" 13 | }, 14 | "APP_ID": { 15 | "summary": "the application ID", 16 | "default": "com.${USERNAME}.${NAMESPACE}", 17 | "pattern": "^\\w+(\\.\\w+)*$" 18 | } 19 | }, 20 | "templates": [ 21 | "meson.build", 22 | "README.md", 23 | "src/Main.vala", 24 | "src/MainWindow.vala", 25 | "src/meson.build" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /templates/gtk3/.editorconfig: -------------------------------------------------------------------------------- 1 | # taken from gitg 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.vala] 11 | indent_size = 4 12 | indent_style = tab 13 | insert_final_newline = true 14 | max_line_length = 100 15 | 16 | [*.{c,h}] 17 | indent_size = 2 18 | indent_style = space 19 | insert_final_newline = true 20 | max_line_length = 100 21 | 22 | [*.css] 23 | indent_size = 2 24 | indent_style = space 25 | 26 | [*.{ui,xml,xml.in}] 27 | indent_size = 2 28 | indent_style = space 29 | 30 | [*.py] 31 | indent_size = 4 32 | indent_style = space 33 | 34 | [*.json] 35 | indent_style = space 36 | indent_size = 4 37 | 38 | [meson.build] 39 | indent_size = 2 40 | indent_style = space 41 | 42 | -------------------------------------------------------------------------------- /templates/gtk3/README.md: -------------------------------------------------------------------------------- 1 | # ${PROJECT_NAME} 2 | 3 | A shiny new GTK app. 4 | 5 | ## Build instructions: 6 | 7 | ```Bash 8 | $ meson build 9 | $ ninja -C build 10 | $ build/${PROGRAM_NAME} 11 | ``` 12 | -------------------------------------------------------------------------------- /templates/gtk3/meson.build: -------------------------------------------------------------------------------- 1 | project('${PROJECT_NAME}', 'vala', 'c', 2 | version: '${PROJECT_VERSION}') 3 | 4 | deps = [ 5 | dependency('glib-2.0'), 6 | dependency('gobject-2.0'), 7 | dependency('gtk+-3.0') 8 | ] 9 | 10 | add_project_arguments(['--enable-experimental'], language: 'vala') 11 | 12 | subdir('src') 13 | subdir('ui') 14 | 15 | executable('${PROGRAM_NAME}', 16 | [src, resources], 17 | dependencies: deps, 18 | vala_args: [resource_args]) 19 | -------------------------------------------------------------------------------- /templates/gtk3/src/App.vala: -------------------------------------------------------------------------------- 1 | class Starter.App : Gtk.Application { 2 | public App () { 3 | Object (application_id: "org.gnome.${PROGRAM_NAME}", 4 | flags: ApplicationFlags.FLAGS_NONE); 5 | } 6 | 7 | public override void activate () { 8 | base.activate (); 9 | 10 | if (this.get_active_window () == null) { 11 | var window = new MainWindow (); 12 | this.add_window (window); 13 | } 14 | 15 | this.active_window.present (); 16 | } 17 | } 18 | 19 | int main(string[] args) { 20 | return new Starter.App ().run (args); 21 | } 22 | -------------------------------------------------------------------------------- /templates/gtk3/src/MainWindow.vala: -------------------------------------------------------------------------------- 1 | [GtkTemplate (ui = "/org/gnome/${PROGRAM_NAME}/main-window.ui")] 2 | class Starter.MainWindow : Gtk.ApplicationWindow { 3 | [GtkChild] unowned Gtk.Label text; 4 | 5 | [GtkCallback] 6 | private void button_clicked () { 7 | text.label = "clicked!"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /templates/gtk3/src/meson.build: -------------------------------------------------------------------------------- 1 | src = files([ 2 | 'App.vala', 3 | 'MainWindow.vala' 4 | ]) 5 | -------------------------------------------------------------------------------- /templates/gtk3/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "a starter GTK3 app", 3 | "variables": { 4 | "PROGRAM_NAME": { 5 | "summary": "the name of the program", 6 | "default": "/${PROJECT_NAME}/\\w+/\\L\\0\\E/\\W+/-/", 7 | "pattern": "^[[:word:]-]+$" 8 | } 9 | }, 10 | "templates": [ 11 | "meson.build", 12 | "README.md", 13 | "src/App.vala", 14 | "src/MainWindow.vala", 15 | "ui/main-window.ui", 16 | "ui/resources.xml" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /templates/gtk3/ui/main-window.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /templates/gtk3/ui/meson.build: -------------------------------------------------------------------------------- 1 | gnome = import('gnome') 2 | 3 | resources_xml = files('resources.xml') 4 | resources = gnome.compile_resources('resources', resources_xml, source_dir: '.') 5 | 6 | resource_args = [ # valac args 7 | '--gresources', resources_xml, 8 | '--target-glib=2.38' # minimum glib version required for composite templates 9 | ] 10 | -------------------------------------------------------------------------------- /templates/gtk3/ui/resources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | main-window.ui 5 | 6 | 7 | -------------------------------------------------------------------------------- /templates/lib/.editorconfig: -------------------------------------------------------------------------------- 1 | # taken from gitg 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.vala] 11 | indent_size = 4 12 | indent_style = tab 13 | insert_final_newline = true 14 | max_line_length = 100 15 | 16 | [*.{c,h}] 17 | indent_size = 2 18 | indent_style = space 19 | insert_final_newline = true 20 | max_line_length = 100 21 | 22 | [*.css] 23 | indent_size = 2 24 | indent_style = space 25 | 26 | [*.{ui,xml,xml.in}] 27 | indent_size = 2 28 | indent_style = space 29 | 30 | [*.py] 31 | indent_size = 4 32 | indent_style = space 33 | 34 | [*.json] 35 | indent_style = space 36 | indent_size = 4 37 | 38 | [meson.build] 39 | indent_size = 2 40 | indent_style = space 41 | 42 | -------------------------------------------------------------------------------- /templates/lib/README.md: -------------------------------------------------------------------------------- 1 | # ${PROJECT_NAME} 2 | 3 | ${PROJECT_SUMMARY} 4 | -------------------------------------------------------------------------------- /templates/lib/meson.build: -------------------------------------------------------------------------------- 1 | project('${PROJECT_NAME}', 'vala', 'c', 2 | version: '${PROJECT_VERSION}') 3 | 4 | dependencies = [ 5 | dependency('glib-2.0'), 6 | dependency('gobject-2.0') 7 | ] 8 | 9 | pkgconfig = import('pkgconfig') 10 | 11 | PKGCONFIG_DEPS = ['glib-2.0', 'gobject-2.0'] 12 | API_VERSION = '${API_VERSION}' 13 | vapidir = get_option('datadir') / 'vala' / 'vapi' 14 | 15 | add_project_arguments(['--enable-experimental'], language: 'vala') 16 | 17 | g_ir_compiler = find_program('g-ir-compiler', required: false) 18 | 19 | subdir('src') 20 | -------------------------------------------------------------------------------- /templates/lib/meson_options.txt: -------------------------------------------------------------------------------- 1 | option('enable_valadoc', type: 'boolean', value: true) 2 | 3 | -------------------------------------------------------------------------------- /templates/lib/src/library.vala: -------------------------------------------------------------------------------- 1 | namespace ${API_NAMESPACE} { 2 | public static void say_hello () { 3 | stdout.printf ("say_hello () called\n"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /templates/lib/src/meson.build: -------------------------------------------------------------------------------- 1 | conf = configuration_data() 2 | conf.set('prefix', get_option('prefix')) 3 | conf.set('libdir', get_option ('libdir')) 4 | conf.set('PROJECT_NAME', '${PROJECT_NAME}') 5 | conf.set('PROJECT_VERSION', '${PROJECT_VERSION}') 6 | conf.set('API_VERSION', API_VERSION) 7 | 8 | sources = files([ 9 | 'library.vala' 10 | ]) 11 | 12 | lib${LIBRARY_DEPNAME} = library('${LIBRARY_NAME}-' + API_VERSION, 13 | sources, 14 | vala_header: '${LIBRARY_NAME}.h', 15 | vala_vapi: '${LIBRARY_NAME}-' + API_VERSION + '.vapi', 16 | vala_gir: '${API_NAMESPACE}-' + API_VERSION + '.gir', 17 | dependencies : dependencies, 18 | vala_args: [ 19 | '--abi-stability' 20 | ], 21 | install: true, 22 | install_dir: [ 23 | true, 24 | get_option('includedir') / '${LIBRARY_NAME}-' + API_VERSION / '${LIBRARY_NAME}', 25 | vapidir, 26 | g_ir_compiler.found() 27 | ] 28 | ) 29 | 30 | if g_ir_compiler.found() 31 | custom_target('lib${LIBRARY_NAME}-typelib', 32 | command: [ 33 | g_ir_compiler, 34 | '--shared-library', 'lib${LIBRARY_NAME}-@0@.so'.format (API_VERSION), 35 | '--output', '@OUTPUT@', 36 | meson.current_build_dir() / '${API_NAMESPACE}-' + API_VERSION + '.gir' 37 | ], 38 | output: '${API_NAMESPACE}-' + API_VERSION + '.typelib', 39 | depends: lib${LIBRARY_DEPNAME}, 40 | install: true, 41 | install_dir: join_paths(get_option('libdir'), 'girepository-1.0')) 42 | endif 43 | 44 | pkgconfig.generate(lib${LIBRARY_DEPNAME}, 45 | subdirs: '${LIBRARY_NAME}-' + API_VERSION, 46 | version: API_VERSION, 47 | name: '${LIBRARY_NAME}', 48 | filebase: '${LIBRARY_NAME}-' + API_VERSION, 49 | requires: PKGCONFIG_DEPS, 50 | description: '${PROJECT_SUMMARY}') 51 | 52 | if get_option('enable_valadoc') 53 | valadoc = find_program('valadoc') 54 | ${LIBRARY_DEPNAME}_docs = custom_target('${LIBRARY_NAME}_apidocs', 55 | input: sources, 56 | install: true, 57 | # FIXME: Installing to tmp, so the target will be built 58 | # the problem is we cannot access a subfolder of the 59 | # buildtarget via the output parameter. 60 | # Find a nicer solution 61 | install_dir: get_option('datadir') / 'devhelp' / 'books', 62 | command: [ 63 | valadoc, 64 | '-o', meson.current_build_dir() / '${API_NAMESPACE}-' + API_VERSION, 65 | '--doclet', 66 | 'devhelp', 67 | '@INPUT@', 68 | '--force' 69 | ], 70 | output: '${API_NAMESPACE}-' + API_VERSION) 71 | 72 | install_subdir(meson.current_build_dir() / '${API_NAMESPACE}-' + API_VERSION / '${API_NAMESPACE}-' + API_VERSION, 73 | install_dir: get_option('datadir') / 'devhelp' / 'books') 74 | endif 75 | -------------------------------------------------------------------------------- /templates/lib/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "a bare library with minimal dependencies", 3 | "variables": { 4 | "PROJECT_SUMMARY": { 5 | "summary": "a very short summary of the project", 6 | "default": "a library that does awesome things" 7 | }, 8 | "API_NAMESPACE": { 9 | "summary": "the API namespace", 10 | "default": "MyLib", 11 | "pattern": "^[A-Za-z][[:word:]]*$" 12 | }, 13 | "API_VERSION": { 14 | "summary": "the API version", 15 | "default": "0.1", 16 | "pattern": "^\\d+(\\.\\d+)*$" 17 | }, 18 | "LIBRARY_NAME": { 19 | "summary": "the name of the library", 20 | "default": "/${API_NAMESPACE}/\\w+/\\L\\0\\E/", 21 | "pattern": "^[[:word:]][[:word:]-]*$" 22 | }, 23 | "LIBRARY_DEPNAME": { 24 | "summary": "the name of the dependency variable for the library", 25 | "default": "/${LIBRARY_NAME}/-/_/", 26 | "auto": true 27 | } 28 | }, 29 | "templates": [ 30 | "meson.build", 31 | "README.md", 32 | "src/library.vala", 33 | "src/meson.build" 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /templates/meson.build: -------------------------------------------------------------------------------- 1 | install_subdir('eos', install_dir: templates_dir) 2 | install_subdir('gnome', install_dir: templates_dir) 3 | install_subdir('gtk', install_dir: templates_dir) 4 | install_subdir('gtk3', install_dir: templates_dir) 5 | install_subdir('lib', install_dir: templates_dir) 6 | install_subdir('new', install_dir: templates_dir) 7 | -------------------------------------------------------------------------------- /templates/new/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig 2 | root = true 3 | 4 | # elementary defaults 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | indent_size = tab 9 | indent_style = space 10 | insert_final_newline = true 11 | max_line_length = 80 12 | tab_width = 4 13 | 14 | # Markup files 15 | [{*.html,*.xml,*.xml.in,*.yml}] 16 | tab_width = 2 17 | -------------------------------------------------------------------------------- /templates/new/README.md: -------------------------------------------------------------------------------- 1 | # ${PROJECT_NAME} 2 | 3 | A new Vala app 4 | -------------------------------------------------------------------------------- /templates/new/meson.build: -------------------------------------------------------------------------------- 1 | project('${PROJECT_NAME}', 'vala', 'c', 2 | version: '${PROJECT_VERSION}') 3 | 4 | dependencies = [ 5 | dependency('glib-2.0'), 6 | dependency('gobject-2.0') 7 | ] 8 | 9 | add_project_arguments(['--enable-experimental'], language: 'vala') 10 | 11 | subdir('src') 12 | -------------------------------------------------------------------------------- /templates/new/src/main.vala: -------------------------------------------------------------------------------- 1 | int main(string[] args) { 2 | print ("A new Vala app\n"); 3 | return 0; 4 | } 5 | -------------------------------------------------------------------------------- /templates/new/src/meson.build: -------------------------------------------------------------------------------- 1 | sources = [ 2 | 'main.vala' 3 | ] 4 | 5 | executable('${PROGRAM_NAME}', 6 | sources, 7 | dependencies: dependencies, 8 | install: true) 9 | -------------------------------------------------------------------------------- /templates/new/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "a bare app, with minimal dependencies", 3 | "variables": { 4 | "PROGRAM_NAME": { 5 | "summary": "the name of the program", 6 | "default": "/${PROJECT_NAME}/\\w+/\\L\\0\\E/\\W+/-/", 7 | "pattern": "^[[:word:]-]+$" 8 | } 9 | }, 10 | "templates": [ 11 | "meson.build", 12 | "README.md", 13 | "src/meson.build" 14 | ] 15 | } 16 | --------------------------------------------------------------------------------