From 472d7c466d33bd1fe4cd293b354e52bf16384520 Mon Sep 17 00:00:00 2001 From: Gordon Norman Squash Date: Tue, 10 Sep 2024 01:28:29 -0400 Subject: Initial commit This is where I have started tracking development with Git. I declare this as version 0.89. --- .gitignore | 1 + COPYING | 165 +++++++ COPYING.GPL-3 | 674 +++++++++++++++++++++++++++ README.md | 136 ++++++ data/00_gtk3-classic-module.gschema.override | 23 + data/settings.ini | 76 +++ data/zebra-stripes.css | 16 + include/gtk3-classic.h | 25 + main.c | 56 +++ meson.build | 74 +++ patches/button-menu-icons.c | 451 ++++++++++++++++++ patches/dialogs.c | 451 ++++++++++++++++++ patches/icon-sizes.c | 325 +++++++++++++ patches/no-emojis.c | 61 +++ patches/persistent-mnemonics.c | 100 ++++ patches/smaller-widgets.c | 262 +++++++++++ screenshots/button-icons.png | Bin 0 -> 5744 bytes screenshots/dialog-with-classic-buttons.png | Bin 0 -> 49077 bytes screenshots/menu-icons.png | Bin 0 -> 13241 bytes screenshots/message-dialog.png | Bin 0 -> 11638 bytes screenshots/persistent-mnemonics.png | Bin 0 -> 2535 bytes 21 files changed, 2896 insertions(+) create mode 100644 .gitignore create mode 100644 COPYING create mode 100644 COPYING.GPL-3 create mode 100644 README.md create mode 100644 data/00_gtk3-classic-module.gschema.override create mode 100644 data/settings.ini create mode 100644 data/zebra-stripes.css create mode 100644 include/gtk3-classic.h create mode 100644 main.c create mode 100644 meson.build create mode 100644 patches/button-menu-icons.c create mode 100644 patches/dialogs.c create mode 100644 patches/icon-sizes.c create mode 100644 patches/no-emojis.c create mode 100644 patches/persistent-mnemonics.c create mode 100644 patches/smaller-widgets.c create mode 100644 screenshots/button-icons.png create mode 100644 screenshots/dialog-with-classic-buttons.png create mode 100644 screenshots/menu-icons.png create mode 100644 screenshots/message-dialog.png create mode 100644 screenshots/persistent-mnemonics.png diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..24e5b0a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.build diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..0a04128 --- /dev/null +++ b/COPYING @@ -0,0 +1,165 @@ + GNU LESSER 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. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser 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 +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/COPYING.GPL-3 b/COPYING.GPL-3 new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/COPYING.GPL-3 @@ -0,0 +1,674 @@ + 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/README.md b/README.md new file mode 100644 index 0000000..6f48a17 --- /dev/null +++ b/README.md @@ -0,0 +1,136 @@ +# gtk3-classic-module + +This project provides a GTK module for GTK+ 3.24 to restore some of the +traditional look-and-feel of older GTK versions to GTK 3. It is similar in +spirit to [gtk3-classic](https://github.com/lah7/gtk3-classic/), and in fact +much of the code in this module was inspired by the code from `gtk3-classic`; +however, this module does not require recompiling of GTK from source code. +You only need the development files for GTK; once this module is compiled, it +can be installed without replacing GTK entirely. + +## Installation Instructions + +You will need the Meson build system and the development files for GTK 3. +On Debian, Ubuntu, and their derivatives, type the following command to install +the build dependencies: + +``` +sudo apt install meson libgtk-3-dev +``` + +Download the source code for this module; `cd` into the directory into which +you downloaded it. Then create a build directory and `cd` into that: + +``` +mkdir .build +cd .build +``` + +By default, it is assumed that GTK was installed into a prefix of `/usr`. If +this is the case (it usually is), then you shouldn't need to supply any build +options: + +``` +meson setup .. +``` + +If GTK was installed into a diffeerent prefix -- for instance `/usr/local` -- +add the `-Dprefix=[GTK-PREFIX]` option to the above `meson setup` command, +like so: + +``` +meson setup -Dprefix=/usr/local .. +``` + +Once the module is configured, build it and then install it: + +``` +meson compile +sudo meson install +``` + +You will need to restart all of your GTK applications before the module will +take effect. If it doesn't then take effect, try running applications with the +environment variable `GTK_MODULES='gtk3-classic-module'` set. + +Once installed, please check out your `/etc/gtk-3.0/settings.ini` file. It +contains numerous useful settings which can be changed, complete with a large +amount of documentation about each option. + +## What Does This Module Do? + +* Applies stock icons to buttons and menu items which have standard text labels + (example: 'Open...', 'Save As', 'Unlock'). + + + + + + **Requires setting the GTK settings `gtk-button-icons` and/or + `gtk-menu-icons`.** + +* Always displays underlines beneath mnemonics, even when the Alt + key is not being held down. Normally, the mnemonics are displayed only when + Alt is held down or when a menu is open and active. + + + + **Requires disabling the GTK setting `gtk-auto-mnemonics`.** + +* Forces GTK to display normal dialog buttons at the bottom of stock dialogs + (e.g. About dialog, color chooser, file chooser), instead of displaying the + buttons in a headerbar at the top of the dialog -- even on Wayland. + + + +* One of the settings in the installed `/etc/gtk-3.0/settings.ini` file, + default disables overlay scrolling: Scrollbars will always be displayed, + instead of only appearing when you are about to use them. + + **Change the `gtk-overlay-scrolling` GTK setting to affect this behaviour.** + +* Stock icon sizes are once again modifiable. Now you can have buttons with + 24x24 icons instead of the tiny 16x16 icons that GTK 3 usually uses. + + **See the GTK setting `gtk-icon-sizes` for more information.** + +* Text entry widgets do not display the 'Insert Emoji' item in the context + menu. + + **Re-enable the menu item by setting the environment variable + `GTKM_INSERT_EMOJI=1`.** + +* Various dialogs have their old appearances restored, not the least of which + is message dialogs: They once again have an image next to the dialog text + (if it's appropriate to include an image), the text is left- (or right-) + justified instead of being centered, and dialog buttons don't appear all + grouped together into one lump: + + + +* The file chooser has the 'typeahead find' feature re-enabled, as opposed to + the recursive search that GTK 3 normally performs. Press + Alt-S to launch the recursive search instead. + +* The sizes of some widgets (mostly buttons) in the built-in GTK themes + Adwaita and HighContrast have been reduced. + +There may be other changes I have applied which I have forgotten to document +here. + +## To-Do + +* At least convert headerbars from a virtual titlebar for the window into a + box at the top of the window content area. + +* Maybe use simple heuristics to eliminate the headerbar entirely if it's only + used as a deliberate forced-client-side-titlebar. + +* Convert menu-like popovers into traditional menus. + +* Restore 'zebra stripes' (alternating row colours in treeviews). + +## License + +GNU LGPL-3 or later. This is a newer version of the same license under which +GTK 3 is released. diff --git a/data/00_gtk3-classic-module.gschema.override b/data/00_gtk3-classic-module.gschema.override new file mode 100644 index 0000000..888ef2d --- /dev/null +++ b/data/00_gtk3-classic-module.gschema.override @@ -0,0 +1,23 @@ +# This file was installed by the gtk3-classic-module package. +# Edit this file if you wish; however, you may want to instead use this file +# as a template for a GSchema override file of your own. Just ensure that +# he name of your file begins with a two-digit number greater than the '00' +# used by this override file, or otherwise your own settings may not take +# precedence over the settings in this file. +# +# Please also see the file at: +# +# /etc/gtk-3.0/settings.ini +# +# ...for additional settings. + + +## Settings pertaining to the GTK file chooser dialog: + +[org.gtk.Settings.FileChooser] + +### Opens the file chooser dialog to the current directory (usually your home +### directory) by default. Change the 'cwd' to 'recent' if you prefer the +### file chooser dialog to initially open up to the list of your recently +### opened files. +startup-mode = 'cwd' diff --git a/data/settings.ini b/data/settings.ini new file mode 100644 index 0000000..6765e79 --- /dev/null +++ b/data/settings.ini @@ -0,0 +1,76 @@ +# This file was installed by the gtk3-classic-module package. +# Edit this file if you wish; however, you may want to instead use this file +# as a template for your ~/.config/gtk-3.0/settings.ini file in your personal +# home directory. +# +# Please also see the file at: +# +# /usr/share/glib-2.0/schemas/00_gtk3-classic-module.gschema.override +# +# ...for additional settings. + + +[Settings] + + +## This ensures that the gtk3-classic-module gets loaded. You can add other +## modules to the list here, though you may prefer to add them to your +## GTK_MODULES environment variable instead. + +gtk-modules = gtk3-classic-module + + +## Comment out the following statement if you want mnemonics (indicated by +## underlining beneath text on buttons and menu items) to be displayed only +## while the key is being held down. Keep this uncommented if you want +## mnemonics to be displayed at all times. + +gtk-auto-mnemonics = 0 + + +## Comment out one or both of the following if you do not want buttons and/or +## menu items (respectively) to display icons next to the button/menu item +## text, presuming there is an icon to display. +## +## NOTE: Some desktop environments may override these settings and provide +## the settings in their own desktop preferences configuration tool(s); +## please check your desktop environment's appearance preferences first. + +gtk-button-images = 1 +gtk-menu-images = 1 + + +## Set this to your preferred set of stock icon sizes. The default here is to +## use 16x16 pixel icons for menus, 16x16 pixel icons for small toolbars, +## 24x24 pixel icons for large toolbars, 24x24 pixel icons for buttons, 32x32 +## pixel icons for the icons displayed to represent dragged content during a +## drag-and-drop operation, and 48x48 pixel icons for dialog icons. Feel free +## to change any of these values as you desire. + +gtk-icon-sizes = gtk-menu=16:gtk-small-toolbar=16:gtk-large-toolbar=24:gtk-button=24:gtk-dnd=32:gtk-dialog=48 + + +## This statement ensures that scrollbars are always displayed, rather than +## disappearing until you are about to use them. Setting the environment +## variable GTK_OVERLAY_SCROLLING=0 has the same effect. +## +## NOTE: Some desktop environments may override this setting, instead +## providing the setting in their own desktop preferences configuration +## tool(s); please check your desktop environment's appearance +## preferences first. +## +## This setting was not available before GTK 3.24.9; if your version of GTK is +## more than a few years old, you may need to comment this out and set +## GTK_OVERLAY_SCROLLING=0 instead. + +gtk-overlay-scrolling = 0 + + +## Change this to whatever your preferred document viewer program is; +## this command will be run when you click 'Print Preview' in an application. +## The default is to invoke Evince, the GNOME document viewer; Atril (from the +## MATE desktop environment, https://mate-desktop.org/) is used here instead +## since it has a more classic user interface than Evince, though theoretically +## virtually any document viewer, such as Xpdf, can be used. + +gtk-print-preview-command = atril --unlink-tempfile --preview --print-settings %s %f diff --git a/data/zebra-stripes.css b/data/zebra-stripes.css new file mode 100644 index 0000000..5f13d79 --- /dev/null +++ b/data/zebra-stripes.css @@ -0,0 +1,16 @@ +/* TODO: This is currently unused, but when alternating treeview row colours + * are restored, this will be the default CSS code to activate them if the + * current theme doesn't provide its own code for this. + */ + + +treeview:not(:selected).odd.sorted, +treeview:not(:selected).even:not(.sorted) +{ + background: alpha(black, 0.07); +} + +treeview:not(:selected).even.sorted +{ + background: alpha(black, 0.13); +} diff --git a/include/gtk3-classic.h b/include/gtk3-classic.h new file mode 100644 index 0000000..51d8a54 --- /dev/null +++ b/include/gtk3-classic.h @@ -0,0 +1,25 @@ +#ifndef __GTK3_CLASSIC_H__ +#define __GTK3_CLASSIC_H__ + + +#define GTK_GETTEXT_DOMAIN "gtk30" +#include + + +#define INTERCEPTED_CLASS_METHOD(type_name, method, parameters, return_type) \ + static return_type (* original_##type_name##_##method) parameters; \ + static return_type new_##type_name##_##method parameters; + +#define INTERCEPT_CLASS_METHOD(type_name, class_cast, method) \ + original_##type_name##_##method = class_cast (type_name##_class)->method; \ + class_cast (type_name##_class)->method = new_##type_name##_##method; + +#define CALL_ORIGINAL_CLASS_METHOD(type_name, method, parameters) \ + if (original_##type_name##_##method) \ + original_##type_name##_##method parameters; + +#define CALL_ORIGINAL_CLASS_METHOD_UNCHECKED(type_name, method, parameters) \ + original_##type_name##_##method parameters; + + +#endif /* __GTK3_CLASSIC_H__ */ diff --git a/main.c b/main.c new file mode 100644 index 0000000..ddfc7ab --- /dev/null +++ b/main.c @@ -0,0 +1,56 @@ +#include +#include + + +#undef G_LOG_DOMAIN +#define G_LOG_DOMAIN "Gtk3-Classic-Module" + + +typedef void (* InitFunc) (); + +void button_menu_icons_init (); +void dialogs_init (); +void icon_sizes_init (); +void no_emojis_init (); +void persistent_mnemonics_init (); +void smaller_widgets_init (); + +static const InitFunc init_funcs[] = +{ + smaller_widgets_init, + /* No Emojis must be loaded before Button/Menu Icons since the former + * overrides GtkMenuItem, the superclass of the GtkImageMenuItem class + * which Button/Menu Icons taps into. + */ + no_emojis_init, + button_menu_icons_init, + persistent_mnemonics_init, + dialogs_init, + icon_sizes_init, + NULL +}; + + +G_MODULE_EXPORT +const char * g_module_check_init (GModule *module) +{ + g_module_make_resident (module); + return NULL; +} + +G_MODULE_EXPORT +int gtk_module_init (gint * argc, char *** argv) +{ + int i; + + + (void) argc; + (void) argv; + + + for (i = 0; init_funcs[i] != NULL; i++) + init_funcs[i] (); + + + return 0; +} diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..7c41125 --- /dev/null +++ b/meson.build @@ -0,0 +1,74 @@ +project ('gtk3-classic-module', 'c', + version : '0.89', + default_options : [ + 'buildtype=release', + 'optimization=2', + 'prefix=/usr', + 'strip=true', + 'warning_level=3' + ], + license: 'LGPLv3+') + + +gtk_version_required = '>= 3.24.0' +gtk_dep = dependency ('gtk+-3.0', + version: gtk_version_required) +gtk_unix_print_dep = dependency ('gtk+-unix-print-3.0', + version: gtk_version_required) +# For glib-compile-schemas +gnome = import ('gnome') + + +gtk_libdir = gtk_dep.get_variable ( + pkgconfig: 'libdir', + internal: 'libdir', + default_value: get_option ('libdir')) + +gtk_sysconfdir = gtk_dep.get_variable ( + pkgconfig: 'sysconfdir', + internal: 'sysconfdir', + default_value: get_option ('sysconfdir')) + +gtk_datadir = gtk_dep.get_variable ( + pkgconfig: 'datadir', + internal: 'datadir', + default_value: get_option ('datadir')) + + +modules_subdir = 'gtk-3.0/modules' +modules_install_dir = join_paths (gtk_libdir, modules_subdir) + +settings_subdir = 'gtk-3.0' +settings_install_dir = join_paths (gtk_sysconfdir, settings_subdir) + +schemas_subdir = 'glib-2.0/schemas' +schemas_install_dir = join_paths (gtk_datadir, schemas_subdir) + + +include_dir = include_directories ('include') + + +shared_module ('gtk3-classic-module', + sources: [ + 'main.c', + 'patches/button-menu-icons.c', + 'patches/dialogs.c', + 'patches/icon-sizes.c', + 'patches/no-emojis.c', + 'patches/persistent-mnemonics.c', + 'patches/smaller-widgets.c' + ], + include_directories: [ include_dir ], + dependencies: [ gtk_dep, gtk_unix_print_dep ], + install_dir: modules_install_dir, + install: true +) + + +install_data ('data/settings.ini', + install_dir: settings_install_dir) + +schema_file = 'data/00_gtk3-classic-module.gschema.override' +install_data (schema_file, + install_dir: schemas_install_dir) +gnome.post_install (glib_compile_schemas: true) diff --git a/patches/button-menu-icons.c b/patches/button-menu-icons.c new file mode 100644 index 0000000..471a0d0 --- /dev/null +++ b/patches/button-menu-icons.c @@ -0,0 +1,451 @@ +/* Button / Menu Icons: + * (from gtk3-classic patch 'appearance__buttons-menus-icons.patch') + * + * Applies appropriate icons to buttons and menus as if they were stock buttons + * or menu items. + * + * Enable the icons by adding to your settings.ini file: + * + * gtk-button-images = 1 + * gtk-menu-images = 1 + * + * Some desktop environments may set these properties via their own appearance + * preferences configuration tool; check for such an option or set of options + * first. + */ + + +#include +#include + +#include +#include + +#include + + +#undef G_LOG_DOMAIN +#define G_LOG_DOMAIN "Gtk3-Classic::Button-Menu-Icons" + + +/* + * Most of the button / menu labels and their associated icons listed herein + * are taken from the gtkstock.h header file which comes with GTK, with the + * exception that most of the GTK-specific icon names have been replaced with + * their generic FreeDesktop equivalents. Other entries in this table may have + * been extracted from the original patch from gtk3-classic. + */ + +#define ICON(_label, _icon_name) \ + { .label = _label, .icon_name = _icon_name } + +typedef struct +{ + const char * label; + const char * translated_label; + const char * icon_name; +} Icon; + +static int icons_list_length; +static Icon icons[] = +{ + ICON ("_About", "help-about"), + ICON ("_Add", "list-add"), + ICON ("_Apply", "gtk-apply"), + ICON ("_Ascending", "view-sort-ascending"), + ICON ("Authentication", "dialog-authentication"), + ICON ("_Back", "back"), + ICON ("Best _Fit", "zoom-fit-best"), + ICON ("_Bold", "format-text-bold"), + ICON ("_Bottom", "bottom"), + ICON ("_Cancel", "gtk-cancel"), + ICON ("_CD-ROM", "media-optical"), + ICON ("_Center", "format-justify-center"), + ICON ("_Clear", "edit-clear"), + ICON ("_Close", "window-close"), + ICON ("_Color", "gtk-select-color"), + ICON ("Color Selection","gtk-select-color"), + ICON ("_Connect", "gtk-connect"), + ICON ("_Convert", "gtk-convert"), + ICON ("_Copy", "edit-copy"), + ICON ("Copy _Link Address", "edit-copy"), + ICON ("Copy URL", "edit-copy"), + ICON ("_Credits", "help-about"), + ICON ("C_ustomize", "gtk-edit"), + ICON ("Cu_t", "edit-cut"), + ICON ("_Delete", "edit-delete"), + ICON ("_Descending", "view-sort-descending"), + ICON ("_Discard", "edit-delete"), + ICON ("_Disconnect", "gtk-disconnect"), + ICON ("_Down", "down"), + ICON ("_Edit", "gtk-edit"), + ICON ("Error", "dialog-error"), + ICON ("_Execute", "gtk-execute"), + ICON ("_File", "text-x-generic"), + ICON ("_Fill", "format-justify-fill"), + ICON ("_Find", "edit-find"), + ICON ("Find and _Replace", "edit-find-replace"), + ICON ("_First", "go-first"), + ICON ("Fol_der", "folder"), + ICON ("_Font", "gtk-select-font"), + ICON ("Font Selection","gtk-select-font"), + ICON ("_Forward", "forward"), + ICON ("_Fullscreen", "view-fullscreen"), + ICON ("_Hard Disk", "media-harddisk"), + ICON ("_Help", "help-contents"), + ICON ("_Home", "go-home"), + ICON ("Image", "image-x-generic"), + ICON ("Indent", "format-indent-more"), + ICON ("_Info", "dialog-information"), + ICON ("_Information", "dialog-information"), + ICON ("Insert _Emoji", "face-smile"), + ICON ("_Italic", "format-text-italic"), + ICON ("_Jump to", "go-jump"), + ICON ("Landscape", "gtk-orientation-landscape"), + ICON ("_Last", "go-last"), + ICON ("_Leave Fullscreen", "view-restore"), + ICON ("_Left", "format-justify-left"), + ICON ("_License", "text-x-generic"), + ICON ("Lock", "changes-prevent"), + ICON ("_Network", "network"), + ICON ("Networks", "network"), + ICON ("_New", "document-new"), + ICON ("_Next", "forward"), + ICON ("_No", "gtk-no"), + ICON ("_Normal Size", "zoom-original"), + ICON ("_OK", "gtk-ok"), + ICON ("_Open", "document-open"), + ICON ("_Open Link", "go-jump"), + ICON ("Page Set_up", "document-page-setup"), + ICON ("_Password", "dialog-authentication"), + ICON ("_Paste", "edit-paste"), + ICON ("P_ause", "media-playback-pause"), + ICON ("Pick a Color", "gtk-select-color"), + ICON ("Pick a Font", "gtk-select-font"), + ICON ("_Play", "media-playback-play"), + ICON ("Portrait", "gtk-orientation-portrait"), + ICON ("_Preferences", "preferences-system"), + ICON ("Pre_view", "document-print-preview"), + ICON ("Pre_vious", "back"), + ICON ("_Print", "document-print"), + ICON ("Print Pre_view", "document-print-preview"), + ICON ("_Properties", "document-properties"), + ICON ("_Question", "dialog-question"), + ICON ("_Quit", "application-exit"), + ICON ("_Record", "media-record"), + ICON ("_Redo", "edit-redo"), + ICON ("_Refresh", "view-refresh"), + ICON ("_Remove", "list-remove"), + ICON ("_Replace", "edit-find-replace"), + ICON ("Reverse landscape", "gtk-orientation-reverse-landscape"), + ICON ("Reverse portrait", "gtk-orientation-reverse-portrait"), + ICON ("_Revert", "document-revert"), + ICON ("R_ewind", "media-seek-backward"), + ICON ("_Right", "format-justify-right"), + ICON ("_Save", "document-save"), + ICON ("Save _As", "document-save-as"), + ICON ("Search", "system-search"), + ICON ("_Select", "gtk-ok"), + ICON ("Select _All", "edit-select-all"), + ICON ("Select a Color", "gtk-select-color"), + ICON ("Select a Font", "gtk-select-font"), + ICON ("_Spell Check", "tools-check-spelling"), + ICON ("_Stop", "process-stop"), + ICON ("_Strikethrough", "format-text-strikethrough"), + ICON ("_Top", "top"), + ICON ("_Undelete", "gtk-undelete"), + ICON ("_Underline", "format-text-underline"), + ICON ("_Undo", "edit-undo"), + ICON ("Unindent", "format-indent-less"), + ICON ("Unlock", "changes-allow"), + ICON ("_Up", "up"), + ICON ("Warning", "dialog-warning"), + ICON ("_Yes", "gtk-yes"), + ICON ("Zoom _In", "zoom-in"), + ICON ("Zoom _Out", "zoom-out"), + { NULL, NULL, NULL } +}; + +static int sort_icon_labels (const void * icon1, const void * icon2); +static int search_icon_labels (const void * key, const void * icon); + + +INTERCEPTED_CLASS_METHOD (gtk_button, notify, + (GObject * object, + GParamSpec * pspec), + void) + + +INTERCEPTED_CLASS_METHOD (gtk_menu_item, constructor, + (GType type, + guint n_construct_properties, + GObjectConstructParam * construct_params), + GObject *) + +INTERCEPTED_CLASS_METHOD (gtk_image_menu_item, parent_set, + (GtkWidget * widget, + GtkWidget * previous_parent), + void) + +INTERCEPTED_CLASS_METHOD (gtk_image_menu_item, set_label, + (GtkMenuItem * menu_item, + const gchar * label), + void) + + +void button_menu_icons_init () +{ + { + GtkButtonClass * gtk_button_class = + g_type_class_ref (GTK_TYPE_BUTTON); + + INTERCEPT_CLASS_METHOD (gtk_button, G_OBJECT_CLASS, notify) + + g_type_class_unref (gtk_button_class); + } + + + { + GtkMenuItemClass * gtk_menu_item_class = + g_type_class_ref (GTK_TYPE_MENU_ITEM); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + GtkImageMenuItemClass * gtk_image_menu_item_class = + g_type_class_ref (GTK_TYPE_IMAGE_MENU_ITEM); + G_GNUC_END_IGNORE_DEPRECATIONS; + + INTERCEPT_CLASS_METHOD ( + gtk_menu_item, G_OBJECT_CLASS, constructor) + INTERCEPT_CLASS_METHOD ( + gtk_image_menu_item, GTK_WIDGET_CLASS, parent_set) + INTERCEPT_CLASS_METHOD ( + gtk_image_menu_item, GTK_MENU_ITEM_CLASS, set_label) + + g_type_class_unref (gtk_menu_item_class); + g_type_class_unref (gtk_image_menu_item_class); + } + + + for (icons_list_length = 0; + icons[icons_list_length].label != NULL; + icons_list_length++) + { + icons[icons_list_length].translated_label = + g_dgettext (GTK_GETTEXT_DOMAIN, + icons[icons_list_length].label); + } + + qsort (icons, icons_list_length, sizeof (Icon), sort_icon_labels); +} + + +static void +new_gtk_button_notify +(GObject * object, + GParamSpec * pspec) +{ + GtkSettings * settings; + gboolean buttons_have_icons; + GtkButton * button; + GtkWidget * image; + const char * label_text; + Icon * icon; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_button, notify, (object, pspec)); + + if (strcmp (pspec->name, "label") != 0) + return; + + button = GTK_BUTTON (object); + label_text = gtk_button_get_label (button); + image = gtk_button_get_image (button); + if (! label_text || image) + return; + + settings = gtk_widget_get_settings (GTK_WIDGET (object)); + g_object_get (settings, + "gtk-button-images", &buttons_have_icons, + NULL); + if (! buttons_have_icons) + return; + + icon = bsearch (label_text, icons, + icons_list_length, sizeof (Icon), + search_icon_labels); + if (icon) + { + image = gtk_image_new_from_icon_name (icon->icon_name, + GTK_ICON_SIZE_BUTTON); + gtk_button_set_image (button, image); + } +} + + +static GObject * +new_gtk_menu_item_constructor +(GType type, + guint n_construct_properties, + GObjectConstructParam * construct_params) +{ + if (type == GTK_TYPE_MENU_ITEM) + { + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + type = GTK_TYPE_IMAGE_MENU_ITEM; + G_GNUC_END_IGNORE_DEPRECATIONS; + } + + return CALL_ORIGINAL_CLASS_METHOD_UNCHECKED (gtk_menu_item, + constructor, + (type, + n_construct_properties, + construct_params)) +} + + +static void +new_gtk_image_menu_item_parent_set +(GtkWidget * widget, + GtkWidget * previous_parent) + +{ + GtkWidget * parent; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_image_menu_item, parent_set, + (widget, previous_parent)); + + + parent = gtk_widget_get_parent (widget); + if (parent && GTK_IS_MENU_BAR (parent)) + { + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (widget), + NULL); + G_GNUC_END_IGNORE_DEPRECATIONS; + } +} + + +static void +new_gtk_image_menu_item_set_label +(GtkMenuItem * menu_item, + const gchar * label) + +{ + GtkWidget * widget; + GtkImageMenuItem * image_menu_item; + GtkWidget * parent; + GtkSettings * settings; + gboolean menus_have_icons; + Icon * icon; + GtkWidget * image; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_image_menu_item, set_label, + (menu_item, label)); + + + widget = GTK_WIDGET (menu_item); + parent = gtk_widget_get_parent (widget); + if (parent && GTK_IS_MENU_BAR (parent)) + return; + + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + image_menu_item = GTK_IMAGE_MENU_ITEM (menu_item); + image = gtk_image_menu_item_get_image (image_menu_item); + G_GNUC_END_IGNORE_DEPRECATIONS; + if (! label || image) + return; + + settings = gtk_widget_get_settings (widget); + g_object_get (settings, + "gtk-menu-images", &menus_have_icons, + NULL); + if (! menus_have_icons) + return; + + icon = bsearch (label, icons, + icons_list_length, sizeof (Icon), + search_icon_labels); + if (icon) + { + image = gtk_image_new_from_icon_name (icon->icon_name, + GTK_ICON_SIZE_MENU); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + gtk_image_menu_item_set_image (image_menu_item, image); + G_GNUC_END_IGNORE_DEPRECATIONS; + } +} + + +/* Helper functions */ + +static int sort_icon_labels (const void * icon1, const void * icon2) +{ + const char * s1 = ((Icon *) icon1)->translated_label; + const char * s2 = ((Icon *) icon2)->translated_label; + int i; + int j; + + + i = 0; + j = 0; + do + { + if (s1[i] == '_') + i++; + if (s2[j] == '_') + j++; + + if (s1[i] != s2[j]) + return s1[i] - s2[j]; + + if (s1[i] == '\0') + break; + + i++; + j++; + } + while (1); + + + return 0; +} + + +static int search_icon_labels (const void * key, const void * icon) +{ + const char * key_string = key; + const char * label = ((Icon *) icon)->translated_label; + int k; + int l; + + k = 0; + l = 0; + do + { + if (key_string[k] == '_') + k++; + if (label[l] == '_') + l++; + + if (key_string[k] != label[l]) + return key_string[k] - label[l]; + + if (key_string[k] == '\0') + break; + + k++; + l++; + + /* Ignore ellipses following the label text, so that buttons / + * menu items such as 'Open...' will be themed as well. + */ + if (strcmp (&key_string[k], "...") == 0) + break; + } + while (1); + + + return 0; +} diff --git a/patches/dialogs.c b/patches/dialogs.c new file mode 100644 index 0000000..5118fc3 --- /dev/null +++ b/patches/dialogs.c @@ -0,0 +1,451 @@ +/* Dialogs: + * From gtk3-classic patches: + * appearance__message-dialogs.patch + * appearance__file-chooser.patch + * appearance__print-dialog.patch + * fixes__wayland_dialogs_header_setting.patch + * file-chooser__eject-button.patch + * file-chooser__typeahead.patch + * + * Restores the classic appearance of message, print, and file dialogs. + * Forces dialogs to use the traditional action area for their buttons, + * instead of putting the buttons in a headerbar -- even on Wayland. + * Also makes some behavioural changes to file chooser widgets (and thus + * by extension file dialogs). + */ + + +#include +#include +#include +#include + +#include + +#include + + +#undef G_LOG_DOMAIN +#define G_LOG_DOMAIN "Gtk3-Classic::Dialogs" + + +#define MESSAGE_DIALOG_CSS \ + "messagedialog > *,\n" \ + "messagedialog buttonbox.dialog-action-area,\n" \ + "messagedialog box.dialog-action-box\n" \ + "{\n" \ + " margin: 0;\n" \ + " margin-top: 0;\n" \ + " padding: 0;\n" \ + "}\n" + +#define PRINT_DIALOG_CSS \ + "printdialog box.dialog-action-box\n" \ + "{\n" \ + " margin: 0;\n" \ + "}\n" + +#define FILE_CHOOSER_CSS \ + "/* Prefer full-color icons to symbolic ones */\n" \ + "filechooser .sidebar-icon,\n" \ + "filechooser .path-bar,\n" \ + "filechooser .path-bar + button\n" \ + "{\n" \ + " opacity: 1;\n" \ + " -gtk-icon-style: regular;\n" \ + "}\n" \ + "\n" \ + "/* Hide the Eject / Unmount buttons next to volumes in the sidebar */\n" \ + "filechooser .sidebar-button\n" \ + "{\n" \ + " opacity: 0;\n" \ + "}\n" + + +static void apply_dialog_css (GtkWidget * dialog); +static GtkWidget * find_widget_by_name (GtkWidget * start, + const char * name); + + +INTERCEPTED_CLASS_METHOD (gtk_settings, constructed, + (GObject * object), + void) + + +INTERCEPTED_CLASS_METHOD (gtk_message_dialog, constructed, + (GObject * object), + void) + +INTERCEPTED_CLASS_METHOD (gtk_message_dialog, notify, + (GObject * object, + GParamSpec * pspec), + void) + + +INTERCEPTED_CLASS_METHOD (gtk_print_unix_dialog, constructed, + (GObject * object), + void) + + +INTERCEPTED_CLASS_METHOD (gtk_file_chooser_widget, constructed, + (GObject * object), + void) + +static void +filechooser_treeview_search_column_changed (GObject * object, + GParamSpec * pspec, + gpointer data); + +static void +filechooser_search_entry_map (GtkWidget * widget, + gpointer data); + +static void +filechooser_search_entry_unmap (GtkWidget * widget, + gpointer data); + + +void dialogs_init () +{ + { + GtkSettingsClass * gtk_settings_class = + g_type_class_ref (GTK_TYPE_SETTINGS); + + INTERCEPT_CLASS_METHOD (gtk_settings, G_OBJECT_CLASS, + constructed) + + g_type_class_unref (gtk_settings_class); + } + + + { + GtkMessageDialogClass * gtk_message_dialog_class = + g_type_class_ref (GTK_TYPE_MESSAGE_DIALOG); + + INTERCEPT_CLASS_METHOD (gtk_message_dialog, G_OBJECT_CLASS, + constructed) + INTERCEPT_CLASS_METHOD (gtk_message_dialog, G_OBJECT_CLASS, + notify); + + g_type_class_unref (gtk_message_dialog_class); + } + + + { + GtkPrintUnixDialogClass * gtk_print_unix_dialog_class = + g_type_class_ref (GTK_TYPE_PRINT_UNIX_DIALOG); + + INTERCEPT_CLASS_METHOD (gtk_print_unix_dialog, G_OBJECT_CLASS, + constructed) + + g_type_class_unref (gtk_print_unix_dialog_class); + } + + + { + GtkFileChooserWidgetClass * gtk_file_chooser_widget_class = + g_type_class_ref (GTK_TYPE_FILE_CHOOSER_WIDGET); + + INTERCEPT_CLASS_METHOD (gtk_file_chooser_widget, + G_OBJECT_CLASS, constructed) + + g_type_class_unref (gtk_file_chooser_widget_class); + } +} + + +static void +new_gtk_settings_constructed +(GObject * object) +{ + CALL_ORIGINAL_CLASS_METHOD (gtk_settings, constructed, (object)); + + g_object_set (object, "gtk-dialogs-use-header", FALSE, NULL); +} + + +static void +new_gtk_message_dialog_constructed +(GObject * object) +{ + GtkWidget * internal_vbox; + GtkWidget * box; + GtkWidget * message_area; + GtkWidget * label; + GtkWidget * secondary_label; + GtkWidget * action_area; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_message_dialog, constructed, (object)); + + apply_dialog_css (GTK_WIDGET (object)); + + gtk_container_set_border_width (GTK_CONTAINER (object), 5); + + internal_vbox = find_widget_by_name (GTK_WIDGET (object), + "dialog-vbox1"); + gtk_container_set_border_width (GTK_CONTAINER (internal_vbox), 2); + gtk_box_set_spacing (GTK_BOX (internal_vbox), 8); + + box = find_widget_by_name (internal_vbox, "box"); + gtk_widget_set_margin_start (box, 2); + gtk_widget_set_margin_end (box, 2); + gtk_container_set_border_width (GTK_CONTAINER (box), 5); + gtk_box_set_spacing (GTK_BOX (box), 12); + + message_area = find_widget_by_name (box, "message_area"); + gtk_box_set_spacing (GTK_BOX (message_area), 12); + + label = find_widget_by_name (message_area, "label"); + secondary_label = find_widget_by_name (message_area, + "secondary_label"); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_halign (secondary_label, GTK_ALIGN_START); + gtk_label_set_xalign (GTK_LABEL (label), 0); + gtk_label_set_xalign (GTK_LABEL (secondary_label), 0); + + action_area = find_widget_by_name (GTK_WIDGET (object), "action_area"); + gtk_container_set_border_width (GTK_CONTAINER (action_area), 5); + gtk_box_set_spacing (GTK_BOX (action_area), 6); + gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), + GTK_BUTTONBOX_END); +} + + +static void +new_gtk_message_dialog_notify +(GObject * object, + GParamSpec * pspec) +{ + GtkMessageType message_type; + const char * icon_name; + GtkWidget * image; + GtkMessageType image_message_type; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_message_dialog, + notify, (object, pspec)); + + + if (strcmp (pspec->name, "message-type") != 0) + return; + + g_object_get (object, "message-type", &message_type, NULL); + g_object_get (object, "image", &image, NULL); + + if (image != NULL) + { + image_message_type = GPOINTER_TO_INT ( + g_object_get_data (G_OBJECT (image), "message-type")) - 1; + if (image_message_type == message_type) + return; + } + + switch (message_type) + { + case GTK_MESSAGE_INFO: + icon_name = "dialog-information"; + break; + case GTK_MESSAGE_WARNING: + icon_name = "dialog-warning"; + break; + case GTK_MESSAGE_QUESTION: + icon_name = "dialog-question"; + break; + case GTK_MESSAGE_ERROR: + icon_name = "dialog-error"; + break; + default: + return; + } + + image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG); + gtk_widget_show (image); + g_object_set_data (G_OBJECT (image), "message-type", + GINT_TO_POINTER (message_type + 1)); + + g_object_freeze_notify (object); + g_object_set (object, "image", image, NULL); + g_object_set (object, "message-type", message_type, NULL); + g_object_thaw_notify (object); +} + + +static void +new_gtk_print_unix_dialog_constructed +(GObject * object) +{ + GtkWidget * internal_vbox; + GtkWidget * box; + GtkWidget * notebook; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_print_unix_dialog, + constructed, (object)); + + apply_dialog_css (GTK_WIDGET (object)); + + gtk_container_set_border_width (GTK_CONTAINER (object), 5); + + internal_vbox = find_widget_by_name (GTK_WIDGET (object), + "dialog-vbox1"); + gtk_container_set_border_width (GTK_CONTAINER (internal_vbox), 2); + + box = find_widget_by_name (internal_vbox, "box1"); + gtk_container_set_border_width (GTK_CONTAINER (box), 5); + + notebook = find_widget_by_name (box, "notebook"); + gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), TRUE); +} + + +static void +new_gtk_file_chooser_widget_constructed +(GObject * object) +{ + GtkWidget * treeview; + GtkWidget * search_entry; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_file_chooser_widget, + constructed, (object)); + + + apply_dialog_css (GTK_WIDGET (object)); + + + treeview = find_widget_by_name (GTK_WIDGET (object), + "browse_files_tree_view"); + + gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeview), TRUE); + + g_signal_connect (G_OBJECT (treeview), "notify::search-column", + G_CALLBACK (filechooser_treeview_search_column_changed), NULL); + + search_entry = find_widget_by_name (GTK_WIDGET (object), + "search_entry"); + + g_signal_connect (G_OBJECT (search_entry), "map", + G_CALLBACK (filechooser_search_entry_map), + treeview); + + g_signal_connect (G_OBJECT (search_entry), "unmap", + G_CALLBACK (filechooser_search_entry_unmap), + treeview); +} + + +static void +filechooser_treeview_search_column_changed +(GObject * object, + GParamSpec * pspec, + gpointer data) +{ + (void) pspec; + (void) data; + + + if (gtk_tree_view_get_search_column (GTK_TREE_VIEW (object)) == -1) + gtk_tree_view_set_search_column (GTK_TREE_VIEW (object), 0); +} + + +static void filechooser_search_entry_map +(GtkWidget * widget, + gpointer data) +{ + (void) widget; + gtk_tree_view_set_enable_search (GTK_TREE_VIEW (data), FALSE); +} + +static void filechooser_search_entry_unmap +(GtkWidget * widget, + gpointer data) +{ + (void) widget; + gtk_tree_view_set_enable_search (GTK_TREE_VIEW (data), TRUE); +} + + +/* Helper functions */ + +static void apply_dialog_css (GtkWidget * dialog) +{ + GdkScreen * screen; + gboolean dialog_css_applied; + GtkCssProvider * provider; + + + screen = gtk_widget_get_screen (dialog); + dialog_css_applied = + GPOINTER_TO_INT (g_object_get_data (G_OBJECT (screen), + "dialog-css-applied")); + if (! dialog_css_applied) + { + provider = gtk_css_provider_new (); + gtk_css_provider_load_from_data (provider, + MESSAGE_DIALOG_CSS + PRINT_DIALOG_CSS + FILE_CHOOSER_CSS, + -1, NULL); + gtk_style_context_add_provider_for_screen (screen, + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_SETTINGS); + g_object_set_data (G_OBJECT (screen), + "dialog-css-applied", + GINT_TO_POINTER (TRUE)); + } +} + + +static void add_widget_to_list (GtkWidget * widget, gpointer data) +{ + GSList ** list = data; + + + *list = g_slist_append (*list, widget); +} + + +static GtkWidget * +find_widget_by_name +(GtkWidget * start, + const char * name) +{ + const char * widget_name; + GtkWidget * widget; + GSList * list; + GSList * list_iter; + + + if (GTK_IS_BUILDABLE (start)) + { + widget_name = gtk_buildable_get_name (GTK_BUILDABLE (start)); + if (widget_name != NULL && strcmp (widget_name, name) == 0) + return start; + } + + if (GTK_IS_CONTAINER (start)) + { + list = NULL; + gtk_container_forall (GTK_CONTAINER (start), + add_widget_to_list, + &list); + for (list_iter = list; + list_iter != NULL; + list_iter = list_iter->next) + { + widget = + find_widget_by_name (GTK_WIDGET (list_iter->data), + name); + if (widget != NULL) + break; + } + + g_slist_free (list); + return widget; + } + + + return NULL; +} diff --git a/patches/icon-sizes.c b/patches/icon-sizes.c new file mode 100644 index 0000000..8ea8a0f --- /dev/null +++ b/patches/icon-sizes.c @@ -0,0 +1,325 @@ +/* Icon Sizes: + * + * Allows for the configuration of stock icon sizes via the GTK setting + * 'gtk-icon-sizes'. GTK (2) used to allow themes to choose the sizes of + * stock icons for various purposes; by default, button icons were 20x20 pixels + * (in reality, 24x24 icons usually were what GTK ended up using), whereas + * menu items used 16x16 icons. Some themes overrode these defaults with the + * 'gtk-icon-sizes' setting. Now, GTK ignores this setting entirely, and + * always uses 16x16 icons for buttons, which may not be such a bad thing if + * the icons weren't so small as to be nearly incomprehensible. + * + * You can change the size of the icons by adding to your settings.ini file: + * + * gtk-icon-sizes = gtk-button=24,24 + * + * More details regarding the exact syntax of this setting are available in + * the GTK Settings documentation, currently available at: + * https://docs.gtk.org/gtk3/property.Settings.gtk-icon-sizes.html + */ + + +#include +#include + +#include +#include +#include + +#include + + +#undef G_LOG_DOMAIN +#define G_LOG_DOMAIN "Gtk3-Classic::Icon-Sizes" + + +static GQuark icon_sizes_table_quark; + + +static void free_icon_sizes_table (gpointer data); +static void parse_icon_sizes_string (char * icon_sizes_string, + int * icon_sizes_table); + + +INTERCEPTED_CLASS_METHOD (gtk_settings, notify, + (GObject * object, + GParamSpec * pspec), + void) + + +INTERCEPTED_CLASS_METHOD (gtk_image, notify, + (GObject * object, + GParamSpec * pspec), + void) + + +void icon_sizes_init () +{ + { + GtkSettingsClass * gtk_settings_class = + g_type_class_ref (GTK_TYPE_SETTINGS); + + INTERCEPT_CLASS_METHOD (gtk_settings, G_OBJECT_CLASS, notify) + + g_type_class_unref (gtk_settings_class); + } + + + { + GtkImageClass * gtk_image_class = + g_type_class_ref (GTK_TYPE_IMAGE); + + INTERCEPT_CLASS_METHOD (gtk_image, G_OBJECT_CLASS, notify) + + g_type_class_unref (gtk_image_class); + } + + + icon_sizes_table_quark = g_quark_from_string ("icon-sizes-table"); +} + + +static void +new_gtk_settings_notify +(GObject * object, + GParamSpec * pspec) +{ + int * icon_sizes_table; + int i; + char * icon_sizes_string; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_settings, notify, (object, pspec)); + + if (strcmp (pspec->name, "gtk-icon-sizes") != 0) + return; + + icon_sizes_table = g_object_get_qdata (object, icon_sizes_table_quark); + if (icon_sizes_table == NULL) + { + icon_sizes_table = calloc (GTK_ICON_SIZE_DIALOG + 1, + sizeof (int)); + g_object_set_qdata_full (object, icon_sizes_table_quark, + icon_sizes_table, free_icon_sizes_table); + } + + /* Initialize the icon sizes table */ + for (i = 0; i <= GTK_ICON_SIZE_DIALOG; i++) + icon_sizes_table[i] = -1; + + g_object_get (object, "gtk-icon-sizes", &icon_sizes_string, NULL); + if (icon_sizes_string) + parse_icon_sizes_string (icon_sizes_string, icon_sizes_table); +} + + +static void +new_gtk_image_notify +(GObject * object, + GParamSpec * pspec) +{ + GtkSettings * settings; + GtkImage * image; + GtkWidget * image_parent; + char * stock_id; + int pixel_size; + GtkIconSize icon_size; + int * icon_sizes_table; + int i; + char * icon_sizes_string; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_image, notify, (object, pspec)); + + + image = GTK_IMAGE (object); + + if (strcmp (pspec->name, "stock") == 0) + { + g_object_get (object, "stock", &stock_id, NULL); + g_object_get (object, "icon-size", &icon_size, NULL); + if (stock_id != NULL) + { + g_object_freeze_notify (object); + gtk_image_set_from_icon_name (image, stock_id, icon_size); + g_object_thaw_notify (object); + } + return; + } + else if (strcmp (pspec->name, "pixel-size") == 0) + { + pixel_size = gtk_image_get_pixel_size (image); + if (pixel_size == 0) + gtk_image_set_pixel_size (image, -1); + else if (pixel_size != 16) + return; + image_parent = gtk_widget_get_parent (GTK_WIDGET (object)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + if (image_parent != NULL && + GTK_IS_IMAGE_MENU_ITEM (image_parent)) + { + g_object_set (object, + "icon-size", GTK_ICON_SIZE_MENU, + NULL); + } + else + return; + G_GNUC_END_IGNORE_DEPRECATIONS; + } + else if (strcmp (pspec->name, "icon-size") != 0) + return; + + g_object_get (object, "icon-size", &icon_size, NULL); + if (icon_size <= GTK_ICON_SIZE_INVALID || + icon_size > GTK_ICON_SIZE_DIALOG) + return; + + icon_sizes_table = g_object_get_qdata (object, icon_sizes_table_quark); + if (icon_sizes_table == NULL) + { + icon_sizes_table = calloc (GTK_ICON_SIZE_DIALOG + 1, + sizeof (int)); + g_object_set_qdata_full (object, icon_sizes_table_quark, + icon_sizes_table, free_icon_sizes_table); + + /* Initialize the icon sizes table */ + for (i = 0; i <= GTK_ICON_SIZE_DIALOG; i++) + icon_sizes_table[i] = -1; + + settings = gtk_widget_get_settings (GTK_WIDGET (image)); + g_object_get (G_OBJECT (settings), + "gtk-icon-sizes", &icon_sizes_string, + NULL); + if (icon_sizes_string) + parse_icon_sizes_string (icon_sizes_string, icon_sizes_table); + } + + gtk_image_set_pixel_size (image, icon_sizes_table[icon_size]); +} + + +/* Helper functions */ + +static void free_icon_sizes_table (gpointer data) +{ + free (data); +} + + +static void +parse_error +(const char * icon_sizes_string, + int position, + const char * error_message) +{ + g_warning ( +"Failed to parse GTK setting \'gtk-icon-sizes\' at character offset %d:\n" +"%s\n" +" %s\n" +" %*.1s\n", + position, error_message, icon_sizes_string, position, "^"); +} + + +static void +parse_icon_sizes_string +(char * icon_sizes_string, + int * icon_sizes_table) +{ + const char * size_names_table[] = + { + NULL, + "gtk-menu", + "gtk-small-toolbar", + "gtk-large-toolbar", + "gtk-button", + "gtk-dnd", + "gtk-dialog", + NULL + }; + + int i; + int j; + char * size_name; + int size_name_length; + char * p; + long width; + long height; + + + i = 0; + while (icon_sizes_string[i] != '\0') + { + /* Skip over any spaces preceding the icon size name */ + while (isspace (icon_sizes_string[i])) + i++; + + /* Collect the size name */ + size_name = &icon_sizes_string[i]; + size_name_length = 0; + while (isalnum (size_name[size_name_length]) || + size_name[size_name_length] == '-' || + size_name[size_name_length] == '_') + size_name_length++; + size_name = strndup (size_name, size_name_length); + + /* Skip over any spaces following the icon size name */ + i += size_name_length; + while (isspace (icon_sizes_string[i])) + i++; + + if (icon_sizes_string[i] != '=') + { + parse_error (icon_sizes_string, i, "Expected \'=\'"); + free (size_name); + return; + } + else + i++; + + /* Read the icon width and height */ + width = 0; + height = 0; + width = strtol (&icon_sizes_string[i], &p, 0); + while (isspace (*p)) + p++; + if (*p == ',') + height = strtol (p+1, &p, 0); + if (height <= 0) + height = width; + + if (*p == ':') + p++; + i = p - icon_sizes_string; + + + for (j = 1; size_names_table[j] != NULL; j++) + if (strcmp (size_name, size_names_table[j]) == 0) + break; + + if (size_names_table[j] == NULL) + { + parse_error (icon_sizes_string, i, + "Unknown icon size name"); + } + else if (width <= 0 || width > 256) + { + parse_error (icon_sizes_string, i, + "Icon width is suspicious, should be" + " between 1 and 256 px"); + } + else if (height <= 0 || height > 256) + { + parse_error (icon_sizes_string, i, + "Icon height is suspicious, should be" + " between 1 and 256 px"); + } + else + { + icon_sizes_table[j] = (int) MAX (width, height); + } + + + free (size_name); + } +} diff --git a/patches/no-emojis.c b/patches/no-emojis.c new file mode 100644 index 0000000..dc7dd89 --- /dev/null +++ b/patches/no-emojis.c @@ -0,0 +1,61 @@ +/* No Emojis: + * (from gtk3-classic patch 'other__hide-insert-emoji.patch') + * + * Hides the 'Insert Emoji' menu item found at the bottom of the context menus + * for GtkEntry and GtkTextView widgets. + * + * Set the environment variable GTKM_INSERT_EMOJI=1 to restore the menu items. + */ + + +#include +#include + +#include +#include + +#include + + +#undef G_LOG_DOMAIN +#define G_LOG_DOMAIN "Gtk3-Classic::No-Emojis" + + +INTERCEPTED_CLASS_METHOD (gtk_menu_item, show, + (GtkWidget * widget), + void) + + +void no_emojis_init () +{ + GtkMenuItemClass * gtk_menu_item_class = + g_type_class_ref (GTK_TYPE_MENU_ITEM); + + INTERCEPT_CLASS_METHOD ( + gtk_menu_item, GTK_WIDGET_CLASS, show) + + g_type_class_unref (gtk_menu_item_class); +} + + +static void +new_gtk_menu_item_show +(GtkWidget * widget) + +{ + const char * gtkm_insert_emoji; + const char * label; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_menu_item, show, + (widget)); + + + gtkm_insert_emoji = getenv ("GTKM_INSERT_EMOJI"); + if (gtkm_insert_emoji != NULL && strcmp (gtkm_insert_emoji, "1") == 0) + return; + + label = gtk_menu_item_get_label (GTK_MENU_ITEM (widget)); + if (label != NULL && strcmp (label, _("Insert _Emoji")) == 0) + gtk_widget_hide (widget); +} diff --git a/patches/persistent-mnemonics.c b/patches/persistent-mnemonics.c new file mode 100644 index 0000000..311815e --- /dev/null +++ b/patches/persistent-mnemonics.c @@ -0,0 +1,100 @@ +/* Persistent mnemonics: + * (from 'sgm-flexible-mnemonics.c' [https://github.com/thesquash/sgm]) + * + * Restores the behaviour of the GTK setting 'gtk-auto-mnemonics'. When this + * setting is set (TRUE, the default), mnemonic letters on buttons and menu + * items will be underlined only while the key is pressed; when unset + * (FALSE), mnemonics will always be underlined. + * + * Enable the latter behaviour by adding to your settings.ini file: + * + * gtk-auto-mnemonics = 0 + */ + + +#include +#include + +#include + + +#undef G_LOG_DOMAIN +#define G_LOG_DOMAIN "Gtk3-Classic::Persistent-Mnemonics" + + +INTERCEPTED_CLASS_METHOD (gtk_window, notify, + (GObject * object, + GParamSpec * pspec), + void) + + +INTERCEPTED_CLASS_METHOD (gtk_menu_shell, deactivate, + (GtkMenuShell * menu_shell), + void) + + +void persistent_mnemonics_init () +{ + { + GtkWindowClass * gtk_window_class = + g_type_class_ref (GTK_TYPE_WINDOW); + + INTERCEPT_CLASS_METHOD (gtk_window, G_OBJECT_CLASS, notify) + + g_type_class_unref (gtk_window_class); + } + + + { + GtkMenuShellClass * gtk_menu_shell_class = + g_type_class_ref (GTK_TYPE_MENU_SHELL); + + INTERCEPT_CLASS_METHOD (gtk_menu_shell, GTK_MENU_SHELL_CLASS, + deactivate) + + g_type_class_unref (gtk_menu_shell_class); + } +} + + +static void +new_gtk_window_notify +(GObject * object, + GParamSpec * pspec) +{ + GtkSettings * settings; + gboolean auto_mnemonics; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_window, notify, (object, pspec)); + + if (strcmp (pspec->name, "mnemonics-visible") != 0) + return; + + if (! gtk_window_get_mnemonics_visible (GTK_WINDOW (object))) + { + settings = gtk_widget_get_settings (GTK_WIDGET (object)); + g_object_get (settings, + "gtk-auto-mnemonics", &auto_mnemonics, + NULL); + if (! auto_mnemonics) + gtk_window_set_mnemonics_visible (GTK_WINDOW (object), + TRUE); + } +} + + +static void +new_gtk_menu_shell_deactivate +(GtkMenuShell * menu_shell) +{ + GtkWidget * toplevel; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_menu_shell, deactivate, (menu_shell)); + + + toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu_shell)); + if (toplevel) + g_object_notify (G_OBJECT (toplevel), "mnemonics-visible"); +} diff --git a/patches/smaller-widgets.c b/patches/smaller-widgets.c new file mode 100644 index 0000000..3b9888f --- /dev/null +++ b/patches/smaller-widgets.c @@ -0,0 +1,262 @@ +/* Smaller Widgets: + * (based on gtk3-classic CSS 'smaller-adwaita.css', and gtk3-classic patch + * 'appearance__smaller-statusbar.patch'): + * + * Reduces the size of certain widgets, especially when the built-in GTK themes + * (Adwaita and HighContrast) are in use, in the spirit of more traditional + * GTK themes for prior versions of GTK. + */ + + +#include +#include +#include + +#include + +#include + + +#undef G_LOG_DOMAIN +#define G_LOG_DOMAIN "Gtk3-Classic::Smaller-Widgets" + + +#define CSS \ + "button,\n" \ + "button.titlebutton,\n" \ + "button.image-button,\n" \ + "button.text-button,\n" \ + "button.image-button.text-button,\n" \ + ".stack-switcher > button.text-button {\n" \ + " padding: 3px 6px;\n" \ + " min-height: 20px;\n" \ + " min-width: 0;\n" \ + "}\n" \ + ".stack-switcher > button.text-button {\n" \ + " min-width: 80px;\n" \ + "}\n" \ + "button.text-button.image-button label {\n" \ + " padding: 0 2px;\n" \ + "}\n" \ + "notebook > header.top tab,\n" \ + "notebook > header.bottom tab {\n" \ + " padding: 0 5px;\n" \ + "}\n" \ + "notebook > header.left tab,\n" \ + "notebook > header.right tab {\n" \ + " padding: 0 8px;\n" \ + "}\n" \ + "notebook tab button {\n" \ + " padding: 0px;\n" \ + " min-height: 15px;\n" \ + "}\n" \ + "entry,\n" \ + "spinbutton:not(.vertical) {\n" \ + " min-height: 26px;\n" \ + "}\n" \ + "treeview button {\n" \ + " padding: 0 7px;\n" \ + " min-height: 23px;\n" \ + "}\n" \ + "progressbar.horizontal trough,\n" \ + "progressbar.horizontal progress,\n" \ + "progressbar.vertical trough,\n" \ + "progressbar.vertical progress,\n" \ + "levelbar trough {\n" \ + " min-height: 9px;\n" \ + " min-width: 9px;\n" \ + "}\n" \ + "scale {\n" \ + " padding: 10px 0;\n" \ + "}\n" \ + "headerbar, switch slider {\n" \ + " min-height: 0;\n" \ + "}\n" \ + "popover:not(.emoji-picker) > *:not(grid) {\n" \ + " margin: -3px;\n" \ + "}\n" \ + "tooltip * {\n" \ + " padding: 0px;\n" \ + "}\n" \ + "placessidebar row {\n" \ + " min-height: 29px;\n" \ + "}\n" \ + "placessidebar row button.sidebar-button {\n" \ + " min-height: 20px;\n" \ + " min-width: 20px;\n" \ + " padding: 0;\n" \ + "}\n" \ + "filechooser > box.search-bar, filechooser > box:last-child {\n" \ + " border-bottom: 1px solid alpha(#000, 0.15);\n" \ + "}\n" \ + "filechooser > actionbar > revealer > box {\n" \ + " border-top: 1px solid alpha(#000, 0.15);\n" \ + "}\n" \ + "* {\n" \ + " -GtkDialog-action-area-border: 5;\n" \ + "}\n" \ + "messagedialog > box {\n" \ + " padding: 7px;\n" \ + "}\n" \ + "messagedialog buttonbox {\n" \ + " margin-top: -17px;\n" \ + "}\n" \ + "menu, .menu, .context-menu, tooltip {\n" \ + " border-radius: 0;\n" \ + "}\n" \ + ".background:not(.csd):not(.solid-csd) .titlebar:not(.default-decoration),\n" \ + ".background:not(.csd):not(.solid-csd) .titlebar:not(.default-decoration) headerbar {\n" \ + " background: inherit;\n" \ + "}\n" \ + "entry undershoot.left,\n" \ + "entry undershoot.right,\n" \ + "spinbutton:not(.vertical) undershoot.left,\n" \ + "spinbutton:not(.vertical) undershoot.right,\n" \ + "scrolledwindow undershoot.left,\n" \ + "scrolledwindow undershoot.right,\n" \ + "scrolledwindow undershoot.top,\n" \ + "scrolledwindow undershoot.bottom {\n" \ + " background-image: none;\n" \ + "}\n" + + +INTERCEPTED_CLASS_METHOD (gtk_settings, notify, + (GObject * object, + GParamSpec * pspec), + void) + + +INTERCEPTED_CLASS_METHOD (gtk_window, constructed, + (GObject * object), + void) + + +INTERCEPTED_CLASS_METHOD (gtk_statusbar, constructed, + (GObject * object), + void) + + +void smaller_widgets_init () +{ + { + GtkSettingsClass * gtk_settings_class = + g_type_class_ref (GTK_TYPE_SETTINGS); + + INTERCEPT_CLASS_METHOD (gtk_settings, G_OBJECT_CLASS, + notify) + + g_type_class_unref (gtk_settings_class); + } + + + { + GtkWindowClass * gtk_window_class = + g_type_class_ref (GTK_TYPE_WINDOW); + + INTERCEPT_CLASS_METHOD (gtk_window, G_OBJECT_CLASS, + constructed) + + g_type_class_unref (gtk_window_class); + } + + + { + GtkStatusbarClass * gtk_statusbar_class = + g_type_class_ref (GTK_TYPE_STATUSBAR); + + INTERCEPT_CLASS_METHOD (gtk_statusbar, G_OBJECT_CLASS, + constructed) + + g_type_class_unref (gtk_statusbar_class); + } +} + + +static void +new_gtk_settings_notify +(GObject * object, + GParamSpec * pspec) +{ + const char * theme_name; + GdkScreen * screen; + GtkCssProvider * provider; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_settings, notify, (object, pspec)); + + + if (strcmp (pspec->name, "gtk-theme-name") != 0) + return; + + g_object_get (object, "gtk-theme-name", &theme_name, NULL); + + screen = g_object_get_data (object, "screen"); + if (screen == NULL) + return; + + provider = g_object_get_data (G_OBJECT (screen), + "smaller-adwaita-css"); + if (provider == NULL) + return; + + if (strcmp (theme_name, "Adwaita") == 0 || + strcmp (theme_name, "Adwaita-Dark") == 0 || + strcmp (theme_name, "HighContrast") == 0 || + strcmp (theme_name, "HighContrastInverse") == 0) + gtk_style_context_add_provider_for_screen (screen, + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_SETTINGS); + else + gtk_style_context_remove_provider_for_screen (screen, + GTK_STYLE_PROVIDER (provider)); +} + + +static void +new_gtk_window_constructed +(GObject * object) +{ + GdkScreen * screen; + GtkCssProvider * provider; + GtkSettings * settings; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_window, constructed, (object)); + + + screen = gtk_widget_get_screen (GTK_WIDGET (object)); + provider = g_object_get_data (G_OBJECT (screen), + "smaller-adwaita-css"); + if (provider == NULL) + { + provider = gtk_css_provider_new (); + gtk_css_provider_load_from_data (provider, CSS, -1, NULL); + g_object_set_data (G_OBJECT (screen), + "smaller-adwaita-css", + provider); + + settings = gtk_settings_get_for_screen (screen); + g_object_set_data (G_OBJECT (settings), "screen", screen); + g_object_notify (G_OBJECT (settings), + "gtk-theme-name"); + } + +} + + +static void +new_gtk_statusbar_constructed +(GObject * object) +{ + GtkStyleContext * style_context; + + + CALL_ORIGINAL_CLASS_METHOD (gtk_statusbar, constructed, (object)); + + + style_context = gtk_widget_get_style_context (GTK_WIDGET (object)); + gtk_style_context_add_class (style_context, "classic"); + + gtk_widget_set_margin_top (GTK_WIDGET (object), 1); + gtk_widget_set_margin_bottom (GTK_WIDGET (object), 1); +} diff --git a/screenshots/button-icons.png b/screenshots/button-icons.png new file mode 100644 index 0000000..9102ddc Binary files /dev/null and b/screenshots/button-icons.png differ diff --git a/screenshots/dialog-with-classic-buttons.png b/screenshots/dialog-with-classic-buttons.png new file mode 100644 index 0000000..76fc99f Binary files /dev/null and b/screenshots/dialog-with-classic-buttons.png differ diff --git a/screenshots/menu-icons.png b/screenshots/menu-icons.png new file mode 100644 index 0000000..e2d412e Binary files /dev/null and b/screenshots/menu-icons.png differ diff --git a/screenshots/message-dialog.png b/screenshots/message-dialog.png new file mode 100644 index 0000000..fb29f36 Binary files /dev/null and b/screenshots/message-dialog.png differ diff --git a/screenshots/persistent-mnemonics.png b/screenshots/persistent-mnemonics.png new file mode 100644 index 0000000..3c811ef Binary files /dev/null and b/screenshots/persistent-mnemonics.png differ -- cgit