summaryrefslogtreecommitdiffstats
path: root/subprojects/extensions-tool
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 15:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 15:07:22 +0000
commitf9d480cfe50ca1d7a0f0b5a2b8bb9932962bfbe7 (patch)
treece9e8db2d4e8799780fa72ae8f1953039373e2ee /subprojects/extensions-tool
parentInitial commit. (diff)
downloadgnome-shell-f9d480cfe50ca1d7a0f0b5a2b8bb9932962bfbe7.tar.xz
gnome-shell-f9d480cfe50ca1d7a0f0b5a2b8bb9932962bfbe7.zip
Adding upstream version 3.38.6.upstream/3.38.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'subprojects/extensions-tool')
-rw-r--r--subprojects/extensions-tool/COPYING675
-rw-r--r--subprojects/extensions-tool/README.md23
-rw-r--r--subprojects/extensions-tool/completion/bash/gnome-extensions91
-rwxr-xr-xsubprojects/extensions-tool/generate-translations.sh19
-rw-r--r--subprojects/extensions-tool/man/gnome-extensions.txt212
-rw-r--r--subprojects/extensions-tool/man/meson.build7
-rw-r--r--subprojects/extensions-tool/man/stylesheet.xsl27
-rw-r--r--subprojects/extensions-tool/meson.build80
-rw-r--r--subprojects/extensions-tool/meson_options.txt17
-rw-r--r--subprojects/extensions-tool/po/.gitignore3
l---------subprojects/extensions-tool/po/LINGUAS1
-rw-r--r--subprojects/extensions-tool/po/meson.build1
-rw-r--r--subprojects/extensions-tool/src/command-create.c509
-rw-r--r--subprojects/extensions-tool/src/command-disable.c129
-rw-r--r--subprojects/extensions-tool/src/command-enable.c129
-rw-r--r--subprojects/extensions-tool/src/command-info.c113
-rw-r--r--subprojects/extensions-tool/src/command-install.c213
-rw-r--r--subprojects/extensions-tool/src/command-list.c196
-rw-r--r--subprojects/extensions-tool/src/command-pack.c516
-rw-r--r--subprojects/extensions-tool/src/command-prefs.c107
-rw-r--r--subprojects/extensions-tool/src/command-reset.c86
-rw-r--r--subprojects/extensions-tool/src/command-uninstall.c114
-rw-r--r--subprojects/extensions-tool/src/commands.h38
-rw-r--r--subprojects/extensions-tool/src/common.h73
-rw-r--r--subprojects/extensions-tool/src/gnome-extensions-tool.gresource.xml11
-rw-r--r--subprojects/extensions-tool/src/main.c408
-rw-r--r--subprojects/extensions-tool/src/meson.build37
-rw-r--r--subprojects/extensions-tool/src/templates/00-plain.desktop.in5
-rw-r--r--subprojects/extensions-tool/src/templates/indicator.desktop.in5
-rw-r--r--subprojects/extensions-tool/src/templates/indicator/extension.js74
-rw-r--r--subprojects/extensions-tool/src/templates/indicator/stylesheet.css1
-rw-r--r--subprojects/extensions-tool/src/templates/meson.build13
-rw-r--r--subprojects/extensions-tool/src/templates/plain/extension.js34
-rw-r--r--subprojects/extensions-tool/src/templates/plain/stylesheet.css1
34 files changed, 3968 insertions, 0 deletions
diff --git a/subprojects/extensions-tool/COPYING b/subprojects/extensions-tool/COPYING
new file mode 100644
index 0000000..10926e8
--- /dev/null
+++ b/subprojects/extensions-tool/COPYING
@@ -0,0 +1,675 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+
diff --git a/subprojects/extensions-tool/README.md b/subprojects/extensions-tool/README.md
new file mode 100644
index 0000000..dc2e2d7
--- /dev/null
+++ b/subprojects/extensions-tool/README.md
@@ -0,0 +1,23 @@
+# gnome-extensions-tool
+gnome-extensions-tool is a command line utility for managing
+GNOME Shell extensions. It is usually built as part of gnome-shell,
+but can be used as a stand-alone project as well (for example to
+create an extension bundle as part of continuous integration).
+
+Bugs should be reported to the GNOME [bug tracking system][bug-tracker].
+
+## Building
+Before the project can be built stand-alone, the po directory has
+to be populated with translations (from gnome-shell).
+
+To do that, simply run the included script:
+```sh
+$ ./generate-translations.sh
+```
+
+## License
+gnome-extensions-tool is distributed under the terms of the GNU General Public
+License, version 3 or later. See the [COPYING][license] file for details.
+
+[bug-tracker]: https://gitlab.gnome.org/GNOME/gnome-shell/issues
+[license]: COPYING
diff --git a/subprojects/extensions-tool/completion/bash/gnome-extensions b/subprojects/extensions-tool/completion/bash/gnome-extensions
new file mode 100644
index 0000000..05cd039
--- /dev/null
+++ b/subprojects/extensions-tool/completion/bash/gnome-extensions
@@ -0,0 +1,91 @@
+
+# Check for bash
+[ -z "$BASH_VERSION" ] && return
+
+################################################################################
+
+__gnome_extensions() {
+ local commands="version enable disable reset info install show list create pack prefs uninstall"
+ local COMMAND=${COMP_WORDS[1]}
+
+ _init_completion -s || return
+
+ case "${COMP_CWORD}" in
+ 1)
+ COMPREPLY=($(compgen -W "help $commands" -- "$2"))
+ return 0
+ ;;
+
+ 2)
+ case "$COMMAND" in
+ help)
+ COMPREPLY=($(compgen -W "$commands" -- "$2"))
+ return 0
+ ;;
+
+ disable)
+ local list_opt=--enabled
+ ;;&
+ enable)
+ local list_opt=--disabled
+ ;;&
+ prefs)
+ local list_opt=--prefs
+ ;;&
+ uninstall)
+ local list_opt=--user
+ ;;&
+ enable|disable|info|show|prefs|reset|uninstall)
+ COMPREPLY=($(compgen -W "`gnome-extensions list $list_opt`" -- "$2"))
+ return 0
+ ;;
+ esac
+ ;;
+ esac
+
+ case "$COMMAND" in
+ create)
+ case "$prev" in
+ --template)
+ COMPREPLY=($(compgen -W "`gnome-extensions create --list-templates`" -- "$2"))
+ return 0
+ ;;
+ esac
+ ;;
+ pack)
+ case "$prev" in
+ --podir|--out-dir|-o)
+ _filedir -d
+ return 0
+ ;;
+ --schema)
+ _filedir gschema.xml
+ return 0
+ ;;
+ --extra-source)
+ _filedir
+ return 0
+ ;;
+ esac
+ ;;
+ install)
+ if [[ $cur != -* ]]
+ then
+ _filedir zip
+ return 0
+ fi
+ ;;
+ esac
+
+ # Stop if we are currently waiting for an option value
+ $split && return
+
+ # Otherwise, get the supported options for ${COMMAND} (if any)
+ COMPREPLY=($(compgen -W "$(_parse_help $1 "help $COMMAND")" -- "$2"))
+ [[ $COMPREPLY == *= ]] && compopt -o nospace
+ return 0
+}
+
+################################################################################
+
+complete -F __gnome_extensions gnome-extensions
diff --git a/subprojects/extensions-tool/generate-translations.sh b/subprojects/extensions-tool/generate-translations.sh
new file mode 100755
index 0000000..9f63081
--- /dev/null
+++ b/subprojects/extensions-tool/generate-translations.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/bash
+
+cd $(dirname $0)
+
+sed -e '/subprojects\/extensions-tool/!d' \
+ -e 's:subprojects/extensions-tool/::' ../../po/POTFILES.in > po/POTFILES.in
+
+for l in $(<po/LINGUAS)
+do
+ cp ../../po/$l.po po/$l.po
+done
+
+builddir=$(mktemp -d -p.)
+
+meson -Dman=False $builddir
+ninja -C $builddir gnome-extensions-tool-pot
+ninja -C $builddir gnome-extensions-tool-update-po
+
+rm -rf $builddir
diff --git a/subprojects/extensions-tool/man/gnome-extensions.txt b/subprojects/extensions-tool/man/gnome-extensions.txt
new file mode 100644
index 0000000..adc08e9
--- /dev/null
+++ b/subprojects/extensions-tool/man/gnome-extensions.txt
@@ -0,0 +1,212 @@
+GNOME-EXTENSIONS(1)
+===================
+:man manual: User Commands
+:man source: GNOME-EXTENSIONS-TOOL
+:doctype: manpage
+:date: August 2018
+
+NAME
+----
+gnome-extensions - Command line tool for managing GNOME extensions
+
+SYNOPSIS
+--------
+*gnome-extensions* help ['COMMAND']
+
+*gnome-extensions* version
+
+*gnome-extensions* enable 'UUID'
+
+*gnome-extensions* disable 'UUID'
+
+*gnome-extensions* reset 'UUID'
+
+*gnome-extensions* info 'UUID'
+
+*gnome-extensions* show 'UUID'
+
+*gnome-extensions* list ['OPTION'...]
+
+*gnome-extensions* prefs 'UUID'
+
+*gnome-extensions* create ['OPTION'...]
+
+*gnome-extensions* pack ['OPTION'...]
+
+*gnome-extensions* install ['OPTION'...] 'PACK'
+
+*gnome-extensions* uninstall 'UUID'
+
+DESCRIPTION
+-----------
+*gnome-extensions* is a utility that makes some common GNOME extensions
+operations available on the command line.
+
+COMMON OPTIONS
+--------------
+All commands except for *help* and *version* handle the following options:
+
+*--quiet*, *-q*::
+Do not print error messages
+
+COMMANDS
+--------
+*help* ['COMMAND']::
+Displays a short synopsis of the available commands or provides
+detailed help on a specific command.
+
+*version*::
+Prints the program version.
+
+*enable* 'UUID'::
+Enables the extension identified by 'UUID'.
++
+The command will not detect any errors from the extension itself, use the
+*info* command to confirm that the extension state is *ENABLED*.
++
+If the extension is already enabled, the command will do nothing.
+
+*disable* 'UUID'::
+Disables the extension identified by 'UUID'.
++
+If the extension is not enabled, the command will do nothing.
+
+*reset* 'UUID'::
+Reset the extension identified by 'UUID'.
++
+The extension will be disabled in GNOME, but may be enabled by other sessions
+like GNOME Classic.
+
+*info* 'UUID'::
+Show details of the extension identified by 'UUID', including name,
+description and state.
+
+*show* 'UUID'::
+Synonym of info.
+
+*list* ['OPTION'...]::
+Displays a list of installed extensions.
++
+.Options
+ *--user*;;
+ Include extensions installed in the user's *$HOME*
+
+ *--system*;;
+ Include extensions installed in the system
+
+ *--enabled*;;
+ Include enabled extensions
+
+ *--disabled*;;
+ Include disabled extensions
+
+ *--prefs*;;
+ Only include extensions with preferences
+
+ *--updates*;;
+ Only include extensions with pending updates
+
+ *-d*;;
+ *--details*;;
+ Show some extra information for each extension
+
+*prefs* 'UUID'::
+Open the preference dialog of the extension identified by 'UUID'.
+
+
+*create* ['OPTION'...]::
+Creates a new extension from a template.
++
+.Options
+ *--name*='NAME':::
+ Set the user-visible name in the extension's metadata
+ to 'NAME'
+
+ *--description*='DESC':::
+ Set the description in the extension's metadata to 'DESC'
+
+ *--uuid*='UUID':::
+ Set the unique extension ID in the metadata to 'UUID'
+
+ *--template*='TEMPLATE':::
+ Use 'TEMPLATE' as base for the new extension
+
+ *-i*:::
+ *--interactive*:::
+ Prompt for any extension metadata that hasn't been provided
+ on the command line
+
+*pack* ['OPTION'...] ['SOURCE-DIRECTORY']::
+Creates an extension bundle that is suitable for publishing.
++
+The bundle will always include the required files extension.js
+and metadata.json, as well as the optional stylesheet.css and
+prefs.js if found. Each additional source that should be included
+must be specified with *--extra-source*.
++
+If the extension includes one or more GSettings schemas, they can
+either be placed in a schemas/ folder to be picked up automatically,
+or be specified with *--schema*.
++
+Similarily, translations are included automatically when they are
+located in a po/ folder, otherwise the *--podir* option can be
+used to point to the correct directory. If no gettext domain is
+provided on the command line, the value of the *gettext-domain*
+metadata field is used if it exists, and the extension UUID
+if not.
++
+All files are searched in 'SOURCE-DIRECTORY' if specified, or
+the current directory otherwise.
++
+.Options
+ *--extra-source*='FILE':::
+ Additional source to include in the bundle
+
+ *--schema*='SCHEMA':::
+ A GSettings schema that should be compiled and
+ included
+
+ *--podir*='PODIR':::
+ A directory with translations that should be
+ compiled and included
+
+ *--gettext-domain*='DOMAIN':::
+ The gettext domain to use for translations
+
+ *-f*:::
+ *--force*:::
+ Overwrite an existing pack
+
+ *-o*:::
+ *--out-dir*='DIRECTORY':::
+ The directory where the pack should be created
+
+*install* ['OPTION'...] 'PACK'::
+Installs an extension from the bundle 'PACK'.
++
+The command unpacks the extension files and moves them to
+the expected location in the user's *$HOME*, so that it
+will be loaded in the next session.
++
+It is mainly intended for testing, not as a replacement for
+GNOME Software or the extension website. As extensions have
+privileged access to the user's session, it is advised to
+never load extensions from untrusted sources without carefully
+reviewing their content.
++
+.Options
+ *--force*:::
+ Override an existing extension
+
+*uninstall* 'UUID'::
+Uninstalls the extension identified by 'UUID'.
+
+
+EXIT STATUS
+-----------
+On success 0 is returned, a non-zero failure code otherwise.
+
+BUGS
+----
+The tool is part of the gnome-shell project, and bugs should be reported
+in its issue tracker at https://gitlab.gnome.org/GNOME/gnome-shell/issues.
diff --git a/subprojects/extensions-tool/man/meson.build b/subprojects/extensions-tool/man/meson.build
new file mode 100644
index 0000000..643509c
--- /dev/null
+++ b/subprojects/extensions-tool/man/meson.build
@@ -0,0 +1,7 @@
+custom_target('gnome-extensions.1',
+ input: ['gnome-extensions.txt', 'stylesheet.xsl'],
+ output: 'gnome-extensions.1',
+ command: [a2x, '-D', '@OUTDIR@', '--xsl-file', '@INPUT1@', '-f', 'manpage', '@INPUT0@'],
+ install_dir: mandir + '/man1',
+ install: true
+)
diff --git a/subprojects/extensions-tool/man/stylesheet.xsl b/subprojects/extensions-tool/man/stylesheet.xsl
new file mode 100644
index 0000000..047bd1b
--- /dev/null
+++ b/subprojects/extensions-tool/man/stylesheet.xsl
@@ -0,0 +1,27 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version='1.0'>
+<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"/>
+
+<xsl:template match="variablelist/title">
+ <xsl:text>.PP&#10;</xsl:text>
+ <xsl:call-template name="bold">
+ <xsl:with-param name="node" select="."/>
+ <xsl:with-param name="context" select=".."/>
+ </xsl:call-template>
+ <xsl:text>&#10;</xsl:text>
+</xsl:template>
+
+<xsl:template match="varlistentry[preceding-sibling::title]">
+ <xsl:if test="not(preceding-sibling::varlistentry)">
+ <xsl:text>.RS 4&#10;</xsl:text>
+ <!-- comment out the leading .PP added by the original template -->
+ <xsl:text>.\"</xsl:text>
+ </xsl:if>
+ <xsl:apply-imports/>
+ <xsl:if test="position() = last()">
+ <xsl:text>.RE&#10;</xsl:text>
+ </xsl:if>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/subprojects/extensions-tool/meson.build b/subprojects/extensions-tool/meson.build
new file mode 100644
index 0000000..1e57f23
--- /dev/null
+++ b/subprojects/extensions-tool/meson.build
@@ -0,0 +1,80 @@
+project('gnome-extensions-tool', 'c',
+ version: '3.38.6',
+ meson_version: '>= 0.53.0',
+ license: 'GPLv2+'
+)
+
+gio_req = '>= 2.56.0'
+
+gnome = import('gnome')
+i18n = import('i18n')
+
+if meson.is_subproject()
+ package_name = get_option('package_name')
+ assert(package_name != '',
+ 'package_name must be specified for subproject builds')
+else
+ package_name = meson.project_name()
+endif
+
+package_version = meson.project_version()
+prefix = get_option('prefix')
+
+bindir = join_paths(prefix, get_option('bindir'))
+datadir = join_paths(prefix, get_option('datadir'))
+mandir = join_paths(prefix, get_option('mandir'))
+
+localedir = join_paths(datadir, 'locale')
+
+gio_dep = dependency('gio-2.0', version: gio_req)
+gio_unix_dep = dependency('gio-unix-2.0', version: gio_req)
+autoar_dep = dependency('gnome-autoar-0')
+json_dep = dependency('json-glib-1.0')
+
+cc = meson.get_compiler('c')
+
+bash_completion = dependency('bash-completion', required: get_option('bash_completion'))
+
+po_dir = meson.source_root() + '/po'
+
+subdir('src')
+
+if bash_completion.found()
+ install_data('completion/bash/gnome-extensions',
+ install_dir: bash_completion.get_pkgconfig_variable('completionsdir', define_variable: ['datadir', datadir])
+ )
+endif
+
+if get_option('man')
+ a2x = find_program('a2x')
+
+ subdir('man')
+endif
+
+if not meson.is_subproject()
+ subdir('po')
+
+ summary_dirs = {
+ 'prefix': get_option('prefix'),
+ 'bindir': get_option('bindir'),
+ 'datadir': get_option('datadir'),
+ }
+
+ if get_option('man')
+ summary_dirs += { 'mandir': get_option('mandir') }
+ endif
+
+ summary_build = {
+ 'buildtype': get_option('buildtype'),
+ 'debug': get_option('debug'),
+ }
+
+ summary_options = {
+ 'man': get_option('man'),
+ 'bash_completion': bash_completion.found(),
+ }
+
+ summary(summary_dirs, section: 'Directories')
+ summary(summary_build, section: 'Build Configuration')
+ summary(summary_options, section: 'Build Options')
+endif
diff --git a/subprojects/extensions-tool/meson_options.txt b/subprojects/extensions-tool/meson_options.txt
new file mode 100644
index 0000000..fb6e370
--- /dev/null
+++ b/subprojects/extensions-tool/meson_options.txt
@@ -0,0 +1,17 @@
+option('man',
+ type: 'boolean',
+ value: true,
+ description: 'Generate man pages',
+ yield: true,
+)
+
+option('bash_completion',
+ type: 'feature',
+ value: 'auto',
+ description: 'Install bash completion support',
+)
+
+option('package_name',
+ type: 'string',
+ description: 'The gettext domain name when used as a subproject'
+)
diff --git a/subprojects/extensions-tool/po/.gitignore b/subprojects/extensions-tool/po/.gitignore
new file mode 100644
index 0000000..3b2228d
--- /dev/null
+++ b/subprojects/extensions-tool/po/.gitignore
@@ -0,0 +1,3 @@
+*.po
+*.pot
+POTFILES.in
diff --git a/subprojects/extensions-tool/po/LINGUAS b/subprojects/extensions-tool/po/LINGUAS
new file mode 120000
index 0000000..4fb83a5
--- /dev/null
+++ b/subprojects/extensions-tool/po/LINGUAS
@@ -0,0 +1 @@
+../../../po/LINGUAS \ No newline at end of file
diff --git a/subprojects/extensions-tool/po/meson.build b/subprojects/extensions-tool/po/meson.build
new file mode 100644
index 0000000..5a1b0e2
--- /dev/null
+++ b/subprojects/extensions-tool/po/meson.build
@@ -0,0 +1 @@
+i18n.gettext(package_name, preset: 'glib')
diff --git a/subprojects/extensions-tool/src/command-create.c b/subprojects/extensions-tool/src/command-create.c
new file mode 100644
index 0000000..b328b60
--- /dev/null
+++ b/subprojects/extensions-tool/src/command-create.c
@@ -0,0 +1,509 @@
+/* command-create.c
+ *
+ * Copyright 2018 Florian Müllner <fmuellner@gnome.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define _GNU_SOURCE /* for strcasestr */
+#include <string.h>
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+#include <gio/gdesktopappinfo.h>
+#include <gio/gunixinputstream.h>
+
+#include "commands.h"
+#include "common.h"
+#include "config.h"
+
+#define TEMPLATES_PATH "/org/gnome/extensions-tool/templates"
+#define TEMPLATE_KEY "Path"
+#define SORT_DATA "desktop-id"
+
+static char *
+get_shell_version (GError **error)
+{
+ g_autoptr (GDBusProxy) proxy = NULL;
+ g_autoptr (GVariant) variant = NULL;
+ g_auto (GStrv) split_version = NULL;
+
+ proxy = get_shell_proxy (error);
+ if (proxy == NULL)
+ return NULL;
+
+ variant = g_dbus_proxy_get_cached_property (proxy, "ShellVersion");
+ if (variant == NULL)
+ return NULL;
+
+ split_version = g_strsplit (g_variant_get_string (variant, NULL), ".", 3);
+ if (g_ascii_strtoll (split_version[1], NULL, 10) % 2 == 0)
+ g_clear_pointer (&split_version[2], g_free);
+
+ return g_strjoinv (".", split_version);
+}
+
+static GDesktopAppInfo *
+load_app_info_from_resource (const char *uri)
+{
+ g_autoptr (GFile) file = NULL;
+ g_autofree char *contents = NULL;
+ g_autoptr (GKeyFile) keyfile = NULL;
+
+ file = g_file_new_for_uri (uri);
+ if (!g_file_load_contents (file, NULL, &contents, NULL, NULL, NULL))
+ return NULL;
+
+ keyfile = g_key_file_new ();
+ if (!g_key_file_load_from_data (keyfile, contents, -1, G_KEY_FILE_NONE, NULL))
+ return NULL;
+
+ return g_desktop_app_info_new_from_keyfile (keyfile);
+}
+
+static int
+sort_func (gconstpointer a, gconstpointer b)
+{
+ GObject *info1 = *((GObject **) a);
+ GObject *info2 = *((GObject **) b);
+ const char *desktop1 = g_object_get_data (info1, SORT_DATA);
+ const char *desktop2 = g_object_get_data (info2, SORT_DATA);
+
+ return g_strcmp0 (desktop1, desktop2);
+}
+
+static GPtrArray *
+get_templates (void)
+{
+ g_auto (GStrv) children = NULL;
+ GPtrArray *templates = g_ptr_array_new_with_free_func (g_object_unref);
+ char **s;
+
+ children = g_resources_enumerate_children (TEMPLATES_PATH, 0, NULL);
+
+ for (s = children; *s; s++)
+ {
+ g_autofree char *uri = NULL;
+ GDesktopAppInfo *info;
+
+ if (!g_str_has_suffix (*s, ".desktop"))
+ continue;
+
+ uri = g_strdup_printf ("resource://" TEMPLATES_PATH "/%s", *s);
+ info = load_app_info_from_resource (uri);
+ if (!info)
+ continue;
+
+ g_object_set_data_full (G_OBJECT (info), SORT_DATA, g_strdup (*s), g_free);
+ g_ptr_array_add (templates, info);
+ }
+
+ g_ptr_array_sort (templates, sort_func);
+
+ return templates;
+}
+
+static char *
+escape_json_string (const char *string)
+{
+ GString *escaped = g_string_new (string);
+
+ for (gsize i = 0; i < escaped->len; ++i)
+ {
+ if (escaped->str[i] == '"' || escaped->str[i] == '\\')
+ {
+ g_string_insert_c (escaped, i, '\\');
+ ++i;
+ }
+ }
+
+ return g_string_free (escaped, FALSE);
+}
+
+static gboolean
+create_metadata (GFile *target_dir,
+ const char *uuid,
+ const char *name,
+ const char *description,
+ GError **error)
+{
+ g_autofree char *uuid_escaped = NULL;
+ g_autofree char *name_escaped = NULL;
+ g_autofree char *desc_escaped = NULL;
+ g_autoptr (GFile) target = NULL;
+ g_autoptr (GString) json = NULL;
+ g_autofree char *version = NULL;
+
+ version = get_shell_version (error);
+ if (version == NULL)
+ return FALSE;
+
+ uuid_escaped = escape_json_string (uuid);
+ name_escaped = escape_json_string (name);
+ desc_escaped = escape_json_string (description);
+
+ json = g_string_new ("{\n");
+
+ g_string_append_printf (json, " \"name\": \"%s\",\n", name_escaped);
+ g_string_append_printf (json, " \"description\": \"%s\",\n", desc_escaped);
+ g_string_append_printf (json, " \"uuid\": \"%s\",\n", uuid_escaped);
+ g_string_append_printf (json, " \"shell-version\": [\n");
+ g_string_append_printf (json, " \"%s\"\n", version);
+ g_string_append_printf (json, " ]\n}\n");
+
+ target = g_file_get_child (target_dir, "metadata.json");
+ return g_file_replace_contents (target,
+ json->str,
+ json->len,
+ NULL,
+ FALSE,
+ 0,
+ NULL,
+ NULL,
+ error);
+}
+
+
+static gboolean
+copy_extension_template (const char *template, GFile *target_dir, GError **error)
+{
+ g_auto (GStrv) templates = NULL;
+ g_autofree char *path = NULL;
+ char **s;
+
+ path = g_strdup_printf (TEMPLATES_PATH "/%s", template);
+ templates = g_resources_enumerate_children (path, 0, NULL);
+
+ if (templates == NULL)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+ "No template %s", template);
+ return FALSE;
+ }
+
+ for (s = templates; *s; s++)
+ {
+ g_autoptr (GFile) target = NULL;
+ g_autoptr (GFile) source = NULL;
+ g_autofree char *uri = NULL;
+
+ uri = g_strdup_printf ("resource://%s/%s", path, *s);
+ source = g_file_new_for_uri (uri);
+ target = g_file_get_child (target_dir, *s);
+
+ if (!g_file_copy (source, target, G_FILE_COPY_TARGET_DEFAULT_PERMS, NULL, NULL, NULL, error))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+launch_extension_source (GFile *dir, GError **error)
+{
+ g_autoptr (GFile) main_source = NULL;
+ g_autoptr (GAppInfo) handler = NULL;
+ GList l;
+
+ main_source = g_file_get_child (dir, "extension.js");
+ handler = g_file_query_default_handler (main_source, NULL, NULL);
+ if (handler == NULL)
+ {
+ /* Translators: a file path to an extension directory */
+ g_print (_("The new extension was successfully created in %s.\n"),
+ g_file_peek_path (dir));
+ return TRUE;
+ }
+
+ l.data = main_source;
+ l.next = l.prev = NULL;
+
+ return g_app_info_launch (handler, &l, NULL, error);
+}
+
+static gboolean
+create_extension (const char *uuid, const char *name, const char *description, const char *template)
+{
+ g_autoptr (GFile) dir = NULL;
+ g_autoptr (GError) error = NULL;
+
+ if (template == NULL)
+ template = "plain";
+
+ dir = g_file_new_build_filename (g_get_user_data_dir (),
+ "gnome-shell",
+ "extensions",
+ uuid,
+ NULL);
+
+ if (!g_file_make_directory_with_parents (dir, NULL, &error))
+ {
+ g_printerr ("%s\n", error->message);
+ return FALSE;
+ }
+
+ if (!create_metadata (dir, uuid, name, description, &error))
+ {
+ g_printerr ("%s\n", error->message);
+ return FALSE;
+ }
+
+ if (!copy_extension_template (template, dir, &error))
+ {
+ g_printerr ("%s\n", error->message);
+ return FALSE;
+ }
+
+ if (!launch_extension_source (dir, &error))
+ {
+ g_printerr ("%s\n", error->message);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+prompt_metadata (char **uuid, char **name, char **description, char **template)
+{
+ g_autoptr (GInputStream) stdin = NULL;
+ g_autoptr (GDataInputStream) istream = NULL;
+
+ if ((uuid == NULL || *uuid != NULL) &&
+ (name == NULL || *name != NULL) &&
+ (description == NULL || *description != NULL) &&
+ (template == NULL || *template != NULL))
+ return;
+
+ stdin = g_unix_input_stream_new (0, FALSE);
+ istream = g_data_input_stream_new (stdin);
+
+ if (name != NULL && *name == NULL)
+ {
+ char *line = NULL;
+
+ g_print (
+ _("Name should be a very short (ideally descriptive) string.\n"
+ "Examples are: %s"),
+ "“Click To Focus”, “Adblock”, “Shell Window Shrinker”\n");
+
+ while (line == NULL)
+ {
+ g_print ("%s: ", _("Name"));
+
+ line = g_data_input_stream_read_line_utf8 (istream, NULL, NULL, NULL);
+ }
+ *name = g_strdelimit (line, "\n", '\0');
+
+ g_print ("\n");
+ }
+
+ if (description != NULL && *description == NULL)
+ {
+ char *line = NULL;
+
+ g_print (
+ _("Description is a single-sentence explanation of what your extension does.\n"
+ "Examples are: %s"),
+ "“Make windows visible on click”, “Block advertisement popups”, “Animate windows shrinking on minimize”\n");
+
+ while (line == NULL)
+ {
+ g_print ("%s: ", _("Description"));
+
+ line = g_data_input_stream_read_line_utf8 (istream, NULL, NULL, NULL);
+ }
+ *description = g_strdelimit (line, "\n", '\0');
+
+ g_print ("\n");
+ }
+
+ if (uuid != NULL && *uuid == NULL)
+ {
+ char *line = NULL;
+
+ g_print (
+ _("UUID is a globally-unique identifier for your extension.\n"
+ "This should be in the format of an email address (clicktofocus@janedoe.example.com)\n"));
+
+ while (line == NULL)
+ {
+ g_print ("UUID: ");
+
+ line = g_data_input_stream_read_line_utf8 (istream, NULL, NULL, NULL);
+ }
+ *uuid = g_strdelimit (line, "\n", '\0');
+
+ g_print ("\n");
+ }
+
+ if (template != NULL && *template == NULL)
+ {
+ g_autoptr (GPtrArray) templates = get_templates ();
+
+ if (templates->len == 1)
+ {
+ GDesktopAppInfo *info = g_ptr_array_index (templates, 0);
+ *template = g_desktop_app_info_get_string (info, TEMPLATE_KEY);
+ }
+ else
+ {
+ int i;
+
+ g_print (_("Choose one of the available templates:\n"));
+ for (i = 0; i < templates->len; i++)
+ {
+ GAppInfo *info = g_ptr_array_index (templates, i);
+ g_print ("%d) %-10s – %s\n",
+ i + 1,
+ g_app_info_get_name (info),
+ g_app_info_get_description (info));
+ }
+
+ while (*template == NULL)
+ {
+ g_autofree char *line = NULL;
+
+ g_print ("%s [1-%d]: ", _("Template"), templates->len);
+
+ line = g_data_input_stream_read_line_utf8 (istream, NULL, NULL, NULL);
+
+ if (line == NULL)
+ continue;
+
+ if (g_ascii_isdigit (*line))
+ {
+ long i = strtol (line, NULL, 10);
+
+ if (i > 0 && i <= templates->len)
+ {
+ GDesktopAppInfo *info;
+
+ info = g_ptr_array_index (templates, i - 1);
+ *template =
+ g_desktop_app_info_get_string (info, TEMPLATE_KEY);
+ }
+ }
+ else
+ {
+ for (i = 0; i < templates->len; i++)
+ {
+ GDesktopAppInfo *info = g_ptr_array_index (templates, i);
+ g_autofree char *cur_template = NULL;
+
+ cur_template =
+ g_desktop_app_info_get_string (info, TEMPLATE_KEY);
+
+ if (strcasestr (cur_template, line) != NULL)
+ *template = g_steal_pointer (&cur_template);
+ }
+ }
+ }
+ g_print ("\n");
+ }
+ }
+}
+
+int
+handle_create (int argc, char *argv[], gboolean do_help)
+{
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (GError) error = NULL;
+ g_autofree char *name = NULL;
+ g_autofree char *description = NULL;
+ g_autofree char *uuid = NULL;
+ g_autofree char *template = NULL;
+ gboolean interactive = FALSE;
+ gboolean list_templates = FALSE;
+ GOptionEntry entries[] = {
+ { .long_name = "uuid",
+ .arg = G_OPTION_ARG_STRING, .arg_data = &uuid,
+ .arg_description = "UUID",
+ .description = _("The unique identifier of the new extension") },
+ { .long_name = "name",
+ .arg = G_OPTION_ARG_STRING, .arg_data = &name,
+ .arg_description = _("NAME"),
+ .description = _("The user-visible name of the new extension") },
+ { .long_name = "description",
+ .arg_description = _("DESCRIPTION"),
+ .arg = G_OPTION_ARG_STRING, .arg_data = &description,
+ .description = _("A short description of what the extension does") },
+ { .long_name = "template",
+ .arg = G_OPTION_ARG_STRING, .arg_data = &template,
+ .arg_description = _("TEMPLATE"),
+ .description = _("The template to use for the new extension") },
+ { .long_name = "list-templates",
+ .arg = G_OPTION_ARG_NONE, .arg_data = &list_templates,
+ .flags = G_OPTION_FLAG_HIDDEN },
+ { .long_name = "interactive", .short_name = 'i',
+ .arg = G_OPTION_ARG_NONE, .arg_data = &interactive,
+ .description = _("Enter extension information interactively") },
+ { NULL }
+ };
+
+ g_set_prgname ("gnome-extensions create");
+
+ context = g_option_context_new (NULL);
+ g_option_context_set_help_enabled (context, FALSE);
+ g_option_context_set_summary (context, _("Create a new extension"));
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, get_option_group ());
+
+ if (do_help)
+ {
+ show_help (context, NULL);
+ return 0;
+ }
+
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ show_help (context, error->message);
+ return 1;
+ }
+
+ if (argc > 1)
+ {
+ show_help (context, _("Unknown arguments"));
+ return 1;
+ }
+
+ if (list_templates)
+ {
+ g_autoptr (GPtrArray) templates = get_templates ();
+ int i;
+
+ for (i = 0; i < templates->len; i++)
+ {
+ GDesktopAppInfo *info = g_ptr_array_index (templates, i);
+ g_autofree char *template = NULL;
+
+ template = g_desktop_app_info_get_string (info, TEMPLATE_KEY);
+ g_print ("%s\n", template);
+ }
+ return 0;
+ }
+
+ if (interactive)
+ prompt_metadata (&uuid, &name, &description, &template);
+
+ if (uuid == NULL || name == NULL || description == NULL)
+ {
+ show_help (context, _("UUID, name and description are required"));
+ return 1;
+ }
+
+ return create_extension (uuid, name, description, template) ? 0 : 2;
+}
diff --git a/subprojects/extensions-tool/src/command-disable.c b/subprojects/extensions-tool/src/command-disable.c
new file mode 100644
index 0000000..93c316b
--- /dev/null
+++ b/subprojects/extensions-tool/src/command-disable.c
@@ -0,0 +1,129 @@
+/* command-disable.c
+ *
+ * Copyright 2018 Florian Müllner <fmuellner@gnome.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include "commands.h"
+#include "common.h"
+#include "config.h"
+
+static gboolean
+disable_extension_dbus (GDBusProxy *proxy,
+ const char *uuid)
+{
+ g_autoptr (GVariant) response = NULL;
+ g_autoptr (GError) error = NULL;
+ gboolean success = FALSE;
+
+ response = g_dbus_proxy_call_sync (proxy,
+ "DisableExtension",
+ g_variant_new ("(s)", uuid),
+ 0,
+ -1,
+ NULL,
+ &error);
+
+ if (response == NULL)
+ {
+ g_printerr (_("Failed to connect to GNOME Shell\n"));
+ return FALSE;
+ }
+
+ g_variant_get (response, "(b)", &success);
+
+ if (!success)
+ g_printerr (_("Extension “%s” does not exist\n"), uuid);
+
+ return success;
+}
+
+static gboolean
+disable_extension_gsettings (const char *uuid)
+{
+ g_autoptr(GSettings) settings = get_shell_settings ();
+
+ if (settings == NULL)
+ return FALSE;
+
+ return settings_list_remove (settings, "enabled-extensions", uuid) &&
+ settings_list_add (settings, "disabled-extensions", uuid);
+}
+
+static gboolean
+disable_extension (const char *uuid)
+{
+ g_autoptr (GDBusProxy) proxy = NULL;
+ g_autoptr (GError) error = NULL;
+
+ proxy = get_shell_proxy (&error);
+
+ if (proxy != NULL)
+ return disable_extension_dbus (proxy, uuid);
+ else
+ return disable_extension_gsettings (uuid);
+}
+
+int
+handle_disable (int argc, char *argv[], gboolean do_help)
+{
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (GError) error = NULL;
+ g_auto(GStrv) uuids = NULL;
+ GOptionEntry entries[] = {
+ { .long_name = G_OPTION_REMAINING,
+ .arg_description = "UUID",
+ .arg = G_OPTION_ARG_STRING_ARRAY, .arg_data = &uuids },
+ { NULL }
+ };
+
+ g_set_prgname ("gnome-extensions disable");
+
+ context = g_option_context_new (NULL);
+ g_option_context_set_help_enabled (context, FALSE);
+ g_option_context_set_summary (context, _("Disable an extension"));
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, get_option_group());
+
+ if (do_help)
+ {
+ show_help (context, NULL);
+ return 0;
+ }
+
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ show_help (context, error->message);
+ return 1;
+ }
+
+ if (uuids == NULL)
+ {
+ show_help (context, _("No UUID given"));
+ return 1;
+ }
+ else if (g_strv_length (uuids) > 1)
+ {
+ show_help (context, _("More than one UUID given"));
+ return 1;
+ }
+
+ return disable_extension (*uuids) ? 0 : 2;
+}
diff --git a/subprojects/extensions-tool/src/command-enable.c b/subprojects/extensions-tool/src/command-enable.c
new file mode 100644
index 0000000..6ae3a83
--- /dev/null
+++ b/subprojects/extensions-tool/src/command-enable.c
@@ -0,0 +1,129 @@
+/* command-enable.c
+ *
+ * Copyright 2018 Florian Müllner <fmuellner@gnome.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include "commands.h"
+#include "common.h"
+#include "config.h"
+
+static gboolean
+enable_extension_dbus (GDBusProxy *proxy,
+ const char *uuid)
+{
+ g_autoptr (GVariant) response = NULL;
+ g_autoptr (GError) error = NULL;
+ gboolean success = FALSE;
+
+ response = g_dbus_proxy_call_sync (proxy,
+ "EnableExtension",
+ g_variant_new ("(s)", uuid),
+ 0,
+ -1,
+ NULL,
+ &error);
+
+ if (response == NULL)
+ {
+ g_printerr (_("Failed to connect to GNOME Shell\n"));
+ return FALSE;
+ }
+
+ g_variant_get (response, "(b)", &success);
+
+ if (!success)
+ g_printerr (_("Extension “%s” does not exist\n"), uuid);
+
+ return success;
+}
+
+static gboolean
+enable_extension_gsettings (const char *uuid)
+{
+ g_autoptr(GSettings) settings = get_shell_settings ();
+
+ if (settings == NULL)
+ return FALSE;
+
+ return settings_list_add (settings, "enabled-extensions", uuid) &&
+ settings_list_remove (settings, "disabled-extensions", uuid);
+}
+
+static gboolean
+enable_extension (const char *uuid)
+{
+ g_autoptr (GDBusProxy) proxy = NULL;
+ g_autoptr (GError) error = NULL;
+
+ proxy = get_shell_proxy (&error);
+
+ if (proxy != NULL)
+ return enable_extension_dbus (proxy, uuid);
+ else
+ return enable_extension_gsettings (uuid);
+}
+
+int
+handle_enable (int argc, char *argv[], gboolean do_help)
+{
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (GError) error = NULL;
+ g_auto(GStrv) uuids = NULL;
+ GOptionEntry entries[] = {
+ { .long_name = G_OPTION_REMAINING,
+ .arg_description = "UUID",
+ .arg = G_OPTION_ARG_STRING_ARRAY, .arg_data = &uuids },
+ { NULL }
+ };
+
+ g_set_prgname ("gnome-extensions enable");
+
+ context = g_option_context_new (NULL);
+ g_option_context_set_help_enabled (context, FALSE);
+ g_option_context_set_summary (context, _("Enable an extension"));
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, get_option_group());
+
+ if (do_help)
+ {
+ show_help (context, NULL);
+ return 0;
+ }
+
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ show_help (context, error->message);
+ return 1;
+ }
+
+ if (uuids == NULL)
+ {
+ show_help (context, _("No UUID given"));
+ return 1;
+ }
+ else if (g_strv_length (uuids) > 1)
+ {
+ show_help (context, _("More than one UUID given"));
+ return 1;
+ }
+
+ return enable_extension (*uuids) ? 0 : 2;
+}
diff --git a/subprojects/extensions-tool/src/command-info.c b/subprojects/extensions-tool/src/command-info.c
new file mode 100644
index 0000000..61492a5
--- /dev/null
+++ b/subprojects/extensions-tool/src/command-info.c
@@ -0,0 +1,113 @@
+/* commands-info.c
+ *
+ * Copyright 2018 Florian Müllner <fmuellner@gnome.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include "commands.h"
+#include "common.h"
+#include "config.h"
+
+static gboolean
+show_extension_info (const char *uuid)
+{
+ g_autoptr (GDBusProxy) proxy = NULL;
+ g_autoptr (GVariant) response = NULL;
+ g_autoptr (GVariant) asv = NULL;
+ g_autoptr (GVariantDict) info = NULL;
+ g_autoptr (GError) error = NULL;
+
+ proxy = get_shell_proxy (&error);
+ if (proxy == NULL)
+ return FALSE;
+
+ response = g_dbus_proxy_call_sync (proxy,
+ "GetExtensionInfo",
+ g_variant_new ("(s)", uuid),
+ 0,
+ -1,
+ NULL,
+ &error);
+ if (response == NULL)
+ {
+ g_printerr (_("Failed to connect to GNOME Shell\n"));
+ return FALSE;
+ }
+
+ asv = g_variant_get_child_value (response, 0);
+ info = g_variant_dict_new (asv);
+
+ if (!g_variant_dict_contains (info, "uuid"))
+ {
+ g_printerr (_("Extension “%s” doesn't exist\n"), uuid);
+ return FALSE;
+ }
+
+ print_extension_info (info, DISPLAY_DETAILED);
+
+ return TRUE;
+}
+
+int
+handle_info (int argc, char *argv[], gboolean do_help)
+{
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (GError) error = NULL;
+ g_auto(GStrv) uuids = NULL;
+ GOptionEntry entries[] = {
+ { .long_name = G_OPTION_REMAINING,
+ .arg_description = "UUID",
+ .arg = G_OPTION_ARG_STRING_ARRAY, .arg_data = &uuids },
+ { NULL }
+ };
+
+ g_set_prgname ("gnome-extensions info");
+
+ context = g_option_context_new (NULL);
+ g_option_context_set_help_enabled (context, FALSE);
+ g_option_context_set_summary (context, _("Show extensions info"));
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, get_option_group());
+
+ if (do_help)
+ {
+ show_help (context, NULL);
+ return 0;
+ }
+
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ show_help (context, error->message);
+ return 1;
+ }
+
+ if (uuids == NULL)
+ {
+ show_help (context, _("No UUID given"));
+ return 1;
+ }
+ else if (g_strv_length (uuids) > 1)
+ {
+ show_help (context, _("More than one UUID given"));
+ return 1;
+ }
+
+ return show_extension_info (*uuids) ? 0 : 2;
+}
diff --git a/subprojects/extensions-tool/src/command-install.c b/subprojects/extensions-tool/src/command-install.c
new file mode 100644
index 0000000..2eefaba
--- /dev/null
+++ b/subprojects/extensions-tool/src/command-install.c
@@ -0,0 +1,213 @@
+/* command-install.c
+ *
+ * Copyright 2018 Florian Müllner <fmuellner@gnome.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include <gnome-autoar/gnome-autoar.h>
+#include <json-glib/json-glib.h>
+
+#include "commands.h"
+#include "common.h"
+#include "config.h"
+
+static JsonObject *
+load_metadata (GFile *dir,
+ GError **error)
+{
+ g_autoptr (JsonParser) parser = NULL;
+ g_autoptr (GInputStream) stream = NULL;
+ g_autoptr (GFile) file = NULL;
+
+ file = g_file_get_child (dir, "metadata.json");
+ stream = G_INPUT_STREAM (g_file_read (file, NULL, error));
+ if (stream == NULL)
+ return NULL;
+
+ parser = json_parser_new_immutable ();
+ if (!json_parser_load_from_stream (parser, stream, NULL, error))
+ return NULL;
+
+ return json_node_dup_object (json_parser_get_root (parser));
+}
+
+static void
+on_error (AutoarExtractor *extractor,
+ GError *error,
+ gpointer data)
+{
+ *((GError **)data) = g_error_copy (error);
+}
+
+static GFile *
+on_decide_destination (AutoarExtractor *extractor,
+ GFile *dest,
+ GList *files,
+ gpointer data)
+{
+ g_autofree char *dest_path = NULL;
+ GFile *new_dest;
+ int copy = 1;
+
+ dest_path = g_file_get_path (dest);
+ new_dest = g_object_ref (dest);
+
+ while (g_file_query_exists (new_dest, NULL))
+ {
+ g_autofree char *new_path = g_strdup_printf ("%s (%d)", dest_path, copy);
+
+ g_object_unref (new_dest);
+ new_dest = g_file_new_for_path (new_path);
+
+ copy++;
+ }
+
+ *((GFile **)data) = g_object_ref (new_dest);
+
+ return new_dest;
+}
+
+static int
+install_extension (const char *bundle,
+ gboolean force)
+{
+ g_autoptr (AutoarExtractor) extractor = NULL;
+ g_autoptr (JsonObject) metadata = NULL;
+ g_autoptr (GFile) cachedir = NULL;
+ g_autoptr (GFile) tmpdir = NULL;
+ g_autoptr (GFile) src = NULL;
+ g_autoptr (GFile) dst = NULL;
+ g_autoptr (GFile) dstdir = NULL;
+ g_autoptr (GError) error = NULL;
+ g_autofree char *cwd = NULL;
+ const char *uuid;
+
+ cwd = g_get_current_dir ();
+ src = g_file_new_for_commandline_arg_and_cwd (bundle, cwd);
+ cachedir = g_file_new_for_path (g_get_user_cache_dir ());
+
+ extractor = autoar_extractor_new (src, cachedir);
+
+ g_signal_connect (extractor, "error", G_CALLBACK (on_error), &error);
+ g_signal_connect (extractor, "decide-destination", G_CALLBACK (on_decide_destination), &tmpdir);
+
+ autoar_extractor_start (extractor, NULL);
+
+ if (error != NULL)
+ goto err;
+
+ metadata = load_metadata (tmpdir, &error);
+ if (metadata == NULL)
+ goto err;
+
+ dstdir = g_file_new_build_filename (g_get_user_data_dir (),
+ "gnome-shell", "extensions", NULL);
+
+ if (!g_file_make_directory_with_parents (dstdir, NULL, &error))
+ {
+ if (error->code == G_IO_ERROR_EXISTS)
+ g_clear_error (&error);
+ else
+ goto err;
+ }
+
+ uuid = json_object_get_string_member (metadata, "uuid");
+ dst = g_file_get_child (dstdir, uuid);
+
+ if (g_file_query_exists (dst, NULL))
+ {
+ if (!force)
+ {
+ g_set_error (&error, G_IO_ERROR, G_IO_ERROR_EXISTS,
+ "%s exists and --force was not specified", uuid);
+ goto err;
+ }
+ else if (!file_delete_recursively (dst, &error))
+ {
+ goto err;
+ }
+ }
+
+ if (!g_file_move (tmpdir, dst, G_FILE_COPY_NONE, NULL, NULL, NULL, &error))
+ goto err;
+
+ return 0;
+
+err:
+ if (error != NULL)
+ g_printerr ("%s\n", error->message);
+
+ if (tmpdir != NULL)
+ file_delete_recursively (tmpdir, NULL);
+
+ return 2;
+}
+
+int
+handle_install (int argc, char *argv[], gboolean do_help)
+{
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (GError) error = NULL;
+ g_auto (GStrv) filenames = NULL;
+ gboolean force = FALSE;
+ GOptionEntry entries[] = {
+ { .long_name = "force", .short_name = 'f',
+ .arg = G_OPTION_ARG_NONE, .arg_data = &force,
+ .description = _("Overwrite an existing extension") },
+ { .long_name = G_OPTION_REMAINING,
+ .arg_description =_("EXTENSION_BUNDLE"),
+ .arg = G_OPTION_ARG_FILENAME_ARRAY, .arg_data = &filenames },
+ { NULL }
+ };
+
+ g_set_prgname ("gnome-extensions install");
+
+ context = g_option_context_new (NULL);
+ g_option_context_set_help_enabled (context, FALSE);
+ g_option_context_set_summary (context, _("Install an extension bundle"));
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, get_option_group());
+
+ if (do_help)
+ {
+ show_help (context, NULL);
+ return 0;
+ }
+
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ show_help (context, error->message);
+ return 1;
+ }
+
+ if (filenames == NULL)
+ {
+ show_help (context, _("No extension bundle specified"));
+ return 1;
+ }
+
+ if (g_strv_length (filenames) > 1)
+ {
+ show_help (context, _("More than one extension bundle specified"));
+ return 1;
+ }
+
+ return install_extension (*filenames, force);
+}
diff --git a/subprojects/extensions-tool/src/command-list.c b/subprojects/extensions-tool/src/command-list.c
new file mode 100644
index 0000000..62db4d9
--- /dev/null
+++ b/subprojects/extensions-tool/src/command-list.c
@@ -0,0 +1,196 @@
+/* command-list.c
+ *
+ * Copyright 2018 Florian Müllner <fmuellner@gnome.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include "commands.h"
+#include "common.h"
+#include "config.h"
+
+
+typedef enum {
+ LIST_FLAGS_NONE = 0,
+ LIST_FLAGS_USER = 1 << 0,
+ LIST_FLAGS_SYSTEM = 1 << 1,
+ LIST_FLAGS_ENABLED = 1 << 2,
+ LIST_FLAGS_DISABLED = 1 << 3,
+ LIST_FLAGS_NO_PREFS = 1 << 4,
+ LIST_FLAGS_NO_UPDATES = 1 << 5,
+} ListFilterFlags;
+
+static gboolean
+list_extensions (ListFilterFlags filter, DisplayFormat format)
+{
+ g_autoptr (GDBusProxy) proxy = NULL;
+ g_autoptr (GVariant) response = NULL;
+ g_autoptr (GVariant) extensions = NULL;
+ g_autoptr (GError) error = NULL;
+ gboolean needs_newline = FALSE;
+ GVariantIter iter;
+ GVariant *value;
+ char *uuid;
+
+ proxy = get_shell_proxy (&error);
+ if (proxy == NULL)
+ return FALSE;
+
+ response = g_dbus_proxy_call_sync (proxy,
+ "ListExtensions",
+ NULL,
+ 0,
+ -1,
+ NULL,
+ &error);
+ if (response == NULL)
+ {
+ g_printerr (_("Failed to connect to GNOME Shell\n"));
+ return FALSE;
+ }
+
+ extensions = g_variant_get_child_value (response, 0);
+
+ g_variant_iter_init (&iter, extensions);
+ while (g_variant_iter_loop (&iter, "{s@a{sv}}", &uuid, &value))
+ {
+ g_autoptr (GVariantDict) info = NULL;
+ double type, state;
+ gboolean has_prefs;
+ gboolean has_update;
+
+ info = g_variant_dict_new (value);
+ g_variant_dict_lookup (info, "type", "d", &type);
+ g_variant_dict_lookup (info, "state", "d", &state);
+ g_variant_dict_lookup (info, "hasPrefs", "b", &has_prefs);
+ g_variant_dict_lookup (info, "hasUpdate", "b", &has_update);
+
+ if (type == TYPE_USER && (filter & LIST_FLAGS_USER) == 0)
+ continue;
+
+ if (type == TYPE_SYSTEM && (filter & LIST_FLAGS_SYSTEM) == 0)
+ continue;
+
+ if (state == STATE_ENABLED && (filter & LIST_FLAGS_ENABLED) == 0)
+ continue;
+
+ if (state != STATE_ENABLED && (filter & LIST_FLAGS_DISABLED) == 0)
+ continue;
+
+ if (!has_prefs && (filter & LIST_FLAGS_NO_PREFS) == 0)
+ continue;
+
+ if (!has_update && (filter & LIST_FLAGS_NO_UPDATES) == 0)
+ continue;
+
+ if (needs_newline)
+ g_print ("\n");
+
+ print_extension_info (info, format);
+ needs_newline = (format != DISPLAY_ONELINE);
+ }
+
+ return TRUE;
+}
+
+int
+handle_list (int argc, char *argv[], gboolean do_help)
+{
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (GError) error = NULL;
+ int flags = LIST_FLAGS_NONE;
+ gboolean details = FALSE;
+ gboolean user = FALSE;
+ gboolean system = FALSE;
+ gboolean enabled = FALSE;
+ gboolean disabled = FALSE;
+ gboolean has_prefs = FALSE;
+ gboolean has_updates = FALSE;
+ GOptionEntry entries[] = {
+ { .long_name = "user",
+ .arg = G_OPTION_ARG_NONE, .arg_data = &user,
+ .description = _("Show user-installed extensions") },
+ { .long_name = "system",
+ .arg = G_OPTION_ARG_NONE, .arg_data = &system,
+ .description = _("Show system-installed extensions") },
+ { .long_name = "enabled",
+ .arg = G_OPTION_ARG_NONE, .arg_data = &enabled,
+ .description = _("Show enabled extensions") },
+ { .long_name = "disabled",
+ .arg = G_OPTION_ARG_NONE, .arg_data = &disabled,
+ .description = _("Show disabled extensions") },
+ { .long_name = "prefs",
+ .arg = G_OPTION_ARG_NONE, .arg_data = &has_prefs,
+ .description = _("Show extensions with preferences") },
+ { .long_name = "updates",
+ .arg = G_OPTION_ARG_NONE, .arg_data = &has_updates,
+ .description = _("Show extensions with updates") },
+ { .long_name = "details", .short_name = 'd',
+ .arg = G_OPTION_ARG_NONE, .arg_data = &details,
+ .description = _("Print extension details") },
+ { NULL }
+ };
+
+ g_set_prgname ("gnome-extensions list");
+
+ context = g_option_context_new (NULL);
+ g_option_context_set_help_enabled (context, FALSE);
+ g_option_context_set_summary (context, _("List installed extensions"));
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, get_option_group());
+
+ if (do_help)
+ {
+ show_help (context, NULL);
+ return 0;
+ }
+
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ show_help (context, error->message);
+ return 1;
+ }
+
+ if (argc > 1)
+ {
+ show_help (context, _("Unknown arguments"));
+ return 1;
+ }
+
+ if (user || !system)
+ flags |= LIST_FLAGS_USER;
+
+ if (system || !user)
+ flags |= LIST_FLAGS_SYSTEM;
+
+ if (enabled || !disabled)
+ flags |= LIST_FLAGS_ENABLED;
+
+ if (disabled || !enabled)
+ flags |= LIST_FLAGS_DISABLED;
+
+ if (!has_prefs)
+ flags |= LIST_FLAGS_NO_PREFS;
+
+ if (!has_updates)
+ flags |= LIST_FLAGS_NO_UPDATES;
+
+ return list_extensions (flags, details ? DISPLAY_DETAILED
+ : DISPLAY_ONELINE) ? 0 : 2;
+}
diff --git a/subprojects/extensions-tool/src/command-pack.c b/subprojects/extensions-tool/src/command-pack.c
new file mode 100644
index 0000000..c8d9950
--- /dev/null
+++ b/subprojects/extensions-tool/src/command-pack.c
@@ -0,0 +1,516 @@
+/* command-pack.c
+ *
+ * Copyright 2018 Florian Müllner <fmuellner@gnome.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include <gnome-autoar/gnome-autoar.h>
+#include <json-glib/json-glib.h>
+
+#include "commands.h"
+#include "common.h"
+#include "config.h"
+
+typedef struct _ExtensionPack {
+ GHashTable *files;
+ JsonObject *metadata;
+ GFile *tmpdir;
+ char *srcdir;
+} ExtensionPack;
+
+static void extension_pack_free (ExtensionPack *);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (ExtensionPack, extension_pack_free);
+
+static ExtensionPack *
+extension_pack_new (const char *srcdir)
+{
+ ExtensionPack *pack = g_new0 (ExtensionPack, 1);
+ pack->srcdir = g_strdup (srcdir);
+ pack->files = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, g_object_unref);
+ return pack;
+}
+
+static void
+extension_pack_free (ExtensionPack *pack)
+{
+ if (pack->tmpdir)
+ file_delete_recursively (pack->tmpdir, NULL);
+
+ g_clear_pointer (&pack->files, g_hash_table_destroy);
+ g_clear_pointer (&pack->metadata, json_object_unref);
+ g_clear_pointer (&pack->srcdir, g_free);
+ g_clear_object (&pack->tmpdir);
+ g_free (pack);
+}
+
+static void
+extension_pack_add_source (ExtensionPack *pack,
+ const char *filename)
+{
+ g_autoptr (GFile) file = NULL;
+ file = g_file_new_for_commandline_arg_and_cwd (filename, pack->srcdir);
+ if (g_file_query_exists (file, NULL))
+ g_hash_table_insert (pack->files,
+ g_path_get_basename (filename), g_steal_pointer (&file));
+}
+
+static gboolean
+extension_pack_check_required_file (ExtensionPack *pack,
+ const char *filename,
+ GError **error)
+{
+ if (!g_hash_table_contains (pack->files, filename))
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+ "Missing %s in extension pack", filename);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static gboolean
+ensure_tmpdir (ExtensionPack *pack,
+ GError **error)
+{
+ g_autofree char *path = NULL;
+
+ if (pack->tmpdir != NULL)
+ return TRUE;
+
+ path = g_dir_make_tmp ("gnome-extensions.XXXXXX", error);
+ if (path != NULL)
+ pack->tmpdir = g_file_new_for_path (path);
+
+ return pack->tmpdir != NULL;
+}
+
+static gboolean
+ensure_metadata (ExtensionPack *pack,
+ GError **error)
+{
+ g_autoptr (JsonParser) parser = NULL;
+ g_autoptr (GInputStream) stream = NULL;
+ GFile *file = NULL;
+
+ if (pack->metadata != NULL)
+ return TRUE;
+
+ if (!extension_pack_check_required_file (pack, "metadata.json", error))
+ return FALSE;
+
+ file = g_hash_table_lookup (pack->files, "metadata.json");
+ stream = G_INPUT_STREAM (g_file_read (file, NULL, error));
+
+ if (stream == NULL)
+ return FALSE;
+
+ parser = json_parser_new_immutable ();
+
+ if (!json_parser_load_from_stream (parser, stream, NULL, error))
+ return FALSE;
+
+ pack->metadata = json_node_dup_object (json_parser_get_root (parser));
+ return TRUE;
+}
+
+static gboolean
+extension_pack_add_schemas (ExtensionPack *pack,
+ char **schemas,
+ GError **error)
+{
+ g_autoptr (GSubprocess) proc = NULL;
+ g_autoptr (GFile) dstdir = NULL;
+ g_autofree char *dstpath = NULL;
+ char **s;
+
+ if (!ensure_tmpdir (pack, error))
+ return FALSE;
+
+ dstdir = g_file_get_child (pack->tmpdir, "schemas");
+ if (!g_file_make_directory (dstdir, NULL, error))
+ return FALSE;
+
+ for (s = schemas; s && *s; s++)
+ {
+ g_autoptr (GFile) src = NULL;
+ g_autoptr (GFile) dst = NULL;
+ g_autofree char *basename = NULL;
+
+ src = g_file_new_for_commandline_arg_and_cwd (*s, pack->srcdir);
+
+ basename = g_file_get_basename (src);
+ dst = g_file_get_child (dstdir, basename);
+
+ if (!g_file_copy (src, dst, G_FILE_COPY_NONE, NULL, NULL, NULL, error))
+ return FALSE;
+ }
+
+ dstpath = g_file_get_path (dstdir);
+ proc = g_subprocess_new (G_SUBPROCESS_FLAGS_STDERR_SILENCE, error,
+ "glib-compile-schemas", "--strict", dstpath, NULL);
+
+ if (!g_subprocess_wait_check (proc, NULL, error))
+ return FALSE;
+
+ g_hash_table_insert (pack->files,
+ g_strdup ("schemas"), g_steal_pointer (&dstdir));
+ return TRUE;
+}
+
+static gboolean
+extension_pack_add_locales (ExtensionPack *pack,
+ const char *podir,
+ const char *gettext_domain,
+ GError **error)
+{
+ g_autoptr (GFile) dstdir = NULL;
+ g_autoptr (GFile) srcdir = NULL;
+ g_autoptr (GFileEnumerator) file_enum = NULL;
+ g_autofree char *dstpath = NULL;
+ g_autofree char *moname = NULL;
+ GFile *child;
+ GFileInfo *info;
+
+ if (!ensure_tmpdir (pack, error))
+ return FALSE;
+
+ dstdir = g_file_get_child (pack->tmpdir, "locale");
+ if (!g_file_make_directory (dstdir, NULL, error))
+ return FALSE;
+
+ srcdir = g_file_new_for_commandline_arg_and_cwd (podir, pack->srcdir);
+ file_enum = g_file_enumerate_children (srcdir,
+ G_FILE_ATTRIBUTE_STANDARD_NAME,
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ error);
+ if (file_enum == NULL)
+ return FALSE;
+
+ if (gettext_domain == NULL)
+ {
+ if (!ensure_metadata (pack, error))
+ return FALSE;
+
+ if (json_object_has_member (pack->metadata, "gettext-domain"))
+ gettext_domain = json_object_get_string_member (pack->metadata,
+ "gettext-domain");
+ else
+ gettext_domain = json_object_get_string_member (pack->metadata,
+ "uuid");
+ }
+
+ dstpath = g_file_get_path (dstdir);
+ moname = g_strdup_printf ("%s.mo", gettext_domain);
+
+ while (TRUE)
+ {
+ g_autoptr (GSubprocess) proc = NULL;
+ g_autoptr (GFile) modir = NULL;
+ g_autofree char *popath = NULL;
+ g_autofree char *mopath = NULL;
+ g_autofree char *lang = NULL;
+ const char *name;
+
+ if (!g_file_enumerator_iterate (file_enum, &info, &child, NULL, error))
+ return FALSE;
+
+ if (info == NULL)
+ break;
+
+ name = g_file_info_get_name (info);
+ if (!g_str_has_suffix (name, ".po"))
+ continue;
+
+ lang = g_strndup (name, strlen (name) - 3 /* strlen (".po") */);
+ modir = g_file_new_build_filename (dstpath, lang, "LC_MESSAGES", NULL);
+ if (!g_file_make_directory_with_parents (modir, NULL, error))
+ return FALSE;
+
+ mopath = g_build_filename (dstpath, lang, "LC_MESSAGES", moname, NULL);
+ popath = g_file_get_path (child);
+
+ proc = g_subprocess_new (G_SUBPROCESS_FLAGS_STDERR_SILENCE, error,
+ "msgfmt", "-o", mopath, popath, NULL);
+
+ if (!g_subprocess_wait_check (proc, NULL, error))
+ return FALSE;
+ }
+
+ g_hash_table_insert (pack->files,
+ g_strdup ("locale"), g_steal_pointer (&dstdir));
+ return TRUE;
+}
+
+static void
+on_error (AutoarCompressor *compressor,
+ GError *error,
+ gpointer data)
+{
+ *((GError **)data) = g_error_copy (error);
+}
+
+static gboolean
+extension_pack_compress (ExtensionPack *pack,
+ const char *outdir,
+ gboolean overwrite,
+ GError **error)
+{
+ g_autoptr (AutoarCompressor) compressor = NULL;
+ g_autoptr (GError) err = NULL;
+ g_autoptr (GFile) outfile = NULL;
+ g_autofree char *name = NULL;
+ const char *uuid;
+
+ if (!ensure_metadata (pack, error))
+ return FALSE;
+
+ uuid = json_object_get_string_member (pack->metadata, "uuid");
+ name = g_strdup_printf ("%s.shell-extension.zip", uuid);
+ outfile = g_file_new_for_commandline_arg_and_cwd (name, outdir);
+
+ if (g_file_query_exists (outfile, NULL))
+ {
+ if (!overwrite)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS,
+ "%s exists and --force was not specified", name);
+ return FALSE;
+ }
+ else if (!g_file_delete (outfile, NULL, error))
+ {
+ return FALSE;
+ }
+ }
+
+ compressor = autoar_compressor_new (g_hash_table_get_values (pack->files),
+ outfile,
+ AUTOAR_FORMAT_ZIP,
+ AUTOAR_FILTER_NONE,
+ FALSE);
+ autoar_compressor_set_output_is_dest (compressor, TRUE);
+
+ g_signal_connect (compressor, "error", G_CALLBACK (on_error), err);
+
+ autoar_compressor_start (compressor, NULL);
+
+ if (err != NULL)
+ {
+ g_propagate_error (error, err);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static char **
+find_schemas (const char *basepath,
+ GError **error)
+{
+ g_autoptr (GFile) basedir = NULL;
+ g_autoptr (GFile) schemadir = NULL;
+ g_autoptr (GFileEnumerator) file_enum = NULL;
+ g_autoptr (GPtrArray) schemas = NULL;
+ GFile *child;
+ GFileInfo *info;
+
+ basedir = g_file_new_for_path (basepath);
+ schemadir = g_file_get_child (basedir, "schemas");
+ file_enum = g_file_enumerate_children (schemadir,
+ G_FILE_ATTRIBUTE_STANDARD_NAME,
+ G_FILE_QUERY_INFO_NONE,
+ NULL, error);
+
+ if (error && *error)
+ {
+ if (g_error_matches (*error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) ||
+ g_error_matches (*error, G_IO_ERROR, G_IO_ERROR_NOT_DIRECTORY))
+ g_clear_error (error);
+ return NULL;
+ }
+
+ schemas = g_ptr_array_new_with_free_func (g_free);
+
+ while (TRUE)
+ {
+ if (!g_file_enumerator_iterate (file_enum, &info, &child, NULL, error))
+ return NULL;
+
+ if (child == NULL)
+ break;
+
+ if (!g_str_has_suffix (g_file_info_get_name (info), ".gschema.xml"))
+ continue;
+
+ g_ptr_array_add (schemas, g_file_get_relative_path (basedir, child));
+ }
+ g_ptr_array_add (schemas, NULL);
+
+ return (char **)g_ptr_array_free (g_ptr_array_ref (schemas), FALSE);
+}
+
+static int
+pack_extension (char *srcdir,
+ char *dstdir,
+ gboolean force,
+ char **extra_sources,
+ char **schemas,
+ char *podir,
+ char *gettext_domain)
+{
+ g_autoptr (ExtensionPack) pack = NULL;
+ g_autoptr (GError) error = NULL;
+ char **s;
+
+ pack = extension_pack_new (srcdir);
+ extension_pack_add_source (pack, "extension.js");
+ extension_pack_add_source (pack, "metadata.json");
+ extension_pack_add_source (pack, "stylesheet.css");
+ extension_pack_add_source (pack, "prefs.js");
+
+ for (s = extra_sources; s && *s; s++)
+ extension_pack_add_source (pack, *s);
+
+ if (!extension_pack_check_required_file (pack, "extension.js", &error))
+ goto err;
+
+ if (!extension_pack_check_required_file (pack, "metadata.json", &error))
+ goto err;
+
+ if (schemas == NULL)
+ schemas = find_schemas (srcdir, &error);
+
+ if (schemas != NULL)
+ extension_pack_add_schemas (pack, schemas, &error);
+
+ if (error)
+ goto err;
+
+ if (podir == NULL)
+ {
+ g_autoptr (GFile) dir = NULL;
+
+ dir = g_file_new_for_commandline_arg_and_cwd ("po", srcdir);
+ if (g_file_query_exists (dir, NULL))
+ podir = (char *)"po";
+ }
+
+ if (podir != NULL)
+ extension_pack_add_locales (pack, podir, gettext_domain, &error);
+
+ if (error)
+ goto err;
+
+ extension_pack_compress (pack, dstdir, force, &error);
+
+err:
+ if (error)
+ {
+ g_printerr ("%s\n", error->message);
+ return 2;
+ }
+
+ return 0;
+}
+
+int
+handle_pack (int argc, char *argv[], gboolean do_help)
+{
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (GError) error = NULL;
+ g_auto(GStrv) extra_sources = NULL;
+ g_auto(GStrv) schemas = NULL;
+ g_auto(GStrv) srcdirs = NULL;
+ g_autofree char *podir = NULL;
+ g_autofree char *srcdir = NULL;
+ g_autofree char *dstdir = NULL;
+ g_autofree char *gettext_domain = NULL;
+ gboolean force = FALSE;
+ GOptionEntry entries[] = {
+ { .long_name = "extra-source",
+ .arg = G_OPTION_ARG_FILENAME_ARRAY, .arg_data = &extra_sources,
+ .arg_description = _("FILE"),
+ .description = _("Additional source to include in the bundle") },
+ { .long_name = "schema",
+ .arg = G_OPTION_ARG_FILENAME_ARRAY, .arg_data = &schemas,
+ .arg_description = _("SCHEMA"),
+ .description = _("A GSettings schema that should be included") },
+ { .long_name = "podir",
+ .arg_description = _("DIRECTORY"),
+ .arg = G_OPTION_ARG_FILENAME, .arg_data = &podir,
+ .description = _("The directory where translations are found") },
+ { .long_name = "gettext-domain",
+ .arg_description = _("DOMAIN"),
+ .arg = G_OPTION_ARG_STRING, .arg_data = &gettext_domain,
+ .description = _("The gettext domain to use for translations") },
+ { .long_name = "force", .short_name = 'f',
+ .arg = G_OPTION_ARG_NONE, .arg_data = &force,
+ .description = _("Overwrite an existing pack") },
+ { .long_name = "out-dir", .short_name = 'o',
+ .arg_description = _("DIRECTORY"),
+ .arg = G_OPTION_ARG_FILENAME, .arg_data = &dstdir,
+ .description = _("The directory where the pack should be created") },
+ { .long_name = G_OPTION_REMAINING,
+ .arg_description =_("SOURCE_DIRECTORY"),
+ .arg = G_OPTION_ARG_FILENAME_ARRAY, .arg_data = &srcdirs },
+ { NULL }
+ };
+
+ g_set_prgname ("gnome-extensions pack");
+
+ context = g_option_context_new (NULL);
+ g_option_context_set_help_enabled (context, FALSE);
+ g_option_context_set_summary (context, _("Create an extension bundle"));
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, get_option_group());
+
+ if (do_help)
+ {
+ show_help (context, NULL);
+ return 0;
+ }
+
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ show_help (context, error->message);
+ return 1;
+ }
+
+ if (srcdirs)
+ {
+ if (g_strv_length (srcdirs) > 1)
+ {
+ show_help (context, _("More than one source directory specified"));
+ return 1;
+ }
+ srcdir = g_strdup (*srcdirs);
+ }
+ else
+ {
+ srcdir = g_get_current_dir ();
+ }
+
+ if (dstdir == NULL)
+ dstdir = g_get_current_dir ();
+
+ return pack_extension (srcdir, dstdir, force,
+ extra_sources, schemas, podir, gettext_domain);
+}
diff --git a/subprojects/extensions-tool/src/command-prefs.c b/subprojects/extensions-tool/src/command-prefs.c
new file mode 100644
index 0000000..50e4b80
--- /dev/null
+++ b/subprojects/extensions-tool/src/command-prefs.c
@@ -0,0 +1,107 @@
+/* commands-prefs.c
+ *
+ * Copyright 2019 Florian Müllner <fmuellner@gnome.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include "commands.h"
+#include "common.h"
+#include "config.h"
+
+static gboolean
+launch_extension_prefs (const char *uuid)
+{
+ g_autoptr (GDBusProxy) proxy = NULL;
+ g_autoptr (GVariant) info = NULL;
+ g_autoptr (GError) error = NULL;
+ gboolean has_prefs;
+
+ proxy = get_shell_proxy (&error);
+ if (proxy == NULL)
+ return FALSE;
+
+ info = get_extension_property (proxy, uuid, "hasPrefs");
+ if (info == NULL)
+ return FALSE;
+
+ has_prefs = g_variant_get_boolean (info);
+ if (!has_prefs)
+ {
+ g_printerr (_("Extension “%s” doesn't have preferences\n"), uuid);
+ return FALSE;
+ }
+
+ g_dbus_proxy_call_sync (proxy,
+ "OpenExtensionPrefs",
+ g_variant_new ("(ssa{sv})", uuid, "", NULL),
+ 0,
+ -1,
+ NULL,
+ &error);
+
+ return TRUE;
+}
+
+int
+handle_prefs (int argc, char *argv[], gboolean do_help)
+{
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (GError) error = NULL;
+ g_auto(GStrv) uuids = NULL;
+ GOptionEntry entries[] = {
+ { .long_name = G_OPTION_REMAINING,
+ .arg_description = "UUID",
+ .arg = G_OPTION_ARG_STRING_ARRAY, .arg_data = &uuids },
+ { NULL }
+ };
+
+ g_set_prgname ("gnome-extensions prefs");
+
+ context = g_option_context_new (NULL);
+ g_option_context_set_help_enabled (context, FALSE);
+ g_option_context_set_summary (context, _("Opens extension preferences"));
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, get_option_group());
+
+ if (do_help)
+ {
+ show_help (context, NULL);
+ return 0;
+ }
+
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ show_help (context, error->message);
+ return 1;
+ }
+
+ if (uuids == NULL)
+ {
+ show_help (context, _("No UUID given"));
+ return 1;
+ }
+ else if (g_strv_length (uuids) > 1)
+ {
+ show_help (context, _("More than one UUID given"));
+ return 1;
+ }
+
+ return launch_extension_prefs (*uuids) ? 0 : 2;
+}
diff --git a/subprojects/extensions-tool/src/command-reset.c b/subprojects/extensions-tool/src/command-reset.c
new file mode 100644
index 0000000..2615f15
--- /dev/null
+++ b/subprojects/extensions-tool/src/command-reset.c
@@ -0,0 +1,86 @@
+/* command-reset.c
+ g_option_context_add_group (context, get_option_group());
+ *
+ * Copyright 2019 Florian Müllner <fmuellner@gnome.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include "commands.h"
+#include "common.h"
+#include "config.h"
+
+static gboolean
+reset_extension (const char *uuid)
+{
+ g_autoptr(GSettings) settings = get_shell_settings();
+
+ if (settings == NULL)
+ return FALSE;
+
+ return settings_list_remove (settings, "enabled-extensions", uuid) &&
+ settings_list_remove (settings, "disabled-extensions", uuid);
+}
+
+int
+handle_reset (int argc, char *argv[], gboolean do_help)
+{
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (GError) error = NULL;
+ g_auto(GStrv) uuids = NULL;
+ GOptionEntry entries[] = {
+ { .long_name = G_OPTION_REMAINING,
+ .arg_description = "UUID",
+ .arg = G_OPTION_ARG_STRING_ARRAY, .arg_data = &uuids },
+ { NULL }
+ };
+
+ g_set_prgname ("gnome-extensions reset");
+
+ context = g_option_context_new (NULL);
+ g_option_context_set_help_enabled (context, FALSE);
+ g_option_context_set_summary (context, _("Reset an extension"));
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, get_option_group());
+
+ if (do_help)
+ {
+ show_help (context, NULL);
+ return 0;
+ }
+
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ show_help (context, error->message);
+ return 1;
+ }
+
+ if (uuids == NULL)
+ {
+ show_help (context, _("No UUID given"));
+ return 1;
+ }
+ else if (g_strv_length (uuids) > 1)
+ {
+ show_help (context, _("More than one UUID given"));
+ return 1;
+ }
+
+ return reset_extension (*uuids) ? 0 : 2;
+}
diff --git a/subprojects/extensions-tool/src/command-uninstall.c b/subprojects/extensions-tool/src/command-uninstall.c
new file mode 100644
index 0000000..344b720
--- /dev/null
+++ b/subprojects/extensions-tool/src/command-uninstall.c
@@ -0,0 +1,114 @@
+/* commands-uninstall.c
+ *
+ * Copyright 2019 Florian Müllner <fmuellner@gnome.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include "commands.h"
+#include "common.h"
+#include "config.h"
+
+static gboolean
+uninstall_extension (const char *uuid)
+{
+ g_autoptr (GDBusProxy) proxy = NULL;
+ g_autoptr (GVariant) info = NULL;
+ g_autoptr (GVariant) response = NULL;
+ g_autoptr (GError) error = NULL;
+ gboolean success = FALSE;
+ double type;
+
+ proxy = get_shell_proxy (&error);
+ if (proxy == NULL)
+ return FALSE;
+
+ info = get_extension_property (proxy, uuid, "type");
+ if (info == NULL)
+ return FALSE;
+
+ type = g_variant_get_double (info);
+ if (type == TYPE_SYSTEM)
+ {
+ g_printerr (_("Cannot uninstall system extensions\n"));
+ return FALSE;
+ }
+
+ response = g_dbus_proxy_call_sync (proxy,
+ "UninstallExtension",
+ g_variant_new ("(s)", uuid),
+ 0,
+ -1,
+ NULL,
+ &error);
+
+ g_variant_get (response, "(b)", &success);
+
+ if (!success)
+ g_printerr (_("Failed to uninstall “%s”\n"), uuid);
+
+ return success;
+}
+
+int
+handle_uninstall (int argc, char *argv[], gboolean do_help)
+{
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (GError) error = NULL;
+ g_auto(GStrv) uuids = NULL;
+ GOptionEntry entries[] = {
+ { .long_name = G_OPTION_REMAINING,
+ .arg_description = "UUID",
+ .arg = G_OPTION_ARG_STRING_ARRAY, .arg_data = &uuids },
+ { NULL }
+ };
+
+ g_set_prgname ("gnome-extensions uninstall");
+
+ context = g_option_context_new (NULL);
+ g_option_context_set_help_enabled (context, FALSE);
+ g_option_context_set_summary (context, _("Uninstall an extension"));
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, get_option_group());
+
+ if (do_help)
+ {
+ show_help (context, NULL);
+ return 0;
+ }
+
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ show_help (context, error->message);
+ return 1;
+ }
+
+ if (uuids == NULL)
+ {
+ show_help (context, _("No UUID given"));
+ return 1;
+ }
+ else if (g_strv_length (uuids) > 1)
+ {
+ show_help (context, _("More than one UUID given"));
+ return 1;
+ }
+
+ return uninstall_extension (*uuids) ? 0 : 2;
+}
diff --git a/subprojects/extensions-tool/src/commands.h b/subprojects/extensions-tool/src/commands.h
new file mode 100644
index 0000000..618e841
--- /dev/null
+++ b/subprojects/extensions-tool/src/commands.h
@@ -0,0 +1,38 @@
+/* commands.h
+ *
+ * Copyright 2018 Florian Müllner <fmuellner@gnome.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+int handle_enable (int argc, char *argv[], gboolean do_help);
+int handle_disable (int argc, char *argv[], gboolean do_help);
+int handle_reset (int argc, char *argv[], gboolean do_help);
+int handle_list (int argc, char *argv[], gboolean do_help);
+int handle_info (int argc, char *argv[], gboolean do_help);
+int handle_prefs (int argc, char *argv[], gboolean do_help);
+int handle_create (int argc, char *argv[], gboolean do_help);
+int handle_pack (int argc, char *argv[], gboolean do_help);
+int handle_install (int argc, char *argv[], gboolean do_help);
+int handle_uninstall (int argc, char *argv[], gboolean do_help);
+
+G_END_DECLS
diff --git a/subprojects/extensions-tool/src/common.h b/subprojects/extensions-tool/src/common.h
new file mode 100644
index 0000000..2b04484
--- /dev/null
+++ b/subprojects/extensions-tool/src/common.h
@@ -0,0 +1,73 @@
+/* common.h
+ *
+ * Copyright 2018 Florian Müllner <fmuellner@gnome.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ TYPE_SYSTEM = 1,
+ TYPE_USER
+} ExtensionType;
+
+typedef enum {
+ STATE_ENABLED = 1,
+ STATE_DISABLED,
+ STATE_ERROR,
+ STATE_OUT_OF_DATE,
+ STATE_DOWNLOADING,
+ STATE_INITIALIZED,
+
+ STATE_UNINSTALLED = 99
+} ExtensionState;
+
+typedef enum {
+ DISPLAY_ONELINE,
+ DISPLAY_DETAILED
+} DisplayFormat;
+
+GOptionGroup *get_option_group (void);
+
+void show_help (GOptionContext *context,
+ const char *message);
+
+void print_extension_info (GVariantDict *info,
+ DisplayFormat format);
+
+GDBusProxy *get_shell_proxy (GError **error);
+GVariant *get_extension_property (GDBusProxy *proxy,
+ const char *uuid,
+ const char *property);
+
+GSettings *get_shell_settings (void);
+
+gboolean settings_list_add (GSettings *settings,
+ const char *key,
+ const char *value);
+gboolean settings_list_remove (GSettings *settings,
+ const char *key,
+ const char *value);
+
+gboolean file_delete_recursively (GFile *file,
+ GError **error);
+
+G_END_DECLS
diff --git a/subprojects/extensions-tool/src/gnome-extensions-tool.gresource.xml b/subprojects/extensions-tool/src/gnome-extensions-tool.gresource.xml
new file mode 100644
index 0000000..0db87c3
--- /dev/null
+++ b/subprojects/extensions-tool/src/gnome-extensions-tool.gresource.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/extensions-tool">
+ <file>templates/00-plain.desktop</file>
+ <file>templates/indicator.desktop</file>
+ <file>templates/indicator/extension.js</file>
+ <file>templates/indicator/stylesheet.css</file>
+ <file>templates/plain/extension.js</file>
+ <file>templates/plain/stylesheet.css</file>
+ </gresource>
+</gresources>
diff --git a/subprojects/extensions-tool/src/main.c b/subprojects/extensions-tool/src/main.c
new file mode 100644
index 0000000..c33058d
--- /dev/null
+++ b/subprojects/extensions-tool/src/main.c
@@ -0,0 +1,408 @@
+/* main.c
+ *
+ * Copyright 2018 Florian Müllner <fmuellner@gnome.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include <locale.h>
+
+#include "config.h"
+#include "commands.h"
+#include "common.h"
+
+static const char *
+extension_state_to_string (ExtensionState state)
+{
+ switch (state)
+ {
+ case STATE_ENABLED:
+ return "ENABLED";
+ case STATE_DISABLED:
+ return "DISABLED";
+ case STATE_ERROR:
+ return "ERROR";
+ case STATE_OUT_OF_DATE:
+ return "OUT OF DATE";
+ case STATE_DOWNLOADING:
+ return "DOWNLOADING";
+ case STATE_INITIALIZED:
+ return "INITIALIZED";
+ case STATE_UNINSTALLED:
+ return "UNINSTALLED";
+ }
+ return "UNKNOWN";
+}
+
+static void
+print_nothing (const char *message)
+{
+}
+
+static gboolean
+quiet_cb (const gchar *option_name,
+ const gchar *value,
+ gpointer data,
+ GError **error)
+{
+ g_set_printerr_handler (print_nothing);
+ return TRUE;
+}
+
+GOptionGroup *
+get_option_group ()
+{
+ GOptionEntry entries[] = {
+ { .long_name = "quiet", .short_name = 'q',
+ .description = _("Do not print error messages"),
+ .arg = G_OPTION_ARG_CALLBACK, .arg_data = &quiet_cb,
+ .flags = G_OPTION_FLAG_NO_ARG | G_OPTION_FLAG_IN_MAIN },
+ { NULL }
+ };
+ GOptionGroup *group;
+
+ group = g_option_group_new ("Common", "common options", "common options", NULL, NULL);
+ g_option_group_add_entries (group, entries);
+
+ return group;
+}
+
+void
+show_help (GOptionContext *context, const char *message)
+{
+ g_autofree char *help = NULL;
+
+ if (message)
+ g_printerr ("gnome-extensions: %s\n\n", message);
+
+ help = g_option_context_get_help (context, TRUE, NULL);
+ g_printerr ("%s", help);
+}
+
+GDBusProxy *
+get_shell_proxy (GError **error)
+{
+ return g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ "org.gnome.Shell.Extensions",
+ "/org/gnome/Shell/Extensions",
+ "org.gnome.Shell.Extensions",
+ NULL,
+ error);
+}
+
+GSettings *
+get_shell_settings (void)
+{
+ g_autoptr (GSettingsSchema) schema = NULL;
+ GSettingsSchemaSource *schema_source;
+
+ schema_source = g_settings_schema_source_get_default ();
+ schema = g_settings_schema_source_lookup (schema_source,
+ "org.gnome.shell",
+ TRUE);
+
+ if (schema == NULL)
+ return NULL;
+
+ return g_settings_new_full (schema, NULL, NULL);
+}
+
+GVariant *
+get_extension_property (GDBusProxy *proxy,
+ const char *uuid,
+ const char *property)
+{
+ g_autoptr (GVariant) response = NULL;
+ g_autoptr (GVariant) asv = NULL;
+ g_autoptr (GVariantDict) info = NULL;
+ g_autoptr (GError) error = NULL;
+
+ response = g_dbus_proxy_call_sync (proxy,
+ "GetExtensionInfo",
+ g_variant_new ("(s)", uuid),
+ 0,
+ -1,
+ NULL,
+ &error);
+ if (response == NULL)
+ {
+ g_printerr (_("Failed to connect to GNOME Shell"));
+ return NULL;
+ }
+
+ asv = g_variant_get_child_value (response, 0);
+ info = g_variant_dict_new (asv);
+
+ if (!g_variant_dict_contains (info, "uuid"))
+ {
+ g_printerr (_("Extension “%s” doesn't exist\n"), uuid);
+ return NULL;
+ }
+
+ return g_variant_dict_lookup_value (info, property, NULL);
+}
+
+gboolean
+settings_list_add (GSettings *settings,
+ const char *key,
+ const char *value)
+{
+ g_auto(GStrv) list = NULL;
+ g_auto(GStrv) new_value = NULL;
+ guint n_values;
+ int i;
+
+ if (!g_settings_is_writable (settings, key))
+ return FALSE;
+
+ list = g_settings_get_strv (settings, key);
+
+ if (g_strv_contains ((const char **)list, value))
+ return TRUE;
+
+ n_values = g_strv_length (list);
+ new_value = g_new0 (char *, n_values + 2);
+ for (i = 0; i < n_values; i++)
+ new_value[i] = g_strdup (list[i]);
+ new_value[i] = g_strdup (value);
+
+ g_settings_set_strv (settings, key, (const char **)new_value);
+ g_settings_sync ();
+
+ return TRUE;
+}
+
+gboolean
+settings_list_remove (GSettings *settings,
+ const char *key,
+ const char *value)
+{
+ g_auto(GStrv) list = NULL;
+ g_auto(GStrv) new_value = NULL;
+ const char **s;
+ guint n_values;
+ int i;
+
+ if (!g_settings_is_writable (settings, key))
+ return FALSE;
+
+ list = g_settings_get_strv (settings, key);
+
+ if (!g_strv_contains ((const char **)list, value))
+ return TRUE;
+
+ n_values = g_strv_length (list);
+ new_value = g_new0 (char *, n_values);
+ i = 0;
+ for (s = (const char **)list; *s != NULL; s++)
+ if (!g_str_equal (*s, value))
+ new_value[i++] = g_strdup (*s);
+
+ g_settings_set_strv (settings, key, (const char **)new_value);
+ g_settings_sync ();
+
+ return TRUE;
+}
+
+void
+print_extension_info (GVariantDict *info,
+ DisplayFormat format)
+{
+ const char *uuid, *name, *desc, *path, *url, *author;
+ double state, version;
+
+ g_variant_dict_lookup (info, "uuid", "&s", &uuid);
+ g_print ("%s\n", uuid);
+
+ if (format == DISPLAY_ONELINE)
+ return;
+
+ g_variant_dict_lookup (info, "name", "&s", &name);
+ g_print (" %s: %s\n", _("Name"), name);
+
+ g_variant_dict_lookup (info, "description", "&s", &desc);
+ g_print (" %s: %s\n", _("Description"), desc);
+
+ g_variant_dict_lookup (info, "path", "&s", &path);
+ g_print (" %s: %s\n", _("Path"), path);
+
+ if (g_variant_dict_lookup (info, "url", "&s", &url))
+ g_print (" %s: %s\n", _("URL"), url);
+
+ if (g_variant_dict_lookup (info, "original-author", "&s", &author))
+ g_print (" %s: %s\n", _("Original author"), author);
+
+ if (g_variant_dict_lookup (info, "version", "d", &version))
+ g_print (" %s: %.0f\n", _("Version"), version);
+
+ g_variant_dict_lookup (info, "state", "d", &state);
+ g_print (" %s: %s\n", _("State"), extension_state_to_string (state));
+}
+
+gboolean
+file_delete_recursively (GFile *file,
+ GError **error)
+{
+ g_autoptr (GFileEnumerator) file_enum = NULL;
+ GFile *child;
+
+ file_enum = g_file_enumerate_children (file, NULL, 0, NULL, NULL);
+ if (file_enum)
+ while (TRUE)
+ {
+ if (!g_file_enumerator_iterate (file_enum, NULL, &child, NULL, error))
+ return FALSE;
+
+ if (child == NULL)
+ break;
+
+ if (!file_delete_recursively (child, error))
+ return FALSE;
+ }
+
+ return g_file_delete (file, NULL, error);
+}
+
+
+static int
+handle_version (int argc, char *argv[], gboolean do_help)
+{
+ if (do_help || argc > 1)
+ {
+ if (!do_help)
+ g_printerr ("gnome-extensions: %s\n\n", _("“version” takes no arguments"));
+
+ g_printerr ("%s\n", _("Usage:"));
+ g_printerr (" gnome-extensions version\n");
+ g_printerr ("\n");
+ g_printerr ("%s\n", _("Print version information and exit."));
+
+ return do_help ? 0 : 2;
+ }
+
+ g_print ("%s\n", VERSION);
+
+ return 0;
+}
+
+static void
+usage (void)
+{
+ g_autofree char *help_command = NULL;
+
+ help_command = g_strdup_printf ("gnome-extensions help %s", _("COMMAND"));
+
+ g_printerr ("%s\n", _("Usage:"));
+ g_printerr (" gnome-extensions %s %s\n", _("COMMAND"), _("[ARGS…]"));
+ g_printerr ("\n");
+ g_printerr ("%s\n", _("Commands:"));
+ g_printerr (" help %s\n", _("Print help"));
+ g_printerr (" version %s\n", _("Print version"));
+ g_printerr (" enable %s\n", _("Enable extension"));
+ g_printerr (" disable %s\n", _("Disable extension"));
+ g_printerr (" reset %s\n", _("Reset extension"));
+ g_printerr (" uninstall %s\n", _("Uninstall extension"));
+ g_printerr (" list %s\n", _("List extensions"));
+ g_printerr (" info %s\n", _("Show extension info"));
+ g_printerr (" show %s\n", _("Show extension info"));
+ g_printerr (" prefs %s\n", _("Open extension preferences"));
+ g_printerr (" create %s\n", _("Create extension"));
+ g_printerr (" pack %s\n", _("Package extension"));
+ g_printerr (" install %s\n", _("Install extension bundle"));
+ g_printerr ("\n");
+ g_printerr (_("Use “%s” to get detailed help.\n"), help_command);
+}
+
+int
+main (int argc, char *argv[])
+{
+ const char *command;
+ gboolean do_help = FALSE;
+
+ setlocale (LC_ALL, "");
+ textdomain (GETTEXT_PACKAGE);
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+
+#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+
+ if (argc < 2)
+ {
+ usage ();
+ return 1;
+ }
+
+ command = argv[1];
+ argc--;
+ argv++;
+
+ if (g_str_equal (command, "help"))
+ {
+ if (argc == 1)
+ {
+ usage ();
+ return 0;
+ }
+ else
+ {
+ command = argv[1];
+ do_help = TRUE;
+ }
+ }
+ else if (g_str_equal (command, "--help"))
+ {
+ usage ();
+ return 0;
+ }
+ else if (g_str_equal (command, "--version"))
+ {
+ command = "version";
+ }
+
+ if (g_str_equal (command, "version"))
+ return handle_version (argc, argv, do_help);
+ else if (g_str_equal (command, "enable"))
+ return handle_enable (argc, argv, do_help);
+ else if (g_str_equal (command, "disable"))
+ return handle_disable (argc, argv, do_help);
+ else if (g_str_equal (command, "reset"))
+ return handle_reset (argc, argv, do_help);
+ else if (g_str_equal (command, "list"))
+ return handle_list (argc, argv, do_help);
+ else if (g_str_equal (command, "info"))
+ return handle_info (argc, argv, do_help);
+ else if (g_str_equal (command, "show"))
+ return handle_info (argc, argv, do_help);
+ else if (g_str_equal (command, "prefs"))
+ return handle_prefs (argc, argv, do_help);
+ else if (g_str_equal (command, "create"))
+ return handle_create (argc, argv, do_help);
+ else if (g_str_equal (command, "pack"))
+ return handle_pack (argc, argv, do_help);
+ else if (g_str_equal (command, "install"))
+ return handle_install (argc, argv, do_help);
+ else if (g_str_equal (command, "uninstall"))
+ return handle_uninstall (argc, argv, do_help);
+ else
+ usage ();
+
+ return 1;
+}
diff --git a/subprojects/extensions-tool/src/meson.build b/subprojects/extensions-tool/src/meson.build
new file mode 100644
index 0000000..a855fef
--- /dev/null
+++ b/subprojects/extensions-tool/src/meson.build
@@ -0,0 +1,37 @@
+config_h = configuration_data()
+config_h.set_quoted('GETTEXT_PACKAGE', package_name)
+config_h.set_quoted('VERSION', meson.project_version())
+config_h.set_quoted('LOCALEDIR', localedir)
+config_h.set('HAVE_BIND_TEXTDOMAIN_CODESET', cc.has_function('bind_textdomain_codeset'))
+configure_file(
+ output: 'config.h',
+ configuration: config_h,
+)
+
+sources = [
+ 'command-create.c',
+ 'command-disable.c',
+ 'command-enable.c',
+ 'command-info.c',
+ 'command-install.c',
+ 'command-list.c',
+ 'command-pack.c',
+ 'command-prefs.c',
+ 'command-reset.c',
+ 'command-uninstall.c',
+ 'main.c'
+]
+
+subdir('templates')
+
+resources = gnome.compile_resources('resources',
+ 'gnome-extensions-tool.gresource.xml',
+ source_dir: ['.', meson.current_build_dir()],
+ dependencies: template_deps,
+)
+
+executable('gnome-extensions',
+ sources, resources,
+ dependencies: [gio_dep, gio_unix_dep, autoar_dep, json_dep],
+ install: true
+)
diff --git a/subprojects/extensions-tool/src/templates/00-plain.desktop.in b/subprojects/extensions-tool/src/templates/00-plain.desktop.in
new file mode 100644
index 0000000..36ddf80
--- /dev/null
+++ b/subprojects/extensions-tool/src/templates/00-plain.desktop.in
@@ -0,0 +1,5 @@
+[Desktop Entry]
+Type=Application
+Name=Plain
+Comment=An empty extension
+Path=plain
diff --git a/subprojects/extensions-tool/src/templates/indicator.desktop.in b/subprojects/extensions-tool/src/templates/indicator.desktop.in
new file mode 100644
index 0000000..1718e94
--- /dev/null
+++ b/subprojects/extensions-tool/src/templates/indicator.desktop.in
@@ -0,0 +1,5 @@
+[Desktop Entry]
+Type=Application
+Name=Indicator
+Comment=Add an icon to the top bar
+Path=indicator
diff --git a/subprojects/extensions-tool/src/templates/indicator/extension.js b/subprojects/extensions-tool/src/templates/indicator/extension.js
new file mode 100644
index 0000000..fd84782
--- /dev/null
+++ b/subprojects/extensions-tool/src/templates/indicator/extension.js
@@ -0,0 +1,74 @@
+/* extension.js
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+/* exported init */
+
+const GETTEXT_DOMAIN = 'my-indicator-extension';
+
+const { GObject, St } = imports.gi;
+
+const Gettext = imports.gettext.domain(GETTEXT_DOMAIN);
+const _ = Gettext.gettext;
+
+const ExtensionUtils = imports.misc.extensionUtils;
+const Main = imports.ui.main;
+const PanelMenu = imports.ui.panelMenu;
+const PopupMenu = imports.ui.popupMenu;
+
+const Indicator = GObject.registerClass(
+class Indicator extends PanelMenu.Button {
+ _init() {
+ super._init(0.0, _('My Shiny Indicator'));
+
+ let box = new St.BoxLayout({ style_class: 'panel-status-menu-box' });
+ box.add_child(new St.Icon({
+ icon_name: 'face-smile-symbolic',
+ style_class: 'system-status-icon',
+ }));
+ box.add_child(PopupMenu.arrowIcon(St.Side.BOTTOM));
+ this.add_child(box);
+
+ let item = new PopupMenu.PopupMenuItem(_('Show Notification'));
+ item.connect('activate', () => {
+ Main.notify(_('Whatʼs up, folks?'));
+ });
+ this.menu.addMenuItem(item);
+ }
+});
+
+class Extension {
+ constructor(uuid) {
+ this._uuid = uuid;
+
+ ExtensionUtils.initTranslations(GETTEXT_DOMAIN);
+ }
+
+ enable() {
+ this._indicator = new Indicator();
+ Main.panel.addToStatusArea(this._uuid, this._indicator);
+ }
+
+ disable() {
+ this._indicator.destroy();
+ this._indicator = null;
+ }
+}
+
+function init(meta) {
+ return new Extension(meta.uuid);
+}
diff --git a/subprojects/extensions-tool/src/templates/indicator/stylesheet.css b/subprojects/extensions-tool/src/templates/indicator/stylesheet.css
new file mode 100644
index 0000000..37b93f2
--- /dev/null
+++ b/subprojects/extensions-tool/src/templates/indicator/stylesheet.css
@@ -0,0 +1 @@
+/* Add your custom extension styling here */
diff --git a/subprojects/extensions-tool/src/templates/meson.build b/subprojects/extensions-tool/src/templates/meson.build
new file mode 100644
index 0000000..670e2bf
--- /dev/null
+++ b/subprojects/extensions-tool/src/templates/meson.build
@@ -0,0 +1,13 @@
+template_metas = [
+ '00-plain.desktop',
+ 'indicator.desktop',
+]
+template_deps = []
+foreach template : template_metas
+ template_deps += i18n.merge_file(template,
+ input: template + '.in',
+ output: template,
+ po_dir: po_dir,
+ type: 'desktop',
+ )
+endforeach
diff --git a/subprojects/extensions-tool/src/templates/plain/extension.js b/subprojects/extensions-tool/src/templates/plain/extension.js
new file mode 100644
index 0000000..64857af
--- /dev/null
+++ b/subprojects/extensions-tool/src/templates/plain/extension.js
@@ -0,0 +1,34 @@
+/* extension.js
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+/* exported init */
+
+class Extension {
+ constructor() {
+ }
+
+ enable() {
+ }
+
+ disable() {
+ }
+}
+
+function init() {
+ return new Extension();
+}
diff --git a/subprojects/extensions-tool/src/templates/plain/stylesheet.css b/subprojects/extensions-tool/src/templates/plain/stylesheet.css
new file mode 100644
index 0000000..37b93f2
--- /dev/null
+++ b/subprojects/extensions-tool/src/templates/plain/stylesheet.css
@@ -0,0 +1 @@
+/* Add your custom extension styling here */