diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/LICENSE b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/LICENSE
new file mode 100644
index 0000000..10926e8
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/LICENSE
@@ -0,0 +1,675 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/README.md b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/README.md
new file mode 100644
index 0000000..5d234d8
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/README.md
@@ -0,0 +1,90 @@
+# Draw On Gnome
+
+[
](https://extensions.gnome.org/extension/7921/draw-on-gnome/)
+
+Annotate your GNOMEβ’ desktop with **`Super+Alt+D`**.
+
+Documentation is **[here](https://daveprowse.github.io/Draw-On-Gnome/)**.
+
+Thank you to all the contributors! π
+
+## Features
+
+- Draw over applications
+- Basic shapes (rectangle, circle, ellipse, line, polygon, polyline, arrow, text, free)
+- Basic transformations (move, rotate, resize, mirror)
+- Laser pointer, highlighter
+- Blackboard and Grid
+- Paste images from local computer
+- Keep drawings on desktop background with persistence
+- Multi-monitor support
+- Save your work with `Ctrl+S`!!
+
+## Installation Options
+
+### Option 1: Install from GNOME Extensions (ver. 48/49)
+
+[
](https://extensions.gnome.org/extension/7921/draw-on-gnome/)
+
+> **IMPORTANT!!**: Currently, this will *only* install to GNOMEv48 and v49. If you need the extension for another version of GNOME, see Option 2.
+
+### Option 2: Use the Automated Script
+
+1. Copy the following command to a *Bash* terminal and press `enter` to run it:
+
+ ```bash
+ bash <(wget -qO- https://raw.githubusercontent.com/daveprowse/scripts/refs/heads/main/dog-install.sh)
+ ```
+
+ The script will attempt to identify your version of GNOME and install the correct version of the extension automatically.
+
+ > Note: Currently, the script will identify GNOME v49 through v40 and back all the way to v3.xx.
+
+ > Note: You may need to enter your sudo password during the install. Make sure you are a sudoer!
+
+ > **IMPORTANT!!** Always check scripts before running them! If you are uncomfortable running the script, or cannot run the script, then install manually with an option listed in the [Documentation](https://daveprowse.github.io/Draw-On-Gnome/installation/#option-3-install-manually-from-the-release-or-repository-branch/).
+
+2. Logout and log back in.
+
+3. Enable the extension:
+
+- In the GUI
+ - Open the GNOME Extensions App:
+
+ `gnome-extensions-app`
+
+ - Locate Draw On GNOME and enable it.
+
+
+- In the CLI:
+
+ ```console
+ gnome-extensions enable draw-on-gnome@daveprowse.github.io
+ ```
+
+
+ > Note: You can install the Gnome Extensions App with the package `gnome-shell-extensions-prefs` within your Linux distribution.
+
+4. Now go forth and use the tool by pressing `Super + Alt + D`.
+
+ > Note: You can discover the keyboard shortcuts by pressing `Ctrl + F1`.
+
+It's back to the drawing board my friends! Enjoy! π
+
+---
+
+## Manual Installs
+
+> Warning!! If you clone the main repository you are getting the latest features, but they have not yet been released, and might not be thoroughly tested. You've been warned!
+
+π For manual installation procedures (git clone and tarball) see the **[Documentation](https://daveprowse.github.io/Draw-On-Gnome/installation/)**.
+
+> Documentation is generated using Material for Mkdocs. Check it out:
+> [](https://squidfunk.github.io/mkdocs-material/)
+
+---
+
+Thanks to the original author and past maintainers:
+
+- Forked from: https://github.com/zhrexl/DrawOnYourScreen2
+- Original work: https://codeberg.org/som/DrawOnYourScreen
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/area.js b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/area.js
new file mode 100644
index 0000000..fc3566d
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/area.js
@@ -0,0 +1,2204 @@
+/*
+ * Copyright 2019 Abakkk
+ * Copyright 2024 Dave Prowse
+ *
+ * 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 .
+ *
+ * SPDX-FileCopyrightText: 2019 Abakkk
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileContributor: Modified by Dave Prowse
+ */
+
+/* jslint esversion: 6 (2019) */
+/* eslint version: 9.16 (2024) */
+/* exported Tool, DrawingArea */
+
+import Cairo from 'cairo';
+import System from 'system';
+
+import Clutter from 'gi://Clutter';
+import Cogl from 'gi://Cogl';
+
+// This line is not necessary for GNOME 47, but is necessary for GNOME 46 backward compatibility (if variables are used properly elsewhere)
+// Old nullish coalescing operator: const Color = Clutter.Color ?? Cogl.Color;
+// GNOME 46/47 compatibility: Use ternary operator instead
+const Color = Clutter.Color ? Clutter.Color : Cogl.Color;
+
+import Gio from 'gi://Gio';
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
+import Pango from 'gi://Pango';
+import PangoCairo from 'gi://PangoCairo';
+import Shell from 'gi://Shell';
+import St from 'gi://St';
+
+import * as Main from 'resource:///org/gnome/shell/ui/main.js';
+import * as Screenshot from 'resource:///org/gnome/shell/ui/screenshot.js';
+
+import { gettext as _, pgettext } from 'resource:///org/gnome/shell/extensions/extension.js';
+
+import { CURATED_UUID as UUID } from './utils.js';
+import * as Elements from './elements.js'
+import { Image } from './files.js'
+import * as Menu from './menu.js'
+
+import Meta from 'gi://Meta';
+
+const MOTION_TIME = 1; // ms, time accuracy for free drawing, max is about 33 ms. The lower it is, the smoother the drawing is.
+const TEXT_CURSOR_TIME = 600; // ms
+const ELEMENT_GRABBER_TIME = 80; // ms, default is about 16 ms
+const TOGGLE_ANIMATION_DURATION = 300; // ms
+const GRID_TILES_HORIZONTAL_NUMBER = 30;
+const COLOR_PICKER_EXTENSION_UUID = 'color-picker@tuberry';
+
+const HIGHLIGHTER_YELLOW = Color.from_string('#ffff00')[1];
+
+const { Shape, StaticColor, TextAlignment, Transformation } = Elements;
+const { DisplayStrings } = Menu;
+
+const FontGenericFamilies = ['Sans-Serif', 'Serif', 'Monospace', 'Cursive', 'Fantasy'];
+const Manipulation = { MOVE: 100, RESIZE: 101, MIRROR: 102 };
+export const Tool = {
+ getNameOf: function (value) {
+ return Object.keys(this).find(key => this[key] == value);
+ },
+ ...Shape,
+ ...Manipulation
+};
+Object.defineProperty(Tool, 'getNameOf', { enumerable: false });
+
+
+
+// Drawing layers are the proper drawing area widgets (painted thanks to Cairo).
+const DrawingLayer = GObject.registerClass({
+ GTypeName: `${UUID}-DrawingLayer`,
+}, class DrawingArea extends St.DrawingArea {
+ _init(repaintFunction, getHasImageFunction) {
+ this._repaint = repaintFunction;
+ this._getHasImage = getHasImageFunction || (() => false);
+ super._init();
+ }
+
+ // Bind the size of layers and layer container.
+ vfunc_parent_set() {
+ this.clear_constraints();
+
+ if (this.get_parent())
+ this.add_constraint(new Clutter.BindConstraint({ coordinate: Clutter.BindCoordinate.SIZE, source: this.get_parent() }));
+ }
+
+ vfunc_repaint() {
+ let cr = this.get_context();
+
+ try {
+ this._repaint(cr);
+ } catch (e) {
+ logError(e, "An error occured while painting");
+ }
+
+ cr.$dispose();
+ if (this._getHasImage())
+ System.gc();
+ }
+});
+
+// Darwing area is a container that manages drawing elements and drawing layers.
+// There is a drawing element for each "brushstroke".
+// There is a separated layer for the current element so only the current element is redisplayed when drawing.
+// It handles pointer/mouse/(touch?) events and some keyboard events.
+export const DrawingArea = GObject.registerClass({
+ GTypeName: `${UUID}-DrawingArea`,
+ Signals: {
+ 'show-osd': { param_types: [Gio.Icon.$gtype, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_DOUBLE, GObject.TYPE_BOOLEAN] },
+ 'pointer-cursor-changed': { param_types: [GObject.TYPE_STRING] },
+ 'leave-drawing-mode': {}
+ },
+}, class DrawingArea extends St.Widget {
+
+ _init(extension, params, monitor, helper, areaManagerUtils, loadPersistent, toolConf) {
+ super._init({ style_class: 'draw-on-gnome', name: params.name });
+ this._extension = extension;
+ this.monitor = monitor;
+ this.helper = helper;
+ this.areaManagerUtils = areaManagerUtils;
+
+ this.layerContainer = new St.Widget({ width: monitor.width, height: monitor.height });
+ this.add_child(this.layerContainer);
+ this.add_child(this.helper);
+
+ this.backLayer = new DrawingLayer(this._repaintBack.bind(this), this._getHasImageBack.bind(this));
+ this.layerContainer.add_child(this.backLayer);
+ this.foreLayer = new DrawingLayer(this._repaintFore.bind(this), this._getHasImageFore.bind(this));
+ this.layerContainer.add_child(this.foreLayer);
+
+ this.gridLayer = new DrawingLayer(this._repaintGrid.bind(this));
+ this.gridLayer.hide();
+ this.gridLayer.opacity = 0;
+ this.layerContainer.add_child(this.gridLayer);
+
+ // Ruler layer - shows with grid
+ this.rulerLayer = new DrawingLayer(this._repaintRulers.bind(this));
+ this.rulerLayer.hide();
+ this.rulerLayer.opacity = 0;
+ this.rulerLayer.reactive = false; // Clicks pass through
+ this.layerContainer.add_child(this.rulerLayer);
+
+ // Track mouse position for ruler highlights
+ this.rulerMouseX = 0;
+ this.rulerMouseY = 0;
+
+ // Laser pointer layer and state
+ this.laserLayer = new DrawingLayer(this._repaintLaser.bind(this));
+ this.laserLayer.hide();
+ this.laserLayer.opacity = 0;
+ this.laserLayer.reactive = false; // ADD THIS LINE - allows clicks to pass through
+ this.layerContainer.add_child(this.laserLayer);
+
+ // Laser pointer state variables
+ this.laserPointerActive = false;
+ this.laserPointerX = 0;
+ this.laserPointerY = 0;
+ this.laserTrailPoints = [];
+ this.laserTrailMaxLength = 15;
+ this.laserAnimationTimeoutId = null;
+ this.laserKeyPressed = false;
+
+ // Laser pointer state variables
+ this.laserPointerActive = false;
+ this.laserPointerX = 0;
+ this.laserPointerY = 0;
+ this.laserTrailPoints = [];
+ this.laserTrailMaxLength = 15;
+ this.laserAnimationTimeoutId = null;
+ this.laserKeyPressed = false;
+ this.laserTrailTimeoutId = null; // ADD THIS LINE
+ // End laser pointer code
+
+ this.elements = [];
+
+ this.undoneElements = [];
+ this.currentElement = null;
+ this.currentTool = Shape.NONE;
+ if (toolConf["toolPalette"][0] != "") {
+ this.currentPalette = toolConf["toolPalette"]
+ }
+ if (toolConf["toolColor"] != "") {
+ this.currentColor = this.getColorFromString(toolConf["toolColor"], "White");
+ }
+ this.currentImage = null;
+ this.currentTextAlignment = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL ? TextAlignment.RIGHT : TextAlignment.LEFT;
+ let fontName = St.Settings && St.Settings.get().font_name || this._extension.getSettings('org.gnome.desktop.interface').get_string('font-name');
+ this.currentFont = Pango.FontDescription.from_string(fontName);
+ this.currentFont.unset_fields(Pango.FontMask.SIZE);
+ this.defaultFontFamily = this.currentFont.get_family();
+ this.currentLineWidth = toolConf["toolSize"];
+ this.currentLineJoin = Cairo.LineJoin.ROUND;
+ this.currentLineCap = Cairo.LineCap.ROUND;
+ this.currentFillRule = Cairo.FillRule.WINDING;
+ this.isSquareArea = false;
+ this.hasBackground = false;
+ this.textHasCursor = false;
+ this.dashedLine = false;
+ this.fill = false;
+
+ this.connect('notify::reactive', this._onReactiveChanged.bind(this));
+ this.drawingSettingsChangedHandler = this._extension.drawingSettings.connect('changed', this._onDrawingSettingsChanged.bind(this));
+ this._onDrawingSettingsChanged();
+
+ if (loadPersistent)
+ this._loadPersistent();
+ }
+
+ get menu() {
+ if (!this._menu)
+ this._menu = new Menu.DrawingMenu(this._extension, this, this.monitor, Tool, this.areaManagerUtils);
+ return this._menu;
+ }
+
+ closeMenu() {
+ if (this._menu)
+ this._menu.close();
+ }
+
+ get isWriting() {
+ return this.textEntry;
+ }
+
+ get currentTool() {
+ return this._currentTool;
+ }
+
+ set currentTool(tool) {
+ this._currentTool = tool;
+ if (this.hasManipulationTool)
+ this._startElementGrabber();
+ else
+ this._stopElementGrabber();
+ }
+
+ get currentPalette() {
+ return this._currentPalette;
+ }
+
+ set currentPalette(palette) {
+ this._currentPalette = palette;
+ this.colors = palette[1].map(colorString => this.getColorFromString(colorString, 'White'));
+ if (!this.colors[0])
+ this.colors.push(StaticColor.WHITE);
+ this._extension.drawingSettings.set_value("tool-palette", new GLib.Variant('(sas)', palette))
+ }
+
+ get currentImage() {
+ if (!this._currentImage)
+ this._currentImage = this._extension.FILES.IMAGES.getNext(this._currentImage);
+
+ return this._currentImage;
+ }
+
+ set currentImage(image) {
+ this._currentImage = image;
+ }
+
+ get currentFontFamily() {
+ return this.currentFont.get_family();
+ }
+
+ set currentFontFamily(family) {
+ this.currentFont.set_family(family);
+ }
+
+ get currentFontStyle() {
+ return this.currentFont.get_style();
+ }
+
+ set currentFontStyle(style) {
+ this.currentFont.set_style(style);
+ }
+
+ get currentFontWeight() {
+ return this.currentFont.get_weight();
+ }
+
+ set currentFontWeight(weight) {
+ this.currentFont.set_weight(weight);
+ }
+
+ get hasManipulationTool() {
+ // No Object.values method in GS 3.24.
+ return Object.keys(Manipulation).map(key => Manipulation[key]).indexOf(this.currentTool) != -1;
+ }
+
+ // Boolean wrapper for switch menu item.
+ get currentEvenodd() {
+ return this.currentFillRule == Cairo.FillRule.EVEN_ODD;
+ }
+
+ set currentEvenodd(evenodd) {
+ this.currentFillRule = evenodd ? Cairo.FillRule.EVEN_ODD : Cairo.FillRule.WINDING;
+ }
+
+ get fontFamilies() {
+ if (!this._fontFamilies) {
+ let otherFontFamilies = Elements.getAllFontFamilies().filter(family => {
+ return family != this.defaultFontFamily && FontGenericFamilies.indexOf(family) == -1;
+ });
+ this._fontFamilies = [this.defaultFontFamily].concat(FontGenericFamilies, otherFontFamilies);
+ }
+ return this._fontFamilies;
+ }
+
+ _onDrawingSettingsChanged() {
+ this.palettes = this._extension.drawingSettings.get_value('palettes').deep_unpack();
+ if (!this.colors) {
+ if (this.palettes[0])
+ this.currentPalette = this.palettes[0];
+ else
+ this.currentPalette = ['Palette', ['White']];
+ }
+ if (!this.currentColor) {
+ this.currentColor = this.colors[0];
+ this.currentColorIndex = 0; // Track that we're using the first color
+ }
+
+ if (this._extension.drawingSettings.get_boolean('square-area-auto')) {
+ this.squareAreaSize = Math.pow(2, 6);
+ while (this.squareAreaSize * 2 < Math.min(this.monitor.width, this.monitor.height))
+ this.squareAreaSize *= 2;
+ } else {
+ this.squareAreaSize = this._extension.drawingSettings.get_uint('square-area-size');
+ }
+
+ this.areaBackgroundColor = this.getColorFromString(this._extension.drawingSettings.get_string('background-color'), 'Black');
+
+ this.gridColor = this.getColorFromString(this._extension.drawingSettings.get_string('grid-color'), 'Gray');
+ if (this._extension.drawingSettings.get_boolean('grid-line-auto')) {
+ this.gridLineSpacing = Math.round(this.monitor.width / (5 * GRID_TILES_HORIZONTAL_NUMBER));
+ this.gridLineWidth = this.gridLineSpacing / 20;
+ } else {
+ this.gridLineSpacing = this._extension.drawingSettings.get_uint('grid-line-spacing');
+ this.gridLineWidth = Math.round(this._extension.drawingSettings.get_double('grid-line-width') * 100) / 100;
+ }
+
+ this.dashOffset = Math.round(this._extension.drawingSettings.get_double('dash-offset') * 100) / 100;
+ if (this._extension.drawingSettings.get_boolean('dash-array-auto')) {
+ this.dashArray = [0,0];
+ } else {
+ let on = Math.round(this._extension.drawingSettings.get_double('dash-array-on') * 100) / 100;
+ let off = Math.round(this._extension.drawingSettings.get_double('dash-array-off') * 100) / 100;
+ this.dashArray = [on, off];
+ }
+ }
+
+ _repaintBack(cr) {
+ this.elements.forEach(element => {
+ cr.save();
+ element.buildCairo(cr, {
+ showElementBounds: this.grabbedElement && this.grabbedElement == element,
+ drawElementBounds: this.grabPoint ? true : false
+ });
+
+ if (this.grabPoint)
+ this._searchElementToGrab(cr, element);
+
+ if (element.fill && !element.isStraightLine) {
+ cr.fillPreserve();
+ if (element.shape == Shape.NONE || element.shape == Shape.LINE)
+ cr.closePath();
+ }
+
+ // Don't stroke images - they're already painted
+ if (element.shape !== Shape.IMAGE) {
+ cr.stroke();
+ }
+ element._addMarks(cr);
+ cr.restore();
+
+ });
+
+ if (this.currentElement && this.currentElement.eraser) {
+ this.currentElement.buildCairo(cr, {
+ showTextCursor: this.textHasCursor,
+ showElementBounds: this.currentElement.shape != Shape.TEXT || !this.isWriting,
+ dummyStroke: this.currentElement.fill && this.currentElement.line.lineWidth == 0
+ });
+ cr.stroke();
+ }
+ }
+
+ _repaintFore(cr) {
+ if (!this.currentElement || this.currentElement.eraser)
+ return;
+
+ this.currentElement.buildCairo(cr, {
+ showTextCursor: this.textHasCursor,
+ showElementBounds: this.currentElement.shape != Shape.TEXT || !this.isWriting,
+ dummyStroke: this.currentElement.fill && this.currentElement.line.lineWidth == 0
+ });
+ cr.stroke();
+ }
+
+ _repaintGrid(cr) {
+ if (!this.reactive)
+ return;
+
+ cr.setSourceColor(this.gridColor);
+
+ let [gridX, gridY] = [0, 0];
+ while (gridX < this.monitor.width / 2) {
+ cr.setLineWidth((gridX / this.gridLineSpacing) % 5 ? this.gridLineWidth / 2 : this.gridLineWidth);
+ cr.moveTo(this.monitor.width / 2 + gridX, 0);
+ cr.lineTo(this.monitor.width / 2 + gridX, this.monitor.height);
+ cr.moveTo(this.monitor.width / 2 - gridX, 0);
+ cr.lineTo(this.monitor.width / 2 - gridX, this.monitor.height);
+ gridX += this.gridLineSpacing;
+ cr.stroke();
+ }
+ while (gridY < this.monitor.height / 2) {
+ cr.setLineWidth((gridY / this.gridLineSpacing) % 5 ? this.gridLineWidth / 2 : this.gridLineWidth);
+ cr.moveTo(0, this.monitor.height / 2 + gridY);
+ cr.lineTo(this.monitor.width, this.monitor.height / 2 + gridY);
+ cr.moveTo(0, this.monitor.height / 2 - gridY);
+ cr.lineTo(this.monitor.width, this.monitor.height / 2 - gridY);
+ gridY += this.gridLineSpacing;
+ cr.stroke();
+ }
+ }
+
+ _repaintRulers(cr) {
+ if (!this.reactive || !this.hasGrid)
+ return;
+
+ const RULER_WIDTH = 40;
+ const RULER_OPACITY = 0.7;
+
+ // Calculate lighter color (30% lighter than grid)
+ let lighterColor = new Color({
+ red: Math.min(255, this.gridColor.red + 77),
+ green: Math.min(255, this.gridColor.green + 77),
+ blue: Math.min(255, this.gridColor.blue + 77),
+ alpha: Math.floor(this.gridColor.alpha * RULER_OPACITY)
+ });
+
+ // Create Pango layout for text
+ let layout = this.rulerLayer.create_pango_layout('');
+ let fontDesc = Pango.FontDescription.from_string('Sans Bold 9');
+ layout.set_font_description(fontDesc);
+
+ // === LEFT RULER (Y-axis) ===
+ cr.save();
+
+ // Draw ruler background
+ cr.setSourceRGBA(
+ lighterColor.red / 255,
+ lighterColor.green / 255,
+ lighterColor.blue / 255,
+ lighterColor.alpha / 255
+ );
+ cr.rectangle(0, 0, RULER_WIDTH, this.monitor.height);
+ cr.fill();
+
+ // Draw Y-axis tick marks
+ cr.setSourceColor(this.gridColor);
+ let centerY = this.monitor.height / 2;
+ let gridUnit = 0;
+ let y = 0;
+
+ while (y < this.monitor.height / 2) {
+ let isMainMark = (gridUnit % 5 === 0);
+ cr.setLineWidth(isMainMark ? 2 : 1);
+
+ let tickLength = isMainMark ? 12 : 6;
+ // Marks above center
+ cr.moveTo(RULER_WIDTH - tickLength, centerY - y);
+ cr.lineTo(RULER_WIDTH, centerY - y);
+ cr.stroke();
+
+ // Marks below center
+ cr.moveTo(RULER_WIDTH - tickLength, centerY + y);
+ cr.lineTo(RULER_WIDTH, centerY + y);
+ cr.stroke();
+
+ y += this.gridLineSpacing;
+ gridUnit++;
+ }
+
+ // Draw Y-axis numbers (separate pass for proper rendering)
+ gridUnit = 0;
+ y = 0;
+ cr.setSourceRGBA(0.1, 0.1, 0.1, 0.9); // Dark gray text
+
+ while (y < this.monitor.height / 2) {
+ let isMainMark = (gridUnit % 5 === 0);
+
+ if (isMainMark && gridUnit > 0) {
+ layout.set_text(String(gridUnit), -1);
+ let [textWidth, textHeight] = layout.get_pixel_size();
+
+ // Above center
+ cr.moveTo(5, centerY - y - textHeight / 2);
+ PangoCairo.show_layout(cr, layout);
+
+ // Below center
+ cr.moveTo(5, centerY + y - textHeight / 2);
+ PangoCairo.show_layout(cr, layout);
+ }
+
+ y += this.gridLineSpacing;
+ gridUnit++;
+ }
+
+ // Highlight current Y position - darker and more visible
+ if (this.rulerMouseY >= 0 && this.rulerMouseY <= this.monitor.height) {
+ cr.setSourceRGBA(0.2, 0.5, 0.8, 0.6); // Blue highlight, more opaque
+ cr.rectangle(0, this.rulerMouseY - 2, RULER_WIDTH, 4);
+ cr.fill();
+ }
+
+ cr.restore();
+
+ // === BOTTOM RULER (X-axis) ===
+ cr.save();
+
+ // Draw ruler background
+ cr.setSourceRGBA(
+ lighterColor.red / 255,
+ lighterColor.green / 255,
+ lighterColor.blue / 255,
+ lighterColor.alpha / 255
+ );
+ cr.rectangle(0, this.monitor.height - RULER_WIDTH, this.monitor.width, RULER_WIDTH);
+ cr.fill();
+
+ // Draw X-axis tick marks
+ cr.setSourceColor(this.gridColor);
+ let centerX = this.monitor.width / 2;
+ gridUnit = 0;
+ let x = 0;
+
+ while (x < this.monitor.width / 2) {
+ let isMainMark = (gridUnit % 5 === 0);
+ cr.setLineWidth(isMainMark ? 2 : 1);
+
+ let tickLength = isMainMark ? 12 : 6;
+ // Marks left of center
+ cr.moveTo(centerX - x, this.monitor.height - RULER_WIDTH);
+ cr.lineTo(centerX - x, this.monitor.height - RULER_WIDTH + tickLength);
+ cr.stroke();
+
+ // Marks right of center
+ cr.moveTo(centerX + x, this.monitor.height - RULER_WIDTH);
+ cr.lineTo(centerX + x, this.monitor.height - RULER_WIDTH + tickLength);
+ cr.stroke();
+
+ x += this.gridLineSpacing;
+ gridUnit++;
+ }
+
+ // Draw X-axis numbers (separate pass for proper rendering)
+ gridUnit = 0;
+ x = 0;
+ cr.setSourceRGBA(0.1, 0.1, 0.1, 0.9); // Dark gray text
+
+ while (x < this.monitor.width / 2) {
+ let isMainMark = (gridUnit % 5 === 0);
+
+ if (isMainMark && gridUnit > 0) {
+ layout.set_text(String(gridUnit), -1);
+ let [textWidth, textHeight] = layout.get_pixel_size();
+
+ // Left of center
+ cr.moveTo(centerX - x - textWidth / 2, this.monitor.height - RULER_WIDTH + 15);
+ PangoCairo.show_layout(cr, layout);
+
+ // Right of center
+ cr.moveTo(centerX + x - textWidth / 2, this.monitor.height - RULER_WIDTH + 15);
+ PangoCairo.show_layout(cr, layout);
+ }
+
+ x += this.gridLineSpacing;
+ gridUnit++;
+ }
+
+ // Highlight current X position - darker and more visible
+ if (this.rulerMouseX >= 0 && this.rulerMouseX <= this.monitor.width) {
+ cr.setSourceRGBA(0.2, 0.5, 0.8, 0.6); // Blue highlight, more opaque
+ cr.rectangle(this.rulerMouseX - 2, this.monitor.height - RULER_WIDTH, 4, RULER_WIDTH);
+ cr.fill();
+ }
+
+ cr.restore();
+ }
+
+ // Laser Rendering Method
+ _repaintLaser(cr) {
+ if (!this.laserPointerActive || this.laserTrailPoints.length === 0)
+ return;
+
+ // Draw the laser trail with fading opacity
+ for (let i = 0; i < this.laserTrailPoints.length; i++) {
+ let point = this.laserTrailPoints[i];
+ let opacity = (i + 1) / this.laserTrailPoints.length;
+ let radius = 8 + (opacity * 4);
+
+ cr.setSourceRGBA(1.0, 0.1, 0.1, opacity * 0.7);
+ cr.arc(point[0], point[1], radius, 0, 2 * Math.PI);
+ cr.fill();
+ }
+
+ // Draw the main laser pointer
+ let mainRadius = 14;
+
+ // Outer glow
+ let gradient = new Cairo.RadialGradient(
+ this.laserPointerX, this.laserPointerY, 0,
+ this.laserPointerX, this.laserPointerY, mainRadius * 1.5
+ );
+ gradient.addColorStopRGBA(0, 1.0, 0.2, 0.2, 0.9);
+ gradient.addColorStopRGBA(0.5, 1.0, 0.1, 0.1, 0.6);
+ gradient.addColorStopRGBA(1, 1.0, 0.0, 0.0, 0.0);
+
+ cr.setSource(gradient);
+ cr.arc(this.laserPointerX, this.laserPointerY, mainRadius * 1.5, 0, 2 * Math.PI);
+ cr.fill();
+
+ // Inner bright core
+ cr.setSourceRGBA(1.0, 0.3, 0.3, 0.95);
+ cr.arc(this.laserPointerX, this.laserPointerY, mainRadius, 0, 2 * Math.PI);
+ cr.fill();
+
+ // Central hot spot
+ cr.setSourceRGBA(1.0, 0.9, 0.9, 1.0);
+ cr.arc(this.laserPointerX, this.laserPointerY, mainRadius * 0.4, 0, 2 * Math.PI);
+ cr.fill();
+ }
+
+ // End Laser Rendering Method code
+
+ _getHasImageBack() {
+ return this.elements.some(element => element.shape == Shape.IMAGE);
+ }
+
+ _getHasImageFore() {
+ return this.currentElement && this.currentElement.shape == Shape.IMAGE || false;
+ }
+
+ _redisplay() {
+ // force area to emit 'repaint'
+ this.backLayer.queue_repaint();
+ this.foreLayer.queue_repaint();
+ if (this.hasGrid) {
+ this.gridLayer.queue_repaint();
+ this.rulerLayer.queue_repaint();
+ }
+ }
+
+ _transformStagePoint(stageX, stageY) {
+ let [s, x, y] = this.transform_stage_point(stageX, stageY);
+ if (!s || !this.layerContainer.get_allocation_box().contains(x, y))
+ return [false, 0, 0];
+
+ return this.layerContainer.transform_stage_point(stageX, stageY);
+ }
+
+ _onButtonPressed(actor, event) {
+ if (this.spaceKeyPressed)
+ return Clutter.EVENT_PROPAGATE;
+
+ let button = event.get_button();
+ let [x, y] = event.get_coords();
+ let controlPressed = event.has_control_modifier();
+ let shiftPressed = event.has_shift_modifier();
+
+ if (this.currentElement && this.currentElement.shape == Shape.TEXT && this.isWriting)
+ // finish writing
+ this._stopWriting();
+
+ if (this.helper.visible) {
+ // hide helper
+ this.toggleHelp();
+ return Clutter.EVENT_STOP;
+ }
+
+ // Laser Button Press Handling Code
+
+ if (button == 1) {
+ if (this.laserPointerActive) {
+ this.stopLaserPointer();
+ }
+
+ if (this.hasManipulationTool) {
+ if (this.grabbedElement)
+ this._startTransforming(x, y, controlPressed, shiftPressed);
+ } else {
+ this._startDrawing(x, y, shiftPressed, (event.get_device ? event.get_device() : null) || event.get_source_device());
+ }
+ return Clutter.EVENT_STOP;
+ // End Laser Button Press Handling Code
+
+ } else if (button == 2) {
+ this.switchFill();
+ } else if (button == 3) {
+ this._stopAll();
+
+ this.menu.open(x, y);
+ return Clutter.EVENT_STOP;
+ }
+
+ return Clutter.EVENT_PROPAGATE;
+ }
+
+ _onKeyboardPopupMenu() {
+ this._stopAll();
+
+ if (this.helper.visible)
+ this.toggleHelp();
+ this.menu.popup();
+ return Clutter.EVENT_STOP;
+ }
+
+ // Laser Integration (pressed) - replaced old code
+
+ _onStageKeyPressed(actor, event) {
+ if (event.get_key_symbol() == Clutter.KEY_Escape) {
+ if (this.laserPointerActive) {
+ this.stopLaserPointer();
+ return Clutter.EVENT_STOP;
+ }
+ if (this.helper.visible)
+ this.toggleHelp();
+ else
+ this.emit('leave-drawing-mode');
+ return Clutter.EVENT_STOP;
+ } else if (event.get_key_symbol() == Clutter.KEY_space) {
+ this.spaceKeyPressed = true;
+ } else if (event.get_key_symbol() == Clutter.KEY_Alt_R) {
+ // Right Alt key for laser pointer
+ this.laserKeyPressed = true;
+ if (!this.laserPointerActive) {
+ let [x, y] = global.get_pointer();
+ let [success, localX, localY] = this._transformStagePoint(x, y);
+ if (success) {
+ this.startLaserPointer(localX, localY);
+ }
+ }
+ }
+
+ return Clutter.EVENT_PROPAGATE;
+ }
+
+ // End Laser Integration (pressed)
+
+ // Laser Integration (released)
+
+ _onStageKeyReleased(actor, event) {
+ if (event.get_key_symbol() == Clutter.KEY_space) {
+ this.spaceKeyPressed = false;
+ } else if (event.get_key_symbol() == Clutter.KEY_Alt_R) {
+ this.laserKeyPressed = false;
+ if (this.laserPointerActive) {
+ this.stopLaserPointer();
+ }
+ }
+
+ return Clutter.EVENT_PROPAGATE;
+ }
+
+ // End Laser Integration (released)
+
+ _onKeyPressed(actor, event) {
+ if (event.get_key_symbol() == Clutter.KEY_Escape) {
+ if (this.helper.visible) {
+ this.toggleHelp();
+ } else
+ this.emit('leave-drawing-mode');
+ return Clutter.EVENT_STOP;
+ }
+
+ if (this.currentElement && this.currentElement.shape == Shape.LINE &&
+ (event.get_key_symbol() == Clutter.KEY_Return ||
+ event.get_key_symbol() == Clutter.KEY_KP_Enter ||
+ event.get_key_symbol() == Clutter.KEY_Control_L)) {
+
+ if (this.currentElement.points.length == 2)
+ // Translators: %s is a key label
+ this.emit('show-osd', this._extension.FILES.ICONS.ARC, _("Press %s to get\na fourth control point")
+ .format(Meta.accelerator_name(0, Clutter.KEY_Return)), "", -1, true);
+ this.currentElement.addPoint();
+ this.updatePointerCursor(true);
+ this._redisplay();
+ return Clutter.EVENT_STOP;
+ } else if (this.currentElement &&
+ (this.currentElement.shape == Shape.POLYGON || this.currentElement.shape == Shape.POLYLINE) &&
+ (event.get_key_symbol() == Clutter.KEY_Return || event.get_key_symbol() == Clutter.KEY_KP_Enter)) {
+
+ this.currentElement.addPoint();
+ return Clutter.EVENT_STOP;
+ }
+
+ return Clutter.EVENT_PROPAGATE;
+ }
+
+ _onScroll(actor, event) {
+ if (this.helper.visible)
+ return Clutter.EVENT_PROPAGATE;
+ let direction = event.get_scroll_direction();
+ if (direction == Clutter.ScrollDirection.UP)
+ this.incrementLineWidth(1);
+ else if (direction == Clutter.ScrollDirection.DOWN)
+ this.incrementLineWidth(-1);
+ else
+ return Clutter.EVENT_PROPAGATE;
+ return Clutter.EVENT_STOP;
+ }
+
+ _searchElementToGrab(cr, element) {
+ if (element.getContainsPoint(cr, this.grabPoint[0], this.grabPoint[1]))
+ this.grabbedElement = element;
+ else if (this.grabbedElement == element)
+ this.grabbedElement = null;
+
+ if (element == this.elements[this.elements.length - 1])
+ // All elements have been tested, the winner is the last.
+ this.updatePointerCursor();
+ }
+
+ _startElementGrabber() {
+ if (this.elementGrabberHandler)
+ return;
+
+ this.elementGrabberHandler = this.connect('motion-event', (actor, event) => {
+ if (this.motionHandler || this.grabbedElementLocked) {
+ this.grabPoint = null;
+ return;
+ }
+
+ // Reduce computing without notable effect.
+ if (event.get_time() - (this.elementGrabberTimestamp || 0) < ELEMENT_GRABBER_TIME)
+ return;
+ this.elementGrabberTimestamp = event.get_time();
+
+ let coords = event.get_coords();
+ let [s, x, y] = this._transformStagePoint(coords[0], coords[1]);
+ if (!s)
+ return;
+
+ this.grabPoint = [x, y];
+ this.grabbedElement = null;
+ // this._redisplay calls this._searchElementToGrab.
+ this._redisplay();
+ });
+ }
+
+ _stopElementGrabber() {
+ if (this.elementGrabberHandler) {
+ this.disconnect(this.elementGrabberHandler);
+ this.grabPoint = null;
+ this.elementGrabberHandler = null;
+ }
+ }
+
+ _startTransforming(stageX, stageY, controlPressed, duplicate) {
+ let [success, startX, startY] = this._transformStagePoint(stageX, stageY);
+
+ if (!success)
+ return;
+
+ if (this.currentTool == Manipulation.MIRROR) {
+ this.grabbedElementLocked = !this.grabbedElementLocked;
+ if (this.grabbedElementLocked) {
+ this.updatePointerCursor();
+ let label = controlPressed ? _("Mark a point of symmetry") : _("Draw a line of symmetry");
+ this.emit('show-osd', this._extension.FILES.ICONS.TOOL_MIRROR, label, "", -1, true);
+ return;
+ }
+ }
+
+ this.grabPoint = null;
+
+ this.buttonReleasedHandler = this.connect('button-release-event', (actor, event) => {
+ this._stopTransforming();
+ });
+
+ if (duplicate) {
+ // deep cloning
+ let copy = new this.grabbedElement.constructor(JSON.parse(JSON.stringify(this.grabbedElement)));
+ if (this.grabbedElement.color)
+ copy.color = this.grabbedElement.color;
+ if (this.grabbedElement.font)
+ copy.font = this.grabbedElement.font;
+ if (this.grabbedElement.image)
+ copy.image = this.grabbedElement.image;
+ this.elements.push(copy);
+ this.grabbedElement = copy;
+ }
+
+ let undoable = !duplicate;
+
+ if (this.currentTool == Manipulation.MOVE)
+ this.grabbedElement.startTransformation(startX, startY, controlPressed ? Transformation.ROTATION : Transformation.TRANSLATION, undoable);
+ else if (this.currentTool == Manipulation.RESIZE)
+ this.grabbedElement.startTransformation(startX, startY, controlPressed ? Transformation.STRETCH : Transformation.SCALE_PRESERVE, undoable);
+ else if (this.currentTool == Manipulation.MIRROR) {
+ this.grabbedElement.startTransformation(startX, startY, controlPressed ? Transformation.INVERSION : Transformation.REFLECTION, undoable);
+ this._redisplay();
+ }
+
+ // Laser Motion Handling
+
+ this.motionHandler = this.connect('motion-event', (actor, event) => {
+ let coords = event.get_coords();
+ let [s, x, y] = this._transformStagePoint(coords[0], coords[1]);
+ if (!s)
+ return;
+
+ if (this.spaceKeyPressed)
+ return;
+
+ let controlPressed = event.has_control_modifier();
+ this._updateTransforming(x, y, controlPressed);
+ });
+
+ // End Laser Motion Handling
+ }
+
+ _updateTransforming(x, y, controlPressed) {
+ let undoable = this.grabbedElement.lastTransformation.undoable || false;
+
+ if (controlPressed && this.grabbedElement.lastTransformation.type == Transformation.TRANSLATION) {
+ this.grabbedElement.stopTransformation();
+ this.grabbedElement.startTransformation(x, y, Transformation.ROTATION, undoable);
+ } else if (!controlPressed && this.grabbedElement.lastTransformation.type == Transformation.ROTATION) {
+ this.grabbedElement.stopTransformation();
+ this.grabbedElement.startTransformation(x, y, Transformation.TRANSLATION, undoable);
+ }
+
+ if (controlPressed && this.grabbedElement.lastTransformation.type == Transformation.SCALE_PRESERVE) {
+ this.grabbedElement.stopTransformation();
+ this.grabbedElement.startTransformation(x, y, Transformation.STRETCH, undoable);
+ } else if (!controlPressed && this.grabbedElement.lastTransformation.type == Transformation.STRETCH) {
+ this.grabbedElement.stopTransformation();
+ this.grabbedElement.startTransformation(x, y, Transformation.SCALE_PRESERVE, undoable);
+ }
+
+ if (controlPressed && this.grabbedElement.lastTransformation.type == Transformation.REFLECTION) {
+ this.grabbedElement.transformations.pop();
+ this.grabbedElement.startTransformation(x, y, Transformation.INVERSION, undoable);
+ } else if (!controlPressed && this.grabbedElement.lastTransformation.type == Transformation.INVERSION) {
+ this.grabbedElement.transformations.pop();
+ this.grabbedElement.startTransformation(x, y, Transformation.REFLECTION, undoable);
+ }
+
+ this.grabbedElement.updateTransformation(x, y);
+ this._redisplay();
+ }
+
+ _stopTransforming() {
+ if (this.motionHandler) {
+ this.disconnect(this.motionHandler);
+ this.motionHandler = null;
+ }
+ if (this.buttonReleasedHandler) {
+ this.disconnect(this.buttonReleasedHandler);
+ this.buttonReleasedHandler = null;
+ }
+
+ this.grabbedElement.stopTransformation();
+ this.grabbedElement = null;
+ this.grabbedElementLocked = false;
+ this._redisplay();
+ }
+
+ _startDrawing(stageX, stageY, shiftPressed, clickedDevice) {
+ let [success, startX, startY] = this._transformStagePoint(stageX, stageY);
+
+ if (!success)
+ return;
+
+ // Handle laser pointer tool
+ if (this.currentTool == Shape.LASER) {
+ if (!this.laserPointerActive) {
+ this.startLaserPointer(startX, startY);
+ }
+ return; // Don't create a drawing element
+ }
+
+ // Start Highlighter section
+ // Handle highlighter tool - creates semi-transparent yellow filled rectangles
+ if (this.currentTool == Shape.HIGHLIGHTER) {
+ this.buttonReleasedHandler = this.connect('button-release-event', (actor, event) => {
+ this._stopDrawing();
+ });
+
+ // Yellow highlighter with 50% transparency
+ let highlighterColor = HIGHLIGHTER_YELLOW.copy();
+ highlighterColor.alpha = 128;
+
+ // Add toJSON method so color saves properly
+ highlighterColor.toJSON = function() {
+ return this.to_string();
+ };
+ highlighterColor.toString = function() {
+ return this.to_string();
+ };
+
+ // Use RECTANGLE shape with fill enabled for highlighting
+ this.currentElement = new Elements.DrawingElement({
+ shape: Shape.RECTANGLE,
+ color: highlighterColor,
+ eraser: false,
+ fill: true,
+ fillRule: this.currentFillRule,
+ line: { lineWidth: 2, // β CHANGED: 2 instead of 0
+ lineJoin: Cairo.LineJoin.ROUND,
+ lineCap: Cairo.LineCap.ROUND },
+ dash: { active: false, array: [0, 0], offset: 0 },
+ points: []
+ });
+
+ this.currentElement.startDrawing(startX, startY);
+
+ // Standard motion handler
+ if (this.motionHandler) {
+ this.disconnect(this.motionHandler);
+ this.motionHandler = null;
+ }
+
+ this.motionHandler = this.connect('motion-event', (actor, event) => {
+ let coords = event.get_coords();
+ let [s, x, y] = this._transformStagePoint(coords[0], coords[1]);
+ if (!s)
+ return;
+
+ if (clickedDevice != (event.get_device ? event.get_device() : null) && clickedDevice != event.get_source_device())
+ return Clutter.EVENT_PROPAGATE;
+
+ if (this.spaceKeyPressed)
+ return;
+
+ let controlPressed = event.has_control_modifier();
+ this._updateDrawing(x, y, controlPressed);
+ });
+
+ return;
+ }
+
+ // } else if (this.currentTool == Shape.HIGHLIGHTER) {
+ // // Highlighter uses yellow color with semi-transparency
+ // let highlighterColor = HIGHLIGHTER_YELLOW.copy();
+ // highlighterColor.alpha = 128; // 50% transparency
+
+ // this.currentElement = new Elements.DrawingElement({
+ // shape: Shape.RECTANGLE,
+ // color: highlighterColor,
+ // eraser: false,
+ // fill: true,
+ // line: { lineWidth: 2, lineJoin: this.currentLineJoin, lineCap: this.currentLineCap },
+ // points: []
+ // });
+
+
+ // End Highlighter section
+
+ this.buttonReleasedHandler = this.connect('button-release-event', (actor, event) => {
+ this._stopDrawing();
+ });
+
+ if (this.currentTool == Shape.TEXT) {
+ this.currentElement = new Elements.DrawingElement({
+ shape: this.currentTool,
+ color: this.currentColor,
+ eraser: shiftPressed,
+ font: this.currentFont.copy(),
+ // Translators: initial content of the text area
+ text: pgettext("text-area-content", "Text"),
+ textAlignment: this.currentTextAlignment,
+ points: []
+ });
+
+ } else if (this.currentTool == Shape.IMAGE) {
+ this.currentElement = new Elements.DrawingElement({
+ shape: this.currentTool,
+ color: this.currentColor,
+ colored: shiftPressed,
+ image: this.currentImage,
+ points: []
+ });
+ } else {
+ // Calculate dash array dynamically based on line width if in auto mode
+ let dashArray = this.dashArray;
+ if (this._extension.drawingSettings.get_boolean('dash-array-auto') && this.dashedLine) {
+ // Scale dash pattern with line width: dash = 3x width, gap = 2x width
+ let dashLength = Math.max(this.currentLineWidth * 3, 8);
+ let gapLength = Math.max(this.currentLineWidth * 2, 4);
+ // alternative formula for larger gaps: * 2,6, * 2,6
+ dashArray = [dashLength, gapLength];
+ }
+
+ this.currentElement = new Elements.DrawingElement({
+ shape: this.currentTool,
+ color: this.currentColor,
+ eraser: shiftPressed,
+ fill: this.fill,
+ fillRule: this.currentFillRule,
+ line: { lineWidth: this.currentLineWidth,
+ lineJoin: this.currentLineJoin,
+ lineCap: this.currentLineCap },
+ dash: { active: this.dashedLine,
+ array: dashArray,
+ offset: this.dashOffset },
+ points: []
+ });
+ }
+
+ this.currentElement.startDrawing(startX, startY);
+
+ if (this.currentTool == Shape.POLYGON || this.currentTool == Shape.POLYLINE) {
+ let icon = this._extension.FILES.ICONS[this.currentTool == Shape.POLYGON ? 'TOOL_POLYGON' : 'TOOL_POLYLINE'];
+ // Translators: %s is a key label
+ this.emit('show-osd', icon, _("Press %s to mark vertices")
+ .format(Meta.accelerator_name(0, Clutter.KEY_Return)), "", -1, true);
+ }
+ // Wayland supports two cursors so its important to disconnect motionhandler to avoid broken two cursors drawing
+ if (this.motionHandler) {
+ this.disconnect(this.motionHandler);
+ this.motionHandler = null;
+ }
+
+ // Laser Motion Handling
+
+ this.motionHandler = this.connect('motion-event', (actor, event) => {
+ let coords = event.get_coords();
+ let [s, x, y] = this._transformStagePoint(coords[0], coords[1]);
+ if (!s)
+ return;
+
+ // To avoid painting due to the wrong device (2 cursors wayland support)
+ //Modified for GNOME 46/47 support
+ if (clickedDevice != (event.get_device ? event.get_device() : null) && clickedDevice != event.get_source_device())
+ return Clutter.EVENT_PROPAGATE;
+
+ if (this.spaceKeyPressed)
+ return;
+
+ let controlPressed = event.has_control_modifier();
+ this._updateDrawing(x, y, controlPressed);
+
+ });
+
+ // End Laser Motion Handling
+ }
+
+ _updateDrawing(x, y, controlPressed) {
+ if (!this.currentElement)
+ return;
+
+ this.currentElement.updateDrawing(x, y, controlPressed);
+
+ if (this.currentElement.eraser)
+ this._redisplay();
+ else
+ this.foreLayer.queue_repaint();
+ this.updatePointerCursor(controlPressed);
+ }
+
+ _stopDrawing() {
+ if (this.motionHandler) {
+ this.disconnect(this.motionHandler);
+ this.motionHandler = null;
+ }
+ if (this.buttonReleasedHandler) {
+ this.disconnect(this.buttonReleasedHandler);
+ this.buttonReleasedHandler = null;
+ }
+
+ // skip when a polygon has not at least 3 points
+ if (this.currentElement && this.currentElement.shape == Shape.POLYGON && this.currentElement.points.length < 3)
+ this.currentElement = null;
+
+ if (this.currentElement)
+ this.currentElement.stopDrawing();
+
+ if (this.currentElement && this.currentElement.points.length >= 2) {
+ if (this.currentElement.shape == Shape.TEXT && !this.isWriting) {
+ this._startWriting();
+ return;
+ }
+
+ // For images, use original size instead of drag size
+ if (this.currentElement && this.currentElement.shape == Shape.IMAGE && this.currentElement.points.length >= 1) {
+ let pixbuf = this.currentElement.image.getPixbuf(this.currentElement.colored ? this.currentElement.color.toJSON() : null);
+ let [startX, startY] = this.currentElement.points[0];
+ // Place image at click point with original dimensions
+ this.currentElement.points[1] = [startX + pixbuf.get_width(), startY + pixbuf.get_height()];
+ this.currentElement.preserveAspectRatio = true;
+ }
+
+ this.elements.push(this.currentElement);
+ }
+
+ this.currentElement = null;
+ this._redisplay();
+ this.updatePointerCursor();
+ }
+
+ _startWriting() {
+ let [stageX, stageY] = this.get_transformed_position();
+ let [x, y] = [this.currentElement.x, this.currentElement.y];
+ this.currentElement.text = '';
+ this.currentElement.cursorPosition = 0;
+ // Translators: %s is a key label
+ this.emit('show-osd', this._extension.FILES.ICONS.TOOL_TEXT, _("Press %s\nto start a new line")
+ .format(Meta.accelerator_name(0, Clutter.KEY_Return)), "", -1, true);
+ this._updateTextCursorTimeout();
+ this.textHasCursor = true;
+ this._redisplay();
+
+ // Do not hide and do not set opacity to 0 because:
+ // 1. ibusCandidatePopup need a mapped text entry to init correctly its position.
+ // 2. 'cursor-changed' signal is no emitted if the text entry is not visible.
+ this.textEntry = new St.Entry({ opacity: 1, x: stageX + x, y: stageY + y });
+ this.insert_child_below(this.textEntry, null);
+ this.textEntry.grab_key_focus();
+ this.updatePointerCursor();
+
+ let ibusCandidatePopup = Main.layoutManager.uiGroup.get_children().find(child =>
+ child.has_style_class_name && child.has_style_class_name('candidate-popup-boxpointer'));
+ if (ibusCandidatePopup) {
+ this.ibusHandler = ibusCandidatePopup.connect('notify::visible', () => {
+ if (ibusCandidatePopup.visible) {
+ this.set_child_above_sibling(this.textEntry, null);
+ this.textEntry.opacity = 255;
+ }
+ });
+ this.textEntry.connect('destroy', () => ibusCandidatePopup.disconnect(this.ibusHandler));
+ }
+
+ this.textEntry.clutterText.set_single_line_mode(false);
+ this.textEntry.clutterText.set_activatable(false);
+
+ let showCursorOnPositionChanged = true;
+ this.textEntry.clutterText.connect('text-changed', clutterText => {
+ this.textEntry.y = stageY + y + (this.textEntry.clutterText.get_layout().get_line_count() - 1) * this.currentElement.height;
+ this.currentElement.text = clutterText.text;
+ showCursorOnPositionChanged = false;
+ this._redisplay();
+ });
+
+ this.textEntry.clutterText.connect('cursor-changed', clutterText => {
+ this.currentElement.cursorPosition = clutterText.cursorPosition;
+ this._updateTextCursorTimeout();
+ let cursorPosition = clutterText.cursorPosition == -1 ? clutterText.text.length : clutterText.cursorPosition;
+ this.textHasCursor = showCursorOnPositionChanged || GLib.unichar_isspace(clutterText.text.charAt(cursorPosition - 1));
+ showCursorOnPositionChanged = true;
+ this._redisplay();
+ });
+
+ this.textEntry.clutterText.connect('key-press-event', (clutterText, event) => {
+ if (event.get_key_symbol() == Clutter.KEY_Escape) {
+ this._stopWriting();
+ return Clutter.EVENT_STOP;
+ }
+
+ return Clutter.EVENT_PROPAGATE;
+ });
+ }
+
+ _stopWriting() {
+ if (this.currentElement.text.length > 0)
+ this.elements.push(this.currentElement);
+
+ this.currentElement = null;
+ this._stopTextCursorTimeout();
+
+ // Store textEntry reference before destroying
+ const textEntry = this.textEntry;
+ delete this.textEntry;
+
+ // Defer focus grab to avoid GNOME Shell 48.3/48.4 crash
+ // This ensures the text entry is fully destroyed before regaining focus
+ GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
+ // Version-compatible check: is_finalized() doesn't exist in all GNOME versions
+ // Check if widget still exists and hasn't been destroyed
+ try {
+ if (textEntry && textEntry.get_stage()) {
+ // Widget still has a stage, safe to destroy
+ textEntry.destroy();
+ }
+ } catch (e) {
+ // Widget already destroyed or finalized, ignore
+ }
+
+ // Only grab focus if the area is still reactive
+ if (this.reactive) {
+ this.grab_key_focus();
+ }
+
+ this.updatePointerCursor();
+ this._redisplay();
+
+ return GLib.SOURCE_REMOVE;
+ });
+ }
+
+ setPointerCursor(pointerCursorName) {
+ if (!this.currentPointerCursorName || this.currentPointerCursorName != pointerCursorName) {
+ this.currentPointerCursorName = pointerCursorName;
+ this.emit('pointer-cursor-changed', pointerCursorName);
+ }
+ }
+
+ //Modifying MOVE_OR_RESIZE_WINDOW, to MOVE, both now function. //check in future versions of GNOME.
+ updatePointerCursor(controlPressed) {
+ // Laser cursor handling
+
+ if (this.laserPointerActive) {
+ this.setPointerCursor('CROSSHAIR');
+ return;
+ }
+ // End laser cursor handling
+
+ if (this.currentTool == Manipulation.MIRROR && this.grabbedElementLocked)
+ this.setPointerCursor('CROSSHAIR');
+ else if (this.hasManipulationTool)
+ this.setPointerCursor(this.grabbedElement ? 'MOVE' : 'DEFAULT');
+ else if (this.currentElement && this.currentElement.shape == Shape.TEXT && this.isWriting)
+ this.setPointerCursor('TEXT');
+ else if (!this.currentElement)
+ this.setPointerCursor(this.currentTool == Shape.NONE ? 'POINTER' : 'CROSSHAIR');
+ else if (this.currentElement.shape != Shape.NONE && controlPressed)
+ this.setPointerCursor('MOVE');
+ }
+
+ initPointerCursor() {
+ this.currentPointerCursorName = null;
+ this.updatePointerCursor();
+ }
+
+ _stopTextCursorTimeout() {
+ if (this.textCursorTimeoutId) {
+ GLib.source_remove(this.textCursorTimeoutId);
+ this.textCursorTimeoutId = null;
+ }
+ this.textHasCursor = false;
+ }
+
+ _updateTextCursorTimeout() {
+ this._stopTextCursorTimeout();
+ this.textCursorTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, TEXT_CURSOR_TIME, () => {
+ this.textHasCursor = !this.textHasCursor;
+ this._redisplay();
+ return GLib.SOURCE_CONTINUE;
+ });
+ }
+
+ // A priori there is nothing to stop, except transformations, if there is no current element.
+ // 'force' argument is passed when leaving drawing mode to ensure all is clean, as a workaround for possible bugs.
+ _stopAll(force) {
+ // Stop laser if active
+ if (this.laserPointerActive) {
+ this.stopLaserPointer();
+ // Also switch away from laser tool so motion doesn't restart it
+ if (this.currentTool === Shape.LASER) {
+ this.currentTool = this.previousTool || Shape.NONE;
+ }
+ }
+ // End laser stop method mods
+
+ if (this.grabbedElement) {
+ this._stopTransforming();
+ this.grabbedElement = null;
+ this.grabbedElementLocked = null;
+ this.updatePointerCursor();
+ }
+
+ if (!this.currentElement && !force)
+ return;
+
+ if (this.isWriting)
+ this._stopWriting();
+
+ this._stopDrawing();
+ }
+
+ erase() {
+ this.deleteLastElement();
+ this.elements = [];
+ this.undoneElements = [];
+ this._redisplay();
+ }
+
+ deleteLastElement() {
+ this._stopAll();
+ this.elements.pop();
+
+ if (this.elements.length)
+ this.elements[this.elements.length - 1].resetUndoneTransformations();
+
+ this._redisplay();
+ }
+
+ undo() {
+ if (!this.elements.length)
+ return;
+
+ let success = this.elements[this.elements.length - 1].undoTransformation();
+ if (!success) {
+ this.undoneElements.push(this.elements.pop());
+ if (this.elements.length)
+ this.elements[this.elements.length - 1].resetUndoneTransformations();
+ }
+
+ this._redisplay();
+ }
+
+ redo() {
+ let success = false;
+
+ if (this.elements.length)
+ success = this.elements[this.elements.length - 1].redoTransformation();
+
+ if (!success && this.undoneElements.length > 0)
+ this.elements.push(this.undoneElements.pop());
+
+ this._redisplay();
+ }
+
+ smoothLastElement() {
+ if (this.elements.length > 0 && this.elements[this.elements.length - 1].shape == Shape.NONE) {
+ this.elements[this.elements.length - 1].smoothAll();
+ this._redisplay();
+ }
+ }
+
+ toggleBackground() {
+ this.hasBackground = !this.hasBackground;
+ let backgroundColor = this.hasBackground ? this.areaBackgroundColor : StaticColor.TRANSPARENT;
+
+ if (this.ease) {
+ this.remove_all_transitions();
+ this.ease({
+ backgroundColor,
+ duration: TOGGLE_ANIMATION_DURATION,
+ transition: Clutter.AnimationMode.EASE_IN_OUT_QUAD
+ });
+ } else {
+ this.set_background_color(backgroundColor);
+ }
+ }
+
+ get hasGrid() {
+ return this.gridLayer.visible;
+ }
+
+ toggleGrid() {
+ // The grid layer is repainted when the visibility changes.
+ if (this.gridLayer.ease) {
+ this.gridLayer.remove_all_transitions();
+ this.rulerLayer.remove_all_transitions();
+ let visible = !this.gridLayer.visible;
+
+ this.gridLayer.visible = true;
+ this.rulerLayer.visible = true;
+
+ this.gridLayer.ease({
+ opacity: visible ? 255 : 0,
+ duration: TOGGLE_ANIMATION_DURATION,
+ transition: Clutter.AnimationMode.EASE_IN_OUT_QUAD,
+ onStopped: () => this.gridLayer.visible = visible
+ });
+
+ this.rulerLayer.ease({
+ opacity: visible ? 255 : 0,
+ duration: TOGGLE_ANIMATION_DURATION,
+ transition: Clutter.AnimationMode.EASE_IN_OUT_QUAD,
+ onStopped: () => this.rulerLayer.visible = visible
+ });
+ } else {
+ this.gridLayer.visible = !this.gridLayer.visible;
+ this.rulerLayer.visible = !this.rulerLayer.visible;
+ }
+ }
+
+ toggleSquareArea() {
+ this.isSquareArea = !this.isSquareArea;
+ let x, y, width, height, onComplete;
+
+ if (this.isSquareArea) {
+ this.layerContainer.add_style_class_name('draw-on-gnome-square-area');
+ [x, y] = [(this.monitor.width - this.squareAreaSize) / 2, (this.monitor.height - this.squareAreaSize) / 2];
+ width = height = this.squareAreaSize;
+ onComplete = () => { };
+ } else {
+ x = y = 0;
+ [width, height] = [this.monitor.width, this.monitor.height];
+ onComplete = () => this.layerContainer.remove_style_class_name('draw-on-gnome-square-area');
+ }
+
+ if (this.layerContainer.ease) {
+ this.layerContainer.remove_all_transitions();
+ this.layerContainer.ease({
+ x, y, width, height, onComplete,
+ duration: TOGGLE_ANIMATION_DURATION,
+ transition: Clutter.AnimationMode.EASE_OUT_QUAD
+ });
+ } else {
+ this.layerContainer.set_position(x, y);
+ this.layerContainer.set_size(width, height);
+ onComplete();
+ }
+ }
+
+ selectColor(index) {
+ if (!this.colors[index])
+ return;
+
+ this.currentColorIndex = index; // Track which index is selected
+ this.currentColor = this.colors[index];
+ this._extension.drawingSettings.set_string("tool-color", this.colors[index].to_string());
+ if (this.currentElement) {
+ this.currentElement.color = this.currentColor;
+ this._redisplay();
+ }
+
+ // Use light background for Ctrl+9 (index 8) to make dark colors readable
+ let osdBackground = (index === 8) ? '#deddda' : this.currentColor.to_string().slice(0, 7);
+
+ // Foreground color markup is not displayed since 3.36, use style instead but the transparency is lost.
+ this.emit('show-osd', this._extension.FILES.ICONS.COLOR, String(this.currentColor), osdBackground, -1, false);
+ }
+
+ selectTool(tool) {
+ this.currentTool = tool;
+ this.emit('show-osd', this._extension.FILES.ICONS[`TOOL_${Tool.getNameOf(tool)}`] || null, DisplayStrings.Tool[tool], "", -1, false);
+ this.updatePointerCursor();
+ }
+
+ // Laser Control Methods
+ startLaserPointer(x, y) {
+ if (this.laserPointerActive)
+ return;
+
+ this.laserPointerActive = true;
+ this.laserPointerX = x;
+ this.laserPointerY = y;
+ this.laserTrailPoints = [[x, y]];
+
+ this.laserLayer.show();
+ this.laserLayer.ease({
+ opacity: 255,
+ duration: 100,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD
+ });
+
+ this._startLaserAnimation();
+ this.setPointerCursor('NONE');
+
+ if (!this._laserPointerShownOnce) {
+ this._laserPointerShownOnce = true;
+ this.emit('show-osd', this._extension.FILES.ICONS.TOOL_ARROW,
+ _("Laser Pointer Active"),
+ _("Release Shift to deactivate"), -1, true);
+ }
+ }
+
+ updateLaserPointer(x, y) {
+ if (!this.laserPointerActive)
+ return;
+
+ this.laserPointerX = x;
+ this.laserPointerY = y;
+
+ this.laserTrailPoints.push([x, y]);
+
+ if (this.laserTrailPoints.length > this.laserTrailMaxLength) {
+ this.laserTrailPoints.shift();
+ }
+
+ // Clear any existing timeout
+ if (this.laserTrailTimeoutId) {
+ GLib.source_remove(this.laserTrailTimeoutId);
+ this.laserTrailTimeoutId = null;
+ }
+
+ // Set new timeout to clear trail after 100ms of no movement
+ // Might need to lower this to 50 ms, need to test more...
+ this.laserTrailTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 100, () => {
+ if (this.laserPointerActive) {
+ // Fade out the trail by removing points
+ if (this.laserTrailPoints.length > 1) {
+ // Remove half the trail points for fade effect
+ let removeCount = Math.ceil(this.laserTrailPoints.length / 2);
+ this.laserTrailPoints.splice(0, removeCount);
+ return GLib.SOURCE_CONTINUE; // Keep running to fade more
+ } else {
+ // Clear all trail points
+ this.laserTrailPoints = [[this.laserPointerX, this.laserPointerY]];
+ }
+ }
+ this.laserTrailTimeoutId = null;
+ return GLib.SOURCE_REMOVE;
+ });
+ }
+
+ stopLaserPointer() {
+ if (!this.laserPointerActive)
+ return;
+
+ this.laserPointerActive = false;
+ this._stopLaserAnimation();
+
+ // Clean up trail timeout - ADD THESE LINES
+ if (this.laserTrailTimeoutId) {
+ GLib.source_remove(this.laserTrailTimeoutId);
+ this.laserTrailTimeoutId = null;
+ }
+
+ this.laserLayer.ease({
+ opacity: 0,
+ duration: 200,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ onComplete: () => {
+ this.laserLayer.hide();
+ this.laserTrailPoints = [];
+ }
+ });
+
+ this.updatePointerCursor();
+ }
+
+ _startLaserAnimation() {
+ if (this.laserAnimationTimeoutId)
+ return;
+
+ this.laserAnimationTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 16, () => {
+ if (this.laserPointerActive) {
+ this.laserLayer.queue_repaint();
+ return GLib.SOURCE_CONTINUE;
+ }
+ this.laserAnimationTimeoutId = null;
+ return GLib.SOURCE_REMOVE;
+ });
+ }
+
+ _stopLaserAnimation() {
+ if (this.laserAnimationTimeoutId) {
+ GLib.source_remove(this.laserAnimationTimeoutId);
+ this.laserAnimationTimeoutId = null;
+ }
+ }
+
+ // End Laser Control Methods
+
+ switchFill() {
+ this.fill = !this.fill;
+ let icon = this._extension.FILES.ICONS[this.fill ? 'FILL' : 'STROKE'];
+ this.emit('show-osd', icon, DisplayStrings.getFill(this.fill), "", -1, false);
+ }
+
+ switchFillRule() {
+ this.currentFillRule = this.currentFillRule == 1 ? 0 : this.currentFillRule + 1;
+ let icon = this._extension.FILES.ICONS[this.currentEvenodd ? 'FILLRULE_EVENODD' : 'FILLRULE_NONZERO'];
+ this.emit('show-osd', icon, DisplayStrings.FillRule[this.currentFillRule], "", -1, false);
+ }
+
+ switchColorPalette(reverse) {
+ // Find current palette by name (not reference) since palette may come from saved config
+ let currentPaletteName = this.currentPalette[0];
+ let index = this.palettes.findIndex(p => p[0] === currentPaletteName);
+
+ // If not found, default to first palette
+ if (index === -1) {
+ index = 0;
+ }
+
+ if (reverse)
+ this.currentPalette = index <= 0 ? this.palettes[this.palettes.length - 1] : this.palettes[index - 1];
+ else
+ this.currentPalette = index == this.palettes.length - 1 ? this.palettes[0] : this.palettes[index + 1];
+
+ // Preserve the color index when switching palettes
+ // If we had a color selected (e.g. Ctrl+1), select the same index in the new palette
+ if (this.currentColorIndex !== undefined && this.colors[this.currentColorIndex]) {
+ this.currentColor = this.colors[this.currentColorIndex];
+ this._extension.drawingSettings.set_string("tool-color", this.colors[this.currentColorIndex].to_string());
+ if (this.currentElement) {
+ this.currentElement.color = this.currentColor;
+ this._redisplay();
+ }
+ }
+
+ this.emit('show-osd', this._extension.FILES.ICONS.PALETTE, this.currentPalette[0], "", -1, false);
+ }
+
+ switchDash() {
+ this.dashedLine = !this.dashedLine;
+ let icon = this._extension.FILES.ICONS[this.dashedLine ? 'DASHED_LINE' : 'FULL_LINE'];
+ this.emit('show-osd', icon, DisplayStrings.getDashedLine(this.dashedLine), "", -1, false);
+ }
+
+ incrementLineWidth(increment) {
+ this.currentLineWidth = Math.max(this.currentLineWidth + increment, 1);
+ this.emit('show-osd', null, DisplayStrings.getPixels(this.currentLineWidth), "", 2 * this.currentLineWidth, false);
+ this._extension.drawingSettings.set_int("tool-size", this.currentLineWidth)
+ }
+
+ switchLineJoin() {
+ this.currentLineJoin = this.currentLineJoin == 2 ? 0 : this.currentLineJoin + 1;
+ this.emit('show-osd', this._extension.FILES.ICONS.LINEJOIN, DisplayStrings.LineJoin[this.currentLineJoin], "", -1, false);
+ }
+
+ switchLineCap() {
+ this.currentLineCap = this.currentLineCap == 2 ? 0 : this.currentLineCap + 1;
+ this.emit('show-osd', this._extension.FILES.ICONS.LINECAP, DisplayStrings.LineCap[this.currentLineCap], "", -1, false);
+ }
+
+ switchFontWeight() {
+ let fontWeights = Object.keys(DisplayStrings.FontWeight).map(key => Number(key));
+ let index = fontWeights.indexOf(this.currentFontWeight);
+ this.currentFontWeight = index == fontWeights.length - 1 ? fontWeights[0] : fontWeights[index + 1];
+ if (this.currentElement && this.currentElement.font) {
+ this.currentElement.font.set_weight(this.currentFontWeight);
+ this._redisplay();
+ }
+ this.emit('show-osd', this._extension.FILES.ICONS.FONT_WEIGHT, `` +
+ `${DisplayStrings.FontWeight[this.currentFontWeight]}`, "", -1, false);
+ }
+
+ switchFontStyle() {
+ this.currentFontStyle = this.currentFontStyle == 2 ? 0 : this.currentFontStyle + 1;
+ if (this.currentElement && this.currentElement.font) {
+ this.currentElement.font.set_style(this.currentFontStyle);
+ this._redisplay();
+ }
+ this.emit('show-osd', this._extension.FILES.ICONS.FONT_STYLE, `` +
+ `${DisplayStrings.FontStyle[this.currentFontStyle]}`, "", -1, false);
+ }
+
+ switchFontFamily(reverse) {
+ let index = Math.max(0, this.fontFamilies.indexOf(this.currentFontFamily));
+ if (reverse)
+ this.currentFontFamily = (index == 0) ? this.fontFamilies[this.fontFamilies.length - 1] : this.fontFamilies[index - 1];
+ else
+ this.currentFontFamily = (index == this.fontFamilies.length - 1) ? this.fontFamilies[0] : this.fontFamilies[index + 1];
+ if (this.currentElement && this.currentElement.font) {
+ this.currentElement.font.set_family(this.currentFontFamily);
+ this._redisplay();
+ }
+ this.emit('show-osd', this._extension.FILES.ICONS.FONT_FAMILY, `${DisplayStrings.getFontFamily(this.currentFontFamily)}`, "", -1, false);
+ }
+
+ switchTextAlignment() {
+ this.currentTextAlignment = this.currentTextAlignment == 2 ? 0 : this.currentTextAlignment + 1;
+ if (this.currentElement && this.currentElement.textAlignment != this.currentTextAlignment) {
+ this.currentElement.textAlignment = this.currentTextAlignment;
+ this._redisplay();
+ }
+ let icon = this._extension.FILES.ICONS[this.currentTextAlignment == TextAlignment.RIGHT ? 'RIGHT_ALIGNED' : this.currentTextAlignment == TextAlignment.CENTER ? 'CENTERED' : 'LEFT_ALIGNED'];
+ this.emit('show-osd', icon, DisplayStrings.TextAlignment[this.currentTextAlignment], "", -1, false);
+ }
+
+ switchImageFile(reverse) {
+ this.currentImage = this._extension.FILES.IMAGES[reverse ? 'getPrevious' : 'getNext'](this.currentImage);
+ if (this.currentImage)
+ this.emit('show-osd', this.currentImage.gicon, this.currentImage.toString(), "", -1, false);
+ }
+
+ pasteImageFiles() {
+ this._extension.FILES.IMAGES.addImagesFromClipboard(lastImage => {
+ this.currentImage = lastImage;
+ this.currentTool = Shape.IMAGE;
+ this.updatePointerCursor();
+ this.emit('show-osd', this.currentImage.gicon, this.currentImage.toString(), "", -1, false);
+ });
+ }
+
+ _onColorPicked(color) {
+ if (color instanceof Color)
+ color = color.to_string().slice(0, -2);
+
+ this.currentColor = this.getColorFromString(color);
+ this._extension.drawingSettings.set_string("tool-color", color);
+ if (this.currentElement) {
+ this.currentElement.color = this.currentColor;
+ this._redisplay();
+ }
+ this.emit('show-osd', this._extension.FILES.ICONS.COLOR, String(this.currentColor), this.currentColor.to_string().slice(0, 7), -1, false);
+ this.initPointerCursor();
+
+ if (this._extension.settings.get_boolean("copy-picked-hex")) {
+ St.Clipboard.get_default().set_text(St.ClipboardType.CLIPBOARD, color);
+ }
+ }
+
+ pickColor() {
+ if (!Screenshot.PickPixel)
+ // GS 3.28-
+ return;
+
+ // Translators: It is displayed in an OSD notification to ask the user to start picking, so it should use the imperative mood.
+ this.emit('show-osd', this._extension.FILES.ICONS.COLOR_PICKER, pgettext("osd-notification", "Pick a color"), "", -1, false);
+
+ let extension = Main.extensionManager && Main.extensionManager.lookup(COLOR_PICKER_EXTENSION_UUID);
+ if (extension && extension.state == ExtensionUtils.ExtensionState.ENABLED && extension.stateObj && extension.stateObj.pickAsync) {
+ extension.stateObj.pickAsync().then(result => {
+ if (typeof result == 'string')
+ this._onColorPicked(result);
+ else
+ this.initPointerCursor();
+ }).catch(e => {
+ this.initPointerCursor();
+ });
+
+ return;
+ }
+
+ try {
+ let screenshot = new Shell.Screenshot();
+ let pickPixel = new Screenshot.PickPixel(screenshot);
+
+ if (pickPixel.pickAsync) {
+ pickPixel.pickAsync().then(result => {
+ if (result instanceof Color) {
+ // GS 3.38+
+ this._onColorPicked(result);
+ } else {
+ // GS 3.36
+ let graphenePoint = result;
+ screenshot.pick_color(graphenePoint.x, graphenePoint.y, (o, res) => {
+ let [, color] = screenshot.pick_color_finish(res);
+ this._onColorPicked(color);
+ });
+ }
+ }).catch(() => this.initPointerCursor());
+ } else {
+ // GS 3.34-
+ pickPixel.show();
+ pickPixel.connect('finished', (pickPixel, coords) => {
+ if (coords)
+ screenshot.pick_color(...coords, (o, res) => {
+ let [, color] = screenshot.pick_color_finish(res);
+ this._onColorPicked(color);
+ });
+ else
+ this.initPointerCursor();
+ });
+ }
+ } catch (e) {
+ console.error(`${this._extension.metadata.uuid}: color picker failed: ${e.message}`);
+ this.initPointerCursor();
+ }
+ }
+
+ toggleHelp() {
+ if (this.helper.visible) {
+ this.helper.hideHelp();
+ if (this.textEntry)
+ this.textEntry.grab_key_focus();
+ } else {
+ this.helper.showHelp();
+ this.grab_key_focus();
+ }
+ }
+
+ // The area is reactive when it is modal.
+ _onReactiveChanged() {
+ if (this.hasGrid)
+ this._redisplay();
+ if (this.helper.visible)
+ this.toggleHelp();
+ if (this.textEntry && this.reactive)
+ this.textEntry.grab_key_focus();
+
+ if (this.reactive) {
+ this.stageKeyPressedHandler = global.stage.connect('key-press-event', this._onStageKeyPressed.bind(this));
+ this.stageKeyReleasedHandler = global.stage.connect('key-release-event', this._onStageKeyReleased.bind(this));
+ } else {
+ if (this.stageKeyPressedHandler) {
+ global.stage.disconnect(this.stageKeyPressedHandler);
+ this.stageKeyPressedHandler = null;
+ }
+ if (this.stageKeyReleasedHandler) {
+ global.stage.disconnect(this.stageKeyReleasedHandler);
+ this.stageKeyReleasedHandler = null;
+ }
+ this.spaceKeyPressed = false;
+ this.laserKeyPressed = false;
+ }
+ }
+
+ // New Laser Method
+ _onLaserMotion(actor, event) {
+ // Update ruler mouse position tracking
+ let coords = event.get_coords();
+ let [success, x, y] = this._transformStagePoint(coords[0], coords[1]);
+
+ if (success && this.hasGrid && this.rulerLayer.visible) {
+ this.rulerMouseX = x;
+ this.rulerMouseY = y;
+ this.rulerLayer.queue_repaint();
+ }
+
+ if (this.currentTool == Shape.LASER) {
+ if (success) {
+ if (!this.laserPointerActive) {
+ this.startLaserPointer(x, y);
+ } else {
+ this.updateLaserPointer(x, y);
+ }
+ return Clutter.EVENT_STOP;
+ }
+ }
+
+ return Clutter.EVENT_PROPAGATE;
+ }
+
+
+
+ destroy() {
+ this.textCursorTimeoutId = null;
+ this._stopAll(true);
+
+ // Clean up laser pointer
+ if (this.laserAnimationTimeoutId) {
+ GLib.source_remove(this.laserAnimationTimeoutId);
+ this.laserAnimationTimeoutId = null;
+ }
+ if (this.laserTrailTimeoutId) {
+ GLib.source_remove(this.laserTrailTimeoutId);
+ this.laserTrailTimeoutId = null;
+ }
+ this.laserLayer = null;
+
+ // Clean up rulers
+ this.rulerLayer = null;
+ // End laser pointer cleanup
+
+ this._extension.drawingSettings.disconnect(this.drawingSettingsChangedHandler);
+ this.erase();
+ if (this._menu)
+ this._menu.disable();
+ delete this.areaManagerUtils;
+
+ super.destroy();
+ }
+
+ enterDrawingMode() {
+ this.keyPressedHandler = this.connect('key-press-event', this._onKeyPressed.bind(this));
+ this.buttonPressedHandler = this.connect('button-press-event', this._onButtonPressed.bind(this));
+ this.keyboardPopupMenuHandler = this.connect('popup-menu', this._onKeyboardPopupMenu.bind(this));
+ this.scrollHandler = this.connect('scroll-event', this._onScroll.bind(this));
+
+ // Add dedicated motion handler for laser pointer
+ this.laserMotionHandler = this.connect('motion-event', this._onLaserMotion.bind(this));
+
+ this.set_background_color(this.reactive && this.hasBackground ? this.areaBackgroundColor : null);
+ }
+
+ leaveDrawingMode(save, erase) {
+ if (this.keyPressedHandler) {
+ this.disconnect(this.keyPressedHandler);
+ this.keyPressedHandler = null;
+ }
+ if (this.buttonPressedHandler) {
+ this.disconnect(this.buttonPressedHandler);
+ this.buttonPressedHandler = null;
+ }
+ if (this.keyboardPopupMenuHandler) {
+ this.disconnect(this.keyboardPopupMenuHandler);
+ this.keyboardPopupMenuHandler = null;
+ }
+ if (this.scrollHandler) {
+ this.disconnect(this.scrollHandler);
+ this.scrollHandler = null;
+ }
+ // More laser motion handling
+ if (this.laserMotionHandler) {
+ this.disconnect(this.laserMotionHandler);
+ this.laserMotionHandler = null;
+ }
+ // Clean up laser pointer
+ if (this.laserPointerActive) {
+ this.stopLaserPointer();
+ }
+ if (this.laserAnimationTimeoutId) {
+ GLib.source_remove(this.laserAnimationTimeoutId);
+ this.laserAnimationTimeoutId = null;
+ }
+
+ this._stopAll(true);
+
+ if (erase)
+ this.erase();
+
+ this.closeMenu();
+ this.set_background_color(null);
+ this._extension.FILES.IMAGES.reset();
+ if (save)
+ this.savePersistent();
+ }
+
+ // Used by the menu.
+ getSvgContentsForJson(json) {
+ let elements = [];
+ let elementsContent = '';
+
+ elements.push(...JSON.parse(json.contents).map(object => {
+ if (object.color)
+ object.color = this.getColorFromString(object.color, 'White');
+ if (object.font && typeof object.font == 'string')
+ object.font = Pango.FontDescription.from_string(object.font);
+ if (object.image)
+ object.image = new Image(object.image);
+ return new Elements.DrawingElement(object);
+ }));
+ elements.forEach(element => elementsContent += element.buildSVG('transparent'));
+
+ let prefixes = 'xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"';
+
+ let getGiconSvgContent = () => {
+ let size = Math.min(this.monitor.width, this.monitor.height);
+ let [x, y] = [(this.monitor.width - size) / 2, (this.monitor.height - size) / 2];
+ return ``;
+ };
+
+ let getImageSvgContent = () => {
+ return ``;
+ };
+
+ return [getGiconSvgContent, getImageSvgContent];
+ }
+
+ exportToSvg() {
+ this._stopAll();
+
+ let prefixes = 'xmlns="http://www.w3.org/2000/svg"';
+ if (this.elements.some(element => element.shape == Shape.IMAGE))
+ prefixes += ' xmlns:xlink="http://www.w3.org/1999/xlink"';
+ let content = `";
+
+ if (this._extension.FILES.saveSvg(content)) {
+ let flashspot = new Screenshot.Flashspot(this);
+ flashspot.fire();
+ if (global.play_theme_sound) {
+ global.play_theme_sound(0, 'screen-capture', "Save as SVG", null);
+ } else if (global.display && global.display.get_sound_player) {
+ let player = global.display.get_sound_player();
+ player.play_from_theme('screen-capture', "Save as SVG", null);
+ }
+ }
+ }
+
+ _saveAsJson(json, notify, callback) {
+ this._stopAll();
+
+ // do not use "content = JSON.stringify(this.elements, null, 2);", neither "content = JSON.stringify(this.elements);"
+ // do compromise between disk usage and human readability
+ let contents = this.elements.length ? `[\n ` + new Array(...this.elements.map(element => JSON.stringify(element))).join(`,\n\n `) + `\n]` : '[]';
+
+ GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
+ json.contents = contents;
+ if (notify)
+ this.emit('show-osd', this._extension.FILES.ICONS.SAVE, json.name, "", -1, false);
+ if (!json.isPersistent)
+ this.currentJson = json;
+ if (callback)
+ callback();
+ });
+ }
+
+ saveAsJsonWithName(name, callback) {
+ this._saveAsJson(this._extension.FILES.JSONS.getNamed(name), false, callback);
+ }
+
+ saveAsJson(notify, callback) {
+ this._saveAsJson(this._extension.FILES.JSONS.getDated(), notify, callback);
+ }
+
+ savePersistent() {
+ this._saveAsJson(this._extension.FILES.JSONS.getPersistent());
+ }
+
+ syncPersistent() {
+ // do not override peristent.json with an empty drawing when changing persistency setting
+ if (!this.elements.length)
+ this._loadPersistent();
+ else
+ this.savePersistent();
+
+ }
+
+ _loadJson(json, notify) {
+ this._stopAll();
+
+ this.elements = [];
+ this.currentElement = null;
+
+ if (!json.contents)
+ return;
+
+ this.elements.push(...JSON.parse(json.contents).map(object => {
+ if (object.color)
+ object.color = this.getColorFromString(object.color, 'White');
+ if (object.font && typeof object.font == 'string')
+ object.font = Pango.FontDescription.from_string(object.font);
+ if (object.image)
+ object.image = new Image(object.image);
+ return new Elements.DrawingElement(object);
+ }));
+
+ if (notify)
+ this.emit('show-osd', this._extension.FILES.ICONS.OPEN, json.name, "", -1, false);
+ if (!json.isPersistent)
+ this.currentJson = json;
+ }
+
+ _loadPersistent() {
+ this._loadJson(this._extension.FILES.JSONS.getPersistent());
+ }
+
+ loadJson(json, notify) {
+ this._loadJson(json, notify);
+ this._redisplay();
+ }
+
+ loadPreviousJson() {
+ let json = this._extension.FILES.JSONS.getPrevious(this.currentJson || null);
+ if (json)
+ this.loadJson(json, true);
+ }
+
+ loadNextJson() {
+ let json = this._extension.FILES.JSONS.getNext(this.currentJson || null);
+ if (json)
+ this.loadJson(json, true);
+ }
+
+ get drawingContentsHasChanged() {
+ let contents = `[\n ` + new Array(...this.elements.map(element => JSON.stringify(element))).join(`,\n\n `) + `\n]`;
+ return contents != (this.currentJson && this.currentJson.contents);
+ }
+
+ // toJSON provides a string suitable for SVG color attribute whereas
+ // toString provides a string suitable for displaying the color name to the user.
+ getColorFromString(string, fallback) {
+ // GNOME 49+ fix: Handle if already a Color object
+ if (string && typeof string === 'object' && string.red !== undefined) {
+ // GNOME 48.5 SVG export fix: Ensure toJSON method exists
+ if (!string.toJSON || typeof string.toJSON !== 'function') {
+ let colorStr;
+ if (string.to_string && typeof string.to_string === 'function') {
+ // KEEP THE ALPHA - Don't slice it off!
+ colorStr = string.to_string(); // Preserves alpha channel
+ } else {
+ // Include alpha in RGB format
+ colorStr = `rgba(${string.red},${string.green},${string.blue},${string.alpha})`;
+ }
+ string.toJSON = () => colorStr;
+ string.toString = () => colorStr;
+ }
+ return string;
+ }
+
+ // Handle null/undefined/non-string
+ if (!string || typeof string !== 'string') {
+ let color = StaticColor[(fallback || 'White').toUpperCase()];
+ if (!color) color = StaticColor.WHITE;
+ color.toJSON = () => fallback || 'White';
+ color.toString = () => fallback || 'White';
+ return color;
+ }
+
+ // Original string handling - Now supports rgba() format with alpha
+ let [colorString, displayName] = string.split(':');
+ let [success, color] = Color.from_string(colorString);
+
+ if (success) {
+ color.toJSON = () => colorString;
+ color.toString = () => displayName || colorString;
+ return color;
+ }
+
+ console.warn(`${this._extension.metadata.uuid}: "${string}" color cannot be parsed.`);
+ color = StaticColor[fallback.toUpperCase()];
+ color.toJSON = () => fallback;
+ color.toString = () => fallback;
+ return color;
+ }
+});
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/areamanager.js b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/areamanager.js
new file mode 100644
index 0000000..1a0ba89
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/areamanager.js
@@ -0,0 +1,600 @@
+/*
+ * Copyright 2019 Abakkk
+ * Copyright 2024 Dave Prowse
+ * 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 .
+ *
+ * SPDX-FileCopyrightText: 2019 Abakkk
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileContributor: Modified by Dave Prowse
+ */
+
+/* jslint esversion: 6 (2019) */
+/* eslint version: 9.16 (2024) */
+/* exported init */
+
+import Meta from 'gi://Meta';
+import Shell from 'gi://Shell';
+import St from 'gi://St';
+import Clutter from 'gi://Clutter';
+
+import * as Main from 'resource:///org/gnome/shell/ui/main.js';
+import * as OsdWindow from 'resource:///org/gnome/shell/ui/osdWindow.js';
+import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
+
+import {gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
+
+import * as Area from './area.js';
+import * as Helper from './helper.js';
+
+import { SHELL_MAJOR_VERSION } from './utils.js';
+
+// AreaManager assigns one DrawingArea per monitor (updateAreas()),
+// distributes keybinding callbacks to the active area
+// and handles stylesheet and monitor changes.
+export class AreaManager {
+
+ constructor(extension) {
+ this._extension = extension;
+
+ // Store references to settings instances from extension
+ this._settings = extension.settings;
+ this._internalShortcutSettings = extension.internalShortcutSettings;
+ this._drawingSettings = extension.drawingSettings;
+
+ this._SHELL_MAJOR_VERSION = SHELL_MAJOR_VERSION;
+ this._HIDE_TIMEOUT_LONG = 2500;
+
+ this._DRAWING_ACTION_MODE = Math.pow(2,14);
+ this._WRITING_ACTION_MODE = Math.pow(2,15);
+ this._WARNING_COLOR_STYLE_CLASS_NAME = 'login-dialog-message-warning';
+}
+
+ enable() {
+ this.areas = [];
+ this.activeArea = null;
+ this.grab = null;
+
+ Main.wm.addKeybinding('toggle-drawing',
+ this._settings,
+ Meta.KeyBindingFlags.NONE,
+ Shell.ActionMode.ALL,
+ this.toggleDrawing.bind(this));
+
+ Main.wm.addKeybinding('toggle-modal',
+ this._settings,
+ Meta.KeyBindingFlags.NONE,
+ Shell.ActionMode.ALL,
+ this.toggleModal.bind(this));
+
+ Main.wm.addKeybinding('erase-drawings',
+ this._settings,
+ Meta.KeyBindingFlags.NONE,
+ Shell.ActionMode.ALL,
+ this.eraseDrawings.bind(this));
+
+ this.updateAreas();
+ this.monitorChangedHandler = Main.layoutManager.connect('monitors-changed', this.updateAreas.bind(this));
+
+ this.updateIndicator();
+ this.indicatorSettingHandler = this._settings.connect('changed::indicator-disabled', this.updateIndicator.bind(this));
+
+ this.desktopSettingHandler = this._settings.connect('changed::drawing-on-desktop', this.onDesktopSettingChanged.bind(this));
+ this.persistentOverRestartsSettingHandler = this._settings.connect('changed::persistent-over-restarts', this.onPersistentOverRestartsSettingChanged.bind(this));
+ this.persistentOverTogglesSettingHandler = this._settings.connect('changed::persistent-over-toggles', this.onPersistentOverTogglesSettingChanged.bind(this));
+ }
+
+ get persistentOverToggles() {
+ return this._settings.get_boolean('persistent-over-toggles');
+ }
+
+ get persistentOverRestarts() {
+ return this._settings.get_boolean('persistent-over-toggles') && this._settings.get_boolean('persistent-over-restarts');
+ }
+
+ get onDesktop() {
+ return this._settings.get_boolean('persistent-over-toggles') && this._settings.get_boolean('drawing-on-desktop');
+ }
+
+ get toolPalette() {
+ return this._extension.getSettings(this._extension.metadata['settings-schema'] + '.drawing').get_value('tool-palette').deep_unpack()
+ }
+
+ get toolColor() {
+ return this._extension.getSettings(this._extension.metadata['settings-schema'] + '.drawing').get_string("tool-color")
+ }
+
+ get toolSize() {
+ return this._extension.getSettings(this._extension.metadata['settings-schema'] + '.drawing').get_int('tool-size');
+ }
+
+ onDesktopSettingChanged() {
+ if (this.onDesktop)
+ this.areas.forEach(area => area.show());
+ else
+ this.areas.forEach(area => area.hide());
+ }
+
+ onPersistentOverRestartsSettingChanged() {
+ if (this.persistentOverRestarts)
+ this.areas[Main.layoutManager.primaryIndex].syncPersistent();
+ }
+
+ onPersistentOverTogglesSettingChanged() {
+ if (!this.persistentOverToggles && !this.activeArea)
+ this.eraseDrawings();
+
+ this.onPersistentOverRestartsSettingChanged();
+ this.onDesktopSettingChanged();
+ }
+
+ updateIndicator() {
+ if (this.indicator) {
+ this.indicator.disable();
+ this.indicator = null;
+ }
+ if (!this._settings.get_boolean('indicator-disabled')) {
+ this.indicator = new DrawingIndicator();
+ this.indicator.enable();
+ }
+ }
+
+ updateAreas() {
+ if (this.activeArea)
+ this.toggleDrawing();
+ this.removeAreas();
+
+ this.monitors = Main.layoutManager.monitors;
+
+ let toolConf = {
+ "toolPalette" : this.toolPalette,
+ "toolColor" : this.toolColor,
+ "toolSize" : this.toolSize
+ };
+
+ for (let i = 0; i < this.monitors.length; i++) {
+ let monitor = this.monitors[i];
+ let helper = new Helper.DrawingHelper(this._extension, { name: 'drawOnGnomeHelper' + i }, monitor);
+ let loadPersistent = i == Main.layoutManager.primaryIndex && this.persistentOverRestarts;
+ // Some utils for the drawing area menus.
+ let areaManagerUtils = {
+ getHiddenList: () => this.hiddenList || null,
+ togglePanelAndDockOpacity: this.togglePanelAndDockOpacity.bind(this),
+ openPreferences: this.openPreferences.bind(this)
+ };
+ let area = new Area.DrawingArea(this._extension, { name: 'drawOnGnomeArea' + i }, monitor, helper, areaManagerUtils, loadPersistent, toolConf);
+
+ Main.layoutManager._backgroundGroup.insert_child_above(area, Main.layoutManager._bgManagers[i].backgroundActor);
+ if (!this.onDesktop)
+ area.hide();
+
+ area.set_position(monitor.x, monitor.y);
+ area.set_size(monitor.width, monitor.height);
+ area.leaveDrawingHandler = area.connect('leave-drawing-mode', this.toggleDrawing.bind(this));
+ area.pointerCursorChangedHandler = area.connect('pointer-cursor-changed', this.setCursor.bind(this));
+ area.showOsdHandler = area.connect('show-osd', this.showOsd.bind(this));
+ this.areas.push(area);
+ }
+ }
+
+ addInternalKeybindings() {
+ // unavailable when writing
+ this.internalKeybindings1 = {
+ 'undo': this.activeArea.undo.bind(this.activeArea),
+ 'redo': this.activeArea.redo.bind(this.activeArea),
+ 'delete-last-element': this.activeArea.deleteLastElement.bind(this.activeArea),
+ 'smooth-last-element': this.activeArea.smoothLastElement.bind(this.activeArea),
+ 'increment-line-width': () => this.activeArea.incrementLineWidth(1),
+ 'decrement-line-width': () => this.activeArea.incrementLineWidth(-1),
+ 'increment-line-width-more': () => this.activeArea.incrementLineWidth(5),
+ 'decrement-line-width-more': () => this.activeArea.incrementLineWidth(-5),
+ 'paste-image-files': this.activeArea.pasteImageFiles.bind(this.activeArea),
+ 'switch-linejoin': this.activeArea.switchLineJoin.bind(this.activeArea),
+ 'switch-linecap': this.activeArea.switchLineCap.bind(this.activeArea),
+ // Removed 'switch-fill-rule' - moved to internalKeybindings2 - intermittent issue of fill rule shortcut
+ 'switch-dash' : this.activeArea.switchDash.bind(this.activeArea),
+ 'switch-fill' : this.activeArea.switchFill.bind(this.activeArea),
+ 'switch-image-file' : this.activeArea.switchImageFile.bind(this.activeArea, false),
+ 'switch-image-file-reverse' : this.activeArea.switchImageFile.bind(this.activeArea, true),
+ 'select-none-shape': () => this.activeArea.selectTool(Area.Tool.NONE),
+ 'select-line-shape': () => this.activeArea.selectTool(Area.Tool.LINE),
+ 'select-arrow-shape': () => this.activeArea.selectTool(Area.Tool.ARROW),
+ 'select-laser-shape': () => {
+ if (this.activeArea.currentTool === Area.Tool.LASER) {
+ this.activeArea.stopLaserPointer();
+ this.activeArea.selectTool(Area.Tool.NONE); // Always go to pencil
+ } else {
+ this.activeArea.selectTool(Area.Tool.LASER);
+ }
+ },
+ 'select-highlighter-shape': () => this.activeArea.selectTool(Area.Tool.HIGHLIGHTER),
+ 'select-ellipse-shape': () => this.activeArea.selectTool(Area.Tool.ELLIPSE),
+ 'select-rectangle-shape': () => this.activeArea.selectTool(Area.Tool.RECTANGLE),
+ 'select-text-shape': () => this.activeArea.selectTool(Area.Tool.TEXT),
+ 'select-image-shape': () => this.activeArea.selectTool(Area.Tool.IMAGE),
+ 'select-polygon-shape': () => this.activeArea.selectTool(Area.Tool.POLYGON),
+ 'select-polyline-shape': () => this.activeArea.selectTool(Area.Tool.POLYLINE),
+ 'select-move-tool': () => this.activeArea.selectTool(Area.Tool.MOVE),
+ 'select-resize-tool': () => this.activeArea.selectTool(Area.Tool.RESIZE),
+ 'select-mirror-tool': () => this.activeArea.selectTool(Area.Tool.MIRROR)
+ };
+
+ // available when writing
+ this.internalKeybindings2 = {
+ 'export-to-svg': this.activeArea.exportToSvg.bind(this.activeArea),
+ 'save-as-json': this.activeArea.saveAsJson.bind(this.activeArea, true, null),
+ 'open-previous-json': this.activeArea.loadPreviousJson.bind(this.activeArea),
+ 'open-next-json': this.activeArea.loadNextJson.bind(this.activeArea),
+ 'pick-color': this.activeArea.pickColor.bind(this.activeArea),
+ 'toggle-background': this.activeArea.toggleBackground.bind(this.activeArea),
+ 'toggle-grid': this.activeArea.toggleGrid.bind(this.activeArea),
+ 'toggle-square-area': this.activeArea.toggleSquareArea.bind(this.activeArea),
+ 'switch-color-palette': this.activeArea.switchColorPalette.bind(this.activeArea, false),
+ 'switch-color-palette-reverse': this.activeArea.switchColorPalette.bind(this.activeArea, true),
+ 'switch-font-family': this.activeArea.switchFontFamily.bind(this.activeArea, false),
+ 'switch-font-family-reverse': this.activeArea.switchFontFamily.bind(this.activeArea, true),
+ 'switch-font-weight': this.activeArea.switchFontWeight.bind(this.activeArea),
+ 'switch-font-style': this.activeArea.switchFontStyle.bind(this.activeArea),
+ 'switch-text-alignment': this.activeArea.switchTextAlignment.bind(this.activeArea),
+ 'toggle-panel-and-dock-visibility': this.togglePanelAndDockOpacity.bind(this),
+ 'toggle-help': this.activeArea.toggleHelp.bind(this.activeArea),
+ 'open-preferences': this.openPreferences.bind(this)
+ };
+
+ for (let key in this.internalKeybindings1) {
+ Main.wm.addKeybinding(key,
+ this._extension.getSettings(this._extension.metadata['settings-schema'] + '.internal-shortcuts'),
+ Meta.KeyBindingFlags.NONE,
+ this._DRAWING_ACTION_MODE,
+ this.internalKeybindings1[key]);
+ }
+
+ for (let key in this.internalKeybindings2) {
+ Main.wm.addKeybinding(key,
+ this._extension.getSettings(this._extension.metadata['settings-schema'] + '.internal-shortcuts'),
+ Meta.KeyBindingFlags.NONE,
+ this._DRAWING_ACTION_MODE | this._WRITING_ACTION_MODE,
+ this.internalKeybindings2[key]);
+ }
+
+ for (let i = 1; i < 10; i++) {
+ let iCaptured = i;
+ Main.wm.addKeybinding('select-color' + i,
+ this._extension.getSettings(this._extension.metadata['settings-schema'] + '.internal-shortcuts'),
+ Meta.KeyBindingFlags.NONE,
+ this._DRAWING_ACTION_MODE | this._WRITING_ACTION_MODE,
+ this.activeArea.selectColor.bind(this.activeArea, iCaptured - 1));
+ }
+ }
+
+ removeInternalKeybindings() {
+ for (let key in this.internalKeybindings1)
+ Main.wm.removeKeybinding(key);
+
+ for (let key in this.internalKeybindings2)
+ Main.wm.removeKeybinding(key);
+
+ for (let i = 1; i < 10; i++)
+ Main.wm.removeKeybinding('select-color' + i);
+ }
+
+ openPreferences() {
+ if (this.activeArea)
+ this.toggleDrawing();
+ this._extension.openPreferences();
+ }
+
+ eraseDrawings() {
+ this.areas.forEach(area => area.erase());
+ if (this.persistentOverRestarts)
+ this.areas[Main.layoutManager.primaryIndex].savePersistent();
+ }
+
+ togglePanelAndDockOpacity() {
+ if (this.hiddenList) {
+ this.hiddenList.forEach(item => item.actor.set_opacity(item.oldOpacity));
+ this.hiddenList = null;
+ } else {
+ let activeIndex = this.areas.indexOf(this.activeArea);
+
+ // dash-to-dock - disabled (user doesn't want dash hidden)
+ let dtdContainers = [];
+ // OLD CODE (kept as comment for reference):
+ // let dtdContainers = Main.uiGroup.get_children().filter((actor) => {
+ // return actor.name && actor.name == 'dashtodockContainer' &&
+ // ((actor._delegate && actor._delegate._monitorIndex !== undefined &&
+ // actor._delegate._monitorIndex == activeIndex) ||
+ // (actor._monitorIndex !== undefined &&
+ // actor._monitorIndex == activeIndex));
+ // });
+
+ // for simplicity, we assume that main dash-to-panel panel is displayed on primary monitor
+ // and we hide all secondary panels together if the active area is not on the primary
+ let name = activeIndex == Main.layoutManager.primaryIndex ? 'panelBox' : 'dashtopanelSecondaryPanelBox';
+ let panelBoxes = Main.uiGroup.get_children().filter((actor) => {
+ return actor.name && actor.name == name ||
+ // dtp v37+
+ actor.get_children().length && actor.get_children()[0].name && actor.get_children()[0].name == name;
+ });
+
+ let actorToHide = dtdContainers.concat(panelBoxes);
+ this.hiddenList = [];
+ actorToHide.forEach(actor => {
+ this.hiddenList.push({ actor: actor, oldOpacity: actor.get_opacity() });
+ actor.set_opacity(0);
+ });
+ }
+ }
+
+ toggleArea() {
+ if (!this.activeArea)
+ return;
+
+ let activeIndex = this.areas.indexOf(this.activeArea);
+
+ if (this.activeArea.get_parent() == Main.uiGroup) {
+ Main.uiGroup.set_child_at_index(Main.layoutManager.keyboardBox, this.oldKeyboardIndex);
+ Main.uiGroup.remove_child(this.activeArea);
+ Main.layoutManager._backgroundGroup.insert_child_above(this.activeArea, Main.layoutManager._bgManagers[activeIndex].backgroundActor);
+ if (!this.onDesktop)
+ this.activeArea.hide();
+ } else {
+ Main.layoutManager._backgroundGroup.remove_child(this.activeArea);
+ Main.uiGroup.add_child(this.activeArea);
+ // move the keyboard above the area to make it available with text entries
+ this.oldKeyboardIndex = Main.uiGroup.get_children().indexOf(Main.layoutManager.keyboardBox);
+ Main.uiGroup.set_child_above_sibling(Main.layoutManager.keyboardBox, this.activeArea);
+ }
+ }
+
+ toggleModal(source) {
+ if (!this.activeArea)
+ return;
+
+ this.activeArea.closeMenu();
+ if (this._findModal(this.grab) != -1) {
+ Main.popModal(this.grab);
+ if (source && source == global.display)
+ this.showOsd(null, this._extension.FILES.ICONS.UNGRAB, _("Keyboard and pointer released"), null, null, false);
+ // Translators: "released" as the opposite of "grabbed"
+
+
+ this.setCursor(null, 'DEFAULT');
+ this.activeArea.reactive = false;
+ this.removeInternalKeybindings();
+
+ } else {
+ // add Shell.ActionMode.NORMAL to keep system keybindings enabled (e.g. Alt + F2 ...)
+ let actionMode = (this.activeArea.isWriting ? this._WRITING_ACTION_MODE : this._DRAWING_ACTION_MODE) | Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW;
+ this.grab = Main.pushModal(this.activeArea, { actionMode: actionMode });
+ if (this.grab.get_seat_state() === Clutter.GrabState.NONE) {
+ Main.popModal(this.grab);
+ return false;
+ }
+ this.addInternalKeybindings();
+ this.activeArea.reactive = true;
+ this.activeArea.initPointerCursor();
+ if (source && source == global.display)
+ this.showOsd(null, this._extension.FILES.ICONS.GRAB, _("Keyboard and pointer grabbed"), null, null, false);
+ }
+
+ return true;
+ }
+
+ toggleDrawing() {
+ if (this.activeArea) {
+ let activeIndex = this.areas.indexOf(this.activeArea);
+ let save = activeIndex == Main.layoutManager.primaryIndex && this.persistentOverRestarts;
+ let erase = !this.persistentOverToggles;
+
+ this.showOsd(null, this._extension.FILES.ICONS.LEAVE, _("Leaving drawing mode"));
+ this.activeArea.leaveDrawingMode(save, erase);
+
+ if (this.hiddenList)
+ this.togglePanelAndDockOpacity();
+
+ if (this._findModal(this.grab) != -1)
+ this.toggleModal();
+
+ this.toggleArea();
+ this.activeArea = null;
+ } else {
+ // avoid to deal with Meta changes (global.display/global.screen)
+ let currentIndex = Main.layoutManager.monitors.indexOf(Main.layoutManager.currentMonitor);
+ this.activeArea = this.areas[currentIndex];
+ this.toggleArea();
+ if (!this.toggleModal()) {
+ this.toggleArea();
+ this.activeArea = null;
+ return;
+ }
+
+ this.activeArea.enterDrawingMode();
+ this.osdDisabled = this._settings.get_boolean('osd-disabled');
+ // is a clutter/mutter 3.38 bug workaround: https://gitlab.gnome.org/GNOME/mutter/-/issues/1467
+ // Translators: %s is a key label
+ let label = `${_("Press Ctrl+F1 for help").format(this.activeArea.helper.helpKeyLabel)}\n\n${_("Entering drawing mode")}`;
+ this.showOsd(null, this._extension.FILES.ICONS.ENTER, label, null, null, true);
+ }
+
+ if (this.indicator)
+ this.indicator.sync(Boolean(this.activeArea));
+ }
+
+ // Use level -1 to set no level through a signal.
+ showOsd(emitter, icon, label, color, level, long) {
+ let activeIndex = this.areas.indexOf(this.activeArea);
+ if (activeIndex == -1 || this.osdDisabled)
+ return;
+
+ // let hideTimeoutSave;
+ // if (long && this._GS_VERSION >= '3.28.0') {
+ // hideTimeoutSave = OsdWindow.HIDE_TIMEOUT;
+ // OsdWindow.HIDE_TIMEOUT = this._HIDE_TIMEOUT_LONG;
+ // }
+
+ let maxLevel;
+ if (level == -1)
+ level = null;
+ else if (level > 100)
+ maxLevel = 2;
+
+ // GS 3.32- : bar from 0 to 100
+ // GS 3.34+ : bar from 0 to 1
+ if (level && this._SHELL_MAJOR_VERSION >= 3)
+ level = level / 100;
+
+ if (!icon)
+ icon = this._extension.FILES.ICONS.ENTER;
+
+ if (this._SHELL_MAJOR_VERSION >= 49)
+ Main.osdWindowManager.showOne(activeIndex, icon, label, level, maxLevel);
+ else
+ Main.osdWindowManager.show(activeIndex, icon, label, level, maxLevel);
+
+ let osdWindow = Main.osdWindowManager._osdWindows[activeIndex];
+
+ osdWindow._label.get_clutter_text().set_use_markup(true);
+
+ if (color) {
+ osdWindow._icon.set_style(`color:${color};`);
+ osdWindow._label.set_style(`color:${color};`);
+ let osdColorChangedHandler = osdWindow._label.connect('notify::text', () => {
+ osdWindow._icon.set_style(`color:;`);
+ osdWindow._label.set_style(`color:;`);
+ osdWindow._label.disconnect(osdColorChangedHandler);
+ });
+ }
+
+ if (level === 0) {
+ osdWindow._label.add_style_class_name(this._WARNING_COLOR_STYLE_CLASS_NAME);
+ // the same label is shared by all GS OSD so the style must be removed after being used
+ let osdLabelChangedHandler = osdWindow._label.connect('notify::text', () => {
+ osdWindow._label.remove_style_class_name(this._WARNING_COLOR_STYLE_CLASS_NAME);
+ osdWindow._label.disconnect(osdLabelChangedHandler);
+ });
+ }
+
+ // if (hideTimeoutSave)
+ // OsdWindow.HIDE_TIMEOUT = hideTimeoutSave;
+ }
+
+ setCursor(sourceActor_, cursorName) {
+ // Map cursor names for GNOME 46/47 fallback compatibility
+ let cursorMap = {
+ 'MOVE': this._SHELL_MAJOR_VERSION >= 48 ? 'MOVE' : 'DND_MOVE',
+ 'POINTER': this._SHELL_MAJOR_VERSION >= 48 ? 'POINTER' : 'POINTING_HAND',
+ 'NONE': this._SHELL_MAJOR_VERSION >= 48 ? 'NONE' : 'BLANK',
+ 'CROSSHAIR': 'CROSSHAIR',
+ 'TEXT': this._SHELL_MAJOR_VERSION >= 48 ? 'TEXT' : 'IBEAM',
+ 'DEFAULT': 'DEFAULT'
+ };
+
+ let mappedCursorName = cursorMap[cursorName] || cursorName;
+
+ // Safety check: verify the cursor constant exists before using it
+ if (!Meta.Cursor[mappedCursorName]) {
+ // Fallback to DEFAULT if cursor doesn't exist
+ console.debug(`Draw On Gnome: Cursor ${mappedCursorName} not found, using DEFAULT`);
+ mappedCursorName = 'DEFAULT';
+ }
+
+ // Check display or screen (API changes)
+ try {
+ if (global.display.set_cursor)
+ global.display.set_cursor(Meta.Cursor[mappedCursorName]);
+ else if (global.screen && global.screen.set_cursor)
+ global.screen.set_cursor(Meta.Cursor[mappedCursorName]);
+ } catch (e) {
+ console.debug(`Draw On Gnome: Error setting cursor ${mappedCursorName}: ${e.message}`);
+ }
+ }
+
+ removeAreas() {
+ for (const area of this.areas) {
+ area.disconnect(area.leaveDrawingHandler);
+ area.disconnect(area.showOsdHandler);
+ area.destroy();
+ }
+ this.areas = [];
+ }
+
+ disable() {
+ if (this.monitorChangedHandler) {
+ Main.layoutManager.disconnect(this.monitorChangedHandler);
+ this.monitorChangedHandler = null;
+ }
+ if (this.indicatorSettingHandler) {
+ this._settings.disconnect(this.indicatorSettingHandler);
+ this.indicatorSettingHandler = null;
+ }
+ if (this.desktopSettingHandler) {
+ this._settings.disconnect(this.desktopSettingHandler);
+ this.desktopSettingHandler = null;
+ }
+ if (this.persistentOverTogglesSettingHandler) {
+ this._settings.disconnect(this.persistentOverTogglesSettingHandler);
+ this.persistentOverTogglesSettingHandler = null;
+ }
+ if (this.persistentOverRestartsSettingHandler) {
+ this._settings.disconnect(this.persistentOverRestartsSettingHandler);
+ this.persistentOverRestartsSettingHandler = null;
+ }
+
+ if (this.activeArea)
+ this.toggleDrawing();
+ Main.wm.removeKeybinding('toggle-drawing');
+ Main.wm.removeKeybinding('toggle-modal');
+ Main.wm.removeKeybinding('erase-drawings');
+ this.removeAreas();
+ // this._extension.FILES.IMAGES.disable();
+ // this._extension.FILES.JSONS.disable();
+ if (this.indicator)
+ this.indicator.disable();
+ }
+
+ /**
+ * @private
+ * @param {Clutter.Grab} grab - grab
+ */
+ _findModal(grab) {
+ return Main.modalActorFocusStack.findIndex(modal => modal.grab === grab);
+ }
+
+};
+
+
+export class DrawingIndicator {
+
+ enable() {
+ let [menuAlignment, dontCreateMenu] = [0, true];
+ this.button = new PanelMenu.Button(menuAlignment, "Drawing Indicator", dontCreateMenu);
+ this.buttonActor = this._SHELL_MAJOR_VERSION >= 3 ? this.button.actor: this.button;
+ Main.panel.addToStatusArea('draw-on-gnome-indicator', this.button);
+
+ this.icon = new St.Icon({ icon_name: 'applications-graphics-symbolic',
+ style_class: 'system-status-icon screencast-indicator' });
+ this.buttonActor.add_child(this.icon);
+ this.buttonActor.visible = false;
+ }
+
+ sync(visible) {
+ this.buttonActor.visible = visible;
+ }
+
+ disable() {
+ this.button.destroy();
+ }
+};
+
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/arc-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/arc-symbolic.svg
new file mode 100644
index 0000000..5da0547
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/arc-symbolic.svg
@@ -0,0 +1,7 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/color-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/color-symbolic.svg
new file mode 100644
index 0000000..163f40f
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/color-symbolic.svg
@@ -0,0 +1,18 @@
+
+
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/dashed-line-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/dashed-line-symbolic.svg
new file mode 100644
index 0000000..dc375d7
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/dashed-line-symbolic.svg
@@ -0,0 +1,5 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/document-export-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/document-export-symbolic.svg
new file mode 100644
index 0000000..eb158e9
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/document-export-symbolic.svg
@@ -0,0 +1,8 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/fill-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/fill-symbolic.svg
new file mode 100644
index 0000000..0a66829
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/fill-symbolic.svg
@@ -0,0 +1,3 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/fillrule-evenodd-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/fillrule-evenodd-symbolic.svg
new file mode 100644
index 0000000..da0de94
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/fillrule-evenodd-symbolic.svg
@@ -0,0 +1,3 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/fillrule-nonzero-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/fillrule-nonzero-symbolic.svg
new file mode 100644
index 0000000..be3096c
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/fillrule-nonzero-symbolic.svg
@@ -0,0 +1,3 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/full-line-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/full-line-symbolic.svg
new file mode 100644
index 0000000..b17a91b
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/full-line-symbolic.svg
@@ -0,0 +1,3 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/linecap-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/linecap-symbolic.svg
new file mode 100644
index 0000000..0df89de
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/linecap-symbolic.svg
@@ -0,0 +1,4 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/linejoin-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/linejoin-symbolic.svg
new file mode 100644
index 0000000..8d5951e
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/linejoin-symbolic.svg
@@ -0,0 +1,3 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/palette-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/palette-symbolic.svg
new file mode 100644
index 0000000..7846c46
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/palette-symbolic.svg
@@ -0,0 +1,32 @@
+
+
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/smooth-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/smooth-symbolic.svg
new file mode 100644
index 0000000..483094e
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/smooth-symbolic.svg
@@ -0,0 +1,6 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/stroke-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/stroke-symbolic.svg
new file mode 100644
index 0000000..29ed599
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/stroke-symbolic.svg
@@ -0,0 +1,3 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-arrow-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-arrow-symbolic.svg
new file mode 100644
index 0000000..742843f
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-arrow-symbolic.svg
@@ -0,0 +1,7 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-ellipse-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-ellipse-symbolic.svg
new file mode 100644
index 0000000..9d93d08
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-ellipse-symbolic.svg
@@ -0,0 +1,7 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-highlighter-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-highlighter-symbolic.svg
new file mode 100644
index 0000000..6d8b747
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-highlighter-symbolic.svg
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-laser-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-laser-symbolic.svg
new file mode 100644
index 0000000..71b9d8a
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-laser-symbolic.svg
@@ -0,0 +1,14 @@
+
\ No newline at end of file
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-line-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-line-symbolic.svg
new file mode 100644
index 0000000..953d9b5
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-line-symbolic.svg
@@ -0,0 +1,7 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-mirror-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-mirror-symbolic.svg
new file mode 100644
index 0000000..403970b
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-mirror-symbolic.svg
@@ -0,0 +1,8 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-move-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-move-symbolic.svg
new file mode 100644
index 0000000..d77f2e3
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-move-symbolic.svg
@@ -0,0 +1,14 @@
+
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-none-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-none-symbolic.svg
new file mode 100644
index 0000000..83dad1a
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-none-symbolic.svg
@@ -0,0 +1,17 @@
+
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-polygon-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-polygon-symbolic.svg
new file mode 100644
index 0000000..9c1a0b6
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-polygon-symbolic.svg
@@ -0,0 +1,8 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-polyline-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-polyline-symbolic.svg
new file mode 100644
index 0000000..2f7c894
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-polyline-symbolic.svg
@@ -0,0 +1,9 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-rectangle-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-rectangle-symbolic.svg
new file mode 100644
index 0000000..e7dbfe0
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-rectangle-symbolic.svg
@@ -0,0 +1,7 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-resize-symbolic.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-resize-symbolic.svg
new file mode 100644
index 0000000..2f4d37f
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/icons/tool-resize-symbolic.svg
@@ -0,0 +1,15 @@
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/images/Example.svg b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/images/Example.svg
new file mode 100644
index 0000000..c2fb36c
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/data/images/Example.svg
@@ -0,0 +1,43 @@
+
+
+
+
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/elements.js b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/elements.js
new file mode 100644
index 0000000..dcb3755
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/elements.js
@@ -0,0 +1,1237 @@
+/*
+ * Copyright 2019 Abakkk
+ * Copyright 2024 Dave Prowse
+ *
+ * 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 .
+ *
+ * SPDX-FileCopyrightText: 2019 Abakkk
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileContributor: Modified by Dave Prowse
+ */
+
+/* jslint esversion: 6 (2019) */
+/* eslint version: 9.16 (2024) */
+/* exported Shape, TextAlignment, Transformation, getAllFontFamilies, DrawingElement */
+
+import Cairo from 'cairo';
+
+import Clutter from 'gi://Clutter';
+import Cogl from 'gi://Cogl';
+import GObject from 'gi://GObject';
+import Pango from 'gi://Pango';
+import PangoCairo from 'gi://PangoCairo';
+
+import { CURATED_UUID as UUID } from './utils.js';
+
+// replacing this nullish with a ternay: const Color = Clutter.Color ?? Cogl.Color;
+const Color = Clutter.Color ? Clutter.Color : Cogl.Color;
+
+export const StaticColor = {
+ WHITE: Color.from_string('#ffffff')[1],
+ BLUE: Color.from_string('#0000ff')[1],
+ TRANSPARENT: Color.from_string('#00000000')[1],
+ BLACK: Color.from_string('#000000')[1],
+ GRAY: Color.from_string('#a0a0a4')[1],
+ RED: Color.from_string('#ff0000')[1]
+}
+
+export const Shape = { NONE: 0, LINE: 1, ELLIPSE: 2, RECTANGLE: 3, TEXT: 4, POLYGON: 5, POLYLINE: 6, IMAGE: 7, ARROW: 8, LASER: 9, HIGHLIGHTER: 10 };
+export const TextAlignment = { LEFT: 0, CENTER: 1, RIGHT: 2 };
+export const Transformation = { TRANSLATION: 0, ROTATION: 1, SCALE_PRESERVE: 2, STRETCH: 3, REFLECTION: 4, INVERSION: 5, SMOOTH: 100 };
+
+export const getAllFontFamilies = function() {
+ return PangoCairo.font_map_get_default().list_families().map(fontFamily => fontFamily.get_name()).sort((a,b) => a.localeCompare(b));
+};
+
+const getFillRuleSvgName = function(fillRule) {
+ return fillRule == Cairo.FillRule.EVEN_ODD ? 'evenodd' : 'nonzero';
+};
+
+const getLineCapSvgName = function(lineCap) {
+ return lineCap == Cairo.LineCap.BUTT ? 'butt' :
+ lineCap == Cairo.LineCap.SQUASH ? 'square' :
+ 'round';
+};
+
+const getLineJoinSvgName = function(lineJoin) {
+ return lineJoin == Cairo.LineJoin.MITER ? 'miter' :
+ lineJoin == Cairo.LineJoin.BEVEL ? 'bevel' :
+ 'round';
+};
+
+const SVG_DEBUG_SUPERPOSES_CAIRO = false;
+const RADIAN = 180 / Math.PI; // degree
+const INVERSION_CIRCLE_RADIUS = 12; // px
+const REFLECTION_TOLERANCE = 5; // px, to select vertical and horizontal directions
+const STRETCH_TOLERANCE = Math.PI / 8; // rad, to select vertical and horizontal directions
+const MIN_REFLECTION_LINE_LENGTH = 10; // px
+const MIN_TRANSLATION_DISTANCE = 1; // px
+const MIN_ROTATION_ANGLE = Math.PI / 1000; // rad
+const MIN_DRAWING_SIZE = 3; // px
+const MIN_INTERMEDIATE_POINT_DISTANCE = 1; // px, the higher it is, the fewer points there will be
+const MARK_COLOR = StaticColor.BLUE
+
+export const DrawingElement = function(params) {
+ return params.shape == Shape.TEXT ? new TextElement(params) :
+ params.shape == Shape.IMAGE ? new ImageElement(params) :
+ new _DrawingElement(params);
+};
+
+// DrawingElement represents a "brushstroke".
+// It can be converted into a cairo path as well as a svg element.
+// See DrawingArea._startDrawing() to know its params.
+const _DrawingElement = GObject.registerClass({
+ GTypeName: `${UUID}-DrawingElement`,
+}, class _DrawingElement extends GObject.Object{
+ _init(params) {
+ for (let key in params)
+ this[key] = params[key];
+
+ // compatibility with json generated by old extension versions
+
+ if (params.transformations === undefined)
+ this.transformations = [];
+
+ if (params.font && !(params.font instanceof Pango.FontDescription)) {
+ // compatibility with v6.2-
+ if (params.font.weight === 0)
+ this.font.weight = 400;
+ else if (params.font.weight === 1)
+ this.font.weight = 700;
+ this.font = new Pango.FontDescription();
+ ['family', 'weight', 'style', 'stretch', 'variant'].forEach(attribute => {
+ if (params.font[attribute] !== undefined)
+ try {
+ this.font[`set_${attribute}`](params.font[attribute]);
+ } catch(e) {}
+ });
+ }
+
+ if (params.transform && params.transform.center) {
+ let angle = (params.transform.angle || 0) + (params.transform.startAngle || 0);
+ if (angle)
+ this.transformations.push({ type: Transformation.ROTATION, angle: angle });
+ }
+ if (params.shape == Shape.ELLIPSE && params.transform && params.transform.ratio && params.transform.ratio != 1 && params.points.length >= 2) {
+ let [ratio, p0, p1] = [params.transform.ratio, params.points[0], params.points[1]];
+ // Add a fake point that will give the right ellipse ratio when building the element.
+ this.points.push([ratio * (p1[0] - p0[0]) + p0[0], ratio * (p1[1] - p0[1]) + p0[1]]);
+ }
+ delete this.transform;
+
+ // v10-
+ if (this.textRightAligned)
+ this.textAlignment = TextAlignment.RIGHT;
+ delete this.textRightAligned;
+ }
+
+ // toJSON is called by JSON.stringify
+ toJSON() {
+ return {
+ shape: this.shape,
+ color: this.color,
+ line: this.line,
+ dash: this.dash,
+ fill: this.fill,
+ fillRule: this.fillRule,
+ eraser: this.eraser,
+ transformations: this.transformations.filter(transformation => transformation.type != Transformation.SMOOTH)
+ .map(transformation => Object.assign({}, transformation, { undoable: undefined })),
+ points: this.points.map((point) => [Math.round(point[0]*100)/100, Math.round(point[1]*100)/100])
+ };
+ }
+
+ buildCairo(cr, params) {
+ if (this.color)
+ cr.setSourceColor(this.color);
+
+ if (this.line) {
+ cr.setLineCap(this.line.lineCap);
+ cr.setLineJoin(this.line.lineJoin);
+ cr.setLineWidth(this.line.lineWidth);
+ }
+
+ if (this.fillRule)
+ cr.setFillRule(this.fillRule);
+
+ if (this.dash && this.dash.active && this.dash.array && this.dash.array[0] && this.dash.array[1])
+ cr.setDash(this.dash.array, this.dash.offset);
+
+ if (this.eraser)
+ cr.setOperator(Cairo.Operator.CLEAR);
+ else
+ cr.setOperator(Cairo.Operator.OVER);
+
+ if (params.dummyStroke)
+ setDummyStroke(cr);
+
+ if (SVG_DEBUG_SUPERPOSES_CAIRO) {
+ cr.setSourceColor(StaticColor.RED);
+ cr.setLineWidth(this.line.lineWidth / 2 || 1);
+ }
+
+ this.transformations.slice(0).reverse().forEach(transformation => {
+ if (transformation.type == Transformation.TRANSLATION) {
+ cr.translate(transformation.slideX, transformation.slideY);
+ } else if (transformation.type == Transformation.ROTATION) {
+ let center = this._getTransformedCenter(transformation);
+ cr.translate(center[0], center[1]);
+ cr.rotate(transformation.angle);
+ cr.translate(-center[0], -center[1]);
+ } else if (transformation.type == Transformation.SCALE_PRESERVE || transformation.type == Transformation.STRETCH) {
+ let center = this._getTransformedCenter(transformation);
+ cr.translate(center[0], center[1]);
+ cr.rotate(transformation.angle);
+ cr.scale(transformation.scaleX, transformation.scaleY);
+ cr.rotate(-transformation.angle);
+ cr.translate(-center[0], -center[1]);
+ } else if (transformation.type == Transformation.REFLECTION || transformation.type == Transformation.INVERSION) {
+ cr.translate(transformation.slideX, transformation.slideY);
+ cr.rotate(transformation.angle);
+ cr.scale(transformation.scaleX, transformation.scaleY);
+ cr.rotate(-transformation.angle);
+ cr.translate(-transformation.slideX, -transformation.slideY);
+ }
+ });
+
+ this._drawCairo(cr, params);
+
+ cr.identityMatrix();
+ }
+
+ _addMarks(cr) {
+ if (this.showSymmetryElement) {
+ setDummyStroke(cr);
+ cr.setSourceColor(MARK_COLOR);
+
+ let transformation = this.lastTransformation;
+ if (transformation.type == Transformation.REFLECTION) {
+ cr.moveTo(transformation.startX, transformation.startY);
+ cr.lineTo(transformation.endX, transformation.endY);
+ } else {
+ cr.arc(transformation.endX, transformation.endY, INVERSION_CIRCLE_RADIUS, 0, 2 * Math.PI);
+ }
+ cr.stroke();
+ }
+
+ if (this.showRotationCenter) {
+ setDummyStroke(cr);
+ cr.setSourceColor(MARK_COLOR);
+
+ let center = this._getTransformedCenter(this.lastTransformation);
+ cr.arc(center[0], center[1], INVERSION_CIRCLE_RADIUS, 0, 2 * Math.PI);
+ cr.stroke();
+ }
+
+ if (this.showStretchAxes) {
+ setDummyStroke(cr);
+ cr.setSourceColor(MARK_COLOR);
+
+ let center = this._getTransformedCenter(this.lastTransformation);
+ for (let i = 0; i <=1; i++) {
+ cr.moveTo(center[0] - 1000 * Math.cos(i * Math.PI / 2), center[1] - 1000 * Math.sin(i * Math.PI / 2));
+ cr.lineTo(center[0] + 1000 * Math.cos(i * Math.PI / 2), center[1] + 1000 * Math.sin(i * Math.PI / 2));
+ }
+ cr.stroke();
+ }
+ }
+
+ _drawCairo(cr, params) {
+ let [points, shape] = [this.points, this.shape];
+
+ if (shape == Shape.LINE && points.length == 3) {
+ cr.moveTo(points[0][0], points[0][1]);
+ cr.curveTo(points[0][0], points[0][1], points[1][0], points[1][1], points[2][0], points[2][1]);
+
+ } else if (shape == Shape.LINE && points.length == 4) {
+ cr.moveTo(points[0][0], points[0][1]);
+ cr.curveTo(points[1][0], points[1][1], points[2][0], points[2][1], points[3][0], points[3][1]);
+
+ } else if (shape == Shape.NONE || shape == Shape.LINE) {
+ cr.moveTo(points[0][0], points[0][1]);
+ for (let j = 1; j < points.length; j++) {
+ cr.lineTo(points[j][0], points[j][1]);
+ }
+
+ } else if (shape == Shape.ELLIPSE && points.length >= 2) {
+ let radius = Math.hypot(points[1][0] - points[0][0], points[1][1] - points[0][1]);
+ let ratio = 1;
+
+ if (points[2]) {
+ ratio = Math.hypot(points[2][0] - points[0][0], points[2][1] - points[0][1]) / radius;
+ cr.translate(points[0][0], points[0][1]);
+ cr.scale(ratio, 1);
+ cr.translate(-points[0][0], -points[0][1]);
+ cr.arc(points[0][0], points[0][1], radius, 0, 2 * Math.PI);
+ cr.translate(points[0][0], points[0][1]);
+ cr.scale(1 / ratio, 1);
+ cr.translate(-points[0][0], -points[0][1]);
+ } else
+ cr.arc(points[0][0], points[0][1], radius, 0, 2 * Math.PI);
+
+ } else if (shape == Shape.RECTANGLE && points.length == 2) {
+ cr.rectangle(points[0][0], points[0][1], points[1][0] - points[0][0], points[1][1] - points[0][1]);
+
+ } else if ((shape == Shape.POLYGON || shape == Shape.POLYLINE) && points.length >= 2) {
+ cr.moveTo(points[0][0], points[0][1]);
+ for (let j = 1; j < points.length; j++) {
+ cr.lineTo(points[j][0], points[j][1]);
+ }
+ if (shape == Shape.POLYGON)
+ cr.closePath();
+
+ } else if (shape == Shape.ARROW && points.length >= 2) {
+ // Draw the main line
+ cr.moveTo(points[0][0], points[0][1]);
+ cr.lineTo(points[1][0], points[1][1]);
+
+ // Draw arrowhead
+ let angle = Math.atan2(points[1][1] - points[0][1], points[1][0] - points[0][0]);
+ let arrowSize = this.line.lineWidth * 5; // Adjust this multiplier to change arrow size
+
+ cr.moveTo(points[1][0], points[1][1]);
+ cr.lineTo(points[1][0] - arrowSize * Math.cos(angle - Math.PI/6),
+ points[1][1] - arrowSize * Math.sin(angle - Math.PI/6));
+ cr.moveTo(points[1][0], points[1][1]);
+ cr.lineTo(points[1][0] - arrowSize * Math.cos(angle + Math.PI/6),
+ points[1][1] - arrowSize * Math.sin(angle + Math.PI/6));
+
+ // Laser Method
+ } else if (shape == Shape.LASER && points.length >= 2) {
+ // LASER BEAM - Like a bass line with vibrato! πΈ
+ const startX = points[0][0];
+ const startY = points[0][1];
+ const endX = points[1][0];
+ const endY = points[1][1];
+
+ const distance = Math.hypot(endX - startX, endY - startY);
+ const angle = Math.atan2(endY - startY, endX - startX);
+ const segments = Math.floor(distance / 8);
+
+ if (segments > 1) {
+ cr.moveTo(startX, startY);
+
+ // Create the wavy laser effect - like sound waves! π΅
+ for (let i = 1; i <= segments; i++) {
+ const progress = i / segments;
+ const x = startX + Math.cos(angle) * distance * progress;
+ const y = startY + Math.sin(angle) * distance * progress;
+ const waveAmplitude = Math.sin(progress * Math.PI) * 3; // Wave intensity
+ const perpOffset = Math.sin(i * Math.PI / 3) * waveAmplitude;
+ const perpX = x + Math.cos(angle + Math.PI/2) * perpOffset;
+ const perpY = y + Math.sin(angle + Math.PI/2) * perpOffset;
+ cr.lineTo(perpX, perpY);
+ }
+
+ cr.lineTo(endX, endY);
+ } else {
+ // Fallback for very short lasers
+ cr.moveTo(startX, startY);
+ cr.lineTo(endX, endY);
+ }
+
+ // End Laser Portion
+
+ // Start Highlighter Portion
+
+ } else if (shape == Shape.HIGHLIGHTER && points.length >= 2) {
+ // HIGHLIGHTER - Semi-transparent yellow brush
+ cr.setOperator(Cairo.Operator.OVER);
+ cr.moveTo(points[0][0], points[0][1]);
+ for (let j = 1; j < points.length; j++) {
+ cr.lineTo(points[j][0], points[j][1]);
+ }
+ }
+ // End Highlighter Portion
+
+ }
+
+ getContainsPoint(cr, x, y) {
+ cr.save();
+ cr.setLineWidth(Math.max(this.line.lineWidth, 25));
+ cr.setDash([], 0);
+
+ // Check whether the point is inside/on/near the element.
+ let inElement = cr.inStroke(x, y) || this.fill && cr.inFill(x, y);
+ cr.restore();
+ return inElement;
+ }
+
+ buildSVG(bgcolorString) {
+ let transforms = [];
+ this.transformations.slice(0).reverse().forEach(transformation => {
+ let center = this._getTransformedCenter(transformation);
+
+ if (transformation.type == Transformation.TRANSLATION) {
+ transforms.push(['translate', transformation.slideX, transformation.slideY]);
+ } else if (transformation.type == Transformation.ROTATION) {
+ transforms.push(['translate', center[0], center[1]]);
+ transforms.push(['rotate', transformation.angle * RADIAN]);
+ transforms.push(['translate', -center[0], -center[1]]);
+ } else if (transformation.type == Transformation.SCALE_PRESERVE || transformation.type == Transformation.STRETCH) {
+ transforms.push(['translate', center[0], center[1]]);
+ transforms.push(['rotate', transformation.angle * RADIAN]);
+ transforms.push(['scale', transformation.scaleX, transformation.scaleY]);
+ transforms.push(['rotate', -transformation.angle * RADIAN]);
+ transforms.push(['translate', -center[0], -center[1]]);
+ } else if (transformation.type == Transformation.REFLECTION || transformation.type == Transformation.INVERSION) {
+ transforms.push(['translate', transformation.slideX, transformation.slideY]);
+ transforms.push(['rotate', transformation.angle * RADIAN]);
+ transforms.push(['scale', transformation.scaleX, transformation.scaleY]);
+ transforms.push(['rotate', -transformation.angle * RADIAN]);
+ transforms.push(['translate', -transformation.slideX, -transformation.slideY]);
+ }
+ });
+
+ let grouped = [];
+ transforms.forEach((transform, index) => {
+ let [type, ...values] = transform;
+
+ if (grouped.length && grouped[grouped.length - 1][0] == type)
+ values.forEach((value, valueIndex) => grouped[grouped.length - 1][valueIndex + 1] += value);
+ else
+ grouped.push(transform);
+ });
+
+ let filtered = grouped.filter(transform => {
+ let [type, ...values] = transform;
+
+ if (type == 'scale')
+ return values.some(value => value != 1);
+ else
+ return values.some(value => value != 0);
+ });
+
+ let transAttribute = '';
+ if (filtered.length) {
+ transAttribute = ' transform="';
+ filtered.forEach((transform, index) => {
+ let [type, ...values] = transform;
+ transAttribute += `${index == 0 ? '' : ' '}${type}(${values.map(value => Number(value).toFixed(2))})`;
+ });
+
+ transAttribute += '"';
+ }
+
+ return this._drawSvg(transAttribute, bgcolorString);
+ }
+
+ _drawSvg(transAttribute, bgcolorString) {
+ let row = "\n ";
+ let points = this.points.map((point) => [Math.round(point[0]*100)/100, Math.round(point[1]*100)/100]);
+
+ // Ensure color has toJSON method (may be lost during copy/mirror operations)
+ let color;
+ if (this.eraser) {
+ color = bgcolorString;
+ } else {
+ if (this.color.toJSON && typeof this.color.toJSON === 'function') {
+ color = this.color.toJSON();
+ } else {
+ // Fallback: reconstruct color string from Color object
+ if (this.color.to_string && typeof this.color.to_string === 'function') {
+ color = this.color.to_string().slice(0, -2); // Remove alpha suffix
+ } else {
+ color = `rgb(${this.color.red},${this.color.green},${this.color.blue})`;
+ }
+ }
+ }
+
+ let fill = this.fill && !this.isStraightLine;
+ let attributes = this.eraser ? `class="eraser" ` : '';
+
+ if (fill) {
+ attributes += `fill="${color}"`;
+ if (this.fillRule)
+ attributes += ` fill-rule="${getFillRuleSvgName(this.fillRule)}"`;
+ } else {
+ attributes += `fill="none"`;
+ }
+
+ if (this.line && this.line.lineWidth) {
+ attributes += ` stroke="${color}"` +
+ ` stroke-width="${this.line.lineWidth}"`;
+ if (this.line.lineCap)
+ attributes += ` stroke-linecap="${getLineCapSvgName(this.line.lineCap)}"`;
+ if (this.line.lineJoin && !this.isStraightLine)
+ attributes += ` stroke-linejoin="${getLineJoinSvgName(this.line.lineJoin)}"`;
+ if (this.dash && this.dash.active && this.dash.array && this.dash.array[0] && this.dash.array[1])
+ attributes += ` stroke-dasharray="${this.dash.array[0]} ${this.dash.array[1]}" stroke-dashoffset="${this.dash.offset}"`;
+ }
+
+ if (this.shape == Shape.LINE && points.length == 4) {
+ row += ``;
+
+ } else if (this.shape == Shape.LINE && points.length == 3) {
+ row += ``;
+
+ } else if (this.shape == Shape.LINE) {
+ row += ``;
+
+ } else if (this.shape == Shape.NONE) {
+ row += ``;
+
+ } else if (this.shape == Shape.ELLIPSE && points.length == 3) {
+ let ry = Math.hypot(points[1][0] - points[0][0], points[1][1] - points[0][1]);
+ let rx = Math.hypot(points[2][0] - points[0][0], points[2][1] - points[0][1]);
+ row += ``;
+
+ } else if (this.shape == Shape.ELLIPSE && points.length == 2) {
+ let r = Math.hypot(points[1][0] - points[0][0], points[1][1] - points[0][1]);
+ row += ``;
+
+ } else if (this.shape == Shape.RECTANGLE && points.length == 2) {
+ row += ``;
+
+ } else if (this.shape == Shape.POLYGON && points.length >= 3) {
+ row += ``;
+
+ } else if (this.shape == Shape.POLYLINE && points.length >= 2) {
+ row += ``;
+
+ } else if (this.shape == Shape.ARROW && points.length >= 2) {
+ let angle = Math.atan2(points[1][1] - points[0][1], points[1][0] - points[0][0]);
+ let arrowSize = this.line.lineWidth * 5; // Should match the Cairo version
+
+ row += ``;
+
+ // Laser portion
+ } else if (this.shape == Shape.LASER && points.length >= 2) {
+ // Export LASER as wavy path
+ const startX = points[0][0];
+ const startY = points[0][1];
+ const endX = points[1][0];
+ const endY = points[1][1];
+ const distance = Math.hypot(endX - startX, endY - startY);
+ const angle = Math.atan2(endY - startY, endX - startX);
+ const segments = Math.floor(distance / 8);
+
+ row += ``;
+
+ // End laser portion
+
+ // Start Highlighter Portion
+ } else if (this.shape == Shape.HIGHLIGHTER && points.length >= 2) {
+ // Export HIGHLIGHTER as semi-transparent path
+ row += ``;
+ }
+ // End Highlighter Portion
+
+ return row;
+ }
+
+ get lastTransformation() {
+ if (!this.transformations.length)
+ return null;
+
+ return this.transformations[this.transformations.length - 1];
+ }
+
+ get isStraightLine() {
+ return this.shape == Shape.LINE && this.points.length == 2;
+ }
+
+ smoothAll() {
+ let oldPoints = this.points.slice();
+
+ for (let i = 0; i < this.points.length; i++)
+ this._smooth(i);
+
+ let newPoints = this.points.slice();
+
+ this.transformations.push({ type: Transformation.SMOOTH, undoable: true,
+ undo: () => this.points = oldPoints,
+ redo: () => this.points = newPoints });
+
+ if (this._undoneTransformations)
+ this._undoneTransformations = this._undoneTransformations.filter(transformation => transformation.type != Transformation.SMOOTH);
+ }
+
+ addPoint() {
+ if (this.shape == Shape.POLYGON || this.shape == Shape.POLYLINE) {
+ // copy last point
+ let [lastPoint, secondToLastPoint] = [this.points[this.points.length - 1], this.points[this.points.length - 2]];
+ if (!getNearness(secondToLastPoint, lastPoint, MIN_DRAWING_SIZE))
+ this.points.push([lastPoint[0], lastPoint[1]]);
+ } else if (this.shape == Shape.LINE) {
+ if (this.points.length == 2) {
+ this.points[2] = this.points[1];
+ } else if (this.points.length == 3) {
+ this.points[3] = this.points[2];
+ this.points[2] = this.points[1];
+ }
+ }
+ }
+
+ // For free drawing only.
+ addIntermediatePoint(x, y, transform) {
+ let points = this.points;
+ if (getNearness(points[points.length - 1], [x, y], MIN_INTERMEDIATE_POINT_DISTANCE))
+ return;
+
+ points.push([x, y]);
+ if (transform)
+ this._smooth(points.length - 1);
+ }
+
+ startDrawing(startX, startY) {
+ this.points.push([startX, startY]);
+
+ if (this.shape == Shape.POLYGON || this.shape == Shape.POLYLINE)
+ this.points.push([startX, startY]);
+ }
+
+ updateDrawing(x, y, transform) {
+ let points = this.points;
+ if (x == points[points.length - 1][0] && y == points[points.length - 1][1])
+ return;
+
+ transform = transform || this.transformations.length >= 1;
+
+ if (this.shape == Shape.NONE) {
+ points.push([x, y]);
+ if (transform)
+ this._smooth(points.length - 1);
+
+ } else if ((this.shape == Shape.RECTANGLE || this.shape == Shape.POLYGON || this.shape == Shape.POLYLINE) && transform) {
+ if (points.length < 2)
+ return;
+
+ let center = this._getOriginalCenter();
+ this.transformations[0] = { type: Transformation.ROTATION,
+ angle: getAngle(center[0], center[1], points[points.length - 1][0], points[points.length - 1][1], x, y) };
+
+ } else if (this.shape == Shape.ELLIPSE && transform) {
+ if (points.length < 2)
+ return;
+
+ points[2] = [x, y];
+ let center = this._getOriginalCenter();
+ this.transformations[0] = { type: Transformation.ROTATION,
+ angle: getAngle(center[0], center[1], center[0] + 1, center[1], x, y) };
+
+ } else if (this.shape == Shape.POLYGON || this.shape == Shape.POLYLINE) {
+ points[points.length - 1] = [x, y];
+
+ } else {
+ points[1] = [x, y];
+
+ }
+ }
+
+ stopDrawing() {
+ // skip when the size is too small to be visible (3px) (except for free drawing)
+ if (this.shape != Shape.NONE && this.points.length >= 2) {
+ let lastPoint = this.points[this.points.length - 1];
+ let secondToLastPoint = this.points[this.points.length - 2];
+ if (getNearness(secondToLastPoint, lastPoint, MIN_DRAWING_SIZE))
+ this.points.pop();
+ }
+
+ if (this.transformations[0] && this.transformations[0].type == Transformation.ROTATION &&
+ Math.abs(this.transformations[0].angle) < MIN_ROTATION_ANGLE)
+ this.transformations.shift();
+ }
+
+ startTransformation(startX, startY, type, undoable) {
+ if (type == Transformation.TRANSLATION)
+ this.transformations.push({ startX, startY, type, undoable, slideX: 0, slideY: 0 });
+ else if (type == Transformation.ROTATION)
+ this.transformations.push({ startX, startY, type, undoable, angle: 0 });
+ else if (type == Transformation.SCALE_PRESERVE || type == Transformation.STRETCH)
+ this.transformations.push({ startX, startY, type, undoable, scaleX: 1, scaleY: 1, angle: 0 });
+ else if (type == Transformation.REFLECTION)
+ this.transformations.push({ startX, startY, endX: startX, endY: startY, type, undoable,
+ scaleX: 1, scaleY: 1, slideX: 0, slideY: 0, angle: 0 });
+ else if (type == Transformation.INVERSION)
+ this.transformations.push({ startX, startY, endX: startX, endY: startY, type, undoable,
+ scaleX: -1, scaleY: -1, slideX: startX, slideY: startY,
+ angle: Math.PI + Math.atan(startY / (startX || 1)) });
+
+ if (type == Transformation.REFLECTION || type == Transformation.INVERSION)
+ this.showSymmetryElement = true;
+ else if (type == Transformation.ROTATION)
+ this.showRotationCenter = true;
+ else if (type == Transformation.STRETCH)
+ this.showStretchAxes = true;
+ }
+
+ updateTransformation(x, y) {
+ let transformation = this.lastTransformation;
+
+ if (transformation.type == Transformation.TRANSLATION) {
+ transformation.slideX = x - transformation.startX;
+ transformation.slideY = y - transformation.startY;
+ } else if (transformation.type == Transformation.ROTATION) {
+ let center = this._getTransformedCenter(transformation);
+ transformation.angle = getAngle(center[0], center[1], transformation.startX, transformation.startY, x, y);
+ } else if (transformation.type == Transformation.SCALE_PRESERVE) {
+ let center = this._getTransformedCenter(transformation);
+ let scale = Math.hypot(x - center[0], y - center[1]) / Math.hypot(transformation.startX - center[0], transformation.startY - center[1]) || 1;
+ [transformation.scaleX, transformation.scaleY] = [scale, scale];
+ } else if (transformation.type == Transformation.STRETCH) {
+ let center = this._getTransformedCenter(transformation);
+ let startAngle = getAngle(center[0], center[1], center[0] + 1, center[1], transformation.startX, transformation.startY);
+ let vertical = Math.abs(Math.sin(startAngle)) >= Math.sin(Math.PI / 2 - STRETCH_TOLERANCE);
+ let horizontal = Math.abs(Math.cos(startAngle)) >= Math.cos(STRETCH_TOLERANCE);
+ let scale = Math.hypot(x - center[0], y - center[1]) / Math.hypot(transformation.startX - center[0], transformation.startY - center[1]) || 1;
+ transformation.scaleX = vertical ? 1 : scale;
+ transformation.scaleY = !vertical ? 1 : scale;
+ transformation.angle = vertical || horizontal ? 0 : getAngle(center[0], center[1], center[0] + 1, center[1], x, y);
+ } else if (transformation.type == Transformation.REFLECTION) {
+ [transformation.endX, transformation.endY] = [x, y];
+
+ if (getNearness([transformation.startX, transformation.startY], [x, y], MIN_REFLECTION_LINE_LENGTH)) {
+ // do nothing to avoid jumps (no transformation at starting and locked transformation after)
+ } else if (Math.abs(y - transformation.startY) <= REFLECTION_TOLERANCE && Math.abs(x - transformation.startX) > REFLECTION_TOLERANCE) {
+ // HORIZONTAL DRAG: Mirror across horizontal axis (flip top/bottom)
+ [transformation.scaleX, transformation.scaleY] = [1, -1];
+ [transformation.slideX, transformation.slideY] = [0, transformation.startY];
+ transformation.angle = 0; // β
FIXED: No rotation needed
+
+ } else if (Math.abs(x - transformation.startX) <= REFLECTION_TOLERANCE && Math.abs(y - transformation.startY) > REFLECTION_TOLERANCE) {
+ // VERTICAL DRAG: Mirror across vertical axis (flip left/right)
+ [transformation.scaleX, transformation.scaleY] = [-1, 1];
+ [transformation.slideX, transformation.slideY] = [transformation.startX, 0];
+ transformation.angle = 0; // β
FIXED: No rotation needed
+
+ } else if (x != transformation.startX) {
+ // DIAGONAL DRAG: Mirror across diagonal line
+ let tan = (y - transformation.startY) / (x - transformation.startX);
+ let reflectionAngle = Math.atan(tan);
+
+ [transformation.scaleX, transformation.scaleY] = [1, -1];
+ [transformation.slideX, transformation.slideY] = [0, transformation.startY - transformation.startX * tan];
+ transformation.angle = reflectionAngle; // β
FIXED: Use actual angle only
+
+ } else if (y != transformation.startY) {
+ // DIAGONAL DRAG: Mirror across diagonal line (vertical case)
+ let tan = (x - transformation.startX) / (y - transformation.startY);
+ let reflectionAngle = Math.atan(tan);
+
+ [transformation.scaleX, transformation.scaleY] = [-1, 1];
+ [transformation.slideX, transformation.slideY] = [transformation.startX - transformation.startY * tan, 0];
+ transformation.angle = -reflectionAngle; // β
FIXED: Use actual angle only
+ }
+
+ } else if (transformation.type == Transformation.INVERSION) {
+ [transformation.endX, transformation.endY] = [x, y];
+ [transformation.scaleX, transformation.scaleY] = [-1, -1];
+ [transformation.slideX, transformation.slideY] = [x, y];
+ transformation.angle = Math.PI + Math.atan(y / (x || 1));
+ }
+ }
+
+ stopTransformation() {
+ this.showSymmetryElement = false;
+ this.showRotationCenter = false;
+ this.showStretchAxes = false;
+
+ // Clean transformations
+ let transformation = this.lastTransformation;
+ if (!transformation)
+ return;
+
+ if (transformation.type == Transformation.REFLECTION &&
+ getNearness([transformation.startX, transformation.startY], [transformation.endX, transformation.endY], MIN_REFLECTION_LINE_LENGTH) ||
+ transformation.type == Transformation.TRANSLATION && Math.hypot(transformation.slideX, transformation.slideY) < MIN_TRANSLATION_DISTANCE ||
+ transformation.type == Transformation.ROTATION && Math.abs(transformation.angle) < MIN_ROTATION_ANGLE) {
+
+ this.transformations.pop();
+ } else {
+ delete transformation.startX;
+ delete transformation.startY;
+ delete transformation.endX;
+ delete transformation.endY;
+ }
+ }
+
+ undoTransformation() {
+ if (this.transformations && this.transformations.length) {
+ // Do not undo initial transformations (transformations made during the drawing step).
+ if (!this.lastTransformation.undoable)
+ return false;
+
+ if (!this._undoneTransformations)
+ this._undoneTransformations = [];
+
+ let transformation = this.transformations.pop();
+ if (transformation.type == Transformation.SMOOTH)
+ transformation.undo();
+
+ this._undoneTransformations.push(transformation);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ redoTransformation() {
+ if (this._undoneTransformations && this._undoneTransformations.length) {
+ if (!this.transformations)
+ this.transformations = [];
+
+ let transformation = this._undoneTransformations.pop();
+ if (transformation.type == Transformation.SMOOTH)
+ transformation.redo();
+
+ this.transformations.push(transformation);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ resetUndoneTransformations() {
+ delete this._undoneTransformations;
+ }
+
+ get canUndo() {
+ return this._undoneTransformations && this._undoneTransformations.length ? true : false;
+ }
+
+ // The figure rotation center before transformations (original).
+ _getOriginalCenter() {
+ if (!this._originalCenter) {
+ let points = this.points;
+ this._originalCenter = this.shape == Shape.ELLIPSE ? [points[0][0], points[0][1]] :
+ this.shape == Shape.LINE && points.length == 4 ? getCurveCenter(points[0], points[1], points[2], points[3]) :
+ this.shape == Shape.LINE && points.length == 3 ? getCurveCenter(points[0], points[0], points[1], points[2]) :
+ points.length >= 3 ? getCentroid(points) :
+ getNaiveCenter(points);
+ }
+
+ return this._originalCenter;
+ }
+
+ // The figure rotation center, whose position is affected by all transformations done before 'transformation'.
+ _getTransformedCenter(transformation) {
+ if (!transformation.elementTransformedCenter) {
+ let matrix = new Pango.Matrix({ xx: 1, xy: 0, yx: 0, yy: 1, x0: 0, y0: 0 });
+
+ // Apply transformations to the matrice in reverse order
+ // because Pango multiply matrices by the left when applying a transformation
+ this.transformations.slice(0, this.transformations.indexOf(transformation)).reverse().forEach(transformation => {
+ if (transformation.type == Transformation.TRANSLATION) {
+ matrix.translate(transformation.slideX, transformation.slideY);
+ } else if (transformation.type == Transformation.ROTATION) {
+ // nothing, the center position is preserved.
+ } else if (transformation.type == Transformation.SCALE_PRESERVE || transformation.type == Transformation.STRETCH) {
+ // nothing, the center position is preserved.
+ } else if (transformation.type == Transformation.REFLECTION || transformation.type == Transformation.INVERSION) {
+ matrix.translate(transformation.slideX, transformation.slideY);
+ matrix.rotate(-transformation.angle * RADIAN);
+ matrix.scale(transformation.scaleX, transformation.scaleY);
+ matrix.rotate(transformation.angle * RADIAN);
+ matrix.translate(-transformation.slideX, -transformation.slideY);
+ }
+ });
+
+ let originalCenter = this._getOriginalCenter();
+ transformation.elementTransformedCenter = matrix.transform_point(originalCenter[0], originalCenter[1]);
+ }
+
+ return transformation.elementTransformedCenter;
+ }
+
+ _smooth(i) {
+ if (i < 2)
+ return;
+ this.points[i-1] = [(this.points[i-2][0] + this.points[i][0]) / 2, (this.points[i-2][1] + this.points[i][1]) / 2];
+ }
+});
+
+const TextElement = GObject.registerClass({
+ GTypeName: `${UUID}-TextElement`,
+}, class TextElement extends _DrawingElement{
+
+ toJSON() {
+ // The font size is useless because it is always computed from the points during cairo/svg building.
+ this.font.unset_fields(Pango.FontMask.SIZE);
+
+ return {
+ shape: this.shape,
+ color: this.color,
+ eraser: this.eraser,
+ transformations: this.transformations,
+ text: this.text,
+ textAlignment: this.textAlignment,
+ font: this.font.to_string(),
+ points: this.points.map((point) => [Math.round(point[0]*100)/100, Math.round(point[1]*100)/100])
+ };
+ }
+
+ get x() {
+ // this.textWidth is computed during Cairo building.
+ let offset = this.textAlignment == TextAlignment.RIGHT ? this.textWidth :
+ this.textAlignment == TextAlignment.CENTER ? this.textWidth / 2 :
+ 0;
+
+ return this.points[1][0] - offset;
+ }
+
+ get y() {
+ return Math.max(this.points[0][1], this.points[1][1]);
+ }
+
+ get height() {
+ return Math.abs(this.points[1][1] - this.points[0][1]);
+ }
+
+ // this.lineWidths is computed during Cairo building.
+ _getLineX(index) {
+ let offset = this.textAlignment == TextAlignment.RIGHT && this.lineWidths && this.lineWidths[index] ? this.lineWidths[index] :
+ this.textAlignment == TextAlignment.CENTER && this.lineWidths && this.lineWidths[index] ? this.lineWidths[index] / 2 :
+ 0;
+
+ return this.points[1][0] - offset;
+ }
+
+ _drawCairo(cr, params) {
+ if (this.points.length != 2)
+ return;
+
+ let layout = PangoCairo.create_layout(cr);
+ let fontSize = this.height * Pango.SCALE;
+ this.font.set_absolute_size(fontSize);
+ layout.set_font_description(this.font);
+ layout.set_text(this.text, -1);
+ this.textWidth = layout.get_pixel_size()[0];
+ this.lineWidths = layout.get_lines_readonly().map(layoutLine => layoutLine.get_pixel_extents()[1].width);
+
+ layout.get_lines_readonly().forEach((layoutLine, index) => {
+ cr.moveTo(this._getLineX(index), this.y + this.height * index);
+ PangoCairo.show_layout_line(cr, layoutLine);
+ });
+
+ // Cannot use 'layout.index_to_line_x(cursorPosition, 0)' because character position != byte index
+ if (params.showTextCursor) {
+ let layoutCopy = layout.copy();
+ if (this.cursorPosition != -1)
+ layoutCopy.set_text(this.text.slice(0, this.cursorPosition), -1);
+
+ let cursorLineIndex = layoutCopy.get_line_count() - 1;
+ let cursorX = this._getLineX(cursorLineIndex) + layoutCopy.get_line_readonly(cursorLineIndex).get_pixel_extents()[1].width;
+ let cursorY = this.y + this.height * cursorLineIndex;
+ cr.rectangle(cursorX, cursorY, this.height / 25, - this.height);
+ cr.fill();
+ }
+
+ if (params.showElementBounds) {
+ cr.rectangle(this.x, this.y - this.height,
+ this.textWidth, this.height * layout.get_line_count());
+ setDummyStroke(cr);
+ } else if (params.drawElementBounds) {
+ cr.rectangle(this.x, this.y - this.height,
+ this.textWidth, this.height * layout.get_line_count());
+ // Only draw the rectangle to find the element, not to show it.
+ cr.setLineWidth(0);
+ }
+ }
+
+ getContainsPoint(cr, x, y) {
+ return cr.inFill(x, y);
+ }
+
+ _drawSvg(transAttribute, bgcolorString) {
+ if (this.points.length != 2)
+ return "";
+
+ let row = "";
+ let height = Math.round(this.height * 100) / 100;
+ let color = this.eraser ? bgcolorString : this.color.toJSON();
+ let attributes = this.eraser ? `class="eraser" ` : '';
+ attributes += `fill="${color}" ` +
+ `font-size="${height}" ` +
+ `font-family="${this.font.get_family()}"`;
+
+ // this.font.to_string() is not valid to fill the svg 'font' shorthand property.
+ // Each property must be filled separately.
+ ['Stretch', 'Style', 'Variant'].forEach(attribute => {
+ let lower = attribute.toLowerCase();
+ if (this.font[`get_${lower}`]() != Pango[attribute].NORMAL) {
+ let font = new Pango.FontDescription();
+ font[`set_${lower}`](this.font[`get_${lower}`]());
+ attributes += ` font-${lower}="${font.to_string()}"`;
+ }
+ });
+ if (this.font.get_weight() != Pango.Weight.NORMAL)
+ attributes += ` font-weight="${this.font.get_weight()}"`;
+
+ // It is a fallback for thumbnails. The following layout is not the same than the Cairo one and
+ // layoutLine.get_pixel_extents does not return the correct value with non-latin fonts.
+ // An alternative would be to store this.lineWidths in the json.
+ if (this.textAlignment != TextAlignment.LEFT && !this.lineWidths) {
+ let clutterText = new Clutter.Text({ text: this.text });
+ let layout = clutterText.get_layout();
+ let fontSize = height * Pango.SCALE;
+ this.font.set_absolute_size(fontSize);
+ layout.set_font_description(this.font);
+ this.lineWidths = layout.get_lines_readonly().map(layoutLine => layoutLine.get_pixel_extents()[1].width);
+ }
+
+ this.text.split(/\r\n|\r|\n/).forEach((text, index) => {
+ let x = Math.round(this._getLineX(index) * 100) / 100;
+ let y = Math.round((this.y + this.height * index) * 100) / 100;
+ row += `\n ${text}`;
+ });
+
+ return row;
+ }
+
+ updateDrawing(x, y, transform) {
+ let points = this.points;
+ if (x == points[points.length - 1][0] && y == points[points.length - 1][1])
+ return;
+
+ transform = transform || this.transformations.length >= 1;
+
+ if (transform) {
+ if (points.length < 2)
+ return;
+
+ let [slideX, slideY] = [x - points[1][0], y - points[1][1]];
+ points[0] = [points[0][0] + slideX, points[0][1] + slideY];
+ points[1] = [x, y];
+
+ } else {
+ points[1] = [x, y];
+
+ }
+ }
+
+ _getOriginalCenter() {
+ if (!this._originalCenter) {
+ let points = this.points;
+ this._originalCenter = points.length == 2 ? [points[1][0], Math.max(points[0][1], points[1][1])] :
+ points.length >= 3 ? getCentroid(points) :
+ getNaiveCenter(points);
+ }
+
+ return this._originalCenter;
+ }
+});
+
+const ImageElement = GObject.registerClass({
+ GTypeName: `${UUID}-ImageElement`,
+}, class ImageElement extends _DrawingElement{
+
+ toJSON() {
+ return {
+ shape: this.shape,
+ color: this.color,
+ colored: this.colored,
+ transformations: this.transformations,
+ image: this.image,
+ preserveAspectRatio: this.preserveAspectRatio,
+ points: this.points.map((point) => [Math.round(point[0]*100)/100, Math.round(point[1]*100)/100])
+ };
+ }
+
+ _drawCairo(cr, params) {
+ if (this.points.length < 2)
+ return;
+
+ let points = this.points;
+ let [x, y] = [Math.min(points[0][0], points[1][0]), Math.min(points[0][1], points[1][1])];
+ let [width, height] = [Math.abs(points[1][0] - points[0][0]), Math.abs(points[1][1] - points[0][1])];
+
+ if (width < 1 || height < 1)
+ return;
+
+ cr.save();
+ this.image.setCairoSource(cr, x, y, width, height, this.preserveAspectRatio, this.colored ? this.color.toJSON() : null);
+ // Image is already painted by setCairoSource - no need to fill
+ cr.restore();
+
+ if (params.showElementBounds) {
+ cr.rectangle(x, y, width, height);
+ setDummyStroke(cr);
+ } else if (params.drawElementBounds) {
+ cr.rectangle(x, y, width, height);
+ // Only draw the rectangle to find the element, not to show it.
+ cr.setLineWidth(0);
+ }
+ }
+
+ getContainsPoint(cr, x, y) {
+ return cr.inFill(x, y);
+ }
+
+ _drawSvg(transAttribute) {
+ let points = this.points;
+ let row = "\n ";
+ let attributes = '';
+
+ // GNOME 48.5 fix: Check if image exists before accessing
+ if (!this.image) {
+ return row; // Return empty row
+ }
+
+ if (points.length == 2) {
+ attributes += `fill="none"`;
+ let base64 = this.image.getBase64ForColor(this.colored ? this.color.toJSON() : null);
+ row += ``;
+ }
+
+ return row;
+ }
+
+ updateDrawing(x, y, transform) {
+ let points = this.points;
+ if (x == points[0][0] || y == points[0][1])
+ return;
+
+ points[1] = [x, y];
+ this.preserveAspectRatio = !transform;
+ }
+});
+
+const setDummyStroke = function(cr) {
+ cr.setLineWidth(2);
+ cr.setLineCap(0);
+ cr.setLineJoin(0);
+ cr.setDash([1, 2], 0);
+};
+
+const getNearness = function(pointA, pointB, distance) {
+ return Math.hypot(pointB[0] - pointA[0], pointB[1] - pointA[1]) < distance;
+};
+
+// mean of the vertices, ok for regular polygons
+const getNaiveCenter = function(points) {
+ return points.reduce((accumulator, point) => accumulator = [accumulator[0] + point[0], accumulator[1] + point[1]])
+ .map(coord => coord / points.length);
+};
+
+// https://en.wikipedia.org/wiki/Centroid#Of_a_polygon
+const getCentroid = function(points) {
+ let n = points.length;
+ points.push(points[0]);
+
+ let [sA, sX, sY] = [0, 0, 0];
+ for (let i = 0; i <= n-1; i++) {
+ let a = points[i][0]*points[i+1][1] - points[i+1][0]*points[i][1];
+ sA += a;
+ sX += (points[i][0] + points[i+1][0]) * a;
+ sY += (points[i][1] + points[i+1][1]) * a;
+ }
+
+ points.pop();
+ if (sA == 0)
+ return getNaiveCenter(points);
+ return [sX / (3 * sA), sY / (3 * sA)];
+};
+
+/*
+Cubic BΓ©zier:
+[0, 1] -> βΒ², P(t) = (1-t)Β³Pβ + 3t(1-t)Β²Pβ + 3tΒ²(1-t)Pβ + tΒ³Pβ
+
+general case:
+
+const cubicBezierCoord = function(x0, x1, x2, x3, t) {
+ return (1-t)**3*x0 + 3*t*(1-t)**2*x1 + 3*t**2*(1-t)*x2 + t**3*x3;
+}
+
+const cubicBezierPoint = function(p0, p1, p2, p3, t) {
+ return [cubicBezier(p0[0], p1[0], p2[0], p3[0], t), cubicBezier(p0[1], p1[1], p2[1], p3[1], t)];
+}
+
+Approximatively:
+control point: p0 ---- p1 ---- p2 ---- p3 (p2 is not on the curve)
+ t: 0 ---- 1/3 ---- 2/3 ---- 1
+*/
+
+// If the curve has a symmetry axis, it is truly a center (the intersection of the curve and the axis).
+// In other cases, it is not a notable point, just a visual approximation.
+const getCurveCenter = function(p0, p1, p2, p3) {
+ if (p0[0] == p1[0] && p0[1] == p1[1])
+ // p0 = p1, t = 2/3
+ return [(p1[0] + 6*p1[0] + 12*p2[0] + 8*p3[0]) / 27, (p1[1] + 6*p1[1] + 12*p2[1] + 8*p3[1]) / 27];
+ else
+ // t = 1/2
+ return [(p0[0] + 3*p1[0] + 3*p2[0] + p3[0]) / 8, (p0[1] + 3*p1[1] + 3*p2[1] + p3[1]) / 8];
+};
+
+const getAngle = function(xO, yO, xA, yA, xB, yB) {
+ // calculate angle of rotation in absolute value
+ // cos(AOB) = (OA.OB)/(||OA||*||OB||) where OA.OB = (xA-xO)*(xB-xO) + (yA-yO)*(yB-yO)
+ let cos = ((xA - xO)*(xB - xO) + (yA - yO)*(yB - yO)) / (Math.hypot(xA - xO, yA - yO) * Math.hypot(xB - xO, yB - yO));
+
+ // acos is defined on [-1, 1] but
+ // with A == B and imperfect computer calculations, cos may be equal to 1.00000001.
+ cos = Math.min(Math.max(-1, cos), 1);
+ let angle = Math.acos( cos );
+
+ // determine the sign of the angle
+ if (xA == xO) {
+ if (xB > xO)
+ angle = -angle;
+ } else {
+ // equation of OA: y = ax + b
+ let a = (yA - yO) / (xA - xO);
+ let b = yA - a*xA;
+ if (yB < a*xB + b)
+ angle = - angle;
+ if (xA < xO)
+ angle = - angle;
+ }
+
+ return angle;
+};
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/extension.js b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/extension.js
new file mode 100644
index 0000000..d362aa2
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/extension.js
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2019 Abakkk
+ * Copyright 2023 zhrexl
+ * Copyright 2024 Dave Prowse
+
+ * 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 .
+ *
+ * SPDX-FileCopyrightText: 2019 Abakkk
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileContributor: Modified by Dave Prowse
+ */
+
+/* eslint version: 9.16 (2024) */
+
+import GObject from 'gi://GObject';
+
+import { QuickToggle, SystemIndicator } from 'resource:///org/gnome/shell/ui/quickSettings.js';
+
+import * as Panel from 'resource:///org/gnome/shell/ui/panel.js';
+
+import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js';
+
+import { Files } from './files.js';
+
+import * as AreaManager from './areamanager.js';
+
+import { SHELL_MAJOR_VERSION } from './utils.js';
+
+
+const FeatureToggle = GObject.registerClass(
+class FeatureToggle extends QuickToggle {
+ _init() {
+ super._init({
+ title: 'Drawing Mode',
+ iconName: 'applications-graphics-symbolic',
+ toggleMode: true,
+ });
+ }
+});
+
+
+const Indicator = GObject.registerClass(
+class Indicator extends SystemIndicator {
+ _init(extension) {
+ super._init();
+
+ this._extension = extension;
+
+ this.toggle = new FeatureToggle();
+ this.quickSettingsItems.push(this.toggle);
+ this._addIndicator();
+
+ this.connect('destroy', () => {
+ this.quickSettingsItems.forEach(item => item.destroy());
+ });
+ }
+
+ get_toggle() {
+ return this.toggle;
+ }
+
+ // Connect the toggle to the extension's drawing functionality
+ connectToExtension(toggleDrawingCallback) {
+ this.toggle.connect('clicked', toggleDrawingCallback);
+ }
+});
+
+
+export default class DrawOnGnomeExtension extends Extension {
+
+ constructor(metadata) {
+ super(metadata);
+ this.indicator = null;
+ }
+
+ enable() {
+ console.debug(`enabling ${this.metadata.name} version ${this.metadata.version}`);
+
+ this.settings = this.getSettings();
+ this.internalShortcutSettings = this.getSettings(this.metadata['settings-schema'] + '.internal-shortcuts');
+ this.drawingSettings = this.getSettings(this.metadata['settings-schema'] + '.drawing');
+
+ // CRITICAL: Initialize FILES before AreaManager to avoid race condition
+ // AreaManager creates DrawingAreas which may try to load persistent data
+ this.FILES = new Files(this);
+
+ this.areaManager = new AreaManager.AreaManager(this);
+ this.areaManager.enable();
+
+ // Create indicator if GNOME version supports it and setting allows it
+ this._updateIndicator();
+
+ // Watch for settings changes
+ this._settingsChangedId = this.settings.connect('changed::quicktoggle-disabled',
+ this._updateIndicator.bind(this));
+ }
+
+ disable() {
+ // Disconnect settings signal
+ if (this._settingsChangedId) {
+ this.settings.disconnect(this._settingsChangedId);
+ this._settingsChangedId = null;
+ }
+
+ // Destroy indicator if it exists
+ if (this.indicator) {
+ this.indicator.destroy();
+ this.indicator = null;
+ }
+
+ this.areaManager.disable();
+ delete this.areaManager;
+ delete this.settings;
+ delete this.internalShortcutSettings;
+ this.FILES = null;
+ this.drawingSettings = null;
+ this.areaManager = null;
+ this.internalShortcutSettings = null;
+ }
+
+ _updateIndicator() {
+ // Only create indicator on GNOME 44+
+ if (SHELL_MAJOR_VERSION < 44) {
+ return;
+ }
+
+ const quicktoggleDisabled = this.settings.get_boolean('quicktoggle-disabled');
+
+ if (quicktoggleDisabled && this.indicator) {
+ // Setting says disabled, but we have an indicator - destroy it
+ this.indicator.destroy();
+ this.indicator = null;
+ } else if (!quicktoggleDisabled && !this.indicator) {
+ // Setting says enabled, but we don't have an indicator - create it
+ this.indicator = new Indicator(this);
+ this.indicator.connectToExtension(this._toggleDrawing.bind(this));
+ }
+ }
+
+ _toggleDrawing() {
+ Panel.closeQuickSettings();
+ if (this.indicator) {
+ this.indicator.get_toggle().set_checked(false);
+ }
+ this.areaManager.toggleDrawing();
+ }
+}
\ No newline at end of file
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/files.js b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/files.js
new file mode 100644
index 0000000..43c127d
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/files.js
@@ -0,0 +1,709 @@
+/*
+ * Copyright 2019 Abakkk
+ * Copyright 2024 Dave Prowse
+ *
+ * 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 .
+ *
+ * SPDX-FileCopyrightText: 2019 Abakkk
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+/* jslint esversion: 6 */
+/* eslint version: 9.16 (2024) */
+/* exported Icons, Image, Images, Json, Jsons, getDateString, saveSvg */
+
+
+import GdkPixbuf from 'gi://GdkPixbuf';
+import Cairo from 'cairo';
+import Gio from 'gi://Gio';
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
+import St from 'gi://St';
+
+// Import Clipboard from St
+// const Clipboard = St.Clipboard;
+
+import { CURATED_UUID as UUID } from './utils.js';
+
+class Icons {
+
+ constructor(extension) {
+ const ICON_NAMES = [
+ 'arc', 'color', 'dashed-line', 'document-export', 'fillrule-evenodd', 'fillrule-nonzero', 'fill', 'full-line', 'linecap', 'linejoin', 'palette', 'smooth', 'stroke',
+ 'tool-ellipse', 'tool-line', 'tool-mirror', 'tool-move', 'tool-none', 'tool-polygon', 'tool-polyline', 'tool-rectangle', 'tool-resize', 'tool-arrow', 'tool-laser', 'tool-highlighter'
+ ];
+ const ICON_DIR = extension.dir.get_child('data').get_child('icons');
+ const THEMED_ICON_NAMES = {
+ COLOR_PICKER: 'color-select',
+ ENTER: 'applications-graphics', LEAVE: 'application-exit',
+ GRAB: 'input-touchpad', UNGRAB: 'touchpad-disabled',
+ OPEN: 'document-open', SAVE: 'document-save',
+ FONT_FAMILY: 'font-x-generic', FONT_STYLE: 'format-text-italic', FONT_WEIGHT: 'format-text-bold',
+ LEFT_ALIGNED: 'format-justify-left', CENTERED: 'format-justify-center', RIGHT_ALIGNED: 'format-justify-right',
+ TOOL_IMAGE: 'insert-image', TOOL_TEXT: 'insert-text',
+ };
+ ICON_NAMES.forEach(name => {
+ Object.defineProperty(this, name.toUpperCase().replace(/-/gi, '_'), {
+ get: function () {
+ if (!this[`_${name}`]) {
+ let file = Gio.File.new_for_path(ICON_DIR.get_child(`${name}-symbolic.svg`).get_path());
+ this[`_${name}`] = file.query_exists(null) ? new Gio.FileIcon({ file }) : new Gio.ThemedIcon({ name: 'action-unavailable-symbolic' });
+ }
+ return this[`_${name}`];
+ }
+ });
+ });
+
+ Object.keys(THEMED_ICON_NAMES).forEach(key => {
+ Object.defineProperty(this, key, {
+ get: function () {
+ if (!this[`_${key}`])
+ this[`_${key}`] = new Gio.ThemedIcon({ name: `${THEMED_ICON_NAMES[key]}-symbolic` });
+ return this[`_${key}`];
+ }
+ });
+ });
+ }
+
+ get FAKE() {
+ if (!this._fake) {
+ let bytes = new GLib.Bytes('');
+ this._fake = Gio.BytesIcon.new(bytes);
+ }
+ return this._fake;
+ }
+
+}
+
+
+
+
+
+
+
+// Access images with getPrevious, getNext, getSorted or by iterating over it.
+class Images {
+ _images = [];
+ _clipboardImages = [];
+ _upToDate = false;
+
+ constructor(extension) {
+ this._extension = extension;
+ this._EXAMPLE_IMAGE_DIRECTORY = extension.dir.get_child('data').get_child('images');
+ this._DEFAULT_USER_IMAGE_LOCATION = GLib.build_filenamev([GLib.get_user_data_dir(), extension.metadata['data-dir'], 'images']);
+ }
+
+ disable() {
+ this._images = [];
+ this._clipboardImages = [];
+ this._upToDate = false;
+ }
+
+ _clipboardImagesContains(file) {
+ return this._clipboardImages.some(image => image.file.equal(file));
+ }
+
+ // Firstly iterate over the extension directory that contains Example.svg,
+ // secondly iterate over the directory that was configured by the user in prefs,
+ // finally iterate over the images pasted from the clipboard.
+ [Symbol.iterator]() {
+ if (this._upToDate)
+ return this._images.concat(this._clipboardImages)[Symbol.iterator]();
+
+ this._upToDate = true;
+ let oldImages = this._images;
+ let newImages = this._images = [];
+ let clipboardImagesContains = this._clipboardImagesContains.bind(this);
+ let clipboardIterator = this._clipboardImages[Symbol.iterator]();
+
+ return {
+ getExampleEnumerator: function () {
+ try {
+ return this._EXAMPLE_IMAGE_DIRECTORY.enumerate_children('standard::,thumbnail::', Gio.FileQueryInfoFlags.NONE, null);
+ } catch (e) {
+ return this.getUserEnumerator();
+ }
+ },
+
+ getUserEnumerator: function () {
+ try {
+ let userLocation = this.extension.drawingSettings.get_string('image-location') || this._DEFAULT_USER_IMAGE_LOCATION;
+ let userDirectory = Gio.File.new_for_commandline_arg(userLocation);
+ return userDirectory.enumerate_children('standard::,thumbnail::', Gio.FileQueryInfoFlags.NONE, null);
+ } catch (e) {
+ return null;
+ }
+ },
+
+ get enumerator() {
+ if (this._enumerator === undefined)
+ this._enumerator = this.getExampleEnumerator();
+ else if (this._enumerator && this._enumerator.get_container().equal(this._EXAMPLE_IMAGE_DIRECTORY) && this._enumerator.is_closed())
+ this._enumerator = this.getUserEnumerator();
+ else if (this._enumerator && this._enumerator.is_closed())
+ this._enumerator = null;
+
+ return this._enumerator;
+ },
+
+ next: function () {
+ if (!this.enumerator)
+ return clipboardIterator.next();
+
+ let info = this.enumerator.next_file(null);
+ if (!info) {
+ this.enumerator.close(null);
+ return this.next();
+ }
+
+ let file = this.enumerator.get_child(info);
+
+ if (info.get_content_type().indexOf('image') == 0 && !clipboardImagesContains(file)) {
+ let image = oldImages.find(oldImage => oldImage.file.equal(file)) || new ImageWithGicon({ file, info });
+ newImages.push(image);
+ return { value: image, done: false };
+ } else {
+ return this.next();
+ }
+ }
+ };
+ }
+
+ getSorted() {
+ return [...this].sort((a, b) => a.toString().localeCompare(b.toString()));
+ }
+
+ getNext(currentImage) {
+ let images = this.getSorted();
+ let index = (currentImage && currentImage.file) ? images.findIndex(image => image.file.equal(currentImage.file)) : -1;
+ return images[index == images.length - 1 ? 0 : index + 1] || null;
+ }
+
+ getPrevious(currentImage) {
+ let images = this.getSorted();
+ let index = (currentImage && currentImage.file) ? images.findIndex(image => image.file.equal(currentImage.file)) : -1;
+ return images[index <= 0 ? images.length - 1 : index - 1] || null;
+ }
+
+ reset() {
+ this._upToDate = false;
+ }
+
+ addImagesFromClipboard(callback) {
+ // The following clipboard access only occurs when the user EXPLICITLY presses Ctrl+V to paste an image. It is not accessed silently by the extension.
+ St.Clipboard.get_default().get_text(St.ClipboardType.CLIPBOARD, (clipboard, text) => {
+ console.debug(`DEBUG CLIPBOARD: text="${text}"`);
+ if (!text) {
+ // testing for images
+ console.debug(`DEBUG CLIPBOARD: No text in clipboard`);
+ return;
+ }
+
+ // Since 3.38 there is a line terminator character, that has to be removed with .trim().
+ let lines = text.split('\n').map(line => line.trim());
+ if (lines[0] == 'x-special/nautilus-clipboard')
+ lines = lines.slice(2);
+
+ let images = lines.filter(line => !!line)
+ .map(line => Gio.File.new_for_commandline_arg(line))
+ .filter(file => file.query_exists(null))
+ .map(file => [file, file.query_info('standard::,thumbnail::', Gio.FileQueryInfoFlags.NONE, null)])
+ .filter(pair => pair[1].get_content_type().indexOf('image') == 0)
+ .map(pair => new ImageWithGicon({ file: pair[0], info: pair[1] }));
+
+ // Prevent duplicated
+ images.filter(image => !this._clipboardImagesContains(image.file))
+ .forEach(image => this._clipboardImages.push(image));
+
+ if (images.length) {
+ this.reset();
+ let lastFile = images[images.length - 1].file;
+ callback(this._clipboardImages.find(image => image.file.equal(lastFile)));
+ }
+ });
+ }
+}
+
+
+
+
+
+// Access jsons with getPersistent, getDated, getNamed, getPrevious, getNext, getSorted or by iterating over it.
+class Jsons {
+ _jsons = [];
+ _upToDate = false;
+
+ constructor(extension) {
+ this._extension = extension;
+ }
+
+ disable() {
+ if (this._monitor) {
+ this._monitor.disconnect(this._monitorHandler);
+ this._monitor.cancel();
+ }
+
+ delete this._monitor;
+ delete this._persistent;
+
+ this._jsons = [];
+ this._upToDate = false;
+ }
+
+ _updateMonitor() {
+ if (this._monitor)
+ return;
+ let directory = Gio.File.new_for_path(GLib.build_filenamev([GLib.get_user_data_dir(), this._extension.metadata['data-dir']]));
+ // It is important to specify that the file to monitor is a directory because maybe the directory does not exist yet
+ // and remove events would not be monitored.
+ this._monitor = directory.monitor_directory(Gio.FileMonitorFlags.NONE, null);
+ this._monitorHandler = this._monitor.connect('changed', (monitor, file) => {
+ if (file.get_basename() != `${this._extension.metadata['persistent-file-name']}.json` && file.get_basename().indexOf('.goutputstream'))
+ this.reset();
+ });
+ }
+
+ [Symbol.iterator]() {
+ if (this._upToDate)
+ return this._jsons[Symbol.iterator]();
+
+ this._updateMonitor();
+ this._upToDate = true;
+ let newJsons = this._jsons = [];
+ const extension = this._extension;
+
+ return {
+ get enumerator() {
+ if (this._enumerator === undefined) {
+ try {
+ let directory = Gio.File.new_for_path(GLib.build_filenamev([GLib.get_user_data_dir(), extension.metadata['data-dir']]));
+ this._enumerator = directory.enumerate_children('standard::name,standard::display-name,standard::content-type,time::modified', Gio.FileQueryInfoFlags.NONE, null);
+ } catch (e) {
+ this._enumerator = null;
+ }
+ }
+ return this._enumerator;
+ },
+
+ next: function () {
+ if (!this.enumerator || this.enumerator.is_closed())
+ return { done: true };
+
+ let info = this.enumerator.next_file(null);
+ if (!info) {
+ this.enumerator.close(null);
+ return this.next();
+ }
+
+ let file = this.enumerator.get_child(info);
+
+ if (info.get_content_type().indexOf('json') != -1 && info.get_name() != `${extension.metadata['persistent-file-name']}.json`) {
+ let json = new Json(this._extension, {
+ file, name: info.get_name().slice(0, -5),
+ displayName: info.get_display_name().slice(0, -5),
+ // info.get_modification_date_time: Gio 2.62+
+ modificationUnixTime: info.get_attribute_uint64('time::modified')
+ });
+
+ newJsons.push(json);
+ return { value: json, done: false };
+ } else {
+ return this.next();
+ }
+ }
+ };
+ }
+
+ getSorted() {
+ return [...this].sort((a, b) => b.modificationUnixTime - a.modificationUnixTime);
+ }
+
+ getNext(currentJson) {
+ let jsons = this.getSorted();
+ let index = currentJson ? jsons.findIndex(json => json.name == currentJson.name) : -1;
+ return jsons[index == jsons.length - 1 ? 0 : index + 1] || null;
+ }
+
+ getPrevious(currentJson) {
+ let jsons = this.getSorted();
+ let index = currentJson ? jsons.findIndex(json => json.name == currentJson.name) : -1;
+ return jsons[index <= 0 ? jsons.length - 1 : index - 1] || null;
+ }
+
+ getPersistent() {
+ if (!this._persistent)
+ this._persistent = new Json(this._extension, { name: this._extension.metadata['persistent-file-name'] });
+
+ return this._persistent;
+ }
+
+ getDated() {
+ return new Json(this._extension, { name: getDateString() });
+ }
+
+ getNamed(name) {
+ return [...this].find(json => json.name == name) || new Json(this._extension, { name });
+ }
+
+ reset() {
+ this._upToDate = false;
+ }
+};
+
+
+
+
+
+
+
+// Wrapper around image data. If not subclassed, it is used when loading in the area an image element for a drawing file (.json)
+// and it takes { displayName, contentType, base64, hash } as params.
+export const Image = GObject.registerClass({
+ GTypeName: `${UUID}-Image`,
+}, class Image extends GObject.Object {
+ _init(params) {
+ for (let key in params)
+ this[key] = params[key];
+ }
+
+ toString() {
+ return this.displayName;
+ }
+
+ toJSON() {
+ return {
+ displayName: this.displayName,
+ contentType: this.contentType,
+ base64: this.base64,
+ hash: this.hash
+ };
+ }
+
+ get bytes() {
+ if (!this._bytes)
+ this._bytes = new GLib.Bytes(GLib.base64_decode(this.base64));
+ return this._bytes;
+ }
+
+ get base64() {
+ if (!this._base64)
+ this._base64 = GLib.base64_encode(this.bytes.get_data());
+ return this._base64;
+ }
+
+ set base64(base64) {
+ this._base64 = base64;
+ }
+
+ getBase64ForColor(color) {
+ if (!color || this.contentType != 'image/svg+xml')
+ return this.base64;
+
+ let contents = GLib.base64_decode(this.base64);
+ return GLib.base64_encode(this._replaceColor(contents, color));
+ }
+
+ // hash is not used
+ get hash() {
+ if (!this._hash)
+ this._hash = this.bytes.hash();
+ return this._hash;
+ }
+
+ set hash(hash) {
+ this._hash = hash;
+ }
+
+ getBytesForColor(color) {
+ if (!color || this.contentType != 'image/svg+xml')
+ return this.bytes;
+
+ let contents = this.bytes.get_data();
+ return new GLib.Bytes(this._replaceColor(contents, color));
+ }
+
+ getPixbuf(color) {
+ if (color) {
+ let stream = Gio.MemoryInputStream.new_from_bytes(this.getBytesForColor(color));
+ let pixbuf = GdkPixbuf.Pixbuf.new_from_stream(stream, null);
+ stream.close(null);
+ return pixbuf;
+ }
+
+ if (!this._pixbuf) {
+ let stream = Gio.MemoryInputStream.new_from_bytes(this.bytes);
+ this._pixbuf = GdkPixbuf.Pixbuf.new_from_stream(stream, null);
+ stream.close(null);
+ }
+ return this._pixbuf;
+ }
+
+ getPixbufAtScale(width, height, color) {
+ let stream = Gio.MemoryInputStream.new_from_bytes(this.getBytesForColor(color));
+ let pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(stream, width, height, true, null);
+ stream.close(null);
+ return pixbuf;
+ }
+
+ setCairoSource(cr, x, y, width, height, preserveAspectRatio, color) {
+ let tempPath = null;
+ try {
+
+ // Get the appropriately scaled pixbuf
+ let pixbuf = preserveAspectRatio
+ ? this.getPixbufAtScale(width, height, color)
+ : this.getPixbuf(color).scale_simple(width, height, GdkPixbuf.InterpType.BILINEAR);
+
+ // Save pixbuf to temporary PNG file
+ tempPath = `/tmp/drawon-image-${Date.now()}-${Math.random().toString(36).substring(7)}.png`;
+
+ pixbuf.savev(tempPath, 'png', [], []);
+
+ // Check if file exists
+ let file = Gio.File.new_for_path(tempPath);
+ if (!file.query_exists(null)) {
+ throw new Error('Temp file was not created');
+ }
+
+ // Load PNG as Cairo surface
+ let surface = Cairo.ImageSurface.createFromPNG(tempPath);
+
+ // Paint the surface to the provided Cairo context
+ cr.save();
+ cr.translate(x, y);
+ cr.setSourceSurface(surface, 0, 0);
+ cr.paint();
+ cr.restore();
+
+ } catch (e) {
+ // Fallback: draw red rectangle to show where image should be
+ cr.save();
+ cr.setSourceRGB(1, 0, 0);
+ cr.rectangle(x, y, width, height);
+ cr.fill();
+ cr.restore();
+ } finally {
+ // Clean up temporary file
+ if (tempPath) {
+ try {
+ let file = Gio.File.new_for_path(tempPath);
+ file.delete(null);
+ } catch (e) {
+ // Ignore cleanup errors
+ console.warn(`[setCairoSource] Failed to cleanup temp file ${tempPath}: ${e.message}`);
+ }
+ }
+ }
+ }
+
+ _replaceColor(contents, color) {
+ if (contents instanceof Uint8Array)
+ contents = new TextDecoder('utf-8').decode(contents);
+ else
+ contents = contents.toString();
+
+ return contents.replace(/fill(?=="transparent"|="none"|:transparent|:none)/gi, 'filll')
+ .replace(/fill="[^"]+"/gi, `fill="${color}"`)
+ .replace(/fill:[^";]+/gi, `fill:${color};`)
+ .replace(/filll/gi, 'fill');
+ }
+});
+
+
+
+// Add a gicon generator to Image. It is used with image files and it takes { file, info } as params.
+const ImageWithGicon = GObject.registerClass({
+ GTypeName: `${UUID}-ImageWithGicon`,
+}, class ImageWithGicon extends Image {
+
+ get displayName() {
+ return this.info.get_display_name();
+ }
+
+ get contentType() {
+ return this.info.get_content_type();
+ }
+
+ get thumbnailFile() {
+ if (!this._thumbnailFile) {
+ if (this.info.has_attribute('thumbnail::path') && this.info.get_attribute_boolean('thumbnail::is-valid')) {
+ let thumbnailPath = this.info.get_attribute_as_string('thumbnail::path');
+ this._thumbnailFile = Gio.File.new_for_path(thumbnailPath);
+ }
+ }
+ return this._thumbnailFile || null;
+ }
+
+ get gicon() {
+ if (!this._gicon)
+ this._gicon = new Gio.FileIcon({ file: this.thumbnailFile || this.file });
+ return this._gicon;
+ }
+
+ // use only thumbnails in menu (memory)
+ get thumbnailGicon() {
+ if (this.contentType != 'image/svg+xml' && !this.thumbnailFile)
+ return null;
+
+ return this.gicon;
+ }
+
+ get bytes() {
+ if (!this._bytes) {
+ try {
+ // load_bytes available in GLib 2.56+
+ this._bytes = this.file.load_bytes(null)[0];
+ } catch (e) {
+ let [, contents] = this.file.load_contents(null);
+ if (contents instanceof Uint8Array)
+ this._bytes = new GLib.Bytes(contents);
+ else
+ this._bytes = contents.toGBytes();
+ }
+ }
+ return this._bytes;
+ }
+});
+
+
+
+
+// It is directly generated from a Json object, without an image file. It takes { bytes, displayName, gicon } as params.
+const ImageFromJson = GObject.registerClass({
+ GTypeName: `${UUID}-ImageFromJson`,
+ contentType: 'image/svg+xml',
+}, class ImageFromJson extends Image {
+ get bytes() {
+ return this._bytes;
+ }
+
+ set bytes(bytes) {
+ this._bytes = bytes;
+ }
+});
+
+
+
+// Wrapper around a json file (drawing saves).
+export const Json = new GObject.registerClass({
+ GTypeName: `${UUID}-Json`,
+}, class Json extends GObject.Object {
+ _init(extension, params) {
+ this._extension = extension;
+ for (let key in params)
+ this[key] = params[key];
+ }
+
+ get isPersistent() {
+ // Safety check for GNOME 49+ compatibility
+ if (!this._extension || !this._extension.metadata) {
+ return false;
+ }
+ return this.name == this._extension.metadata['persistent-file-name'];
+ }
+
+ toString() {
+ return this.displayName || this.name;
+ }
+
+ delete() {
+ this.file.delete(null);
+ }
+
+ get file() {
+ if (!this._file)
+ this._file = Gio.File.new_for_path(GLib.build_filenamev([GLib.get_user_data_dir(), this._extension.metadata['data-dir'], `${this.name}.json`]));
+ return this._file;
+ }
+
+ set file(file) {
+ this._file = file;
+ }
+
+ get contents() {
+ if (this._contents === undefined) {
+ try {
+ [, this._contents] = this.file.load_contents(null);
+ if (this._contents instanceof Uint8Array)
+ this._contents = new TextDecoder('utf-8').decode(this._contents);
+ } catch (e) {
+ this._contents = null;
+ }
+ }
+
+ return this._contents;
+ }
+
+ set contents(contents) {
+ if (this.isPersistent && (this.contents == contents || !this.contents && contents == '[]'))
+ return;
+
+ try {
+ this.file.replace_contents(contents, null, false, Gio.FileCreateFlags.NONE, null);
+ } catch (e) {
+ this.file.get_parent().make_directory_with_parents(null);
+ this.file.replace_contents(contents, null, false, Gio.FileCreateFlags.NONE, null);
+ }
+
+ this._contents = contents;
+ }
+
+ addSvgContents(getGiconSvgContent, getImageSvgContent) {
+ let giconSvgBytes = new GLib.Bytes(getGiconSvgContent());
+ this.gicon = Gio.BytesIcon.new(giconSvgBytes);
+ this.getImageSvgBytes = () => new GLib.Bytes(getImageSvgContent());
+ }
+
+ get image() {
+ if (!this._image)
+ this._image = new ImageFromJson({ bytes: this.getImageSvgBytes(), gicon: this.gicon, displayName: this.displayName });
+
+ return this._image;
+ }
+});
+
+
+
+
+export function getDateString() {
+ let date = GLib.DateTime.new_now_local();
+ return `${date.format("%F")} ${date.format("%T")}`;
+}
+
+
+
+export class Files {
+
+ constructor(extension) {
+ this._extension = extension;
+ this.ICONS = new Icons(extension);
+ this.IMAGES = new Images(extension);
+ this.JSONS = new Jsons(extension);
+ }
+
+ saveSvg(content) {
+ let filename = `${this._extension.metadata['svg-file-name']} ${getDateString()}.svg`;
+ let dir = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES);
+ let path = GLib.build_filenamev([dir, filename]);
+ let file = Gio.File.new_for_path(path);
+ if (file.query_exists(null))
+ return false;
+
+ try {
+ return file.replace_contents(content, null, false, Gio.FileCreateFlags.NONE, null)[0];
+ } catch (e) {
+ return false;
+ }
+ }
+}
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/gimpPaletteParser.js b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/gimpPaletteParser.js
new file mode 100644
index 0000000..b7c3335
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/gimpPaletteParser.js
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2019 Abakkk
+ * Copyright 2024 Dave Prowse
+ *
+ * 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 .
+ *
+ * SPDX-FileCopyrightText: 2019 Abakkk
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileContributor: Modified by Dave Prowse
+ */
+
+/* jslint esversion: 6 (2019) */
+/* eslint version: 9.16 (2024) */
+/* exported parseFile */
+
+
+
+
+/*
+ * [
+ * [
+ * 'palette name 1', // a palette for each column
+ * [
+ * 'rgb(...)',
+ * 'rgb(...):color display name', // the optional name separated with ':'
+ * ...
+ * ]
+ * ],
+ * [
+ * 'palette name 2',
+ * [...]
+ * ],
+ * ...
+ * ]
+*/
+
+function parse(contents) {
+ let lines = contents.split('\n');
+ let line, name, columnNumber;
+
+ line = lines.shift();
+ if (!line || !line.startsWith('GIMP Palette'))
+ console.error("Missing magic header");
+
+ line = lines.shift();
+ if (line.startsWith('Name:')) {
+ name = line.slice(5).trim() || file.get_basename();
+ line = lines.shift();
+ }
+ if (line.startsWith('Columns:')) {
+ columnNumber = Number(line.slice(8).trim()) || 1;
+ line = lines.shift();
+ }
+
+ let columns = (new Array(columnNumber)).fill(null).map(() => []);
+
+ lines.forEach((line, index) => {
+ if (!line || line.startsWith('#'))
+ return;
+
+ line = line.split('#')[0].trim();
+
+ let [, color, displayName] = line.split(/(^[\d\s]+)/);
+
+ let values = color.trim().split(/\D+/gi).filter(value => value >= 0 && value <= 255);
+ if (values.length < 3)
+ return;
+
+ let string = `rgb(${values[0]},${values[1]},${values[2]})`;
+ if (displayName.trim())
+ string += `:${displayName.trim()}`;
+
+ columns[index % columns.length].push(string);
+ });
+
+ return columns.map((column, index) => [columnNumber > 1 ? `${name} ${index + 1}` : name, column]);
+}
+
+export function parseFile(file) {
+ const decoder = new TextDecoder('utf-8');
+ if (!file.query_exists(null))
+ return [];
+
+ let [, contents] = file.load_contents(null);
+ if (contents instanceof Uint8Array)
+ contents = decoder.decode(contents);
+
+ return parse(contents);
+}
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/helper.js b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/helper.js
new file mode 100644
index 0000000..31a80f6
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/helper.js
@@ -0,0 +1,228 @@
+/*
+ * Copyright 2019 Abakkk
+ * Copyright 2024 Dave Prowse
+ *
+ * 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 .
+ *
+ * SPDX-FileCopyrightText: 2019 Abakkk
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileContributor: Modified by Dave Prowse
+ */
+
+/* jslint esversion: 6 (2019) */
+/* eslint version: 9.16 (2024) */
+/* exported DrawingHelper */
+
+import Clutter from 'gi://Clutter';
+
+import St from 'gi://St';
+import GObject from 'gi://GObject';
+import * as Shortcuts from './shortcuts.js';
+import { gettext as _ } from 'resource:///org/gnome/shell/extensions/extension.js';
+
+import { CURATED_UUID as UUID } from './utils.js';
+import { SHELL_MAJOR_VERSION } from './utils.js';
+
+import GLib from 'gi://GLib';
+
+
+const HELPER_ANIMATION_TIME = 0.25;
+
+// DrawingHelper provides the "help osd" (Ctrl + F1)
+// It uses the same texts as in prefs
+//TODO: Review this class later
+export const DrawingHelper = GObject.registerClass({
+ GTypeName: `${UUID}-DrawingHelper`,
+}, class DrawingHelper extends St.ScrollView {
+
+ _init(extension, params, monitor) {
+ params.style_class = 'osd-window draw-on-gnome-helper';
+ super._init(params);
+ this._extension = extension;
+ this.monitor = monitor;
+ this.hide();
+
+ this.settingsHandler = this._extension.settings.connect('changed', this._onSettingsChanged.bind(this));
+ this.internalShortcutsettingsHandler = this._extension.internalShortcutSettings.connect('changed', this._onSettingsChanged.bind(this));
+ this.connect('destroy', () => {
+ this._extension.settings.disconnect(this.settingsHandler);
+ this._extension.internalShortcutSettings.disconnect(this.internalShortcutsettingsHandler);
+ });
+ }
+
+ _onSettingsChanged(settings, key) {
+ if (key == 'toggle-help')
+ this._updateHelpKeyLabel();
+
+ if (this.vbox) {
+ this.vbox.destroy();
+ delete this.vbox;
+ }
+ }
+
+ _updateHelpKeyLabel() {
+ try {
+ this._helpKeyLabel = this._extension.internalShortcutSettings.get_strv('toggle-help')[0];
+ } catch(e) {
+ logError(e);
+ this._helpKeyLabel = " ";
+ }
+ }
+
+ get helpKeyLabel() {
+ if (!this._helpKeyLabel)
+ this._updateHelpKeyLabel();
+
+ return GLib.markup_escape_text(this._helpKeyLabel, -1);
+ }
+
+ _populate() {
+ this.vbox = new St.BoxLayout({ vertical: true });
+ this.add_child(this.vbox);
+ this.vbox.add_child(new St.Label({ text: _("Global") }));
+
+ Shortcuts.GLOBAL_KEYBINDINGS.forEach((settingKeys) => {
+ this.vbox.add_child(new St.BoxLayout({ vertical: false, style_class: 'draw-on-gnome-helper-separator' }));
+
+ if (!this._extension.settings.get_strv(settingKeys)[0])
+ return;
+
+ let hbox = new St.BoxLayout({ vertical: false });
+ let shortcut = this._extension.settings.get_strv(settingKeys)[0];
+ // Convert modifier keys
+ shortcut = shortcut.replace(//g, 'Ctrl+')
+ .replace(//g, 'Shift+')
+ .replace(//g, 'Alt+')
+ .replace(//g, 'Super+')
+ // Remove KP_ prefix (numpad keys)
+ .replace(/KP_/g, '')
+ // Convert symbol names to actual symbols
+ .replace(/equal/g, '=')
+ .replace(/Multiply/g, '*')
+ .replace(/Divide/g, '/')
+ .replace(/Add/g, '+')
+ .replace(/Subtract/g, '-')
+ .replace(/period/g, '.')
+ .replace(/comma/g, ',')
+ .replace(/slash/g, '/')
+ .replace(/minus/g, '-')
+ .replace(/plus/g, '+')
+ .replace(/asterisk/g, '*')
+ // Uppercase single letters after + or at start
+ .replace(/\+([a-z])$/g, (match, letter) => '+' + letter.toUpperCase())
+ .replace(/^([a-z])$/g, (match, letter) => letter.toUpperCase());
+ shortcut = GLib.markup_escape_text(shortcut, -1);
+ hbox.add_child(new St.Label({ text: this._extension.settings.settings_schema.get_key(settingKeys).get_summary() }));
+ let label = new St.Label({ text: "" + shortcut + "", x_expand: true })
+ label.get_clutter_text().set_use_markup(true);
+ hbox.add_child(label);
+ this.vbox.add_child(hbox);
+ });
+
+ this.vbox.add_child(new St.BoxLayout({ vertical: false, style_class: 'draw-on-gnome-helper-separator' }));
+ this.vbox.add_child(new St.Label({ text: _("Internal") }));
+
+ // Shortcuts.OTHERS.forEach((pairs, index) => {
+ // if (index)
+ // this.vbox.add_child(new St.BoxLayout({ vertical: false, style_class: 'draw-on-gnome-helper-separator' }));
+
+ // pairs.forEach(pair => {
+ // let [action, shortcut] = pair;
+ // let hbox = new St.BoxLayout({ vertical: false });
+ // hbox.add_child(new St.Label({ text: action }));
+ // hbox.add_child(new St.Label({ text: shortcut, x_expand: true }).get_clutter_text().set_use_markup(true));
+
+ // hbox.get_children()[0]);
+ // this.vbox.add_child(hbox);
+ // });
+ // });
+
+ // this.vbox.add_child(new St.BoxLayout({ vertical: false, style_class: 'draw-on-gnome-helper-separator' }));
+
+ Shortcuts.INTERNAL_KEYBINDINGS.forEach((settingKeys) => {
+ this.vbox.add_child(new St.BoxLayout({ vertical: false, style_class: 'draw-on-gnome-helper-separator' }));
+
+ if (!this._extension.internalShortcutSettings.get_strv(settingKeys)[0])
+ return;
+
+ let hbox = new St.BoxLayout({ vertical: false });
+ let shortcut = this._extension.internalShortcutSettings.get_strv(settingKeys)[0];
+ // Convert modifier keys
+ shortcut = shortcut.replace(//g, 'Ctrl+')
+ .replace(//g, 'Shift+')
+ .replace(//g, 'Alt+')
+ .replace(//g, 'Super+')
+ // Remove KP_ prefix (numpad keys)
+ .replace(/KP_/g, '')
+ // Convert symbol names to actual symbols
+ .replace(/equal/g, '=')
+ .replace(/Multiply/g, '*')
+ .replace(/Divide/g, '/')
+ .replace(/Add/g, '+')
+ .replace(/Subtract/g, '-')
+ .replace(/period/g, '.')
+ .replace(/comma/g, ',')
+ .replace(/slash/g, '/')
+ .replace(/minus/g, '-')
+ .replace(/plus/g, '+')
+ .replace(/asterisk/g, '*')
+ // Uppercase single letters after + or at start
+ .replace(/\+([a-z])$/g, (match, letter) => '+' + letter.toUpperCase())
+ .replace(/^([a-z])$/g, (match, letter) => letter.toUpperCase());
+ shortcut = GLib.markup_escape_text(shortcut, -1);
+ hbox.add_child(new St.Label({ text: this._extension.internalShortcutSettings.settings_schema.get_key(settingKeys).get_summary() }));
+ let label = new St.Label({ text: "" + shortcut + "", x_expand: true })
+ label.get_clutter_text().set_use_markup(true);
+ hbox.add_child(label);
+ this.vbox.add_child(hbox);
+ });
+ }
+
+ showHelp() {
+ if (!this.vbox)
+ this._populate();
+
+ this.opacity = 0;
+ this.show();
+
+ let maxHeight = this.monitor.height * 3 / 4;
+ this.set_height(Math.min(this.height, maxHeight));
+ this.set_position(Math.floor(this.monitor.width / 2 - this.width / 2),
+ Math.floor(this.monitor.height / 2 - this.height / 2));
+
+ // St.PolicyType: GS 3.32+
+ if (this.height == maxHeight)
+ this.vscrollbar_policy = St.PolicyType ? St.PolicyType.ALWAYS : 1;
+ else
+ this.vscrollbar_policy = St.PolicyType ? St.PolicyType.NEVER : 0;
+
+ this.remove_all_transitions();
+ this.ease({
+ opacity: 255,
+ duration: HELPER_ANIMATION_TIME * 1000,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD
+ });
+ }
+
+ hideHelp() {
+ this.remove_all_transitions();
+ this.ease({
+ opacity: 0,
+ duration: HELPER_ANIMATION_TIME * 1000,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ onComplete: () => this.hide()
+ });
+ }
+});
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/de/LC_MESSAGES/draw-on-gnome.mo b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/de/LC_MESSAGES/draw-on-gnome.mo
new file mode 100644
index 0000000..2301124
Binary files /dev/null and b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/de/LC_MESSAGES/draw-on-gnome.mo differ
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/es_ES/LC_MESSAGES/draw-on-gnome.mo b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/es_ES/LC_MESSAGES/draw-on-gnome.mo
new file mode 100644
index 0000000..cc33b4e
Binary files /dev/null and b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/es_ES/LC_MESSAGES/draw-on-gnome.mo differ
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/es_MX/LC_MESSAGES/draw-on-gnome.mo b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/es_MX/LC_MESSAGES/draw-on-gnome.mo
new file mode 100644
index 0000000..cc33b4e
Binary files /dev/null and b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/es_MX/LC_MESSAGES/draw-on-gnome.mo differ
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/fr/LC_MESSAGES/draw-on-gnome.mo b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/fr/LC_MESSAGES/draw-on-gnome.mo
new file mode 100644
index 0000000..77868fc
Binary files /dev/null and b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/fr/LC_MESSAGES/draw-on-gnome.mo differ
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/it_IT/LC_MESSAGES/draw-on-gnome.mo b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/it_IT/LC_MESSAGES/draw-on-gnome.mo
new file mode 100644
index 0000000..ff88d15
Binary files /dev/null and b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/it_IT/LC_MESSAGES/draw-on-gnome.mo differ
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/nl/LC_MESSAGES/draw-on-gnome.mo b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/nl/LC_MESSAGES/draw-on-gnome.mo
new file mode 100644
index 0000000..1508736
Binary files /dev/null and b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/nl/LC_MESSAGES/draw-on-gnome.mo differ
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/pt_BR/LC_MESSAGES/draw-on-gnome.mo b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/pt_BR/LC_MESSAGES/draw-on-gnome.mo
new file mode 100644
index 0000000..09d3359
Binary files /dev/null and b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/pt_BR/LC_MESSAGES/draw-on-gnome.mo differ
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/ru/LC_MESSAGES/draw-on-gnome.mo b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/ru/LC_MESSAGES/draw-on-gnome.mo
new file mode 100644
index 0000000..930b694
Binary files /dev/null and b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/ru/LC_MESSAGES/draw-on-gnome.mo differ
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/zh_CN/LC_MESSAGES/draw-on-gnome.mo b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/zh_CN/LC_MESSAGES/draw-on-gnome.mo
new file mode 100644
index 0000000..738a06f
Binary files /dev/null and b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/locale/zh_CN/LC_MESSAGES/draw-on-gnome.mo differ
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/menu.js b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/menu.js
new file mode 100644
index 0000000..f304af8
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/menu.js
@@ -0,0 +1,1026 @@
+/*
+ * Copyright 2019 Abakkk
+ * Copyright 2024 Dave Prowse
+ *
+ * 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 .
+ *
+ * SPDX-FileCopyrightText: 2019 Abakkk
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileContributor: Modified by Dave Prowse
+ */
+
+/* jslint esversion: 6 (2019) */
+/* eslint version: 9.16 (2024) */
+
+import Clutter from 'gi://Clutter';
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
+import St from 'gi://St';
+
+import * as BoxPointer from 'resource:///org/gnome/shell/ui/boxpointer.js';
+import * as Dash from 'resource:///org/gnome/shell/ui/dash.js';
+import * as Main from 'resource:///org/gnome/shell/ui/main.js';
+import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
+import * as Slider from 'resource:///org/gnome/shell/ui/slider.js';
+
+import {gettext as _, pgettext} from 'resource:///org/gnome/shell/extensions/extension.js';
+
+import { CURATED_UUID as UUID, SHELL_MAJOR_VERSION } from './utils.js';
+
+// 150 labels with font-family style take ~15Mo
+const FONT_FAMILY_STYLE = true;
+// use 'login-dialog-message-warning' class in order to get GS theme warning color (default: #f57900)
+const WARNING_COLOR_STYLE_CLASS_NAME = 'login-dialog-message-warning';
+
+
+
+
+// Used by both menu and osd notifications.
+export const DisplayStrings = {
+ getDashedLine: function(dashed) {
+ return dashed ? _("Dashed line") :
+ // Translators: as the alternative to "Dashed line"
+ _("Full line");
+ },
+
+ getFill: function(fill) {
+ return fill ? _("Fill") :
+ // Translators: as the alternative to "Fill"
+ _("Outline");
+ },
+
+ get FillRule() {
+ if (!this._FillRule)
+ // Translators: fill-rule SVG attribute
+ this._FillRule = { 0: _("Nonzero"), 1: _("Evenodd") };
+ return this._FillRule;
+ },
+
+ getFontFamily: function(family) {
+ if (!this._FontGenericFamily)
+ // Translators: generic font-family SVG attribute
+ this._FontGenericFamily = { 'Sans-Serif': pgettext("font-family", "Sans-Serif"), 'Serif': pgettext("font-family", "Serif"),
+ 'Monospace': pgettext("font-family", "Monospace"), 'Cursive': pgettext("font-family", "Cursive"),
+ 'Fantasy': pgettext("font-family", "Fantasy") };
+ return this._FontGenericFamily[family] || family;
+ },
+
+ get FontStyle() {
+ if (!this._FontStyle)
+ // Translators: font-style SVG attribute
+ this._FontStyle = { 0: pgettext("font-style", "Normal"), 1: pgettext("font-style", "Oblique"), 2: pgettext("font-style", "Italic") };
+ return this._FontStyle;
+ },
+
+ FontStyleMarkup: { 0: 'normal', 1: 'oblique', 2: 'italic' },
+
+ get FontWeight() {
+ if (!this._FontWeight)
+ // Translators: font-weight SVG attribute
+ this._FontWeight = { 100: pgettext("font-weight", "Thin"), 200: pgettext("font-weight", "Ultra Light"), 300: pgettext("font-weight", "Light"),
+ 350: pgettext("font-weight", "Semi Light"), 380: pgettext("font-weight", "Book"), 400: pgettext("font-weight", "Normal"),
+ 500: pgettext("font-weight", "Medium"), 600: pgettext("font-weight", "Semi Bold"), 700: pgettext("font-weight", "Bold"),
+ 800: pgettext("font-weight", "Ultra Bold"), 900: pgettext("font-weight", "Heavy"), 1000: pgettext("font-weight", "Ultra Heavy") };
+ return this._FontWeight;
+ },
+
+ get LineCap() {
+ if (!this._LineCap)
+ // Translators: stroke-linecap SVG attribute
+ this._LineCap = { 0: pgettext("stroke-linecap", "Butt"), 1: pgettext("stroke-linecap", "Round"), 2: pgettext("stroke-linecap", "Square") };
+ return this._LineCap;
+ },
+
+ get LineJoin() {
+ if (!this._LineJoin)
+ // Translators: stroke-linejoin SVG attribute
+ this._LineJoin = { 0: pgettext("stroke-linejoin", "Miter"), 1: pgettext("stroke-linejoin", "Round"), 2: pgettext("stroke-linejoin", "Bevel") };
+ return this._LineJoin;
+ },
+
+ getPixels(value) {
+ // Translators: value in pixel unit (e.g. "5 px")
+ return _("%f px").format(value);
+ },
+
+ get TextAlignment() {
+ // Translators: text alignment
+ if (!this._TextAlignment)
+ this._TextAlignment = { 0: _("Left aligned"), 1: _("Centered"), 2: _("Right aligned") };
+
+ return this._TextAlignment;
+ },
+
+ get Tool() {
+ if (!this._Tool)
+ this._Tool = { 0: pgettext("drawing-tool", "Free drawing"),
+ 1: pgettext("drawing-tool", "Line"),
+ 2: pgettext("drawing-tool", "Ellipse"),
+ 3: pgettext("drawing-tool", "Rectangle"),
+ 4: pgettext("drawing-tool", "Text"),
+ 5: pgettext("drawing-tool", "Polygon"),
+ 6: pgettext("drawing-tool", "Polyline"),
+ 7: pgettext("drawing-tool", "Image"),
+ 8: pgettext("drawing-tool", "Arrow"),
+ 9: pgettext("drawing-tool", "Laser Pointer"),
+ 10: pgettext("drawing-tool", "Highlighter"),
+ 100: pgettext("drawing-tool", "Move"),
+ 101: pgettext("drawing-tool", "Resize"),
+ 102: pgettext("drawing-tool", "Mirror") };
+ return this._Tool;
+ }
+};
+
+
+export const DrawingMenu = GObject.registerClass({
+ GTypeName: `${UUID}-DrawingMenu`,
+}, class DrawingMenu extends GObject.Object {
+ _init(extension, area, monitor, DrawingTool, areaManagerUtils) {
+ super._init({});
+ this._extension = extension;
+ this.area = area;
+ this.monitor = monitor;
+ this.DrawingTool = DrawingTool;
+ this.areaManagerUtils = areaManagerUtils;
+
+ let side = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL ? St.Side.RIGHT : St.Side.LEFT;
+ this.menu = new PopupMenu.PopupMenu(Main.layoutManager.dummyCursor, 0.25, side);
+ this.menuManager = new PopupMenu.PopupMenuManager(SHELL_MAJOR_VERSION >= 3 ? { actor: this.area } : this.area);
+ this.menuManager.addMenu(this.menu);
+
+ Main.layoutManager.uiGroup.add_child(this.menu.actor);
+
+ this.menu.actor.add_style_class_name('background-menu draw-on-gnome-menu');
+ this.menu.actor.hide();
+ this.hasSeparators = monitor.height >= 750;
+
+ // do not close the menu on item activated
+ this.menu.itemActivated = () => {};
+ this.menu.connect('open-state-changed', this._onMenuOpenStateChanged.bind(this));
+
+ // Case where the menu is closed (escape key) while the save entry clutter_text is active:
+ // St.Entry clutter_text set the DEFAULT cursor on leave event with a delay and
+ // overrides the cursor set by area.updatePointerCursor().
+ // In order to update drawing cursor on menu closed, we need to leave the saveEntry before closing menu.
+ // Since escape key press event can't be captured easily, the job is done in the menu close function.
+ let menuCloseFunc = this.menu.close;
+ this.menu.close = (animate) => {
+ if (this.saveDrawingSubMenu && this.saveDrawingSubMenu.isOpen)
+ this.saveDrawingSubMenu.close();
+ menuCloseFunc.bind(this.menu)(animate);
+ };
+ }
+
+ disable() {
+ delete this.area;
+ delete this.DrawingTool;
+ delete this.areaManagerUtils;
+ this.menuManager.removeMenu(this.menu);
+ Main.layoutManager.uiGroup.remove_child(this.menu.actor);
+ this.menu.destroy();
+ }
+
+ _onMenuOpenStateChanged(menu, open) {
+ if (open) {
+ this.area.setPointerCursor('DEFAULT');
+ } else {
+ this.area.updatePointerCursor();
+ this.area.grab_key_focus();
+ }
+
+ let workArea = Main.layoutManager.getWorkAreaForMonitor(this.monitor.index);
+ let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
+ let maxHeight = Math.round(workArea.height / scaleFactor);
+ this.menu.actor.set_style(`max-height:${maxHeight}px;`);
+ }
+
+ popup() {
+ if (this.menu.isOpen) {
+ this.close();
+ } else {
+ this.open();
+ this.menu.actor.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
+ }
+ }
+
+ open(x, y) {
+ if (this.menu.isOpen)
+ return;
+ if (x === undefined || y === undefined)
+ [x, y] = [this.area.monitor.x + this.area.monitor.width / 2, this.area.monitor.y + this.area.monitor.height / 2];
+ this._redisplay();
+ Main.layoutManager.setDummyCursorGeometry(x, y, 0, 0);
+ let monitor = this.area.monitor;
+ this.menu._arrowAlignment = (y - monitor.y) / monitor.height;
+ this.menu.open(BoxPointer.PopupAnimation.NONE);
+ this.menuManager.ignoreRelease();
+ }
+
+ close() {
+ if (this.menu.isOpen)
+ this.menu.close();
+ }
+
+ _redisplay() {
+ this.menu.removeAll();
+
+ let groupItem = new PopupMenu.PopupBaseMenuItem({ reactive: false, can_focus: false, style_class: 'draw-on-gnome-menu-group-item' });
+ this.undoButton = new ActionButton(this._getSummary('undo'), 'edit-undo-symbolic', this.area.undo.bind(this.area), this._updateActionSensitivity.bind(this));
+ this.redoButton = new ActionButton(this._getSummary('redo'), 'edit-redo-symbolic', this.area.redo.bind(this.area), this._updateActionSensitivity.bind(this));
+ this.eraseButton = new ActionButton(_("Erase"), 'edit-clear-all-symbolic', this.area.deleteLastElement.bind(this.area), this._updateActionSensitivity.bind(this));
+ this.smoothButton = new ActionButton(_("Smooth"), this._extension.FILES.ICONS.SMOOTH, this.area.smoothLastElement.bind(this.area), this._updateActionSensitivity.bind(this));
+
+ // Add hover colors - Top row
+ this.undoButton.setHoverColor('orange');
+ this.redoButton.setHoverColor('green');
+ this.eraseButton.child.add_style_class_name('draw-on-gnome-menu-destructive-button');
+ this.smoothButton.setHoverColor('cyan');
+
+ this._getActor(groupItem).add_child(this.undoButton);
+ this._getActor(groupItem).add_child(this.redoButton);
+ this._getActor(groupItem).add_child(this.eraseButton);
+ this._getActor(groupItem).add_child(this.smoothButton);
+ this.menu.addMenuItem(groupItem);
+ this._addSeparator(this.menu, true);
+
+ this.toolItem = this._addToolSubMenuItem(this.menu, this._updateSectionVisibility.bind(this));
+ this.paletteItem = this._addPaletteSubMenuItem(this.menu, this._extension.FILES.ICONS.PALETTE);
+ this.colorItem = this._addColorSubMenuItem(this.menu, this._extension.FILES.ICONS.COLOR);
+ this.fillItem = this._addSwitchItem(this.menu, DisplayStrings.getFill(true), this._extension.FILES.ICONS.STROKE, this._extension.FILES.ICONS.FILL, this.area, 'fill', this._updateSectionVisibility.bind(this));
+ this.fillSection = new PopupMenu.PopupMenuSection();
+ this.fillSection.itemActivated = () => {};
+ this.fillRuleItem = this._addSwitchItem(this.fillSection, DisplayStrings.FillRule[1], this._extension.FILES.ICONS.FILLRULE_NONZERO, this._extension.FILES.ICONS.FILLRULE_EVENODD, this.area, 'currentEvenodd');
+ this.menu.addMenuItem(this.fillSection);
+ this._addSeparator(this.menu);
+
+ let lineSection = new PopupMenu.PopupMenuSection();
+ this._addSliderItem(lineSection, this.area, 'currentLineWidth');
+ this._addSubMenuItem(lineSection, this._extension.FILES.ICONS.LINEJOIN, DisplayStrings.LineJoin, this.area, 'currentLineJoin');
+ this._addSubMenuItem(lineSection, this._extension.FILES.ICONS.LINECAP, DisplayStrings.LineCap, this.area, 'currentLineCap');
+ this._addSwitchItem(lineSection, DisplayStrings.getDashedLine(true), this._extension.FILES.ICONS.FULL_LINE, this._extension.FILES.ICONS.DASHED_LINE, this.area, 'dashedLine');
+ this._addSeparator(lineSection);
+ this.menu.addMenuItem(lineSection);
+ lineSection.itemActivated = () => {};
+ this.lineSection = lineSection;
+
+ let fontSection = new PopupMenu.PopupMenuSection();
+ this._addFontFamilySubMenuItem(fontSection, this._extension.FILES.ICONS.FONT_FAMILY);
+ this._addSubMenuItem(fontSection, this._extension.FILES.ICONS.FONT_WEIGHT, DisplayStrings.FontWeight, this.area, 'currentFontWeight');
+ this._addSubMenuItem(fontSection, this._extension.FILES.ICONS.FONT_STYLE, DisplayStrings.FontStyle, this.area, 'currentFontStyle');
+ this._addTextAlignmentSubMenuItem(fontSection);
+ this._addSeparator(fontSection);
+ this.menu.addMenuItem(fontSection);
+ fontSection.itemActivated = () => {};
+ this.fontSection = fontSection;
+
+ let imageSection = new PopupMenu.PopupMenuSection();
+ this.imageItem = this._addImageSubMenuItem(imageSection);
+ this._addSeparator(imageSection);
+ this.menu.addMenuItem(imageSection);
+ imageSection.itemActivated = () => {};
+ this.imageSection = imageSection;
+
+ this._addSimpleSwitchItem(this.menu, this._getSummary('toggle-panel-and-dock-visibility'), !!this.areaManagerUtils.getHiddenList(), this.areaManagerUtils.togglePanelAndDockOpacity);
+ this._addSimpleSwitchItem(this.menu, this._getSummary('toggle-background'), this.area.hasBackground, this.area.toggleBackground.bind(this.area));
+ this._addSimpleSwitchItem(this.menu, this._getSummary('toggle-grid'), this.area.hasGrid, this.area.toggleGrid.bind(this.area));
+ this._addSimpleSwitchItem(this.menu, this._getSummary('toggle-square-area'), this.area.isSquareArea, this.area.toggleSquareArea.bind(this.area));
+ this._addSeparator(this.menu);
+
+ this._addDrawingNameItem(this.menu);
+ this._addOpenDrawingSubMenuItem(this.menu, _("Open drawing"), 'document-open-symbolic');
+ this._addSaveDrawingSubMenuItem(this.menu, _("Save drawing asβ¦"), 'document-save-as-symbolic');
+ this._addSeparator(this.menu);
+
+ groupItem = new PopupMenu.PopupBaseMenuItem({ reactive: false, can_focus: false, style_class: 'draw-on-gnome-menu-group-item' });
+ this.saveButton = new ActionButton(this._getSummary('save-as-json'), 'document-save-symbolic', this.area.saveAsJson.bind(this.area, false, this._onDrawingSaved.bind(this)), null);
+ this.svgButton = new ActionButton(this._getSummary('export-to-svg'), this._extension.FILES.ICONS.DOCUMENT_EXPORT, this.area.exportToSvg.bind(this.area), null);
+ this.prefsButton = new ActionButton(this._getSummary('open-preferences'), 'document-page-setup-symbolic', this.areaManagerUtils.openPreferences, null);
+ this.helpButton = new ActionButton(this._getSummary('toggle-help'), 'preferences-desktop-keyboard-shortcuts-symbolic', () => { this.close(); this.area.toggleHelp(); }, null);
+
+ // Add hover colors - Bottom row
+ this.saveButton.setHoverColor('blue');
+ this.svgButton.setHoverColor('purple');
+ this.prefsButton.setHoverColor('red');
+ this.helpButton.setHoverColor('yellow');
+
+ this._getActor(groupItem).add_child(this.saveButton);
+ this._getActor(groupItem).add_child(this.svgButton);
+ this._getActor(groupItem).add_child(this.prefsButton);
+ this._getActor(groupItem).add_child(this.helpButton);
+ this.menu.addMenuItem(groupItem);
+
+ this._updateActionSensitivity();
+ this._updateSectionVisibility();
+ }
+
+ _updateActionSensitivity() {
+ this.undoButton.child.reactive = this.area.elements.length > 0;
+ this.redoButton.child.reactive = this.area.undoneElements.length > 0 || (this.area.elements.length && this.area.elements[this.area.elements.length - 1].canUndo);
+ this.eraseButton.child.reactive = this.area.elements.length > 0;
+ this.smoothButton.child.reactive = this.area.elements.length > 0 && this.area.elements[this.area.elements.length - 1].shape == this.DrawingTool.NONE;
+ this.saveButton.child.reactive = this.area.elements.length > 0;
+ this.svgButton.child.reactive = this.area.elements.length > 0;
+ this.saveDrawingSubMenuItem.setSensitive(this.area.elements.length > 0);
+ }
+
+ _updateSectionVisibility() {
+ let [isText, isImage] = [this.area.currentTool == this.DrawingTool.TEXT, this.area.currentTool == this.DrawingTool.IMAGE];
+ this.lineSection.actor.visible = !isText && !isImage;
+ this.fontSection.actor.visible = isText;
+ this.imageSection.actor.visible = isImage;
+ this.fillItem.setSensitive(!isText && !isImage);
+ this.fillSection.setSensitive(!isText && !isImage);
+
+ if (this.area.fill)
+ this.fillSection.actor.show();
+ else
+ this.fillSection.actor.hide();
+ }
+
+ _addSwitchItem(menu, label, iconFalse, iconTrue, target, targetProperty, onToggled) {
+ let item = new PopupMenu.PopupSwitchMenuItem(label, target[targetProperty]);
+
+ item.icon = new St.Icon({ style_class: 'popup-menu-icon' });
+ this._getActor(item).insert_child_at_index(item.icon, 1);
+ let icon = target[targetProperty] ? iconTrue : iconFalse;
+ if (icon)
+ item.icon.set_gicon(icon);
+
+ item.connect('toggled', (item, state) => {
+ target[targetProperty] = state;
+ let icon = target[targetProperty] ? iconTrue : iconFalse;
+ if (icon)
+ item.icon.set_gicon(icon);
+ if (onToggled)
+ onToggled();
+ });
+ menu.addMenuItem(item);
+ return item;
+ }
+
+ _addSimpleSwitchItem(menu, label, active, onToggled) {
+ let item = new PopupMenu.PopupSwitchMenuItem(label, active);
+ item.connect('toggled', onToggled);
+ menu.addMenuItem(item);
+ }
+
+ _addSliderItem(menu, target, targetProperty) {
+ let item = new PopupMenu.PopupBaseMenuItem({ activate: false });
+ let label = new St.Label({ text: DisplayStrings.getPixels(target[targetProperty]), style_class: 'draw-on-gnome-menu-slider-label' });
+ let slider = new Slider.Slider(target[targetProperty] / 50);
+
+ // In GNOME 40+, the signal changed from 'value-changed' to 'notify::value'
+ if (SHELL_MAJOR_VERSION >= 40) {
+ slider.connect('notify::value', () => {
+ target[targetProperty] = Math.max(Math.round(slider.value * 50), 1);
+ label.set_text(DisplayStrings.getPixels(target[targetProperty]));
+ this._extension.drawingSettings.set_int("tool-size", target[targetProperty]);
+ // No warning needed - minimum is now 1
+ label.remove_style_class_name(WARNING_COLOR_STYLE_CLASS_NAME);
+ });
+ } else {
+ slider.connect('value-changed', (slider, value, property) => {
+ target[targetProperty] = Math.max(Math.round(value * 50), 1);
+ label.set_text(DisplayStrings.getPixels(target[targetProperty]));
+ this._extension.drawingSettings.set_int("tool-size", target[targetProperty]);
+ // No warning needed - minimum is now 1
+ label.remove_style_class_name(WARNING_COLOR_STYLE_CLASS_NAME);
+ });
+ }
+
+ // Rest of the function continues here...
+ this._getActor(slider).x_expand = true;
+ this._getActor(item).add_child(this._getActor(slider));
+ this._getActor(item).add_child(label);
+ if (slider.onKeyPressEvent)
+ this._getActor(item).connect('key-press-event', slider.onKeyPressEvent.bind(slider));
+ menu.addMenuItem(item);
+ }
+
+ _addSubMenuItem(menu, icon, obj, target, targetProperty) {
+ let item = new PopupMenu.PopupSubMenuMenuItem(String(obj[target[targetProperty]]), icon ? true : false);
+
+ item.icon.set_gicon(icon);
+ item.menu.itemActivated = item.menu.close;
+
+ GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
+ Object.keys(obj).forEach(key => {
+ let text = targetProperty == 'currentFontWeight' ? `${obj[key]}` :
+ targetProperty == 'currentFontStyle' ? `${obj[key]}` :
+ String(obj[key]);
+
+ let subItem = item.menu.addAction(text, () => {
+ item.label.set_text(String(obj[key]));
+ target[targetProperty] = Number(key);
+ });
+
+ subItem.label.get_clutter_text().set_use_markup(true);
+ this._getActor(subItem).connect('key-focus-in', updateSubMenuAdjustment);
+ });
+ return GLib.SOURCE_REMOVE;
+ });
+
+ menu.addMenuItem(item);
+ }
+
+ _addToolSubMenuItem(menu, callback) {
+ let item = new PopupMenu.PopupSubMenuMenuItem('', true);
+ item.update = () => {
+ item.label.set_text(DisplayStrings.Tool[this.area.currentTool]);
+ let toolName = this.DrawingTool.getNameOf(this.area.currentTool);
+ item.icon.set_gicon(this._extension.FILES.ICONS[`TOOL_${toolName}`]);
+ };
+ item.update();
+
+ item.menu.itemActivated = item.menu.close;
+
+ GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
+ Object.keys(DisplayStrings.Tool).forEach(key => {
+ let text = DisplayStrings.Tool[key];
+ let toolName = this.DrawingTool.getNameOf(key);
+ let subItemIcon = this._extension.FILES.ICONS[`TOOL_${toolName}`];
+ let subItem = item.menu.addAction(text, () => {
+ this.area.currentTool = Number(key);
+ item.update();
+ callback();
+ }, subItemIcon);
+
+ subItem.label.get_clutter_text().set_use_markup(true);
+ this._getActor(subItem).connect('key-focus-in', updateSubMenuAdjustment);
+
+ // change the display order of tools
+ if (key == this.DrawingTool.POLYGON)
+ item.menu.moveMenuItem(subItem, Number(this.DrawingTool.TEXT));
+ else if (key == this.DrawingTool.POLYLINE)
+ item.menu.moveMenuItem(subItem, Number(this.DrawingTool.TEXT) + 1);
+ });
+ return GLib.SOURCE_REMOVE;
+ });
+
+ menu.addMenuItem(item);
+ return item;
+ }
+
+ _addPaletteSubMenuItem(menu, icon) {
+ let text = _(this.area.currentPalette[0] || "Palette");
+ let item = new PopupMenu.PopupSubMenuMenuItem(text, true);
+ item.icon.set_gicon(icon);
+
+ item.menu.itemActivated = item.menu.close;
+
+ GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
+ this.area.palettes.forEach(palette => {
+ let [name, colors] = palette;
+ if (!colors[0])
+ return;
+
+ let subItem = item.menu.addAction(_(name || "Palette"), () => {
+ item.label.set_text(_(name || "Palette"));
+ this.area.currentPalette = palette;
+ this._populateColorSubMenu();
+ });
+ this._getActor(subItem).connect('key-focus-in', updateSubMenuAdjustment);
+ });
+ return GLib.SOURCE_REMOVE;
+ });
+
+ menu.addMenuItem(item);
+ return item;
+ }
+
+ _addColorSubMenuItem(menu, icon) {
+ let item = new PopupMenu.PopupSubMenuMenuItem(_("Color"), true);
+ this.colorSubMenu = item.menu;
+ item.icon.set_gicon(icon);
+ item.icon.set_style(`color:${this.area.currentColor.to_string().slice(0, 7)};`);
+
+ if (SHELL_MAJOR_VERSION >= 3) {
+ let colorPickerCallback = () => {
+ this.close();
+ this.area.pickColor();
+ };
+ // Translators: It is displayed in a menu button tooltip or as a shortcut action description, so it should NOT use the imperative mood.
+ let colorPickerButton = new ActionButton(_("Pick a color"), this._extension.FILES.ICONS.COLOR_PICKER, colorPickerCallback, null, true);
+ let index = this._getActor(item).get_children().length - 1;
+ this._getActor(item).insert_child_at_index(colorPickerButton, index);
+ }
+
+ item.menu.itemActivated = item.menu.close;
+
+ this._populateColorSubMenu();
+ menu.addMenuItem(item);
+ return item;
+ }
+
+ _populateColorSubMenu() {
+ this.colorSubMenu.removeAll();
+ GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
+ this.area.colors.forEach(color => {
+ let text = String(color);
+ let subItem = this.colorSubMenu.addAction(text, () => {
+ this.area.currentColor = color;
+ this._extension.drawingSettings.set_string("tool-color", color.to_string());
+ this.colorItem.icon.set_style(`color:${color.to_string().slice(0, 7)};`);
+ });
+ // Foreground color markup is not displayed since 3.36, use style instead but the transparency is lost.
+ subItem.label.set_style(`color:${color.to_string().slice(0, 7)};`);
+ this._getActor(subItem).connect('key-focus-in', updateSubMenuAdjustment);
+ });
+ return GLib.SOURCE_REMOVE;
+ });
+ }
+
+ _addFontFamilySubMenuItem(menu, icon) {
+ let item = new PopupMenu.PopupSubMenuMenuItem(DisplayStrings.getFontFamily(this.area.currentFontFamily), true);
+ item.icon.set_gicon(icon);
+
+ item.menu.itemActivated = item.menu.close;
+ item.menu.actor.add_style_class_name('draw-on-gnome-menu-ellipsized');
+
+ item.menu.openOld = item.menu.open;
+ item.menu.open = (animate) => {
+ if (!item.menu.isOpen && item.menu.isEmpty()) {
+ this.area.fontFamilies.forEach(family => {
+ let subItem = item.menu.addAction(DisplayStrings.getFontFamily(family), () => {
+ item.label.set_text(DisplayStrings.getFontFamily(family));
+ this.area.currentFontFamily = family;
+ });
+
+ if (FONT_FAMILY_STYLE)
+ GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
+ subItem.label.set_style(`font-family:${family}`);
+ });
+
+ this._getActor(subItem).connect('key-focus-in', updateSubMenuAdjustment);
+ });
+ }
+ item.menu.openOld();
+ };
+
+ menu.addMenuItem(item);
+ }
+
+ _addTextAlignmentSubMenuItem(menu) {
+ let item = new PopupMenu.PopupSubMenuMenuItem(DisplayStrings.TextAlignment[this.area.currentTextAlignment], true);
+ const TextAlignmentIcon = { 0: this._extension.FILES.ICONS.LEFT_ALIGNED, 1: this._extension.FILES.ICONS.CENTERED, 2: this._extension.FILES.ICONS.RIGHT_ALIGNED };
+ item.icon.set_gicon(TextAlignmentIcon[this.area.currentTextAlignment]);
+
+ item.menu.itemActivated = item.menu.close;
+
+ GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
+ Object.keys(TextAlignmentIcon).forEach(key => {
+ let subItem = item.menu.addAction(DisplayStrings.TextAlignment[key], () => {
+ item.label.set_text(DisplayStrings.TextAlignment[key]);
+ this.area.currentTextAlignment = key;
+ item.icon.set_gicon(TextAlignmentIcon[key]);
+ });
+
+ this._getActor(subItem).connect('key-focus-in', updateSubMenuAdjustment);
+ });
+ return GLib.SOURCE_REMOVE;
+ });
+
+ menu.addMenuItem(item);
+ }
+
+ _addImageSubMenuItem(menu, images) {
+ let item = new PopupMenu.PopupSubMenuMenuItem('', true);
+ item.update = () => {
+ if (this.area.currentImage) { // null value. what consequences ?
+ item.label.set_text(this.area.currentImage.toString());
+ item.icon.set_gicon(this.area.currentImage.gicon);
+ }
+ };
+ item.update();
+
+ item.menu.itemActivated = item.menu.close;
+ item.menu.actor.add_style_class_name('draw-on-gnome-menu-ellipsized');
+
+ item.menu.openOld = item.menu.open;
+ item.menu.open = (animate) => {
+ if (!item.menu.isOpen && item.menu.isEmpty()) {
+ this._extension.FILES.IMAGES.getSorted().forEach(image => {
+ let subItem = item.menu.addAction(image.toString(), () => {
+ this.area.currentImage = image;
+ item.update();
+ }, this._extension.FILES.ICONS.FAKE);
+
+ GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
+ if (subItem.setIcon && image.thumbnailGicon)
+ subItem.setIcon(image.thumbnailGicon);
+ });
+
+ this._getActor(subItem).connect('key-focus-in', updateSubMenuAdjustment);
+ });
+ }
+ item.menu.openOld();
+ };
+
+ menu.addMenuItem(item);
+ return item;
+ }
+
+ _addDrawingNameItem(menu) {
+ this.drawingNameMenuItem = new PopupMenu.PopupMenuItem('', { reactive: false, activate: false });
+ this.drawingNameMenuItem.setSensitive(false);
+ this._getActor(this.drawingNameMenuItem).add_style_class_name('draw-on-gnome-menu-ellipsized');
+ menu.addMenuItem(this.drawingNameMenuItem);
+ this._updateDrawingNameMenuItem();
+ }
+
+ _updateDrawingNameMenuItem() {
+ this._getActor(this.drawingNameMenuItem).visible = this.area.currentJson ? true : false;
+ if (this.area.currentJson) {
+ let prefix = this.area.drawingContentsHasChanged ? "* " : "";
+ this.drawingNameMenuItem.label.set_text(`${prefix}${this.area.currentJson.name}`);
+ this.drawingNameMenuItem.label.get_clutter_text().set_use_markup(true);
+ }
+ }
+
+ _addOpenDrawingSubMenuItem(menu, label, icon) {
+ let item = new PopupMenu.PopupSubMenuMenuItem(label, true);
+ this.openDrawingSubMenuItem = item;
+ this.openDrawingSubMenu = item.menu;
+ item.setSensitive(Boolean(this._extension.FILES.JSONS.getSorted().length));
+ item.icon.set_icon_name(icon);
+
+ item.menu.itemActivated = item.menu.close;
+ item.menu.actor.add_style_class_name('draw-on-gnome-menu-ellipsized');
+
+ item.menu.openOld = item.menu.open;
+ item.menu.open = (animate) => {
+ if (!item.menu.isOpen)
+ this._populateOpenDrawingSubMenu();
+ item.menu.openOld();
+ };
+
+ menu.addMenuItem(item);
+ }
+
+ _populateOpenDrawingSubMenu() {
+ this.openDrawingSubMenu.removeAll();
+ this._extension.FILES.JSONS.getSorted().forEach(json => {
+ if (!json.gicon)
+ json.addSvgContents(...this.area.getSvgContentsForJson(json));
+
+ let subItem = this.openDrawingSubMenu.addAction(`${String(json)}`, () => {
+ this.area.loadJson(json);
+ this._updateDrawingNameMenuItem();
+ this._updateActionSensitivity();
+ }, this._extension.FILES.ICONS.FAKE);
+
+ GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
+ if (subItem.setIcon)
+ subItem.setIcon(json.gicon);
+ });
+
+ subItem.label.get_clutter_text().set_use_markup(true);
+ this._getActor(subItem).connect('key-focus-in', updateSubMenuAdjustment);
+
+ let expander = new St.Bin({
+ style_class: 'popup-menu-item-expander',
+ x_expand: true,
+ });
+ this._getActor(subItem).add_child(expander);
+
+ let insertCallback = () => {
+ this.area.currentImage = json.image;
+ this.imageItem.update();
+ this.area.currentTool = this.DrawingTool.IMAGE;
+ this.toolItem.update();
+ this._updateSectionVisibility();
+ };
+ let insertButton = new ActionButton(_("Add to images"), 'insert-image-symbolic', insertCallback, null, true);
+ this._getActor(subItem).add_child(insertButton);
+
+ let deleteCallback = () => {
+ json.delete();
+ subItem.destroy();
+ this.openDrawingSubMenuItem.setSensitive(!this.openDrawingSubMenu.isEmpty());
+ };
+ let deleteButton = new ActionButton(_("Delete"), 'edit-delete-symbolic', deleteCallback, null, true);
+ deleteButton.child.add_style_class_name('draw-on-gnome-menu-destructive-button');
+ this._getActor(subItem).add_child(deleteButton);
+ });
+
+ this.openDrawingSubMenuItem.setSensitive(!this.openDrawingSubMenu.isEmpty());
+ }
+
+ _addSaveDrawingSubMenuItem(menu, label, icon) {
+ let item = new PopupMenu.PopupSubMenuMenuItem(label, true);
+ this.saveDrawingSubMenuItem = item;
+ this.saveDrawingSubMenu = item.menu;
+ item.icon.set_icon_name(icon);
+
+ item.menu.itemActivated = item.menu.close;
+
+ item.menu.openOld = item.menu.open;
+ item.menu.open = (animate) => {
+ if (!item.menu.isOpen)
+ this._populateSaveDrawingSubMenu();
+ item.menu.openOld();
+ };
+ menu.addMenuItem(item);
+ }
+
+ _updateSaveDrawingSubMenuItemSensitivity() {
+ this.saveDrawingSubMenuItem.setSensitive(this.area.elements.length > 0);
+ }
+
+ _onDrawingSaved() {
+ this._updateDrawingNameMenuItem();
+ this.openDrawingSubMenuItem.setSensitive(true);
+ }
+
+ _populateSaveDrawingSubMenu() {
+ this.saveDrawingSubMenu.removeAll();
+ let saveEntry = new Entry({ initialTextGetter: () => this.area.currentJson ? this.area.currentJson.name : "",
+ hint_text: _("Type a name"),
+ entryActivateCallback: (text) => {
+ this.area.saveAsJsonWithName(text, this._onDrawingSaved.bind(this));
+ this.saveDrawingSubMenu.toggle();
+ },
+ invalidStrings: [this._extension.metadata['persistent-file-name'], '/'],
+ primaryIconName: 'insert-text' });
+ this.saveDrawingSubMenu.addMenuItem(saveEntry.item);
+ }
+
+ _addSeparator(menu, thin) {
+ if (this.hasSeparators) {
+ let separatorItem = new PopupMenu.PopupSeparatorMenuItem(' ');
+ this._getActor(separatorItem).add_style_class_name('draw-on-gnome-menu-separator-item');
+ if (thin)
+ this._getActor(separatorItem).add_style_class_name('draw-on-gnome-menu-thin-separator-item');
+ menu.addMenuItem(separatorItem);
+ }
+ }
+
+ _getSummary(settingKey) {
+ return this._extension.internalShortcutSettings.settings_schema.get_key(settingKey).get_summary();
+ };
+
+ _getActor(object) {
+ return object.actor || object;
+ };
+});
+
+
+
+
+// Updated for GNOME version 49.1
+const updateSubMenuAdjustment = function(itemActor) {
+ let scrollView = itemActor.get_parent().get_parent();
+
+ // GNOME 49+ compatibility: get_vscroll_bar() no longer exists
+ let adjustment;
+ if (scrollView.get_vscroll_bar) {
+ // GNOME 48 and below
+ adjustment = scrollView.get_vscroll_bar().get_adjustment();
+ } else if (scrollView.vscroll && scrollView.vscroll.adjustment) {
+ // GNOME 49+
+ adjustment = scrollView.vscroll.adjustment;
+ } else {
+ // Fallback: can't find scrollbar, exit gracefully
+ return;
+ }
+
+ let scrollViewAlloc = scrollView.get_allocation_box();
+ let currentScrollValue = adjustment.get_value();
+ let height = scrollViewAlloc.y2 - scrollViewAlloc.y1;
+ let itemActorAlloc = itemActor.get_allocation_box();
+ let newScrollValue = currentScrollValue;
+ if (currentScrollValue > itemActorAlloc.y1 - 10)
+ newScrollValue = itemActorAlloc.y1 - 10;
+ if (height + currentScrollValue < itemActorAlloc.y2 + 10)
+ newScrollValue = itemActorAlloc.y2 - height + 10;
+ if (newScrollValue != currentScrollValue)
+ adjustment.set_value(newScrollValue);
+};
+
+
+
+// An action button that uses upstream dash item tooltips.
+const ActionButton = GObject.registerClass ({
+ GTypeName: `${UUID}-DrawingMenuActionButton`,
+ _labelShowing: false,
+ _resetHoverTimeoutId: 0,
+ _showLabelTimeoutId: 0,
+ showLabel: Dash.DashItemContainer.prototype.showLabel,
+ hideLabel: Dash.DashItemContainer.prototype.hideLabel,
+ _syncLabel: Dash.Dash.prototype._syncLabel,
+}, class ActionButton extends St.Bin {
+ _init(name, icon, callback, callbackAfter, inline) {
+ this._labelText = name;
+
+ let button = new St.Button({ track_hover: true,
+ x_align: Clutter.ActorAlign.CENTER,
+ accessible_name: name,
+ style_class: `button draw-on-gnome-menu-${inline ? 'inline' : 'action'}-button` });
+
+ button.child = new St.Icon(typeof icon == 'string' ? { icon_name: icon } : { gicon: icon });
+ if (inline)
+ button.child.add_style_class_name('popup-menu-icon');
+
+ // Create tooltip label
+ this._tooltipLabel = new St.Label({
+ text: name,
+ style_class: 'dash-label',
+ opacity: 0,
+ visible: false
+ });
+ Main.layoutManager.uiGroup.add_child(this._tooltipLabel);
+
+ button.connect('notify::hover', () => {
+ if (button.hover) {
+ // Position tooltip
+ let [stageX, stageY] = button.get_transformed_position();
+ let buttonWidth = button.width;
+ let buttonHeight = button.height;
+
+ this._tooltipLabel.opacity = 0;
+ this._tooltipLabel.visible = true;
+
+ let labelWidth = this._tooltipLabel.width;
+ let labelHeight = this._tooltipLabel.height;
+
+ // Determine if we're in the bottom half of the screen
+ let monitor = Main.layoutManager.primaryMonitor;
+ let isBottomHalf = stageY > monitor.height / 2;
+
+ // Position tooltip above or below based on screen position
+ let tooltipX = Math.floor(stageX + (buttonWidth - labelWidth) / 2);
+ let tooltipY = isBottomHalf
+ ? Math.floor(stageY + buttonHeight + 6) // Below button
+ : Math.floor(stageY - labelHeight - 6); // Above button
+
+ this._tooltipLabel.set_position(tooltipX, tooltipY);
+
+ this._tooltipLabel.ease({
+ opacity: 255,
+ duration: 150,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD
+ });
+ } else {
+ this._tooltipLabel.ease({
+ opacity: 0,
+ duration: 100,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ onComplete: () => {
+ this._tooltipLabel.visible = false;
+ }
+ });
+ }
+ });
+
+ button.connect('clicked', () => {
+ callback();
+ if (callbackAfter)
+ callbackAfter();
+ });
+ button.bind_property('reactive', button, 'can_focus', GObject.BindingFlags.DEFAULT);
+
+ super._init({ child: button, x_expand: inline ? false : true });
+
+ // Clean up tooltip on destroy
+ this.connect('destroy', () => {
+ if (this._tooltipLabel) {
+ this._tooltipLabel.destroy();
+ }
+ });
+ }
+
+ setHoverColor(color) {
+ // Store reference to button for hover effect
+ let button = this.child;
+
+ // Define color mapping
+ const colors = {
+ 'orange': 'background-color: rgba(255, 165, 0, 0.3);',
+ 'green': 'background-color: rgba(0, 255, 0, 0.3);',
+ 'cyan': 'background-color: rgba(0, 255, 255, 0.3);',
+ 'blue': 'background-color: rgba(0, 100, 255, 0.3);',
+ 'purple': 'background-color: rgba(160, 32, 240, 0.3);',
+ 'red': 'background-color: rgba(255, 0, 0, 0.3);',
+ 'yellow': 'background-color: rgba(255, 255, 0, 0.3);'
+ };
+
+ const hoverStyle = colors[color] || '';
+
+ // Connect to hover events
+ button.connect('notify::hover', () => {
+ if (button.hover) {
+ button.set_style(hoverStyle);
+ } else {
+ button.set_style('');
+ }
+ });
+ } // <-- New method ends here
+
+ get label() {
+ if (!this._label) {
+ this._label = new St.Label({ style_class: 'dash-label' });
+ Main.layoutManager.uiGroup.add_child(this._label);
+ this.connect('destroy', () => this._label.destroy());
+ }
+
+ return this._label;
+ }
+});
+
+// based on searchItem.js, https://github.com/leonardo-bartoli/gnome-shell-extension-Recents
+// zhrexl: Registered as if it needed to extend Object but I might change that in the future
+const Entry = GObject.registerClass({
+ GTypeName: `${UUID}-DrawingMenuEntry`,
+}, class Entry extends GObject.Object{
+ _init(params) {
+ this.params = params;
+ this.item = new PopupMenu.PopupBaseMenuItem({ style_class: 'draw-on-gnome-menu-entry-item',
+ activate: false,
+ reactive: true,
+ can_focus: false });
+
+ this.itemActor = SHELL_MAJOR_VERSION >= 3 ? this.item.actor : this.item;
+
+ this.entry = new St.Entry({
+ hint_text: params.hint_text || "",
+ style_class: 'search-entry draw-on-gnome-menu-entry',
+ track_hover: true,
+ reactive: true,
+ can_focus: true,
+ x_expand: true
+ });
+
+ this.entry.set_primary_icon(new St.Icon({ style_class: 'search-entry-icon',
+ icon_name: this.params.primaryIconName }));
+
+ this.entry.clutter_text.connect('text-changed', this._onTextChanged.bind(this));
+ this.entry.clutter_text.connect('activate', this._onTextActivated.bind(this));
+
+ this.clearIcon = new St.Icon({
+ style_class: 'search-entry-icon',
+ icon_name: 'edit-clear-symbolic'
+ });
+ this.entry.connect('secondary-icon-clicked', this._reset.bind(this));
+
+ this._getActor(this.item).add_child(this.entry);
+ this._getActor(this.item).connect('notify::mapped', (actor) => {
+ if (actor.mapped) {
+ this.entry.set_text(this.params.initialTextGetter());
+ this.entry.clutter_text.grab_key_focus();
+ }
+ });
+ }
+
+ _setError(hasError) {
+ if (hasError)
+ this.entry.add_style_class_name('draw-on-gnome-menu-entry-error');
+ else
+ this.entry.remove_style_class_name('draw-on-gnome-menu-entry-error');
+ }
+
+ _reset() {
+ this.entry.text = '';
+ this.entry.clutter_text.set_cursor_visible(true);
+ this.entry.clutter_text.set_selection(0, 0);
+ this._setError(false);
+ }
+
+ _onTextActivated(clutterText) {
+ let text = clutterText.get_text();
+ if (text.length == 0)
+ return;
+ if (this._getIsInvalid())
+ return;
+ this._reset();
+ this.params.entryActivateCallback(text);
+ }
+
+ _onTextChanged(clutterText) {
+ let text = clutterText.get_text();
+ this.entry.set_secondary_icon(text.length ? this.clearIcon : null);
+
+ if (text.length)
+ this._setError(this._getIsInvalid());
+ }
+
+ _getIsInvalid() {
+ return this.params.invalidStrings.some(invalidString => this.entry.text.indexOf(invalidString) != -1);
+ }
+
+ _getActor(object) {
+ return object.actor || object;
+ };
+});
+
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/metadata.json b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/metadata.json
new file mode 100644
index 0000000..b2e85ff
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/metadata.json
@@ -0,0 +1,18 @@
+{
+ "_generated": "Generated by SweetTooth, do not edit",
+ "data-dir": "draw-on-gnome",
+ "description": "Annotation tool for the GNOME desktop. Documentation at: https://daveprowse.github.io/Draw-On-Gnome/. Note: This extension accesses the clipboard when you press Ctrl+V to paste images. Credits: This is a fork of the original DrawOnYourScreen by abakkk.",
+ "gettext-domain": "draw-on-gnome",
+ "name": "Draw On Gnome",
+ "settings-schema": "org.gnome.shell.extensions.draw-on-gnome",
+ "shell-version": [
+ "46",
+ "47",
+ "48",
+ "49"
+ ],
+ "url": "https://github.com/daveprowse/Draw-On-Gnome",
+ "uuid": "draw-on-gnome@daveprowse.github.io",
+ "version": 9,
+ "version-name": "9.0"
+}
\ No newline at end of file
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/prefs.js b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/prefs.js
new file mode 100644
index 0000000..894d89a
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/prefs.js
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2022 zhrexl
+ * Originally Forked from Abakkk
+ * Copyright 2024 Dave Prowse
+ *
+ * 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 .
+ *
+ * SPDX-FileCopyrightText: 2022 zhrexl
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileContributor: Modified by Dave Prowse
+ */
+
+/* eslint version: 9.16 (2024) */
+
+import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
+
+import PreferencesPage from './ui/preferencespage.js';
+import DrawingPage from './ui/drawingpage.js';
+import AboutPage from './ui/about.js';
+
+export default class DrawOnGnomeExtensionPreferences extends ExtensionPreferences {
+
+ constructor(metadata) {
+ super(metadata);
+ }
+
+ // !!! These are the changes for E.G.O. as per their issue #3 (11/3/2025 review).
+ // They negate the changes made for issue #2 by using "window" instead of "this".
+ // REMOVE these getter methods (lines 45, 53, 61 in your file):
+ // get settings() { ... }
+ // get internalShortcutSettings() { ... }
+ // get drawingSettings() { ... }
+ //
+ // Don't store settings as properties on THIS class (the exported one)
+
+ fillPreferencesWindow(window) {
+ // Store settings on the WINDOW object instead of on this class
+ // This satisfies both fix #2 (use _settings.get_child) and fix #3 (don't store on exported class)
+ window._settings = this.getSettings();
+ window._internalShortcutSettings = window._settings.get_child('internal-shortcuts');
+ window._drawingSettings = window._settings.get_child('drawing');
+
+ window.search_enabled = true;
+
+ let page1 = new PreferencesPage(this, window);
+ let page2 = new DrawingPage(this, window);
+ let page3 = new AboutPage(this);
+
+ window.add(page1);
+ window.add(page2);
+ window.add(page3);
+
+ // Clean up when window closes to allow garbage collection
+ window.connect('close-request', () => {
+ delete window._settings;
+ delete window._internalShortcutSettings;
+ delete window._drawingSettings;
+ });
+ }
+}
\ No newline at end of file
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/schemas/gschemas.compiled b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/schemas/gschemas.compiled
new file mode 100644
index 0000000..b6882dc
Binary files /dev/null and b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/schemas/gschemas.compiled differ
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/schemas/org.gnome.shell.extensions.draw-on-gnome.gschema.xml b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/schemas/org.gnome.shell.extensions.draw-on-gnome.gschema.xml
new file mode 100644
index 0000000..3e02a52
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/schemas/org.gnome.shell.extensions.draw-on-gnome.gschema.xml
@@ -0,0 +1,379 @@
+
+
+
+
+
+
+ false
+ Drawing on the desktop
+ Draw On Gnome becomes Draw On Gnome Desktop]]>
+
+
+ ["<Alt><Super>e"]
+ Erase all drawings
+
+
+ false
+ Disable panel indicator
+
+
+ false
+ Disable quick settings toggle
+
+
+ false
+ Disable on-screen notifications
+
+
+ true
+ Persistent over toggles
+ Drawing remains when toggling drawing mode
+
+
+ false
+ Persistent over restarts
+ Drawing is automatically saved to a file
+
+
+ false
+ Copy picked color to clipboard
+ After using color picker, the picked value is saved to clipboard
+
+
+ ["<Alt><Super>d"]
+ Enter/leave drawing mode
+
+
+ ["<Primary><Alt><Super>d"]
+
+ Grab/ungrab keyboard and pointer
+
+
+
+
+
+ "#2e2e2e"
+ Background color
+ The color of the drawing area background
+
+
+ true
+ Automatic dash array
+ Compute the lengths from the line width
+
+
+
+ 5
+ Dash array on
+ The dash length in pixels
+
+
+
+ 15
+ Dash array off
+ The gap between the dashes in pixels
+
+
+
+ 0
+ Dash offset
+ The dash offset in pixels
+
+
+ "rgb(190,190,190)"
+ Grid overlay color
+ The color of the lines
+
+
+ true
+ Automatic grid overlay line
+ Compute the lengths from the screen size
+
+
+
+ 10
+ Grid overlay line spacing
+ The gap between lines in pixels
+
+
+
+ 0.5
+ Grid overlay line width
+ The line width in pixels
+
+
+ ""
+ Image location
+ The location of the directory in which the image tool picks
+
+
+
+ [
+ ('Palette', ['rgb(255,105,180):HotPink', 'rgb(0,255,255):Cyan', 'rgb(255,255,0):yellow', 'rgb(255,69,0):Orangered', 'rgb(127,255,0):Chartreuse', 'rgb(148,0,211):DarkViolet', 'rgb(255,255,255):White', 'rgb(190,190,190):Gray', 'rgb(0,0,0):Black']),
+ ('GNOME HIG lighter', ['rgb(153,193,241):Blue 1', 'rgb(143,240,164):Green 1', 'rgb(249,240,107):Yellow 1', 'rgb(255,190,111):Orange 1', 'rgb(246,97,81):Red 1', 'rgb(220,138,221):Purple 1', 'rgb(205,171,143):Brown 1', 'rgb(255,255,255):Light 1', 'rgb(119,118,123):Dark 1']),
+ ('GNOME HIG light', ['rgb(98,160,234):Blue 2', 'rgb(87,227,137):Green 2', 'rgb(248,228,92):Yellow 2', 'rgb(255,163,72):Orange 2', 'rgb(237,51,59):Red 2', 'rgb(192,97,203):Purple 2', 'rgb(181,131,90):Brown 2', 'rgb(246,245,244):Light 2', 'rgb(94,92,100):Dark 2']),
+ ('GNOME HIG normal', ['rgb(53,132,228):Blue 3', 'rgb(51,209,122):Green 3', 'rgb(246,211,45):Yellow 3', 'rgb(255,120,0):Orange 3', 'rgb(224,27,36):Red 3', 'rgb(145,65,172):Purple 3', 'rgb(152,106,68):Brown 3', 'rgb(222,221,218):Light 3', 'rgb(61,56,70):Dark 3']),
+ ('GNOME HIG dark', ['rgb(28,113,216):Blue 4', 'rgb(46,194,126):Green 4', 'rgb(245,194,17):Yellow 4', 'rgb(230,97,0):Orange 4', 'rgb(192,28,40):Red 4', 'rgb(129,61,156):Purple 4', 'rgb(134,94,60):Brown 4', 'rgb(192,191,188):Light 4', 'rgb(36,31,49):Dark 4']),
+ ('GNOME HIG darker', ['rgb(26,95,180):Blue 5', 'rgb(38,162,105):Green 5', 'rgb(229,165,10):Yellow 5', 'rgb(198,70,0):Orange 5', 'rgb(165,29,45):Red 5', 'rgb(97,53,131):Purple 5', 'rgb(99,69,44):Brown 5', 'rgb(154,153,150):Light 5', 'rgb(0,0,0):Dark 5'])
+ ]
+
+ Color palettes
+ The palettes of drawing colors
+
+
+ true
+ Automatic square area size
+ Compute the area size from the screen size
+
+
+
+ 512
+ Square area size
+ The size of the area in pixels
+
+
+ ('',[])
+ Tool palette
+ Color palette of tool
+
+
+ ""
+ Tool color
+ Color of tool
+
+
+ 5
+ Tool size
+ Size of tool brush
+
+
+
+
+ ["<Primary>KP_Subtract","<Primary>minus","<Primary><Shift>minus"]
+ Decrement line width
+
+
+ ["<Primary><Shift>KP_Subtract"]
+ Decrement line width even more
+
+
+ ["Delete"]
+ Erase last brushstroke
+
+
+ ["<Primary><Alt>s"]
+ Export drawing to a SVG file
+
+
+ ["<Primary>KP_Add","<Primary><Shift>plus"]
+ Increment line width
+
+
+ ["<Primary><Shift>KP_Add"]
+ Increment line width even more
+
+
+ ["<Primary>o"]
+ Open next drawing
+
+
+ ["<Primary>comma"]
+ Open preferences
+
+
+ ["<Primary><Shift>o"]
+ Open previous drawing
+
+
+ ["<Primary>v"]
+ Add images from the clipboard
+
+
+ ["<Primary>KP_0","<Primary>0"]
+ Pick a color
+
+
+ ["<Primary><Shift>z"]
+ Redo
+
+
+ ["<Primary>s"]
+ Save drawing
+
+
+ ["<Primary>KP_1","<Primary>1"]
+ Select color 1
+
+
+
+ ["<Primary>KP_2","<Primary>2"]
+ Select color 2
+
+
+ ["<Primary>KP_3","<Primary>3"]
+ Select color 3
+
+
+ ["<Primary>KP_4","<Primary>4"]
+ Select color 4
+
+
+ ["<Primary>KP_5","<Primary>5"]
+ Select color 5
+
+
+ ["<Primary>KP_6","<Primary>6"]
+ Select color 6
+
+
+ ["<Primary>KP_7","<Primary>7"]
+ Select color 7
+
+
+ ["<Primary>KP_8","<Primary>8"]
+ Select color 8
+
+
+ ["<Primary>KP_9","<Primary>9"]
+ Select color 9
+
+
+ ["<Primary>e"]
+ Select ellipse tool
+
+
+ ["<Primary>i"]
+ Select image tool
+
+
+ ["<Primary>l"]
+ Select line tool
+
+
+ ["<Primary>a"]
+ Select arrow tool
+
+
+ ["<Primary>q"]
+ Select laser tool
+
+
+ ["<Primary>h"]
+ Select highlighter tool
+ Select yellow highlighter tool
+
+
+ ["<Primary>c"]
+ Select mirror tool
+
+
+ ["<Primary>m"]
+ Select move tool
+
+
+ ["<Primary>p"]
+ Select free drawing
+
+
+ ["<Primary>y"]
+ Select polygon tool
+
+
+ ["<Primary>u"]
+ Select polyline tool
+
+
+ ["<Primary>r"]
+ Select rectangle tool
+
+
+ ["<Primary>x"]
+ Select resize tool
+
+
+ ["<Primary>t"]
+ Select text tool
+
+
+ ["<Primary>equal"]
+ Smooth last brushstroke
+
+
+ ["<Primary>KP_Divide","<Primary>slash"]
+ Change color palette
+
+
+ ["<Primary><Shift>KP_Divide","<Primary><Shift>slash"]
+ Change color palette (reverse)
+
+
+ ["<Primary>period"]
+ Dashed line
+
+
+ ["<Primary><Shift>a"]
+ Toggle fill/outline
+
+
+ ["<Primary>f"]
+ Change font family
+
+
+ ["<Primary><Shift>f"]
+ Change font family (reverse)
+
+
+ ["<Primary><Alt>w"]
+ Change font style
+
+
+ ["<Primary>w"]
+ Change font weight
+
+
+ ["<Primary><Alt>i"]
+ Change image
+
+
+ ["<Primary><Alt><Shift>i"]
+ Change image (reverse)
+
+
+ ["<Primary>k"]
+ Change linecap
+
+
+ ["<Primary>j"]
+ Change linejoin
+
+
+ ["<Primary><Alt>a"]
+ Change text alignment
+
+
+ ["<Primary>b"]
+ Add a drawing background
+
+
+ ["<Primary>g"]
+ Add a grid overlay
+
+
+ ["<Primary>F1"]
+ Show help
+
+
+ ["<Primary><Shift>h"]
+ Hide panel
+
+
+ ["<Primary>n"]
+
+ Square drawing area
+
+
+ ["<Primary>z"]
+ Undo
+
+
+
\ No newline at end of file
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/shortcuts.js b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/shortcuts.js
new file mode 100644
index 0000000..2ba626b
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/shortcuts.js
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2019 Abakkk
+ * Copyright 2024 Dave Prowse
+ *
+ * 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 .
+ *
+ * SPDX-FileCopyrightText: 2019 Abakkk
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileContributor: Modified by Dave Prowse
+ */
+
+/* eslint version: 9.16 (2024) */
+
+// The setting keys of the "org.gnome.shell.extensions.draw-on-gnome" schema.
+
+export const GLOBAL_KEYBINDINGS = [
+ 'toggle-drawing', 'toggle-modal', 'erase-drawings',
+];
+export const GLOBAL_KEYBINDINGS_SWITCHES = [
+ 'persistent-over-toggles', 'persistent-over-restarts', 'drawing-on-desktop', 'osd-disabled', 'indicator-disabled', 'quicktoggle-disabled', 'copy-picked-hex',
+];
+// The setting keys of the "org.gnome.shell.extensions.draw-on-gnome.internal-shortcuts" schema.
+export const INTERNAL_KEYBINDINGS = [
+ 'undo', 'redo', 'delete-last-element', 'smooth-last-element',
+ 'select-none-shape', 'select-line-shape', 'select-arrow-shape', 'select-laser-shape', 'select-highlighter-shape', 'select-ellipse-shape', 'select-rectangle-shape', 'select-polygon-shape', 'select-polyline-shape',
+ 'select-text-shape', 'select-image-shape', 'select-move-tool', 'select-resize-tool', 'select-mirror-tool',
+ 'switch-fill', 'switch-color-palette', 'switch-color-palette-reverse', 'pick-color',
+ 'increment-line-width', 'increment-line-width-more', 'decrement-line-width', 'decrement-line-width-more',
+ 'switch-linejoin', 'switch-linecap', 'switch-dash',
+ 'switch-font-family', 'switch-font-family-reverse', 'switch-font-weight', 'switch-font-style', 'switch-text-alignment',
+ 'switch-image-file', 'switch-image-file-reverse', 'paste-image-files',
+ 'toggle-panel-and-dock-visibility', 'toggle-background', 'toggle-grid', 'toggle-square-area',
+ 'open-next-json', 'open-previous-json', 'save-as-json', 'export-to-svg', 'open-preferences', 'toggle-help',
+];
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/stylesheet.css b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/stylesheet.css
new file mode 100644
index 0000000..158cd56
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/stylesheet.css
@@ -0,0 +1,136 @@
+/* square area */
+
+.draw-on-gnome .draw-on-gnome-square-area {
+ outline: 2px solid rgba(255, 0, 0, 0.7);
+}
+
+.draw-on-gnome:insensitive .draw-on-gnome-square-area {
+ outline: none;
+}
+
+ /* "Ctrl + F1" on-screen-display */
+
+.draw-on-gnome-helper {
+ margin: 0px;
+ border-radius: 0px;
+}
+
+.draw-on-gnome-helper > StBoxLayout {
+ margin: 8px;
+ margin-right: 16px;
+ spacing: 0.5em;
+}
+
+.draw-on-gnome-helper > StBoxLayout StBoxLayout {
+ spacing: 7em;
+}
+
+.draw-on-gnome-helper > StBoxLayout StBoxLayout StLabel {
+ text-align: right;
+ font-weight: normal;
+}
+
+.draw-on-gnome-helper-separator {
+ min-height: 0.6em;
+}
+
+/* context menu */
+
+.draw-on-gnome-menu {
+ font-size: 0.97em; /* default: 1em */
+ min-width: 21em; /* like the aggregate menu */
+}
+
+.draw-on-gnome-menu .popup-menu-item {
+ padding-top: .3em; /* default: .4em */
+ padding-bottom: .3em;
+}
+
+.draw-on-gnome-menu .popup-menu-item > .popup-menu-icon {
+ icon-size: 1em; /* default: 1.09 */
+ padding-top: 0.03em;
+}
+
+/* max size for uncontrolled contents (font, image and drawing names) */
+.draw-on-gnome-menu-ellipsized {
+ max-width: 21em;
+}
+
+.draw-on-gnome-menu .toggle-switch {
+ height: 1.35em; /* default: 22px */
+}
+
+.draw-on-gnome-menu-separator-item {
+ margin-top: 0;
+ padding-top: 0.14em;
+ padding-bottom: 0.14em;
+}
+
+.draw-on-gnome-menu-separator-item StLabel {
+ font-size: 0;
+}
+
+.draw-on-gnome-menu-separator-item .popup-separator-menu-item {
+ margin-top: 0.2em; /* default 6px */
+ margin-bottom: 0.2em; /* default 6px */
+}
+
+.draw-on-gnome-menu-separator-item .popup-separator-menu-item-separator {
+ background-color: transparent;
+}
+
+.draw-on-gnome-menu-thin-separator-item .popup-separator-menu-item-separator {
+ margin-top: 0;
+}
+
+.draw-on-gnome-menu-destructive-button:hover {
+ color: #e01b24; /* upstream destructive color, light: #e01b24, dark: #b2161d */
+}
+
+/* override .button upstream style class */
+.draw-on-gnome-menu-action-button {
+ min-height: 0;
+ min-width: 0;
+ border-radius: 32px;
+ padding: 12px;
+}
+
+.draw-on-gnome-menu-action-button > StIcon {
+ icon-size: 1em;
+}
+
+.draw-on-gnome-menu-slider-label {
+ min-width: 3em;
+ text-align: right;
+}
+
+.draw-on-gnome-menu-entry-item {
+ padding-right: 1.15em; /* default 1.75em */
+ spacing: 0; /* default 12px */
+}
+
+.draw-on-gnome-menu-entry {
+ border: none;
+ border-radius: 3px;
+ padding: 0.35em 0.57em;
+ width: 10em;
+}
+
+.draw-on-gnome-menu-entry-error {
+ color: #f57900; /* upstream warning_color */
+}
+
+.draw-on-gnome-menu-entry:focus {
+ padding: 0.35em 0.57em;
+}
+
+/* override .button upstream style class */
+.draw-on-gnome-menu-inline-button {
+ min-height: 1px;
+ padding: 2px 4px; /* default 3px 24px */
+}
+
+.draw-on-gnome-menu-inline-button .popup-menu-icon {
+ icon-size: 0.85em; /* default 1.09 */
+}
+
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/ui/about.js b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/ui/about.js
new file mode 100644
index 0000000..f5ddf78
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/ui/about.js
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2022 zhrexl
+ * Copyright 2024 Dave Prowse
+ *
+ * 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 .
+ *
+ * SPDX-FileCopyrightText: 2024 Dave Prowse
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileContributor: Modified by Dave Prowse
+ */
+
+/* eslint version: 9.16 (2024) */
+
+import Adw from 'gi://Adw';
+import Gtk from 'gi://Gtk';
+import GObject from 'gi://GObject';
+
+import { gettext as _ } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
+
+import { CURATED_UUID as UUID } from '../utils.js';
+
+const MARGIN = 10;
+
+//TODO: Follow GNOME HIG for About Pages
+const AboutPage = GObject.registerClass({
+ GTypeName: `${UUID}-AboutPage`
+}, class AboutPage extends Adw.PreferencesPage {
+ constructor(extensionPreferences) {
+ super({});
+ this.set_title(_("About"));
+ this.set_name('about');
+ this.set_icon_name("dialog-question-symbolic");
+
+ let aboutGroup = Adw.PreferencesGroup.new();
+ let scrolledWindow = Gtk.ScrolledWindow.new();
+
+ scrolledWindow.set_vexpand(true);
+ scrolledWindow.hscrollbar_policy = Gtk.PolicyType.NEVER;
+
+ aboutGroup.add(scrolledWindow);
+
+ let vbox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, margin_top: 3 * MARGIN, margin_bottom: 3 * MARGIN, margin_start: 3 * MARGIN, margin_end: 3 * MARGIN });
+ scrolledWindow.set_child(vbox);
+
+ // Translators: you are free to translate the extension name, that is displayed in About page, or not
+ let name = " " + _("Draw On Gnome") + "";
+ // Translators: version number in "About" page
+ let version = _("Version %f").format(extensionPreferences.metadata.version);
+ // Translators: you are free to translate the extension description, that is displayed in About page, or not
+ let description = _("Draw on your GNOME Desktop!.\nStart by pressing 'Super+Alt+D'. Have fun! :)");
+ let link = "" + extensionPreferences.metadata.url + "";
+ let licenseName = _("GNU General Public License, version 3 or later");
+ let licenseLink = "https://www.gnu.org/licenses/gpl-3.0.html";
+ let license = "" + _("This program comes with absolutely no warranty.\nSee the %s for details.").format(licenseLink, licenseName) + "";
+
+ let aboutLabel = new Gtk.Label({
+ wrap: true, justify: Gtk.Justification.CENTER, use_markup: true, label:
+ name + "\n\n" + version + "\n\n" + description + "\n\n" + link + "\n\n" + license + "\n"
+ });
+
+ vbox.append(aboutLabel);
+
+ let creditBox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL, margin_top: 2 * MARGIN, margin_bottom: 2 * MARGIN, margin_start: 2 * MARGIN, margin_end: 2 * MARGIN, spacing: 5 });
+ let leftBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, hexpand: true });
+ let rightBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, hexpand: true });
+ leftBox.append(new Gtk.Label({
+ wrap: true, valign: Gtk.Align.START, halign: Gtk.Align.END, justify: Gtk.Justification.RIGHT,
+ use_markup: true, label: "" + _("Created by") + ""
+ }));
+ rightBox.append(new Gtk.Label({
+ wrap: true, valign: Gtk.Align.START, halign: Gtk.Align.START, justify: Gtk.Justification.LEFT,
+ use_markup: true, label: "Abakkk"
+ }));
+
+ leftBox.append(new Gtk.Label({
+ wrap: true, valign: Gtk.Align.START, halign: Gtk.Align.END, justify: Gtk.Justification.RIGHT,
+ use_markup: true, label: "" + _("Forked by") + ""
+ }));
+ rightBox.append(new Gtk.Label({
+ wrap: true, valign: Gtk.Align.START, halign: Gtk.Align.START, justify: Gtk.Justification.LEFT,
+ use_markup: true, label: "zhrexl"
+ }));
+
+ leftBox.append(new Gtk.Label({
+ wrap: true, valign: Gtk.Align.START, halign: Gtk.Align.END, justify: Gtk.Justification.RIGHT,
+ use_markup: true, label: "" + _("Forked by") + ""
+ }));
+ rightBox.append(new Gtk.Label({
+ wrap: true, valign: Gtk.Align.START, halign: Gtk.Align.START, justify: Gtk.Justification.LEFT,
+ use_markup: true, label: "daveprowse"
+ }));
+
+ creditBox.append(leftBox);
+ creditBox.append(rightBox);
+ vbox.append(creditBox);
+
+ // Translators: add your name here or keep it empty, it will be displayed in about page, e.g.
+ // msgstr ""
+ // "translator1\n"
+ // "translator2\n"
+ // "translator3"
+ if (_("translator-credits") != "translator-credits" && _("translator-credits") != "") {
+ leftBox.append(new Gtk.Label());
+ rightBox.append(new Gtk.Label());
+ leftBox.append(new Gtk.Label({ wrap: true, valign: Gtk.Align.START, halign: Gtk.Align.END, justify: 1, use_markup: true, label: "" + _("Translated by") + "" }));
+ rightBox.append(new Gtk.Label({ wrap: true, valign: Gtk.Align.START, halign: Gtk.Align.START, justify: 0, use_markup: true, label: "" + _("translator-credits") + "" }));
+ }
+ this.add(aboutGroup);
+ }
+});
+
+export default AboutPage;
\ No newline at end of file
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/ui/drawingpage.js b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/ui/drawingpage.js
new file mode 100644
index 0000000..37ff62f
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/ui/drawingpage.js
@@ -0,0 +1,515 @@
+/*
+ * Copyright 2022 zhrexl
+ * Copyright 2024 Dave Prowse
+ * 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 .
+ * SPDX-FileCopyrightText: 2024 Dave Prowse
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileContributor: Modified by Dave Prowse
+ */
+
+/* eslint version: 9.16 (2024) */
+
+import Adw from 'gi://Adw';
+import Gdk from 'gi://Gdk';
+import GLib from 'gi://GLib';
+import Gtk from 'gi://Gtk';
+import GObject from 'gi://GObject';
+import Gio from 'gi://Gio';
+
+import {gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
+
+import * as GimpPaletteParser from '../gimpPaletteParser.js';
+import { CURATED_UUID as UUID } from '../utils.js';
+
+
+const MARGIN = 10;
+const ROWBOX_MARGIN_PARAMS = { margin_top: MARGIN / 2, margin_bottom: MARGIN / 2, margin_start: MARGIN, margin_end: MARGIN, spacing: 4 };
+
+const DrawingPage = GObject.registerClass({
+ GTypeName: `${UUID}-Drawing`
+}, class DrawingPage extends Adw.PreferencesPage {
+
+ constructor(extensionPreferences, window) {
+ super({});
+
+ this.window = window;
+ this.set_title("Drawing Page");
+ this.set_name('drawing');
+ this.set_icon_name("applications-graphics-symbolic");
+
+ // Use cached drawingSettings from extensionPreferences
+ this.settings = window._drawingSettings;
+
+ this.schema = this.settings.settings_schema;
+
+ this.palettes = this.settings.get_value('palettes').deep_unpack();
+
+ // New constructor code above, below is the same
+ this.palettes_adw_group = Adw.PreferencesGroup.new()
+ this.palettes_adw_group.set_title(_("Palettes"));
+
+ this.PalettesActionRow = Adw.ActionRow.new();
+
+ this.PalettesActionRow.set_title(_("New Palette"));
+ this.PalettesActionRow.set_subtitle(_("Create or Import palette"));
+ let addButton = Gtk.Button.new_from_icon_name('list-add-symbolic');
+ addButton.set_tooltip_text(_("Add a new palette"));
+ addButton.valign = Gtk.Align.CENTER;
+ addButton.connect('clicked', this._addNewPalette.bind(this));
+
+ let importButton = Gtk.Button.new_from_icon_name('document-open-symbolic');
+ importButton.set_tooltip_text(_("Select a File"));
+ importButton.valign = Gtk.Align.CENTER;
+ importButton.connect('clicked', this._importPalette.bind(this));
+
+ this.PalettesActionRow.add_suffix(addButton);
+ this.PalettesActionRow.add_suffix(importButton);
+ this.palettes_adw_group.add(this.PalettesActionRow);
+
+ this.nPalettes = [];
+ this.settings.connect('changed::palettes', this._updatePalettes.bind(this));
+ this._updatePalettes();
+
+ /* Area Group */
+ let adw_groupArea = Adw.PreferencesGroup.new()
+ adw_groupArea.set_title(_("Area"));
+
+ let squareAreaRow = Adw.ActionRow.new();
+ squareAreaRow.set_title(this.schema.get_key('square-area-size').get_summary());
+ let squareAreaAutoButton = new Gtk.CheckButton({ label: _("Auto"),
+ name: this.schema.get_key('square-area-auto').get_summary(),
+ tooltip_text: this.schema.get_key('square-area-auto').get_description() });
+ let squareAreaSizeButton = new PixelSpinButton({ width_chars: 5, digits: 0, step: 1,
+ range: this.schema.get_key('square-area-size').get_range(),
+ name: this.schema.get_key('square-area-size').get_summary(),
+ tooltip_text: this.schema.get_key('square-area-size').get_description() });
+ this.settings.bind('square-area-auto', squareAreaAutoButton, 'active', 0);
+ this.settings.bind('square-area-size', squareAreaSizeButton, 'value', 0);
+ squareAreaAutoButton.bind_property('active', squareAreaSizeButton, 'sensitive', GObject.BindingFlags.SYNC_CREATE | GObject.BindingFlags.INVERT_BOOLEAN);
+
+ squareAreaAutoButton.valign = Gtk.Align.CENTER;
+ squareAreaSizeButton.valign = Gtk.Align.CENTER;
+
+ squareAreaRow.add_suffix(squareAreaAutoButton);
+ squareAreaRow.add_suffix(squareAreaSizeButton);
+
+
+ let backgroundColorRow = Adw.ActionRow.new();
+ backgroundColorRow.set_title(this.schema.get_key('background-color').get_summary());
+
+ let backgroundColorButton = new ColorStringButton({ use_alpha: true, show_editor: true,
+ name: this.schema.get_key('background-color').get_summary(),
+ tooltip_text: this.schema.get_key('background-color').get_description() });
+ this.settings.bind('background-color', backgroundColorButton, 'color-string', 0);
+
+ backgroundColorButton.valign = Gtk.Align.CENTER;
+ backgroundColorRow.add_suffix(backgroundColorButton);
+
+ let gridLineRow = Adw.ActionRow.new();
+ gridLineRow.set_title( _("Grid overlay line"));
+
+ let gridLineAutoButton = new Gtk.CheckButton({ label: _("Auto"),
+ name: this.schema.get_key('grid-line-auto').get_summary(),
+ tooltip_text: this.schema.get_key('grid-line-auto').get_description() });
+ let gridLineWidthButton = new PixelSpinButton({ width_chars: 5, digits: 1, step: 0.1,
+ range: this.schema.get_key('grid-line-width').get_range(),
+ name: this.schema.get_key('grid-line-width').get_summary(),
+ tooltip_text: this.schema.get_key('grid-line-width').get_description() });
+ let gridLineSpacingButton = new PixelSpinButton({ width_chars: 5, digits: 1, step: 1,
+ range: this.schema.get_key('grid-line-spacing').get_range(),
+ name: this.schema.get_key('grid-line-spacing').get_summary(),
+ tooltip_text: this.schema.get_key('grid-line-spacing').get_description() });
+
+ this.settings.bind('grid-line-auto', gridLineAutoButton, 'active', 0);
+ this.settings.bind('grid-line-width', gridLineWidthButton, 'value', 0);
+ this.settings.bind('grid-line-spacing', gridLineSpacingButton, 'value', 0);
+
+ gridLineAutoButton.bind_property('active', gridLineWidthButton, 'sensitive', GObject.BindingFlags.SYNC_CREATE | GObject.BindingFlags.INVERT_BOOLEAN);
+ gridLineAutoButton.bind_property('active', gridLineSpacingButton, 'sensitive', GObject.BindingFlags.SYNC_CREATE | GObject.BindingFlags.INVERT_BOOLEAN);
+
+ gridLineAutoButton.valign = Gtk.Align.CENTER;
+ gridLineWidthButton.valign = Gtk.Align.CENTER;
+ gridLineSpacingButton.valign = Gtk.Align.CENTER;
+
+ gridLineRow.add_suffix(gridLineAutoButton);
+ gridLineRow.add_suffix(gridLineWidthButton);
+ gridLineRow.add_suffix(gridLineSpacingButton);
+
+ let gridColorRow = Adw.ActionRow.new();
+ gridColorRow.set_title(this.schema.get_key('grid-color').get_summary());
+
+ let gridColorButton = new ColorStringButton({ use_alpha: true, show_editor: true,
+ name: this.schema.get_key('grid-color').get_summary(),
+ tooltip_text: this.schema.get_key('grid-color').get_description() });
+ this.settings.bind('grid-color', gridColorButton, 'color-string', 0);
+ gridColorRow.add_suffix(gridColorButton);
+ gridColorButton.valign = Gtk.Align.CENTER;
+
+ adw_groupArea.add(squareAreaRow);
+ adw_groupArea.add(backgroundColorRow);
+ adw_groupArea.add(gridLineRow);
+ adw_groupArea.add(gridColorRow);
+
+ /* End of Area Group */
+
+ /* Tools Group */
+ let adw_groupTools = Adw.PreferencesGroup.new()
+ adw_groupTools.set_title(_("Tools"));
+
+
+ let dashArrayRow = Adw.ActionRow.new();
+ dashArrayRow.set_title(_("Dash array"));
+
+ let dashArrayAutoButton = new Gtk.CheckButton({ label: _("Auto"),
+ name: this.schema.get_key('dash-array-auto').get_summary(),
+ tooltip_text: this.schema.get_key('dash-array-auto').get_description() });
+ let dashArrayOnButton = new PixelSpinButton({ width_chars: 5, digits: 1, step: 0.1,
+ range: this.schema.get_key('dash-array-on').get_range(),
+ name: this.schema.get_key('dash-array-on').get_summary(),
+ tooltip_text: this.schema.get_key('dash-array-on').get_description() });
+ let dashArrayOffButton = new PixelSpinButton({ width_chars: 5, digits: 1, step: 0.1,
+ range: this.schema.get_key('dash-array-off').get_range(),
+ name: this.schema.get_key('dash-array-off').get_summary(),
+ tooltip_text: this.schema.get_key('dash-array-off').get_description() });
+ this.settings.bind('dash-array-auto', dashArrayAutoButton, 'active', 0);
+ this.settings.bind('dash-array-on', dashArrayOnButton, 'value', 0);
+ this.settings.bind('dash-array-off', dashArrayOffButton, 'value', 0);
+ dashArrayAutoButton.bind_property('active', dashArrayOnButton, 'sensitive', GObject.BindingFlags.SYNC_CREATE | GObject.BindingFlags.INVERT_BOOLEAN);
+ dashArrayAutoButton.bind_property('active', dashArrayOffButton, 'sensitive', GObject.BindingFlags.SYNC_CREATE | GObject.BindingFlags.INVERT_BOOLEAN);
+ dashArrayAutoButton.valign = Gtk.Align.CENTER;
+ dashArrayOnButton.valign = Gtk.Align.CENTER;
+ dashArrayOffButton.valign = Gtk.Align.CENTER;
+ dashArrayRow.add_suffix(dashArrayAutoButton);
+ dashArrayRow.add_suffix(dashArrayOnButton);
+ dashArrayRow.add_suffix(dashArrayOffButton);
+
+
+ let dashOffsetRow = Adw.ActionRow.new();
+ dashOffsetRow.set_title(this.schema.get_key('dash-offset').get_summary());
+
+ let dashOffsetButton = new PixelSpinButton({ width_chars: 5, digits: 1, step: 0.1,
+ range: this.schema.get_key('dash-offset').get_range(),
+ name: this.schema.get_key('dash-offset').get_summary(),
+ tooltip_text: this.schema.get_key('dash-offset').get_description() });
+ this.settings.bind('dash-offset', dashOffsetButton, 'value', 0);
+ dashOffsetButton.valign = Gtk.Align.CENTER;
+ dashOffsetRow.add_suffix(dashOffsetButton);
+
+ let imageLocationRow = Adw.ActionRow.new();
+ imageLocationRow.set_title(this.schema.get_key('image-location').get_summary());
+
+ let imageLocationButton = new FileChooserButton({ action: Gtk.FileChooserAction.SELECT_FOLDER,
+ name: this.schema.get_key('image-location').get_summary(),
+ tooltip_text: this.schema.get_key('image-location').get_description() });
+ this.settings.bind('image-location', imageLocationButton, 'location', 0);
+ imageLocationButton.valign = Gtk.Align.CENTER;
+ imageLocationRow.add_suffix(imageLocationButton);
+
+
+ adw_groupTools.add(dashArrayRow);
+ adw_groupTools.add(dashOffsetRow);
+ adw_groupTools.add(imageLocationRow);
+
+ let resetButton = new Gtk.Button({ label: _("Reset settings"), halign: Gtk.Align.CENTER });
+ resetButton.get_style_context().add_class('destructive-action');
+ resetButton.connect('clicked', () => this.schema.list_keys().forEach(key => this.settings.reset(key)));
+
+ resetButton.set_margin_top(12);
+ adw_groupTools.add(resetButton);
+ /* End of Tools Group */
+
+ this.add(this.palettes_adw_group);
+ this.add(adw_groupArea);
+ this.add(adw_groupTools);
+ };
+ _updatePalettes() {
+ this.palettes = this.settings.get_value('palettes').deep_unpack();
+ /*TODO: I Should probably reutilize these widgets instead of just removing it */
+ this.nPalettes.forEach((actionrow) => {
+ if (actionrow){
+ this.palettes_adw_group.remove(actionrow);
+ }
+ });
+ this.nPalettes = [];
+
+ this.palettes.forEach((palette,index) => {
+ let tmpAction = Adw.ActionRow.new();
+ tmpAction.set_title(palette[0]);
+ this.nPalettes.push(tmpAction);
+
+ let EditButton = Gtk.Button.new_from_icon_name('edit-symbolic');
+ EditButton.set_tooltip_text(_("Edit this palette colors"));
+ EditButton.valign = Gtk.Align.CENTER;
+ EditButton.connect('clicked', () => {this._editPalette(palette, index)});
+
+ let RemoveButton = Gtk.Button.new_from_icon_name('edit-delete-symbolic');
+ RemoveButton.set_tooltip_text(_("Remove this palette"));
+ RemoveButton.valign = Gtk.Align.CENTER;
+ RemoveButton.connect('clicked', () => {
+ this.palettes.splice(index,1);
+ this._savePalettes();
+ });
+
+ tmpAction.add_suffix(EditButton);
+ tmpAction.add_suffix(RemoveButton);
+
+ this.palettes_adw_group.add(this.nPalettes[index]);
+ });
+
+ }
+
+ _savePalettes() {
+ this.settings.set_value('palettes', new GLib.Variant('a(sas)', this.palettes));
+ }
+
+ _onPaletteNameChanged(index, text) {
+ this.palettes[index][0] = text;
+ this._savePalettes();
+ }
+
+ _onPaletteColorChanged(paletteIndex, colorIndex, colorButton) {
+ this.palettes[paletteIndex][1][colorIndex] = colorButton.get_rgba().to_string();
+ if (colorButton.tooltip_text)
+ this.palettes[paletteIndex][1][colorIndex] += `:${colorButton.tooltip_text}`;
+ this._savePalettes();
+ }
+
+ _addNewPalette() {
+ let colors = Array(9).fill('Black');
+ // Translators: default name of a new palette
+ this.palettes.push([_("New palette"), colors]);
+ this._savePalettes();
+ }
+
+ _importPalette() {
+ let dialog = new Gtk.FileChooserDialog({
+ title: _("Select a File"),
+ action: Gtk.FileChooserAction.OPEN,
+ modal: true,
+ });
+ dialog.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL);
+ dialog.add_button(_("_Open"), Gtk.ResponseType.ACCEPT);
+
+ let filter = new Gtk.FileFilter();
+ filter.set_name("GIMP Palette (*.gpl)");
+ filter.add_pattern('*.gpl');
+ dialog.add_filter(filter);
+
+ dialog.connect('response', (dialog, response) => {
+ if (response == Gtk.ResponseType.ACCEPT) {
+ let file = dialog.get_file();
+ let palettes = GimpPaletteParser.parseFile(file);
+ palettes.forEach(palette => this.palettes.push(palette));
+ this._savePalettes();
+ }
+ dialog.destroy();
+ });
+
+ dialog.show();
+ }
+ _editPalette(palette, index)
+ {
+ let modal = new Gtk.Dialog({
+ default_height: 400,
+ default_width: 500,
+ modal: true,
+ transient_for: this.window,
+ title: 'Editing ' + palette[0] + ' palette',
+ use_header_bar: true
+ });
+
+ let contentArea = modal.get_content_area();
+ let preferencesPage = Adw.PreferencesPage.new();
+ let editor_palettes_group = Adw.PreferencesGroup.new()
+ editor_palettes_group.set_title(_("Customize Palette"));
+
+ let PalettesNameActionRow = Adw.ActionRow.new();
+ PalettesNameActionRow.set_title(_("Name"));
+ let EntryName = Gtk.EditableLabel.new(palette[0]);
+
+ EntryName.connect('changed', () => {
+ this._onPaletteNameChanged(index, EntryName.get_text());
+ });
+
+ EntryName.set_alignment(1);
+ PalettesNameActionRow.add_suffix(EntryName);
+ editor_palettes_group.add(PalettesNameActionRow);
+
+ palette[1].forEach((color, colorindex)=>{
+ let pActionRow = Adw.ActionRow.new();
+ let [cname, title] = color.split(":");
+
+ let colortitle = Gtk.EditableLabel.new(title || cname);
+ colortitle.connect('changed', () => {
+ this.palettes[index][1][colorindex] = cname+':'+colortitle.get_text();
+ this._savePalettes();
+ });
+
+ pActionRow.add_prefix(colortitle);
+ let colorEntry = new ColorStringButton({ use_alpha: true, show_editor: true,
+ name: cname,
+ tooltip_text: title || cname});
+ colorEntry.color_string = cname;
+ colorEntry.valign = Gtk.Align.CENTER;
+ colorEntry.connect('notify::color-string', () => {
+ this._onPaletteColorChanged(index,colorindex, colorEntry);
+ });
+
+
+ pActionRow.add_suffix(colorEntry);
+ editor_palettes_group.add(pActionRow);
+ });
+
+ preferencesPage.add(editor_palettes_group);
+ contentArea.append(preferencesPage);
+ modal.show();
+ }
+ _removePalette(paletteIndex) {
+ this.palettes.splice(paletteIndex, 1);
+ this._savePalettes();
+ }
+ });
+
+
+const PixelSpinButton = new GObject.Class({
+ Name: `${UUID}-PixelSpinButton2`,
+ Extends: Gtk.SpinButton,
+ Properties: {
+ 'range': GObject.param_spec_variant('range', 'range', 'GSettings range',
+ GLib.VariantType.new('(sv)'), null, GObject.ParamFlags.WRITABLE),
+
+ 'step': GObject.ParamSpec.double('step', 'step', 'step increment',
+ GObject.ParamFlags.WRITABLE,
+ 0, 1000, 1)
+ },
+
+ set range(range) {
+ let [type, variant] = range.deep_unpack();
+ if (type == 'range') {
+ let [min, max] = variant.deep_unpack();
+ this.adjustment.set_lower(min);
+ this.adjustment.set_upper(max);
+ }
+ },
+
+ set step(step) {
+ this.adjustment.set_step_increment(step);
+ this.adjustment.set_page_increment(step * 10);
+ },
+
+ on_output: function() {
+ this.text = _("%f px").format(Number(this.value).toFixed(2));
+ return true;
+ },
+
+ // Prevent accidental scrolling (GTK 3).
+ on_scroll_event: function(event) {
+ if (this.has_focus) {
+ try {
+ GObject.signal_chain_from_overridden([this, event], false);
+ } catch(e) { }
+
+ return Gdk.EVENT_STOP;
+ }
+
+ return Gdk.EVENT_PROPAGATE;
+ }
+});
+
+
+// A color button that can be easily bound with a color string setting.
+const ColorStringButton = new GObject.Class({
+ Name: `${UUID}-ColorStringButton2`,
+ Extends: Gtk.ColorButton,
+ Properties: {
+ 'color-string': GObject.ParamSpec.string('color-string', 'colorString', 'A string that describes the color',
+ GObject.ParamFlags.READWRITE, 'black')
+ },
+
+ get color_string() {
+ return this._color_string || 'black';
+ },
+
+ set color_string(colorString) {
+ this._color_string = colorString;
+
+ let newRgba = new Gdk.RGBA();
+ newRgba.parse(colorString);
+ this.set_rgba(newRgba);
+ },
+
+ on_color_set: function() {
+ let oldRgba = new Gdk.RGBA();
+ oldRgba.parse(this.color_string);
+
+ // Do nothing if the new color is equivalent to the old color (e.g. "black" and "rgb(0,0,0)").
+ if (!this.rgba.equal(oldRgba)) {
+ this._color_string = this.rgba.to_string();
+ this.notify('color-string');
+ }
+ }
+});
+
+
+const FileChooserButton = new GObject.Class({
+ Name: `${UUID}-FileChooserButton2`,
+ Extends: Gtk.Button,
+ Properties: {
+ 'action': GObject.ParamSpec.enum('action', 'action', 'action',
+ GObject.ParamFlags.READWRITE,
+ Gtk.FileChooserAction.$gtype,
+ Gtk.FileChooserAction.SELECT_FOLDER),
+
+ 'location': GObject.ParamSpec.string('location', 'location', 'location',
+ GObject.ParamFlags.READWRITE, '')
+ },
+
+ get location() {
+ return this._location || "";
+ },
+
+ set location(location) {
+ if (!this._location || this._location != location) {
+ this._location = location;
+ this.label = location ?
+ Gio.File.new_for_commandline_arg(location).query_info('standard::display-name', Gio.FileQueryInfoFlags.NONE, null).get_display_name() :
+ _("(None)");
+
+ this.notify('location');
+ }
+ },
+
+ vfunc_clicked: function() {
+ let dialog = new Gtk.FileChooserDialog({
+ title: _(this.name),
+ action: this.action,
+ modal: true,
+ });
+ dialog.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL);
+ dialog.add_button(_("_Select"), Gtk.ResponseType.ACCEPT);
+
+ if (this.location)
+ dialog.set_file(Gio.File.new_for_commandline_arg(this.location));
+
+ dialog.connect('response', (dialog, response) => {
+ if (response == Gtk.ResponseType.ACCEPT)
+ this.location = dialog.get_file().get_path();
+ dialog.destroy();
+ });
+
+ dialog.show();
+ }
+});
+
+export default DrawingPage;
\ No newline at end of file
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/ui/preferencespage.js b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/ui/preferencespage.js
new file mode 100644
index 0000000..ade57fa
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/ui/preferencespage.js
@@ -0,0 +1,185 @@
+/*
+ * Copyright 2022 zhrexl
+ * Copyright 2024 Dave Prowse
+ * 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 .
+
+ * SPDX-FileCopyrightText: 2024 Dave Prowse
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileContributor: Modified by Dave Prowse
+ */
+
+/* eslint version: 9.16 (2024) */
+
+
+import Adw from 'gi://Adw';
+import Gdk from 'gi://Gdk';
+import Gtk from 'gi://Gtk';
+import GObject from 'gi://GObject';
+
+import { gettext } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
+
+import { CURATED_UUID as UUID } from '../utils.js';
+import * as Shortcuts from '../shortcuts.js';
+
+
+const _ = (string) => string ? gettext(string) : "";
+const MARGIN = 10;
+const ROWBOX_MARGIN_PARAMS = { margin_top: MARGIN / 2, margin_bottom: MARGIN / 2, margin_start: MARGIN, margin_end: MARGIN, spacing: 4 };
+
+
+const PreferencesPage = GObject.registerClass({
+ GTypeName: `${UUID}-PreferencesPage`
+}, class Preferences extends Adw.PreferencesPage {
+
+ constructor(extensionPreferences, window) {
+ super({});
+
+ this.set_title("Preferences");
+ this.set_name('prefs');
+ this.set_icon_name("preferences-system-symbolic");
+
+ // Use cached settings from extensionPreferences
+ let settings = window._settings;
+ let schema = settings.settings_schema;
+
+ let grp_Global = Adw.PreferencesGroup.new();
+ grp_Global.set_title("Global");
+
+ Shortcuts.GLOBAL_KEYBINDINGS.forEach((settingKeys) => {
+ let globalKeybindingsRow = new Adw.ActionRow();
+ let globalKeybindingsWidget = new ShortCutWidget(settings, settingKeys);
+ let name = settings.settings_schema.get_key(settingKeys).get_summary();
+
+ globalKeybindingsRow.set_title(name);
+ globalKeybindingsRow.add_suffix(globalKeybindingsWidget);
+ globalKeybindingsWidget.valign = Gtk.Align.CENTER;
+
+ grp_Global.add(globalKeybindingsRow);
+ });
+
+ Shortcuts.GLOBAL_KEYBINDINGS_SWITCHES.forEach((settingKeys) => {
+ let ActionRow = Adw.ActionRow.new();
+ let ActionRow_switch = Gtk.Switch.new();
+ let persistentOverTogglesKey = schema.get_key(settingKeys);
+
+ ActionRow.set_title(persistentOverTogglesKey.get_summary());
+ let description = persistentOverTogglesKey.get_description();
+
+ if (description)
+ ActionRow.set_subtitle(persistentOverTogglesKey.get_description());
+
+ ActionRow.add_suffix(ActionRow_switch);
+ ActionRow_switch.valign = Gtk.Align.CENTER;
+
+ settings.bind(settingKeys, ActionRow_switch, 'active', 0);
+
+ grp_Global.add(ActionRow);
+ });
+
+ let grp_Internal = Adw.PreferencesGroup.new();
+ grp_Internal.set_title("Internal");
+
+ // Use cached internalShortcutSettings
+ let internalShortcutSettings = window._internalShortcutSettings;
+
+ // Rest of the code stays the same...
+ Shortcuts.INTERNAL_KEYBINDINGS.forEach((settingKeys) => {
+ let globalKeybindingsRow = new Adw.ActionRow();
+ let globalKeybindingsWidget = new ShortCutWidget(internalShortcutSettings, settingKeys);
+ let name = internalShortcutSettings.settings_schema.get_key(settingKeys).get_summary();
+
+ globalKeybindingsRow.set_title(name);
+ globalKeybindingsRow.add_suffix(globalKeybindingsWidget);
+ globalKeybindingsWidget.valign = Gtk.Align.CENTER;
+
+ grp_Internal.add(globalKeybindingsRow);
+ });
+
+ let resetButton = new Gtk.Button({ label: _("Reset settings"), halign: Gtk.Align.CENTER });
+ resetButton.get_style_context().add_class('destructive-action');
+ resetButton.connect('clicked', () => {
+ internalShortcutSettings.settings_schema.list_keys().forEach(key => internalShortcutSettings.reset(key));
+ settings.settings_schema.list_keys().forEach(key => settings.reset(key));
+ });
+
+ resetButton.set_margin_top(12);
+
+ this.add(grp_Global);
+ this.add(grp_Internal);
+ grp_Internal.add(resetButton);
+ }
+});
+
+
+//TODO: ShortCutWidget should not allow two identicals shortcuts
+const ShortCutWidget = GObject.registerClass({
+ GTypeName: `${UUID}-ShortCutWidget`
+}, class ShortCutWidget extends Gtk.Button {
+ constructor(settings, settingsKeys) {
+ super({});
+ this._settings = settings;
+ this._settingsKeys = settingsKeys;
+
+ let key = settings.get_strv(settingsKeys)[0];
+ this.shortcutlabel = Gtk.ShortcutLabel.new(key);
+ this.evck = Gtk.EventControllerKey.new();
+ this.allow_changes = false;
+
+ this.add_controller(this.evck);
+
+ //TODO: This needs testing
+ if (key == null)
+ this.set_label(_("Click here to set new shortcut..."));
+ else
+ this.set_child(this.shortcutlabel);
+
+ this.get_style_context().add_class('flat');
+ this.connect('clicked', this.clicked.bind(this));
+ this.evck.connect('key-pressed', this.key_pressed.bind(this));
+ this.evck.connect('key-released', this.key_released.bind(this));
+ this._settings.connect('changed', this.on_settings_changed.bind(this));
+ }
+ on_settings_changed() {
+ let key = this._settings.get_strv(this._settingsKeys)[0];
+ this.shortcutlabel.set_accelerator(key);
+ }
+ clicked() {
+ this.set_label(_("Press the new shortcut..."));
+ this.allow_changes = true;
+ }
+ key_released(widget, keyval, keycode, state) {
+ if (this.allow_changes == false)
+ return Gdk.EVENT_STOP;
+ else
+ this.allow_changes = false;
+
+ let value = this.shortcutlabel.get_accelerator();
+ this._settings.set_strv(this._settingsKeys, [value]);
+ }
+ key_pressed(widget, keyval, keycode, state) {
+ if (this.allow_changes == false)
+ return Gdk.EVENT_STOP;
+
+ let mask = state & Gtk.accelerator_get_default_mod_mask();
+ let binding = Gtk.accelerator_name_with_keycode(null, keyval, keycode, mask);
+
+ this.shortcutlabel.set_accelerator(binding);
+ this.set_child(this.shortcutlabel);
+
+ return Gdk.EVENT_STOP;
+ }
+});
+
+
+export default PreferencesPage;
\ No newline at end of file
diff --git a/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/utils.js b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/utils.js
new file mode 100644
index 0000000..3ad5f1c
--- /dev/null
+++ b/gnome/.local/share/gnome-shell/extensions/draw-on-gnome@daveprowse.github.io/utils.js
@@ -0,0 +1,40 @@
+export const UUID = 'draw-on-gnome@daveprowse.github.io';
+export const CURATED_UUID = UUID.replace(/@/gi, '_at_').replace(/[^a-z0-9+_-]/gi, '_');
+
+/**
+ * Parse GNOME Shell version string to a comparable number
+ * Converts version strings like "45.2" or "46.0" to numeric values
+ * @param {string} versionString - Version string (default: current shell version)
+ * @returns {number} - Numeric version for comparison
+ */
+export function parseShellVersion(versionString) {
+ const parts = versionString.split('.');
+ const major = parseInt(parts[0], 10) || 0;
+ const minor = parts.length > 1 ? parseInt(parts[1], 10) || 0 : 0;
+ // Returns major.minor as a float (e.g., "45.2" becomes 45.02)
+ return major + (minor / 100);
+}
+
+/**
+ * Get only the major version number
+ * @param {string} versionString - Version string
+ * @returns {number} - Major version number
+ */
+export function getShellMajorVersion(versionString) {
+ return parseInt(versionString.split('.')[0], 10) || 0;
+}
+
+// Only import Config in the shell context, not in prefs
+let PACKAGE_VERSION;
+try {
+ const Config = await import('resource:///org/gnome/shell/misc/config.js');
+ PACKAGE_VERSION = Config.PACKAGE_VERSION;
+} catch (e) {
+ // We're in prefs context, Config is not available
+ // This is okay - prefs don't need version checks
+ PACKAGE_VERSION = '0.0';
+}
+
+// Export parsed version for convenience
+export const SHELL_VERSION = parseShellVersion(PACKAGE_VERSION);
+export const SHELL_MAJOR_VERSION = getShellMajorVersion(PACKAGE_VERSION);
\ No newline at end of file
diff --git a/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/CHANGELOG.md b/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/CHANGELOG.md
index 417230b..a3ce11d 100644
--- a/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/CHANGELOG.md
+++ b/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/CHANGELOG.md
@@ -333,7 +333,11 @@ other: Other
## [v55] - 2025-07-18
### Other
- The warning message when thresholds do not match has been modified.
-
-## [v56] - 2025-09-30
### Added
-- Gnome 49 support
\ No newline at end of file
+- Gnome 49 support
+
+## [V56] - 2026-02-25
+### Other
+- Update translations
+- This was the last update. I invite you to check out my other project: [Preserve Battery Health](https://extensions.gnome.org/extension/8389/preserve-battery-health/). Thank you all!
+- Unmaintained
\ No newline at end of file
diff --git a/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/cs/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo b/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/cs/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo
index 0592953..1f4ad89 100644
Binary files a/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/cs/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo and b/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/cs/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo differ
diff --git a/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/de/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo b/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/de/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo
index bf72382..1b7f3ce 100644
Binary files a/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/de/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo and b/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/de/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo differ
diff --git a/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/id/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo b/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/id/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo
new file mode 100644
index 0000000..69d01b5
Binary files /dev/null and b/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/id/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo differ
diff --git a/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/ru/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo b/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/ru/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo
index b09ee32..8adafa1 100644
Binary files a/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/ru/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo and b/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/locale/ru/LC_MESSAGES/thinkpad-battery-threshold@marcosdalvarez.org.mo differ
diff --git a/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/metadata.json b/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/metadata.json
index 31d0fcf..ec3edb3 100644
--- a/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/metadata.json
+++ b/gnome/.local/share/gnome-shell/extensions/thinkpad-battery-threshold@marcosdalvarez.org/metadata.json
@@ -1,8 +1,8 @@
{
"_generated": "Generated by SweetTooth, do not edit",
- "description": "Enable/Disable battery threshold on Lenovo Thinkpad laptops.\n\nIf you mainly use the system with the AC power adapter connected and only use the battery sporadically, you can increase battery life by setting the maximum charge value to less than 100%. This is useful because batteries that are used sporadically have a longer lifespan when kept at less than full charge.",
+ "description": "Enable/Disable battery threshold on Lenovo Thinkpad laptops.\n\nIf you mainly use the system with the AC power adapter connected and only use the battery sporadically, you can increase battery life by setting the maximum charge value to less than 100%. This is useful because batteries that are used sporadically have a longer lifespan when kept at less than full charge.\n\nUnfortunately, it's no longer possible or practical for me to maintain this extension. Since GNOME includes a native option to enable and disable battery charge thresholds, this option is more practical and stable, so I'll stop implementing options or fixing bugs in this project to focus on my other extension, which is much simpler and easier to maintain: https://extensions.gnome.org/extension/8389/preserve-battery-health/ \nThank you all for your support, and I invite you to check out my other project.",
"gettext-domain": "thinkpad-battery-threshold@marcosdalvarez.org",
- "name": "Thinkpad Battery Threshold",
+ "name": "Thinkpad Battery Threshold [Unmaintained]",
"settings-schema": "org.gnome.shell.extensions.thinkpad-battery-threshold",
"shell-version": [
"46",
@@ -12,5 +12,5 @@
],
"url": "https://gitlab.com/marcosdalvarez/thinkpad-battery-threshold-extension",
"uuid": "thinkpad-battery-threshold@marcosdalvarez.org",
- "version": 55
+ "version": 56
}
\ No newline at end of file