aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore19
-rw-r--r--COPYING15
-rw-r--r--DEPENDENCIES1
-rw-r--r--LICENSE683
-rw-r--r--Makefile210
-rw-r--r--README1
-rw-r--r--config.mk10
-rw-r--r--include-libgamma.h2
-rw-r--r--libgamma.py4
-rw-r--r--libgamma_error.py (renamed from src/libgamma_error.py)199
-rw-r--r--libgamma_facade.py (renamed from src/libgamma_facade.py)85
-rw-r--r--libgamma_method.py (renamed from src/libgamma_method.py)526
-rw-r--r--libgamma_native_error.posix.pyx (renamed from src/libgamma_native_error.pyx)101
-rw-r--r--libgamma_native_error.w32.pyx (renamed from src/libgamma_native_error.w32.pyx)84
-rw-r--r--libgamma_native_facade.pyx (renamed from src/libgamma_native_facade.pyx)1028
-rw-r--r--libgamma_native_method.pyx (renamed from src/libgamma_native_method.pyx)592
-rw-r--r--mk/linux.mk2
-rw-r--r--mk/macos.mk2
-rw-r--r--mk/windows.mk2
-rw-r--r--src/include-libgamma.h19
-rw-r--r--src/libgamma.py23
-rwxr-xr-xtest.py (renamed from src/test.py)21
22 files changed, 1263 insertions, 2366 deletions
diff --git a/.gitignore b/.gitignore
index cbc0dc0..b6f2c48 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,18 +1,17 @@
-_/
-bin/
-obj/
-\#*\#
-.*
-!.git*
+*\#*
*~
__pycache__/
*.bak
-*.sw[op]
+*.swo
+*.swp
*.o
*.out
*.su
*.so
+*.dll
+*.dylib
*.gch
-*.py[co]
-src/*_native_*.c
-
+*.pyo
+*.pyo
+*_native_*.c
+/libgamma_native_error.pyx
diff --git a/COPYING b/COPYING
deleted file mode 100644
index eac493e..0000000
--- a/COPYING
+++ /dev/null
@@ -1,15 +0,0 @@
-pylibgamma — Python 3 wrapper for libgamma
-Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
-
-This library 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 library 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 library. If not, see <http://www.gnu.org/licenses/>.
diff --git a/DEPENDENCIES b/DEPENDENCIES
index 217abad..3acdb68 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -21,4 +21,3 @@ INSTALL DEPENDENCIES:
make
coreutils
-
diff --git a/LICENSE b/LICENSE
index 94a9ed0..d3ebfaa 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,674 +1,15 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
+ISC License
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
+© 2014, 2022 Mattias Andrée <maandree@kth.se>
- Preamble
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/Makefile b/Makefile
index df1e521..ab06f19 100644
--- a/Makefile
+++ b/Makefile
@@ -1,190 +1,62 @@
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
+.POSIX:
+CONFIGFILE = config.mk
+include $(CONFIGFILE)
-# The package path prefix, if you want to install to another root, set DESTDIR to that root
-PREFIX ?= /usr
-# The library path excluding prefix
-LIB ?= /lib
-# The resource path excluding prefix
-DATA ?= /share
-# The library path including prefix
-LIBDIR ?= $(PREFIX)$(LIB)
-# The resource path including prefix
-DATADIR ?= $(PREFIX)$(DATA)
-# The generic documentation path including prefix
-DOCDIR ?= $(DATADIR)/doc
-# The info manual documentation path including prefix
-INFODIR ?= $(DATADIR)/info
-# The license base path including prefix
-LICENSEDIR ?= $(DATADIR)/licenses
+OS = linux
+include mk/$(OS).mk
-# The target and host platform
-PLATFORM = posix
-# The major version number of the current Python installation
-PY_MAJOR = 3
-# The minor version number of the current Python installation
-PY_MINOR = 5
-# The version number of the current Python installation without a dot
-PY_VER = $(PY_MAJOR)$(PY_MINOR)
-# The version number of the current Python installation with a dot
-PY_VERSION = $(PY_MAJOR).$(PY_MINOR)
+python = python$(PYTHON_MAJOR)
+python_version = $(PYTHON_MAJOR).$(PYTHON_MINOR)
+python_ver = $(PYTHON_MAJOR)$(PYTHON_MINOR)
+python_dir = $(PREFIX)/lib/python$(python_version)/site-packages
+python_cache = $(python_dir)/__pycache__
-# The directory for python modules
-PYTHONDIR = $(LIBDIR)/python$(PY_VERSION)
-# The name of the package as it should be installed
-PKGNAME = pylibgamma
+OBJ =\
+ libgamma_native_error.o\
+ libgamma_native_facade.o\
+ libgamma_native_method.o
+PYSRC =\
+ libgamma.py\
+ libgamma_error.py\
+ libgamma_facade.py\
+ libgamma_method.py
-# The installed pkg-config command
-PKGCONFIG ?= pkg-config
-# The installed cython command
-CYTHON ?= cython
-# The installed python command
-PYTHON = python$(PY_MAJOR)
+LIBFILES = $(OBJ:.o=.$(LIBEXT))
+FILES = $(PYSRC) $(LIBFILES)
-# Libraries to link with using pkg-config
-LIBS = python$(PY_MAJOR)
+all: $(LIBFILES)
-# The C standard for C code compilation
-STD = c99
-# Optimisation settings for C code compilation
-OPTIMISE ?= -Og -g
+libgamma_native_error.pyx: libgamma_native_error.$(PLATFORM).pyx
+ cp -- $< $@
+.o.$(LIBEXT):
+ $(CC) -o $@ $< -shared $(LDFLAGS)
+.c.o:
+ $(CC) -fPIC -c -o $@ $< $$(pkg-config --cflags $(python)) $(CFLAGS) $(CPPFLAGS)
-# Flags to use when compiling
-CC_FLAGS = $$($(PKGCONFIG) --cflags $(LIBS)) -std=$(STD) \
- $(OPTIMISE) -fPIC $(CFLAGS) $(CPPFLAGS)
+.pyx.c:
+ if ! cython -$(PYTHON_MAJOR) -v $< -o $@ ; then rm $@; false; fi
-# Flags to use when linking
-LD_FLAGS = $$($(PKGCONFIG) --libs $(LIBS)) -lgamma -std=$(STD) \
- $(OPTIMISE) -shared $(LDFLAGS)
+install: $(LIBFILES)
+ mkdir -p -- "$(DESTDIR)$(python_dir)"
+ cp -- $(FILES) "$(DESTDIR)$(python_dir)/"
-
-# The suffixless basename of the .py-files
-PYTHON_SRC = libgamma_error libgamma_facade libgamma_method libgamma
-
-# The suffixless basename of the .py-files
-CYTHON_SRC = libgamma_native_error libgamma_native_facade libgamma_native_method
-
-
-# Filename extension for -OO optimised python files
-ifeq ($(shell test $(PY_VER) -ge 35 ; echo $$?),0)
-PY_OPT2_EXT = opt-2.pyc
-else
-PY_OPT2_EXT = pyo
-endif
-
-
-
-.PHONY: all pyc-files pyo-files so-files
-all: pyc-files pyo-files so-files
-pyc-files: $(foreach M,$(PYTHON_SRC),src/__pycache__/$(M).cpython-$(PY_VER).pyc)
-pyo-files: $(foreach M,$(PYTHON_SRC),src/__pycache__/$(M).cpython-$(PY_VER).$(PY_OPT2_EXT))
-so-files: $(foreach M,$(CYTHON_SRC),bin/$(M).so)
-
-bin/%.so: obj/%.o
- @mkdir -p bin
- $(CC) $(LD_FLAGS) -o $@ $^
-
-obj/%.o: obj/%.c src/*.h
- $(CC) $(CC_FLAGS) -iquote"src" -c -o $@ $<
-
-obj/%.c: obj/%.pyx
- if ! $(CYTHON) -3 -v $< ; then rm $@ ; false ; fi
-
-obj/libgamma_native_facade.pyx: src/libgamma_native_facade.pyx
- @mkdir -p obj
- cp $< $@
-
-obj/libgamma_native_method.pyx: src/libgamma_native_method.pyx
- @mkdir -p obj
- cp $< $@
-
-ifeq ($(PLATFORM),windows)
-obj/libgamma_native_error.pyx: src/libgamma_native_error.w32.pyx
- @mkdir -p obj
- cp $< $@
-else
-obj/libgamma_native_error.pyx: src/libgamma_native_error.pyx
- @mkdir -p obj
- cp $< $@
-endif
-
-src/__pycache__/%.cpython-$(PY_VER).pyc: src/%.py
- $(PYTHON) -m compileall $<
-
-src/__pycache__/%.cpython-$(PY_VER).$(PY_OPT2_EXT): src/%.py
- $(PYTHON) -OO -m compileall $<
-
-
-.PHONY: install
-install: install-base
-
-.PHONY: install-all
-install-all: install-base
-
-.PHONY: install-base
-install-base: install-lib install-copyright
-
-
-.PHONY: install-lib
-install-lib: install-source install-compiled install-optimised install-native
-
-.PHONY: install-source
-install-source: $(foreach M,$(PYTHON_SRC),src/$(M).py)
- install -dm755 -- "$(DESTDIR)$(PYTHONDIR)"
- install -m644 $^ -- "$(DESTDIR)$(PYTHONDIR)"
-
-.PHONY: install-compiled
-install-compiled: $(foreach M,$(PYTHON_SRC),src/__pycache__/$(M).cpython-$(PY_VER).pyc)
- install -dm755 -- "$(DESTDIR)$(PYTHONDIR)/__pycache__"
- install -m644 $^ -- "$(DESTDIR)$(PYTHONDIR)/__pycache__"
-
-.PHONY: install-optimised
-install-optimised: $(foreach M,$(PYTHON_SRC),src/__pycache__/$(M).cpython-$(PY_VER).$(PY_OPT2_EXT))
- install -dm755 -- "$(DESTDIR)$(PYTHONDIR)/__pycache__"
- install -m644 $^ -- "$(DESTDIR)$(PYTHONDIR)/__pycache__"
-
-.PHONY: install-native
-install-native: $(foreach M,$(CYTHON_SRC),bin/$(M).so)
- install -dm755 -- "$(DESTDIR)$(PYTHONDIR)"
- install -m755 $^ -- "$(DESTDIR)$(PYTHONDIR)"
-
-
-.PHONY: install-copyright
-install-copyright: install-copying install-license
-
-.PHONY: install-copying
-install-copying: COPYING
- install -dm755 -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- install -m644 $^ -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
-
-.PHONY: install-license
-install-license: LICENSE
- install -dm755 -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- install -m644 $^ -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
-
-
-
-.PHONY: uninstall
uninstall:
- -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE"
- -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING"
- -rmdir -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- -rm -- $(foreach M,$(PYTHON_SRC),"$(DESTDIR)$(PYTHONDIR)/__pycache__/$(M).cpython-$(PY_VER).$(PY_OPT2_EXT)")
- -rm -- $(foreach M,$(PYTHON_SRC),"$(DESTDIR)$(PYTHONDIR)/__pycache__/$(M).cpython-$(PY_VER).pyc")
- -rm -- $(foreach M,$(PYTHON_SRC),"$(DESTDIR)$(PYTHONDIR)/$(M).py")
- -rm -- $(foreach M,$(CYTHON_SRC),"$(DESTDIR)$(PYTHONDIR)/$(M).so")
+ -cd -- "$(DESTDIR)$(python_dir)" && rm -f -- $(FILES)
+run-test: $(LIBFILES)
+ ./test.py
-.PHONY: clean
clean:
- -rm -r obj bin src/__pycache__
+ -rm -rf -- *.$(LIBEXT) *.o *_native_*.c *.pyc *.pyo __pycache__ libgamma_native_error.pyx
+
+.SUFFIXES:
+.SUFFIXES: .$(LIBEXT) .o .c .pyx
+.PHONY: all install uninstall check run-test clean
diff --git a/README b/README
index 99ab71e..55c4546 100644
--- a/README
+++ b/README
@@ -10,4 +10,3 @@ SEE ALSO
libgamma(7)
Full documentation available locally via the command help in python(1).
-
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..51eba37
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,10 @@
+PREFIX = /usr
+
+PYTHON_MAJOR = $$(python --version 2>&1 | cut -d . -f 1 | cut -d ' ' -f 2)
+PYTHON_MINOR = $$(python$(PYTHON_MAJOR) --version 2>&1 | cut -d . -f 2)
+
+CC = c99
+
+CPPFLAGS =
+CFLAGS =
+LDFLAGS = -lgamma
diff --git a/include-libgamma.h b/include-libgamma.h
new file mode 100644
index 0000000..bd1a562
--- /dev/null
+++ b/include-libgamma.h
@@ -0,0 +1,2 @@
+/* See LICENSE file for copyright and license details. */
+#include <libgamma.h>
diff --git a/libgamma.py b/libgamma.py
new file mode 100644
index 0000000..fd0e7ae
--- /dev/null
+++ b/libgamma.py
@@ -0,0 +1,4 @@
+# See LICENSE file for copyright and license details.
+from libgamma_error import *
+from libgamma_method import *
+from libgamma_facade import *
diff --git a/src/libgamma_error.py b/libgamma_error.py
index afefd5e..bd3a9aa 100644
--- a/src/libgamma_error.py
+++ b/libgamma_error.py
@@ -1,74 +1,55 @@
-# -*- python -*-
-'''
-pylibgamma — Python 3 wrapper for libgamma
-Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
-
-This library 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 library 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 library. If not, see <http://www.gnu.org/licenses/>.
-'''
-
-
+# See LICENSE file for copyright and license details.
class LibgammaGroup:
'''
Class for `group`
'''
-
+
@property
def gid(self) -> int:
'''
- Getter.
+ Getter
Group that the user needs to be a member of if
- `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned.
+ `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned
'''
from libgamma_native_error import libgamma_native_get_group_gid
return libgamma_native_get_group_gid()
-
+
@gid.setter
def gid(self, value : int):
'''
- Setter.
+ Setter
Group that the user needs to be a member of if
- `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned.
+ `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned
'''
from libgamma_native_error import libgamma_native_set_group_gid
libgamma_native_set_group_gid(value)
-
-
+
+
@property
def name(self) -> str:
'''
- Getter.
+ Getter
Group that the user needs to be a member of if
`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned,
`None` if the name of the group `group.gid`
- cannot be determined.
+ cannot be determined
'''
from libgamma_native_error import libgamma_native_get_group_name
return libgamma_native_get_group_name()
-
+
@name.setter
def name(self, value : str):
'''
- Setter.
+ Setter
Group that the user needs to be a member of if
`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned,
`None` if the name of the group `group.gid`
- cannot be determined.
+ cannot be determined
'''
from libgamma_native_error import libgamma_native_set_group_name
libgamma_native_set_group_name(value)
@@ -77,7 +58,7 @@ class LibgammaGroup:
group = LibgammaGroup()
'''
Group that the user needs to be a member of if
-`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned.
+`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned
'''
@@ -96,8 +77,8 @@ def perror(name : str, error_code : int):
required group will be printed with its numerical value
and, if known, its name.
- @param name The text to add at the beginning.
- @param value The error code, may be an `errno` value.
+ @param name The text to add at the beginning
+ @param value The error code, may be an `errno` value
'''
from libgamma_native_error import libgamma_native_perror
libgamma_native_perror(name, error_code)
@@ -105,11 +86,11 @@ def perror(name : str, error_code : int):
def name_of_error(value : int) -> str:
'''
- Returns the name of the definition associated with a `libgamma` error code.
+ Returns the name of the definition associated with a `libgamma` error code
- @param value The error code.
+ @param value The error code
@return The name of the definition associated with the error code,
- `None` if the error code does not exist.
+ `None` if the error code does not exist
'''
from libgamma_native_error import libgamma_native_name_of_error
return libgamma_native_name_of_error(value)
@@ -117,11 +98,11 @@ def name_of_error(value : int) -> str:
def value_of_error(name : str) -> int:
'''
- Return the value of a `libgamma` error definition refered to by name.
+ Return the value of a `libgamma` error definition refered to by name
- @param name The name of the definition associated with the error code.
+ @param name The name of the definition associated with the error code
@return The error code, zero if the name is `None`
- or does not refer to a `libgamma` error.
+ or does not refer to a `libgamma` error
'''
from libgamma_native_error import libgamma_native_value_of_error
return libgamma_native_value_of_error(name)
@@ -131,126 +112,126 @@ def value_of_error(name : str) -> int:
LIBGAMMA_ERRNO_SET = -1
'''
`errno` has be set with a standard error number
-to indicate the what has gone wrong.
+to indicate the what has gone wrong
'''
LIBGAMMA_NO_SUCH_ADJUSTMENT_METHOD = -2
'''
The selected adjustment method does not exist
-or has been excluded at compile-time.
+or has been excluded at compile-time
'''
LIBGAMMA_NO_SUCH_SITE = -3
'''
-The selected site does not exist.
+The selected site does not exist
'''
LIBGAMMA_NO_SUCH_PARTITION = -4
'''
-The selected partition does not exist.
+The selected partition does not exist
'''
LIBGAMMA_NO_SUCH_CRTC = -5
'''
-The selected CRTC does not exist.
+The selected CRTC does not exist
'''
LIBGAMMA_IMPOSSIBLE_AMOUNT = -6
'''
Counter overflowed when counting the number
-of available items.
+of available items
'''
LIBGAMMA_CONNECTOR_DISABLED = -7
'''
The selected connector is disabled, it does
-not have a CRTC.
+not have a CRTC
'''
LIBGAMMA_OPEN_CRTC_FAILED = -8
'''
The selected CRTC could not be opened,
-reason unknown.
+reason unknown
'''
LIBGAMMA_CRTC_INFO_NOT_SUPPORTED = -9
'''
The CRTC information field is not supported
-by the adjustment method.
+by the adjustment method
'''
LIBGAMMA_GAMMA_RAMP_READ_FAILED = -10
'''
Failed to read the current gamma ramps for
-the selected CRTC, reason unknown.
+the selected CRTC, reason unknown
'''
LIBGAMMA_GAMMA_RAMP_WRITE_FAILED = -11
'''
Failed to write the current gamma ramps for
-the selected CRTC, reason unknown.
+the selected CRTC, reason unknown
'''
LIBGAMMA_GAMMA_RAMP_SIZE_CHANGED = -12
'''
The specified ramp sizes does not match the
ramps sizes returned by the adjustment methods
-in response to the query/command.
+in response to the query/command
'''
LIBGAMMA_MIXED_GAMMA_RAMP_SIZE = -13
'''
The specified ramp sizes are not identical
-which is required by the adjustment method.
-(Only returned in debug mode.)
+which is required by the adjustment method
+(Only returned in debug mode)
'''
LIBGAMMA_WRONG_GAMMA_RAMP_SIZE = -14
'''
The specified ramp sizes are not supported
-by the adjustment method.
-(Only returned in debug mode.)
+by the adjustment method
+(Only returned in debug mode)
'''
LIBGAMMA_SINGLETON_GAMMA_RAMP = -15
'''
The adjustment method reported that the gamma
-ramps size is 1, or perhaps even zero or negative.
+ramps size is 1, or perhaps even zero or negative
'''
LIBGAMMA_LIST_CRTCS_FAILED = -16
'''
The adjustment method failed to list
-available CRTC:s, reason unknown.
+available CRTC:s, reason unknown
'''
LIBGAMMA_ACQUIRING_MODE_RESOURCES_FAILED = -17
'''
Failed to acquire mode resources from the
-adjustment method.
+adjustment method
'''
LIBGAMMA_NEGATIVE_PARTITION_COUNT = -18
'''
The adjustment method reported that a negative
-number of partitions exists in the site.
+number of partitions exists in the site
'''
LIBGAMMA_NEGATIVE_CRTC_COUNT = -19
'''
The adjustment method reported that a negative
-number of CRTC:s exists in the partition.
+number of CRTC:s exists in the partition
'''
LIBGAMMA_DEVICE_RESTRICTED = -20
'''
Device cannot be access becauses of
-insufficient permissions.
+insufficient permissions
'''
LIBGAMMA_DEVICE_ACCESS_FAILED = -21
'''
-Device cannot be access, reason unknown.
+Device cannot be access, reason unknown
'''
LIBGAMMA_DEVICE_REQUIRE_GROUP = -22
@@ -258,150 +239,150 @@ LIBGAMMA_DEVICE_REQUIRE_GROUP = -22
Device cannot be access, membership of the
`group.gid` (named by `group.name` (can be
`None`, if so `errno` may have been set to
-tell why)) is required.
+tell why)) is required
'''
LIBGAMMA_GRAPHICS_CARD_REMOVED = -23
'''
-The graphics card appear to have been removed.
+The graphics card appear to have been removed
'''
LIBGAMMA_STATE_UNKNOWN = -24
'''
-The state of the requested information is unknown.
+The state of the requested information is unknown
'''
LIBGAMMA_CONNECTOR_UNKNOWN = -25
'''
Failed to determine which connector the
-CRTC belongs to.
+CRTC belongs to
'''
LIBGAMMA_CONNECTOR_TYPE_NOT_RECOGNISED = -26
'''
The detected connector type is not listed
-in this library and has to be updated.
+in this library and has to be updated
'''
LIBGAMMA_SUBPIXEL_ORDER_NOT_RECOGNISED = -27
'''
The detected subpixel order is not listed
-in this library and has to be updated.
+in this library and has to be updated
'''
LIBGAMMA_EDID_LENGTH_UNSUPPORTED = -28
'''
The length of the EDID does not match that
-of any supported EDID structure revision.
+of any supported EDID structure revision
'''
LIBGAMMA_EDID_WRONG_MAGIC_NUMBER = -29
'''
The magic number in the EDID does not match
-that of any supported EDID structure revision.
+that of any supported EDID structure revision
'''
LIBGAMMA_EDID_REVISION_UNSUPPORTED = -30
'''
The EDID structure revision used by the
-monitor is not supported.
+monitor is not supported
'''
LIBGAMMA_GAMMA_NOT_SPECIFIED = -31
'''
The gamma characteristics field in the EDID
-is left unspecified.
-(This could be considered a non-error.)
+is left unspecified
+(This could be considered a non-error)
'''
LIBGAMMA_EDID_CHECKSUM_ERROR = -32
'''
The checksum in the EDID is incorrect, all
request information has been provided
-by you cannot count on it.
+by you cannot count on it
'''
LIBGAMMA_GAMMA_NOT_SPECIFIED_AND_EDID_CHECKSUM_ERROR = -33
'''
Both of the errors `LIBGAMMA_GAMMA_NOT_SPECIFIED`
-and `LIBGAMMA_EDID_CHECKSUM_ERROR` have occurred.
+and `LIBGAMMA_EDID_CHECKSUM_ERROR` have occurred
'''
LIBGAMMA_GAMMA_RAMPS_SIZE_QUERY_FAILED = -34
'''
Failed to query the gamma ramps size from the
-adjustment method, reason unknown.
+adjustment method, reason unknown
'''
LIBGAMMA_OPEN_PARTITION_FAILED = -35
'''
The selected partition could not be opened,
-reason unknown.
+reason unknown
'''
LIBGAMMA_OPEN_SITE_FAILED = -36
'''
The selected site could not be opened,
-reason unknown.
+reason unknown
'''
LIBGAMMA_PROTOCOL_VERSION_QUERY_FAILED = -37
'''
Failed to query the adjustment method for
-its protocol version, reason unknown.
+its protocol version, reason unknown
'''
LIBGAMMA_PROTOCOL_VERSION_NOT_SUPPORTED = -38
'''
The adjustment method's version of its
-protocol is not supported.
+protocol is not supported
'''
LIBGAMMA_LIST_PARTITIONS_FAILED = -39
'''
The adjustment method failed to list
-available partitions, reason unknown.
+available partitions, reason unknown
'''
LIBGAMMA_NULL_PARTITION = -40
'''
Partition exists by index, but the partition
-at that index does not exist.
+at that index does not exist
'''
LIBGAMMA_NOT_CONNECTED = -41
'''
There is not monitor connected to the
-connector of the selected CRTC.
+connector of the selected CRTC
'''
LIBGAMMA_REPLY_VALUE_EXTRACTION_FAILED = -42
'''
Data extraction from a reply from the
-adjustment method failed, reason unknown.
+adjustment method failed, reason unknown
'''
LIBGAMMA_EDID_NOT_FOUND = -43
'''
-No EDID property was found on the output.
+No EDID property was found on the output
'''
LIBGAMMA_LIST_PROPERTIES_FAILED = -44
'''
Failed to list properties on the output,
-reason unknown.
+reason unknown
'''
LIBGAMMA_PROPERTY_VALUE_QUERY_FAILED = -45
'''
Failed to query a property's value from
-the output, reason unknown.
+the output, reason unknown
'''
LIBGAMMA_OUTPUT_INFORMATION_QUERY_FAILED = -46
'''
A request for information on an output
-failed, reason unknown.
+failed, reason unknown
'''
@@ -414,50 +395,47 @@ update your program for new errors.
'''
-
class LibgammaError(Exception):
'''
- libgamma error class.
+ libgamma error class
- @variable errno The error code.
- @variable strerror The name of the error.
+ @variable errno The error code
+ @variable strerror The name of the error
'''
-
+
def __init__(self, errno : int, strerror : str):
'''
- Constructor.
+ Constructor
- @param errno The error code.
- @param strerror The name of the error.
+ @param errno The error code
+ @param strerror The name of the error
'''
self.errno = errno
self.strerror = strerror
-
+
def __str__(self) -> str:
'''
- Return the name of the error.
+ Return the name of the error
- @return The name of the error.
+ @return The name of the error
'''
return self.strerror
-
-
+
def __repr__(self) -> str:
'''
- Create a string representation of the error.
+ Create a string representation of the error
- @return A string representation of the error.
+ @return A string representation of the error
'''
return 'LibgammaError(%i, %s)' % (self.errno, repr(self.strerror))
-
def create_error(error_code : int) -> Exception:
'''
- Create an exception from an error code.
+ Create an exception from an error code
- @param error_code The error code.
- @return :OSError|LibgammaError The error as a throwable object.
+ @param error_code The error code
+ @return :OSError|LibgammaError The error as a throwable object
'''
if error_code == LIBGAMMA_ERRNO_SET:
import ctypes
@@ -473,4 +451,3 @@ def create_error(error_code : int) -> Exception:
e = LibgammaError(error_code, strerror)
return e
-
diff --git a/src/libgamma_facade.py b/libgamma_facade.py
index 5920a5b..ac2ec2c 100644
--- a/src/libgamma_facade.py
+++ b/libgamma_facade.py
@@ -1,39 +1,19 @@
-# -*- python -*-
-'''
-pylibgamma — Python 3 wrapper for libgamma
-Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
-
-This library 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 library 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 library. If not, see <http://www.gnu.org/licenses/>.
-'''
-
-
+# See LICENSE file for copyright and license details.
from libgamma_method import MethodCapabilities
-
def list_methods(operation : int) -> list:
'''
- List available adjustment methods by their order of preference based on the environment.
+ List available adjustment methods by their order of preference based on the environment
- @param operation Allowed values:
- 0: Methods that the environment suggests will work, excluding fake.
- 1: Methods that the environment suggests will work, including fake.
- 2: All real non-fake methods.
- 3: All real methods.
- 4: All methods.
- Other values invoke undefined behaviour.
- @return :list<int> A list of available adjustment methods.
+ @param operation Allowed values
+ 0: Methods that the environment suggests will work, excluding fake
+ 1: Methods that the environment suggests will work, including fake
+ 2: All real non-fake methods
+ 3: All real methods
+ 4: All methods
+ Other values invoke undefined behaviour
+ @return :list<int> A list of available adjustment methods
'''
from libgamma_native_facade import libgamma_native_list_methods
return libgamma_native_list_methods(operation)
@@ -42,10 +22,10 @@ def list_methods(operation : int) -> list:
def is_method_available(method : int) -> bool:
'''
Check whether an adjustment method is available, non-existing (invalid) methods will be
- identified as not available under the rationale that the library may be out of date.
+ identified as not available under the rationale that the library may be out of date
- @param method The adjustment method.
- @return Whether the adjustment method is available.
+ @param method The adjustment method
+ @return Whether the adjustment method is available
'''
from libgamma_native_facade import libgamma_native_is_method_available
return not libgamma_native_is_method_available(method) == 0
@@ -53,10 +33,10 @@ def is_method_available(method : int) -> bool:
def method_capabilities(method : int) -> MethodCapabilities:
'''
- Return the capabilities of an adjustment method.
+ Return the capabilities of an adjustment method
@param this The data structure to fill with the method's capabilities
- @param method The adjustment method (display server and protocol).
+ @param method The adjustment method (display server and protocol)
'''
from libgamma_native_facade import libgamma_native_method_capabilities
caps = libgamma_native_method_capabilities(method)
@@ -65,12 +45,12 @@ def method_capabilities(method : int) -> MethodCapabilities:
def method_default_site(method : int) -> str:
'''
- Return the default site for an adjustment method.
+ Return the default site for an adjustment method
- @param method The adjustment method (display server and protocol.)
+ @param method The adjustment method (display server and protocol)
@return The default site, `None` if it cannot be determined or
if multiple sites are not supported by the adjustment
- method.
+ method
'''
from libgamma_native_facade import libgamma_native_method_default_site
return libgamma_native_method_default_site(method)
@@ -79,9 +59,9 @@ def method_default_site(method : int) -> str:
def method_default_site_variable(method : int) -> str:
'''
Return the default variable that determines
- the default site for an adjustment method.
+ the default site for an adjustment method
- @param method The adjustment method (display server and protocol.)
+ @param method The adjustment method (display server and protocol)
@return The environ variables that is used to determine the
default site. `None` if there is none, that is, if
the method does not support multiple sites.
@@ -93,20 +73,20 @@ def method_default_site_variable(method : int) -> str:
def behex_edid(edid : bytes) -> str:
'''
- Convert a raw representation of an EDID to a lowercase hexadecimal representation.
+ Convert a raw representation of an EDID to a lowercase hexadecimal representation
- @param edid The EDID in raw representation.
- @return The EDID in lowercase hexadecimal representation.
+ @param edid The EDID in raw representation
+ @return The EDID in lowercase hexadecimal representation
'''
return behex_edid_lowercase(edid)
def behex_edid_lowercase(edid : bytes) -> str:
'''
- Convert a raw representation of an EDID to a lowercase hexadecimal representation.
+ Convert a raw representation of an EDID to a lowercase hexadecimal representation
- @param edid The EDID in raw representation.
- @return The EDID in lowercase hexadecimal representation.
+ @param edid The EDID in raw representation
+ @return The EDID in lowercase hexadecimal representation
'''
rc = ''
for b in edid:
@@ -117,10 +97,10 @@ def behex_edid_lowercase(edid : bytes) -> str:
def behex_edid_uppercase(edid : bytes) -> str:
'''
- Convert a raw representation of an EDID to an uppercase hexadecimal representation.
+ Convert a raw representation of an EDID to an uppercase hexadecimal representation
- @param edid The EDID in raw representation.
- @return The EDID in uppercase hexadecimal representation.
+ @param edid The EDID in raw representation
+ @return The EDID in uppercase hexadecimal representation
'''
rc = ''
for b in edid:
@@ -131,10 +111,10 @@ def behex_edid_uppercase(edid : bytes) -> str:
def unhex_edid(edid : str) -> bytes:
'''
- Convert an hexadecimal representation of an EDID to a raw representation.
+ Convert an hexadecimal representation of an EDID to a raw representation
- @param edid The EDID in hexadecimal representation.
- @return The EDID in raw representation.
+ @param edid The EDID in hexadecimal representation
+ @return The EDID in raw representation
'''
rc = []
edid = edid.lower()
@@ -144,4 +124,3 @@ def unhex_edid(edid : str) -> bytes:
b = '0123456789abcdef'.find(b) << 0
rc.append(a | b)
return bytes(rc)
-
diff --git a/src/libgamma_method.py b/libgamma_method.py
index dcd4f6a..c606959 100644
--- a/src/libgamma_method.py
+++ b/libgamma_method.py
@@ -1,26 +1,7 @@
-# -*- python -*-
-'''
-pylibgamma — Python 3 wrapper for libgamma
-Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
-
-This library 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 library 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 library. If not, see <http://www.gnu.org/licenses/>.
-'''
-
+# See LICENSE file for copyright and license details.
from libgamma_error import create_error
-
LIBGAMMA_METHOD_DUMMY = 0
'''
The identifier for the dummy adjustment method.
@@ -31,7 +12,7 @@ testing your program's ability to handle errors.
LIBGAMMA_METHOD_X_RANDR = 1
'''
The identifier for the adjustment method with
-uses the RandR protocol under the X display server.
+uses the RandR protocol under the X display server
'''
LIBGAMMA_METHOD_X_VIDMODE = 2
@@ -97,33 +78,33 @@ class MethodCapabilities:
---- Integer variables ----
@variable crtc_information OR of the CRTC information fields in `CRTCInformation`
- that may (but can fail) be read successfully.
+ that may (but can fail) be read successfully
---- Boolean variables ----
@variable default_site_known Whether the default site is known, if true the site is integrated
- to the system or can be determined using environment variables.
+ to the system or can be determined using environment variables
@variable multiple_sites Whether the adjustment method supports multiple sites rather
- than just the default site.
+ than just the default site
@variable multiple_partitions Whether the adjustment method supports multiple partitions
- per site.
+ per site
@variable multiple_crtcs Whether the adjustment method supports multiple CRTC:s
- per partition per site.
- @variable partitions_are_graphics_cards Whether the partition to graphics card is a bijection.
- @variable site_restore Whether the adjustment method supports `site_restore`.
- @variable partition_restore Whether the adjustment method supports `partition_restore`.
- @variable crtc_restore Whether the adjustment method supports `crtc_restore`.
+ per partition per site
+ @variable partitions_are_graphics_cards Whether the partition to graphics card is a bijection
+ @variable site_restore Whether the adjustment method supports `site_restore`
+ @variable partition_restore Whether the adjustment method supports `partition_restore`
+ @variable crtc_restore Whether the adjustment method supports `crtc_restore`
@variable identical_gamma_sizes Whether the `red_gamma_size`, `green_gamma_size` and
`blue_gamma_size` fields in `CRTCInformation` will always
- have the same values as each other for the adjustment method.
+ have the same values as each other for the adjustment method
@variable fixed_gamma_size Whether the `red_gamma_size`, `green_gamma_size` and
`blue_gamma_size` fields in `CRTCInformation` will always be
- filled with the same value for the adjustment method.
+ filled with the same value for the adjustment method
@variable fixed_gamma_depth Whether the `gamma_depth` field in `CRTCInformation` will
- always be filled with the same value for the adjustment method.
- @variable real Whether the adjustment method will actually perform adjustments.
+ always be filled with the same value for the adjustment method
+ @variable real Whether the adjustment method will actually perform adjustments
@variable fake Whether the adjustment method is implement using a translation
- layer.
+ layer
'''
def __init__(self, crtc_information : int = 0, booleans : int = 0):
@@ -131,7 +112,7 @@ class MethodCapabilities:
Constructor
@param crtc_information The value for `CRTCInformation`
- @param booleans The value for each booleanic variable
+ @param booleans The value for each boolean variable
'''
self.crtc_information = crtc_information
self.default_site_known = (booleans & (1 << 0)) != 0
@@ -151,14 +132,14 @@ class MethodCapabilities:
class CRTCInformation:
'''
- Cathode ray tube controller information data structure.
+ Cathode ray tube controller information data structure
@variable edid:bytes The Extended Display Identification Data associated with
the attached monitor. This is raw byte array that is usually
128 bytes long.
@variable edid_error:int Zero on success, positive it holds the value `errno` had
when the reading failed, otherwise (negative) the value
- of an error identifier provided by this library.
+ of an error identifier provided by this library
@variable width_mm:int The phyical width, in millimetres, of the viewport of the
attached monitor, as reported by the adjustment method. This
@@ -169,7 +150,7 @@ class CRTCInformation:
for projectors.
@variable width_mm_error:int Zero on success, positive it holds the value `errno` had
when the reading failed, otherwise (negative) the value
- of an error identifier provided by this library.
+ of an error identifier provided by this library
@variable height_mm:int The phyical height, in millimetres, of the viewport of the
attached monitor, as reported by the adjustment method. This
value may be incorrect, which is a known issue with the X
@@ -179,7 +160,7 @@ class CRTCInformation:
for projectors.
@variable height_mm_error:int Zero on success, positive it holds the value `errno` had
when the reading failed, otherwise (negative) the value
- of an error identifier provided by this library.
+ of an error identifier provided by this library
@variable width_mm_edid:int The phyical width, in millimetres, of the viewport of the
attached monitor, as reported by it the monitor's Extended
@@ -191,7 +172,7 @@ class CRTCInformation:
for projectors.
@variable width_mm_edid_error:int Zero on success, positive it holds the value `errno` had
when the reading failed, otherwise (negative) the value
- of an error identifier provided by this library.
+ of an error identifier provided by this library
@variable height_mm_edid:int The phyical height, in millimetres, of the viewport of the
attached monitor, as reported by it the monitor's Extended
Display Information Data. This value can only contain whole
@@ -202,50 +183,50 @@ class CRTCInformation:
for projectors.
@variable height_mm_edid_error:int Zero on success, positive it holds the value `errno` had
when the reading failed, otherwise (negative) the value
- of an error identifier provided by this library.
+ of an error identifier provided by this library
- @variable red_gamma_size:int The size of the encoding axis of the red gamma ramp.
- @variable green_gamma_size:int The size of the encoding axis of the green gamma ramp.
- @variable blue_gamma_size:int The size of the encoding axis of the blue gamma ramp.
+ @variable red_gamma_size:int The size of the encoding axis of the red gamma ramp
+ @variable green_gamma_size:int The size of the encoding axis of the green gamma ramp
+ @variable blue_gamma_size:int The size of the encoding axis of the blue gamma ramp
@variable gamma_size_error:int Zero on success, positive it holds the value `errno` had
when the reading failed, otherwise (negative) the value
- of an error identifier provided by this library.
+ of an error identifier provided by this library
@variable gamma_depth:int The bit-depth of the value axes of gamma ramps,
-1 for single precision floating point, and -2 for
- double precision floating point.
+ double precision floating point
@variable gamma_depth_error:int Zero on success, positive it holds the value `errno` had
when the reading failed, otherwise (negative) the value
- of an error identifier provided by this library.
+ of an error identifier provided by this library
- @variable gamma_support:int Non-zero gamma ramp adjustments are supported.
+ @variable gamma_support:int Non-zero gamma ramp adjustments are supported
@variable gamma_support_error:int Zero on success, positive it holds the value `errno` had
when the reading failed, otherwise (negative) the value
- of an error identifier provided by this library.
+ of an error identifier provided by this library
@variable subpixel_order:int The layout of the subpixels.
You cannot count on this value — especially for CRT:s —
but it is provided anyway as a means of distinguishing monitors.
@variable subpixel_order_error:int Zero on success, positive it holds the value `errno` had
when the reading failed, otherwise (negative) the value
- of an error identifier provided by this library.
+ of an error identifier provided by this library
- @variable active:bool Whether there is a monitors connected to the CRTC.
+ @variable active:bool Whether there is a monitors connected to the CRTC
@variable active_error:int Zero on success, positive it holds the value `errno` had
when the reading failed, otherwise (negative) the value
- of an error identifier provided by this library.
+ of an error identifier provided by this library
@variable connector_name:str The name of the connector as designated by the display
server or as give by this library in case the display
- server lacks this feature.
+ server lacks this feature
@variable connector_name_error:int Zero on success, positive it holds the value `errno` had
when the reading failed, otherwise (negative) the value
- of an error identifier provided by this library.
+ of an error identifier provided by this library
- @variable connector_type:int The type of the connector that is associated with the CRTC.
+ @variable connector_type:int The type of the connector that is associated with the CRTC
@variable connector_type_error:int Zero on success, positive it holds the value `errno` had
when the reading failed, otherwise (negative) the value
- of an error identifier provided by this library.
+ of an error identifier provided by this library
@variable gamma_red:float The gamma characteristics of the monitor as reported
in its Extended Display Information Data. The value
@@ -270,7 +251,7 @@ class CRTCInformation:
the result for the blue channel in the gamma correction.
@variable gamma_error:int Zero on success, positive it holds the value `errno` had
when the reading failed, otherwise (negative) the value
- of an error identifier provided by this library.
+ of an error identifier provided by this library
'''
def __init__(self, data):
@@ -314,236 +295,236 @@ class CRTCInformation:
LIBGAMMA_CONNECTOR_TYPE_Unknown = 0
'''
The adjustment method does not know the connector's type
-(This could be considered an error).
+(This could be considered an error)
'''
LIBGAMMA_CONNECTOR_TYPE_VGA = 1
'''
-Video Graphics Array (VGA).
+Video Graphics Array (VGA)
'''
LIBGAMMA_CONNECTOR_TYPE_DVI = 2
'''
-Digital Visual Interface, unknown type.
+Digital Visual Interface, unknown type
'''
LIBGAMMA_CONNECTOR_TYPE_DVII = 3
'''
-Digital Visual Interface, integrated (DVI-I).
+Digital Visual Interface, integrated (DVI-I)
'''
LIBGAMMA_CONNECTOR_TYPE_DVID = 4
'''
-Digital Visual Interface, digital only (DVI-D).
+Digital Visual Interface, digital only (DVI-D)
'''
LIBGAMMA_CONNECTOR_TYPE_DVIA = 5
'''
-Digital Visual Interface, analogue only (DVI-A).
+Digital Visual Interface, analogue only (DVI-A)
'''
LIBGAMMA_CONNECTOR_TYPE_Composite = 6
'''
-Composite video.
+Composite video
'''
LIBGAMMA_CONNECTOR_TYPE_SVIDEO = 7
'''
-Separate Video (S-video).
+Separate Video (S-video)
'''
LIBGAMMA_CONNECTOR_TYPE_LVDS = 8
'''
-Low-voltage differential signaling (LVDS).
+Low-voltage differential signaling (LVDS)
'''
LIBGAMMA_CONNECTOR_TYPE_Component = 9
'''
-Component video, usually separate cables for each channel.
+Component video, usually separate cables for each channel
'''
LIBGAMMA_CONNECTOR_TYPE_9PinDIN = 10
'''
-9 pin DIN (Deutsches Institut für Normung) connector.
+9 pin DIN (Deutsches Institut für Normung) connector
'''
LIBGAMMA_CONNECTOR_TYPE_DisplayPort = 11
'''
-DisplayPort.
+DisplayPort
'''
LIBGAMMA_CONNECTOR_TYPE_HDMI = 12
'''
-High-Definition Multimedia Interface (HDMI), unknown type.
+High-Definition Multimedia Interface (HDMI), unknown type
'''
LIBGAMMA_CONNECTOR_TYPE_HDMIA = 13
'''
-High-Definition Multimedia Interface, type A (HDMI-A).
+High-Definition Multimedia Interface, type A (HDMI-A)
'''
LIBGAMMA_CONNECTOR_TYPE_HDMIB = 14
'''
-High-Definition Multimedia Interface, type B (HDMI-B).
+High-Definition Multimedia Interface, type B (HDMI-B)
'''
LIBGAMMA_CONNECTOR_TYPE_TV = 15
'''
-Television, unknown connector.
+Television, unknown connector
'''
LIBGAMMA_CONNECTOR_TYPE_eDP = 16
'''
-Embedded DisplayPort (eDP).
+Embedded DisplayPort (eDP)
'''
LIBGAMMA_CONNECTOR_TYPE_VIRTUAL = 17
'''
-A virtual connector.
+A virtual connector
'''
LIBGAMMA_CONNECTOR_TYPE_DSI = 18
'''
-Display Serial Interface (DSI).
+Display Serial Interface (DSI)
'''
LIBGAMMA_CONNECTOR_TYPE_LFP = 19
'''
-LFP connector.
-(If you know what this is add it to Wikipedia.)
+LFP connector
+(If you know what this is add it to Wikipedia)
'''
LIBGAMMA_CONNECTOR_TYPE_COUNT = 20
'''
-The number of `LIBGAMMA_CONNECTOR_*` values defined.
+The number of `LIBGAMMA_CONNECTOR_*` values defined
'''
LIBGAMMA_SUBPIXEL_ORDER_UNKNOWN = 0
'''
-The adjustment method does not know the order of the subpixels.
-(This could be considered an error.)
+The adjustment method does not know the order of the subpixels
+(This could be considered an error)
'''
LIBGAMMA_SUBPIXEL_ORDER_NONE = 1
'''
-There are no subpixels in the monitor.
+There are no subpixels in the monitor
'''
LIBGAMMA_SUBPIXEL_ORDER_HORIZONTAL_RGB = 2
'''
-The subpixels are ordered red, green and then blue, from left to right.
+The subpixels are ordered red, green and then blue, from left to right
'''
LIBGAMMA_SUBPIXEL_ORDER_HORIZONTAL_BGR = 3
'''
-The subpixels are ordered blue, green and then red, from left to right.
+The subpixels are ordered blue, green and then red, from left to right
'''
LIBGAMMA_SUBPIXEL_ORDER_VERTICAL_RGB = 4
'''
-The subpixels are ordered red, green and then blue, from the top down.
+The subpixels are ordered red, green and then blue, from the top down
'''
LIBGAMMA_SUBPIXEL_ORDER_VERTICAL_BGR = 5
'''
-The subpixels are ordered blue, green and then red, from the top down.
+The subpixels are ordered blue, green and then red, from the top down
'''
LIBGAMMA_SUBPIXEL_ORDER_COUNT = 6
'''
-The number of `LIBGAMMA_SUBPIXEL_ORDER_*` values defined.
+The number of `LIBGAMMA_SUBPIXEL_ORDER_*` values defined
'''
LIBGAMMA_CRTC_INFO_EDID = 1 << 0
'''
-For a `CRTCInformation` fill in the
-values for `edid` and `edid_length` and report errors to `edid_error`.
+For a `CRTCInformation` fill in the values for
+`edid` and `edid_length` and report errors to `edid_error`
'''
LIBGAMMA_CRTC_INFO_WIDTH_MM = 1 << 1
'''
-For a `CRTCInformation` fill in the
-value for `width_mm` and report errors to `width_mm_error`.
+For a `CRTCInformation` fill in the value for
+`width_mm` and report errors to `width_mm_error`
'''
LIBGAMMA_CRTC_INFO_HEIGHT_MM = 1 << 2
'''
-For a `CRTCInformation` fill in the
-value for `height_mm` and report errors to `height_mm_error`.
+For a `CRTCInformation` fill in the value for
+`height_mm` and report errors to `height_mm_error`
'''
LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID = 1 << 3
'''
-For a `CRTCInformation` fill in the
-value for `width_mm_edid` and report errors to `width_mm_edid_error`.
+For a `CRTCInformation` fill in the value for
+`width_mm_edid` and report errors to `width_mm_edid_error`
'''
LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID = 1 << 4
'''
-For a `CRTCInformation` fill in the
-value for `height_mm_edid` and report errors to `height_mm_edid_error`.
+For a `CRTCInformation` fill in the value for
+`height_mm_edid` and report errors to `height_mm_edid_error`
'''
LIBGAMMA_CRTC_INFO_GAMMA_SIZE = 1 << 5
'''
-For a `CRTCInformation` fill in the
-values for `red_gamma_size`, `green_gamma_size` and `blue_gamma_size`.
+For a `CRTCInformation` fill in the values for
+`red_gamma_size`, `green_gamma_size` and `blue_gamma_size`,
and report errors to `gamma_size_error`
'''
LIBGAMMA_CRTC_INFO_GAMMA_DEPTH = 1 << 6
'''
-For a `CRTCInformation` fill in the
-value for `gamma_depth` and report errors to `gamma_depth_error`.
+For a `CRTCInformation` fill in the value for
+`gamma_depth` and report errors to `gamma_depth_error`
'''
LIBGAMMA_CRTC_INFO_GAMMA_SUPPORT = 1 << 7
'''
-For a `CRTCInformation` fill in the
-value for `gamma_support` and report errors to `gamma_support_error`.
+For a `CRTCInformation` fill in the value for
+`gamma_support` and report errors to `gamma_support_error`
'''
LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER = 1 << 8
'''
-For a `CRTCInformation` fill in the
-value for `subpixel_order` and report errors to `subpixel_order_error`.
+For a `CRTCInformation` fill in the value for
+`subpixel_order` and report errors to `subpixel_order_error`
'''
LIBGAMMA_CRTC_INFO_ACTIVE = 1 << 9
'''
-For a `CRTCInformation` fill in the
-value for `active` and report errors to `active_error`.
+For a `CRTCInformation` fill in the value for
+`active` and report errors to `active_error`
'''
LIBGAMMA_CRTC_INFO_CONNECTOR_NAME = 1 << 10
'''
-For a `CRTCInformation` fill in the
-value for `connector_name` and report errors to `connector_name_error`.
+For a `CRTCInformation` fill in the value for
+`connector_name` and report errors to `connector_name_error`
'''
LIBGAMMA_CRTC_INFO_CONNECTOR_TYPE = 1 << 11
'''
-For a `CRTCInformation` fill in the
-value for `connector_type` and report errors to `connector_type_error`.
+For a `CRTCInformation` fill in the value for
+`connector_type` and report errors to `connector_type_error`
'''
LIBGAMMA_CRTC_INFO_GAMMA = 1 << 12
'''
-For a `CRTCInformation` fill in the
-values for `gamma_red`, `gamma_green` and `gamma_blue`
-and report errors to `gamma_error`.
+For a `CRTCInformation` fill in the values for
+`gamma_red`, `gamma_green` and `gamma_blue` and
+report errors to `gamma_error`
'''
LIBGAMMA_CRTC_INFO_COUNT = 13
'''
-The number of `LIBGAMMA_CRTC_INFO_*` values defined.
+The number of `LIBGAMMA_CRTC_INFO_*` values defined
'''
@@ -551,46 +532,42 @@ The number of `LIBGAMMA_CRTC_INFO_*` values defined.
LIBGAMMA_CRTC_INFO_MACRO_EDID_VIEWPORT = LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID | \
LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID
'''
-Macro for both `CRTCInformation` fields
-that can specify the size of the monitor's viewport
-as specified in the monitor's Extended Display
-Information Data.
+Macro for both `CRTCInformation` fields that can
+specify the size of the monitor's viewport as specified
+in the monitor's Extended Display Information Data
'''
LIBGAMMA_CRTC_INFO_MACRO_EDID = LIBGAMMA_CRTC_INFO_EDID | \
LIBGAMMA_CRTC_INFO_MACRO_EDID_VIEWPORT | \
LIBGAMMA_CRTC_INFO_GAMMA
'''
-Macro for all `CRTCInformation` fields
-that can be filled if the adjustment method have
-support for reading the monitors' Extended Display
-Information Data.
+Macro for all `CRTCInformation` fields that can be
+filled if the adjustment method have support for
+reading the monitors' Extended Display Information Data
'''
LIBGAMMA_CRTC_INFO_MACRO_VIEWPORT = LIBGAMMA_CRTC_INFO_WIDTH_MM | \
LIBGAMMA_CRTC_INFO_HEIGHT_MM
'''
-Macro for both `CRTCInformation` fields
-that can specify the size of the monitor's viewport
-as provided by the adjustment method without this
-library having to parse the monitor's Extended Display
-Information Data.
+Macro for both `CRTCInformation` fields that can
+specify the size of the monitor's viewport as provided
+by the adjustment method without this library having to
+parse the monitor's Extended Display Information Data
'''
LIBGAMMA_CRTC_INFO_MACRO_RAMP = LIBGAMMA_CRTC_INFO_GAMMA_SIZE | \
LIBGAMMA_CRTC_INFO_GAMMA_DEPTH
'''
-Macro for the `CRTCInformation` fields
-that specifies the CRTC's gamma ramp sizes and gamma
-ramp depth.
+Macro for the `CRTCInformation` fields that specifies
+the CRTC's gamma ramp sizes and gamma ramp depth
'''
LIBGAMMA_CRTC_INFO_MACRO_CONNECTOR = LIBGAMMA_CRTC_INFO_CONNECTOR_NAME | \
LIBGAMMA_CRTC_INFO_CONNECTOR_TYPE
'''
-Macro for the `CRTCInformation` fields
-that specifies the CRTC's connector type and the
-partition unique name of the connector.
+Macro for the `CRTCInformation` fields that specifies
+the CRTC's connector type and the partition unique
+name of the connector
'''
LIBGAMMA_CRTC_INFO_MACRO_ACTIVE = LIBGAMMA_CRTC_INFO_MACRO_EDID | \
@@ -598,30 +575,30 @@ LIBGAMMA_CRTC_INFO_MACRO_ACTIVE = LIBGAMMA_CRTC_INFO_MACRO_EDID | \
LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER | \
LIBGAMMA_CRTC_INFO_ACTIVE
'''
-Macro for the `CRTCInformation` fields
-that required there is a monitor attached to the connector,
-and that status itself.
+Macro for the `CRTCInformation` fields that required
+there is a monitor attached to the connector, and
+that status itself
'''
class GammaRamps:
'''
- Gamma ramp structure.
+ Gamma ramp structure
'''
-
+
class Ramp:
'''
- A gamma ramp for one single channel.
+ A gamma ramp for one single channel
'''
-
+
def __init__(self, ramp, size : int, depth : int):
'''
- Constructor.
+ Constructor
- @param ramp The gamma ramp.
- @param size The number of stops in the gamma ramp.
- @param depth The depth of the gamma ramp.
+ @param ramp The gamma ramp
+ @param size The number of stops in the gamma ramp
+ @param depth The depth of the gamma ramp
'''
from libgamma_native_method import libgamma_native_gamma_ramps8_get
from libgamma_native_method import libgamma_native_gamma_ramps16_get
@@ -644,44 +621,44 @@ class GammaRamps:
elif depth == -1: fs = (libgamma_native_gamma_rampsf_get, libgamma_native_gamma_rampsf_set)
elif depth == -2: fs = (libgamma_native_gamma_rampsd_get, libgamma_native_gamma_rampsd_set)
(self._get, self._set) = fs
-
-
+
+
@property
def size(self) -> int:
'''
- Get the number of stops in the gamma ramp.
+ Get the number of stops in the gamma ramp
- @return The number of stops in the gamma ramp.
+ @return The number of stops in the gamma ramp
'''
return self._size
-
+
@size.setter
def size(self, value : int):
'''
- It is not possible to change this attribute, but a setter is
- required for the getter to function.
+ It is not possible to change this attribute, but
+ a setter is required for the getter to function
'''
raise AttributeError('cannot resize ramp')
-
+
def __len__(self) -> int:
'''
- Get the number of stops in the gamma ramp.
+ Get the number of stops in the gamma ramp
- @return The number of stops in the gamma ramp.
+ @return The number of stops in the gamma ramp
'''
return self._size
-
+
def __getitem__(self, indices):
'''
- Read the gamma ramp.
+ Read the gamma ramp
- @param indices:slice The stops to read.
- @return :list<int|float> The values of the read stops.
+ @param indices:slice The stops to read
+ @return :list<int|float> The values of the read stops
-- OR --
- @param indices:int The index of the stop to read.
- @return :int|float The value of the read stop.
+ @param indices:int The index of the stop to read
+ @return :int|float The value of the read stop
'''
if isinstance(indices, slice):
start = indices.start
@@ -697,18 +674,18 @@ class GammaRamps:
if indices < 0:
indices += self._size
return self._get(self._ramp, indices)
-
+
def __setitem__(self, indices, values):
'''
- Modify the gamma ramp.
+ Modify the gamma ramp
- @param indices:slice The stops to modify.
- @param values:itr<int|float> The values for the selected stops.
+ @param indices:slice The stops to modify
+ @param values:itr<int|float> The values for the selected stops
-- OR --
- @param indices:int The index of the stop to modify.
- @param values:int|float The new value for the stop.
+ @param indices:int The index of the stop to modify
+ @param values:int|float The new value for the stop
'''
if isinstance(indices, slice):
start = indices.start
@@ -728,37 +705,38 @@ class GammaRamps:
if indices < 0:
indices += self._size
self._set(self._ramp, indices, values)
-
+
def __iter__(self) -> iter:
'''
- Read the gamma ramp.
+ Read the gamma ramp
- @return :itr<int|float> The values of each stop.
+ @return :itr<int|float> The values of each stop
'''
for value in self[:]:
yield value
-
+
def map(self, function):
'''
Modify the entire ramp using a function that
- maps encoding value to output value.
+ maps encoding value to output value
@param function:(float)→int|float Function that takes the encoding value as a
- [0, 1] floating point and returns its output
- value as the format using in the gamma ramp.
+ [0, 1] floating point and returns its output
+ value as the format using in the gamma ramp
'''
max_i = self._size - 1
for i in range(self._size):
self._set(self._ramp, i, function(i / max_i))
-
+
+
def __init__(self, red_size : int, green_size : int = ..., blue_size : int = ..., *, depth : int = 16):
'''
- Constructor.
+ Constructor
- @param red_size The number of stops in the gamma ramp for the red channel.
- @param green_size The number of stops in the gamma ramp for the green channel, `...` for `red_size`.
- @param blue_size The number of stops in the gamma ramp for the blue channel, `...` for `green_size`.
- @param depth The depth of the gamma ramps.
+ @param red_size The number of stops in the gamma ramp for the red channel
+ @param green_size The number of stops in the gamma ramp for the green channel, `...` for `red_size`
+ @param blue_size The number of stops in the gamma ramp for the blue channel, `...` for `green_size`
+ @param depth The depth of the gamma ramps
'''
if green_size is ...: green_size = red_size
if blue_size is ...: blue_size = green_size
@@ -790,11 +768,11 @@ class GammaRamps:
self._red = GammaRamps.Ramp(red, red_size, depth)
self._green = GammaRamps.Ramp(green, green_size, depth)
self._blue = GammaRamps.Ramp(blue, blue_size, depth)
-
-
+
+
def __del__(self):
'''
- This function is called when the object is not longer in use.
+ This function is called when the object is not longer in use
'''
from libgamma_native_method import libgamma_native_gamma_ramps8_free
from libgamma_native_method import libgamma_native_gamma_ramps16_free
@@ -810,108 +788,107 @@ class GammaRamps:
elif self._depth == 64: libgamma_native_gamma_ramps64_free(self._ramps)
elif self._depth == -1: libgamma_native_gamma_rampsf_free(self._ramps)
elif self._depth == -2: libgamma_native_gamma_rampsd_free(self._ramps)
-
-
+
+
@property
def red(self) -> Ramp:
'''
- Get the gamma ramp for the red channel.
+ Get the gamma ramp for the red channel
- @return The gamma ramp for the red channel.
+ @return The gamma ramp for the red channel
'''
return self._red
-
-
+
+
@red.setter
def red(self, value):
'''
It is not possible to change this attribute, but a setter is
- required for the getter to function.
+ required for the getter to function
'''
raise AttributeError('cannot change ramps')
-
-
+
+
@property
def green(self) -> Ramp:
'''
- Get the gamma ramp for the green channel.
+ Get the gamma ramp for the green channel
- @return The gamma ramp for the green channel.
+ @return The gamma ramp for the green channel
'''
return self._green
-
-
+
+
@green.setter
def green(self, value) -> Ramp:
'''
It is not possible to change this attribute, but a setter is
- required for the getter to function.
+ required for the getter to function
'''
raise AttributeError('cannot change ramps')
-
-
+
+
@property
def blue(self):
'''
- Get the gamma ramp for the blue channel.
+ Get the gamma ramp for the blue channel
- @return The gamma ramp for the blue channel.
+ @return The gamma ramp for the blue channel
'''
return self._blue
-
-
+
+
@blue.setter
def blue(self, value):
'''
It is not possible to change this attribute, but a setter is
- required for the getter to function.
+ required for the getter to function
'''
raise AttributeError('cannot change ramps')
-
-
+
+
@property
def size(self) -> tuple:
'''
- Get the ramps' sizes.
+ Get the ramps' sizes
- @return :(red:int, green:int, blue:int) The size of each individual ramp.
+ @return :(red:int, green:int, blue:int) The size of each individual ramp
'''
return (self._red.size, self._green.size, self._blue.size)
-
-
+
+
@size.setter
def size(self, value):
'''
It is not possible to change this attribute, but a setter is
- required for the getter to function.
+ required for the getter to function
'''
raise AttributeError('cannot resize ramps')
-
-
+
+
@property
def depth(self) -> int:
'''
- Get the depth of ramps.
+ Get the depth of ramps
@return :int The ramps' depth in bits and -1 for single precision floating
- point and -2 for doublesingle precision floating point.
+ point and -2 for doublesingle precision floating point
'''
return self._depth
-
-
+
+
@depth.setter
def depth(self, value):
'''
It is not possible to change this attribute, but a setter is
- required for the getter to function.
+ required for the getter to function
'''
raise AttributeError('cannot change depth')
-
class Site:
'''
- Site state.
+ Site state
On operating systems that integrate a graphical environment
there is usually just one site. However, one systems with
@@ -919,17 +896,17 @@ class Site:
and the BSD:s, there can usually be any (feasible) number of
sites. In X.org parlance they are called displays.
- @variable method:int The adjustment method of the site.
- @variable site:str? The site identifier.
- @variable partitions_available:int The number of paritions available in the site.
+ @variable method:int The adjustment method of the site
+ @variable site:str? The site identifier
+ @variable partitions_available:int The number of paritions available in the site
'''
-
+
def __init__(self, method : int, site : str = None):
'''
- Constructor.
+ Constructor
- @param method:int The adjustment method of the site.
- @param site:str? The site identifier.
+ @param method:int The adjustment method of the site
+ @param site:str? The site identifier
'''
from libgamma_native_facade import libgamma_native_site_create
(self._state, n) = libgamma_native_site_create(method, site)
@@ -938,20 +915,20 @@ class Site:
self.partitions_available = n
self.method = method
self.site = site
-
-
+
+
def __del__(self):
'''
- This function is called when the object is not longer in use.
+ This function is called when the object is not longer in use
'''
from libgamma_native_facade import libgamma_native_site_free
if not self._state == 0:
libgamma_native_site_free(self._state)
-
-
+
+
def restore(self):
'''
- Restore the gamma ramps all CRTC:s with the site to the system settings.
+ Restore the gamma ramps all CRTC:s with the site to the system settings
'''
from libgamma_native_facade import libgamma_native_site_restore
r = libgamma_native_site_restore(self._state)
@@ -961,7 +938,7 @@ class Site:
class Partition:
'''
- Partition state.
+ Partition state
Probably the majority of display server only one partition
per site. However, X.org can, and traditional used to have
@@ -972,17 +949,17 @@ class Partition:
On hardware-level adjustment methods, such as Direct
Rendering Manager, a partition is a graphics card
- @variable site:Site The site of the partition.
- @variable partition:int The index of the partition.
- @variable crtcs_available:int The number of CRTC:s available in the parition.
+ @variable site:Site The site of the partition
+ @variable partition:int The index of the partition
+ @variable crtcs_available:int The number of CRTC:s available in the parition
'''
-
+
def __init__(self, site : Site, partition : int):
'''
Constructor.
- @param site The site of the partition.
- @param partition The index of the partition.
+ @param site The site of the partition
+ @param partition The index of the partition
'''
from libgamma_native_facade import libgamma_native_partition_create
(self._state, n) = libgamma_native_partition_create(site._state, partition)
@@ -991,20 +968,20 @@ class Partition:
self.crtcs_available = n
self.site = site
self.partition = partition
-
-
+
+
def __del__(self):
'''
- This function is called when the object is not longer in use.
+ This function is called when the object is not longer in use
'''
from libgamma_native_facade import libgamma_native_partition_free
if not self._state == 0:
libgamma_native_partition_free(self._state)
-
-
+
+
def restore(self):
'''
- Restore the gamma ramps all CRTC:s with the partition to the system settings.
+ Restore the gamma ramps all CRTC:s with the partition to the system settings
'''
from libgamma_native_facade import libgamma_native_partition_restore
r = libgamma_native_partition_restore(self._state)
@@ -1014,22 +991,22 @@ class Partition:
class CRTC:
'''
- Cathode ray tube controller state.
+ Cathode ray tube controller state
The CRTC controls the gamma ramps for the
monitor that is plugged in to the connector
- that the CRTC belongs to.
+ that the CRTC belongs to
- @variable partition:Partition The partition of the CRTC.
- @variable crtc:int The index of the CRTC.
+ @variable partition:Partition The partition of the CRTC
+ @variable crtc:int The index of the CRTC
'''
-
+
def __init__(self, partition : Partition, crtc : int):
'''
- Constructor.
+ Constructor
- @param partition The partition the of the CRTC.
- @param crtc The index of the CRTC.
+ @param partition The partition the of the CRTC
+ @param crtc The index of the CRTC
'''
from libgamma_native_facade import libgamma_native_crtc_create
(self._state, n) = libgamma_native_crtc_create(partition._state, crtc)
@@ -1037,46 +1014,46 @@ class CRTC:
raise create_error(n)
self.partition = partition
self.crtc = crtc
-
-
+
+
def __del__(self):
'''
- This function is called when the object is not longer in use.
+ This function is called when the object is not longer in use
'''
from libgamma_native_facade import libgamma_native_crtc_free
if not self._state == 0:
libgamma_native_crtc_free(self._state)
-
-
+
+
def restore(self):
'''
- Restore the gamma ramps for a CRTC to the system settings for that CRTC.
+ Restore the gamma ramps for a CRTC to the system settings for that CRTC
'''
from libgamma_native_facade import libgamma_native_crtc_restore
r = libgamma_native_crtc_restore(self._state)
if not r == 0:
raise create_error(r)
-
-
+
+
def information(self, fields : int) -> tuple:
'''
- Read information about a CRTC.
+ Read information about a CRTC
@param field OR:ed identifiers for the information
- about the CRTC that should be read.
+ about the CRTC that should be read
@return :(:CRTCInformation, :bool) The information about the CRTC and
- whether no errors occurred.
+ whether no errors occurred
'''
from libgamma_native_facade import libgamma_native_get_crtc_information
(data, e) = libgamma_native_get_crtc_information(self._state, fields)
return (CRTCInformation(data), e == 0)
-
-
+
+
def get_gamma(self, ramps : GammaRamps):
'''
- Get the current gamma ramps for the CRTC.
+ Get the current gamma ramps for the CRTC
- @param ramps The gamma ramps to fill with the current values.
+ @param ramps The gamma ramps to fill with the current values
'''
from libgamma_native_facade import libgamma_native_crtc_get_gamma_ramps8
from libgamma_native_facade import libgamma_native_crtc_get_gamma_ramps16
@@ -1092,13 +1069,13 @@ class CRTC:
elif ramps.depth == -2: r = libgamma_native_crtc_get_gamma_rampsd(self._state, ramps._ramps)
if not r == 0:
raise create_error(r)
-
-
+
+
def set_gamma(self, ramps : GammaRamps):
'''
- Set gamma ramps for the CRTC.
+ Set gamma ramps for the CRTC
- @param ramps The gamma ramps to apply.
+ @param ramps The gamma ramps to apply
'''
from libgamma_native_facade import libgamma_native_crtc_set_gamma_ramps8
from libgamma_native_facade import libgamma_native_crtc_set_gamma_ramps16
@@ -1114,4 +1091,3 @@ class CRTC:
elif ramps.depth == -2: r = libgamma_native_crtc_set_gamma_rampsd(self._state, ramps._ramps)
if not r == 0:
raise create_error(r)
-
diff --git a/src/libgamma_native_error.pyx b/libgamma_native_error.posix.pyx
index 6963a44..0370eb4 100644
--- a/src/libgamma_native_error.pyx
+++ b/libgamma_native_error.posix.pyx
@@ -1,22 +1,5 @@
# -*- python -*-
-'''
-pylibgamma — Python 3 wrapper for libgamma
-Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
-
-This library 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 library 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 library. If not, see <http://www.gnu.org/licenses/>.
-'''
-
+# See LICENSE file for copyright and license details.
cimport cython
from posix.unistd cimport gid_t
@@ -27,20 +10,20 @@ cdef extern gid_t libgamma_group_gid_get() nogil
cdef extern void libgamma_group_gid_set(gid_t) nogil
'''
Group that the user needs to be a member of if
-`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned.
+`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned
'''
-cdef extern const char* libgamma_group_name_get() nogil
-cdef extern void libgamma_group_name_set(const char*) nogil
+cdef extern const char *libgamma_group_name_get() nogil
+cdef extern void libgamma_group_name_set(const char *) nogil
'''
Group that the user needs to be a member of if
`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned,
`NULL` if the name of the group `libgamma_group_gid`
-cannot be determined.
+cannot be determined
'''
-cdef extern void libgamma_perror(const char* name, int error_code) nogil
+cdef extern void libgamma_perror(const char *name, int error_code) nogil
'''
Prints an error to stderr in a `perror` fashion,
however this function will not translate the `libgamma`
@@ -55,60 +38,60 @@ the value of `LIBGAMMA_DEVICE_REQUIRE_GROUP` the
required group will be printed with its numerical value
and, if known, its name.
-@param name The text to add at the beginning.
-@param value The error code, may be an `errno` value.
+@param name The text to add at the beginning
+@param value The error code, may be an `errno` value
'''
-cdef extern const char* libgamma_name_of_error(int value) nogil
+cdef extern const char *libgamma_name_of_error(int value) nogil
'''
-Returns the name of the definition associated with a `libgamma` error code.
+Returns the name of the definition associated with a `libgamma` error code
-@param value The error code.
+@param value The error code
@return The name of the definition associated with the error code,
`NULL` if the error code does not exist. The return string
should not be `free`:d.
'''
-cdef extern int libgamma_value_of_error(const char* name) nogil
+cdef extern int libgamma_value_of_error(const char *name) nogil
'''
-Return the value of a `libgamma` error definition refered to by name.
+Return the value of a `libgamma` error definition refered to by name
-@param name The name of the definition associated with the error code.
+@param name The name of the definition associated with the error code
@return The error code, zero if the name does is `NULL`
- or does not refer to a `libgamma` error.
+ or does not refer to a `libgamma` error
'''
-
def libgamma_native_get_group_gid() -> int:
'''
- Getter.
+ Getter
Group that the user needs to be a member of if
- `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned.
+ `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned
'''
return int(libgamma_group_gid_get())
+
def libgamma_native_set_group_gid(gid : int):
'''
- Setter.
+ Setter
Group that the user needs to be a member of if
- `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned.
+ `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned
'''
libgamma_group_gid_set(<int>gid)
def libgamma_native_get_group_name() -> str:
'''
- Getter.
+ Getter
Group that the user needs to be a member of if
`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned,
`None` if the name of the group `libgamma_group_gid`
- cannot be determined.
+ cannot be determined
'''
- cdef const char* group_name
+ cdef const char *group_name
cdef bytes bs
group_name = libgamma_group_name_get()
if group_name is NULL:
@@ -116,19 +99,20 @@ def libgamma_native_get_group_name() -> str:
bs = group_name
return bs.decode('utf-8', 'strict')
+
def libgamma_native_set_group_name(name : str):
'''
- Setter.
+ Setter
Group that the user needs to be a member of if
`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned,
`None` if the name of the group `libgamma_group_gid`
- cannot be determined.
+ cannot be determined
'''
- cdef const char* group_name
+ cdef const char *group_name
cdef bytes bs
if name is None:
- libgamma_group_name_set(<char*>NULL)
+ libgamma_group_name_set(<char *>NULL)
return
bs = name.encode('utf-8') + bytes([0])
group_name = bs
@@ -150,8 +134,8 @@ def libgamma_native_perror(name : str, error_code : int):
required group will be printed with its numerical value
and, if known, its name.
- @param name The text to add at the beginning.
- @param value The error code, may be an `errno` value.
+ @param name The text to add at the beginning
+ @param value The error code, may be an `errno` value
'''
cdef bytes bs
bs = name.encode('utf-8') + bytes([0])
@@ -160,13 +144,13 @@ def libgamma_native_perror(name : str, error_code : int):
def libgamma_native_name_of_error(value : int) -> str:
'''
- Returns the name of the definition associated with a `libgamma` error code.
+ Returns the name of the definition associated with a `libgamma` error code
- @param value The error code.
+ @param value The error code
@return The name of the definition associated with the error code,
- `None` if the error code does not exist.
+ `None` if the error code does not exist
'''
- cdef const char* name
+ cdef const char *name
cdef bytes bs
name = libgamma_name_of_error(<int>value)
if name is NULL:
@@ -177,29 +161,28 @@ def libgamma_native_name_of_error(value : int) -> str:
def libgamma_native_value_of_error(name : str) -> int:
'''
- Return the value of a `libgamma` error definition refered to by name.
+ Return the value of a `libgamma` error definition refered to by name
- @param name The name of the definition associated with the error code.
+ @param name The name of the definition associated with the error code
@return The error code, zero if the name is `None`,
- or does not refer to a `libgamma` error.
+ or does not refer to a `libgamma` error
'''
cdef bytes bs
if name is None:
return 0
bs = name.encode('utf-8') + bytes([0])
return int(libgamma_value_of_error(bs))
-
+
def strerror(error : int) -> str:
'''
- Get a textual description of an error.
+ Get a textual description of an error
- @param error The number of the error.
- @return The description of the error.
+ @param error The number of the error
+ @return The description of the error
'''
- cdef const char* text
+ cdef const char *text
cdef bytes bs
text = c_strerror(<int>error)
bs = text
return bs.decode('utf-8', 'strict')
-
diff --git a/src/libgamma_native_error.w32.pyx b/libgamma_native_error.w32.pyx
index abef314..21548f0 100644
--- a/src/libgamma_native_error.w32.pyx
+++ b/libgamma_native_error.w32.pyx
@@ -1,29 +1,12 @@
# -*- python -*-
-'''
-pylibgamma — Python 3 wrapper for libgamma
-Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
-
-This library 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 library 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 library. If not, see <http://www.gnu.org/licenses/>.
-'''
-
+# See LICENSE file for copyright and license details.
cimport cython
cdef extern short libgamma_group_gid
'''
Group that the user needs to be a member of if
-`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned.
+`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned
'''
cdef extern const char* libgamma_group_name
@@ -31,11 +14,11 @@ cdef extern const char* libgamma_group_name
Group that the user needs to be a member of if
`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned,
`NULL` if the name of the group `libgamma_group_gid`
-cannot be determined.
+cannot be determined
'''
-cdef extern void libgamma_perror(const char* name, int error_code) nogil
+cdef extern void libgamma_perror(const char *name, int error_code) nogil
'''
Prints an error to stderr in a `perror` fashion,
however this function will not translate the `libgamma`
@@ -50,58 +33,58 @@ the value of `LIBGAMMA_DEVICE_REQUIRE_GROUP` the
required group will be printed with its numerical value
and, if known, its name.
-@param name The text to add at the beginning.
-@param value The error code, may be an `errno` value.
+@param name The text to add at the beginning
+@param value The error code, may be an `errno` value
'''
-cdef extern const char* libgamma_name_of_error(int value) nogil
+cdef extern const char *libgamma_name_of_error(int value) nogil
'''
-Returns the name of the definition associated with a `libgamma` error code.
+Returns the name of the definition associated with a `libgamma` error code
-@param value The error code.
+@param value The error code
@return The name of the definition associated with the error code,
`NULL` if the error code does not exist. The return string
- should not be `free`:d.
+ should not be `free`:d
'''
-cdef extern int libgamma_value_of_error(const char* name) nogil
+cdef extern int libgamma_value_of_error(const char *name) nogil
'''
-Return the value of a `libgamma` error definition refered to by name.
+Return the value of a `libgamma` error definition refered to by name
-@param name The name of the definition associated with the error code.
+@param name The name of the definition associated with the error code
@return The error code, zero if the name does is `NULL`
- or does not refer to a `libgamma` error.
+ or does not refer to a `libgamma` error
'''
-
def libgamma_native_get_group_gid() -> int:
'''
- Getter.
+ Getter
Group that the user needs to be a member of if
- `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned.
+ `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned
'''
return int(libgamma_group_gid)
+
def libgamma_native_set_group_gid(gid : int):
'''
- Setter.
+ Setter
Group that the user needs to be a member of if
- `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned.
+ `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned
'''
libgamma_group_gid = <int>gid
def libgamma_native_get_group_name() -> str:
'''
- Getter.
+ Getter
Group that the user needs to be a member of if
`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned,
`None` if the name of the group `libgamma_group_gid`
- cannot be determined.
+ cannot be determined
'''
cdef bytes bs
if libgamma_group_name is NULL:
@@ -109,18 +92,19 @@ def libgamma_native_get_group_name() -> str:
bs = libgamma_group_name
return bs.decode('utf-8', 'strict')
+
def libgamma_native_set_group_name(name : str):
'''
- Setter.
+ Setter
Group that the user needs to be a member of if
`LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned,
`None` if the name of the group `libgamma_group_gid`
- cannot be determined.
+ cannot be determined
'''
cdef bytes bs
if name is None:
- libgamma_group_name = <char*>NULL
+ libgamma_group_name = <char *>NULL
return
bs = name.encode('utf-8') + bytes([0])
libgamma_group_name = bs
@@ -141,8 +125,8 @@ def libgamma_native_perror(name : str, error_code : int):
required group will be printed with its numerical value
and, if known, its name.
- @param name The text to add at the beginning.
- @param value The error code, may be an `errno` value.
+ @param name The text to add at the beginning
+ @param value The error code, may be an `errno` value
'''
cdef bytes bs
bs = name.encode('utf-8') + bytes([0])
@@ -151,12 +135,12 @@ def libgamma_native_perror(name : str, error_code : int):
def libgamma_native_name_of_error(value : int) -> str:
'''
- Returns the name of the definition associated with a `libgamma` error code.
+ Returns the name of the definition associated with a `libgamma` error code
- @param value The error code.
+ @param value The error code
@return The name of the definition associated with the error code,
`None` if the error code does not exist. The return string
- should not be `free`:d.
+ should not be `free`:d
'''
cdef const char* name
cdef bytes bs
@@ -169,15 +153,15 @@ def libgamma_native_name_of_error(value : int) -> str:
def libgamma_native_value_of_error(name : str) -> int:
'''
- Return the value of a `libgamma` error definition refered to by name.
+ Return the value of a `libgamma` error definition refered to by name
- @param name The name of the definition associated with the error code.
+ @param name The name of the definition associated with the error code
@return The error code, zero if the name is `None`,
- or does not refer to a `libgamma` error.
+ or does not refer to a `libgamma` error
'''
cdef bytes bs
if name is None:
return 0
bs = name.encode('utf-8') + bytes([0])
return int(libgamma_value_of_error(bs))
-
+
diff --git a/src/libgamma_native_facade.pyx b/libgamma_native_facade.pyx
index 32846e2..19da8b1 100644
--- a/src/libgamma_native_facade.pyx
+++ b/libgamma_native_facade.pyx
@@ -1,22 +1,5 @@
# -*- python -*-
-'''
-pylibgamma — Python 3 wrapper for libgamma
-Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
-
-This library 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 library 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 library. If not, see <http://www.gnu.org/licenses/>.
-'''
-
+# See LICENSE file for copyright and license details.
cimport cython
from libc.stddef cimport size_t
@@ -28,90 +11,88 @@ from libc.errno cimport errno
ctypedef int libgamma_subpixel_order_t
ctypedef int libgamma_connector_type_t
-
cdef extern from "include-libgamma.h":
-
+
ctypedef struct libgamma_method_capabilities_t:
- # Capabilities of adjustment methods.
-
+ # Capabilities of adjustment methods
+
int32_t crtc_information
# OR of the CRTC information fields in `libgamma_crtc_information_t`
- # that may (but can fail) be read successfully.
-
+ # that may (but can fail) be read successfully
+
unsigned default_site_known # : 1
# Whether the default site is known, if true the site is integrated
- # to the system or can be determined using environment variables.
-
+ # to the system or can be determined using environment variables
+
unsigned multiple_sites # : 1
# Whether the adjustment method supports multiple sites rather
- # than just the default site.
-
+ # than just the default site
+
unsigned multiple_partitions # : 1
# Whether the adjustment method supports multiple partitions
- # per site.
-
+ # per site
+
unsigned multiple_crtcs # : 1
# Whether the adjustment method supports multiple CRTC:s
- # per partition per site.
-
+ # per partition per site
+
unsigned partitions_are_graphics_cards # : 1
- # Whether the partition to graphics card is a bijection.
-
+ # Whether the partition to graphics card is a bijection
+
unsigned site_restore # : 1
- # Whether the adjustment method supports `libgamma_site_restore`.
-
+ # Whether the adjustment method supports `libgamma_site_restore`
+
unsigned partition_restore # : 1
- # Whether the adjustment method supports `libgamma_partition_restore`.
-
+ # Whether the adjustment method supports `libgamma_partition_restore`
+
unsigned crtc_restore # : 1
- # Whether the adjustment method supports `libgamma_crtc_restore`.
-
+ # Whether the adjustment method supports `libgamma_crtc_restore`
+
unsigned identical_gamma_sizes # : 1
# Whether the `red_gamma_size`, `green_gamma_size` and `blue_gamma_size`
# fields in `libgamma_crtc_information_t` will always have the same
- # values as each other for the adjustment method.
-
+ # values as each other for the adjustment method
+
unsigned fixed_gamma_size # : 1
# Whether the `red_gamma_size`, `green_gamma_size` and `blue_gamma_size`
# fields in `libgamma_crtc_information_t` will always be filled with the
- # same value for the adjustment method.
-
+ # same value for the adjustment method
+
unsigned fixed_gamma_depth # : 1
# Whether the `gamma_depth` field in `libgamma_crtc_information_t`
- # will always be filled with the same value for the adjustment method.
-
+ # will always be filled with the same value for the adjustment method
+
unsigned real # : 1
- # Whether the adjustment method will actually perform adjustments.
-
+ # Whether the adjustment method will actually perform adjustments
+
unsigned fake # : 1
- # Whether the adjustment method is implement using a translation layer.
-
-
+ # Whether the adjustment method is implement using a translation layer
+
ctypedef struct libgamma_site_state_t:
- # Site state.
+ # Site state
#
# On operating systems that integrate a graphical environment
# there is usually just one site. However, one systems with
# pluggable graphics, like Unix-like systems such as GNU/Linux
# and the BSD:s, there can usually be any (feasible) number of
# sites. In X.org parlance they are called displays.
-
- void* data
+
+ void *data
# Adjustment method implementation specific data.
# You as a user of this library should not touch this.
-
+
int method
# This field specifies, for the methods if this library,
# which adjustment method (display server and protocol)
- # is used to adjust the gamma ramps.
-
- char* site
+ # is used to adjust the gamma ramps
+
+ char *site
# The site identifier. It can either be `NULL` or a string.
# `NULL` indicates the default site. On systems like the
# Unix-like systems, where the graphics are pluggable, this
# is usually resolved by an environment variable, such as
# "DISPLAY" for X.org.
-
+
size_t partitions_available
# The number of partitions that is available on this site.
# Probably the majority of display server only one partition
@@ -122,10 +103,9 @@ cdef extern from "include-libgamma.h":
# and the mapping from monitors to screens is a surjection.
# On hardware-level adjustment methods, such as Direct
# Rendering Manager, a partition is a graphics card.
-
-
+
ctypedef struct libgamma_partition_state_t:
- # Partition state.
+ # Partition state
#
# Probably the majority of display server only one partition
# per site. However, X.org can, and traditional used to have
@@ -135,59 +115,56 @@ cdef extern from "include-libgamma.h":
# and the mapping from monitors to screens is a surjection.
# On hardware-level adjustment methods, such as Direct
# Rendering Manager, a partition is a graphics card.
-
- void* data
+
+ void *data
# Adjustment method implementation specific data.
# You as a user of this library should not touch this.
-
+
libgamma_site_state_t* site
- # The site this partition belongs to.
-
+ # The site this partition belongs to
+
size_t partition
- # The index of the partition.
-
+ # The index of the partition
+
size_t crtcs_available
# The number of CRTC:s that are available under this
# partition. Note that the CRTC:s are not necessarily
# online.
-
-
+
ctypedef struct libgamma_crtc_state_t:
- # Cathode ray tube controller state.
+ # Cathode ray tube controller state
#
# The CRTC controls the gamma ramps for the
# monitor that is plugged in to the connector
- # that the CRTC belongs to.
-
+ # that the CRTC belongs to
+
void* data
# Adjustment method implementation specific data.
# You as a user of this library should not touch this.
-
+
libgamma_partition_state_t* partition
- # The partition this CRTC belongs to.
-
+ # The partition this CRTC belongs to
+
size_t crtc
- # The index of the CRTC within its partition.
-
-
+ # The index of the CRTC within its partition
+
ctypedef struct libgamma_crtc_information_t:
- # Cathode ray tube controller information data structure.
-
- unsigned char* edid
+ # Cathode ray tube controller information data structure
+
+ unsigned char *edid
# The Extended Display Identification Data associated with
# the attached monitor. This is raw byte array that is usually
# 128 bytes long. It is not NUL-terminate, rather its length
# is stored in `edid_length`.
-
+
size_t edid_length
- # The length of `edid`.
-
+ # The length of `edid`
+
int edid_error
# Zero on success, positive it holds the value `errno` had
# when the reading failed, otherwise (negative) the value
# of an error identifier provided by this library.
-
-
+
size_t width_mm
# The phyical width, in millimetres, of the viewport of the
# attached monitor, as reported by the adjustment method. This
@@ -196,13 +173,12 @@ cdef extern from "include-libgamma.h":
# the estimate the size on its own.
# Zero means that its is not applicable, which is the case
# for projectors.
-
+
int width_mm_error
# Zero on success, positive it holds the value `errno` had
# when the reading failed, otherwise (negative) the value
- # of an error identifier provided by this library.
-
-
+ # of an error identifier provided by this library
+
size_t height_mm
# The phyical height, in millimetres, of the viewport of the
# attached monitor, as reported by the adjustment method. This
@@ -211,13 +187,12 @@ cdef extern from "include-libgamma.h":
# the estimate the size on its own.
# Zero means that its is not applicable, which is the case
# for projectors.
-
+
int height_mm_error
# Zero on success, positive it holds the value `errno` had
# when the reading failed, otherwise (negative) the value
- # of an error identifier provided by this library.
-
-
+ # of an error identifier provided by this library
+
size_t width_mm_edid
# The phyical width, in millimetres, of the viewport of the
# attached monitor, as reported by it the monitor's Extended
@@ -227,13 +202,12 @@ cdef extern from "include-libgamma.h":
# the EDID structure.
# Zero means that its is not applicable, which is the case
# for projectors.
-
+
int width_mm_edid_error
# Zero on success, positive it holds the value `errno` had
# when the reading failed, otherwise (negative) the value
- # of an error identifier provided by this library.
-
-
+ # of an error identifier provided by this library
+
size_t height_mm_edid
# The phyical height, in millimetres, of the viewport of the
# attached monitor, as reported by it the monitor's Extended
@@ -243,88 +217,80 @@ cdef extern from "include-libgamma.h":
# the EDID structure.
# Zero means that its is not applicable, which is the case
# for projectors.
-
+
int height_mm_edid_error
# Zero on success, positive it holds the value `errno` had
# when the reading failed, otherwise (negative) the value
- # of an error identifier provided by this library.
-
-
+ # of an error identifier provided by this library
+
size_t red_gamma_size
- # The size of the encoding axis of the red gamma ramp.
-
+ # The size of the encoding axis of the red gamma ramp
+
size_t green_gamma_size
- # The size of the encoding axis of the green gamma ramp.
-
+ # The size of the encoding axis of the green gamma ramp
+
size_t blue_gamma_size
- # The size of the encoding axis of the blue gamma ramp.
-
+ # The size of the encoding axis of the blue gamma ramp
+
int gamma_size_error
# Zero on success, positive it holds the value `errno` had
# when the reading failed, otherwise (negative) the value
- # of an error identifier provided by this library.
-
-
+ # of an error identifier provided by this library
+
signed gamma_depth
# The bit-depth of the value axes of gamma ramps,
# -1 for single precision floating point, and -2 for
- # double precision floating point.
-
+ # double precision floating point
+
int gamma_depth_error
# Zero on success, positive it holds the value `errno` had
# when the reading failed, otherwise (negative) the value
- # of an error identifier provided by this library.
-
-
+ # of an error identifier provided by this library
+
int gamma_support
- # Non-zero gamma ramp adjustments are supported.
-
+ # Non-zero gamma ramp adjustments are supported
+
int gamma_support_error
# Zero on success, positive it holds the value `errno` had
# when the reading failed, otherwise (negative) the value
- # of an error identifier provided by this library.
-
-
+ # of an error identifier provided by this library
+
libgamma_subpixel_order_t subpixel_order
# The layout of the subpixels.
# You cannot count on this value --- especially for CRT:s ---
# but it is provided anyway as a means of distinguishing monitors.
-
+
int subpixel_order_error
# Zero on success, positive it holds the value `errno` had
# when the reading failed, otherwise (negative) the value
# of an error identifier provided by this library.
-
-
+
int active
- # Whether there is a monitors connected to the CRTC.
-
+ # Whether there is a monitors connected to the CRTC
+
int active_error
# Zero on success, positive it holds the value `errno` had
# when the reading failed, otherwise (negative) the value
- # of an error identifier provided by this library.
-
-
- char* connector_name
+ # of an error identifier provided by this library
+
+ char *connector_name
# The name of the connector as designated by the display
# server or as give by this library in case the display
- # server lacks this feature.
-
+ # server lacks this feature
+
int connector_name_error
# Zero on success, positive it holds the value `errno` had
# when the reading failed, otherwise (negative) the value
- # of an error identifier provided by this library.
-
-
+ # of an error identifier provided by this library
+
libgamma_connector_type_t connector_type
- # The type of the connector that is associated with the CRTC.
-
+ # The type of the connector that is associated with the CRTC
+
int connector_type_error
# Zero on success, positive it holds the value `errno` had
# when the reading failed, otherwise (negative) the value
- # of an error identifier provided by this library.
-
-
+ # of an error identifier provided by this library
+
float gamma_red
# The gamma characteristics of the monitor as reported
# in its Extended Display Information Data. The value
@@ -333,7 +299,7 @@ cdef extern from "include-libgamma.h":
# monitor this could be used to give a rought gamma
# correction; simply divide the value with 2.2 and use
# the result for the red channel in the gamma correction.
-
+
float gamma_green
# The gamma characteristics of the monitor as reported
# in its Extended Display Information Data. The value
@@ -342,7 +308,7 @@ cdef extern from "include-libgamma.h":
# monitor this could be used to give a rought gamma
# correction; simply divide the value with 2.2 and use
# the result for the green channel in the gamma correction.
-
+
float gamma_blue
# The gamma characteristics of the monitor as reported
# in its Extended Display Information Data. The value
@@ -351,160 +317,123 @@ cdef extern from "include-libgamma.h":
# monitor this could be used to give a rought gamma
# correction; simply divide the value with 2.2 and use
# the result for the blue channel in the gamma correction.
-
+
int gamma_error
# Zero on success, positive it holds the value `errno` had
# when the reading failed, otherwise (negative) the value
- # of an error identifier provided by this library.
-
-
+ # of an error identifier provided by this library
+
ctypedef struct libgamma_gamma_ramps8_t:
- # Gamma ramp structure for 8-bit gamma ramps.
- size_t red_size
- # The size of `red`.
- size_t green_size
- # The size of `green`.
- size_t blue_size
- # The size of `blue`.
- uint8_t* red
- # The gamma ramp for the red channel.
- uint8_t* green
- # The gamma ramp for the green channel.
- uint8_t* blue
- # The gamma ramp for the blue channel.
-
+ # Gamma ramp structure for 8-bit gamma ramps
+ size_t red_size # The size of `red`
+ size_t green_size # The size of `green`
+ size_t blue_size # The size of `blue`
+ uint8_t *red # The gamma ramp for the red channel
+ uint8_t *green # The gamma ramp for the green channel
+ uint8_t *blue # The gamma ramp for the blue channel
+
ctypedef struct libgamma_gamma_ramps16_t:
- # Gamma ramp structure for 16-bit gamma ramps.
- size_t red_size
- # The size of `red`.
- size_t green_size
- # The size of `green`.
- size_t blue_size
- # The size of `blue`.
- uint16_t* red
- # The gamma ramp for the red channel.
- uint16_t* green
- # The gamma ramp for the green channel.
- uint16_t* blue
- # The gamma ramp for the blue channel.
-
+ # Gamma ramp structure for 16-bit gamma ramps
+ size_t red_size # The size of `red`
+ size_t green_size # The size of `green`
+ size_t blue_size # The size of `blue`
+ uint16_t *red # The gamma ramp for the red channel
+ uint16_t *green # The gamma ramp for the green channel
+ uint16_t *blue # The gamma ramp for the blue channel
+
ctypedef struct libgamma_gamma_ramps32_t:
- # Gamma ramp structure for 32-bit gamma ramps.
- size_t red_size
- # The size of `red`.
- size_t green_size
- # The size of `green`.
- size_t blue_size
- # The size of `blue`.
- uint32_t* red
- # The gamma ramp for the red channel.
- uint32_t* green
- # The gamma ramp for the green channel.
- uint32_t* blue
- # The gamma ramp for the blue channel.
-
+ # Gamma ramp structure for 32-bit gamma ramps
+ size_t red_size # The size of `red`
+ size_t green_size # The size of `green`
+ size_t blue_size # The size of `blue`
+ uint32_t *red # The gamma ramp for the red channel
+ uint32_t *green # The gamma ramp for the green channel
+ uint32_t *blue # The gamma ramp for the blue channel
+
ctypedef struct libgamma_gamma_ramps64_t:
- # Gamma ramp structure for 64-bit gamma ramps.
- size_t red_size
- # The size of `red`.
- size_t green_size
- # The size of `green`.
- size_t blue_size
- # The size of `blue`.
- uint64_t* red
- # The gamma ramp for the red channel.
- uint64_t* green
- # The gamma ramp for the green channel.
- uint64_t* blue
- # The gamma ramp for the blue channel.
-
+ # Gamma ramp structure for 64-bit gamma ramps
+ size_t red_size # The size of `red`
+ size_t green_size # The size of `green`
+ size_t blue_size # The size of `blue`
+ uint64_t *red # The gamma ramp for the red channel
+ uint64_t *green # The gamma ramp for the green channel
+ uint64_t *blue # The gamma ramp for the blue channel
+
ctypedef struct libgamma_gamma_rampsf_t:
- # Gamma ramp structure for `float` gamma ramps.
- size_t red_size
- # The size of `red`.
- size_t green_size
- # The size of `green`.
- size_t blue_size
- # The size of `blue`.
- float* red
- # The gamma ramp for the red channel.
- float* green
- # The gamma ramp for the green channel.
- float* blue
- # The gamma ramp for the blue channel.
-
+ # Gamma ramp structure for `float` gamma ramps
+ size_t red_size # The size of `red`
+ size_t green_size # The size of `green`
+ size_t blue_size # The size of `blue`
+ float *red # The gamma ramp for the red channel
+ float *green # The gamma ramp for the green channel
+ float *blue # The gamma ramp for the blue channel
+
ctypedef struct libgamma_gamma_rampsd_t:
- # Gamma ramp structure for `double` gamma ramps.
- size_t red_size
- # The size of `red`.
- size_t green_size
- # The size of `green`.
- size_t blue_size
- # The size of `blue`.
- double* red
- # The gamma ramp for the red channel.
- double* green
- # The gamma ramp for the green channel.
- double* blue
- # The gamma ramp for the blue channel.
-
-
-cdef extern size_t libgamma_list_methods(int* methods, size_t buf_size, int operation) nogil
+ # Gamma ramp structure for `double` gamma ramps
+ size_t red_size # The size of `red`
+ size_t green_size # The size of `green`
+ size_t blue_size # The size of `blue`
+ double *red # The gamma ramp for the red channel
+ double *green # The gamma ramp for the green channel
+ double *blue # The gamma ramp for the blue channel
+
+
+cdef extern size_t libgamma_list_methods(int *methods, size_t buf_size, int operation) nogil
'''
-List available adjustment methods by their order of preference based on the environment.
+List available adjustment methods by their order of preference based on the environment
-@param methods Output array of methods, should be able to hold `LIBGAMMA_METHOD_COUNT` elements.
+@param methods Output array of methods, should be able to hold `LIBGAMMA_METHOD_COUNT` elements
@param buf_size The number of elements that fits in `methods`, it should be `LIBGAMMA_METHOD_COUNT`,
This is used to avoid writing outside the output buffer if this library adds new
- adjustment methods without the users of the library recompiling.
+ adjustment methods without the users of the library recompiling
@param operation Allowed values:
- 0: Methods that the environment suggests will work, excluding fake.
- 1: Methods that the environment suggests will work, including fake.
- 2: All real non-fake methods.
- 3: All real methods.
- 4: All methods.
- Other values invoke undefined behaviour.
+ 0: Methods that the environment suggests will work, excluding fake
+ 1: Methods that the environment suggests will work, including fake
+ 2: All real non-fake methods
+ 3: All real methods
+ 4: All methods
+ Other values invoke undefined behaviour
@return The number of element that have been stored in `methods`, or should
- have been stored if the buffer was large enough.
+ have been stored if the buffer was large enough
'''
cdef extern int libgamma_is_method_available(int method) nogil
'''
Check whether an adjustment method is available, non-existing (invalid) methods will be
-identified as not available under the rationale that the library may be out of date.
+identified as not available under the rationale that the library may be out of date
-@param method The adjustment method.
-@return Whether the adjustment method is available.
+@param method The adjustment method
+@return Whether the adjustment method is available
'''
-cdef extern void libgamma_method_capabilities(libgamma_method_capabilities_t* this, int method) nogil
+cdef extern void libgamma_method_capabilities(libgamma_method_capabilities_t *this, int method) nogil
'''
-Return the capabilities of an adjustment method.
+Return the capabilities of an adjustment method
@param this The data structure to fill with the method's capabilities
-@param method The adjustment method (display server and protocol).
+@param method The adjustment method (display server and protocol)
'''
-cdef extern char* libgamma_method_default_site(int method) nogil
+cdef extern char *libgamma_method_default_site(int method) nogil
'''
-Return the default site for an adjustment method.
+Return the default site for an adjustment method
-@param method The adjustment method (display server and protocol.)
+@param method The adjustment method (display server and protocol)
@return The default site, `NULL` if it cannot be determined or
if multiple sites are not supported by the adjustment
- method. This value should not be `free`:d.
+ method. This value should not be `free`:d
'''
-cdef extern const char* libgamma_method_default_site_variable(int method) nogil
+cdef extern const char *libgamma_method_default_site_variable(int method) nogil
'''
Return the default variable that determines
-the default site for an adjustment method.
+the default site for an adjustment method
-@param method The adjustment method (display server and protocol.)
+@param method The adjustment method (display server and protocol)
@return The environ variables that is used to determine the
default site. `NULL` if there is none, that is, if
the method does not support multiple sites.
@@ -512,13 +441,12 @@ the default site for an adjustment method.
'''
-
-cdef extern int libgamma_site_initialise(libgamma_site_state_t* this, int method, char* site) nogil
+cdef extern int libgamma_site_initialise(libgamma_site_state_t *this, int method, char *site) nogil
'''
-Initialise an allocated site state.
+Initialise an allocated site state
-@param this The site state to initialise.
-@param method The adjustment method (display server and protocol.)
+@param this The site state to initialise
+@param method The adjustment method (display server and protocol)
@param site The site identifier, unless it is `NULL` it must a
`free`:able. One the state is destroyed the library
will attempt to free it. There you should not free
@@ -526,277 +454,268 @@ Initialise an allocated site state.
or allocate on the stack. Note however that it will
not be `free`:d if this function fails.
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-cdef extern void libgamma_site_free(libgamma_site_state_t* this) nogil
+cdef extern void libgamma_site_free(libgamma_site_state_t *this) nogil
'''
Release all resources held by a site state
-and free the site state pointer.
+and free the site state pointer
-@param this The site state.
+@param this The site state
'''
-cdef extern int libgamma_site_restore(libgamma_site_state_t* this) nogil
+cdef extern int libgamma_site_restore(libgamma_site_state_t *this) nogil
'''
-Restore the gamma ramps all CRTC:s with a site to the system settings.
+Restore the gamma ramps all CRTC:s with a site to the system settings
-@param this The site state.
+@param this The site state
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-
-cdef extern int libgamma_partition_initialise(libgamma_partition_state_t* this, libgamma_site_state_t* site, size_t partition) nogil
+cdef extern int libgamma_partition_initialise(libgamma_partition_state_t *this, libgamma_site_state_t* site, size_t partition) nogil
'''
-Initialise an allocated partition state.
+Initialise an allocated partition state
-@param this The partition state to initialise.
+@param this The partition state to initialise
@param site The site state for the site that the partition belongs to.
-@param partition The index of the partition within the site.
+@param partition The index of the partition within the site
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-cdef extern void libgamma_partition_free(libgamma_partition_state_t* this) nogil
+cdef extern void libgamma_partition_free(libgamma_partition_state_t *this) nogil
'''
Release all resources held by a partition state
-and free the partition state pointer.
+and free the partition state pointer
-@param this The partition state.
+@param this The partition state
'''
-cdef extern int libgamma_partition_restore(libgamma_partition_state_t* this) nogil
+cdef extern int libgamma_partition_restore(libgamma_partition_state_t *this) nogil
'''
-Restore the gamma ramps all CRTC:s with a partition to the system settings.
+Restore the gamma ramps all CRTC:s with a partition to the system settings
-@param this The partition state.
+@param this The partition state
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-
-cdef extern int libgamma_crtc_initialise(libgamma_crtc_state_t* this, libgamma_partition_state_t* partition, size_t crtc) nogil
+cdef extern int libgamma_crtc_initialise(libgamma_crtc_state_t *this, libgamma_partition_state_t *partition, size_t crtc) nogil
'''
-Initialise an allocated CRTC state.
+Initialise an allocated CRTC state
-@param this The CRTC state to initialise.
-@param partition The partition state for the partition that the CRTC belongs to.
-@param crtc The index of the CRTC within the partition.
+@param this The CRTC state to initialise
+@param partition The partition state for the partition that the CRTC belongs to
+@param crtc The index of the CRTC within the partition
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-cdef extern void libgamma_crtc_free(libgamma_crtc_state_t* this) nogil
+cdef extern void libgamma_crtc_free(libgamma_crtc_state_t *this) nogil
'''
Release all resources held by a CRTC state
-and free the CRTC state pointer.
+and free the CRTC state pointer
-@param this The CRTC state.
+@param this The CRTC state
'''
-cdef extern int libgamma_crtc_restore(libgamma_crtc_state_t* this) nogil
+cdef extern int libgamma_crtc_restore(libgamma_crtc_state_t *this) nogil
'''
-Restore the gamma ramps for a CRTC to the system settings for that CRTC.
+Restore the gamma ramps for a CRTC to the system settings for that CRTC
@param this The CRTC state
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-
-cdef extern int libgamma_get_crtc_information(libgamma_crtc_information_t* this, libgamma_crtc_state_t* crtc, int32_t fields) nogil
+cdef extern int libgamma_get_crtc_information(libgamma_crtc_information_t *this, libgamma_crtc_state_t *crtc, int32_t fields) nogil
'''
-Read information about a CRTC.
+Read information about a CRTC
-@param this Instance of a data structure to fill with the information about the CRTC.
-@param crtc The state of the CRTC whose information should be read.
-@param fields OR:ed identifiers for the information about the CRTC that should be read.
-@return Zero on success, -1 on error. On error refer to the error reports in `this`.
+@param this Instance of a data structure to fill with the information about the CRTC
+@param crtc The state of the CRTC whose information should be read
+@param fields OR:ed identifiers for the information about the CRTC that should be read
+@return Zero on success, -1 on error; on error refer to the error reports in `this`
'''
-cdef extern void libgamma_crtc_information_destroy(libgamma_crtc_information_t* this) nogil
+cdef extern void libgamma_crtc_information_destroy(libgamma_crtc_information_t *this) nogil
'''
-Release all resources in an information data structure for a CRTC.
+Release all resources in an information data structure for a CRTC
-@param this The CRTC information.
+@param this The CRTC information
'''
-
-cdef extern int libgamma_crtc_get_gamma_ramps8(libgamma_crtc_state_t* this, libgamma_gamma_ramps8_t* ramps) nogil
+cdef extern int libgamma_crtc_get_gamma_ramps8(libgamma_crtc_state_t *this, libgamma_gamma_ramps8_t *ramps) nogil
'''
-Get the current gamma ramps for a CRTC, 8-bit gamma-depth version.
+Get the current gamma ramps for a CRTC, 8-bit gamma-depth version
-@param this The CRTC state.
+@param this The CRTC state
@param ramps The gamma ramps to fill with the current values
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-cdef extern int libgamma_crtc_set_gamma_ramps8(libgamma_crtc_state_t* this, libgamma_gamma_ramps8_t ramps) nogil
+cdef extern int libgamma_crtc_set_gamma_ramps8(libgamma_crtc_state_t *this, libgamma_gamma_ramps8_t ramps) nogil
'''
-Set the gamma ramps for a CRTC, 8-bit gamma-depth version.
+Set the gamma ramps for a CRTC, 8-bit gamma-depth version
-@param this The CRTC state.
-@param ramps The gamma ramps to apply.
+@param this The CRTC state
+@param ramps The gamma ramps to apply
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-
-cdef extern int libgamma_crtc_get_gamma_ramps16(libgamma_crtc_state_t* this, libgamma_gamma_ramps16_t* ramps) nogil
+cdef extern int libgamma_crtc_get_gamma_ramps16(libgamma_crtc_state_t *this, libgamma_gamma_ramps16_t *ramps) nogil
'''
-Get the current gamma ramps for a CRTC, 16-bit gamma-depth version.
+Get the current gamma ramps for a CRTC, 16-bit gamma-depth version
-@param this The CRTC state.
+@param this The CRTC state
@param ramps The gamma ramps to fill with the current values
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-cdef extern int libgamma_crtc_set_gamma_ramps16(libgamma_crtc_state_t* this, libgamma_gamma_ramps16_t ramps) nogil
+cdef extern int libgamma_crtc_set_gamma_ramps16(libgamma_crtc_state_t *this, libgamma_gamma_ramps16_t ramps) nogil
'''
-Set the gamma ramps for a CRTC, 16-bit gamma-depth version.
+Set the gamma ramps for a CRTC, 16-bit gamma-depth version
-@param this The CRTC state.
-@param ramps The gamma ramps to apply.
+@param this The CRTC state
+@param ramps The gamma ramps to apply
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-
-cdef extern int libgamma_crtc_get_gamma_ramps32(libgamma_crtc_state_t* this, libgamma_gamma_ramps32_t* ramps) nogil
+cdef extern int libgamma_crtc_get_gamma_ramps32(libgamma_crtc_state_t *this, libgamma_gamma_ramps32_t *ramps) nogil
'''
-Get the current gamma ramps for a CRTC, 32-bit gamma-depth version.
+Get the current gamma ramps for a CRTC, 32-bit gamma-depth version
-@param this The CRTC state.
-@param ramps The gamma ramps to fill with the current values.
+@param this The CRTC state
+@param ramps The gamma ramps to fill with the current values
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-cdef extern int libgamma_crtc_set_gamma_ramps32(libgamma_crtc_state_t* this, libgamma_gamma_ramps32_t ramps) nogil
+cdef extern int libgamma_crtc_set_gamma_ramps32(libgamma_crtc_state_t *this, libgamma_gamma_ramps32_t ramps) nogil
'''
-Set the gamma ramps for a CRTC, 32-bit gamma-depth version.
+Set the gamma ramps for a CRTC, 32-bit gamma-depth version
-@param this The CRTC state.
-@param ramps The gamma ramps to apply.
+@param this The CRTC state
+@param ramps The gamma ramps to apply
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-
-cdef extern int libgamma_crtc_get_gamma_ramps64(libgamma_crtc_state_t* this, libgamma_gamma_ramps64_t* ramps) nogil
+cdef extern int libgamma_crtc_get_gamma_ramps64(libgamma_crtc_state_t *this, libgamma_gamma_ramps64_t *ramps) nogil
'''
-Get the current gamma ramps for a CRTC, 64-bit gamma-depth version.
+Get the current gamma ramps for a CRTC, 64-bit gamma-depth version
-@param this The CRTC state.
-@param ramps The gamma ramps to fill with the current values.
+@param this The CRTC state
+@param ramps The gamma ramps to fill with the current values
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-cdef extern int libgamma_crtc_set_gamma_ramps64(libgamma_crtc_state_t* this, libgamma_gamma_ramps64_t ramps) nogil
+cdef extern int libgamma_crtc_set_gamma_ramps64(libgamma_crtc_state_t *this, libgamma_gamma_ramps64_t ramps) nogil
'''
-Set the gamma ramps for a CRTC, 64-bit gamma-depth version.
+Set the gamma ramps for a CRTC, 64-bit gamma-depth version
-@param this The CRTC state.
-@param ramps The gamma ramps to apply.
+@param this The CRTC state
+@param ramps The gamma ramps to apply
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-
-cdef extern int libgamma_crtc_set_gamma_rampsf(libgamma_crtc_state_t* this, libgamma_gamma_rampsf_t ramps) nogil
+cdef extern int libgamma_crtc_get_gamma_rampsf(libgamma_crtc_state_t *this, libgamma_gamma_rampsf_t *ramps) nogil
'''
-Set the gamma ramps for a CRTC, `float` version.
+Get the current gamma ramps for a CRTC, `float` version
-@param this The CRTC state.
-@param ramps The gamma ramps to apply.
+@param this The CRTC state
+@param ramps The gamma ramps to fill with the current values
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-cdef extern int libgamma_crtc_get_gamma_rampsf(libgamma_crtc_state_t* this, libgamma_gamma_rampsf_t* ramps) nogil
+cdef extern int libgamma_crtc_set_gamma_rampsf(libgamma_crtc_state_t *this, libgamma_gamma_rampsf_t ramps) nogil
'''
-Get the current gamma ramps for a CRTC, `float` version.
+Set the gamma ramps for a CRTC, `float` version
-@param this The CRTC state.
-@param ramps The gamma ramps to fill with the current values.
+@param this The CRTC state
+@param ramps The gamma ramps to apply
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-cdef extern int libgamma_crtc_get_gamma_rampsd(libgamma_crtc_state_t* this, libgamma_gamma_rampsd_t* ramps) nogil
+cdef extern int libgamma_crtc_get_gamma_rampsd(libgamma_crtc_state_t *this, libgamma_gamma_rampsd_t *ramps) nogil
'''
-Get the current gamma ramps for a CRTC, `double` version.
+Get the current gamma ramps for a CRTC, `double` version
-@param this The CRTC state.
-@param ramps The gamma ramps to fill with the current values.
+@param this The CRTC state
+@param ramps The gamma ramps to fill with the current values
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-cdef extern int libgamma_crtc_set_gamma_rampsd(libgamma_crtc_state_t* this, libgamma_gamma_rampsd_t ramps) nogil
+cdef extern int libgamma_crtc_set_gamma_rampsd(libgamma_crtc_state_t *this, libgamma_gamma_rampsd_t ramps) nogil
'''
-Set the gamma ramps for a CRTC, `double` version.
+Set the gamma ramps for a CRTC, `double` version
-@param this The CRTC state.
-@param ramps The gamma ramps to apply.
+@param this The CRTC state
+@param ramps The gamma ramps to apply
@return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ error identifier provided by this library
'''
-
def libgamma_native_list_methods(operation : int) -> list:
'''
- List available adjustment methods by their order of preference based on the environment.
+ List available adjustment methods by their order of preference based on the environment
@param operation Allowed values:
- 0: Methods that the environment suggests will work, excluding fake.
- 1: Methods that the environment suggests will work, including fake.
- 2: All real non-fake methods.
- 3: All real methods.
- 4: All methods.
- Other values invoke undefined behaviour.
- @return :list<int> A list of available adjustment methods.
+ 0: Methods that the environment suggests will work, excluding fake
+ 1: Methods that the environment suggests will work, including fake
+ 2: All real non-fake methods
+ 3: All real methods
+ 4: All methods
+ Other values invoke undefined behaviour
+ @return :list<int> A list of available adjustment methods
'''
- cdef int* methods
+ cdef int *methods
cdef size_t buf_size
cdef size_t r
buf_size = 6
- methods = <int*>malloc(buf_size * sizeof(size_t))
+ methods = <int *>malloc(buf_size * sizeof(size_t))
if methods == NULL:
raise MemoryError()
r = libgamma_list_methods(methods, buf_size, operation)
if r > buf_size:
buf_size = r
free(methods)
- methods = <int*>malloc(buf_size * sizeof(size_t))
+ methods = <int *>malloc(buf_size * sizeof(size_t))
if methods == NULL:
raise MemoryError()
libgamma_list_methods(methods, buf_size, operation)
@@ -810,20 +729,20 @@ def libgamma_native_list_methods(operation : int) -> list:
def libgamma_native_is_method_available(method : int) -> int:
'''
Check whether an adjustment method is available, non-existing (invalid) methods will be
- identified as not available under the rationale that the library may be out of date.
+ identified as not available under the rationale that the library may be out of date
- @param method The adjustment method.
- @return Whether the adjustment method is available.
+ @param method The adjustment method
+ @return Whether the adjustment method is available
'''
return int(libgamma_is_method_available(<int>method))
def libgamma_native_method_capabilities(method : int) -> tuple:
'''
- Return the capabilities of an adjustment method.
+ Return the capabilities of an adjustment method
- @param method The adjustment method (display server and protocol).
- @return :(int, int) Input parameters for `MethodCapabilities.__init__`.
+ @param method The adjustment method (display server and protocol)
+ @return :(int, int) Input parameters for `MethodCapabilities.__init__`
'''
cdef libgamma_method_capabilities_t caps
libgamma_method_capabilities(&caps, <int>method)
@@ -847,14 +766,14 @@ def libgamma_native_method_capabilities(method : int) -> tuple:
def libgamma_native_method_default_site(method : int) -> str:
'''
- Return the default site for an adjustment method.
+ Return the default site for an adjustment method
- @param method The adjustment method (display server and protocol.)
+ @param method The adjustment method (display server and protocol)
@return The default site, `None` if it cannot be determined or
if multiple sites are not supported by the adjustment
- method.
+ method
'''
- cdef char* var
+ cdef char *var
cdef bytes bs
var = libgamma_method_default_site(<int>method)
if var is NULL:
@@ -866,14 +785,14 @@ def libgamma_native_method_default_site(method : int) -> str:
def libgamma_native_method_default_site_variable(method : int) -> str:
'''
Return the default variable that determines
- the default site for an adjustment method.
+ the default site for an adjustment method
- @param method The adjustment method (display server and protocol.)
+ @param method The adjustment method (display server and protocol)
@return The environ variables that is used to determine the
default site. `None` if there is none, that is, if
the method does not support multiple sites.
'''
- cdef const char* var
+ cdef const char *var
cdef bytes bs
var = libgamma_method_default_site_variable(<int>method)
if var is NULL:
@@ -882,12 +801,11 @@ def libgamma_native_method_default_site_variable(method : int) -> str:
return bs.decode('utf-8', 'strict')
-
def libgamma_native_site_create(method : int, site : str) -> tuple:
'''
- Create an allocated site state.
+ Create an allocated site state
- @param method The adjustment method (display server and protocol.)
+ @param method The adjustment method (display server and protocol)
@param site The site identifier, unless it is `NULL` it must a
`free`:able. One the state is destroyed the library
will attempt to free it. There you should not free
@@ -897,19 +815,19 @@ def libgamma_native_site_create(method : int, site : str) -> tuple:
@return :(site:int, partitions:int) First value: The created site, zero on error
Second value: The number of partitions in the site,
on error: the value of the error identifier
- provided by this library or `errno`.
+ provided by this library or `errno`
'''
- cdef libgamma_site_state_t* this
- cdef char* site_
+ cdef libgamma_site_state_t *this
+ cdef char *site_
cdef size_t this_address
- this = <libgamma_site_state_t*>malloc(sizeof(libgamma_site_state_t))
+ this = <libgamma_site_state_t *>malloc(sizeof(libgamma_site_state_t))
if this is NULL:
raise MemoryError()
- this_address = <size_t><void*>this
+ this_address = <size_t><void *>this
site_ = NULL
if site is not None:
site_bs = site.encode('utf-8') + bytes([0])
- site_ = <char*>malloc(len(site_bs) * sizeof(char))
+ site_ = <char *>malloc(len(site_bs) * sizeof(char))
if site_ is None:
free(this)
raise MemoryError()
@@ -925,55 +843,54 @@ def libgamma_native_site_create(method : int, site : str) -> tuple:
def libgamma_native_site_free(this : int):
'''
Release all resources held by a site state
- and free the CRTC state pointer.
+ and free the CRTC state pointer
- @param this The site state.
+ @param this The site state
'''
cdef size_t this_address
- cdef libgamma_site_state_t* this_
+ cdef libgamma_site_state_t *this_
this_address = <size_t>this
- this_ = <libgamma_site_state_t*><void*>this_address
+ this_ = <libgamma_site_state_t *><void *>this_address
libgamma_site_free(this_)
def libgamma_native_site_restore(this : int) -> int:
'''
- Restore the gamma ramps all CRTC:s with a site to the system settings.
+ Restore the gamma ramps all CRTC:s with a site to the system settings
- @param this The site state.
+ @param this The site state
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
- cdef libgamma_site_state_t* this_
+ cdef libgamma_site_state_t *this_
this_address = <size_t>this
- this_ = <libgamma_site_state_t*><void*>this_address
+ this_ = <libgamma_site_state_t *><void *>this_address
r = int(libgamma_site_restore(this_))
return int(errno) if r == -1 else r
-
def libgamma_native_partition_create(site : int, partition : int) -> tuple:
'''
- Create an allocated partition state.
+ Create an allocated partition state
- @param site The site state for the site that the partition belongs to.
- @param partition The index of the partition within the site.
+ @param site The site state for the site that the partition belongs to
+ @param partition The index of the partition within the site
@return :(site:int, partitions:int) First value: The created partition, zero on error
Second value: The number of CRTC:s in the partition,
on error: the value of the error identifier
- provided by this library or `errno`.
+ provided by this library or `errno`
'''
- cdef libgamma_partition_state_t* this
- cdef libgamma_site_state_t* site_
+ cdef libgamma_partition_state_t *this
+ cdef libgamma_site_state_t *site_
cdef size_t this_address
cdef size_t site_address
site_address = <size_t>site
- site_ = <libgamma_site_state_t*><void*>site_address
- this = <libgamma_partition_state_t*>malloc(sizeof(libgamma_partition_state_t))
+ site_ = <libgamma_site_state_t *><void *>site_address
+ this = <libgamma_partition_state_t *>malloc(sizeof(libgamma_partition_state_t))
if this is NULL:
raise MemoryError()
- this_address = <size_t><void*>this
+ this_address = <size_t><void *>this
r = int(libgamma_partition_initialise(this, site_, <size_t>partition))
if not r == 0:
libgamma_partition_free(this)
@@ -984,54 +901,53 @@ def libgamma_native_partition_create(site : int, partition : int) -> tuple:
def libgamma_native_partition_free(this : int):
'''
Release all resources held by a partition state
- and free the partition state pointer.
+ and free the partition state pointer
- @param this The partition state.
+ @param this The partition state
'''
cdef size_t this_address
- cdef libgamma_partition_state_t* this_
+ cdef libgamma_partition_state_t *this_
this_address = <size_t>this
- this_ = <libgamma_partition_state_t*><void*>this_address
+ this_ = <libgamma_partition_state_t *><void *>this_address
libgamma_partition_free(this_)
def libgamma_native_partition_restore(this : int) -> int:
'''
- Restore the gamma ramps all CRTC:s with a partition to the system settings.
+ Restore the gamma ramps all CRTC:s with a partition to the system settings
- @param this The partition state.
+ @param this The partition state
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
- cdef libgamma_partition_state_t* this_
+ cdef libgamma_partition_state_t *this_
this_address = <size_t>this
- this_ = <libgamma_partition_state_t*><void*>this_address
+ this_ = <libgamma_partition_state_t *><void *>this_address
r = int(libgamma_partition_restore(this_))
return int(errno) if r == -1 else r
-
def libgamma_native_crtc_create(partition : int, crtc : int) -> tuple:
'''
- Create an allocated CRTC state.
+ Create an allocated CRTC state
@param partition The partition state for the partition that the CRTC belongs to.
- @param crtc The index of the CRTC within the partition.
- @return :(int, int) First value: The created CRTC, zero on error.
+ @param crtc The index of the CRTC within the partition
+ @return :(int, int) First value: The created CRTC, zero on error
Second value: Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
- cdef libgamma_crtc_state_t* this
- cdef libgamma_partition_state_t* partition_
+ cdef libgamma_crtc_state_t *this
+ cdef libgamma_partition_state_t *partition_
cdef size_t this_address
cdef size_t partition_address
partition_address = <size_t>partition
- partition_ = <libgamma_partition_state_t*><void*>partition_address
- this = <libgamma_crtc_state_t*>malloc(sizeof(libgamma_crtc_state_t))
+ partition_ = <libgamma_partition_state_t *><void *>partition_address
+ this = <libgamma_crtc_state_t *>malloc(sizeof(libgamma_crtc_state_t))
if this is NULL:
raise MemoryError()
- this_address = <size_t><void*>this
+ this_address = <size_t><void *>this
r = int(libgamma_crtc_initialise(this, partition_, <size_t>crtc))
if not r == 0:
libgamma_crtc_free(this)
@@ -1042,50 +958,49 @@ def libgamma_native_crtc_create(partition : int, crtc : int) -> tuple:
def libgamma_native_crtc_free(this : int):
'''
Release all resources held by a CRTC state
- and free the CRTC state pointer.
+ and free the CRTC state pointer
- @param this The CRTC state.
+ @param this The CRTC state
'''
cdef size_t this_address
- cdef libgamma_crtc_state_t* this_
+ cdef libgamma_crtc_state_t *this_
this_address = <size_t>this
- this_ = <libgamma_crtc_state_t*><void*>this_address
+ this_ = <libgamma_crtc_state_t *><void *>this_address
libgamma_crtc_free(this_)
def libgamma_native_crtc_restore(this : int) -> int:
'''
- Restore the gamma ramps for a CRTC to the system settings for that CRTC.
+ Restore the gamma ramps for a CRTC to the system settings for that CRTC
@param this The CRTC state
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
- cdef libgamma_crtc_state_t* this_
+ cdef libgamma_crtc_state_t *this_
this_address = <size_t>this
- this_ = <libgamma_crtc_state_t*><void*>this_address
+ this_ = <libgamma_crtc_state_t *><void *>this_address
r = int(libgamma_crtc_restore(this_))
return int(errno) if r == -1 else r
-
def libgamma_native_get_crtc_information(crtc : int, fields : int) -> tuple:
'''
- Read information about a CRTC.
+ Read information about a CRTC
- @param crtc The state of the CRTC whose information should be read.
- @param field OR:ed identifiers for the information about the CRTC that should be read.
+ @param crtc The state of the CRTC whose information should be read
+ @param field OR:ed identifiers for the information about the CRTC that should be read
@return :(list, :int) First value: Input parametrs for `CRTCInformation.__init__`
- Second value: Zero on success, -1 on error. On error refer to
- the error reports in the return.
+ Second value: Zero on success, -1 on error; on error refer to
+ the error reports in the return
'''
cdef libgamma_crtc_information_t info
cdef size_t crtc_address
- cdef libgamma_crtc_state_t* crtc_
+ cdef libgamma_crtc_state_t *crtc_
cdef bytes bs
crtc_address = <size_t>crtc
- crtc_ = <libgamma_crtc_state_t*><void*>crtc_address
+ crtc_ = <libgamma_crtc_state_t *><void *>crtc_address
r = int(libgamma_get_crtc_information(&info, crtc_, <int32_t>fields))
rc = []
connector_name = None
@@ -1130,260 +1045,253 @@ def libgamma_native_get_crtc_information(crtc : int, fields : int) -> tuple:
return (rc, r)
-
def libgamma_native_crtc_get_gamma_ramps8(this : int, ramps : int) -> int:
'''
- Get the current gamma ramps for a CRTC, 8-bit gamma-depth version.
+ Get the current gamma ramps for a CRTC, 8-bit gamma-depth version
- @param this The CRTC state.
- @param ramps The gamma ramps to fill with the current values.
+ @param this The CRTC state
+ @param ramps The gamma ramps to fill with the current values
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
cdef size_t ramps_address
- cdef libgamma_crtc_state_t* this_
- cdef libgamma_gamma_ramps8_t* ramps_
+ cdef libgamma_crtc_state_t *this_
+ cdef libgamma_gamma_ramps8_t *ramps_
this_address = <size_t>this
ramps_address = <size_t>ramps
- this_ = <libgamma_crtc_state_t*><void*>this_address
- ramps_ = <libgamma_gamma_ramps8_t*><void*>ramps_address
+ this_ = <libgamma_crtc_state_t *><void *>this_address
+ ramps_ = <libgamma_gamma_ramps8_t *><void *>ramps_address
r = int(libgamma_crtc_get_gamma_ramps8(this_, ramps_))
return int(errno) if r == -1 else r
def libgamma_native_crtc_set_gamma_ramps8(this : int, ramps : int) -> int:
'''
- Set the gamma ramps for a CRTC, 8-bit gamma-depth version.
+ Set the gamma ramps for a CRTC, 8-bit gamma-depth version
- @param this The CRTC state.
- @param ramps The gamma ramps to apply.
+ @param this The CRTC state
+ @param ramps The gamma ramps to apply
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
cdef size_t ramps_address
- cdef libgamma_crtc_state_t* this_
- cdef libgamma_gamma_ramps8_t* ramps_
+ cdef libgamma_crtc_state_t *this_
+ cdef libgamma_gamma_ramps8_t *ramps_
this_address = <size_t>this
ramps_address = <size_t>ramps
- this_ = <libgamma_crtc_state_t*><void*>this_address
- ramps_ = <libgamma_gamma_ramps8_t*><void*>ramps_address
+ this_ = <libgamma_crtc_state_t *><void *>this_address
+ ramps_ = <libgamma_gamma_ramps8_t *><void *>ramps_address
r = int(libgamma_crtc_set_gamma_ramps8(this_, ramps_[0]))
return int(errno) if r == -1 else r
-
def libgamma_native_crtc_get_gamma_ramps16(this : int, ramps : int) -> int:
'''
- Get the current gamma ramps for a CRTC, 16-bit gamma-depth version.
+ Get the current gamma ramps for a CRTC, 16-bit gamma-depth version
- @param this The CRTC state.
- @param ramps The gamma ramps to fill with the current values.
+ @param this The CRTC state
+ @param ramps The gamma ramps to fill with the current values
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
cdef size_t ramps_address
- cdef libgamma_crtc_state_t* this_
- cdef libgamma_gamma_ramps16_t* ramps_
+ cdef libgamma_crtc_state_t *this_
+ cdef libgamma_gamma_ramps16_t *ramps_
this_address = <size_t>this
ramps_address = <size_t>ramps
- this_ = <libgamma_crtc_state_t*><void*>this_address
- ramps_ = <libgamma_gamma_ramps16_t*><void*>ramps_address
+ this_ = <libgamma_crtc_state_t *><void *>this_address
+ ramps_ = <libgamma_gamma_ramps16_t *><void *>ramps_address
r = int(libgamma_crtc_get_gamma_ramps16(this_, ramps_))
return int(errno) if r == -1 else r
def libgamma_native_crtc_set_gamma_ramps16(this : int, ramps : int) -> int:
'''
- Set the gamma ramps for a CRTC, 16-bit gamma-depth version.
+ Set the gamma ramps for a CRTC, 16-bit gamma-depth version
- @param this The CRTC state.
- @param ramps The gamma ramps to apply.
+ @param this The CRTC state
+ @param ramps The gamma ramps to apply
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
cdef size_t ramps_address
- cdef libgamma_crtc_state_t* this_
- cdef libgamma_gamma_ramps16_t* ramps_
+ cdef libgamma_crtc_state_t *this_
+ cdef libgamma_gamma_ramps16_t *ramps_
this_address = <size_t>this
ramps_address = <size_t>ramps
- this_ = <libgamma_crtc_state_t*><void*>this_address
- ramps_ = <libgamma_gamma_ramps16_t*><void*>ramps_address
+ this_ = <libgamma_crtc_state_t *><void *>this_address
+ ramps_ = <libgamma_gamma_ramps16_t *><void *>ramps_address
r = int(libgamma_crtc_set_gamma_ramps16(this_, ramps_[0]))
return int(errno) if r == -1 else r
-
def libgamma_native_crtc_get_gamma_ramps32(this : int, ramps : int) -> int:
'''
- Get the current gamma ramps for a CRTC, 32-bit gamma-depth version.
+ Get the current gamma ramps for a CRTC, 32-bit gamma-depth version
- @param this The CRTC state.
- @param ramps The gamma ramps to fill with the current values.
+ @param this The CRTC state
+ @param ramps The gamma ramps to fill with the current values
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
cdef size_t ramps_address
- cdef libgamma_crtc_state_t* this_
- cdef libgamma_gamma_ramps32_t* ramps_
+ cdef libgamma_crtc_state_t *this_
+ cdef libgamma_gamma_ramps32_t *ramps_
this_address = <size_t>this
ramps_address = <size_t>ramps
- this_ = <libgamma_crtc_state_t*><void*>this_address
- ramps_ = <libgamma_gamma_ramps32_t*><void*>ramps_address
+ this_ = <libgamma_crtc_state_t *><void *>this_address
+ ramps_ = <libgamma_gamma_ramps32_t *><void *>ramps_address
r = int(libgamma_crtc_get_gamma_ramps32(this_, ramps_))
return int(errno) if r == -1 else r
def libgamma_native_crtc_set_gamma_ramps32(this : int, ramps : int) -> int:
'''
- Set the gamma ramps for a CRTC, 32-bit gamma-depth version.
+ Set the gamma ramps for a CRTC, 32-bit gamma-depth version
- @param this The CRTC state.
- @param ramps The gamma ramps to apply.
+ @param this The CRTC state
+ @param ramps The gamma ramps to apply
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
cdef size_t ramps_address
- cdef libgamma_crtc_state_t* this_
- cdef libgamma_gamma_ramps32_t* ramps_
+ cdef libgamma_crtc_state_t *this_
+ cdef libgamma_gamma_ramps32_t *ramps_
this_address = <size_t>this
ramps_address = <size_t>ramps
- this_ = <libgamma_crtc_state_t*><void*>this_address
- ramps_ = <libgamma_gamma_ramps32_t*><void*>ramps_address
+ this_ = <libgamma_crtc_state_t *><void *>this_address
+ ramps_ = <libgamma_gamma_ramps32_t *><void *>ramps_address
r = int(libgamma_crtc_set_gamma_ramps32(this_, ramps_[0]))
return int(errno) if r == -1 else r
-
def libgamma_native_crtc_get_gamma_ramps64(this : int, ramps : int) -> int:
'''
- Get the current gamma ramps for a CRTC, 64-bit gamma-depth version.
+ Get the current gamma ramps for a CRTC, 64-bit gamma-depth version
- @param this The CRTC state.
- @param ramps The gamma ramps to fill with the current values.
+ @param this The CRTC state
+ @param ramps The gamma ramps to fill with the current values
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
cdef size_t ramps_address
- cdef libgamma_crtc_state_t* this_
- cdef libgamma_gamma_ramps64_t* ramps_
+ cdef libgamma_crtc_state_t *this_
+ cdef libgamma_gamma_ramps64_t *ramps_
this_address = <size_t>this
ramps_address = <size_t>ramps
- this_ = <libgamma_crtc_state_t*><void*>this_address
- ramps_ = <libgamma_gamma_ramps64_t*><void*>ramps_address
+ this_ = <libgamma_crtc_state_t *><void *>this_address
+ ramps_ = <libgamma_gamma_ramps64_t *><void *>ramps_address
r = int(libgamma_crtc_get_gamma_ramps64(this_, ramps_))
return int(errno) if r == -1 else r
def libgamma_native_crtc_set_gamma_ramps64(this : int, ramps : int) -> int:
'''
- Set the gamma ramps for a CRTC, 64-bit gamma-depth version.
+ Set the gamma ramps for a CRTC, 64-bit gamma-depth version
- @param this The CRTC state.
- @param ramps The gamma ramps to apply.
+ @param this The CRTC state
+ @param ramps The gamma ramps to apply
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
cdef size_t ramps_address
- cdef libgamma_crtc_state_t* this_
- cdef libgamma_gamma_ramps64_t* ramps_
+ cdef libgamma_crtc_state_t * this_
+ cdef libgamma_gamma_ramps64_t * ramps_
this_address = <size_t>this
ramps_address = <size_t>ramps
- this_ = <libgamma_crtc_state_t*><void*>this_address
- ramps_ = <libgamma_gamma_ramps64_t*><void*>ramps_address
+ this_ = <libgamma_crtc_state_t *><void *>this_address
+ ramps_ = <libgamma_gamma_ramps64_t *><void *>ramps_address
r = int(libgamma_crtc_set_gamma_ramps64(this_, ramps_[0]))
return int(errno) if r == -1 else r
-
def libgamma_native_crtc_get_gamma_rampsf(this : int, ramps : int) -> int:
'''
- Get the current gamma ramps for a CRTC, `float` version.
+ Get the current gamma ramps for a CRTC, `float` version
- @param this The CRTC state.
- @param ramps The gamma ramps to fill with the current values.
+ @param this The CRTC state
+ @param ramps The gamma ramps to fill with the current values
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
cdef size_t ramps_address
- cdef libgamma_crtc_state_t* this_
- cdef libgamma_gamma_rampsf_t* ramps_
+ cdef libgamma_crtc_state_t *this_
+ cdef libgamma_gamma_rampsf_t *ramps_
this_address = <size_t>this
ramps_address = <size_t>ramps
- this_ = <libgamma_crtc_state_t*><void*>this_address
- ramps_ = <libgamma_gamma_rampsf_t*><void*>ramps_address
+ this_ = <libgamma_crtc_state_t *><void *>this_address
+ ramps_ = <libgamma_gamma_rampsf_t *><void *>ramps_address
r = int(libgamma_crtc_get_gamma_rampsf(this_, ramps_))
return int(errno) if r == -1 else r
def libgamma_native_crtc_set_gamma_rampsf(this : int, ramps : int) -> int:
'''
- Set the gamma ramps for a CRTC, `float` version.
+ Set the gamma ramps for a CRTC, `float` version
- @param this The CRTC state.
- @param ramps The gamma ramps to apply.
+ @param this The CRTC state
+ @param ramps The gamma ramps to apply
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
cdef size_t ramps_address
- cdef libgamma_crtc_state_t* this_
- cdef libgamma_gamma_rampsf_t* ramps_
+ cdef libgamma_crtc_state_t *this_
+ cdef libgamma_gamma_rampsf_t *ramps_
this_address = <size_t>this
ramps_address = <size_t>ramps
- this_ = <libgamma_crtc_state_t*><void*>this_address
- ramps_ = <libgamma_gamma_rampsf_t*><void*>ramps_address
+ this_ = <libgamma_crtc_state_t *><void *>this_address
+ ramps_ = <libgamma_gamma_rampsf_t *><void *>ramps_address
r = int(libgamma_crtc_set_gamma_rampsf(this_, ramps_[0]))
return int(errno) if r == -1 else r
-
def libgamma_native_crtc_get_gamma_rampsd(this : int, ramps : int) -> int:
'''
- Get the current gamma ramps for a CRTC, `double` version.
+ Get the current gamma ramps for a CRTC, `double` version
- @param this The CRTC state.
- @param ramps The gamma ramps to fill with the current values.
+ @param this The CRTC state
+ @param ramps The gamma ramps to fill with the current values
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
cdef size_t ramps_address
- cdef libgamma_crtc_state_t* this_
- cdef libgamma_gamma_rampsd_t* ramps_
+ cdef libgamma_crtc_state_t *this_
+ cdef libgamma_gamma_rampsd_t *ramps_
this_address = <size_t>this
ramps_address = <size_t>ramps
- this_ = <libgamma_crtc_state_t*><void*>this_address
- ramps_ = <libgamma_gamma_rampsd_t*><void*>ramps_address
+ this_ = <libgamma_crtc_state_t *><void *>this_address
+ ramps_ = <libgamma_gamma_rampsd_t *><void *>ramps_address
r = int(libgamma_crtc_get_gamma_rampsd(this_, ramps_))
return int(errno) if r == -1 else r
def libgamma_native_crtc_set_gamma_rampsd(this : int, ramps : int) -> int:
'''
- Set the gamma ramps for a CRTC, `double` version.
+ Set the gamma ramps for a CRTC, `double` version
- @param this The CRTC state.
- @param ramps The gamma ramps to apply.
+ @param this The CRTC state
+ @param ramps The gamma ramps to apply
@return Zero on success, otherwise the value of an error
- identifier provided by this library or `errno`.
+ identifier provided by this library or `errno`
'''
cdef size_t this_address
cdef size_t ramps_address
- cdef libgamma_crtc_state_t* this_
- cdef libgamma_gamma_rampsd_t* ramps_
+ cdef libgamma_crtc_state_t *this_
+ cdef libgamma_gamma_rampsd_t *ramps_
this_address = <size_t>this
ramps_address = <size_t>ramps
- this_ = <libgamma_crtc_state_t*><void*>this_address
- ramps_ = <libgamma_gamma_rampsd_t*><void*>ramps_address
+ this_ = <libgamma_crtc_state_t *><void *>this_address
+ ramps_ = <libgamma_gamma_rampsd_t *><void *>ramps_address
r = int(libgamma_crtc_set_gamma_rampsd(this_, ramps_[0]))
return int(errno) if r == -1 else r
-
diff --git a/src/libgamma_native_method.pyx b/libgamma_native_method.pyx
index 1550caf..96eee7c 100644
--- a/src/libgamma_native_method.pyx
+++ b/libgamma_native_method.pyx
@@ -1,22 +1,5 @@
# -*- python -*-
-'''
-pylibgamma — Python 3 wrapper for libgamma
-Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
-
-This library 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 library 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 library. If not, see <http://www.gnu.org/licenses/>.
-'''
-
+# See LICENSE file for copyright and license details.
cimport cython
from libc.stdint cimport *
@@ -27,239 +10,196 @@ from libc.errno cimport errno
cdef extern from "include-libgamma.h":
ctypedef struct libgamma_gamma_ramps8_t:
- # Gamma ramp structure for 8-bit gamma ramps.
- size_t red_size
- # The size of `red`.
- size_t green_size
- # The size of `green`.
- size_t blue_size
- # The size of `blue`.
- uint8_t* red
- # The gamma ramp for the red channel.
- uint8_t* green
- # The gamma ramp for the green channel.
- uint8_t* blue
- # The gamma ramp for the blue channel.
-
+ # Gamma ramp structure for 8-bit gamma ramps
+ size_t red_size # The size of `red`
+ size_t green_size # The size of `green`
+ size_t blue_size # The size of `blue`
+ uint8_t *red # The gamma ramp for the red channel
+ uint8_t *green # The gamma ramp for the green channel
+ uint8_t *blue # The gamma ramp for the blue channel
+
ctypedef struct libgamma_gamma_ramps16_t:
- # Gamma ramp structure for 16-bit gamma ramps.
- size_t red_size
- # The size of `red`.
- size_t green_size
- # The size of `green`.
- size_t blue_size
- # The size of `blue`.
- uint16_t* red
- # The gamma ramp for the red channel.
- uint16_t* green
- # The gamma ramp for the green channel.
- uint16_t* blue
- # The gamma ramp for the blue channel.
-
+ # Gamma ramp structure for 16-bit gamma ramps
+ size_t red_size # The size of `red`
+ size_t green_size # The size of `green`
+ size_t blue_size # The size of `blue`
+ uint16_t *red # The gamma ramp for the red channel
+ uint16_t *green # The gamma ramp for the green channel
+ uint16_t *blue # The gamma ramp for the blue channel
+
ctypedef struct libgamma_gamma_ramps32_t:
- # Gamma ramp structure for 32-bit gamma ramps.
- size_t red_size
- # The size of `red`.
- size_t green_size
- # The size of `green`.
- size_t blue_size
- # The size of `blue`.
- uint32_t* red
- # The gamma ramp for the red channel.
- uint32_t* green
- # The gamma ramp for the green channel.
- uint32_t* blue
- # The gamma ramp for the blue channel.
-
+ # Gamma ramp structure for 32-bit gamma ramps
+ size_t red_size # The size of `red`
+ size_t green_size # The size of `green`
+ size_t blue_size # The size of `blue`
+ uint32_t *red # The gamma ramp for the red channel
+ uint32_t *green # The gamma ramp for the green channel
+ uint32_t *blue # The gamma ramp for the blue channel
+
ctypedef struct libgamma_gamma_ramps64_t:
- # Gamma ramp structure for 64-bit gamma ramps.
- size_t red_size
- # The size of `red`.
- size_t green_size
- # The size of `green`.
- size_t blue_size
- # The size of `blue`.
- uint64_t* red
- # The gamma ramp for the red channel.
- uint64_t* green
- # The gamma ramp for the green channel.
- uint64_t* blue
- # The gamma ramp for the blue channel.
-
+ # Gamma ramp structure for 64-bit gamma ramps
+ size_t red_size # The size of `red`
+ size_t green_size # The size of `green`
+ size_t blue_size # The size of `blue`
+ uint64_t *red # The gamma ramp for the red channel
+ uint64_t *green # The gamma ramp for the green channel
+ uint64_t *blue # The gamma ramp for the blue channel
+
ctypedef struct libgamma_gamma_rampsf_t:
- # Gamma ramp structure for `float` gamma ramps.
- size_t red_size
- # The size of `red`.
- size_t green_size
- # The size of `green`.
- size_t blue_size
- # The size of `blue`.
- float* red
- # The gamma ramp for the red channel.
- float* green
- # The gamma ramp for the green channel.
- float* blue
- # The gamma ramp for the blue channel.
-
+ # Gamma ramp structure for `float` gamma ramps
+ size_t red_size # The size of `red`
+ size_t green_size # The size of `green`
+ size_t blue_size # The size of `blue`
+ float *red # The gamma ramp for the red channel
+ float *green # The gamma ramp for the green channel
+ float *blue # The gamma ramp for the blue channel
+
ctypedef struct libgamma_gamma_rampsd_t:
- # Gamma ramp structure for `double` gamma ramps.
- size_t red_size
- # The size of `red`.
- size_t green_size
- # The size of `green`.
- size_t blue_size
- # The size of `blue`.
- double* red
- # The gamma ramp for the red channel.
- double* green
- # The gamma ramp for the green channel.
- double* blue
- # The gamma ramp for the blue channel.
-
-
-cdef extern int libgamma_gamma_ramps8_initialise(libgamma_gamma_ramps8_t* this) nogil
+ # Gamma ramp structure for `double` gamma ramps
+ size_t red_size # The size of `red`
+ size_t green_size # The size of `green`
+ size_t blue_size # The size of `blue`
+ double *red # The gamma ramp for the red channel
+ double *green # The gamma ramp for the green channel
+ double *blue # The gamma ramp for the blue channel
+
+cdef extern int libgamma_gamma_ramps8_initialise(libgamma_gamma_ramps8_t *this) nogil
'''
Initialise a gamma ramp in the proper way that allows all adjustment
-methods to read from and write to it without causing segmentation violation.
+methods to read from and write to it without causing segmentation violation
-The input must have `red_size`, `green_size` and `blue_size` set to the
-sizes of the gamma ramps that should be allocated.
+The input must have `red_size`, `green_size` and `blue_size`
+set to the sizes of the gamma ramps that should be allocated
-@param this The gamma ramps.
-@return Zero on success, -1 on allocation error, `errno` will be set accordingly.
+@param this The gamma ramps
+@return Zero on success, -1 on allocation error, `errno` will be set accordingly
'''
-cdef extern void libgamma_gamma_ramps8_free(libgamma_gamma_ramps8_t* this) nogil
+cdef extern void libgamma_gamma_ramps8_free(libgamma_gamma_ramps8_t *this) nogil
'''
Release resources that are held by a gamma ramp strcuture that
-has been allocated by `libgamma_gamma_ramps8_initialise` or otherwise
-initialises in the proper manner, as well as release the pointer
-to the structure.
+has been allocated by `libgamma_gamma_ramps8_initialise` or
+otherwise initialises in the proper manner, as well as release
+the pointer to the structure
-@param this The gamma ramps.
+@param this The gamma ramps
'''
-
-cdef extern int libgamma_gamma_ramps16_initialise(libgamma_gamma_ramps16_t* this) nogil
+cdef extern int libgamma_gamma_ramps16_initialise(libgamma_gamma_ramps16_t *this) nogil
'''
Initialise a gamma ramp in the proper way that allows all adjustment
-methods to read from and write to it without causing segmentation violation.
+methods to read from and write to it without causing segmentation violation
-The input must have `red_size`, `green_size` and `blue_size` set to the
-sizes of the gamma ramps that should be allocated.
+The input must have `red_size`, `green_size` and `blue_size`
+set to the sizes of the gamma ramps that should be allocated
-@param this The gamma ramps.
-@return Zero on success, -1 on allocation error, `errno` will be set accordingly.
+@param this The gamma ramps
+@return Zero on success, -1 on allocation error, `errno` will be set accordingly
'''
-cdef extern void libgamma_gamma_ramps16_free(libgamma_gamma_ramps16_t* this) nogil
+cdef extern void libgamma_gamma_ramps16_free(libgamma_gamma_ramps16_t *this) nogil
'''
Release resources that are held by a gamma ramp strcuture that
-has been allocated by `libgamma_gamma_ramps16_initialise` or otherwise
-initialises in the proper manner, as well as release the pointer
-to the structure.
+has been allocated by `libgamma_gamma_ramps16_initialise` or
+otherwise initialises in the proper manner, as well as release
+the pointer to the structure
-@param this The gamma ramps.
+@param this The gamma ramps
'''
-
-cdef extern int libgamma_gamma_ramps32_initialise(libgamma_gamma_ramps32_t* this) nogil
+cdef extern int libgamma_gamma_ramps32_initialise(libgamma_gamma_ramps32_t *this) nogil
'''
Initialise a gamma ramp in the proper way that allows all adjustment
-methods to read from and write to it without causing segmentation violation.
+methods to read from and write to it without causing segmentation violation
-The input must have `red_size`, `green_size` and `blue_size` set to the
-sizes of the gamma ramps that should be allocated.
+The input must have `red_size`, `green_size` and `blue_size`
+set to the sizes of the gamma ramps that should be allocated
-@param this The gamma ramps.
-@return Zero on success, -1 on allocation error, `errno` will be set accordingly.
+@param this The gamma ramps
+@return Zero on success, -1 on allocation error, `errno` will be set accordingly
'''
-cdef extern void libgamma_gamma_ramps32_free(libgamma_gamma_ramps32_t* this) nogil
+cdef extern void libgamma_gamma_ramps32_free(libgamma_gamma_ramps32_t *this) nogil
'''
Release resources that are held by a gamma ramp strcuture that
-has been allocated by `libgamma_gamma_ramps32_initialise` or otherwise
-initialises in the proper manner, as well as release the pointer
-to the structure.
+has been allocated by `libgamma_gamma_ramps32_initialise` or
+otherwise initialises in the proper manner, as well as release
+the pointer to the structure
-@param this The gamma ramps.
+@param this The gamma ramps
'''
-
-cdef extern int libgamma_gamma_ramps64_initialise(libgamma_gamma_ramps64_t* this) nogil
+cdef extern int libgamma_gamma_ramps64_initialise(libgamma_gamma_ramps64_t *this) nogil
'''
Initialise a gamma ramp in the proper way that allows all adjustment
-methods to read from and write to it without causing segmentation violation.
+methods to read from and write to it without causing segmentation violation
-The input must have `red_size`, `green_size` and `blue_size` set to the
-sizes of the gamma ramps that should be allocated.
+The input must have `red_size`, `green_size` and `blue_size`
+set to the sizes of the gamma ramps that should be allocated
-@param this The gamma ramps.
-@return Zero on success, -1 on allocation error, `errno` will be set accordingly.
+@param this The gamma ramps
+@return Zero on success, -1 on allocation error, `errno` will be set accordingly
'''
-cdef extern void libgamma_gamma_ramps64_free(libgamma_gamma_ramps64_t* this) nogil
+cdef extern void libgamma_gamma_ramps64_free(libgamma_gamma_ramps64_t *this) nogil
'''
Release resources that are held by a gamma ramp strcuture that
-has been allocated by `libgamma_gamma_ramps64_initialise` or otherwise
-initialises in the proper manner, as well as release the pointer
-to the structure.
+has been allocated by `libgamma_gamma_ramps64_initialise` or
+otherwise initialises in the proper manner, as well as release
+the pointer to the structure
-@param this The gamma ramps.
+@param this The gamma ramps
'''
-
-cdef extern int libgamma_gamma_rampsf_initialise(libgamma_gamma_rampsf_t* this) nogil
+cdef extern int libgamma_gamma_rampsf_initialise(libgamma_gamma_rampsf_t *this) nogil
'''
Initialise a gamma ramp in the proper way that allows all adjustment
-methods to read from and write to it without causing segmentation violation.
+methods to read from and write to it without causing segmentation violation
-The input must have `red_size`, `green_size` and `blue_size` set to the
-sizes of the gamma ramps that should be allocated.
+The input must have `red_size`, `green_size` and `blue_size`
+set to the sizes of the gamma ramps that should be allocated
-@param this The gamma ramps.
-@return Zero on success, -1 on allocation error, `errno` will be set accordingly.
+@param this The gamma ramps
+@return Zero on success, -1 on allocation error, `errno` will be set accordingly
'''
-cdef extern void libgamma_gamma_rampsf_free(libgamma_gamma_rampsf_t* this) nogil
+cdef extern void libgamma_gamma_rampsf_free(libgamma_gamma_rampsf_t *this) nogil
'''
Release resources that are held by a gamma ramp strcuture that
-has been allocated by `libgamma_gamma_rampsf_initialise` or otherwise
-initialises in the proper manner, as well as release the pointer
-to the structure.
+has been allocated by `libgamma_gamma_rampsf_initialise` or
+otherwise initialises in the proper manner, as well as release
+the pointer to the structure
-@param this The gamma ramps.
+@param this The gamma ramps
'''
-
-cdef extern int libgamma_gamma_rampsd_initialise(libgamma_gamma_rampsd_t* this) nogil
+cdef extern int libgamma_gamma_rampsd_initialise(libgamma_gamma_rampsd_t *this) nogil
'''
Initialise a gamma ramp in the proper way that allows all adjustment
-methods to read from and write to it without causing segmentation violation.
+methods to read from and write to it without causing segmentation violation
-The input must have `red_size`, `green_size` and `blue_size` set to the
-sizes of the gamma ramps that should be allocated.
+The input must have `red_size`, `green_size` and `blue_size`
+set to the sizes of the gamma ramps that should be allocated
@param this The gamma ramps
-@return Zero on success, -1 on allocation error, `errno` will be set accordingly.
+@return Zero on success, -1 on allocation error, `errno` will be set accordingly
'''
-cdef extern void libgamma_gamma_rampsd_free(libgamma_gamma_rampsd_t* this) nogil
+cdef extern void libgamma_gamma_rampsd_free(libgamma_gamma_rampsd_t *this) nogil
'''
Release resources that are held by a gamma ramp strcuture that
-has been allocated by `libgamma_gamma_rampsd_initialise` or otherwise
-initialises in the proper manner, as well as release the pointer
-to the structure.
+has been allocated by `libgamma_gamma_rampsd_initialise` or
+otherwise initialises in the proper manner, as well as release
+the pointer to the structure
-@param this The gamma ramps.
+@param this The gamma ramps
'''
-
def libgamma_native_gamma_ramps8_create(red_size : int, green_size : int, blue_size : int):
'''
- Create a gamma ramp in the proper way that allows all adjustment
- methods to read from and write to it without causing segmentation violation.
+ Create a gamma ramp in the proper way that allows all adjustment methods
+ to read from and write to it without causing segmentation violation
@param red_size The size of the gamma ramp for the red channel
@param green_size The size of the gamma ramp for the green channel
@@ -270,8 +210,8 @@ def libgamma_native_gamma_ramps8_create(red_size : int, green_size : int, blue_s
Element 3: The address of the gamma ramp for the green channel
Element 4: The address of the gamma ramp for the blue channel
'''
- cdef void* allocation = malloc(sizeof(libgamma_gamma_ramps8_t))
- cdef libgamma_gamma_ramps8_t* item = <libgamma_gamma_ramps8_t*>allocation
+ cdef void *allocation = malloc(sizeof(libgamma_gamma_ramps8_t))
+ cdef libgamma_gamma_ramps8_t *item = <libgamma_gamma_ramps8_t *>allocation
cdef size_t red, green, blue
if item is NULL:
return int(errno)
@@ -280,57 +220,56 @@ def libgamma_native_gamma_ramps8_create(red_size : int, green_size : int, blue_s
item.blue_size = blue_size
if libgamma_gamma_ramps8_initialise(item) < 0:
return int(errno)
- red = <size_t><void*>(item.red)
- green = <size_t><void*>(item.green)
- blue = <size_t><void*>(item.blue)
+ red = <size_t><void *>(item.red)
+ green = <size_t><void *>(item.green)
+ blue = <size_t><void *>(item.blue)
return (int(<size_t>allocation), int(red), int(green), int(blue))
def libgamma_native_gamma_ramps8_free(this : int):
'''
Release resources that are held by a gamma ramp strcuture that
- has been allocated by `libgamma_native_gamma_ramps8_create` or otherwise
- created in the proper manner, as well as release the pointer
- to the structure.
+ has been allocated by `libgamma_native_gamma_ramps8_create` or
+ otherwise created in the proper manner, as well as release the
+ pointer to the structure
- @param this The gamma ramps.
+ @param this The gamma ramps
'''
- cdef void* address = <void*><size_t>this
- cdef libgamma_gamma_ramps8_t* item = <libgamma_gamma_ramps8_t*>address
+ cdef void *address = <void *><size_t>this
+ cdef libgamma_gamma_ramps8_t *item = <libgamma_gamma_ramps8_t *>address
libgamma_gamma_ramps8_free(item)
def libgamma_native_gamma_ramps8_get(this : int, index : int) -> int:
'''
- Read a stop in a gamma ramp.
+ Read a stop in a gamma ramp
- @param this The gamma ramp.
- @param index The index of the gamma ramp stop.
- @return The value of the gamma ramp stop.
+ @param this The gamma ramp
+ @param index The index of the gamma ramp stop
+ @return The value of the gamma ramp stop
'''
- cdef void* address = <void*><size_t>this
- cdef uint8_t* ramp = <uint8_t*>address
+ cdef void *address = <void *><size_t>this
+ cdef uint8_t *ramp = <uint8_t *>address
return int(ramp[<size_t>index])
def libgamma_native_gamma_ramps8_set(this : int, index : int, value : int):
'''
- Modify a stop in a gamma ramp.
+ Modify a stop in a gamma ramp
- @param this The gamma ramp.
- @param index The index of the gamma ramp stop.
- @param value The value of the gamma ramp stop.
+ @param this The gamma ramp
+ @param index The index of the gamma ramp stop
+ @param value The value of the gamma ramp stop
'''
- cdef void* address = <void*><size_t>this
- cdef uint8_t* ramp = <uint8_t*>address
+ cdef void *address = <void *><size_t>this
+ cdef uint8_t *ramp = <uint8_t *>address
ramp[<size_t>index] = <uint8_t>value
-
def libgamma_native_gamma_ramps16_create(red_size : int, green_size : int, blue_size : int):
'''
- Create a gamma ramp in the proper way that allows all adjustment
- methods to read from and write to it without causing segmentation violation.
+ Create a gamma ramp in the proper way that allows all adjustment methods
+ to read from and write to it without causing segmentation violation
@param red_size The size of the gamma ramp for the red channel
@param green_size The size of the gamma ramp for the green channel
@@ -341,8 +280,8 @@ def libgamma_native_gamma_ramps16_create(red_size : int, green_size : int, blue_
Element 3: The address of the gamma ramp for the green channel
Element 4: The address of the gamma ramp for the blue channel
'''
- cdef void* allocation = malloc(sizeof(libgamma_gamma_ramps16_t))
- cdef libgamma_gamma_ramps16_t* item = <libgamma_gamma_ramps16_t*>allocation
+ cdef void *allocation = malloc(sizeof(libgamma_gamma_ramps16_t))
+ cdef libgamma_gamma_ramps16_t *item = <libgamma_gamma_ramps16_t *>allocation
cdef size_t red, green, blue
if item is NULL:
return int(errno)
@@ -351,57 +290,56 @@ def libgamma_native_gamma_ramps16_create(red_size : int, green_size : int, blue_
item.blue_size = blue_size
if libgamma_gamma_ramps16_initialise(item) < 0:
return int(errno)
- red = <size_t><void*>(item.red)
- green = <size_t><void*>(item.green)
- blue = <size_t><void*>(item.blue)
+ red = <size_t><void *>(item.red)
+ green = <size_t><void *>(item.green)
+ blue = <size_t><void *>(item.blue)
return (int(<size_t>allocation), int(red), int(green), int(blue))
def libgamma_native_gamma_ramps16_free(this : int):
'''
Release resources that are held by a gamma ramp strcuture that
- has been allocated by `libgamma_native_gamma_ramps16_create` or otherwise
- created in the proper manner, as well as release the pointer
- to the structure.
+ has been allocated by `libgamma_native_gamma_ramps16_create` or
+ otherwise created in the proper manner, as well as release the
+ pointer to the structure
- @param this The gamma ramps.
+ @param this The gamma ramps
'''
- cdef void* address = <void*><size_t>this
- cdef libgamma_gamma_ramps16_t* item = <libgamma_gamma_ramps16_t*>address
+ cdef void *address = <void*><size_t>this
+ cdef libgamma_gamma_ramps16_t *item = <libgamma_gamma_ramps16_t *>address
libgamma_gamma_ramps16_free(item)
def libgamma_native_gamma_ramps16_get(this : int, index : int) -> int:
'''
- Read a stop in a gamma ramp.
+ Read a stop in a gamma ramp
- @param this The gamma ramp.
- @param index The index of the gamma ramp stop.
- @return The value of the gamma ramp stop.
+ @param this The gamma ramp
+ @param index The index of the gamma ramp stop
+ @return The value of the gamma ramp stop
'''
- cdef void* address = <void*><size_t>this
- cdef uint16_t* ramp = <uint16_t*>address
+ cdef void *address = <void *><size_t>this
+ cdef uint16_t *ramp = <uint16_t *>address
return int(ramp[<size_t>index])
def libgamma_native_gamma_ramps16_set(this : int, index : int, value : int):
'''
- Modify a stop in a gamma ramp.
+ Modify a stop in a gamma ramp
- @param this The gamma ramp.
- @param index The index of the gamma ramp stop.
- @param value The value of the gamma ramp stop.
+ @param this The gamma ramp
+ @param index The index of the gamma ramp stop
+ @param value The value of the gamma ramp stop
'''
- cdef void* address = <void*><size_t>this
- cdef uint16_t* ramp = <uint16_t*>address
+ cdef void *address = <void *><size_t>this
+ cdef uint16_t *ramp = <uint16_t *>address
ramp[<size_t>index] = <uint16_t>value
-
def libgamma_native_gamma_ramps32_create(red_size : int, green_size : int, blue_size : int):
'''
- Create a gamma ramp in the proper way that allows all adjustment
- methods to read from and write to it without causing segmentation violation.
+ Create a gamma ramp in the proper way that allows all adjustment methods
+ to read from and write to it without causing segmentation violation
@param red_size The size of the gamma ramp for the red channel
@param green_size The size of the gamma ramp for the green channel
@@ -412,8 +350,8 @@ def libgamma_native_gamma_ramps32_create(red_size : int, green_size : int, blue_
Element 3: The address of the gamma ramp for the green channel
Element 4: The address of the gamma ramp for the blue channel
'''
- cdef void* allocation = malloc(sizeof(libgamma_gamma_ramps32_t))
- cdef libgamma_gamma_ramps32_t* item = <libgamma_gamma_ramps32_t*>allocation
+ cdef void *allocation = malloc(sizeof(libgamma_gamma_ramps32_t))
+ cdef libgamma_gamma_ramps32_t *item = <libgamma_gamma_ramps32_t *>allocation
cdef size_t red, green, blue
if item is NULL:
return int(errno)
@@ -422,57 +360,56 @@ def libgamma_native_gamma_ramps32_create(red_size : int, green_size : int, blue_
item.blue_size = blue_size
if libgamma_gamma_ramps32_initialise(item) < 0:
return int(errno)
- red = <size_t><void*>(item.red)
- green = <size_t><void*>(item.green)
- blue = <size_t><void*>(item.blue)
+ red = <size_t><void *>(item.red)
+ green = <size_t><void *>(item.green)
+ blue = <size_t><void *>(item.blue)
return (int(<size_t>allocation), int(red), int(green), int(blue))
def libgamma_native_gamma_ramps32_free(this : int):
'''
Release resources that are held by a gamma ramp strcuture that
- has been allocated by `libgamma_native_gamma_ramps32_create` or otherwise
- created in the proper manner, as well as release the pointer
- to the structure.
+ has been allocated by `libgamma_native_gamma_ramps32_create` or
+ otherwise created in the proper manner, as well as release the
+ pointer to the structure
- @param this The gamma ramps.
+ @param this The gamma ramps
'''
- cdef void* address = <void*><size_t>this
- cdef libgamma_gamma_ramps32_t* item = <libgamma_gamma_ramps32_t*>address
+ cdef void *address = <void *><size_t>this
+ cdef libgamma_gamma_ramps32_t *item = <libgamma_gamma_ramps32_t *>address
libgamma_gamma_ramps32_free(item)
def libgamma_native_gamma_ramps32_get(this : int, index : int) -> int:
'''
- Read a stop in a gamma ramp.
+ Read a stop in a gamma ramp
- @param this The gamma ramp.
- @param index The index of the gamma ramp stop.
- @return The value of the gamma ramp stop.
+ @param this The gamma ramp
+ @param index The index of the gamma ramp stop
+ @return The value of the gamma ramp stop
'''
- cdef void* address = <void*><size_t>this
- cdef uint32_t* ramp = <uint32_t*>address
+ cdef void *address = <void *><size_t>this
+ cdef uint32_t *ramp = <uint32_t *>address
return int(ramp[<size_t>index])
def libgamma_native_gamma_ramps32_set(this : int, index : int, value : int):
'''
- Modify a stop in a gamma ramp.
+ Modify a stop in a gamma ramp
- @param this The gamma ramp.
- @param index The index of the gamma ramp stop.
- @param value The value of the gamma ramp stop.
+ @param this The gamma ramp
+ @param index The index of the gamma ramp stop
+ @param value The value of the gamma ramp stop
'''
- cdef void* address = <void*><size_t>this
- cdef uint32_t* ramp = <uint32_t*>address
+ cdef void *address = <void*><size_t>this
+ cdef uint32_t *ramp = <uint32_t *>address
ramp[<size_t>index] = <uint32_t>value
-
def libgamma_native_gamma_ramps64_create(red_size : int, green_size : int, blue_size : int):
'''
- Create a gamma ramp in the proper way that allows all adjustment
- methods to read from and write to it without causing segmentation violation.
+ Create a gamma ramp in the proper way that allows all adjustment methods
+ to read from and write to it without causing segmentation violation
@param red_size The size of the gamma ramp for the red channel
@param green_size The size of the gamma ramp for the green channel
@@ -483,8 +420,8 @@ def libgamma_native_gamma_ramps64_create(red_size : int, green_size : int, blue_
Element 3: The address of the gamma ramp for the green channel
Element 4: The address of the gamma ramp for the blue channel
'''
- cdef void* allocation = malloc(sizeof(libgamma_gamma_ramps64_t))
- cdef libgamma_gamma_ramps64_t* item = <libgamma_gamma_ramps64_t*>allocation
+ cdef void *allocation = malloc(sizeof(libgamma_gamma_ramps64_t))
+ cdef libgamma_gamma_ramps64_t *item = <libgamma_gamma_ramps64_t *>allocation
cdef size_t red, green, blue
if item is NULL:
return int(errno)
@@ -493,57 +430,56 @@ def libgamma_native_gamma_ramps64_create(red_size : int, green_size : int, blue_
item.blue_size = blue_size
if libgamma_gamma_ramps64_initialise(item) < 0:
return int(errno)
- red = <size_t><void*>(item.red)
- green = <size_t><void*>(item.green)
- blue = <size_t><void*>(item.blue)
+ red = <size_t><void *>(item.red)
+ green = <size_t><void *>(item.green)
+ blue = <size_t><void *>(item.blue)
return (int(<size_t>allocation), int(red), int(green), int(blue))
def libgamma_native_gamma_ramps64_free(this : int):
'''
Release resources that are held by a gamma ramp strcuture that
- has been allocated by `libgamma_native_gamma_ramps64_create` or otherwise
- created in the proper manner, as well as release the pointer
- to the structure.
+ has been allocated by `libgamma_native_gamma_ramps64_create` or
+ otherwise created in the proper manner, as well as release the
+ pointer to the structure
- @param this The gamma ramps.
+ @param this The gamma ramps
'''
- cdef void* address = <void*><size_t>this
- cdef libgamma_gamma_ramps64_t* item = <libgamma_gamma_ramps64_t*>address
+ cdef void *address = <void *><size_t>this
+ cdef libgamma_gamma_ramps64_t *item = <libgamma_gamma_ramps64_t *>address
libgamma_gamma_ramps64_free(item)
def libgamma_native_gamma_ramps64_get(this : int, index : int) -> int:
'''
- Read a stop in a gamma ramp.
+ Read a stop in a gamma ramp
- @param this The gamma ramp.
- @param index The index of the gamma ramp stop.
- @return The value of the gamma ramp stop.
+ @param this The gamma ramp
+ @param index The index of the gamma ramp stop
+ @return The value of the gamma ramp stop
'''
- cdef void* address = <void*><size_t>this
- cdef uint64_t* ramp = <uint64_t*>address
+ cdef void *address = <void *><size_t>this
+ cdef uint64_t *ramp = <uint64_t *>address
return int(ramp[<size_t>index])
def libgamma_native_gamma_ramps64_set(this : int, index : int, value : int):
'''
- Modify a stop in a gamma ramp.
+ Modify a stop in a gamma ramp
- @param this The gamma ramp.
- @param index The index of the gamma ramp stop.
- @param value The value of the gamma ramp stop.
+ @param this The gamma ramp
+ @param index The index of the gamma ramp stop
+ @param value The value of the gamma ramp stop
'''
- cdef void* address = <void*><size_t>this
- cdef uint64_t* ramp = <uint64_t*>address
+ cdef void *address = <void *><size_t>this
+ cdef uint64_t *ramp = <uint64_t *>address
ramp[<size_t>index] = <uint64_t>value
-
def libgamma_native_gamma_rampsf_create(red_size : int, green_size : int, blue_size : int):
'''
- Create a gamma ramp in the proper way that allows all adjustment
- methods to read from and write to it without causing segmentation violation.
+ Create a gamma ramp in the proper way that allows all adjustment methods
+ to read from and write to it without causing segmentation violation
@param red_size The size of the gamma ramp for the red channel
@param green_size The size of the gamma ramp for the green channel
@@ -554,8 +490,8 @@ def libgamma_native_gamma_rampsf_create(red_size : int, green_size : int, blue_s
Element 3: The address of the gamma ramp for the green channel
Element 4: The address of the gamma ramp for the blue channel
'''
- cdef void* allocation = malloc(sizeof(libgamma_gamma_rampsf_t))
- cdef libgamma_gamma_rampsf_t* item = <libgamma_gamma_rampsf_t*>allocation
+ cdef void *allocation = malloc(sizeof(libgamma_gamma_rampsf_t))
+ cdef libgamma_gamma_rampsf_t *item = <libgamma_gamma_rampsf_t *>allocation
cdef size_t red, green, blue
if item is NULL:
return int(errno)
@@ -564,57 +500,56 @@ def libgamma_native_gamma_rampsf_create(red_size : int, green_size : int, blue_s
item.blue_size = blue_size
if libgamma_gamma_rampsf_initialise(item) < 0:
return int(errno)
- red = <size_t><void*>(item.red)
- green = <size_t><void*>(item.green)
- blue = <size_t><void*>(item.blue)
+ red = <size_t><void *>(item.red)
+ green = <size_t><void *>(item.green)
+ blue = <size_t><void *>(item.blue)
return (int(<size_t>allocation), int(red), int(green), int(blue))
def libgamma_native_gamma_rampsf_free(this : int):
'''
Release resources that are held by a gamma ramp strcuture that
- has been allocated by `libgamma_native_gamma_rampsf_create` or otherwise
- created in the proper manner, as well as release the pointer
- to the structure.
+ has been allocated by `libgamma_native_gamma_rampsf_create` or
+ otherwise created in the proper manner, as well as release the
+ pointer to the structure
- @param this The gamma ramps.
+ @param this The gamma ramps
'''
- cdef void* address = <void*><size_t>this
- cdef libgamma_gamma_rampsf_t* item = <libgamma_gamma_rampsf_t*>address
+ cdef void *address = <void *><size_t>this
+ cdef libgamma_gamma_rampsf_t *item = <libgamma_gamma_rampsf_t *>address
libgamma_gamma_rampsf_free(item)
def libgamma_native_gamma_rampsf_get(this : int, index : int) -> float:
'''
- Read a stop in a gamma ramp.
+ Read a stop in a gamma ramp
- @param this The gamma ramp.
- @param index The index of the gamma ramp stop.
- @return The value of the gamma ramp stop.
+ @param this The gamma ramp
+ @param index The index of the gamma ramp stop
+ @return The value of the gamma ramp stop
'''
- cdef void* address = <void*><size_t>this
- cdef float* ramp = <float*>address
+ cdef void *address = <void *><size_t>this
+ cdef float *ramp = <float *>address
return float(ramp[<size_t>index])
def libgamma_native_gamma_rampsf_set(this : int, index : int, value : float):
'''
- Modify a stop in a gamma ramp.
+ Modify a stop in a gamma ramp
- @param this The gamma ramp.
- @param index The index of the gamma ramp stop.
- @param value The value of the gamma ramp stop.
+ @param this The gamma ramp
+ @param index The index of the gamma ramp stop
+ @param value The value of the gamma ramp stop
'''
- cdef void* address = <void*><size_t>this
- cdef float* ramp = <float*>address
+ cdef void *address = <void *><size_t>this
+ cdef float *ramp = <float *>address
ramp[<size_t>index] = <float>value
-
def libgamma_native_gamma_rampsd_create(red_size : int, green_size : int, blue_size : int):
'''
Create a gamma ramp in the proper way that allows all adjustment
- methods to read from and write to it without causing segmentation violation.
+ methods to read from and write to it without causing segmentation violation
@param red_size The size of the gamma ramp for the red channel
@param green_size The size of the gamma ramp for the green channel
@@ -625,8 +560,8 @@ def libgamma_native_gamma_rampsd_create(red_size : int, green_size : int, blue_s
Element 3: The address of the gamma ramp for the green channel
Element 4: The address of the gamma ramp for the blue channel
'''
- cdef void* allocation = malloc(sizeof(libgamma_gamma_rampsd_t))
- cdef libgamma_gamma_rampsd_t* item = <libgamma_gamma_rampsd_t*>allocation
+ cdef void *allocation = malloc(sizeof(libgamma_gamma_rampsd_t))
+ cdef libgamma_gamma_rampsd_t *item = <libgamma_gamma_rampsd_t *>allocation
cdef size_t red, green, blue
if item is NULL:
return int(errno)
@@ -635,48 +570,47 @@ def libgamma_native_gamma_rampsd_create(red_size : int, green_size : int, blue_s
item.blue_size = blue_size
if libgamma_gamma_rampsd_initialise(item) < 0:
return int(errno)
- red = <size_t><void*>(item.red)
- green = <size_t><void*>(item.green)
- blue = <size_t><void*>(item.blue)
+ red = <size_t><void *>(item.red)
+ green = <size_t><void *>(item.green)
+ blue = <size_t><void *>(item.blue)
return (int(<size_t>allocation), int(red), int(green), int(blue))
def libgamma_native_gamma_rampsd_free(this : int):
'''
Release resources that are held by a gamma ramp strcuture that
- has been allocated by `libgamma_native_gamma_rampsd_create` or otherwise
- created in the proper manner, as well as release the pointer
- to the structure.
+ has been allocated by `libgamma_native_gamma_rampsd_create` or
+ otherwise created in the proper manner, as well as release the
+ pointer to the structure
- @param this The gamma ramps.
+ @param this The gamma ramps
'''
- cdef void* address = <void*><size_t>this
- cdef libgamma_gamma_rampsd_t* item = <libgamma_gamma_rampsd_t*>address
+ cdef void *address = <void *><size_t>this
+ cdef libgamma_gamma_rampsd_t *item = <libgamma_gamma_rampsd_t *>address
libgamma_gamma_rampsd_free(item)
def libgamma_native_gamma_rampsd_get(this : int, index : int) -> float:
'''
- Read a stop in a gamma ramp.
+ Read a stop in a gamma ramp
- @param this The gamma ramp.
- @param index The index of the gamma ramp stop.
- @return The value of the gamma ramp stop.
+ @param this The gamma ramp
+ @param index The index of the gamma ramp stop
+ @return The value of the gamma ramp stop
'''
- cdef void* address = <void*><size_t>this
- cdef double* ramp = <double*>address
+ cdef void *address = <void *><size_t>this
+ cdef double *ramp = <double *>address
return float(ramp[<size_t>index])
def libgamma_native_gamma_rampsd_set(this : int, index : int, value : float):
'''
- Modify a stop in a gamma ramp.
+ Modify a stop in a gamma ramp
- @param this The gamma ramp.
- @param index The index of the gamma ramp stop.
- @param value The value of the gamma ramp stop.
+ @param this The gamma ramp
+ @param index The index of the gamma ramp stop
+ @param value The value of the gamma ramp stop
'''
- cdef void* address = <void*><size_t>this
- cdef double* ramp = <double*>address
+ cdef void *address = <void *><size_t>this
+ cdef double *ramp = <double *>address
ramp[<size_t>index] = <double>value
-
diff --git a/mk/linux.mk b/mk/linux.mk
new file mode 100644
index 0000000..818e2e1
--- /dev/null
+++ b/mk/linux.mk
@@ -0,0 +1,2 @@
+PLATFORM = posix
+LIBEXT = so
diff --git a/mk/macos.mk b/mk/macos.mk
new file mode 100644
index 0000000..35caab1
--- /dev/null
+++ b/mk/macos.mk
@@ -0,0 +1,2 @@
+PLATFORM = posix
+LIBEXT = dylib
diff --git a/mk/windows.mk b/mk/windows.mk
new file mode 100644
index 0000000..8489de6
--- /dev/null
+++ b/mk/windows.mk
@@ -0,0 +1,2 @@
+PLATFORM = w32
+LIBEXT = dll
diff --git a/src/include-libgamma.h b/src/include-libgamma.h
deleted file mode 100644
index eb857e1..0000000
--- a/src/include-libgamma.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * pylibgamma — Python 3 wrapper for libgamma
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library 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 library 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 library. If not, see <http://www.gnu.org/licenses/>.
- */
-#include <libgamma.h>
-
diff --git a/src/libgamma.py b/src/libgamma.py
deleted file mode 100644
index 34c646c..0000000
--- a/src/libgamma.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# -*- python -*-
-'''
-pylibgamma — Python 3 wrapper for libgamma
-Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
-
-This library 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 library 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 library. If not, see <http://www.gnu.org/licenses/>.
-'''
-
-from libgamma_error import *
-from libgamma_method import *
-from libgamma_facade import *
-
diff --git a/src/test.py b/test.py
index 58ed78e..5286c07 100755
--- a/src/test.py
+++ b/test.py
@@ -1,23 +1,5 @@
#!/usr/bin/env python3
-# -*- python -*-
-'''
-pylibgamma — Python 3 wrapper for libgamma
-Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
-
-This library 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 library 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 library. If not, see <http://www.gnu.org/licenses/>.
-'''
-
+# See LICENSE file for copyright and license details.
import libgamma
from time import sleep
@@ -121,4 +103,3 @@ del site
del partition
del crtc
del ramps
-