commit 374e32e5b83d8287950b409a3675de60f45c38da Author: davemds Date: Wed Aug 27 21:38:08 2014 +0200 Say welcome to Edgar, the python gadget loader. You can now write E gadgets in python. ...python rocks !! diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..cfe26f0 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Dave 'MDS' Andreoli diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/COPYING.LESSER b/COPYING.LESSER new file mode 100644 index 0000000..1604322 --- /dev/null +++ b/COPYING.LESSER @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..e69de29 diff --git a/GADGETS/audio/Makefile b/GADGETS/audio/Makefile new file mode 100644 index 0000000..8cee017 --- /dev/null +++ b/GADGETS/audio/Makefile @@ -0,0 +1,36 @@ +# Simple Makefile for Enlightenment (edgar) gadgets + +# gadget specific config +GADGET_NAME = audio +EXTRA_FILES = + + +# nothing should be changed below this point +GADGET_FILES = __init__.pyc $(GADGET_NAME).edj +prefix = $(shell pkg-config --variable=libdir enlightenment) +gadget_folder = ${prefix}/enlightenment/gadgets/$(GADGET_NAME) + +.PHONY: all install clean + +all: $(GADGET_FILES) $(EXTRA_FILES) + +install: all + @mkdir -p -v ${gadget_folder} + @cp --preserve=mode -v $(GADGET_FILES) $(EXTRA_FILES) $(gadget_folder) + +uninstall: all + @rm -rfv ${gadget_folder} + +clean: + @rm -fv $(GADGET_NAME).edj + + +EDJE_CC = edje_cc +EDJE_FLAGS = -v -id images/ -fd fonts/ + +%.edj: %.edc images/* + $(EDJE_CC) $(EDJE_FLAGS) $< + @chmod -v og+r $@ + +%.pyc: %.py + python3 -c "from py_compile import compile; compile('$<', '$@')" diff --git a/GADGETS/audio/__init__.py b/GADGETS/audio/__init__.py new file mode 100644 index 0000000..8b1c031 --- /dev/null +++ b/GADGETS/audio/__init__.py @@ -0,0 +1,508 @@ +# This python file use the following encoding: utf-8 + +import os +import sys +import dbus +from urllib.parse import unquote as url_unquote + +import e + +from efl import ecore +from efl import evas +from efl import edje +from efl.dbus_mainloop import DBusEcoreMainLoop +from efl.elementary.icon import Icon +from efl.elementary.label import Label +from efl.elementary.slider import Slider + + +def DBG(*args): + print(*args) + sys.stdout.flush() + + +_instance = None + + +class Gadget(e.Gadget): + + __gadget_name__ = 'Audio' + __gadget_vers__ = '0.1' + __gadget_auth__ = 'DaveMDS' + __gadget_mail__ = 'dave@gurumeditation.it' + __gadget_desc__ = 'The complete audio gadget.' + __gadget_vapi__ = 1 + + def __init__(self): + global _instance + _instance = self + + super().__init__() + + self.player_objs = {} # key: "player name" val: (list of edje objs) + self.channel_objs = {} # key: Channel instance val: (list of elm Slider) + + self.mpris = Mpris2_Client() + self.pulse = PulseAudio_Client() + + def instance_created(self, obj, site): + super().instance_created(obj, site) + + obj.signal_callback_add('mouse,down,2', 'over', self.speaker_click_cb) + obj.signal_callback_add('mouse,wheel,*', 'over', self.speaker_wheel_cb) + self.speaker_update(obj) + + def instance_destroyed(self, obj): + super().instance_destroyed(obj) + + def speaker_click_cb(self, obj, sig, source): + ch = self.pulse.channels[0] + ch.mute_toggle() + + def speaker_update(self, speaker): + if self.pulse and len(self.pulse.channels) > 0: + ch = self.pulse.channels[0] + left = right = ch.volume / 655 + speaker.message_send(0, (ch.muted, left, right)) + + def speaker_wheel_cb(self, obj, sig, source): + ch = self.pulse.channels[0] + vol = ch.volume + if sig == 'mouse,wheel,0,1': + new_vol = vol - 3000 + elif sig == 'mouse,wheel,0,-1': + new_vol = vol + 3000 + else: + return + ch.volume_set(min(max(0, new_vol), 65500)) + + def popup_created(self, popup): + super().popup_created(popup) + + # add all the available players to the popup edje box + for player in self.mpris.players: + self.popup_player_add(popup, player) + + # add all the channel sliders + if self.pulse.conn is not None: + for ch in self.pulse.channels: + self.popup_volume_add(popup, ch) + else: + lb = Label(popup, text='Cannot connect to PulseAudio') + lb.show() + popup.part_box_append('volumes.box', lb) + + def popup_destroyed(self, popup): + super().popup_destroyed(popup) + + while True: + # pop an item from the players box + obj = popup.part_box_remove_at('players.box', 0) + if obj is None: break + + # remove the obj from our lists + for name, objs in self.player_objs.items(): + while obj in objs: objs.remove(obj) + + # delete the cover image + cover = obj.part_swallow_get('cover.swallow') + if cover: cover.delete() + + # and finally delete the player edje obj + obj.delete() + + def popup_player_add(self, popup, player): + # create the edje obj for this player from 'e/gadgets/audio/player' + o = edje.Edje(popup.evas, update_hints=True) + e.theme_edje_object_set(o, 'audio', 'player') + o.size_hint_min = o.size_min + + o.signal_callback_add('act,play', '', lambda o,sig,src: player.play()) + o.signal_callback_add('act,prev', '', lambda o,sig,src: player.prev()) + o.signal_callback_add('act,next', '', lambda o,sig,src: player.next()) + o.signal_callback_add('act,rais', '', lambda o,sig,src: player.rais()) + + self.player_update(o, player) + o.show() + + # insert the player in the popup box + popup.part_box_append('players.box', o) + + # keep track of this obj in the player_objs dict + if not player in self.player_objs: + self.player_objs[player] = [] + self.player_objs[player].append(o) + + def player_changed(self, player): + # the mpris player has changed, update all the relative edje objects + for o in self.player_objs.get(player, []): + self.player_update(o, player) + + def player_update(self, obj, player): + # player name + obj.part_text_set('player_name', player.label or player.name) + + # play/pause button + if player.playback_status == 'Playing': + obj.signal_emit('state,set,playing', '') + else: + obj.signal_emit('state,set,paused', '') + + # metadata + txt = '' + if 'xesam:title' in player.metadata: + txt += '%s</><br>' % player.metadata['xesam:title'] + if 'xesam:artist' in player.metadata: + txt += '<tag>by</> %s<br>' % player.metadata['xesam:artist'][0] + if 'xesam:album' in player.metadata: + txt += '<tag>from</> %s<br>' % player.metadata['xesam:album'] + obj.part_text_set('metadata', txt) + + # cover image + img = obj.part_swallow_get('cover.swallow') + if img: img.delete() + + if 'mpris:artUrl' in player.metadata: + fname = url_unquote(player.metadata['mpris:artUrl']) + fname = fname.replace('file://', '') + try: + img = evas.FilledImage(obj.evas, file=fname) + obj.part_swallow('cover.swallow', img) + except: + pass + + def popup_volume_add(self, popup, channel): + sl = Slider(popup, text=channel.name, min_max=(0, 65500), + size_hint_align=(evas.EVAS_HINT_FILL, 0.0)) + sl.value = channel.volume + sl.disabled = True if channel.muted else False + sl.callback_changed_add(self.popup_slider_changed_cb, channel) + sl.callback_slider_drag_start_add(self.popup_slider_drag_start_cb) + sl.callback_slider_drag_stop_add(self.popup_slider_drag_stop_cb) + sl.event_callback_add(evas.EVAS_CALLBACK_MOUSE_DOWN, + self.popup_slider_click_cb, channel) + sl.show() + + # insert the slider in the popup box + popup.part_box_prepend('volumes.box', sl) + # popup.calc_force() + + # keep track of this obj in the channel_objs dict + if not channel in self.channel_objs: + self.channel_objs[channel] = [] + self.channel_objs[channel].append(sl) + + def popup_slider_changed_cb(self, slider, channel): + channel.volume_set(slider.value) + + def popup_slider_click_cb(self, slider, event, channel): + if event.button == 2: + channel.mute_toggle() + + def popup_slider_drag_start_cb(self, slider): + slider.data['dragging'] = True + + def popup_slider_drag_stop_cb(self, slider): + del slider.data['dragging'] + + def volume_changed(self, channel): + # update all the sliders (except the one currently dragged) + if channel in self.channel_objs: + for sl in self.channel_objs[channel]: + if not 'dragging' in sl.data: + sl.value = channel.volume + # update all the speakers + for speaker in self._instances: + self.speaker_update(speaker) + + def mute_changed(self, channel): + # update all the sliders and the speakers + if channel in self.channel_objs: + for sl in self.channel_objs[channel]: + sl.disabled = True if channel.muted else False + for speaker in self._instances: + self.speaker_update(speaker) + + def channel_added(self, channel): + for popup in self._popups: + self.popup_volume_add(popup, channel) + + def channel_removed(self, channel): + if channel in self.channel_objs: + for sl in self.channel_objs[channel]: + sl.delete() + del self.channel_objs[channel][:] + del self.channel_objs[channel] + + +class Mpris2_Client(object): + BASE_PATH = 'org.mpris.MediaPlayer2.' + + def __init__ (self): + self.players = [] + self.bus = dbus.SessionBus(mainloop=DBusEcoreMainLoop()) + + # update the players list + self.update_players_list() + # and keep the list updated when names changes + self.sig1 = self.bus.add_signal_receiver(self.name_owner_changed_cb, + "NameOwnerChanged") + + def name_owner_changed_cb(self, name, old_owner, new_owner): + if name.startswith(self.BASE_PATH): + self.update_players_list() + + def update_players_list(self): + names = [ n for n in self.bus.list_names() if n.startswith(self.BASE_PATH) ] + del self.players[:] + for name in names: + self.players.append(Mpris2_Player(self.bus, name[len(self.BASE_PATH):])) + + +class Mpris2_Player(object): + MAIN_IFACE = 'org.mpris.MediaPlayer2' + PLAYER_IFACE = 'org.mpris.MediaPlayer2.Player' + + def __init__(self, bus, name): + self.name = name + self.label = None + self.metadata = None # metadata dict as per mpris2 specs + self.playback_status = 'Stopped' # or 'Playing' or 'Paused' + self.volume = 0.0 # range: 0.0 - 1.0 + + self.proxy = bus.get_object('org.mpris.MediaPlayer2.%s' % name, + '/org/mpris/MediaPlayer2') + + # self.prop_iface.GetAll(...) + self.prop_iface = dbus.Interface(self.proxy, dbus_interface=dbus.PROPERTIES_IFACE) + self.prop_iface.connect_to_signal('PropertiesChanged', self.props_changed_cb) + self.metadata = self.prop_iface.Get(self.PLAYER_IFACE, 'Metadata') + self.playback_status = self.prop_iface.Get(self.PLAYER_IFACE, 'PlaybackStatus') + self.volume = self.prop_iface.Get(self.PLAYER_IFACE, 'Volume') + self.label = self.prop_iface.Get(self.MAIN_IFACE, 'Identity') + + def props_changed_cb(self, iface, props, invalidated): + if 'Metadata' in props: + self.metadata = props.get('Metadata') + if 'PlaybackStatus' in props: + self.playback_status = props.get('PlaybackStatus') + if 'Volume' in props: + self.volume = props.get('Volume') + + _instance.player_changed(self) + + def play(self): + self.proxy.PlayPause(dbus_interface=self.PLAYER_IFACE) + + def next(self): + self.proxy.Next(dbus_interface=self.PLAYER_IFACE) + + def prev(self): + self.proxy.Previous(dbus_interface=self.PLAYER_IFACE) + + def rais(self): + self.proxy.Raise(dbus_interface=self.MAIN_IFACE) + + +class AudioChannel(object): + def __init__(self, obj, iface, name, volume, muted): + self.obj = obj + self.iface = iface + self.name = name + self.volume = int(volume[0]) + self.muted = muted + + # This do not work, only connection on the main pulse obj work... + # so for the moment dispatch the callback from there + # obj.connect_to_signal('VolumeUpdated', self.volume_changed_signal_cb) + + def volume_set(self, value): + self.volume = value + self.obj.Set(self.iface, 'Volume', [dbus.UInt32(value)], + dbus_interface=dbus.PROPERTIES_IFACE) + + def mute_toggle(self): + self.muted = not self.muted + self.obj.Set(self.iface, 'Mute', self.muted, + dbus_interface=dbus.PROPERTIES_IFACE) + + def volume_changed_signal_cb(self, volume): + self.volume = int(volume[0]) + _instance.volume_changed(self) + + def mute_changed_signal_cb(self, muted): + self.muted = muted + _instance.mute_changed(self) + + def __str__(self): + return '[%s]: "%s" volume: %s' % \ + (self.iface.split('.')[-1], self.name, self.volume[:]) + + +class PulseAudio_Client(object): + PULSE_OBJ = '/org/pulseaudio/core1' + PULSE_IFACE = 'org.PulseAudio.Core1' + STREAM_IFACE = 'org.PulseAudio.Core1.Stream' + DEVICE_IFACE = 'org.PulseAudio.Core1.Device' + + def __init__ (self): + self.conn = None + self.srv_addr = None + self.channels = [] + + self.try_to_connect() + + def try_to_connect(self): + if self.connect() is False: + ecore.Timer(5.0, self.try_to_connect) + return ecore.ECORE_CALLBACK_CANCEL + + def connect(self): + self.srv_addr = self.address_lookup() + if self.srv_addr is None: + # TODO maybe try to start pulse here + return False + try: + self.conn = dbus.connection.Connection(self.srv_addr, + mainloop=DBusEcoreMainLoop()) + except: + return False + + # get all available channels + self.all_channels_add() + # and listen for channels added/removed + pulse = self.conn.get_object(object_path=self.PULSE_OBJ) + for sig in ('NewSink', 'SinkRemoved', + 'NewPlaybackStream', 'PlaybackStreamRemoved'): + pulse.ListenForSignal('org.PulseAudio.Core1.' + sig, + dbus.Array(signature='o')) + self.conn.add_signal_receiver(self.channel_signal_cb, sig, + member_keyword='signal') + # also enable volume/mute signal from pulse + for sig in ('Device.VolumeUpdated', 'Device.MuteUpdated', + 'Stream.VolumeUpdated', 'Stream.MuteUpdated'): + pulse.ListenForSignal('org.PulseAudio.Core1.' + sig, + dbus.Array(signature='o')) + # this should be connected per-object, in the Channel class... + for sig in ('VolumeUpdated', 'MuteUpdated'): + self.conn.add_signal_receiver(self.volume_signal_cb, sig, + member_keyword='signal', + path_keyword='obj_path') + return True + + def channel_signal_cb(self, *args, signal): + obj_path = args[0] + if signal == 'NewSink': + ch = self.sink_add(obj_path) + if ch: _instance.channel_added(ch) + elif signal == 'NewPlaybackStream': + ch = self.stream_add(obj_path) + if ch: _instance.channel_added(ch) + elif signal in ('SinkRemoved', 'PlaybackStreamRemoved'): + for ch in self.channels: + if ch.obj.object_path == obj_path: + _instance.channel_removed(ch) + self.channels.remove(ch) + del ch + + def volume_signal_cb(self, *args, signal, obj_path): + # dispatch to the correct Channel instance + for ch in self.channels: + if ch.obj.object_path == obj_path: + if signal == 'VolumeUpdated': + ch.volume_changed_signal_cb(*args) + elif signal == 'MuteUpdated': + ch.mute_changed_signal_cb(*args) + break + + def address_lookup(self): + """ Search the address of the pulse dbus socket """ + # 1. try the environment var + addr = os.environ.get('PULSE_DBUS_SERVER') + if addr: return addr + + # 2. well-known system-wide daemon socket + if os.access('/run/pulse/dbus-socket', os.R_OK | os.W_OK): + return 'unix:path=/run/pulse/dbus-socket' + + # 3. dbus lookup on the SessionBus + try: + bus = dbus.SessionBus() + obj = bus.get_object('org.PulseAudio1', '/org/pulseaudio/server_lookup1') + return obj.Get('org.PulseAudio.ServerLookup1', 'Address', + dbus_interface=dbus.PROPERTIES_IFACE) + except: + return None + + def _fuckyoupulse(self, ay): + return ''.join([ chr(byte) for byte in ay ]) + + def all_channels_add(self): + obj = self.conn.get_object(self.PULSE_IFACE, self.PULSE_OBJ) + + sinks = obj.Get(self.PULSE_IFACE, 'Sinks', + dbus_interface=dbus.PROPERTIES_IFACE) + streams = obj.Get(self.PULSE_IFACE, 'PlaybackStreams', + dbus_interface=dbus.PROPERTIES_IFACE) + + # keep the default sink (if available) on top of the list + try: + default_sink = obj.Get(self.PULSE_IFACE, 'FallbackSink', + dbus_interface=dbus.PROPERTIES_IFACE) + except: + pass + else: + if default_sink in sinks: + sinks.remove(default_sink) + sinks.insert(0, default_sink) + + for obj_path in sinks: + self.sink_add(obj_path) + + for obj_path in streams: + self.stream_add(obj_path) + + def stream_add(self, obj_path): + try: + obj = self.conn.get_object(self.STREAM_IFACE, obj_path) + volume = obj.Get(self.STREAM_IFACE, 'Volume', + dbus_interface=dbus.PROPERTIES_IFACE) + mute = obj.Get(self.STREAM_IFACE, 'Mute', + dbus_interface=dbus.PROPERTIES_IFACE) + props = obj.Get(self.STREAM_IFACE, 'PropertyList', + dbus_interface=dbus.PROPERTIES_IFACE) + except: + return None + + try: + name = self._fuckyoupulse(props['application.name']) + except: + name = 'Unknown app' + + ch = AudioChannel(obj, self.STREAM_IFACE, name, volume, mute) + self.channels.append(ch) + return ch + + def sink_add(self, obj_path): + try: + obj = self.conn.get_object(self.DEVICE_IFACE, obj_path) + volume = obj.Get(self.DEVICE_IFACE, 'Volume', + dbus_interface=dbus.PROPERTIES_IFACE) + mute = obj.Get(self.DEVICE_IFACE, 'Mute', + dbus_interface=dbus.PROPERTIES_IFACE) + props = obj.Get(self.DEVICE_IFACE, 'PropertyList', + dbus_interface=dbus.PROPERTIES_IFACE) + except: + return None + + try: + name = self._fuckyoupulse(props['device.profile.description']) + except: + try: + name = self._fuckyoupulse(props['device.description']) + except: + name = 'Unknown device' + + ch = AudioChannel(obj, self.DEVICE_IFACE, name, volume, mute) + self.channels.append(ch) + return ch diff --git a/GADGETS/audio/audio.edc b/GADGETS/audio/audio.edc new file mode 100644 index 0000000..527b53f --- /dev/null +++ b/GADGETS/audio/audio.edc @@ -0,0 +1,413 @@ +/** + * E17 Audio Gadget + */ + + +#define FIXED_SIZE(_WIDTH, _HEIGHT) \ + min: _WIDTH _HEIGHT; max: _WIDTH _HEIGHT; fixed: 1 1; + +#define FN "Sans" +#define FNBD "Sans:style=Bold" +#define FN_COL_HIGHLIGHT 51 153 255 255; color2: 51 153 255 24; color3: 51 153 255 18 + + +images { + image: "icon_mixer.png" COMP; + image: "icon_prev.png" COMP; + image: "icon_next.png" COMP; + image: "icon_pause.png" COMP; + image: "icon_play.png" COMP; + image: "cover.png" COMP; + image: "speaker.png" COMP; + image: "inset_round_hilight.png" COMP; + image: "inset_round_shadow.png" COMP; + image: "inset_round_shading.png" COMP; + image: "led_dot_white.png" COMP; +} + + +collections { +/** + * API [e/gadget/icon] The group used for the icon of the gadget + */ + group { name: "e/gadgets/audio/icon"; + parts { + part { name: "icon"; + description { + state: "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + image { + normal: "icon_mixer.png"; + } + } + } + } + } + +/** + * API [e/gadget/main] The main group of the gadget + */ + group { name: "e/gadgets/audio/main"; + max: 160 160; + min: 16 16; + script { + public message(Msg_Type:type, id, ...) { + if ((type == MSG_INT_SET) && (id == 0)) { + new m, l, r; + + m = getarg(2); + l = getarg(3); + r = getarg(4); + + if (m) { + run_program(PROGRAM:"mute"); + } else { + run_program(PROGRAM:"unmute"); + } + + if (l <= 0) { + run_program(PROGRAM:"l0-off"); + run_program(PROGRAM:"l1-off"); + run_program(PROGRAM:"l2-off"); + run_program(PROGRAM:"l3-off"); + run_program(PROGRAM:"l4-off"); + } else if (l <= 20) { + run_program(PROGRAM:"l0-on"); + run_program(PROGRAM:"l1-off"); + run_program(PROGRAM:"l2-off"); + run_program(PROGRAM:"l3-off"); + run_program(PROGRAM:"l4-off"); + } else if (l <= 40) { + run_program(PROGRAM:"l0-on"); + run_program(PROGRAM:"l1-on"); + run_program(PROGRAM:"l2-off"); + run_program(PROGRAM:"l3-off"); + run_program(PROGRAM:"l4-off"); + } else if (l <= 60) { + run_program(PROGRAM:"l0-on"); + run_program(PROGRAM:"l1-on"); + run_program(PROGRAM:"l2-on"); + run_program(PROGRAM:"l3-off"); + run_program(PROGRAM:"l4-off"); + } else if (l <= 80) { + run_program(PROGRAM:"l0-on"); + run_program(PROGRAM:"l1-on"); + run_program(PROGRAM:"l2-on"); + run_program(PROGRAM:"l3-on"); + run_program(PROGRAM:"l4-off"); + } else { + run_program(PROGRAM:"l0-on"); + run_program(PROGRAM:"l1-on"); + run_program(PROGRAM:"l2-on"); + run_program(PROGRAM:"l3-on"); + run_program(PROGRAM:"l4-on"); + } + + if (r <= 0) { + run_program(PROGRAM:"r0-off"); + run_program(PROGRAM:"r1-off"); + run_program(PROGRAM:"r2-off"); + run_program(PROGRAM:"r3-off"); + run_program(PROGRAM:"r4-off"); + } else if (r <= 20) { + run_program(PROGRAM:"r0-on"); + run_program(PROGRAM:"r1-off"); + run_program(PROGRAM:"r2-off"); + run_program(PROGRAM:"r3-off"); + run_program(PROGRAM:"r4-off"); + } else if (r <= 40) { + run_program(PROGRAM:"r0-on"); + run_program(PROGRAM:"r1-on"); + run_program(PROGRAM:"r2-off"); + run_program(PROGRAM:"r3-off"); + run_program(PROGRAM:"r4-off"); + } else if (r <= 60) { + run_program(PROGRAM:"r0-on"); + run_program(PROGRAM:"r1-on"); + run_program(PROGRAM:"r2-on"); + run_program(PROGRAM:"r3-off"); + run_program(PROGRAM:"r4-off"); + } else if (r <= 80) { + run_program(PROGRAM:"r0-on"); + run_program(PROGRAM:"r1-on"); + run_program(PROGRAM:"r2-on"); + run_program(PROGRAM:"r3-on"); + run_program(PROGRAM:"r4-off"); + } else { + run_program(PROGRAM:"r0-on"); + run_program(PROGRAM:"r1-on"); + run_program(PROGRAM:"r2-on"); + run_program(PROGRAM:"r3-on"); + run_program(PROGRAM:"r4-on"); + } + } + } + } + parts { + part { name: "base-sh"; + description { state: "default" 0.0; + rel1.to: "base"; + rel1.offset: 0 -1; + rel2.to: "base"; + rel2.offset: -1 -2; + image.normal: "inset_round_shadow.png"; + } + } + part { name: "base-hi"; + description { state: "default" 0.0; + rel1.to: "base"; + rel1.offset: 0 1; + rel2.to: "base"; + rel2.offset: -1 0; + image.normal: "inset_round_hilight.png"; + } + } + part { name: "base"; + description { state: "default" 0.0; + // min: 32 32; + rel1.relative: (25/380) (25/380); + rel2.relative: (365/380) (365/380); + aspect: 1.0 1.0; aspect_preference: BOTH; + image.normal: "speaker.png"; + } + } + part { name: "state"; type: RECT; + description { state: "default" 0.0; + rel1.relative: -1.0 -1.0; + rel2.relative: 2.0 2.0; + color: 51 153 255 255; + } + description { state: "mute" 0.0; + inherit: "default" 0.0; + color: 255 153 51 255; + } + } +#define LED(_NAME, _BASE, _X, _SIZE) \ + part { name: _NAME; type: RECT; \ + clip_to: "state"; \ + description { state: "default" 0.0; \ + rel1.relative: ((_BASE+(_X*8))/160) (80/160); \ + rel2.relative: ((_BASE+(_X*8))/160) (80/160); \ + min: 1 1; \ + max: 1 1; \ + visible: 0; \ + color: 255 255 255 0; \ + } \ + description { state: "active" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + color: 255 255 255 255; \ + } \ + } \ + part { name: _NAME"g"; \ + clip_to: "state"; \ + description { state: "default" 0.0; \ + rel1.to: _NAME; \ + rel2.to: _NAME; \ + image.normal: "led_dot_white.png"; \ + min: _SIZE _SIZE; \ + visible: 0; \ + color: 255 255 255 0; \ + } \ + description { state: "active" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + color: 255 255 255 255; \ + } \ + } + LED("r0", 99, 0, 1) + LED("r1", 99, 1, 9) + LED("r2", 99, 2, 15) + LED("r3", 99, 3, 21) + LED("r4", 99, 4, 27) + LED("l0", 61, 0, 1) + LED("l1", 61, -1, 9) + LED("l2", 61, -2, 15) + LED("l3", 61, -3, 21) + LED("l4", 61, -4, 27) +#undef LED + part { name: "over"; type: RECT; + description { state: "default" 0.0; + color: 255 255 255 0; + } + } + } + programs { + program { name: "mute"; + action: STATE_SET "mute" 0.0; + transition: LINEAR 0.3; + target: "state"; + } + program { name: "unmute"; + action: STATE_SET "default" 0.0; + transition: LINEAR 0.2; + target: "state"; + } +#define PROG(_NAME) \ + program { name: _NAME"-on"; \ + action: STATE_SET "active" 0.0; \ + target: _NAME; \ + target: _NAME"g"; \ + } \ + program { name: _NAME"-off"; \ + action: STATE_SET "default" 0.0; \ + target: _NAME; \ + target: _NAME"g"; \ + } + PROG("r0") + PROG("r1") + PROG("r2") + PROG("r3") + PROG("r4") + PROG("l0") + PROG("l1") + PROG("l2") + PROG("l3") + PROG("l4") +#undef PROG + } + } + +/** + * API [e/gadget/popup] This is the group that will be placed inside popups + */ + group { name: "e/gadgets/audio/popup"; + min: 310 0; + parts { + part { name: "players.box"; + type: BOX; + description { state: "default" 0.0; + rel2.relative: 1.0 0.0; + align: 0.0 0.0; + box { + layout: "vertical"; + padding: 0 6; + min: 1 1; + } + } + } + part { name: "volumes.box"; + type: BOX; + description { state: "default" 0.0; + rel1.to: "players.box"; + rel1.relative: 0.0 1.0; + rel1.offset: 0 6; + box { + layout: "vertical"; + padding: 0 6; + min: 1 1; + } + } + } + } + } + + group { name: "e/gadgets/audio/player"; + styles { + style { name: "music_control_metadata_style"; + base: "font="FN" font_size=10 align=left color=#ffff style=shadow,bottom shadow_color=#00000080 wrap=mixed"; + tag: "title" "+ font="FNBD" font_size=12"; + tag: "tag" "+ font_size=8 color=#888f"; + tag: "br" "\n"; + } + } + parts { + part { name: "cover_bg"; + description { state: "default" 0; + min: 100 100; + max: 100 100; + align: 0.0 0.5; + image.normal: "cover.png"; + } + } + part { name: "cover.swallow"; type: SWALLOW; + description { state: "default" 0; + rel1.to: "cover_bg"; + rel2.to: "cover_bg"; + } + } + part { name: "player_name"; type: TEXT; + effect: GLOW; + description { state: "default" 0; + min: 210 15; + max: 210 15; + align: 0.5 0.0; + color: FN_COL_HIGHLIGHT; + text { + size: 12; + font: FNBD; + } + rel1.to_x: "cover_bg"; + rel1.relative: 1.0 0.0; + rel1.offset: 3 0; + } + } + part { name: "metadata"; type: TEXTBLOCK; + description { state: "default" 0; + text { + style: "music_control_metadata_style"; + text: "Song Title"; + align: 0.0 0.0; + } + rel1.to_x: "cover_bg"; + rel1.relative: 1.0 0.0; + rel1.offset: 3 15; + } + } + part { name: "prev_btn"; + description { state: "default" 0; + FIXED_SIZE(32, 32) + rel1.to: "metadata"; + rel2.to: "metadata"; + align: 0.1 1.0; + image.normal: "icon_prev.png"; + } + } + part { name: "play_btn"; + description { state: "default" 0; + FIXED_SIZE(32, 32) + rel1.to: "metadata"; + rel2.to: "metadata"; + align: 0.5 1.0; + image.normal: "icon_pause.png"; + } + description { state: "play" 0.0; + inherit: "default" 0.0; + image.normal: "icon_play.png"; + } + } + part { name: "next_btn"; + description { state: "default" 0; + FIXED_SIZE(32, 32) + rel1.to: "metadata"; + rel2.to: "metadata"; + align: 0.9 1.0; + image.normal: "icon_next.png"; + } + } + } + programs { + program { signal: "state,set,playing"; source: ""; + action: STATE_SET "default" 0.0; + target: "play_btn"; + } + program { signal: "state,set,paused"; source: ""; + action: STATE_SET "play" 0.0; + target: "play_btn"; + } + program { signal: "mouse,down,1"; source: "play_btn"; + action: SIGNAL_EMIT "act,play" ""; + } + program { signal: "mouse,down,1"; source: "prev_btn"; + action: SIGNAL_EMIT "act,prev" ""; + } + program { signal: "mouse,down,1"; source: "next_btn"; + action: SIGNAL_EMIT "act,next" ""; + } + program { signal: "mouse,down,1"; source: "player_name"; + action: SIGNAL_EMIT "act,rais" ""; + } + } + } +} diff --git a/GADGETS/audio/images/cover.png b/GADGETS/audio/images/cover.png new file mode 100644 index 0000000..66834e4 Binary files /dev/null and b/GADGETS/audio/images/cover.png differ diff --git a/GADGETS/audio/images/icon_mixer.png b/GADGETS/audio/images/icon_mixer.png new file mode 100644 index 0000000..e5e3b0e Binary files /dev/null and b/GADGETS/audio/images/icon_mixer.png differ diff --git a/GADGETS/audio/images/icon_next.png b/GADGETS/audio/images/icon_next.png new file mode 100644 index 0000000..049ec4d Binary files /dev/null and b/GADGETS/audio/images/icon_next.png differ diff --git a/GADGETS/audio/images/icon_pause.png b/GADGETS/audio/images/icon_pause.png new file mode 100644 index 0000000..b5dbfee Binary files /dev/null and b/GADGETS/audio/images/icon_pause.png differ diff --git a/GADGETS/audio/images/icon_play.png b/GADGETS/audio/images/icon_play.png new file mode 100644 index 0000000..b9b301c Binary files /dev/null and b/GADGETS/audio/images/icon_play.png differ diff --git a/GADGETS/audio/images/icon_prev.png b/GADGETS/audio/images/icon_prev.png new file mode 100644 index 0000000..b486a37 Binary files /dev/null and b/GADGETS/audio/images/icon_prev.png differ diff --git a/GADGETS/audio/images/inset_round_hilight.png b/GADGETS/audio/images/inset_round_hilight.png new file mode 100644 index 0000000..7696175 Binary files /dev/null and b/GADGETS/audio/images/inset_round_hilight.png differ diff --git a/GADGETS/audio/images/inset_round_shading.png b/GADGETS/audio/images/inset_round_shading.png new file mode 100644 index 0000000..429f073 Binary files /dev/null and b/GADGETS/audio/images/inset_round_shading.png differ diff --git a/GADGETS/audio/images/inset_round_shadow.png b/GADGETS/audio/images/inset_round_shadow.png new file mode 100644 index 0000000..5dd3b0c Binary files /dev/null and b/GADGETS/audio/images/inset_round_shadow.png differ diff --git a/GADGETS/audio/images/led_dot_white.png b/GADGETS/audio/images/led_dot_white.png new file mode 100644 index 0000000..9c22789 Binary files /dev/null and b/GADGETS/audio/images/led_dot_white.png differ diff --git a/GADGETS/audio/images/speaker.png b/GADGETS/audio/images/speaker.png new file mode 100644 index 0000000..f6622f5 Binary files /dev/null and b/GADGETS/audio/images/speaker.png differ diff --git a/GADGETS/calculator/Makefile b/GADGETS/calculator/Makefile new file mode 100644 index 0000000..9d58b2d --- /dev/null +++ b/GADGETS/calculator/Makefile @@ -0,0 +1,36 @@ +# Simple Makefile for Enlightenment (edgar) gadgets + +# gadget specific config +GADGET_NAME = calculator +EXTRA_FILES = + + +# nothing should be changed below this point +GADGET_FILES = __init__.pyc $(GADGET_NAME).edj +prefix = $(shell pkg-config --variable=libdir enlightenment) +gadget_folder = ${prefix}/enlightenment/gadgets/$(GADGET_NAME) + +.PHONY: all install clean + +all: $(GADGET_FILES) $(EXTRA_FILES) + +install: all + @mkdir -p -v ${gadget_folder} + @cp --preserve=mode -v $(GADGET_FILES) $(EXTRA_FILES) $(gadget_folder) + +uninstall: all + @rm -rfv ${gadget_folder} + +clean: + @rm -fv $(GADGET_NAME).edj + + +EDJE_CC = edje_cc +EDJE_FLAGS = -v -id images/ -fd fonts/ + +%.edj: %.edc images/* + $(EDJE_CC) $(EDJE_FLAGS) $< + @chmod -v og+r $@ + +%.pyc: %.py + python3 -c "from py_compile import compile; compile('$<', '$@')" diff --git a/GADGETS/calculator/__init__.py b/GADGETS/calculator/__init__.py new file mode 100644 index 0000000..90bd90c --- /dev/null +++ b/GADGETS/calculator/__init__.py @@ -0,0 +1,13 @@ +# This python file use the following encoding: utf-8 + +import e + + + +class Gadget(e.Gadget): + __gadget_name__ = 'Calculator' + __gadget_vers__ = '0.1' + __gadget_auth__ = 'DaveMDS' + __gadget_mail__ = 'dave@gurumeditation.it' + __gadget_desc__ = 'A pure edje calculator.' + __gadget_vapi__ = 1 diff --git a/GADGETS/calculator/calculator.edc b/GADGETS/calculator/calculator.edc new file mode 100644 index 0000000..56d0a62 --- /dev/null +++ b/GADGETS/calculator/calculator.edc @@ -0,0 +1,472 @@ +/* Copyright (C) 2008-2014 Davide Andreoli (see AUTHORS) + * + * This file is part of calculator. + * calculator. is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * calculator. 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with calculator. If not, see <http://www.gnu.org/licenses/>. + */ + +images { + image: "0.png" COMP; + image: "1.png" COMP; + image: "2.png" COMP; + image: "3.png" COMP; + image: "4.png" COMP; + image: "5.png" COMP; + image: "6.png" COMP; + image: "7.png" COMP; + image: "8.png" COMP; + image: "9.png" COMP; + image: "bg.png" COMP; + image: "canc.png" COMP; + image: "divide.png" COMP; + image: "multiply.png" COMP; + image: "minus.png" COMP; + image: "plus.png" COMP; + image: "point.png" COMP; + image: "result.png" COMP; + image: "m-c.png" COMP; + image: "m-minus.png" COMP; + image: "m-plus.png" COMP; + image: "m-r.png" COMP; +} + +fonts { + font: "Vera.ttf" "vera"; +} + + +collections { + + group { name: "e/gadgets/calculator/icon"; + parts { + part { name: "icon"; + description { + state: "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + image { + normal: "canc.png"; + } + } + } + } + } + + group { name: "e/gadgets/calculator/main"; + min: 231 256; + max: 462 512; + script { + public current = 0; //Current float number + public sum = 0; + public sub = 0; + public mul = 0; + public div = 0; + public restart = 0; + public locale = 0; //The ascii value used for '.' by current locale + + public get_locale() + { + new buf[5]; + snprintf(buf, 4, "%f", 1.1); + set_int(locale, buf[1]); + } + + public calc_digit_add(val) + { + new buf[32]; + new text[32]; + + get_text(PART:"display", text, 31); + + //need a new number (+.-,*,/ pressed) + if (get_int(restart)) + snprintf(buf, 31, "%i", val); + //point pressed + else if (val == -1) + snprintf(buf, 31, "%i%c", get_int(current), get_int(locale)); + //only the 0 digit is on screen + else if ((text[0] == '0') && (text[1] == 0)) + snprintf(buf, 31, "%i", val); + //Normal: append the number + else + snprintf(buf, 31, "%s%i", text, val); + + set_text(PART:"display", buf); + set_float(current, atof(buf)); + + if (get_int(restart)) + set_int(restart, 0); + } + + public calc_reset() + { + set_float(current, 0.0); + set_float(sum, 0.0); + set_float(sub, 0.0); + set_float(mul, 0.0); + set_float(div, 0.0); + set_text(PART:"display", "0"); + } + + public calc_result() + { + new buf[32]; + + if (get_float(sum)) + { + snprintf(buf, 31, "%f", get_float(sum) + get_float(current)); + set_float(sum, 0.0); + } + else if (get_float(sub)) + { + snprintf(buf, 31, "%f", get_float(sub) - get_float(current)); + set_float(sub, 0.0); + } + else if (get_float(mul)) + { + snprintf(buf, 31, "%f", get_float(mul) * get_float(current)); + set_float(mul, 0.0); + } + else if (get_float(div)) + { + snprintf(buf, 31, "%f", get_float(div) / get_float(current)); + set_float(div, 0.0); + } + else + { + return; + } + + //remove leading zeroes + new i = 0; + while (buf[i] != 0) i++; + i--; + while (i && (buf[i] == '0')) + { + buf[i] = 0; + i--; + } + if (buf[i] == get_int(locale)) buf[i] = 0; + + //Set result + set_text(PART:"display", buf); + set_float(current, atof(buf)); + } + + public calc_sum() + { + if (get_float(sum)) + calc_result(); + set_float(sum, get_float(current)); + set_float(current, 0.0); + set_int(restart, 1); + } + + public calc_sub() + { + if (get_float(sub)) + calc_result(); + set_float(sub, get_float(current)); + set_float(current, 0.0); + set_int(restart, 1); + } + + public calc_mul() + { + if (get_float(mul)) + calc_result(); + set_float(mul, get_float(current)); + set_float(current, 0.0); + set_int(restart, 1); + } + + public calc_div() + { + if (get_float(div)) + calc_result(); + set_float(div, get_float(current)); + set_float(current, 0.0); + set_int(restart, 1); + } + } + + parts { + part { name: "bg"; + type: IMAGE; + mouse_events: 1; + description { state: "default" 0.0; + aspect: 0.9 0.9; + aspect_preference: BOTH; + image { + normal: "bg.png"; + } + } + } + + part { name: "display"; + type: TEXT; + mouse_events: 0; + description { state: "default" 0.0; + color: 68 72 63 200; + rel1 { + relative: 0.07 0.09; + to: "bg"; + } + rel2 { + relative: 0.93 0.22; + to: "bg"; + } + text{ + font: "vera"; + size: 20; + fit: 0 1; + align: 1 0.5; + text: "012345"; + } + } + } + + part { name: "num_bg"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + color: 255 0 255 0; + rel1 { + relative: 0.14 0.27; + to: "bg"; + } + rel2 { + relative: 0.73 0.95; + to: "bg"; + } + } + } + +#define BTN(pname, rel1x, rel1y, rel2x, rel2y) \ + part { name: pname; \ + type: IMAGE; \ + description { state: "default" 0.0; \ + align: 0.5 0.5; \ + image { \ + normal: pname".png"; \ + } \ + rel1 { \ + relative: (rel1x+0.01) (rel1y+0.01); \ + to: "num_bg"; \ + } \ + rel2 { \ + relative: (rel2x-0.01) (rel2y-0.01); \ + to: "num_bg"; \ + } \ + } \ + description { state: "pressed" 0.0; \ + align: 0.5 0.5; \ + image { \ + normal: pname".png"; \ + } \ + rel1 { \ + relative: (rel1x+0.01) (rel1y+0.05); \ + to: "num_bg"; \ + } \ + rel2 { \ + relative: (rel2x-0.01) (rel2y-0.05); \ + to: "num_bg"; \ + } \ + } \ + } + + BTN("0", 0.0, 0.75, 0.33, 1.0) + BTN("1", 0.0, 0.50, 0.33, 0.75) + BTN("2", 0.33, 0.50, 0.66, 0.75) + BTN("3", 0.66, 0.50, 0.99, 0.75) + BTN("4", 0.0, 0.25, 0.33, 0.50) + BTN("5", 0.33, 0.25, 0.66, 0.50) + BTN("6", 0.66, 0.25, 0.99, 0.50) + BTN("7", 0.0, 0.0, 0.33, 0.25) + BTN("8", 0.33, 0.0, 0.66, 0.25) + BTN("9", 0.66, 0.0, 0.99, 0.25) + BTN("point", 0.33, 0.75, 0.66, 1.0) + BTN("result", 0.66, 0.75, 0.99, 1.0) + BTN("canc", 1.03, 0.0, 1.30, 0.20) + BTN("divide", 1.03, 0.20, 1.30, 0.40) + BTN("multiply", 1.03, 0.40, 1.30, 0.60) + BTN("minus", 1.03, 0.60, 1.30, 0.80) + BTN("plus", 1.03, 0.80, 1.30, 1.0) + + } +#define BTN_PROG(__pname) \ + program { name: "pressed_"__pname; \ + signal: "mouse,down,*"; \ + source: __pname; \ + action: STATE_SET "pressed" 0.0; \ + transition: SINUSOIDAL 0.2; \ + target: __pname; \ + after: "released_"__pname; \ + } \ + program { name: "released_"__pname; \ + source: ""; \ + action: STATE_SET "default" 0.0;\ + transition: SINUSOIDAL 0.2; \ + target: __pname; \ + } + + programs { + program { name: "init"; + signal: "load"; + source: ""; + script { + set_text(PART:"display", "0"); + get_locale(); + } + } + + BTN_PROG("0") + BTN_PROG("1") + BTN_PROG("2") + BTN_PROG("3") + BTN_PROG("4") + BTN_PROG("5") + BTN_PROG("6") + BTN_PROG("7") + BTN_PROG("8") + BTN_PROG("9") + BTN_PROG("point") + BTN_PROG("result") + BTN_PROG("canc") + BTN_PROG("divide") + BTN_PROG("multiply") + BTN_PROG("plus") + BTN_PROG("minus") + + program { name: "clicked_0"; + signal: "mouse,down,*"; + source: "0"; + script { + calc_digit_add(0); + } + } + program { name: "clicked_1"; + signal: "mouse,down,*"; + source: "1"; + script { + calc_digit_add(1); + } + } + program { name: "clicked_2"; + signal: "mouse,down,*"; + source: "2"; + script { + calc_digit_add(2); + } + } + program { name: "clicked_3"; + signal: "mouse,down,*"; + source: "3"; + script { + calc_digit_add(3); + } + } + program { name: "clicked_4"; + signal: "mouse,down,*"; + source: "4"; + script { + calc_digit_add(4); + } + } + program { name: "clicked_5"; + signal: "mouse,down,*"; + source: "5"; + script { + calc_digit_add(5); + } + } + program { name: "clicked_6"; + signal: "mouse,down,*"; + source: "6"; + script { + calc_digit_add(6); + } + } + program { name: "clicked_7"; + signal: "mouse,down,*"; + source: "7"; + script { + calc_digit_add(7); + } + } + program { name: "clicked_8"; + signal: "mouse,down,*"; + source: "8"; + script { + calc_digit_add(8); + } + } + program { name: "clicked_9"; + signal: "mouse,down,*"; + source: "9"; + script { + calc_digit_add(9); + } + } + program { name: "clicked_point"; + signal: "mouse,down,*"; + source: "point"; + script { + calc_digit_add(-1); + } + } + program { name: "clicked_canc"; + signal: "mouse,down,*"; + source: "canc"; + script { + calc_reset(); + } + } + program { name: "clicked_plus"; + signal: "mouse,down,*"; + source: "plus"; + script { + calc_sum(); + } + } + program { name: "clicked_minus"; + signal: "mouse,down,*"; + source: "minus"; + script { + calc_sub(); + } + } + program { name: "clicked_multiply"; + signal: "mouse,down,*"; + source: "multiply"; + script { + calc_mul(); + } + } + program { name: "clicked_divide"; + signal: "mouse,down,*"; + source: "divide"; + script { + calc_div(); + } + } + program { name: "clicked_result"; + signal: "mouse,down,*"; + source: "result"; + script { + calc_result(); + } + } + } + } +} diff --git a/GADGETS/calculator/fonts/Vera.ttf b/GADGETS/calculator/fonts/Vera.ttf new file mode 100644 index 0000000..58cd6b5 Binary files /dev/null and b/GADGETS/calculator/fonts/Vera.ttf differ diff --git a/GADGETS/calculator/images/0.png b/GADGETS/calculator/images/0.png new file mode 100644 index 0000000..371995e Binary files /dev/null and b/GADGETS/calculator/images/0.png differ diff --git a/GADGETS/calculator/images/1.png b/GADGETS/calculator/images/1.png new file mode 100644 index 0000000..cd679c9 Binary files /dev/null and b/GADGETS/calculator/images/1.png differ diff --git a/GADGETS/calculator/images/2.png b/GADGETS/calculator/images/2.png new file mode 100644 index 0000000..51e504a Binary files /dev/null and b/GADGETS/calculator/images/2.png differ diff --git a/GADGETS/calculator/images/3.png b/GADGETS/calculator/images/3.png new file mode 100644 index 0000000..126e15d Binary files /dev/null and b/GADGETS/calculator/images/3.png differ diff --git a/GADGETS/calculator/images/4.png b/GADGETS/calculator/images/4.png new file mode 100644 index 0000000..5e9109c Binary files /dev/null and b/GADGETS/calculator/images/4.png differ diff --git a/GADGETS/calculator/images/5.png b/GADGETS/calculator/images/5.png new file mode 100644 index 0000000..3c55e2e Binary files /dev/null and b/GADGETS/calculator/images/5.png differ diff --git a/GADGETS/calculator/images/6.png b/GADGETS/calculator/images/6.png new file mode 100644 index 0000000..e828c5f Binary files /dev/null and b/GADGETS/calculator/images/6.png differ diff --git a/GADGETS/calculator/images/7.png b/GADGETS/calculator/images/7.png new file mode 100644 index 0000000..946c8c6 Binary files /dev/null and b/GADGETS/calculator/images/7.png differ diff --git a/GADGETS/calculator/images/8.png b/GADGETS/calculator/images/8.png new file mode 100644 index 0000000..bdb9bd4 Binary files /dev/null and b/GADGETS/calculator/images/8.png differ diff --git a/GADGETS/calculator/images/9.png b/GADGETS/calculator/images/9.png new file mode 100644 index 0000000..232e81c Binary files /dev/null and b/GADGETS/calculator/images/9.png differ diff --git a/GADGETS/calculator/images/bg.png b/GADGETS/calculator/images/bg.png new file mode 100644 index 0000000..4de0cb0 Binary files /dev/null and b/GADGETS/calculator/images/bg.png differ diff --git a/GADGETS/calculator/images/canc.png b/GADGETS/calculator/images/canc.png new file mode 100644 index 0000000..77716f4 Binary files /dev/null and b/GADGETS/calculator/images/canc.png differ diff --git a/GADGETS/calculator/images/divide.png b/GADGETS/calculator/images/divide.png new file mode 100644 index 0000000..680d18b Binary files /dev/null and b/GADGETS/calculator/images/divide.png differ diff --git a/GADGETS/calculator/images/m-c.png b/GADGETS/calculator/images/m-c.png new file mode 100644 index 0000000..9b864e6 Binary files /dev/null and b/GADGETS/calculator/images/m-c.png differ diff --git a/GADGETS/calculator/images/m-minus.png b/GADGETS/calculator/images/m-minus.png new file mode 100644 index 0000000..764b002 Binary files /dev/null and b/GADGETS/calculator/images/m-minus.png differ diff --git a/GADGETS/calculator/images/m-plus.png b/GADGETS/calculator/images/m-plus.png new file mode 100644 index 0000000..3080d2e Binary files /dev/null and b/GADGETS/calculator/images/m-plus.png differ diff --git a/GADGETS/calculator/images/m-r.png b/GADGETS/calculator/images/m-r.png new file mode 100644 index 0000000..76cdaa0 Binary files /dev/null and b/GADGETS/calculator/images/m-r.png differ diff --git a/GADGETS/calculator/images/minus.png b/GADGETS/calculator/images/minus.png new file mode 100644 index 0000000..c51b904 Binary files /dev/null and b/GADGETS/calculator/images/minus.png differ diff --git a/GADGETS/calculator/images/multiply.png b/GADGETS/calculator/images/multiply.png new file mode 100644 index 0000000..b45de25 Binary files /dev/null and b/GADGETS/calculator/images/multiply.png differ diff --git a/GADGETS/calculator/images/plus.png b/GADGETS/calculator/images/plus.png new file mode 100644 index 0000000..8998e8b Binary files /dev/null and b/GADGETS/calculator/images/plus.png differ diff --git a/GADGETS/calculator/images/point.png b/GADGETS/calculator/images/point.png new file mode 100644 index 0000000..a05abd3 Binary files /dev/null and b/GADGETS/calculator/images/point.png differ diff --git a/GADGETS/calculator/images/result.png b/GADGETS/calculator/images/result.png new file mode 100644 index 0000000..cf15f54 Binary files /dev/null and b/GADGETS/calculator/images/result.png differ diff --git a/GADGETS/led_clock/Makefile b/GADGETS/led_clock/Makefile new file mode 100644 index 0000000..0a1fa96 --- /dev/null +++ b/GADGETS/led_clock/Makefile @@ -0,0 +1,36 @@ +# Simple Makefile for Enlightenment (edgar) gadgets + +# gadget specific config +GADGET_NAME = led_clock +EXTRA_FILES = + + +# nothing should be changed below this point +GADGET_FILES = __init__.pyc $(GADGET_NAME).edj +prefix = $(shell pkg-config --variable=libdir enlightenment) +gadget_folder = ${prefix}/enlightenment/gadgets/$(GADGET_NAME) + +.PHONY: all install clean + +all: $(GADGET_FILES) $(EXTRA_FILES) + +install: all + @mkdir -p -v ${gadget_folder} + @cp --preserve=mode -v $(GADGET_FILES) $(EXTRA_FILES) $(gadget_folder) + +uninstall: all + @rm -rfv ${gadget_folder} + +clean: + @rm -fv $(GADGET_NAME).edj + + +EDJE_CC = edje_cc +EDJE_FLAGS = -v -id images/ -fd fonts/ + +%.edj: %.edc images/* + $(EDJE_CC) $(EDJE_FLAGS) $< + @chmod -v og+r $@ + +%.pyc: %.py + python3 -c "from py_compile import compile; compile('$<', '$@')" diff --git a/GADGETS/led_clock/__init__.py b/GADGETS/led_clock/__init__.py new file mode 100644 index 0000000..5a5bd5c --- /dev/null +++ b/GADGETS/led_clock/__init__.py @@ -0,0 +1,145 @@ +# This python file use the following encoding: utf-8 + +import sys +import os +import datetime +import random +import e + +from efl import edje +from efl import ecore + + +COLORS = ('off', 'red', 'green', 'blu') + +class Gadget(e.Gadget): + + __gadget_name__ = 'Led Clock' + __gadget_vers__ = '0.1' + __gadget_auth__ = 'DaveMDS' + __gadget_mail__ = 'dave@gurumeditation.it' + __gadget_desc__ = 'The usual led clock.' + __gadget_vapi__ = 1 + + def instance_created(self, obj, site): + super().instance_created(obj, site) + + timer = ecore.Timer(1.0, self.clock_timer_cb, obj) + obj.data['timer'] = timer + + obj.signal_callback_add('mouse,down,1', '*', self.led_click_cb) + return obj + + def instance_destroyed(self, obj): + super().instance_destroyed(obj) + + timer = obj.data.get('timer') + if timer: timer.delete() + timer2 = obj.data.get('timer2') + if timer2: timer2.delete() + + def clock_timer_cb(self, obj): + time = datetime.datetime.now() + self.draw_digit(obj, int(time.hour / 10), 1) + self.draw_digit(obj, int(time.hour % 10), 2); + self.draw_digit(obj, int(time.minute / 10), 3); + self.draw_digit(obj, int(time.minute % 10), 4); + return ecore.ECORE_CALLBACK_RENEW + + def draw_digit(self, obj, digit, position): + # build the "framebuffer" + if position == 1: + fb = [0, 0, 0] + elif position == 3: + fb = [0, 0, 0, 0, 0, 0] + else: + fb = [0, 0, 0, 0, 0, 0, 0, 0, 0] + + # turn on the first N 'led' on the array (N = digit) + for i in range(digit): + fb[i] = 1; + + # scramble the grid + random.shuffle(fb) + + # render to the 'fb' + if position == 1: + for i in range(len(fb)): + self.led_set(obj, i + 1, 'red' if fb[i] else 'off') + elif position == 2: + for i in range(len(fb)): + self.led_set(obj, i + 4, 'green' if fb[i] else 'off') + elif position == 3: + for i in range(len(fb)): + self.led_set(obj, i + 13, 'blu' if fb[i] else 'off') + elif position == 4: + for i in range(len(fb)): + self.led_set(obj, i + 19, 'red' if fb[i] else 'off') + + + def led_set(self, obj, led, color): + obj.signal_emit('led,set,' + color, 'led%d' % led) + + def clear_all(self, obj): + for i in range(1, 28): + self.led_set(obj, i, 'off') + + + ## Animations + def led_click_cb(self, obj, signal, source): + if source == 'led1': start_func = self.start_anim_1 + elif source == 'led2': start_func = self.start_anim_2 + elif source == 'led3': start_func = self.start_anim_3 + else: return + + timer = obj.data.get('timer') + if timer: timer.delete() + timer2 = obj.data.get('timer2') + if timer2: timer2.delete() + obj.data['timer2'] = ecore.Timer(10.0, self.stop_anim, obj) + start_func(obj) + + def stop_anim(self, obj): + self.clear_all(obj) + del obj.data['timer2'] + obj.data['timer'].delete() + obj.data['timer'] = ecore.Timer(1.0, self.clock_timer_cb, obj) + + return ecore.ECORE_CALLBACK_CANCEL + + + ## ANIM 1 (full colors) + def start_anim_1(self, obj): + obj.data['timer'] = ecore.Timer(0.4, self.animator_1, obj) + obj.data['color'] = 0 + + def animator_1(self, obj): + for i in range(1, 28): + self.led_set(obj, i, COLORS[obj.data['color'] % 4]) + obj.data['color'] += 1 + return ecore.ECORE_CALLBACK_RENEW + + + ## ANIM 2 (colors carousell) + def start_anim_2(self, obj): + self.clear_all(obj) + obj.data['timer'] = ecore.Timer(0.02, self.animator_2, obj) + obj.data['color'] = 1 + obj.data['count'] = 27 + + def animator_2(self, obj): + self.led_set(obj, obj.data['count'], COLORS[obj.data['color'] % 4]) + obj.data['count'] -= 1 + if obj.data['count'] <= 0: + obj.data['count'] = 27 + obj.data['color'] += 1 + return ecore.ECORE_CALLBACK_RENEW + + ## ANIM 3 (randomize) + def start_anim_3(self, obj): + obj.data['timer'] = ecore.Timer(0.075, self.animator_3, obj) + + def animator_3(self, obj): + for i in range(1, 28): + self.led_set(obj, i, random.choice(COLORS)) + return ecore.ECORE_CALLBACK_RENEW diff --git a/GADGETS/led_clock/images/bg.png b/GADGETS/led_clock/images/bg.png new file mode 100644 index 0000000..4b7b189 Binary files /dev/null and b/GADGETS/led_clock/images/bg.png differ diff --git a/GADGETS/led_clock/images/bg_orig.png b/GADGETS/led_clock/images/bg_orig.png new file mode 100644 index 0000000..6f95a1e Binary files /dev/null and b/GADGETS/led_clock/images/bg_orig.png differ diff --git a/GADGETS/led_clock/images/icon.png b/GADGETS/led_clock/images/icon.png new file mode 100644 index 0000000..94625c0 Binary files /dev/null and b/GADGETS/led_clock/images/icon.png differ diff --git a/GADGETS/led_clock/images/led_blu.png b/GADGETS/led_clock/images/led_blu.png new file mode 100644 index 0000000..2d98108 Binary files /dev/null and b/GADGETS/led_clock/images/led_blu.png differ diff --git a/GADGETS/led_clock/images/led_green.png b/GADGETS/led_clock/images/led_green.png new file mode 100644 index 0000000..78c29ef Binary files /dev/null and b/GADGETS/led_clock/images/led_green.png differ diff --git a/GADGETS/led_clock/images/led_off.png b/GADGETS/led_clock/images/led_off.png new file mode 100644 index 0000000..fe0fba8 Binary files /dev/null and b/GADGETS/led_clock/images/led_off.png differ diff --git a/GADGETS/led_clock/images/led_red.png b/GADGETS/led_clock/images/led_red.png new file mode 100644 index 0000000..18b2403 Binary files /dev/null and b/GADGETS/led_clock/images/led_red.png differ diff --git a/GADGETS/led_clock/images/template.png b/GADGETS/led_clock/images/template.png new file mode 100644 index 0000000..24b7d95 Binary files /dev/null and b/GADGETS/led_clock/images/template.png differ diff --git a/GADGETS/led_clock/led_clock.edc b/GADGETS/led_clock/led_clock.edc new file mode 100644 index 0000000..a3d4977 --- /dev/null +++ b/GADGETS/led_clock/led_clock.edc @@ -0,0 +1,188 @@ +/* Copyright (C) 2014 Davide Andreoli <dave@gurumeditation.it> + * + * This file is part of led_clock. + * led_clock. is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * led_clock. 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with led_clock. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * E17 Led Clock + * A led clock. + */ + +images { + image: "bg.png" COMP; + image: "led_off.png" COMP; + image: "led_red.png" COMP; + image: "led_blu.png" COMP; + image: "led_green.png" COMP; + image: "icon.png" COMP; +} + +collections { + + group { name: "e/gadgets/led_clock/icon"; + parts { + part { name: "icon"; + description { + state: "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + image { + normal: "icon.png"; + } + } + } + } + } + + group { name: "e/gadgets/led_clock/main"; + + + parts { + part { name: "bg"; + description { state: "default" 0.0; + min: 74 21; + max: 370 105; + aspect: 3.5 3.5; + aspect_preference: BOTH; + image { + normal: "bg.png"; + border: 4 6 4 4; + } + } + } + +#define LED_PART(NAME, X1, Y1, X2, Y2) \ + part { name: NAME; \ + description { state: "default" 0.0; \ + align: 0.0 0.0; \ + rel1.relative: X1 Y1; \ + rel2.relative: X2 Y2; \ + rel1.to: "bg"; \ + rel2.to: "bg"; \ + color: 230 230 230 150; \ + image { normal: "led_off.png"; } \ + } \ + description { state: "green" 0.0; \ + inherit: "default" 0.0; \ + color: 230 230 230 230; \ + image { normal: "led_green.png"; } \ + } \ + description { state: "red" 0.0; \ + inherit: "default" 0.0; \ + color: 230 230 230 230; \ + image { normal: "led_red.png"; } \ + } \ + description { state: "blu" 0.0; \ + inherit: "default" 0.0; \ + color: 230 230 230 230; \ + image { normal: "led_blu.png"; } \ + } \ + } + + LED_PART("led1", 0.043, 0.15, 0.103, 0.35) + LED_PART("led2", 0.043, 0.40, 0.103, 0.60) + LED_PART("led3", 0.043, 0.65, 0.103, 0.85) + //-------------------- + LED_PART("led4", 0.193, 0.15, 0.253, 0.35) + LED_PART("led5", 0.193, 0.40, 0.253, 0.60) + LED_PART("led6", 0.193, 0.65, 0.253, 0.85) + + LED_PART("led7", 0.268, 0.15, 0.330, 0.35) + LED_PART("led8", 0.268, 0.40, 0.330, 0.60) + LED_PART("led9", 0.268, 0.65, 0.330, 0.85) + + LED_PART("led10", 0.346, 0.15, 0.404, 0.35) + LED_PART("led11", 0.346, 0.40, 0.404, 0.60) + LED_PART("led12", 0.346, 0.65, 0.404, 0.85) + //-------------------- + LED_PART("led13", 0.497, 0.15, 0.560, 0.35) + LED_PART("led14", 0.497, 0.40, 0.560, 0.60) + LED_PART("led15", 0.497, 0.65, 0.560, 0.85) + + LED_PART("led16", 0.573, 0.15, 0.638, 0.35) + LED_PART("led17", 0.573, 0.40, 0.638, 0.60) + LED_PART("led18", 0.573, 0.65, 0.638, 0.85) + //-------------------- + LED_PART("led19", 0.730, 0.15, 0.795, 0.35) + LED_PART("led20", 0.730, 0.40, 0.795, 0.60) + LED_PART("led21", 0.730, 0.65, 0.795, 0.85) + + LED_PART("led22", 0.805, 0.15, 0.869, 0.35) + LED_PART("led23", 0.805, 0.40, 0.869, 0.60) + LED_PART("led24", 0.805, 0.65, 0.869, 0.85) + + LED_PART("led25", 0.883, 0.15, 0.947, 0.35) + LED_PART("led26", 0.883, 0.40, 0.947, 0.60) + LED_PART("led27", 0.883, 0.65, 0.947, 0.85) + } + programs { + +#define LED_PROG(LED) \ + program { name: LED"_green"; \ + signal: "led,set,green"; \ + source: LED; \ + action: STATE_SET "green" 0.0; \ + target: LED; \ + } \ + program { name: LED"_red"; \ + signal: "led,set,red"; \ + source: LED; \ + action: STATE_SET "red" 0.0; \ + target: LED; \ + } \ + program { name: LED"_blu"; \ + signal: "led,set,blu"; \ + source: LED; \ + action: STATE_SET "blu" 0.0; \ + target: LED; \ + } \ + program { name: LED"_off"; \ + signal: "led,set,off"; \ + source: LED; \ + action: STATE_SET "default" 0.0; \ + target: LED; \ + } + + LED_PROG("led1") + LED_PROG("led2") + LED_PROG("led3") + LED_PROG("led4") + LED_PROG("led5") + LED_PROG("led6") + LED_PROG("led7") + LED_PROG("led8") + LED_PROG("led9") + LED_PROG("led10") + LED_PROG("led11") + LED_PROG("led12") + LED_PROG("led13") + LED_PROG("led14") + LED_PROG("led15") + LED_PROG("led16") + LED_PROG("led17") + LED_PROG("led18") + LED_PROG("led19") + LED_PROG("led20") + LED_PROG("led21") + LED_PROG("led22") + LED_PROG("led23") + LED_PROG("led24") + LED_PROG("led25") + LED_PROG("led26") + LED_PROG("led27") + + } + } +} diff --git a/GADGETS/ruler/Makefile b/GADGETS/ruler/Makefile new file mode 100644 index 0000000..4736210 --- /dev/null +++ b/GADGETS/ruler/Makefile @@ -0,0 +1,36 @@ +# Simple Makefile for Enlightenment (edgar) gadgets + +# gadget specific config +GADGET_NAME = ruler +EXTRA_FILES = + + +# nothing should be changed below this point +GADGET_FILES = __init__.pyc $(GADGET_NAME).edj +prefix = $(shell pkg-config --variable=libdir enlightenment) +gadget_folder = ${prefix}/enlightenment/gadgets/$(GADGET_NAME) + +.PHONY: all install clean + +all: $(GADGET_FILES) $(EXTRA_FILES) + +install: all + @mkdir -p -v ${gadget_folder} + @cp --preserve=mode -v $(GADGET_FILES) $(EXTRA_FILES) $(gadget_folder) + +uninstall: all + @rm -rfv ${gadget_folder} + +clean: + @rm -fv $(GADGET_NAME).edj + + +EDJE_CC = edje_cc +EDJE_FLAGS = -v -id images/ -fd fonts/ + +%.edj: %.edc images/* + $(EDJE_CC) $(EDJE_FLAGS) $< + @chmod -v og+r $@ + +%.pyc: %.py + python3 -c "from py_compile import compile; compile('$<', '$@')" diff --git a/GADGETS/ruler/__init__.py b/GADGETS/ruler/__init__.py new file mode 100644 index 0000000..5b7b667 --- /dev/null +++ b/GADGETS/ruler/__init__.py @@ -0,0 +1,28 @@ +# This python file use the following encoding: utf-8 + +import sys +import os +import e + +from efl import evas + + +class Gadget(e.Gadget): + + __gadget_name__ = 'Ruler (HalloWorld)' + __gadget_vers__ = '0.1' + __gadget_auth__ = 'DaveMDS' + __gadget_mail__ = 'dave@gurumeditation.it' + __gadget_desc__ = 'All gadgets sets have a ruler...' + __gadget_vapi__ = 1 + + def __init__(self): + super().__init__() + + def instance_orient(self, obj, generic, specific): + super().instance_orient(obj, generic, specific) + + if generic == e.E_GADCON_ORIENT_VERT: + obj.signal_emit('gadget,orient,vert', '') + else: + obj.signal_emit('gadget,orient,horiz', '') diff --git a/GADGETS/ruler/images/icon.png b/GADGETS/ruler/images/icon.png new file mode 100644 index 0000000..b0a8172 Binary files /dev/null and b/GADGETS/ruler/images/icon.png differ diff --git a/GADGETS/ruler/images/ruler_horiz.png b/GADGETS/ruler/images/ruler_horiz.png new file mode 100644 index 0000000..fef303e Binary files /dev/null and b/GADGETS/ruler/images/ruler_horiz.png differ diff --git a/GADGETS/ruler/images/ruler_vert.png b/GADGETS/ruler/images/ruler_vert.png new file mode 100644 index 0000000..02b4217 Binary files /dev/null and b/GADGETS/ruler/images/ruler_vert.png differ diff --git a/GADGETS/ruler/ruler.edc b/GADGETS/ruler/ruler.edc new file mode 100644 index 0000000..2db7a1e --- /dev/null +++ b/GADGETS/ruler/ruler.edc @@ -0,0 +1,77 @@ +/** + * E17 Ruler Gadget (HalloWorld) + * + * This is the simplest gadget yo can do. + * Ruler will be used as reference, all off the gadgets features will be + * documented here.You can use this file as a skeleton for your new gadgets. + * + * All the thing that is labeled as API are part that must exist in every + * gadget. + * + */ + + +images { + image: "icon.png" COMP; + image: "ruler_horiz.png" COMP; + image: "ruler_vert.png" COMP; +} + + +collections { +/** + * API [e/gadget/icon] The group used for the icon of the gadget + */ + group { name: "e/gadgets/ruler/icon"; + parts { + part { name: "icon"; + description { + state: "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + image { + normal: "icon.png"; + } + } + } + } + } + +/** + * API [e/gadget/main] The main group of the gadget + * This group is the one that is places on the screen. It's name must be + * e/gadget/main. + */ + group { name: "e/gadgets/ruler/main"; + parts { + part { name: "ruler"; + description { state: "default" 0.0; + min: 800 70; + max: 800 70; + image { + normal: "ruler_horiz.png"; + } + } + description { state: "vertical" 0.0; + min: 70 800; + max: 70 800; + image { + normal: "ruler_vert.png"; + } + } + } + } + programs { + program { signal: "gadget,orient,vert"; + source: ""; + action: STATE_SET "vertical" 0.0; + target: "ruler"; + } + program { signal: "gadget,orient,horiz"; + source: ""; + action: STATE_SET "default" 0.0; + target: "ruler"; + } + } + } +} diff --git a/GADGETS_OLD/actions/Makefile b/GADGETS_OLD/actions/Makefile new file mode 100644 index 0000000..1cca9d1 --- /dev/null +++ b/GADGETS_OLD/actions/Makefile @@ -0,0 +1,22 @@ +GADGET_NAME = actions + +EDJE_CC = edje_cc +EDJE_FLAGS = -v -id images/ -fd fonts/ + +.PHONY: all install clean + +all: $(GADGET_NAME).edj + +$(GADGET_NAME).edj: $(GADGET_NAME).edc $(GADGET_NAME).embryo images/* + $(EDJE_CC) $(EDJE_FLAGS) $< $@ + +install: all + rm -f ~/.e/e/gadgets/$(GADGET_NAME).edj + cp $(GADGET_NAME).edj ~/.e/e/gadgets/$(GADGET_NAME).edj + +uninstall: all + rm -f ~/.e/e/gadgets/$(GADGET_NAME).edj; + + +clean: + rm -f $(GADGET_NAME).edj diff --git a/GADGETS_OLD/actions/actions.edc b/GADGETS_OLD/actions/actions.edc new file mode 100644 index 0000000..6f3aa42 --- /dev/null +++ b/GADGETS_OLD/actions/actions.edc @@ -0,0 +1,119 @@ +/* Copyright (C) 2008 Davide Andreoli (see AUTHORS) + * + * This file is part of top5. + * top5 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * top5 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with top5. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * E17 Actions Launcher + */ + + +data { + item: "e/gadget/name" "EActions"; + item: "e/gadget/description" "Example gadget that run E actions"; + item: "e/gadget/version" "0.1.0"; + item: "e/gadget/author" "davemds <dave@gurumeditattion.it>"; + item: "e/gadget/license" "LGPL"; + item: "e/gadget/apparence" "plain"; +} + +images { + image: "bg.png" COMP; + image: "e_logo.png" COMP; +} + +collections { + group { name: "e/gadget/icon"; + parts { + part { name: "icon"; + description { + state: "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + image { + normal: "bg.png"; + } + } + } + } + } + group { name: "e/gadget/main"; + min: 90 100; + max: 450 100; + + #include "actions.embryo" + + parts { + part { name: "bg"; + type: IMAGE; + mouse_events: 0; + description { state: "default" 0; + color: 255 255 255 255; + image { + normal: "bg.png"; + border: 9 9 9 9; + } + } + } + part { name: "text"; + type: TEXT; + effect: PLAIN; + mouse_events: 0; + description { state: "default" 0; + color: 255 255 255 255; + text { + text: "push me"; + font: "Sans"; + size: 14; + align: 0.5 0.5; + } + } + } + part { name: "logo"; + type: IMAGE; + mouse_events: 1; + description { state: "default" 0; + min: 140 70; + max: 140 70; + color: 255 255 255 255; + rel1 { + offset: 0 5; + to: "bg"; + } + image { + normal: "e_logo.png"; + } + } + } + + } + programs { + program { name: "init"; + signal: "load"; + source: ""; + script { + init(); + } + } + program { name: "click"; + signal: "mouse,clicked,1"; + source: "logo"; + script { + do_the_action(); + } + } + } + } +} diff --git a/GADGETS_OLD/actions/actions.embryo b/GADGETS_OLD/actions/actions.embryo new file mode 100644 index 0000000..e1c7a7a --- /dev/null +++ b/GADGETS_OLD/actions/actions.embryo @@ -0,0 +1,459 @@ +/* Copyright (C) 2008 Davide Andreoli (see AUTHORS) + * + * This file is part top5. + * top5 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * top5 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with top5. If not, see <http://www.gnu.org/licenses/>. + */ + +// #define ACTION "syscon" +// #define PARAMS "" + +// #define ACTION "everything" +// #define PARAMS "" + +// #define ACTION "restart" +// #define PARAMS "" + +// #define ACTION "desk_flip_by" +// #define PARAMS "1 0" + +// #define ACTION "exec" +// #define PARAMS "terminology" + + +// #define ACTION "fileman" +// #define PARAMS "~" + +#define ACTION "menu_show" +#define PARAMS "main" +// #define PARAMS "favorites" +// #define PARAMS "all" + + +// #define ACTION "volume_increase" +// #define ACTION "volume_decrease" +// #define ACTION "volume_mute" +// #define PARAMS "" + + +// THOSE FAILS +// #define ACTION "configuration" +// #define PARAMS "" +// #define ACTION "app" +// #define PARAMS "firefox" + +// THOSE FAILS (no go() in action) +// #define ACTION "delayed_action" +// #define PARAMS "0.0 everything" +// #define ACTION "delayed_action" +// #define PARAMS "0.0 exec terminology" + + +script { + +public init() +{ + send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "Actions Init"); +} + +public do_the_action() +{ + send_message(MSG_STRING_SET, 0, "EDGAR_ACTION", ACTION, PARAMS); +} + +public message(Msg_Type:type, id, ...) +{ + new cmd[32]; + new res[32]; + + if ((type != MSG_STRING_SET)) return; + getsarg(2, cmd, sizeof(cmd)); + + if (strcmp(cmd, "EDGAR_ACTION_REPLY") == 0) + { + getsarg(3, res, sizeof(res)) + send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "Action reply received", res); + } +} + +} + +/*** basic actions list ***/ + +/*** Clock + - Toggle calendar [clock] + params:'show_calendar' '(null)' +*** Desktop + - Flip Desktop Left [desk_flip_by] + params:'-1 0' '(null)' + - Flip Desktop Right [desk_flip_by] + params:'1 0' '(null)' + - Flip Desktop Up [desk_flip_by] + params:'0 -1' '(null)' + - Flip Desktop Down [desk_flip_by] + params:'0 1' '(null)' + - Flip Desktop By... [desk_flip_by] + params:'(null)' 'syntax: X-offset Y-offset, example: -1 0' + - Flip To Previous Desktop [desk_flip_prev] + params:'(null)' '(null)' + - Show The Desktop [desk_deskshow_toggle] + params:'(null)' '(null)' + - Show The Shelf [shelf_show] + params:'(null)' 'shelf name glob: Shelf-* ' + - Flip Desktop To... [desk_flip_to] + params:'(null)' 'syntax: X Y, example: 1 2' + - Flip Desktop Linearly... [desk_linear_flip_by] + params:'(null)' 'syntax: N-offset, example: -2' + - Switch To Desktop 0 [desk_linear_flip_to] + params:'0' '(null)' + - Switch To Desktop 1 [desk_linear_flip_to] + params:'1' '(null)' + - Switch To Desktop 2 [desk_linear_flip_to] + params:'2' '(null)' + - Switch To Desktop 3 [desk_linear_flip_to] + params:'3' '(null)' + - Switch To Desktop 4 [desk_linear_flip_to] + params:'4' '(null)' + - Switch To Desktop 5 [desk_linear_flip_to] + params:'5' '(null)' + - Switch To Desktop 6 [desk_linear_flip_to] + params:'6' '(null)' + - Switch To Desktop 7 [desk_linear_flip_to] + params:'7' '(null)' + - Switch To Desktop 8 [desk_linear_flip_to] + params:'8' '(null)' + - Switch To Desktop 9 [desk_linear_flip_to] + params:'9' '(null)' + - Switch To Desktop 10 [desk_linear_flip_to] + params:'10' '(null)' + - Switch To Desktop 11 [desk_linear_flip_to] + params:'11' '(null)' + - Switch To Desktop... [desk_linear_flip_to] + params:'(null)' 'syntax: N, example: 1' + - Flip Desktop Left (All Screens) [desk_flip_by_all] + params:'-1 0' '(null)' + - Flip Desktop Right (All Screens) [desk_flip_by_all] + params:'1 0' '(null)' + - Flip Desktop Up (All Screens) [desk_flip_by_all] + params:'0 -1' '(null)' + - Flip Desktop Down (All Screens) [desk_flip_by_all] + params:'0 1' '(null)' + - Flip Desktop By... (All Screens) [desk_flip_by_all] + params:'(null)' 'syntax: X-offset Y-offset, example: -1 0' + - Flip Desktop To... (All Screens) [desk_flip_to_all] + params:'(null)' 'syntax: X Y, example: 1 2' + - Flip Desktop Linearly... (All Screens) [desk_linear_flip_by_all] + params:'(null)' 'syntax: N-offset, example: -2' + - Flip Desktop In Direction... [desk_flip_in_direction] + params:'(null)' 'syntax: N-pixel-offset, example: 25' + - Switch To Desktop 0 (All Screens) [desk_linear_flip_to_all] + params:'0' '(null)' + - Switch To Desktop 1 (All Screens) [desk_linear_flip_to_all] + params:'1' '(null)' + - Switch To Desktop 2 (All Screens) [desk_linear_flip_to_all] + params:'2' '(null)' + - Switch To Desktop 3 (All Screens) [desk_linear_flip_to_all] + params:'3' '(null)' + - Switch To Desktop 4 (All Screens) [desk_linear_flip_to_all] + params:'4' '(null)' + - Switch To Desktop 5 (All Screens) [desk_linear_flip_to_all] + params:'5' '(null)' + - Switch To Desktop 6 (All Screens) [desk_linear_flip_to_all] + params:'6' '(null)' + - Switch To Desktop 7 (All Screens) [desk_linear_flip_to_all] + params:'7' '(null)' + - Switch To Desktop 8 (All Screens) [desk_linear_flip_to_all] + params:'8' '(null)' + - Switch To Desktop 9 (All Screens) [desk_linear_flip_to_all] + params:'9' '(null)' + - Switch To Desktop 10 (All Screens) [desk_linear_flip_to_all] + params:'10' '(null)' + - Switch To Desktop 11 (All Screens) [desk_linear_flip_to_all] + params:'11' '(null)' + - Switch To Desktop... (All Screens) [desk_linear_flip_to_all] + params:'(null)' 'syntax: N, example: 1' + - Lock [desk_lock] + params:'(null)' '(null)' + - Cleanup Windows [cleanup_windows] + params:'(null)' '(null)' +*** Enlightenment + - Restart [restart] + params:'(null)' '(null)' + - Exit [exit] + params:'(null)' '(null)' + - Exit Now [exit_now] + params:'(null)' '(null)' +*** Enlightenment : Mode + - Presentation Mode Toggle [mode_presentation_toggle] + params:'(null)' '(null)' + - Offline Mode Toggle [mode_offline_toggle] + params:'(null)' '(null)' +*** Enlightenment : Module + - Enable the named module [module_enable] + params:'(null)' '(null)' + - Disable the named module [module_disable] + params:'(null)' '(null)' + - Toggle the named module [module_toggle] + params:'(null)' '(null)' +*** Everything Launcher + - Show Everything Launcher [everything] + params:'' '(null)' + - Show Applications Plugin [everything] + params:'Applications' '(null)' + - Show Exebuf Plugin [everything] + params:'Exebuf' '(null)' + - Show Files Plugin [everything] + params:'Files' '(null)' + - Show Recent Files Plugin [everything] + params:'Recent Files' '(null)' + - Show Windows Plugin [everything] + params:'Windows' '(null)' + - Show Settings Plugin [everything] + params:'Settings' '(null)' + - Show Calculator Plugin [everything] + params:'Calculator' '(null)' + - Show Plugins Plugin [everything] + params:'Plugins' '(null)' + - Show Start Plugin [everything] + params:'Start' '(null)' + - Show Text Plugin [everything] + params:'Text' '(null)' +*** Gadgets + - Show/hide gadgets [gadman_toggle] + params:'(null)' '(null)' +*** Generic : Actions + - Delayed Action [delayed_action] + params:'(null)' '[0.0 exec xterm] [0.3 exec xev]' +*** IBar + - Focus IBar [ibar_focus] + params:'<none>' '(null)' +*** Keyboard Layouts + - Use keyboard layout [kbd_layout] + params:'(null)' 'syntax: Keyboard-layout-name, example: us' + - Next keyboard layout [kbd_layout_next] + params:'(null)' '(null)' + - Previous keyboard layout [kbd_layout_prev] + params:'(null)' '(null)' +*** Launch + - Command [exec] + params:'(null)' 'syntax: CommandName, example: /usr/bin/xmms' + - Application [app] + params:'(null)' 'syntax: , example:' + - New Instance of Focused App [app_new_instance] + params:'(null)' '(null)' + - File Manager [fileman] + params:'(null)' 'syntax: /path/to/dir or ~/path/to/dir or favorites or desktop, examples: /boot/grub, ~/downloads' + - Settings Panel [configuration] + params:'(null)' '(null)' +*** Menu + - Window Menu [window_menu] + params:'(null)' '(null)' + - Show Main Menu [menu_show] + params:'main' '(null)' + - Show Favorites Menu [menu_show] + params:'favorites' '(null)' + - Show All Applications Menu [menu_show] + params:'all' '(null)' + - Show Clients Menu [menu_show] + params:'clients' '(null)' + - Show Menu... [menu_show] + params:'(null)' 'syntax: MenuName, example: MyMenu' +*** Mixer + - Increase Volume [volume_increase] + params:'(null)' '(null)' + - Decrease Volume [volume_decrease] + params:'(null)' '(null)' + - Mute Volume [volume_mute] + params:'(null)' '(null)' +*** Pager + - Show Pager Popup [pager_show] + params:'<none>' '(null)' + - Popup Desk Right [pager_switch] + params:'right' '(null)' + - Popup Desk Left [pager_switch] + params:'left' '(null)' + - Popup Desk Up [pager_switch] + params:'up' '(null)' + - Popup Desk Down [pager_switch] + params:'down' '(null)' + - Popup Desk Next [pager_switch] + params:'next' '(null)' + - Popup Desk Previous [pager_switch] + params:'prev' '(null)' +*** Screen + - Send Mouse To Screen 0 [screen_send_to] + params:'0' '(null)' + - Send Mouse To Screen 1 [screen_send_to] + params:'1' '(null)' + - Send Mouse To Screen... [screen_send_to] + params:'(null)' 'syntax: N, example: 0' + - Send Mouse Forward 1 Screen [screen_send_by] + params:'1' '(null)' + - Send Mouse Back 1 Screen [screen_send_by] + params:'-1' '(null)' + - Send Mouse Forward/Back Screens... [screen_send_by] + params:'(null)' 'syntax: N-offset, example: -2' + - Dim [dim_screen] + params:'(null)' '(null)' + - Undim [undim_screen] + params:'(null)' '(null)' + - Backlight Set [backlight_set] + params:'(null)' 'syntax: brightness(0 - 100), example: 50' + - Backlight Min [backlight_set] + params:'0' '(null)' + - Backlight Mid [backlight_set] + params:'50' '(null)' + - Backlight Max [backlight_set] + params:'100' '(null)' + - Backlight Adjust [backlight_adjust] + params:'(null)' 'syntax: brightness(-100 - 100), example: -20' + - Backlight Up [backlight_adjust] + params:'10' '(null)' + - Backlight Down [backlight_adjust] + params:'-10' '(null)' + - Backlight Controls [backlight] + params:'(null)' '(null)' +*** System + - Log Out [logout] + params:'(null)' '(null)' + - Power Off Now [halt_now] + params:'(null)' '(null)' + - Power Off [halt] + params:'(null)' '(null)' + - Reboot [reboot] + params:'(null)' '(null)' + - Suspend Now [suspend_now] + params:'(null)' '(null)' + - Suspend [suspend] + params:'(null)' '(null)' + - Hibernate [hibernate] + params:'(null)' '(null)' + - Hibernate Now [hibernate_now] + params:'(null)' '(null)' + - System Controls [syscon] + params:'(null)' '(null)' +*** Window : Actions + - Move [window_move] + params:'(null)' '(null)' + - Resize [window_resize] + params:'(null)' '(null)' + - Raise [window_raise] + params:'(null)' '(null)' + - Lower [window_lower] + params:'(null)' '(null)' + - Close [window_close] + params:'(null)' '(null)' + - Kill [window_kill] + params:'(null)' '(null)' + - Move To Center [window_move_to_center] + params:'(null)' '(null)' + - Move To Coordinates... [window_move_to] + params:'(null)' 'syntax: [+,-]X [+,-]Y or * [+,-]Y or [+,-]X *, example: -1 +1' + - Move By Coordinate Offset... [window_move_by] + params:'(null)' 'syntax: X-offset Y-offset, example: -1 0' + - Resize By... [window_resize_by] + params:'(null)' 'syntax: W H, example: 100 150' + - Push in Direction... [window_push] + params:'(null)' 'syntax: direction, example: up, down, left, right, up-left, up-right, down-left, down-right' + - Drag Icon... [window_drag_icon] + params:'(null)' '(null)' +*** Window : List + - Jump to window... [window_jump_to] + params:'(null)' 'syntax: icccm window name, example: urxvt-mutt' + - Jump to window... or start... [window_jump_to_or_start] + params:'(null)' 'syntax: icccm_window_name application' + - Next Window [winlist] + params:'next' '(null)' + - Previous Window [winlist] + params:'prev' '(null)' + - Next window of same class [winlist] + params:'class-next' '(null)' + - Previous window of same class [winlist] + params:'class-prev' '(null)' + - Next window class [winlist] + params:'classes-next' '(null)' + - Previous window class [winlist] + params:'classes-prev' '(null)' + - Window on the Left [winlist] + params:'left' '(null)' + - Window Down [winlist] + params:'down' '(null)' + - Window Up [winlist] + params:'up' '(null)' + - Window on the Right [winlist] + params:'right' '(null)' +*** Window : Moving + - To Next Desktop [window_desk_move_by] + params:'1 0' '(null)' + - To Previous Desktop [window_desk_move_by] + params:'-1 0' '(null)' + - By Desktop #... [window_desk_move_by] + params:'(null)' 'syntax: X-offset Y-offset, example: -2 2' + - To Desktop... [window_desk_move_to] + params:'(null)' 'syntax: X Y, example: 0 1' + - To Next Screen [window_zone_move_by] + params:'1' '(null)' + - To Previous Screen [window_zone_move_by] + params:'-1' '(null)' +*** Window : State + - Sticky Mode Toggle [window_sticky_toggle] + params:'(null)' '(null)' + - Sticky Mode Enable [window_sticky] + params:'(null)' '(null)' + - Iconic Mode Toggle [window_iconic_toggle] + params:'(null)' '(null)' + - Iconic Mode Enable [window_iconic] + params:'(null)' '(null)' + - Fullscreen Mode Toggle [window_fullscreen_toggle] + params:'(null)' '(null)' + - Fullscreen Mode Enable [window_fullscreen] + params:'(null)' '(null)' + - Maximize [window_maximized_toggle] + params:'(null)' '(null)' + - Maximize Vertically [window_maximized_toggle] + params:'default vertical' '(null)' + - Maximize Horizontally [window_maximized_toggle] + params:'default horizontal' '(null)' + - Maximize Left [window_maximized_toggle] + params:'default left' '(null)' + - Maximize Right [window_maximized_toggle] + params:'default right' '(null)' + - Maximize Fullscreen [window_maximized_toggle] + params:'fullscreen' '(null)' + - Maximize Mode "Smart" [window_maximized_toggle] + params:'smart' '(null)' + - Maximize Mode "Expand" [window_maximized_toggle] + params:'expand' '(null)' + - Maximize Mode "Fill" [window_maximized_toggle] + params:'fill' '(null)' + - Shade Up Mode Toggle [window_shaded_toggle] + params:'up' '(null)' + - Shade Down Mode Toggle [window_shaded_toggle] + params:'down' '(null)' + - Shade Left Mode Toggle [window_shaded_toggle] + params:'left' '(null)' + - Shade Right Mode Toggle [window_shaded_toggle] + params:'right' '(null)' + - Shade Mode Toggle [window_shaded_toggle] + params:'(null)' '(null)' + - Set Shaded State [window_shaded] + params:'(null)' 'syntax: "(0|1) (up|down|left|right)"' + - Toggle Borderless State [window_borderless_toggle] + params:'(null)' '(null)' + - Set Border [window_border_set] + params:'(null)' 'syntax: BorderName, example: pixel' + - Cycle between Borders [window_border_cycle] + params:'(null)' 'syntax: BorderNames, example: default pixel' + - Toggle Pinned State [window_pinned_toggle] + params:'(null)' '(null)' +*/ diff --git a/GADGETS_OLD/actions/images/bg.png b/GADGETS_OLD/actions/images/bg.png new file mode 100644 index 0000000..cfafe22 Binary files /dev/null and b/GADGETS_OLD/actions/images/bg.png differ diff --git a/GADGETS_OLD/actions/images/e_logo.png b/GADGETS_OLD/actions/images/e_logo.png new file mode 100644 index 0000000..6be92d2 Binary files /dev/null and b/GADGETS_OLD/actions/images/e_logo.png differ diff --git a/GADGETS_OLD/amule_control/Makefile b/GADGETS_OLD/amule_control/Makefile new file mode 100644 index 0000000..35ccb5a --- /dev/null +++ b/GADGETS_OLD/amule_control/Makefile @@ -0,0 +1,22 @@ +GADGET_NAME = amule_control + +EDJE_CC = edje_cc +EDJE_FLAGS = -v -id images/ -fd fonts/ + +.PHONY: all install clean + +all: $(GADGET_NAME).edj + +$(GADGET_NAME).edj: $(GADGET_NAME).edc $(GADGET_NAME).embryo images/* + $(EDJE_CC) $(EDJE_FLAGS) $< $@ + +install: all + rm -f ~/.e/e/gadgets/$(GADGET_NAME).edj + cp $(GADGET_NAME).edj ~/.e/e/gadgets/$(GADGET_NAME).edj + +uninstall: all + rm -f ~/.e/e/gadgets/$(GADGET_NAME).edj; + + +clean: + rm -f $(GADGET_NAME).edj diff --git a/GADGETS_OLD/amule_control/amule_control.edc b/GADGETS_OLD/amule_control/amule_control.edc new file mode 100644 index 0000000..b17376a --- /dev/null +++ b/GADGETS_OLD/amule_control/amule_control.edc @@ -0,0 +1,433 @@ +/* Copyright (C) 2008 Davide Andreoli (see AUTHORS) + * + * This file is part of amule_control. + * amule_control is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * amule_control 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with amule_control. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * E17 aMule Control gadget + */ + + +data { + item: "e/gadget/name" "aMule Control"; + item: "e/gadget/description" "Control your aMule deamon"; + item: "e/gadget/version" "0.0.1"; + item: "e/gadget/author" "DaveMDS <dave@gurumeditattion.it>"; + item: "e/gadget/license" "LGPL"; + item: "e/gadget/apparence" "plain"; +} + +images { + image: "amule.png" COMP; + image: "amule_over.png" COMP; + image: "down.png" COMP; + image: "up.png" COMP; + image: "net.png" COMP; + image: "net_kad_green.png" COMP; + image: "net_kad_red.png" COMP; + image: "net_donk_green.png" COMP; + image: "net_donk_red.png" COMP; + image: "bg.png" COMP; + image: "bg_over.png" COMP; +} + +//~ styles { + //~ style { + //~ name: "text_style"; + //~ //base: "font=Sans font_size=10 align=left color=#000 wrap=word"; + //~ base: "font=MARI.TTF font_size=14 align=left color=#000 wrap=word"; + //~ tag: "br" "\n"; + //~ tag: "tab" "\t"; + //~ tag: "title" "+ style=Bold font_size=20 align=center"; + //~ tag: "i" "+ font=Sans:style=Oblique"; + //~ tag: "b" "+ font=Sans:style=Bold"; + //~ tag: "u" "+ underline=on underline_color=#000"; + //~ } +//~ } + +collections { + group { name: "e/gadget/icon"; + parts { + part { name: "icon"; + description { + state: "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + image { + normal: "amule.png"; + } + } + } + } + } + group { name: "e/gadget/main"; + min: 250 100; + max: 250 100; + + #include "amule_control.embryo" + + parts { + part { name: "bg"; + type: IMAGE; + description { state: "default" 0; + // aspect: 2.5 2.5; + // aspect_preference: BOTH; + color: 255 255 255 255; + image { + normal: "bg.png"; + border: 9 9 9 9; + } + } + } + part { name: "icon"; + type: IMAGE; + description { state: "default" 0.0; + color: 255 255 255 100; + rel1 { + relative: 0.0 0.05; + to: "bg"; + } + rel2 { + relative: 0.27 0.65; + offset: 0 0; + to: "bg"; + } + image { + normal: "amule.png"; + } + } + description { state: "connected" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + } + description { state: "over" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + image { + normal: "amule_over.png"; + } + } + } + part { name: "text.status"; + type: TEXT; + effect: PLAIN; + description { state: "default" 0; + color: 0 0 0 255; + rel1 { + relative: 0.230263 0.05; + to: "bg"; + } + rel2 { + relative: 1 0.362205; + to: "bg"; + } + text { + text: "Deamon: stopped"; + font: "Sans"; + size: 14; + align: 0.0 0.0; + } + } + } + part { name: "text.download"; + type: TEXT; + effect: SHADOW; + description { state: "default" 0.0; + visible: 0; + } + description { state: "visible" 0; + rel1 { + relative: 0.35 0.25; + to: "bg"; + } + rel2 { + relative: 1.0 0.40; + to: "bg"; + } + text { + text: "Download: "; + font: "Sans"; + size: 12; + align: 0.0 0.0; + } + } + } + part { name: "download_icon"; + description { state: "default" 0.0; + rel1 { + relative: -0.1 0.2; + to: "text.download"; + } + rel2 { + relative: -0.02 1.2; + to: "text.download"; + } + image { + normal: "down.png"; + } + } + } + part { name: "text.upload"; + type: TEXT; + effect: SHADOW; + description { state: "default" 0.0; + visible: 0; + } + description { state: "visible" 0; + rel1 { + relative: 0.35 0.45; + to: "bg"; + } + rel2 { + relative: 1.0 0.6; + to: "bg"; + } + text { + text: "Upload: "; + font: "Sans"; + size: 12; + align: 0.0 0.0; + } + } + } + part { name: "up_icon"; + description { state: "default" 0.0; + rel1 { + relative: -0.1 0.2; + to: "text.upload"; + } + rel2 { + relative: -0.02 1.2; + to: "text.upload"; + } + image { + normal: "up.png"; + } + } + } + part { name: "text.kad"; + type: TEXT; + description { state: "default" 0.0; + visible: 0; + } + description { state: "visible" 0; + rel1 { + relative: 0.12 0.68; + to: "bg"; + } + rel2 { + relative: 0.98 1.0; + to: "bg"; + } + text { + text: "kad"; + font: "Sans"; + size: 10; + align: 0.0 0.0; + } + } + } + part { name: "text.ed2k"; + type: TEXT; + description { state: "default" 0.0; + visible: 0; + } + description { state: "visible" 0; + rel1 { + relative: 0.12 0.82; + to: "bg"; + } + rel2 { + relative: 0.98 10; + to: "bg"; + } + text { + text: "ed2k"; + font: "Sans"; + size: 10; + align: 0.0 0.0; + } + } + } + part { name: "net_icon"; + type: IMAGE; + description { state: "default" 0.0; + visible: 0; + } + description { state: "visible" 0.0; + visible: 1; + image { + normal: "net.png"; + } + rel1 { + relative: 0.02 0.7; + to: "bg"; + } + rel2 { + relative: 0.12 0.95; + to: "bg"; + } + } + } + part { name: "net_icon_kad"; + type: IMAGE; + description { state: "default" 0.0; + rel1.to: "net_icon"; + rel2.to: "net_icon"; + visible: 0; + } + description { state: "notconnected" 0.0; + inherit: "default" 0.0; + image.normal: "net_kad_red.png"; + visible: 1; + } + description { state: "firewalled" 0.0; + inherit: "default" 0.0; + visible: 0; + } + + description { state: "connected" 0.0; + inherit: "default" 0.0; + image.normal: "net_kad_green.png"; + visible: 1; + } + } + part { name: "net_icon_donk"; + type: IMAGE; + description { state: "default" 0.0; + rel1.to: "net_icon"; + rel2.to: "net_icon"; + visible: 0; + } + description { state: "notconnected" 0.0; + inherit: "default" 0.0; + image.normal: "net_donk_red.png"; + visible: 1; + } + description { state: "firewalled" 0.0; + inherit: "default" 0.0; + visible: 0; + } + description { state: "connected" 0.0; + inherit: "default" 0.0; + image.normal: "net_donk_green.png"; + visible: 1; + } + } + part { name: "button_bg"; + type: IMAGE; + description { state: "default" 0.0; + color: 255 255 255 255; + image { + normal: "bg.png"; + border: 9 9 9 9; + } + rel1 { + relative: 0.1 0.7; + to: "bg"; + } + rel2 { + relative: 0.9 0.95; + to: "bg"; + } + } + description { state: "over" 0.0; + inherit: "default" 0.0; + image { + normal: "bg_over.png"; + border: 9 9 9 9; + } + } + description { state: "hidden" 0.0; + visible: 0; + } + } + part { name: "text.button"; + type: TEXT; + mouse_events: 0; + description { state: "default" 0; + color: 255 255 255 255; + text { + font: "Sans"; + align: 0.5 0.5; + size: 11; + text: "Run aMule Daemon"; + } + rel1 { + + to: "button_bg"; + } + rel2 { + + to: "button_bg"; + } + } + description { state: "hidden" 0; + visible: 0; + } + } + } + programs { + program { name: "init"; + signal: "load"; + source: ""; + script { + init(); + } + } + program { name: "mule_click"; + signal: "mouse,down,1"; + source: "icon"; + script { + start_client(); + } + } + program { name: "run_daemon_click"; + signal: "mouse,down,1"; + source: "button_bg"; + script { + start_deamon(); + } + } + program { name: "button_over_in"; + signal: "mouse,in"; + source: "button_bg"; + action: STATE_SET "over" 0.0; + target: "button_bg"; + } + program { name: "button_over_out"; + signal: "mouse,out"; + source: "button_bg"; + script { + button_out(); + } + } + program { name: "amule_over_in"; + signal: "mouse,in"; + source: "icon"; + script { + icon_in(); + } + } + program { name: "amule_over_out"; + signal: "mouse,out"; + source: "icon"; + script { + icon_out(); + } + } + } + } +} diff --git a/GADGETS_OLD/amule_control/amule_control.embryo b/GADGETS_OLD/amule_control/amule_control.embryo new file mode 100644 index 0000000..58bb939 --- /dev/null +++ b/GADGETS_OLD/amule_control/amule_control.embryo @@ -0,0 +1,238 @@ +/* Copyright (C) 2008 Davide Andreoli (see AUTHORS) + * + * This file is part ofamule_control. + * amule_control is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * amule_control 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with amule_control. If not, see <http://www.gnu.org/licenses/>. + */ +#define EXEC_PID 1 +#define EXEC_GUI 2 +#define EXEC_DEAMON 3 +#define EXEC_CMD_DL 4 +#define EXEC_CMD_UP 5 +#define EXEC_CMD_ED2K 6 +#define EXEC_CMD_KAD 7 + +script { + +public conf_keep_alive = 0; + +public running = 0; +public starting = 0; + +public init() +{ + //send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "aMule Control Init"); + check_mule(); +} + +public check_mule() +{ + //send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "CHK Mule"); + send_message(MSG_STRING_SET, EXEC_PID, "EDGAR_EXEC", "pidof amuled"); + timer(10.0, "check_mule", 0) +} + +public get_info() +{ + if (!get_int(running)) + return; + + send_message(MSG_STRING_SET, EXEC_CMD_DL, "EDGAR_EXEC", + "amulecmd -c Status -P asd | grep Download"); + send_message(MSG_STRING_SET, EXEC_CMD_UP, "EDGAR_EXEC", + "amulecmd -c Status -P asd | grep Upload"); + send_message(MSG_STRING_SET, EXEC_CMD_ED2K, "EDGAR_EXEC", + "amulecmd -c Status -P asd | grep eD2k:"); + send_message(MSG_STRING_SET, EXEC_CMD_KAD, "EDGAR_EXEC", + "amulecmd -c Status -P asd | grep Kad:"); +} + +public start_client() +{ + //send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "RUN MULE"); + send_message(MSG_STRING_SET, EXEC_GUI, "EDGAR_EXEC", "amulegui"); +} + +public start_deamon() +{ + set_text(PART:"text.status", "Deamon: starting..."); + set_state(PART:"button_bg", "hidden", 0.0); + set_state(PART:"text.button", "hidden", 0.0); + set_int(starting, 1); + send_message(MSG_STRING_SET, EXEC_DEAMON, "EDGAR_EXEC", "amuled"); +} + +public button_out() +{ + if (!get_int(running) && !get_int(starting)) + set_state(PART:"button_bg", "default", 0.0); +} + +public icon_in() +{ + if (get_int(running)) + set_state(PART:"icon", "over", 0.0); +} + +public icon_out() +{ + if (get_int(running)) + set_state(PART:"icon", "connected", 0.0); +} + +public set_running() +{ + set_int(running, 1); + set_int(starting, 0); + set_text(PART:"text.status", "Deamon: running"); + set_state(PART:"icon", "connected", 0.0); + set_state(PART:"button_bg", "hidden", 0.0); + set_state(PART:"text.download", "visible", 0.0); + set_state(PART:"text.upload", "visible", 0.0); + set_state(PART:"text.ed2k", "visible", 0.0); + set_state(PART:"text.kad", "visible", 0.0); + set_state(PART:"net_icon", "visible", 0.0); + set_state(PART:"text.button", "hidden", 0.0); +} + +public set_notrunning() +{ + set_int(running, 0); + set_int(starting, 0); + set_text(PART:"text.status", "Deamon: stopped"); + set_state(PART:"icon", "default", 0.0); + set_state(PART:"text.download", "default", 0.0); + set_state(PART:"text.upload", "default", 0.0); + set_state(PART:"text.ed2k", "default", 0.0); + set_state(PART:"text.kad", "default", 0.0); + set_state(PART:"button_bg", "default", 0.0); + set_state(PART:"net_icon", "default", 0.0); + set_state(PART:"text.button", "default", 0.0); + set_state(PART:"net_icon_donk", "default", 0.0) + set_state(PART:"net_icon_kad", "default", 0.0) +} + +public message(Msg_Type:type, id, ...) +{ + new cmd[32]; + new key[32]; + new val[2048]; //TODO if this is too big (> 4000) something goes wrong + + if ((type != MSG_STRING_SET)) return; + getsarg(2, cmd, sizeof(cmd)); + + + if (strcmp(cmd, "EDGAR_CONF_GET_REPLY") == 0) + { + getsarg(3, key, sizeof(key)); + getsarg(4, val, sizeof(val)); + } + else if (strcmp(cmd, "EDGAR_EXEC_REPLY") == 0) + { + if (id == EXEC_PID) + { + getsarg(3, key, sizeof(key)); + if (strcmp(key, "OK") == 0) + { + getsarg(4, val, sizeof(val)); + set_running(); + get_info(); + } + else + { + if (conf_keep_alive == 1) + start_deamon(); + else + set_notrunning(); + } + } + else if (id == EXEC_CMD_DL) + { + getsarg(3, key, sizeof(key)); + if (strcmp(key, "OK") == 0) + { + getsarg(4, val, sizeof(val)); + set_text(PART:"text.download", val[strrchr(val, "\t") + 1]); + } + else + { + send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "AMULECMD DL ERROR"); + set_text(PART:"text.download", "???"); + } + } + else if (id == EXEC_CMD_UP) + { + getsarg(3, key, sizeof(key)); + if (strcmp(key, "OK") == 0) + { + getsarg(4, val, sizeof(val)); + set_text(PART:"text.upload", val[strrchr(val, "\t") + 1]); + } + else + { + set_text(PART:"text.upload", "???"); + } + } + else if (id == EXEC_CMD_ED2K) + { + getsarg(3, key, sizeof(key)); + if (strcmp(key, "OK") == 0) + { + getsarg(4, val, sizeof(val)); + set_text(PART:"text.ed2k", val[2]); + if (strstr(val, "irewalled") != -1) // case-insensitive :P + set_state(PART:"net_icon_donk", "firewalled", 0.0) + else if (strstr(val, "Connected") != -1) + set_state(PART:"net_icon_donk", "connected", 0.0) + else + set_state(PART:"net_icon_donk", "notconnected", 0.0) + } + else + { + set_text(PART:"text.upload", "???"); + set_state(PART:"net_icon_donk", "default", 0.0) + } + } + else if (id == EXEC_CMD_KAD) + { + getsarg(3, key, sizeof(key)); + if (strcmp(key, "OK") == 0) + { + getsarg(4, val, sizeof(val)); + set_text(PART:"text.kad", val[2]); + if (strstr(val, "irewalled") != -1) + set_state(PART:"net_icon_kad", "firewalled", 0.0) + else if (strstr(val, "Connected") != -1) + set_state(PART:"net_icon_kad", "connected", 0.0) + else + set_state(PART:"net_icon_kad", "notconnected", 0.0) + } + else + { + set_text(PART:"text.upload", "???"); + set_state(PART:"net_icon_kad", "default", 0.0) + } + } + else if (id == EXEC_GUI) + { + //send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "Gui terminated", key, val); + } + else if (id == EXEC_DEAMON) + { + //send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "Deamon terminated", key, val); + } + } + +} + +} diff --git a/GADGETS_OLD/amule_control/images/amule.png b/GADGETS_OLD/amule_control/images/amule.png new file mode 100644 index 0000000..a001ec4 Binary files /dev/null and b/GADGETS_OLD/amule_control/images/amule.png differ diff --git a/GADGETS_OLD/amule_control/images/amule.xcf b/GADGETS_OLD/amule_control/images/amule.xcf new file mode 100644 index 0000000..b2e77e8 Binary files /dev/null and b/GADGETS_OLD/amule_control/images/amule.xcf differ diff --git a/GADGETS_OLD/amule_control/images/amule_over.png b/GADGETS_OLD/amule_control/images/amule_over.png new file mode 100644 index 0000000..64e97fc Binary files /dev/null and b/GADGETS_OLD/amule_control/images/amule_over.png differ diff --git a/GADGETS_OLD/amule_control/images/bg.png b/GADGETS_OLD/amule_control/images/bg.png new file mode 100644 index 0000000..cfafe22 Binary files /dev/null and b/GADGETS_OLD/amule_control/images/bg.png differ diff --git a/GADGETS_OLD/amule_control/images/bg_over.png b/GADGETS_OLD/amule_control/images/bg_over.png new file mode 100644 index 0000000..9dabd0e Binary files /dev/null and b/GADGETS_OLD/amule_control/images/bg_over.png differ diff --git a/GADGETS_OLD/amule_control/images/down.png b/GADGETS_OLD/amule_control/images/down.png new file mode 100644 index 0000000..0b57dc8 Binary files /dev/null and b/GADGETS_OLD/amule_control/images/down.png differ diff --git a/GADGETS_OLD/amule_control/images/net.png b/GADGETS_OLD/amule_control/images/net.png new file mode 100644 index 0000000..6c25172 Binary files /dev/null and b/GADGETS_OLD/amule_control/images/net.png differ diff --git a/GADGETS_OLD/amule_control/images/net.xcf b/GADGETS_OLD/amule_control/images/net.xcf new file mode 100644 index 0000000..1c2d6b8 Binary files /dev/null and b/GADGETS_OLD/amule_control/images/net.xcf differ diff --git a/GADGETS_OLD/amule_control/images/net_donk_green.png b/GADGETS_OLD/amule_control/images/net_donk_green.png new file mode 100644 index 0000000..1648e32 Binary files /dev/null and b/GADGETS_OLD/amule_control/images/net_donk_green.png differ diff --git a/GADGETS_OLD/amule_control/images/net_donk_red.png b/GADGETS_OLD/amule_control/images/net_donk_red.png new file mode 100644 index 0000000..e798fcc Binary files /dev/null and b/GADGETS_OLD/amule_control/images/net_donk_red.png differ diff --git a/GADGETS_OLD/amule_control/images/net_kad_green.png b/GADGETS_OLD/amule_control/images/net_kad_green.png new file mode 100644 index 0000000..a96b17e Binary files /dev/null and b/GADGETS_OLD/amule_control/images/net_kad_green.png differ diff --git a/GADGETS_OLD/amule_control/images/net_kad_red.png b/GADGETS_OLD/amule_control/images/net_kad_red.png new file mode 100644 index 0000000..fee700c Binary files /dev/null and b/GADGETS_OLD/amule_control/images/net_kad_red.png differ diff --git a/GADGETS_OLD/amule_control/images/up.png b/GADGETS_OLD/amule_control/images/up.png new file mode 100644 index 0000000..b32fb09 Binary files /dev/null and b/GADGETS_OLD/amule_control/images/up.png differ diff --git a/GADGETS_OLD/postit/Makefile b/GADGETS_OLD/postit/Makefile new file mode 100644 index 0000000..ec2a64f --- /dev/null +++ b/GADGETS_OLD/postit/Makefile @@ -0,0 +1,22 @@ +GADGET_NAME = postit + +EDJE_CC = edje_cc +EDJE_FLAGS = -v -id images/ -fd fonts/ + +.PHONY: all install clean + +all: $(GADGET_NAME).edj + +$(GADGET_NAME).edj: $(GADGET_NAME).edc $(GADGET_NAME).embryo images/* + $(EDJE_CC) $(EDJE_FLAGS) $< $@ + +install: all + rm -f ~/.e/e/gadgets/$(GADGET_NAME).edj + cp $(GADGET_NAME).edj ~/.e/e/gadgets/$(GADGET_NAME).edj + +uninstall: all + rm -f ~/.e/e/gadgets/$(GADGET_NAME).edj; + + +clean: + rm -f $(GADGET_NAME).edj diff --git a/GADGETS_OLD/postit/fonts/ANMARI.TTF b/GADGETS_OLD/postit/fonts/ANMARI.TTF new file mode 100644 index 0000000..5658c13 Binary files /dev/null and b/GADGETS_OLD/postit/fonts/ANMARI.TTF differ diff --git a/GADGETS_OLD/postit/fonts/ANMARI.txt b/GADGETS_OLD/postit/fonts/ANMARI.txt new file mode 100644 index 0000000..779b99f --- /dev/null +++ b/GADGETS_OLD/postit/fonts/ANMARI.txt @@ -0,0 +1,39 @@ + +ANTAVIANA TYPEFACE DIVISION +___________________________ + +http://www.astramat.com/typeface +e-mail: typeface@astramat.com + info@antaviana.com + + + +Antaviana Typeface Division distributes freely this font, +but you must be aware that this typeface is PUBLISHWARE. + + +What is PUBLISHWARE? + +Publishware consists in the fact that the user must sent +a copy of each work where it appears (in paper, CD-ROM or +any other support) to the creators of this font. +The address where the copy should be send is: + +ANTAVIANA SERVEIS INTERACTIUS, SCCL +(Typeface Division) +Santa Justina, 29 +25400 Les Borges Blanques +Lleida +Spain + +In case of using this typeface in a web, you just have to send the URL +by e-mail to + + typeface@astramat.com + +© Antaviana Serveis Interactius, SCCL +Typeface Division + +http://www.astramat.com/typeface +e-mail: typeface@astramat.com + info@antaviana.com diff --git a/GADGETS_OLD/postit/fonts/BRINGTHANOIZE.TTF b/GADGETS_OLD/postit/fonts/BRINGTHANOIZE.TTF new file mode 100644 index 0000000..b7b375c Binary files /dev/null and b/GADGETS_OLD/postit/fonts/BRINGTHANOIZE.TTF differ diff --git a/GADGETS_OLD/postit/fonts/BRINGTHANOIZE.txt b/GADGETS_OLD/postit/fonts/BRINGTHANOIZE.txt new file mode 100644 index 0000000..426d08e --- /dev/null +++ b/GADGETS_OLD/postit/fonts/BRINGTHANOIZE.txt @@ -0,0 +1,14 @@ +Thank you for downloading this font! + +This font is copyright (c) Jakob Fischer at www.pizzadude.dk, all rights reserved. Do not distribute without the author's permission. + +Use this font for non-commercial use only! If you plan to use it for commercial purposes, contact me before doing so! + + +For more original fonts take a look at www.pizzadude.dk + +Have fun and enjoy! + +Jakob Fischer +jakob@pizzadude.dk +www.pizzadude.dk \ No newline at end of file diff --git a/GADGETS_OLD/postit/images/icon.png b/GADGETS_OLD/postit/images/icon.png new file mode 100644 index 0000000..e228f54 Binary files /dev/null and b/GADGETS_OLD/postit/images/icon.png differ diff --git a/GADGETS_OLD/postit/images/postit.png b/GADGETS_OLD/postit/images/postit.png new file mode 100644 index 0000000..d0895f5 Binary files /dev/null and b/GADGETS_OLD/postit/images/postit.png differ diff --git a/GADGETS_OLD/postit/postit.edc b/GADGETS_OLD/postit/postit.edc new file mode 100644 index 0000000..3506994 --- /dev/null +++ b/GADGETS_OLD/postit/postit.edc @@ -0,0 +1,182 @@ +/* Copyright (C) 2008 Davide Andreoli (see AUTHORS) + * + * This file is part of Postit. + * Postit. is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Postit. 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Postit. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * E17 Postit Gadget + */ + +/** + * TODO + * + * TODOC emit("API:DBG", "ciccio"); + * + */ + +data { + item: "e/gadget/name" "PostIt"; + item: "e/gadget/description" "Simple stickies on your desktop"; + item: "e/gadget/version" "0.0.1"; + item: "e/gadget/author" "DaveMDS <dave@gurumeditattion.it>"; + item: "e/gadget/license" "LGPL"; + item: "e/gadget/apparence" "plain"; +} + +images { + image: "postit.png" COMP; + image: "icon.png" COMP; +} + +fonts { + font: "BRINGTHANOIZE.TTF" "BTN.TTF"; + font: "ANMARI.TTF" "MARI.TTF"; +} + +styles { + style { + name: "text_style"; + //base: "font=Sans font_size=10 align=left color=#000 wrap=word"; + base: "font=MARI.TTF font_size=14 align=left color=#000 wrap=word"; + tag: "br" "\n"; + tag: "tab" "\t"; + tag: "title" "+ style=Bold font_size=20 align=center"; + tag: "i" "+ font=Sans:style=Oblique"; + tag: "b" "+ font=Sans:style=Bold"; + tag: "u" "+ underline=on underline_color=#000"; + } +} + +collections { + group { name: "e/gadget/icon"; + parts { + part { name: "icon"; + description { + state: "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + image { + normal: "icon.png"; + } + } + } + } + } + group { name: "e/gadget/main"; + min: 100 100; + max: 300 300; + script { + #include "postit.embryo" + } + parts { + part { name: "bg"; + description { state: "default" 0.0; + image { + normal: "postit.png"; + border: 1 12 30 12; + } + } + } + part { name: "textblock"; + type: TEXTBLOCK; + entry_mode: EDITABLE; + multiline: 1; + source: "e/gadget/selection"; //selection under + source4: "e/gadget/cursor"; //cursor over + description { state: "default" 0.0; + text { + text: "Put your note here"; + style: "text_style"; + } + rel1 { + offset: 5 35; + } + } + } + } + programs { + program { name: "init"; + signal: "load"; + source: ""; + script { + init(); + } + } + program { name: "focus"; + signal: "load"; + source: ""; + action: FOCUS_SET; + target: "textblock"; + } + program { name: "focus_out"; + signal: "mouse,down,1"; + source: "textblock"; + script { + save(); + } + } + } + } + group { name: "e/gadget/selection"; + parts { + part {name: "bg"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + color: 128 128 128 128; + } + } + } + } + group { name: "e/gadget/cursor"; + parts { + part { name: "cur"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + color: 0 0 0 255; + rel2 { + relative: 0.0 1.0; + offset: 0 -1; + } + } + description { state: "blink" 0.0; + color: 0 0 0 0; + rel2 { + relative: 0.0 1.0; + offset: 0 -1; + } + } + } + } + programs { + program { name: "blink"; + signal: "load"; + source: "*"; + in: 1.5 0; + action: STATE_SET "blink" 0.0; + transition: LINEAR 0.5; + target: "cur"; + after: "blink2"; + } + program { name: "blink2"; + action: STATE_SET "default" 0.0; + transition: LINEAR 0.5; + target: "cur"; + after: "blink"; + } + } + } +} diff --git a/GADGETS_OLD/postit/postit.embryo b/GADGETS_OLD/postit/postit.embryo new file mode 100644 index 0000000..6d32fd4 --- /dev/null +++ b/GADGETS_OLD/postit/postit.embryo @@ -0,0 +1,66 @@ +/* Copyright (C) 2008 Davide Andreoli (see AUTHORS) + * + * This file is part of Postit. + * Postit. is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Postit. 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Postit. If not, see <http://www.gnu.org/licenses/>. + */ + + +public init() +{ +// send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "Postit Init"); + + //Try some message with errors +// send_message(MSG_STRING_SET, 0, "EDGAR_GF"); +// send_message(MSG_STRING_SET, 0, "EDGAR_"); +// send_message(MSG_STRING_SET, 0, "EDGAR"); +// send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "", ""); + + /* Get a saved memo */ + //send_message(MSG_STRING_SET, 0, "EDGAR_CONF_GET", "postit/memo"); + send_message(MSG_STRING_SET, 0, "EDGAR_ID_GET"); +} + +public save() +{ + send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "Postit save"); + new memo[2048]; + + get_text(PART:"textblock", memo, 2048); + send_message(MSG_STRING_SET, 0, "EDGAR_CONF_SET", "postit/memo", memo); +} + +public message(Msg_Type:type, id, ...) +{ + new cmd[32]; + new key[32]; + new val[2048]; //TODO if this is too big (> 4000) something goes wrong + + if ((type != MSG_STRING_SET)) return; + getsarg(2, cmd, sizeof(cmd)); + + //send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "message()", cmd); + + if (strcmp(cmd, "EDGAR_CONF_GET_REPLY") == 0) + { + getsarg(3, key, sizeof(key)); + getsarg(4, val, sizeof(val)); + + set_text(PART:"textblock", val); + } + else if (strcmp(cmd, "EDGAR_ID_GET_REPLY") == 0) + { + getsarg(3, val, sizeof(val)); + set_text(PART:"textblock", val); + } +} diff --git a/GADGETS_OLD/top5/Makefile b/GADGETS_OLD/top5/Makefile new file mode 100644 index 0000000..6259ca6 --- /dev/null +++ b/GADGETS_OLD/top5/Makefile @@ -0,0 +1,22 @@ +GADGET_NAME = top5 + +EDJE_CC = edje_cc +EDJE_FLAGS = -v -id images/ -fd fonts/ + +.PHONY: all install clean + +all: $(GADGET_NAME).edj + +$(GADGET_NAME).edj: $(GADGET_NAME).edc $(GADGET_NAME).embryo images/* + $(EDJE_CC) $(EDJE_FLAGS) $< $@ + +install: all + rm -f ~/.e/e/gadgets/$(GADGET_NAME).edj + cp $(GADGET_NAME).edj ~/.e/e/gadgets/$(GADGET_NAME).edj + +uninstall: all + rm -f ~/.e/e/gadgets/$(GADGET_NAME).edj; + + +clean: + rm -f $(GADGET_NAME).edj diff --git a/GADGETS_OLD/top5/images/bg.png b/GADGETS_OLD/top5/images/bg.png new file mode 100644 index 0000000..cfafe22 Binary files /dev/null and b/GADGETS_OLD/top5/images/bg.png differ diff --git a/GADGETS_OLD/top5/images/e_logo.png b/GADGETS_OLD/top5/images/e_logo.png new file mode 100644 index 0000000..6be92d2 Binary files /dev/null and b/GADGETS_OLD/top5/images/e_logo.png differ diff --git a/GADGETS_OLD/top5/top5.edc b/GADGETS_OLD/top5/top5.edc new file mode 100644 index 0000000..294ff5c --- /dev/null +++ b/GADGETS_OLD/top5/top5.edc @@ -0,0 +1,195 @@ +/* Copyright (C) 2008 Davide Andreoli (see AUTHORS) + * + * This file is part of top5. + * top5 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * top5 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with top5. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * E17 Top Process Viewer + */ + + +data { + item: "e/gadget/name" "Top5"; + item: "e/gadget/description" "Keep your process under control"; + item: "e/gadget/version" "0.0.1"; + item: "e/gadget/author" "DaveMDS <dave@gurumeditattion.it>"; + item: "e/gadget/license" "LGPL"; + item: "e/gadget/apparence" "plain"; +} + +images { + image: "bg.png" COMP; + image: "e_logo.png" COMP; +} + +collections { + group { name: "e/gadget/icon"; + parts { + part { name: "icon"; + description { + state: "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + image { + normal: "bg.png"; + } + } + } + } + } + group { name: "e/gadget/main"; + min: 150 100; + max: 450 100; + + #include "top5.embryo" + + parts { + part { name: "bg"; + type: IMAGE; + description { state: "default" 0; + color: 255 255 255 255; + image { + normal: "bg.png"; + border: 9 9 9 9; + } + } + } + part { name: "logo"; + type: IMAGE; + description { state: "default" 0; + min: 180 90; + max: 180 90; + color: 255 255 255 255; + rel1 { + offset: 0 5; + to: "bg"; + } + image { + normal: "e_logo.png"; + } + } + } + part { name: "text.line1"; + type: TEXT; + effect: PLAIN; + description { state: "default" 0; + color: 255 255 255 255; + rel1 { + offset: 10 8; + to: "bg"; + } + rel2 { + to: "bg"; + } + text { + text: "CIAO"; + font: "Sans"; + size: 12; + align: 0.0 0.0; + } + } + } + part { name: "text.line2"; + type: TEXT; + effect: PLAIN; + description { state: "default" 0; + color: 255 255 255 255; + rel1 { + offset: 10 23; + to: "bg"; + } + rel2 { + to: "bg"; + } + text { + text: "CIAO2"; + font: "Sans"; + size: 12; + align: 0.0 0.0; + } + } + } + part { name: "text.line3"; + type: TEXT; + effect: PLAIN; + description { state: "default" 0; + color: 255 255 255 255; + rel1 { + offset: 10 38; + to: "bg"; + } + rel2 { + to: "bg"; + } + text { + text: "CIAO 3"; + font: "Sans"; + size: 12; + align: 0.0 0.0; + } + } + } + part { name: "text.line4"; + type: TEXT; + effect: PLAIN; + description { state: "default" 0; + color: 255 255 255 255; + rel1 { + offset: 10 53; + to: "bg"; + } + rel2 { + to: "bg"; + } + text { + text: "CIAO 4"; + font: "Sans"; + size: 12; + align: 0.0 0.0; + } + } + } + part { name: "text.line5"; + type: TEXT; + effect: PLAIN; + description { state: "default" 0; + color: 255 255 255 255; + rel1 { + offset: 10 68; + to: "bg"; + } + rel2 { + to: "bg"; + } + text { + text: "CIAO 5"; + font: "Sans"; + size: 12; + align: 0.0 0.0; + } + } + } + } + programs { + program { name: "init"; + signal: "load"; + source: ""; + script { + init(); + } + } + } + } +} diff --git a/GADGETS_OLD/top5/top5.embryo b/GADGETS_OLD/top5/top5.embryo new file mode 100644 index 0000000..0edf3c6 --- /dev/null +++ b/GADGETS_OLD/top5/top5.embryo @@ -0,0 +1,71 @@ +/* Copyright (C) 2008 Davide Andreoli (see AUTHORS) + * + * This file is part top5. + * top5 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * top5 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with top5. If not, see <http://www.gnu.org/licenses/>. + */ + +#define PS_CMD "ps --sort=-pcpu axo pcpu,comm --no-headers |head -n 5" +#define DELAY 2 + + +script { + + +public line = 1; + +public init() +{ + send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "Top5 Init"); + update(); +} + +public update() +{ + set_int(line, 1); + send_message(MSG_STRING_SET, 0, "EDGAR_EXEC", PS_CMD); + timer(DELAY, "update", 0); +} + +public message(Msg_Type:type, id, ...) +{ + new cmd[32]; + new key[32]; + new val[2048]; //TODO if this is too big (> 4000) something goes wrong + + if ((type != MSG_STRING_SET)) return; + getsarg(2, cmd, sizeof(cmd)); + + //send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "MSG CMD", cmd); + + if (strcmp(cmd, "EDGAR_EXEC_DATA") == 0) + { + getsarg(3, val, sizeof(val)); + + if (get_int(line) == 1) set_text(PART:"text.line1", val); + if (get_int(line) == 2) set_text(PART:"text.line2", val); + if (get_int(line) == 3) set_text(PART:"text.line3", val); + if (get_int(line) == 4) set_text(PART:"text.line4", val); + if (get_int(line) == 5) set_text(PART:"text.line5", val); + set_int(line, get_int(line) + 1); + } + else if (strcmp(cmd, "EDGAR_EXEC_REPLY") == 0) + { + getsarg(3, key, sizeof(key)) + getsarg(4, val, sizeof(val)); + //send_message(MSG_STRING_SET, 0, "EDGAR_DBG", "Command end", key, val); + set_int(line, 1); + } +} + +} diff --git a/GADGETS_OLD/wiki_images/gadgets_amule01.jpg b/GADGETS_OLD/wiki_images/gadgets_amule01.jpg new file mode 100644 index 0000000..930ec46 Binary files /dev/null and b/GADGETS_OLD/wiki_images/gadgets_amule01.jpg differ diff --git a/GADGETS_OLD/wiki_images/gadgets_amule02.jpg b/GADGETS_OLD/wiki_images/gadgets_amule02.jpg new file mode 100644 index 0000000..05021a7 Binary files /dev/null and b/GADGETS_OLD/wiki_images/gadgets_amule02.jpg differ diff --git a/GADGETS_OLD/wiki_images/gadgets_calculator.jpg b/GADGETS_OLD/wiki_images/gadgets_calculator.jpg new file mode 100644 index 0000000..6b181e6 Binary files /dev/null and b/GADGETS_OLD/wiki_images/gadgets_calculator.jpg differ diff --git a/GADGETS_OLD/wiki_images/gadgets_clock.jpg b/GADGETS_OLD/wiki_images/gadgets_clock.jpg new file mode 100644 index 0000000..471bd08 Binary files /dev/null and b/GADGETS_OLD/wiki_images/gadgets_clock.jpg differ diff --git a/GADGETS_OLD/wiki_images/gadgets_led.jpg b/GADGETS_OLD/wiki_images/gadgets_led.jpg new file mode 100644 index 0000000..d113a8d Binary files /dev/null and b/GADGETS_OLD/wiki_images/gadgets_led.jpg differ diff --git a/GADGETS_OLD/wiki_images/gadgets_ruler.jpg b/GADGETS_OLD/wiki_images/gadgets_ruler.jpg new file mode 100644 index 0000000..749e7a0 Binary files /dev/null and b/GADGETS_OLD/wiki_images/gadgets_ruler.jpg differ diff --git a/GADGETS_OLD/wiki_images/gadgets_top5.jpg b/GADGETS_OLD/wiki_images/gadgets_top5.jpg new file mode 100644 index 0000000..0b9a962 Binary files /dev/null and b/GADGETS_OLD/wiki_images/gadgets_top5.jpg differ diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..d3c5b40 --- /dev/null +++ b/INSTALL @@ -0,0 +1,237 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007 Free Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 6. Often, you can also type `make uninstall' to remove the installed + files again. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + +Installation Names +================== + +By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..c7f07c4 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,25 @@ +ACLOCAL_AMFLAGS = -I m4 +MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \ + config.sub configure depcomp install-sh ltmain.sh \ + missing module.desktop config.rpath mkinstalldirs + +SUBDIRS = src python + +EDJE_FLAGS = -v \ + -id $(top_srcdir) + +filesdir = $(datadir) +files_DATA = module.desktop e-module-edgar.edj + +EXTRA_DIST = module.desktop.in \ + module_icon.png \ + e-module-edgar.edc + +%.edj: %.edc + $(EDJE_CC) $(EDJE_FLAGS) $< $@ + +clean-local: + rm -rf e-module-edgar.edj module.desktop *~ + +uninstall: + rm -rf $(DESTDIR)$(datadir) diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..b823ce8 --- /dev/null +++ b/README @@ -0,0 +1,4 @@ +Edgar Gadget Loader + +This module load python gadgets in enlightenments. + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..31ccda0 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +rm -rf autom4te.cache +rm -f aclocal.m4 ltmain.sh + +touch README + +echo "Running aclocal..." ; aclocal -I m4 $ACLOCAL_FLAGS || exit 1 +echo "Running autoheader..." ; autoheader || exit 1 +echo "Running autoconf..." ; autoconf || exit 1 +echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1 +echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1 + +if [ -z "$NOCONFIGURE" ]; then + ./configure "$@" +fi diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..831fce3 --- /dev/null +++ b/configure.ac @@ -0,0 +1,79 @@ +dnl Process this file with autoconf to produce a configure script. + +# get rid of that stupid cache mechanism +rm -f config.cache + +AC_INIT(edgar, 0.2.0, dave@gurumeditation.it) +AC_PREREQ(2.52) +AC_CONFIG_SRCDIR(configure.ac) +AC_CANONICAL_BUILD +AC_CANONICAL_HOST +AC_ISC_POSIX + +AM_INIT_AUTOMAKE(1.8) +AM_CONFIG_HEADER(config.h) + +AC_PROG_CC +AM_PROG_CC_STDC +AC_HEADER_STDC +AC_C_CONST +AC_C___ATTRIBUTE__ + +define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])dnl +define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl +AC_PROG_LIBTOOL + +#AM_GNU_GETTEXT([external]) +#AM_GNU_GETTEXT_VERSION(0.14) + +release=$(pkg-config --variable=release enlightenment) +MODULE_ARCH="$host_os-$host_cpu-$release" +AC_SUBST(MODULE_ARCH) +AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture") + +# Find edje_cc +PKG_CHECK_MODULES(EDJE, [edje >= 0.5.0]) +AC_ARG_WITH(edje-cc, + AC_HELP_STRING([--with-edje-cc=PATH], [specify a specific path to edje_cc]), + [ + v=$withval; + EDJE_CC=$v + ],[ + EDJE_CC=$(pkg-config --variable=prefix edje)/bin/edje_cc + ] +) +AC_SUBST(EDJE_CC) +AC_MSG_CHECKING([Which edje_cc to use]) +AC_MSG_RESULT(${EDJE_CC}) + +# Check enlightenment version +PKG_CHECK_MODULES(E, [enlightenment >= 0.19], + [AC_DEFINE([HAVE_E19], [1], [Have at least E19])], + [PKG_CHECK_MODULES(E, [enlightenment >= 0.17])] +) + +# Explicit link to Eo +PKG_CHECK_MODULES(EO, [eo]) + +# Check for python3 and required modules +PKG_CHECK_MODULES(PYTHON3, [python3 >= 3.2]) +AX_PYTHON3_MODULE(efl, "required") +AX_PYTHON3_MODULE(dbus, "required") + + + +datadir=$(pkg-config --variable=modules enlightenment)/${PACKAGE} + +AC_ARG_ENABLE(homedir-install, + AS_HELP_STRING([--enable-homedir-install], [Install module in homedir]), + [ datadir="${HOME}/.e/e/modules/${PACKAGE}" ] +) + + +AC_OUTPUT([ +Makefile +src/Makefile +python/Makefile +module.desktop +], [ +]) diff --git a/e-module-edgar.edc b/e-module-edgar.edc new file mode 100644 index 0000000..3a82f76 --- /dev/null +++ b/e-module-edgar.edc @@ -0,0 +1,21 @@ +images +{ + image: "module_icon.png" COMP; +} + +collections +{ + group { name: "icon"; + max: 24 24; + parts + { + part { name: "image"; + mouse_events: 0; + type: IMAGE; + description { state: "default" 0.0; + image.normal: "module_icon.png"; + } + } + } + } +} diff --git a/m4/ac_attribute.m4 b/m4/ac_attribute.m4 new file mode 100644 index 0000000..46c1a42 --- /dev/null +++ b/m4/ac_attribute.m4 @@ -0,0 +1,14 @@ + +AC_DEFUN([AC_C___ATTRIBUTE__], +[ + AC_MSG_CHECKING(for __attribute__) + AC_CACHE_VAL(ac_cv___attribute__, [ + AC_TRY_COMPILE([#include <stdlib.h>], + [int func(int x); int foo(int x __attribute__ ((unused))) { exit(1); }], + ac_cv___attribute__=yes, ac_cv___attribute__=no)]) + if test "$ac_cv___attribute__" = "yes"; then + AC_DEFINE(HAVE___ATTRIBUTE__, 1, [Define to 1 if your compiler has __attribute__]) + fi + AC_MSG_RESULT($ac_cv___attribute__) +]) + diff --git a/m4/ax_python_module.m4 b/m4/ax_python_module.m4 new file mode 100644 index 0000000..559b569 --- /dev/null +++ b/m4/ax_python_module.m4 @@ -0,0 +1,50 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_python_module.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PYTHON3_MODULE(modname[, fatal]) +# +# DESCRIPTION +# +# Checks for Python3 module. +# +# If fatal is non-empty then absence of a module will trigger an error. +# +# LICENSE +# +# Copyright (c) 2008 Andrew Collier +# +# 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. + +#serial 6 + +AU_ALIAS([AC_PYTHON3_MODULE], [AX_PYTHON3_MODULE]) +AC_DEFUN([AX_PYTHON3_MODULE],[ + # if test -z $PYTHON; + # then + # PYTHON="python" + # fi + PYTHON="python3" + PYTHON_NAME=`basename $PYTHON` + AC_MSG_CHECKING($PYTHON_NAME module: $1) + $PYTHON -c "import $1" 2>/dev/null + if test $? -eq 0; + then + AC_MSG_RESULT(yes) + eval AS_TR_CPP(HAVE_PYMOD_$1)=yes + else + AC_MSG_RESULT(no) + eval AS_TR_CPP(HAVE_PYMOD_$1)=no + # + if test -n "$2" + then + AC_MSG_ERROR(failed to find required python3 module $1) + exit 1 + fi + fi +]) diff --git a/module.desktop.in b/module.desktop.in new file mode 100644 index 0000000..1b9afa4 --- /dev/null +++ b/module.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Link +Name=Edgar Gadget Loader +Name[cs]=Loader gadgetů Edgar +Icon=e-module-edgar +Comment=<title>Edgar Gadget Loader
Load simple edje files as E17 gadgets. +Comment[cs]=Loader gadgetů Edgar
Umožňuje použít edje soubory jako E17 gadgety. +X-Enlightenment-ModuleType=core diff --git a/module_icon.png b/module_icon.png new file mode 100644 index 0000000..425902a Binary files /dev/null and b/module_icon.png differ diff --git a/python/Makefile.am b/python/Makefile.am new file mode 100644 index 0000000..aa9f651 --- /dev/null +++ b/python/Makefile.am @@ -0,0 +1,6 @@ +MAINTAINERCLEANFILES = Makefile.in + +edgarpy_base = e.py +edgarpydir = $(libdir)/enlightenment/gadgets +edgarpy_DATA = $(edgarpy_base) +EXTRA_DIST = $(edgarpy_base) diff --git a/python/e.py b/python/e.py new file mode 100644 index 0000000..fc361b5 --- /dev/null +++ b/python/e.py @@ -0,0 +1,69 @@ +# This python file use the following encoding: utf-8 + +from eapi import ( + theme_edje_object_set # (edje_object, 'gadget_name', 'group_name') +) + + +class Gadget(object): + """ Class doc """ + + __gadget_name__ = 'Unnamed' + __gadget_vers__ = '0.0' + __gadget_auth__ = 'Your name' + __gadget_mail__ = 'author@email.your' + __gadget_desc__ = 'Long gadget description.' + __gadget_vapi__ = 0 + + + def __init__(self): + """ Class initialiser """ + self._instances = list() + self._popups = list() + + def instance_created(self, obj, site): + """ TODO DOC """ + self._instances.append(obj) + + def instance_destroyed(self, obj): + """ TODO DOC """ + self._instances.remove(obj) + + def instance_orient(self, obj, generic, specific): + """ TODO DOC """ + pass + + def popup_created(self, obj): + """ TODO DOC """ + self._popups.append(obj) + + def popup_destroyed(self, obj): + """ TODO DOC """ + ################################### + # self._popups.remove(popup) #### ARGHHHH !! popup is already deleted in py eo :( + self._popups = [] #### for now just clear the list... + + +""" TODO DOC """ +E_GADCON_SITE_UNKNOWN = 0 +E_GADCON_SITE_SHELF = 1 +E_GADCON_SITE_DESKTOP = 2 +E_GADCON_SITE_TOOLBAR = 3 +E_GADCON_SITE_EFM_TOOLBAR = 4 + +""" TODO DOC """ +E_GADCON_ORIENT_FLOAT = 0 +E_GADCON_ORIENT_HORIZ = 1 +E_GADCON_ORIENT_VERT = 2 +E_GADCON_ORIENT_LEFT = 3 +E_GADCON_ORIENT_RIGHT = 4 +E_GADCON_ORIENT_TOP = 5 +E_GADCON_ORIENT_BOTTOM = 6 +E_GADCON_ORIENT_CORNER_TL = 7 +E_GADCON_ORIENT_CORNER_TR = 8 +E_GADCON_ORIENT_CORNER_BL = 9 +E_GADCON_ORIENT_CORNER_BR = 10 +E_GADCON_ORIENT_CORNER_LT = 11 +E_GADCON_ORIENT_CORNER_RT = 12 +E_GADCON_ORIENT_CORNER_LB = 13 +E_GADCON_ORIENT_CORNER_RB = 14 diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..3104064 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,21 @@ +MAINTAINERCLEANFILES = Makefile.in + +INCLUDES = -I. -Wall \ + -I$(top_srcdir) \ + -I$(includedir) \ + @EO_CFLAGS@ @E_CFLAGS@ @PYTHON3_CFLAGS@ + +pkgdir = $(datadir)/$(MODULE_ARCH) +pkg_LTLIBRARIES = module.la +module_la_SOURCES = e_mod_main.h \ + e_mod_main.c \ + e_mod_edgar.c \ + e_mod_edgar.h + +module_la_CPPFLAGS = -DEFL_BETA_API_SUPPORT -DEFL_EO_API_SUPPORT +module_la_LIBADD = @EO_LIBS@ @E_LIBS@ @PYTHON3_LIBS@ +module_la_LDFLAGS = -module -avoid-version +module_la_DEPENDENCIES = $(top_builddir)/config.h + +clean-local: + rm -rf *~ diff --git a/src/OLD_e_mod_config.c b/src/OLD_e_mod_config.c new file mode 100644 index 0000000..220630a --- /dev/null +++ b/src/OLD_e_mod_config.c @@ -0,0 +1,361 @@ +/* Copyright (C) 2008-2014 Davide Andreoli (see AUTHORS) + * + * This file is part of edgar. + * edgar is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * edgar 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with edgar. If not, see . + */ + +#include +#include "e_mod_main.h" + +struct _E_Config_Dialog_Data +{ + Eina_List *key_list; + Evas_Object *ilist; + Evas_Object *allow_btn, *deny_btn, *ask_btn; +}; + +/* Local Function Prototypes */ +static void *_create_data(E_Config_Dialog *cfd); +static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); +static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata); +static int _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); +extern Config *edgar_conf; + + +/* External Functions */ +#ifdef HAVE_E19 +EAPI E_Config_Dialog * +e_int_config_edgar_module(E_Comp *con, const char *params) +#else +EAPI E_Config_Dialog * +e_int_config_edgar_module(E_Container *con, const char *params) +#endif +{ + E_Config_Dialog_View *v = NULL; + char buf[PATH_MAX]; + + /* is this config dialog already visible ? */ + if (edgar_conf->cfd) + { + e_win_raise(edgar_conf->cfd->dia->win); +#ifndef HAVE_E19 + e_border_focus_set(edgar_conf->cfd->dia->win->border, 1, 1); +#endif + return NULL; + } + + v = E_NEW(E_Config_Dialog_View, 1); + if (!v) return NULL; + + v->create_cfdata = _create_data; + v->free_cfdata = _free_data; + v->basic.create_widgets = _basic_create; + v->basic.apply_cfdata = _basic_apply; + + /* Icon in the theme */ + //snprintf(buf, sizeof(buf), "%s/e-module-edgar.edj", edgar_conf->module->dir); + + /* create new config dialog */ + snprintf(buf, sizeof(buf), "%s/e-module-edgar.edj", edgar_conf->module->dir); + edgar_conf->cfd = e_config_dialog_new(con, "Edgar Gadgets Loader", // TODO i18n + "E", "extensions/edgar", + buf, 0, v, NULL); + + e_dialog_resizable_set(edgar_conf->cfd->dia, 1); + + return edgar_conf->cfd; +} + +/* Local Functions */ +static int +_cmp_func(const void *a, const void *b) +{ + const char *_a = a; + const char *_b = b; + if (_a[0] == ':' && _a[1] == ':') _a = _a + 2; + if (_b[0] == ':' && _b[1] == ':') _b = _b + 2; + return strcmp(_a, _b); +} + +static void * +_create_data(E_Config_Dialog *cfd) +{ + E_Config_Dialog_Data *cfdata; + Eina_Iterator *it; + const char *key; + + cfdata = E_NEW(E_Config_Dialog_Data, 1); + if (!cfdata) return NULL; + + // build a sorted list (with headers on top) of all the hash keys + it = eina_hash_iterator_key_new(edgar_conf->conf_guardian_hash); + while (eina_iterator_next(it, (void *)&key)) + cfdata->key_list = eina_list_sorted_insert(cfdata->key_list, _cmp_func, + eina_stringshare_add(key)); + eina_iterator_free(it); + + return cfdata; +} + +static void +_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) +{ + const char *key; + + edgar_conf->cfd = NULL; + EINA_LIST_FREE(cfdata->key_list, key) + eina_stringshare_del(key); + E_FREE(cfdata); +} + +static void +_list_selected_cb(void *data) +{ + E_Config_Dialog_Data *cfdata = data; + Guardian_Item *allow; + const char *key; + + key = e_widget_ilist_selected_value_get(cfdata->ilist); + allow = eina_hash_find(edgar_conf->conf_guardian_hash, key); + + if (!allow || allow->allow == EDGAR_GUARDIAN_ASK) + { + e_widget_disabled_set(cfdata->allow_btn, 0); + e_widget_disabled_set(cfdata->deny_btn, 0); + e_widget_disabled_set(cfdata->ask_btn, 1); + return; + } + + e_widget_disabled_set(cfdata->ask_btn, 0); + e_widget_disabled_set(cfdata->allow_btn, + (allow->allow == EDGAR_GUARDIAN_ALLOW) || + (allow->allow == EDGAR_GUARDIAN_ALLOW_ALL) ? 1 : 0); + e_widget_disabled_set(cfdata->deny_btn, + (allow->allow == EDGAR_GUARDIAN_ALLOW) || + (allow->allow == EDGAR_GUARDIAN_ALLOW_ALL) ? 0 : 1); +} + +static void +_allow_btn_cb(void *data, void *data2) +{ + E_Config_Dialog_Data *cfdata = data; + Guardian_Item *allow; + Evas_Object *end; + const char *key; + + key = e_widget_ilist_selected_value_get(cfdata->ilist); + allow = eina_hash_find(edgar_conf->conf_guardian_hash, key); + allow->allow = ((key[0] == ':') && (key[1] == ':')) ? + EDGAR_GUARDIAN_ALLOW_ALL : EDGAR_GUARDIAN_ALLOW; + + e_widget_disabled_set(cfdata->allow_btn, 1); + e_widget_disabled_set(cfdata->deny_btn, 0); + e_widget_disabled_set(cfdata->ask_btn, 0); + + end = e_widget_ilist_selected_end_get(cfdata->ilist); + edje_object_signal_emit(end, "e,state,checked", "e"); +} + +static void +_deny_btn_cb(void *data, void *data2) +{ + E_Config_Dialog_Data *cfdata = data; + Guardian_Item *allow; + Evas_Object *end; + const char *key; + + key = e_widget_ilist_selected_value_get(cfdata->ilist); + allow = eina_hash_find(edgar_conf->conf_guardian_hash, key); + allow->allow = ((key[0] == ':') && (key[1] == ':')) ? + EDGAR_GUARDIAN_DENY_ALL : EDGAR_GUARDIAN_DENY; + + e_widget_disabled_set(cfdata->allow_btn, 0); + e_widget_disabled_set(cfdata->deny_btn, 1); + e_widget_disabled_set(cfdata->ask_btn, 0); + + end = e_widget_ilist_selected_end_get(cfdata->ilist); + edje_object_signal_emit(end, "e,state,alert", "e"); +} + +static void +_ask_btn_cb(void *data, void *data2) +{ + E_Config_Dialog_Data *cfdata = data; + Guardian_Item *allow; + Evas_Object *end; + const char *key; + + key = e_widget_ilist_selected_value_get(cfdata->ilist); + allow = eina_hash_find(edgar_conf->conf_guardian_hash, key); + allow->allow = EDGAR_GUARDIAN_ASK; + + e_widget_disabled_set(cfdata->allow_btn, 0); + e_widget_disabled_set(cfdata->deny_btn, 0); + e_widget_disabled_set(cfdata->ask_btn, 1); + + end = e_widget_ilist_selected_end_get(cfdata->ilist); + edje_object_signal_emit(end, "e,state,unchecked", "e"); +} + +static void +_basic_populate_list(E_Config_Dialog_Data *cfdata) +{ + Evas_Object *icon, *end; + Evas *evas; + Eina_List *l; + Guardian_Item *allow; + const char *key; + char gadget[1024]; + char action[4096]; + + evas = evas_object_evas_get(cfdata->ilist); + + // populate the ilist with items and headers + EINA_LIST_FOREACH(cfdata->key_list, l, key) + { + DBG("KEY: '%s'", key); + if ((key[0] == ':') && (key[1] == ':')) + { + // extract the gadget name '::gadget_name::' + if (sscanf(key, "::%[^:]::", gadget) != 1) return; + DBG("'%s'", gadget); + + // append the header + icon = e_icon_add(evas); + if (!e_icon_file_edje_set(icon, gadget, "e/gadget/icon")) + { + evas_object_del(icon); + icon = NULL; + } + e_widget_ilist_header_append(cfdata->ilist, icon, gadget); + + // append the 'trust all' item + end = edje_object_add(evas); + if (!e_theme_edje_object_set(end, "base/theme/widgets", + "e/widgets/ilist/toggle_end")) + { + evas_object_del(end); + end = NULL; + } + else + { + edje_object_signal_emit(end, "e,state,unchecked", "e"); + allow = eina_hash_find(edgar_conf->conf_guardian_hash, key); + if (allow && allow->allow == EDGAR_GUARDIAN_ALLOW_ALL) + edje_object_signal_emit(end, "e,state,checked", "e"); + else if (allow && allow->allow == EDGAR_GUARDIAN_DENY_ALL) + edje_object_signal_emit(end, "e,state,alert", "e"); + } + e_widget_ilist_append_full(cfdata->ilist, NULL, end, + "Trust or Deny ALL from this gadget", + _list_selected_cb, cfdata, key); + } + else + { + // extract the gadget name and the action 'gadget_name::action' + // this is not really correct, will truncate action with the char ':' + if (sscanf(key, "%[^:]::%[^:]", gadget, action) != 2) return; + DBG("'%s' '%s'", gadget, action); + + // append the action + allow = eina_hash_find(edgar_conf->conf_guardian_hash, key); + end = edje_object_add(evas); + if (!e_theme_edje_object_set(end, "base/theme/widgets", + "e/widgets/ilist/toggle_end")) + { + evas_object_del(end); + end = NULL; + } + else + { + edje_object_signal_emit(end, "e,state,unchecked", "e"); + if (allow && allow->allow == EDGAR_GUARDIAN_ALLOW) + edje_object_signal_emit(end, "e,state,checked", "e"); + else if (allow && allow->allow == EDGAR_GUARDIAN_DENY) + edje_object_signal_emit(end, "e,state,alert", "e"); + } + e_widget_ilist_append_full(cfdata->ilist, NULL, end, action, + _list_selected_cb, cfdata, key); + } + } +} + +static Evas_Object * +_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) +{ + Evas_Object *hbox, *frame, *icon; + + frame = e_widget_framelist_add(evas, "The Gadget Guardian", 0); + + // ilist + cfdata->ilist = e_widget_ilist_add(evas, 24, 24, NULL); + e_widget_size_min_set(cfdata->ilist, 180, 100); + e_widget_ilist_go(cfdata->ilist); + e_widget_framelist_object_append(frame, cfdata->ilist); + + // button box + hbox = e_widget_list_add(evas, 1, 1); + + // allow btn + cfdata->allow_btn = e_widget_button_add(evas, "Allow", NULL, + _allow_btn_cb, cfdata, NULL); + e_widget_disabled_set(cfdata->allow_btn, 1); + icon = edje_object_add(evas); + if (e_theme_edje_object_set(icon, "base/theme/widgets", + "e/widgets/ilist/toggle_end")) + { + edje_object_signal_emit(icon, "e,state,checked", "e"); + e_widget_button_icon_set(cfdata->allow_btn, icon); + } + e_widget_list_object_append(hbox, cfdata->allow_btn, 1, 1, 0.5); + + // deny btn + cfdata->deny_btn = e_widget_button_add(evas, "Deny", NULL, + _deny_btn_cb, cfdata, NULL); + e_widget_disabled_set(cfdata->deny_btn, 1); + icon = edje_object_add(evas); + if (e_theme_edje_object_set(icon, "base/theme/widgets", + "e/widgets/ilist/toggle_end")) + { + edje_object_signal_emit(icon, "e,state,alert", "e"); + e_widget_button_icon_set(cfdata->deny_btn, icon); + } + e_widget_list_object_append(hbox, cfdata->deny_btn, 1, 0, 0.5); + + // ask btn + cfdata->ask_btn = e_widget_button_add(evas, "Ask", NULL, + _ask_btn_cb, cfdata, NULL); + e_widget_disabled_set(cfdata->ask_btn, 1); + icon = edje_object_add(evas); + if (e_theme_edje_object_set(icon, "base/theme/widgets", + "e/widgets/ilist/toggle_end")) + { + edje_object_signal_emit(icon, "e,state,unchecked", "e"); + e_widget_button_icon_set(cfdata->ask_btn, icon); + } + e_widget_list_object_append(hbox, cfdata->ask_btn, 1, 0, 0.5); + + e_widget_framelist_object_append_full(frame, hbox, + 1, 0, 1, 0, 0.5, 0.5, 25, 25, 999, 999); + + _basic_populate_list(cfdata); + return frame; +} + +static int +_basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) +{ + e_config_save_queue(); + return 1; +} diff --git a/src/OLD_e_mod_edgar.c b/src/OLD_e_mod_edgar.c new file mode 100644 index 0000000..ec8c4b7 --- /dev/null +++ b/src/OLD_e_mod_edgar.c @@ -0,0 +1,869 @@ +/* Copyright (C) 2008-2014 Davide Andreoli (see AUTHORS) + * + * This file is part of edgar. + * edgar is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * edgar 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with edgar. If not, see . + */ + +#include +#include +#include "config.h" +#include "e_mod_main.h" +#include "e_mod_edgar.h" +#include "e_mod_guardian.h" + + +/* Local Prototypes */ +static unsigned char edgar_load_class(const char *path); +static unsigned char edgar_unload_class(E_Gadcon_Client_Class *cclass); +static void _edgar_file_monitor_cb(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path); +static void _edgar_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _edgar_edje_messagge_cb(void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *message); +static void _edgar_message_send(Instance *inst, int id, const char *args, ...); +static Eina_Bool _edgar_exec_pipe_data(void *data, int ev_type, void *ev); +static Eina_Bool _edgar_exec_pipe_exit(void *data, int ev_type, void *ev); + +/* Gadcon Prototypes */ +static E_Gadcon_Client *_edgar_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style); +static void _edgar_gc_shutdown(E_Gadcon_Client *gcc); +static void _edgar_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient); +static const char *_edgar_gc_label(const E_Gadcon_Client_Class *client_class); +static const char *_edgar_gc_id_new(const E_Gadcon_Client_Class *client_class); +static void _edgar_gc_id_del(const E_Gadcon_Client_Class *client_class, const char *id); +static Evas_Object *_edgar_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas); + +/* Gadgets API Prototypes */ +static void _edgar_api_dbg (Instance *inst, int id, Edje_Message_String_Set *msg); +static void _edgar_api_conf_set (Instance *inst, int id, Edje_Message_String_Set *msg); +static void _edgar_api_conf_get (Instance *inst, int id, Edje_Message_String_Set *msg); +static void _edgar_api_id_get (Instance *inst, int id, Edje_Message_String_Set *msg); +static void _edgar_api_min_set (Instance *inst, int id, Edje_Message_String_Set *msg); +static void _edgar_api_exec (Instance *inst, int id, Edje_Message_String_Set *msg); +static void _edgar_api_action (Instance *inst, int id, Edje_Message_String_Set *msg); + +/* Local Variables */ +static const char *gadgets_user_dir; +static const char *gadgets_system_dir; + +static Eina_List *classes; +static Eina_List *instances; +static Ecore_File_Monitor *mon1, *mon2; + +extern Config *edgar_conf; +extern E_Config_DD *conf_edd; +extern E_Config_DD *conf_item_edd; + +Ecore_Event_Handler *eeh1, *eeh2, *eeh3; + +/* Implementation */ +void +edgar_init(void) +{ + char buf[PATH_MAX]; + Eina_List *files; + char *filename; + + classes = NULL; + + INF("EDGAR: ================================"); + INF("EDGAR: Init"); + + snprintf(buf, sizeof(buf), "%s/.e/e/gadgets", e_user_homedir_get()); + gadgets_user_dir = eina_stringshare_add(buf); + + snprintf(buf, sizeof(buf), "%s/data/gadgets", e_prefix_data_get()); + gadgets_system_dir = eina_stringshare_add(buf); + + //Create user dir if not exists + if (!ecore_file_exists(gadgets_user_dir)) + ecore_file_mkpath(gadgets_user_dir); + + /* search in user dir */ + DBG("EDGAR: Search in %s", gadgets_user_dir); + files = ecore_file_ls(gadgets_user_dir); + EINA_LIST_FREE(files, filename) + { + snprintf(buf, sizeof(buf), "%s/%s", gadgets_user_dir, filename); + edgar_load_class(buf); + free(filename); + } + eina_list_free(files); + + /* search in system dir */ + DBG("EDGAR: Search in %s", gadgets_system_dir); + files = ecore_file_ls(gadgets_system_dir); + EINA_LIST_FREE(files, filename) + { + snprintf(buf, PATH_MAX, "%s/%s", gadgets_system_dir, filename); + edgar_load_class(buf); + free(filename); + } + eina_list_free(files); + + /* Monitor the directories */ + mon1 = ecore_file_monitor_add(gadgets_user_dir, _edgar_file_monitor_cb, NULL); + mon2 = ecore_file_monitor_add(gadgets_system_dir, _edgar_file_monitor_cb, NULL); + + /* Pipe Handler */ + eeh1 = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, + _edgar_exec_pipe_exit, NULL); + eeh2 = ecore_event_handler_add(ECORE_EXE_EVENT_DATA, + _edgar_exec_pipe_data, NULL); + eeh3 = ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, + _edgar_exec_pipe_data, NULL); +} + +void +edgar_shutdown(void) +{ + INF("EDGAR Shutdown (%d)", eina_list_count(classes)); + + if (eeh1) ecore_event_handler_del(eeh1); + if (eeh2) ecore_event_handler_del(eeh2); + if (eeh3) ecore_event_handler_del(eeh3); + eeh1 = eeh2 = eeh3 = NULL; + + if (mon1) ecore_file_monitor_del(mon1); + if (mon2) ecore_file_monitor_del(mon2); + mon1 = mon2 = NULL; + + while (classes) + { + edgar_unload_class(classes->data); + classes = eina_list_remove_list(classes, classes); + } + eina_stringshare_del(gadgets_user_dir); + eina_stringshare_del(gadgets_system_dir); +} + +/* Internals */ +static Eina_Bool +_edgar_monitor_dalayed(void *data) +{ + edgar_shutdown(); + edgar_init(); + return 0; +} + +static void +_edgar_file_monitor_cb(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path) +{ + static Ecore_Timer *monitor_timer = NULL; + + switch (event) + { + case ECORE_FILE_EVENT_CREATED_FILE: + case ECORE_FILE_EVENT_DELETED_FILE: + case ECORE_FILE_EVENT_MODIFIED: + DBG("EDGAR: FILE EVENT [%s]", path); + //TODO check if is an edje file + if (monitor_timer) ecore_timer_del(monitor_timer); + monitor_timer = ecore_timer_add(1.5, _edgar_monitor_dalayed, NULL); + break; + case ECORE_FILE_EVENT_DELETED_SELF: + //TODO handle this catasastrofic case... + break; + case ECORE_FILE_EVENT_CREATED_DIRECTORY: + case ECORE_FILE_EVENT_DELETED_DIRECTORY: + default: + break; + } + +} + +static unsigned char +edgar_load_class(const char *path) +{ + E_Gadcon_Client_Class *cclass; + Eina_List *l; + char *style; + + if (!path || !ecore_file_exists(path)) + return 0; + + //TODO check better if is an edje file + if (!eina_str_has_suffix(path, ".edj")) + return 0; + + DBG("EDGAR: Load Gadget %s", path); + + //Do not load twice + EINA_LIST_FOREACH(classes, l, cclass) + { + //DBG("EDGAR: SEARCH: %s", cclass->name); + if (!strcmp(ecore_file_file_get(path), + ecore_file_file_get(cclass->name))) + return 0; + } + + //Alloc & populate the gc_class + cclass = E_NEW(E_Gadcon_Client_Class, 1); + if (!cclass) return 0; + cclass->version = GADCON_CLIENT_CLASS_VERSION; + cclass->name = eina_stringshare_add(path); + cclass->func.init = _edgar_gc_init; + cclass->func.shutdown = _edgar_gc_shutdown; + cclass->func.orient = _edgar_gc_orient; + cclass->func.label = _edgar_gc_label; + cclass->func.icon = _edgar_gc_icon; + cclass->func.id_new = _edgar_gc_id_new; + cclass->func.id_del = _edgar_gc_id_del; + + style = edje_file_data_get(path, "e/gadget/apparence"); + if (!style) style = E_GADCON_CLIENT_STYLE_PLAIN; + cclass->default_style = (char*)eina_stringshare_add(style); + + //Register the new class + e_gadcon_provider_register(cclass); + + classes = eina_list_append(classes, cclass); + return 1; +} + +static unsigned char +edgar_unload_class(E_Gadcon_Client_Class *cclass) +{ + DBG("EDGAR: UnLoad Gadgets %s", cclass->name); + + /* Free the cclass */ + e_gadcon_provider_unregister(cclass); + eina_stringshare_del(cclass->name); + eina_stringshare_del(cclass->default_style); + free(cclass); + + return 1; +} + +/******************** + * Gadcon IFace * + ********************/ + +// static void +// _edgar_focus_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +// { + // Instance *inst = data; + // ERR("FOCUSIN on %s!!!", inst->gcc->cf->id); + // evas_object_focus_set(inst->obj, 1); +// } + +static E_Gadcon_Client * +_edgar_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) +{ + //E_Gadcon_Client *gcc; + Instance *inst; + Config_Item *ci = NULL; + + DBG("EDGAR: Gadcon Init name: %s id: %s", name, id); + + /* Search for a config for this id */ + ci = eina_hash_find(edgar_conf->conf_items_hash, id); + if (!ci) + { + ci = E_NEW(Config_Item, 1); + ci->id = eina_stringshare_add(id); //TODO freeme + ci->data_hash = NULL; + eina_hash_direct_add(edgar_conf->conf_items_hash, ci->id, ci); + } + + /* Create the gadget instance */ + inst = E_NEW(Instance, 1); + if (!inst) return 0; + inst->ci = ci; + + /* Create the edje object */ + inst->obj = edje_object_add(gc->evas); + edje_object_file_set(inst->obj, name, "e/gadget/main");//TODO Here search different group names...or load the first one + evas_object_data_set(inst->obj, "EDGAR:instance", inst); + //evas_object_repeat_events_set(inst->obj, 0); + //evas_object_pass_events_set(inst->obj, 0); + + + /* setup callbacks on the edje object */ + edje_object_message_handler_set(inst->obj, _edgar_edje_messagge_cb, NULL); + //TODO MOUSE_DOWN?? I prefer MOUSE_IN!! + //evas_object_event_callback_add(inst->obj, EVAS_CALLBACK_MOUSE_IN, + // _edgar_mouse_down_cb, inst); + + // evas_object_event_callback_add(inst->obj, EVAS_CALLBACK_FOCUS_IN, + // _edgar_focus_cb, inst); + evas_object_event_callback_add(inst->obj, EVAS_CALLBACK_MOUSE_DOWN, + _edgar_mouse_down_cb, inst); + + /* Create the Gadcon_Client*/ + inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->obj); + inst->gcc->data = inst; + + instances = eina_list_append(instances, inst); + return inst->gcc; +} + +static void +_edgar_gc_shutdown(E_Gadcon_Client *gcc) +{ + Instance *inst = gcc->data; + + DBG("EDGAR: Shutdown"); + instances = eina_list_remove(instances, inst); + evas_object_del(inst->obj); + E_FREE(inst); +} + +static void +_edgar_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient) +{ + Instance *inst = gcc->data; + + DBG("EDGAR: Gadcon Orient: %d", orient); + switch (orient) + { + case E_GADCON_ORIENT_FLOAT: + _edgar_message_send(inst, 0, "EDGAR_ORIENT", "FLOAT", NULL); + break; + case E_GADCON_ORIENT_HORIZ: + case E_GADCON_ORIENT_TOP: + case E_GADCON_ORIENT_BOTTOM: + case E_GADCON_ORIENT_CORNER_TL: + case E_GADCON_ORIENT_CORNER_TR: + case E_GADCON_ORIENT_CORNER_BL: + case E_GADCON_ORIENT_CORNER_BR: + _edgar_message_send(inst, 0, "EDGAR_ORIENT", "HORIZ", NULL); + break; + case E_GADCON_ORIENT_VERT: + case E_GADCON_ORIENT_LEFT: + case E_GADCON_ORIENT_RIGHT: + case E_GADCON_ORIENT_CORNER_LT: + case E_GADCON_ORIENT_CORNER_RT: + case E_GADCON_ORIENT_CORNER_LB: + case E_GADCON_ORIENT_CORNER_RB: + _edgar_message_send(inst, 0, "EDGAR_ORIENT", "VERT", NULL); + break; + default: + break; + } + + if (!inst->min_w && !inst->min_h) + edje_object_size_min_get(inst->obj, &inst->min_w, &inst->min_h); + + //edje_object_size_min_calc(inst->obj, &inst->min_w, &inst->min_h); + // DBG("EDGAR: w:%d h:%d", inst->min_w, inst->min_h); + + e_gadcon_client_min_size_set(gcc, inst->min_w, inst->min_h); + // DBG("EDGAR: DOPO"); +} + +static const char* +_edgar_gc_label(const E_Gadcon_Client_Class *client_class) +{ + char *label; + DBG("EDGAR: Gadcon Label for class: %s", client_class->name); + + //Search the label in the edje file or use the filename as label + label = edje_file_data_get(client_class->name, "e/gadget/name"); + if (!label) + label = (char*)ecore_file_file_get(client_class->name); + + return label; +} + +static const char* +_edgar_gc_id_new(const E_Gadcon_Client_Class *client_class) +{ + Config_Item *ci = NULL; + char buf[128]; + + snprintf(buf, sizeof(buf), "ED.%s.%.0f", + ecore_file_file_get(client_class->name), ecore_time_get() * 1000000); + + DBG("EDGAR: Gadcon ID New [%s]", buf); + + ci = E_NEW(Config_Item, 1); + ci->id = eina_stringshare_add(buf); + ci->data_hash = eina_hash_string_superfast_new(NULL); + eina_hash_direct_add(edgar_conf->conf_items_hash, ci->id, ci); + + return ci->id; +} + +static void +_edgar_gc_id_del(const E_Gadcon_Client_Class *client_class, const char *id) +{ + //DBG("EDGAR: Gadcon ID Del [%s]", id); + //~ Config_Item *ci = NULL; + + //~ if (!(ci = _skel_conf_item_get(id))) return; + + //~ /* cleanup !! */ + //~ if (ci->id) eina_stringshare_del(ci->id); + + //~ skel_conf->conf_items = eina_list_remove(skel_conf->conf_items, ci); + //~ E_FREE(ci); +} + +static Evas_Object* +_edgar_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas) +{ + Evas_Object *icon; + + DBG("EDGAR: Gadcon Icon for class: %s", client_class->name); + + icon = edje_object_add(evas); + if (edje_object_file_set(icon, client_class->name, "e/gadget/icon")) + return icon; + + evas_object_del(icon); + return NULL; +} + +/************************ + * Gadgets Callbacks * + ************************/ +static void +_edgar_menu_post_cb(void *data, E_Menu *m) +{ + E_Gadcon_Client *gcc; + + if (!(gcc = data)) return; + if (gcc->gadcon) e_gadcon_locked_set(gcc->gadcon, 0); + if (!gcc->menu) return; + if (gcc->gadcon && gcc->gadcon->shelf && (gcc->menu == gcc->gadcon->shelf->menu)) + gcc->gadcon->shelf->menu = NULL; + e_object_del(E_OBJECT(gcc->menu)); + gcc->menu = NULL; +} + +static void +_edgar_menu_configure_cb(void *data, E_Menu *m, E_Menu_Item *mi) +{ +#ifdef HAVE_E19 + e_int_config_edgar_module(m->zone->comp, NULL); +#else + e_int_config_edgar_module(m->zone->container, NULL); +#endif +} + +static void +_edgar_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Instance *inst = data; + Evas_Event_Mouse_Down *ev = event_info; + + // DBG("EDGAR: DONW on %s!!!", inst->gcc->cf->id); + // evas_object_focus_set(inst->obj, 1); + + if (inst->gcc->menu) return; + if (ev->button == 3) + { + E_Menu_Item *mi; + E_Zone *zone; + int cx, cy, cw, ch; + + e_gadcon_locked_set(inst->gcc->gadcon, 1); + inst->gcc->menu = e_menu_new(); + + mi = e_menu_item_new(inst->gcc->menu); + e_menu_item_label_set(mi, "Gadgets settings"); // TODO i18n + e_util_menu_item_theme_icon_set(mi, "configure"); + e_menu_item_callback_set(mi, _edgar_menu_configure_cb, NULL); + + inst->gcc->menu = e_gadcon_client_util_menu_items_append(inst->gcc, inst->gcc->menu, 0); + e_menu_post_deactivate_callback_set(inst->gcc->menu, _edgar_menu_post_cb, inst->gcc); + + if (inst->gcc->gadcon->shelf) inst->gcc->gadcon->shelf->menu = inst->gcc->menu; + + e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy, &cw, &ch); + zone = inst->gcc->gadcon->zone; + if (!zone) zone = e_util_zone_current_get(e_manager_current_get()); + e_menu_activate_mouse(inst->gcc->menu, zone, + cx + ev->output.x, + cy + ev->output.y, 1, 1, + E_MENU_POP_DIRECTION_AUTO, ev->timestamp); + } +} + +static void +_edgar_edje_messagge_cb(void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *message) +{ + Edje_Message_String_Set *msg; + Instance *inst; + char *cmd; + + if (type != EDJE_MESSAGE_STRING_SET) + return; + + msg = message; + if (msg->count < 1) + return; + cmd = msg->str[0]; + + inst = evas_object_data_get(obj, "EDGAR:instance"); + if (!inst) return; + + // int i; + // printf("CMD [%s](%d) ", cmd, msg->count); + // for(i = 1; i < msg->count; i++) printf("[%s]", msg->str[i]); + // printf(""); + + //command must start with EDGAR_ and must have at least 1 char after it + if (strlen(cmd) < 7 || strncmp(cmd, "EDGAR_", 6)) + return; + cmd += 6; + + if (!strcmp(cmd, "DBG")) _edgar_api_dbg (inst, id, msg); + else if (!strcmp(cmd, "MIN_SET")) _edgar_api_min_set (inst, id, msg); + else if (!strcmp(cmd, "EXEC")) _edgar_api_exec (inst, id, msg); + else if (!strcmp(cmd, "ACTION")) _edgar_api_action (inst, id, msg); + else if (!strcmp(cmd, "CONF_SET")) _edgar_api_conf_set (inst, id, msg); + else if (!strcmp(cmd, "CONF_GET")) _edgar_api_conf_get (inst, id, msg); + else if (!strcmp(cmd, "ID_GET")) _edgar_api_id_get (inst, id, msg); + else WRN("Warning: unknow command '%s'", cmd); +} + +static void +_edgar_message_send(Instance *inst, int id, const char *args, ...) +{ + Edje_Message_String_Set *rmsg; + va_list ap; + const char *param; + int n = 0; + int i; + + //DBG("MSG"); + + //Count the args + va_start(ap, args); + param = args; + while (param != 0) + { + param = va_arg(ap, const char *); + n++; + } + if (n < 1) return; + + //Alloc messagge + rmsg = alloca(sizeof(Edje_Message_String_Set) + ((n - 1) * sizeof(char *))); //TODO FREE??? + rmsg->count = n; + + //Populate messagge + va_start(ap, args); + param = args; + for (i = 0; i < n; i++) + { + rmsg->str[i] = (char*)eina_stringshare_add(param); //NEED TO FREE??? + param = va_arg(ap, const char *); + } + va_end(ap); + + //Send the messagge + edje_object_message_send(inst->obj, EDJE_MESSAGE_STRING_SET, id, rmsg); +} + +/******************* + * Gadgets API * + *******************/ + +/** EDGAR_DBG "string to print" "another one" ... "as many as you wish" + * + */ +static void +_edgar_api_dbg(Instance *inst, int id, Edje_Message_String_Set *msg) +{ + int i; + + printf("\033[31;1m[GADGET %s] ", + ecore_file_file_get(inst->gcc->client_class->name)); + for (i = 1; i < msg->count; i++) + printf("%s ", msg->str[i]); + printf("\033[0m"); + printf("\n"); +} + +/** EDGAR_ID_GET no_params + * + * replay with EDGAR_ID_GET_REPLAY "id" + */ +static void +_edgar_api_id_get(Instance *inst, int id, Edje_Message_String_Set *msg) +{ + DBG("EDGAR: ID_GET"); + _edgar_message_send(inst, id, "EDGAR_ID_GET_REPLY", (char*)inst->ci->id); +} + +/** EDGAR_MIN_SET "min_w min_h" + * + */ +static void +_edgar_api_min_set(Instance *inst, int id, Edje_Message_String_Set *msg) +{ + char *value; + int min_w, min_h; + //~ char *value; + //~ Data_Item *data; + + if (msg->count < 2) + return; + + value = msg->str[1]; + //~ value = msg->str[2]; + + DBG("EDGAR: MIN_SET '%s'", value); + + sscanf(value, "%d %d", &min_w, &min_h); + DBG("EDGAR: MIN_SET '%d' '%d'", min_w, min_h); + inst->gcc->min.w = min_w; + inst->gcc->min.h = min_h; + + //e_gadcon_client_min_size_set(inst->gcc, min_w, min_h); + + //~ e_config_save_queue(); +} + +static Eina_Bool +_edgar_exec_pipe_data(void *data, int ev_type, void *ev) +{ + Ecore_Exe_Event_Data *e = (Ecore_Exe_Event_Data *)ev; + Edgar_Exe_Data *exe_data; + + if (!e->exe) return 1; + if (!ecore_exe_tag_get(e->exe) )return 1; + if (strcmp(ecore_exe_tag_get(e->exe), "EdG")) return 1; + + exe_data = ecore_exe_data_get(e->exe); + if (!exe_data) return 1; + + //DBG("EDGAR: data received."); + if (e->lines) + { + int i; + for (i = 0; e->lines[i].line != NULL; i++) + { + _edgar_message_send(exe_data->inst, exe_data->id_msg, + "EDGAR_EXEC_DATA", e->lines[i].line, NULL); + + if (exe_data->last_line) eina_stringshare_del(exe_data->last_line); + exe_data->last_line = eina_stringshare_add(e->lines[i].line); + } + } + return 1; +} + +static Eina_Bool +_edgar_exec_pipe_exit(void *data, int ev_type, void *ev) +{ + Ecore_Exe_Event_Del *e = (Ecore_Exe_Event_Del *)ev; + Edgar_Exe_Data *exe_data; + + if (!e->exe) return 1; + if (!ecore_exe_tag_get(e->exe) )return 1; + if (strcmp(ecore_exe_tag_get(e->exe), "EdG")) return 1; + + exe_data = ecore_exe_data_get(e->exe); + if (!exe_data) return 1; + + if (e->exit_code) + { + //~ DBG("EDGAR: Error in EXEC, exit code: %d", e->exit_code); + _edgar_message_send(exe_data->inst, exe_data->id_msg, + "EDGAR_EXEC_REPLY", "ERR", exe_data->last_line, NULL); + } + else + { + //~ DBG("EDGAR: Operation completed"); + _edgar_message_send(exe_data->inst, exe_data->id_msg, + "EDGAR_EXEC_REPLY", "OK", exe_data->last_line, NULL); + } + + if (exe_data->last_line) eina_stringshare_del(exe_data->last_line); + E_FREE(exe_data); + + return 0; +} + +/** EDGAR_EXEC "command" + * + * replay with EDGAR_EXEC_REPLY "status" "last_line" when the command end. + * status can be 'OK' 'ERR'. + * You can also listen for EDGAR_EXEC_DATA "line" to catch every line of the + * output. + */ +static void +_edgar_api_exec(Instance *inst, int id, Edje_Message_String_Set *msg) +{ + char *exe; + Edgar_Exe_Data *exe_data; + Ecore_Exe *ee; + + if (msg->count < 2) + return; + + if (!edgar_guardian_is_allowed(inst, EDGAR_GUARDIAN_TYPE_COMMAND, msg->str[1])) + return; + + exe = msg->str[1]; + // DBG("EDGAR: EXEC '%s'", exe); + + // if (inst->eeh1) + // { + // WRN("There is another EXEC running...skipping."); + // return; + // } + + exe_data = E_NEW(Edgar_Exe_Data, 1); + exe_data->id_msg = id; + exe_data->inst = inst; + exe_data->last_line = NULL; + + ee = ecore_exe_pipe_run(exe, + ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_READ_LINE_BUFFERED | + ECORE_EXE_PIPE_ERROR | ECORE_EXE_PIPE_ERROR_LINE_BUFFERED, + exe_data); + ecore_exe_tag_set(ee, "EdG"); +} + +/** EDGAR_ACTION "action" + * + * replay with EDGAR_ACTION_REPLY "status". + * status can be 'OK' 'ERR'. + */ +static void +_edgar_api_action(Instance *inst, int id, Edje_Message_String_Set *msg) +{ + E_Action *ac; + char *action; + char *params; + + if (msg->count != 2) + { + ERR("Wrong args count: %d", msg->count); + return; + } + + if (!edgar_guardian_is_allowed(inst, EDGAR_GUARDIAN_TYPE_EACTION, msg->str[1])) + return; + + action = strdup(msg->str[1]); + params = strchr(action, ' '); + if (params) + { + *params = '\0'; + params++; + } + else + { + params = ""; + } + + ac = e_action_find(action); + if (!ac) + { + ERR("Cannot find action: %s", action); + _edgar_message_send(inst, id, "EDGAR_ACTION_REPLY", "ERR", NULL); + free(action); + return; + } + + if (!ac->func.go) + { + ERR("Cannot find go() func in action: %s", action); + _edgar_message_send(inst, id, "EDGAR_ACTION_REPLY", "ERR", NULL); + free(action); + return; + } + + DBG("EDGAR: GO! action:'%s' params:'%s'", action, params); + ac->func.go(NULL, params); + _edgar_message_send(inst, id, "EDGAR_ACTION_REPLY", "OK", NULL); + + free(action); + + /*** print the list of available actions + { + Eina_List *l, *l2; + + E_Action_Group *actg; + E_Action_Description *actd; + int g, a; + for (l = e_action_groups_get(), g = 0; l; l = l->next, g++) + { + actg = l->data; + + if (!actg->acts) continue; + printf("*** %s\n", actg->act_grp); + + for (l2 = actg->acts, a = 0; l2; l2 = l2->next, a++) + { + actd = l2->data; + printf(" - %s [%s]\n", actd->act_name, actd->act_cmd); + printf(" params:'%s' '%s'\n", actd->act_params, actd->param_example); + } + } + } + */ + +} + +/** EDGAR_CONF_SET "key" "value" + * + */ +static void +_edgar_api_conf_set(Instance *inst, int id, Edje_Message_String_Set *msg) +{ + char *key; + char *value; + Data_Item *data; + + if (msg->count < 3) + return; + + key = msg->str[1]; + value = msg->str[2]; + + DBG("EDGAR: CONF_SET key '%s' val: '%s'", key, value); + + data = eina_hash_find(inst->ci->data_hash, key); + if (!data) + { + DBG("EDGAR: DATA NOT EXIST. Create new"); + data = E_NEW(Data_Item, 1); + data->val_str = NULL; + data->val_int = 0; + eina_hash_add(inst->ci->data_hash, key, data); + } + + if (data->val_str) eina_stringshare_del(data->val_str); + data->val_str = eina_stringshare_add(value); + + e_config_save_queue(); +} + +/** EDGAR_CONF_GET "key" + * + * replay with EDGAR_CONF_GET_REPLAY "key" "value" + * note: if no conf with that key exists, than no REPLAY msg is sent. + */ +static void +_edgar_api_conf_get(Instance *inst, int id, Edje_Message_String_Set *msg) +{ + Data_Item *data; + char *key; + + DBG("EDGAR: CONF_GET"); + + if (msg->count < 2) + return; + + key = msg->str[1]; + data = eina_hash_find(inst->ci->data_hash, key); + if (!data) return; + + _edgar_message_send(inst, id, "EDGAR_CONF_GET_REPLY", key, data->val_str); +} diff --git a/src/OLD_e_mod_edgar.h b/src/OLD_e_mod_edgar.h new file mode 100644 index 0000000..76c2e61 --- /dev/null +++ b/src/OLD_e_mod_edgar.h @@ -0,0 +1,25 @@ +/* Copyright (C) 2008 Davide Andreoli (see AUTHORS) + * + * This file is part of edgar. + * edgar is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * edgar 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with edgar. If not, see . + */ + +#ifndef E_MOD_EDGAR_H +#define E_MOD_EDGAR_H + +void edgar_init(void); +void edgar_shutdown(void); + + +#endif diff --git a/src/OLD_e_mod_guardian.c b/src/OLD_e_mod_guardian.c new file mode 100644 index 0000000..a29a239 --- /dev/null +++ b/src/OLD_e_mod_guardian.c @@ -0,0 +1,217 @@ +/* Copyright (C) 2008-2014 Davide Andreoli (see AUTHORS) + * + * This file is part of edgar. + * edgar is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * edgar 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with edgar. If not, see . + */ + +#include +#include "e_mod_main.h" +#include "e_mod_guardian.h" + +typedef struct { + const char *action; + int action_type; + int check_state; + Guardian_Item *inwait_item; +}Guardian_Dialog_Data; + +extern Config *edgar_conf; + +static Guardian_Item * +_edgar_guardian_allow_set(const char *gadget, const char *action, int allow) +{ + Guardian_Item *item; + char key[4096]; + + if (allow >= EDGAR_GUARDIAN_DENY_LAST) + return NULL; + + snprintf(key, sizeof(key), "::%s::", gadget); + if ((allow != EDGAR_GUARDIAN_DENY_ALL) && (allow != EDGAR_GUARDIAN_ALLOW_ALL)) + { + // we always want an 'header' item (simplify the config list) + if (!eina_hash_find(edgar_conf->conf_guardian_hash, &key)) + { + item = E_NEW(Guardian_Item, 1); + item->allow = EDGAR_GUARDIAN_ASK; + eina_hash_add(edgar_conf->conf_guardian_hash, key, item); + } + snprintf(key, sizeof(key), "%s::%s", gadget, action); + } + + item = eina_hash_find(edgar_conf->conf_guardian_hash, &key); + if (!item) + { + item = E_NEW(Guardian_Item, 1); + eina_hash_add(edgar_conf->conf_guardian_hash, key, item); + } + item->allow = allow; + + return item; +} + +static void +_edgar_guardian_dialog_allow_cb(void *data, E_Dialog *dia) +{ + Instance *inst = data; + Guardian_Dialog_Data *gdd; + + gdd = e_object_data_get((E_Object *)dia); + _edgar_guardian_allow_set(inst->gcc->client_class->name, gdd->action, + gdd->check_state ? EDGAR_GUARDIAN_ALLOW_ALL : EDGAR_GUARDIAN_ALLOW); + + e_object_del((E_Object *)dia); +} + +static void +_edgar_guardian_dialog_deny_cb(void *data, E_Dialog *dia) +{ + Instance *inst = data; + Guardian_Dialog_Data *gdd; + + gdd = e_object_data_get((E_Object *)dia); + _edgar_guardian_allow_set(inst->gcc->client_class->name, gdd->action, + gdd->check_state ? EDGAR_GUARDIAN_DENY_ALL : EDGAR_GUARDIAN_DENY); + e_object_del((E_Object *)dia); +} + +static void +_edgar_guardian_dialog_free_cb(void *dia) +{ + Guardian_Dialog_Data *gdd; + + gdd = e_object_data_get(dia); + if (!gdd) return; + + if (gdd->inwait_item && gdd->inwait_item->allow == EDGAR_GUARDIAN_IN_WAIT) + gdd->inwait_item->allow = EDGAR_GUARDIAN_ASK; + + if (gdd->action) eina_stringshare_del(gdd->action); + E_FREE(gdd); +} + +EAPI Eina_Bool +edgar_guardian_is_allowed(Instance *inst, int type, const char *action) +{ + Guardian_Item *allow; + Guardian_Dialog_Data *gdd; + E_Dialog *dia; + char buf[4096]; + int w, h; + + // just to be safe, in case something goes wrong loading from config + if (!edgar_conf->conf_guardian_hash) + edgar_conf->conf_guardian_hash = eina_hash_string_superfast_new(NULL); + + // check in the guardian hash + if (action && inst && inst->gcc && inst->gcc->client_class && + inst->gcc->client_class->name) + { + snprintf(buf, sizeof(buf), "::%s::", inst->gcc->client_class->name); + allow = eina_hash_find(edgar_conf->conf_guardian_hash, &buf); + if (!allow || allow->allow == EDGAR_GUARDIAN_ASK) + { + snprintf(buf, sizeof(buf), "%s::%s", inst->gcc->client_class->name, action); + allow = eina_hash_find(edgar_conf->conf_guardian_hash, &buf); + } + DBG("Guardian, can exec this? '%s'", buf); + + if (allow && allow->allow != EDGAR_GUARDIAN_ASK) + { + switch (allow->allow) + { + case EDGAR_GUARDIAN_ALLOW: + case EDGAR_GUARDIAN_ALLOW_ALL: + DBG("Yes, you can! go on."); + return EINA_TRUE; + + case EDGAR_GUARDIAN_DENY: + case EDGAR_GUARDIAN_DENY_ALL: + case EDGAR_GUARDIAN_IN_WAIT: + default: + DBG("NO! permission denied. (reason: %d)", allow->allow); + return EINA_FALSE; + } + } + } + + // or ask the user what to do + gdd = E_NEW(Guardian_Dialog_Data, 1); + if (!gdd) return EINA_FALSE; + gdd->action = eina_stringshare_add(action); + gdd->action_type = type; + + if (type == EDGAR_GUARDIAN_TYPE_EACTION) + snprintf(buf, sizeof(buf), + "The gadget \"%s\"
" + "want to execute the enlightenment action:
" + "
%s

" + "Do I have to allow the execution?", inst->ci->id ,action); + else if (type == EDGAR_GUARDIAN_TYPE_COMMAND) + snprintf(buf, sizeof(buf), + "The gadget \"%s\"
" + "want to execute the shell command:
" + "
%s

" + "Do I have to allow the execution?", inst->ci->id ,action); + + else if (type == EDGAR_GUARDIAN_TYPE_GETURL) + snprintf(buf, sizeof(buf), + "The gadget \"%s\"
" + "want to access the net at the url:
" + "
%s

" + "Do I have to allow the access?", inst->ci->id ,action); + + + // dialog +#ifdef HAVE_E19 + E_Comp *con; + con = e_manager_current_get()->comp; +#else + E_Container *con; + con = e_container_current_get(e_manager_current_get()); +#endif + dia = e_dialog_new(con, "can exec", "class"); + e_dialog_resizable_set(dia, EINA_TRUE); + e_dialog_title_set(dia, "The gadget guardian"); + e_dialog_button_add(dia, "Allow", NULL, _edgar_guardian_dialog_allow_cb, inst); + e_dialog_button_add(dia, "Deny", NULL, _edgar_guardian_dialog_deny_cb, inst); + e_object_data_set((E_Object*)dia, gdd); + e_object_free_attach_func_set((E_Object*)dia, _edgar_guardian_dialog_free_cb); + + // vbox + Evas_Object *vbox; + vbox = e_widget_list_add(dia->win->evas, 0, 0); + + // label + Evas_Object *text; + text = e_widget_textblock_add(dia->win->evas); + e_widget_textblock_markup_set(text, buf); + e_widget_size_min_set(text, 260 * e_scale, 90 * e_scale); // hmmm, :/ + e_widget_list_object_append(vbox, text, 1, 1, 0.0); + + // check + Evas_Object *chk; + chk = e_widget_check_add(dia->win->evas, "Allow or deny all the actions from this gadget", &gdd->check_state); //TODO i18n + e_widget_list_object_append(vbox, chk, 1, 1, 0.0); + + // resize & show the dialog + e_widget_size_min_get(vbox, &w, &h); + e_dialog_content_set(dia, vbox, w, h); + e_dialog_show(dia); + + // set to deny (in_wait), until the user choose or the dialog will be closed + gdd->inwait_item = _edgar_guardian_allow_set(inst->gcc->client_class->name, + action, EDGAR_GUARDIAN_IN_WAIT); + return EINA_FALSE; +} diff --git a/src/OLD_e_mod_guardian.h b/src/OLD_e_mod_guardian.h new file mode 100644 index 0000000..bd0a81c --- /dev/null +++ b/src/OLD_e_mod_guardian.h @@ -0,0 +1,24 @@ +/* Copyright (C) 2008 Davide Andreoli (see AUTHORS) + * + * This file is part of edgar. + * edgar is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * edgar 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with edgar. If not, see . + */ + +#ifndef E_MOD_EDGAR_GUARDIAN_H +#define E_MOD_EDGAR_GUARDIAN_H + + +EAPI Eina_Bool edgar_guardian_is_allowed(Instance *inst, int type, const char *action); + +#endif diff --git a/src/e_mod_edgar.c b/src/e_mod_edgar.c new file mode 100644 index 0000000..e5a59d7 --- /dev/null +++ b/src/e_mod_edgar.c @@ -0,0 +1,758 @@ +/* Copyright (C) 2008-2014 Davide Andreoli (see AUTHORS) + * + * This file is part of edgar. + * edgar is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * edgar 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with edgar. If not, see . + */ + + +#include +#include +#include "e_mod_main.h" +#include "e_mod_edgar.h" +#include "efl.eo_api.h" + + +/* Local typedefs */ +typedef struct { + const char *name; // ex: "ruler" (from folder name) + const char *label; // ex: "ruler" (from __gadget_name__) + const char *path; // ex: "/usr/local/lib/enlightenment/gadgets/ruler" + const char *edjefile; // ex: "/usr/local/lib/enlightenment/gadgets/ruler/ruler.edj" + PyObject *mod; // the python module for this gadget + PyObject *instance; // the python Gadget class instance + Eina_List *pops_obj; // list of edje objs that are set as popup content + E_Gadcon_Client_Class *cclass; +}Edgar_Py_Gadget; + + +/* Local Prototypes */ +static Edgar_Py_Gadget *edgar_gadget_load(const char *name, const char *path); +static void edgar_gadget_unload(Edgar_Py_Gadget *gadget); +static void edgar_gadgets_load_all(const char *path); +static void edgar_gadgets_hash_free_func(void *data); +static void edgar_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static Eina_Bool edgar_theme_edje_object_set(Edgar_Py_Gadget *gadget, Evas_Object *obj, const char *group); + +/* Local Gadcon Prototypes */ +static E_Gadcon_Client *_edgar_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style); +static void _edgar_gc_shutdown(E_Gadcon_Client *gcc); +static void _edgar_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient); +static const char *_edgar_gc_label(const E_Gadcon_Client_Class *client_class); +static const char *_edgar_gc_id_new(const E_Gadcon_Client_Class *client_class); +static void _edgar_gc_id_del(const E_Gadcon_Client_Class *client_class, const char *id); +static Evas_Object *_edgar_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas); + +/* Python eapi module proto */ +PyMODINIT_FUNC PyInit_eapi(void); + + +/* Local Variables */ +static const char *edgar_gadgets_system_dir; //ex: "/usr/lib/enlightenment/gadgets/" +static Eina_Hash *edgar_gadgets; //key: "gadget_name" val: Edgar_Py_Gadget* +static PyObject *evasObjectType; +static PyObject *edjeEdjeType; + + +#define CURRENT_VAPI 1 + +#define PY_BOOTSTRAP_SCRIPT \ +"import sys \n" \ +"sys.path.append('%s') \n" \ +"\n" + + +#define PY_ON_ERROR_RETURN(_extra_check_, _ret_val_, _msg_) \ + if (PyErr_Occurred() || _extra_check_) { \ + PyErr_Print(); \ + PyRun_SimpleString("sys.stdout.flush()"); \ + PyRun_SimpleString("sys.stderr.flush()"); \ + if (_msg_) DBG("EDGAR: ERROR "_msg_); \ + return _ret_val_; \ + } \ + + +#if (PY_VERSION_HEX < 0x03030000) +#define PyString_AsString(x) PyBytes_AsString(PyUnicode_AsUTF8String(x)) +#else +#define PyString_AsString PyUnicode_AsUTF8 +#endif + + +/*****************************************************************************/ +/***** Main stuff ***********************************************************/ +/*****************************************************************************/ + +Eina_Bool +edgar_init() +{ + char buf[PATH_MAX]; + int ret; + + // prepare the local scope + snprintf(buf, sizeof(buf), "%s/enlightenment/gadgets", e_prefix_lib_get()); + edgar_gadgets_system_dir = eina_stringshare_add(buf); + edgar_gadgets = eina_hash_string_superfast_new(edgar_gadgets_hash_free_func); + + // Add the eapi module as a built-in module + PyImport_AppendInittab("eapi", PyInit_eapi); + + // init python + /// TOTRY Py_SetPath() + Py_Initialize(); + + // This import the C functions from the efl eo api. + // The module do NOT need to be linked with the .so files, python + // import machinery is used here. + // Used functions: object_from_instance() and instance_from_object() + if (import_efl__eo() != 0) + { + DBG("EDGAR: Cannot import python-efl"); + e_util_dialog_internal("Edgar Error", + "Python-efl not found.
" + "Your python gadgets will not work.

" + "Please install or update python-efl.
"); + return EINA_FALSE; + } + + // keep some efl types around, will be used for type-checking + PyObject *module, *moduleDict; + + module = PyImport_ImportModule("efl.evas"); + moduleDict = PyModule_GetDict(module); + evasObjectType = PyDict_GetItemString(moduleDict, "Object"); + Py_DECREF(module); + + module = PyImport_ImportModule("efl.edje"); + /// TO TRY: PyObject * pClass = PyObject_GetAttrString(pModule, "Grasp_Behavior"); + moduleDict = PyModule_GetDict(module); + edjeEdjeType = PyDict_GetItemString(moduleDict, "Edje"); + Py_DECREF(module); + + // Run the bootstrap python code + snprintf(buf, sizeof(buf), PY_BOOTSTRAP_SCRIPT, edgar_gadgets_system_dir); + DBG("EDGAR: Bootstrap (sys.path: '%s')", edgar_gadgets_system_dir); + ret = PyRun_SimpleString(buf); + PY_ON_ERROR_RETURN(ret != 0, EINA_FALSE, "Python bootstrap failed!"); + DBG("EDGAR: Bootstrap successful"); + + // Load all the available gadgets + edgar_gadgets_load_all(edgar_gadgets_system_dir); + + return EINA_TRUE; +} + +void +edgar_shutdown() +{ + DBG("EDGAR: Shutdown started ..."); + + // unload and free all the gadgets + eina_hash_free(edgar_gadgets); + + // shutdown python + if (Py_IsInitialized()) + Py_Finalize(); + + // clean local scope + eina_stringshare_del(edgar_gadgets_system_dir); + + DBG("EDGAR: Shutdown completed!"); +} + +static void +edgar_gadgets_load_all(const char *path) +{ + Eina_List *files; + char buf[PATH_MAX]; + char *filename; + + DBG("EDGAR: Seaching python gadgets in %s", path); + files = ecore_file_ls(path); + EINA_LIST_FREE(files, filename) + { + snprintf(buf, sizeof(buf), "%s/%s", path, filename); + if (ecore_file_is_dir(buf)) + edgar_gadget_load(filename, buf); + + free(filename); + } + eina_list_free(files); +} + +static Edgar_Py_Gadget* +edgar_gadget_load(const char *name, const char *path) +{ + Edgar_Py_Gadget *gadget; + E_Gadcon_Client_Class *cclass; + char fname[PATH_MAX]; + const char *label; + PyObject *mod, *cls, *attr; + long vapi = 0; + + // check the given path + snprintf(fname, sizeof(fname), "%s/__init__.pyc", path); + if (!ecore_file_exists(fname)) + { + snprintf(fname, sizeof(fname), "%s/__init__.py", path); + if (!ecore_file_exists(fname)) + return NULL; + } + + // import the gadget in python + DBG("EDGAR: * importing gadget: '%s' from: '%s'", name, fname); + mod = PyImport_ImportModule(name); + PY_ON_ERROR_RETURN(mod == NULL, NULL, "Gadget import failed!"); + + // check the existance of the Gadget class + cls = PyObject_GetAttrString(mod, "Gadget"); + PY_ON_ERROR_RETURN(cls == NULL, NULL, "Gadget class not found"); + + // check the api version + attr = PyObject_GetAttrString(cls, "__gadget_vapi__"); + if ((attr == NULL) || (!PyLong_Check(attr)) || + ((vapi = PyLong_AsLong(attr)) != CURRENT_VAPI)) + { + e_util_dialog_show("Edgar Error", + "The %s gadget is outdated !

" + "Please update the gadget or contact the gadget maintainer.

" + "current edgar api: %d
" + "gadget api version: %ld" + "
", name, CURRENT_VAPI, vapi); + return NULL; + } + Py_DECREF(attr); + + // cache the label + attr = PyObject_GetAttrString(cls, "__gadget_name__"); + PY_ON_ERROR_RETURN(attr == NULL, NULL, "Gadget name not found"); + + label = eina_stringshare_add(PyString_AsString(attr)); + Py_DECREF(attr); + Py_DECREF(cls); + + //Alloc & populate the gc_class + cclass = E_NEW(E_Gadcon_Client_Class, 1); + if (!cclass) return NULL; + cclass->version = GADCON_CLIENT_CLASS_VERSION; + cclass->name = eina_stringshare_add(name); + cclass->default_style = eina_stringshare_add("plain"); + cclass->func.init = _edgar_gc_init; + cclass->func.shutdown = _edgar_gc_shutdown; + cclass->func.orient = _edgar_gc_orient; + cclass->func.label = _edgar_gc_label; + cclass->func.icon = _edgar_gc_icon; + cclass->func.id_new = _edgar_gc_id_new; + cclass->func.id_del = _edgar_gc_id_del; + + //Alloc & populate the gadget struct + gadget = E_NEW(Edgar_Py_Gadget, 1); + if (!gadget) return NULL; + gadget->label = label; + gadget->name = eina_stringshare_add(name); + gadget->path = eina_stringshare_add(path); + gadget->cclass = cclass; + gadget->mod = mod; + // do gadget have a local edj ? + snprintf(fname, sizeof(fname), "%s/%s.edj", path, name); + if (ecore_file_exists(fname)) + gadget->edjefile = eina_stringshare_add(fname); + else + gadget->edjefile = NULL; + + //Register the new class + e_gadcon_provider_register(cclass); + eina_hash_add(edgar_gadgets, name, gadget); + + return gadget; +} + +static void +edgar_gadget_unload(Edgar_Py_Gadget *gadget) +{ + Evas_Object *popup_content; + Eina_List *l, *l2; + + DBG("EDGAR: Unload gadget: %s", gadget->name); + + // kill all the active popups edje obj + EINA_LIST_FOREACH_SAFE(gadget->pops_obj, l, l2, popup_content) + E_FREE_FUNC(popup_content, evas_object_del); + + // Free the gadcon client class + e_gadcon_provider_unregister(gadget->cclass); + eina_stringshare_del(gadget->cclass->name); + eina_stringshare_del(gadget->cclass->default_style); + free(gadget->cclass); + + // Free the gadget itself + eina_stringshare_del(gadget->name); + eina_stringshare_del(gadget->label); + eina_stringshare_del(gadget->path); + eina_stringshare_del(gadget->edjefile); + Py_XDECREF(gadget->instance); + Py_XDECREF(gadget->mod); + free(gadget); +} + +static void +edgar_gadgets_hash_free_func(void *data) +{ + Edgar_Py_Gadget *gadget = data; + edgar_gadget_unload(gadget); +} + + +/*****************************************************************************/ +/***** Gadgets Utils ******************************************************/ +/*****************************************************************************/ + +static Eina_Bool +edgar_theme_edje_object_set(Edgar_Py_Gadget *gadget, Evas_Object *obj, const char *group) +{ + char buf[PATH_MAX]; + + if (!gadget || !obj || !group) + return EINA_FALSE; + + snprintf(buf, sizeof(buf), "e/gadgets/%s/%s", gadget->name, group); + + // TODO search in E theme + + // search in gadget local edje file + if (!gadget->edjefile) + return EINA_FALSE; + + return edje_object_file_set(obj, gadget->edjefile, buf); +} + +static Eina_Bool +edgar_popup_del_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info) +{ + Edgar_Py_Gadget *gadget = data; + + // call the popup_destoyed() method of the gadget. + PyObject *pyobj = object_from_instance(obj); + PyObject *ret = PyObject_CallMethod(gadget->instance, "popup_destroyed", + "(S)", pyobj); + PY_ON_ERROR_RETURN(!ret, EO_CALLBACK_CONTINUE, "Cannot call popup_destroyed()"); + Py_DECREF(pyobj); + Py_DECREF(ret); + + gadget->pops_obj = eina_list_remove(gadget->pops_obj, obj); + + return EO_CALLBACK_CONTINUE; +} + +static E_Gadcon_Popup * +edgar_popup_new(Edgar_Py_Gadget *gadget, E_Gadcon_Client *gcc) +{ + E_Gadcon_Popup *popup; + Evas_Object *content; + + // create the popup content from the e/gadgets/name/popup group + content = edje_object_add(gcc->gadcon->evas); + if (!edgar_theme_edje_object_set(gadget, content, "popup")) + { + evas_object_del(content); + return NULL; + } + // NOTE: del cb with priority to be called before the python-efl one. + // Otherwise python-efl delete the python obj too soon + eo_do(content, eo_event_callback_priority_add( + EO_EV_DEL, EO_CALLBACK_PRIORITY_BEFORE, edgar_popup_del_cb, gadget)); + + // call the popup_created() method of the gadget. + PyObject *pyobj = object_from_instance(content); + PyObject *ret = PyObject_CallMethod(gadget->instance, "popup_created", + "(S)", pyobj); + PY_ON_ERROR_RETURN(!ret, NULL, "Cannot call popup_created()"); + Py_DECREF(pyobj); + Py_DECREF(ret); + + // put the popup content in a gadcon popup and show it +#ifdef HAVE_E19 + popup = e_gadcon_popup_new(gcc, 0); +#else + popup = e_gadcon_popup_new(gcc); +#endif + e_gadcon_popup_content_set(popup, content); + e_gadcon_popup_show(popup); + + gadget->pops_obj = eina_list_append(gadget->pops_obj, content); + + return popup; +} + +static void +edgar_menu_info_cb(void *data, E_Menu *m, E_Menu_Item *mi) +{ + Edgar_Py_Gadget *gadget = data; + Evas_Object *hbox, *tb, *icon, *img; + Eina_Strbuf *strbuf; + Evas_Coord w, h; + PyObject *cls, *attr; + E_Dialog *dia; + + // build the text + strbuf = eina_strbuf_new(); + + if (!(cls = PyObject_GetAttrString(gadget->mod, "Gadget"))) + return; + + if ((attr = PyObject_GetAttrString(cls, "__gadget_name__"))) + { + eina_strbuf_append_printf(strbuf, "%s", + PyString_AsString(attr)); + Py_DECREF(attr); + } + if ((attr = PyObject_GetAttrString(cls, "__gadget_vers__"))) + { + eina_strbuf_append_printf(strbuf, " v%s", PyString_AsString(attr)); + Py_DECREF(attr); + } + if ((attr = PyObject_GetAttrString(cls, "__gadget_auth__"))) + { + eina_strbuf_append_printf(strbuf, "
Author: %s", PyString_AsString(attr)); + Py_DECREF(attr); + } + if ((attr = PyObject_GetAttrString(cls, "__gadget_mail__"))) + { + eina_strbuf_append_printf(strbuf, "
Contact: %s", PyString_AsString(attr)); + Py_DECREF(attr); + } + if ((attr = PyObject_GetAttrString(cls, "__gadget_desc__"))) + { + eina_strbuf_append_printf(strbuf, "

%s", PyString_AsString(attr)); + Py_DECREF(attr); + } + Py_DECREF(cls); + + // dialog +#ifdef HAVE_E19 + E_Comp *con; + con = e_manager_current_get()->comp; +#else + E_Container *con; + con = e_container_current_get(e_manager_current_get()); +#endif + dia = e_dialog_new(con, "gadget_info", "class"); + e_dialog_resizable_set(dia, 0); + e_dialog_title_set(dia, "Gadget info"); + e_dialog_button_add(dia, "Close", NULL, NULL, NULL); + + // hbox + hbox = e_widget_list_add(dia->win->evas, 0, 1); + + // icon + icon = edje_object_add(dia->win->evas); + edgar_theme_edje_object_set(gadget, icon, "icon"); + img = e_widget_image_add_from_object(dia->win->evas, icon, + 70 * e_scale, 70 * e_scale); + e_widget_list_object_append(hbox, img, 1, 0, 0.0); + + // text + tb = e_widget_textblock_add(dia->win->evas); + e_widget_textblock_markup_set(tb, eina_strbuf_string_get(strbuf)); + e_widget_size_min_set(tb, 250 * e_scale, 100 * e_scale); + e_widget_list_object_append(hbox, tb, 1, 1, 0.0); + + // resize & show the dialog + e_widget_size_min_get(hbox, &w, &h); + e_dialog_content_set(dia, hbox, w, h); + e_dialog_show(dia); + + eina_strbuf_free(strbuf); +} + +static void +edgar_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + E_Gadcon_Client *gcc = data; + Evas_Event_Mouse_Down *ev = event_info; + Edgar_Py_Gadget *gadget = gcc->data; + E_Gadcon_Popup *popup; + + if (ev->button == 3) + { + // gadcon menu on right-click + E_Zone *zone; + E_Menu *m; + int x, y; + + zone = e_util_zone_current_get(e_manager_current_get()); + + m = e_menu_new(); + + E_Menu_Item *mi; + mi = e_menu_item_new(m); + e_menu_item_label_set(mi, "Gadget info"); + e_util_menu_item_theme_icon_set(mi, "help-about"); + e_menu_item_callback_set(mi, edgar_menu_info_cb, gadget); + + m = e_gadcon_client_util_menu_items_append(gcc, m, 0); + + e_gadcon_canvas_zone_geometry_get(gcc->gadcon, &x, &y, NULL, NULL); + e_menu_activate_mouse(m, zone, x + ev->output.x, y + ev->output.y, + 1, 1, E_MENU_POP_DIRECTION_AUTO, ev->timestamp); + evas_event_feed_mouse_up(gcc->gadcon->evas, ev->button, + EVAS_BUTTON_NONE, ev->timestamp, NULL); + } + else if (ev->button == 1) + { + // toggle gadget popup on left-click + if ((popup = evas_object_data_get(obj, "popup"))) + { + E_FREE_FUNC(popup, e_object_del); + evas_object_data_del(obj, "popup"); + } + else if ((popup = edgar_popup_new(gadget, gcc))) + { + evas_object_data_set(obj, "popup", popup); + } + } +} + + +/*****************************************************************************/ +/***** Gadcon IFace *******************************************************/ +/*****************************************************************************/ + +static E_Gadcon_Client * +_edgar_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) +{ + Edgar_Py_Gadget *gadget; + Evas_Object *obj; + + gadget = eina_hash_find(edgar_gadgets, name); + if (!gadget) return NULL; + + DBG("EDGAR: Gadcon Init name: %s id: %s (gc orient: %d) (edjefile: %s", + name, id, gc->orient, gadget->edjefile); + + // create the python Gadget class instance (if not done yet) + if (!gadget->instance) + { + DBG("EDGAR: Instantiate the python class"); + gadget->instance = PyObject_CallMethod(gadget->mod, "Gadget", ""); + PY_ON_ERROR_RETURN(!gadget->instance, NULL, "Cannot create the Gadget instance"); + } + + // TODO search in the E theme ("e/gadget/name/main") + obj = edje_object_add(gc->evas); + if (!edgar_theme_edje_object_set(gadget, obj, "main")) + { + DBG("EDGAR: ERROR, cannot find a theme for the gadget: '%s'", name); + evas_object_del(obj); + return NULL; + } + + // create the Gadcon_Client + E_Gadcon_Client *gcc = e_gadcon_client_new(gc, name, id, style, obj); + gcc->data = gadget; + + // setup default callbacks on object (right-click for menu, left for popup) + evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN, + edgar_mouse_down_cb, gcc); + + + // call the instance_created() method of the gadget. + PyObject *pyobj = object_from_instance(obj); + PyObject *ret = PyObject_CallMethod(gadget->instance, "instance_created", + "(Si)", pyobj, gc->location->site); + PY_ON_ERROR_RETURN(!ret, NULL, "Cannot call instance_created()"); + Py_DECREF(pyobj); + Py_DECREF(ret); + + return gcc; +} + +static void +_edgar_gc_shutdown(E_Gadcon_Client *gcc) +{ + Edgar_Py_Gadget *gadget = gcc->data; + + DBG("EDGAR: Gadcon Shutdown. NAME: %s, ID: %d", gcc->name, gcc->id); + + // call the instance_destroyed() method of the gadget. + PyObject *py_obj = object_from_instance(gcc->o_base); + PyObject *ret = PyObject_CallMethod(gadget->instance, "instance_destroyed", + "(S)", py_obj); + PY_ON_ERROR_RETURN(!ret, , "Cannot call instance_destroyed()"); + Py_DECREF(py_obj); + Py_DECREF(ret); + + // destroy the object + evas_object_del(gcc->o_base); + gcc->o_base = NULL; +} + +static void +_edgar_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient) +{ + Edgar_Py_Gadget *gadget = gcc->data; + E_Gadcon_Orient generic; + Evas_Coord min_w, min_h; + + DBG("EDGAR: Gadcon Orient: %d", orient); + switch (orient) + { + case E_GADCON_ORIENT_HORIZ: + case E_GADCON_ORIENT_TOP: + case E_GADCON_ORIENT_BOTTOM: + case E_GADCON_ORIENT_CORNER_TL: + case E_GADCON_ORIENT_CORNER_TR: + case E_GADCON_ORIENT_CORNER_BL: + case E_GADCON_ORIENT_CORNER_BR: + generic = E_GADCON_ORIENT_HORIZ; + break; + case E_GADCON_ORIENT_VERT: + case E_GADCON_ORIENT_LEFT: + case E_GADCON_ORIENT_RIGHT: + case E_GADCON_ORIENT_CORNER_LT: + case E_GADCON_ORIENT_CORNER_RT: + case E_GADCON_ORIENT_CORNER_LB: + case E_GADCON_ORIENT_CORNER_RB: + generic = E_GADCON_ORIENT_VERT; + break; + case E_GADCON_ORIENT_FLOAT: + default: + generic = E_GADCON_ORIENT_FLOAT; + break; + } + + // call the instance_orient() method of the gadget. + PyObject *py_evas_obj = object_from_instance(gcc->o_base); + PyObject *ret = PyObject_CallMethod(gadget->instance, "instance_orient", + "(Sii)", py_evas_obj, generic, orient); + PY_ON_ERROR_RETURN(!ret, , "Cannot call instance_orient()"); + Py_DECREF(py_evas_obj); + Py_DECREF(ret); + + // apply obj size hints + edje_object_message_signal_process(gcc->o_base); + edje_object_size_min_calc(gcc->o_base, &min_w, &min_h); + e_gadcon_client_min_size_set(gcc, min_w, min_h); + e_gadcon_client_aspect_set(gcc, min_w, min_h); +} + +static const char* +_edgar_gc_label(const E_Gadcon_Client_Class *client_class) +{ + Edgar_Py_Gadget *gadget; + + DBG("EDGAR: Gadcon Label for class: %s", client_class->name); + + gadget = eina_hash_find(edgar_gadgets, client_class->name); + if (!gadget) return NULL; + + return gadget->label; +} + +static const char* +_edgar_gc_id_new(const E_Gadcon_Client_Class *client_class) +{ + Edgar_Py_Gadget *gadget; + char buf[256]; + + gadget = eina_hash_find(edgar_gadgets, client_class->name); + if (!gadget) return NULL; + + snprintf(buf, sizeof(buf), "ED.%s.%.0f", + gadget->name, ecore_time_get() * 1000000); + + DBG("EDGAR: Gadcon ID New: %s", buf); + //TODO manage config here + return eina_stringshare_add(buf); +} + +static void +_edgar_gc_id_del(const E_Gadcon_Client_Class *client_class, const char *id) +{ + +} + +static Evas_Object* +_edgar_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas) +{ + Edgar_Py_Gadget *gadget; + Evas_Object *icon; + + DBG("EDGAR: Gadcon Icon for class: %s", client_class->name); + + gadget = eina_hash_find(edgar_gadgets, client_class->name); + if (!gadget) return NULL; + + icon = edje_object_add(evas); + if (edgar_theme_edje_object_set(gadget, icon, "icon")) + return icon; + + evas_object_del(icon); + return NULL; +} + + +/*****************************************************************************/ +/***** Gadget Python API (the python eapi module) **************************/ +/*****************************************************************************/ + +#define EXCEPTION(_type_, _msg_) \ +{ \ + PyErr_SetString(_type_, _msg_); \ + return NULL; \ +} \ + + +static PyObject* +_eapi_theme_edje_object_set(PyObject *self, PyObject *args) +{ + Edgar_Py_Gadget *gadget; + const char *name, *group; + Evas_Object *obj; + PyObject *pyobj; + + if (!PyArg_ParseTuple(args, "O!ss", edjeEdjeType, &pyobj, &name, &group)) + return NULL; + + if (!(gadget = eina_hash_find(edgar_gadgets, name))) + EXCEPTION(PyExc_ValueError, "name is not a valid gadget name"); + + obj = instance_from_object(pyobj); + if (!edgar_theme_edje_object_set(gadget, obj, group)) + EXCEPTION(PyExc_RuntimeError, "cannot find group in theme"); + + Py_RETURN_NONE; +} + + +static PyMethodDef EApiMethods[] = { + {"theme_edje_object_set", _eapi_theme_edje_object_set, METH_VARARGS, + "Load the given group from the theme file."}, + {NULL, NULL, 0, NULL} +}; + +static struct PyModuleDef EApiModule = { + PyModuleDef_HEAD_INIT, + "eapi", /* name of module */ + NULL, /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, + or -1 if the module keeps state in global variables. */ + EApiMethods +}; + + +PyMODINIT_FUNC +PyInit_eapi(void) +{ + return PyModule_Create(&EApiModule); +} diff --git a/src/e_mod_edgar.h b/src/e_mod_edgar.h new file mode 100644 index 0000000..edfb5e6 --- /dev/null +++ b/src/e_mod_edgar.h @@ -0,0 +1,25 @@ +/* Copyright (C) 2008 Davide Andreoli (see AUTHORS) + * + * This file is part of edgar. + * edgar is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * edgar 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with edgar. If not, see . + */ + +#ifndef E_MOD_EDGAR_H +#define E_MOD_EDGAR_H + + +Eina_Bool edgar_init(void); +void edgar_shutdown(void); + +#endif diff --git a/src/e_mod_main.c b/src/e_mod_main.c new file mode 100644 index 0000000..e03fd04 --- /dev/null +++ b/src/e_mod_main.c @@ -0,0 +1,118 @@ +/* Copyright (C) 2008-2014 Davide Andreoli (see AUTHORS) + * + * This file is part of edgar. + * edgar is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * edgar 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with edgar. If not, see . + */ + +#include +#include "e_mod_main.h" +#include "e_mod_edgar.h" + + +EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION , "Edgar" }; + + +static E_Config_DD *conf_edd = NULL; +E_Config_DD *conf_item_edd = NULL; +E_Config_DD *conf_data_edd = NULL; + +Config *edgar_conf = NULL; + +static void +_edgar_conf_free(Config *cfg) +{ + /* Cleanup our item list */ + //~ while (edgar_conf->conf_items) TODO CLEANUP THE HASH like mixer + //~ { + //~ Config_Item *ci = NULL; + + //~ ci = edgar_conf->conf_items->data; + //~ edgar_conf->conf_items = eina_list_remove_list(edgar_conf->conf_items, + //~ edgar_conf->conf_items); + //~ if (ci->id) eina_stringshare_del(ci->id); + //~ E_FREE(ci); + //~ } + E_FREE(cfg); +} + +EAPI void * +e_modapi_init(E_Module *m) +{ + /* Define EET Data Storage */ + conf_data_edd = E_CONFIG_DD_NEW("Data_Item", Data_Item); + E_CONFIG_VAL(conf_data_edd, Data_Item, val_str, STR); + E_CONFIG_VAL(conf_data_edd, Data_Item, val_int, INT); + E_CONFIG_VAL(conf_data_edd, Data_Item, val_float, DOUBLE); + + conf_item_edd = E_CONFIG_DD_NEW("Config_Item", Config_Item); + E_CONFIG_VAL(conf_item_edd, Config_Item, id, STR); + E_CONFIG_HASH(conf_item_edd, Config_Item, data_hash, conf_data_edd); + + conf_edd = E_CONFIG_DD_NEW("Config", Config); + E_CONFIG_VAL(conf_edd, Config, version, INT); + //E_CONFIG_VAL(conf_edd, Config, switch1, UCHAR); /* our var from header */ + //E_CONFIG_LIST(conf_edd, Config, conf_items, conf_item_edd); /* the list */ + E_CONFIG_HASH(conf_edd, Config, conf_items_hash, conf_item_edd); /* the hash of items */ + + /* Tell E to find any existing module data. First run ? */ + edgar_conf = e_config_domain_load("module.edgar", conf_edd); + if (edgar_conf) + { + // Chech if a new configuration is needed + // TODO i18n + if (!e_util_module_config_check(("Gadget loader"), + edgar_conf->version, + MOD_CONFIG_FILE_VERSION)) + { + _edgar_conf_free(edgar_conf); + edgar_conf = NULL; + } + } + + /* if we don't have a config yet create a default one */ + if (!edgar_conf) + { + edgar_conf = E_NEW(Config, 1); + edgar_conf->version = MOD_CONFIG_FILE_VERSION; + edgar_conf->conf_items_hash = eina_hash_string_superfast_new(NULL); + e_config_save_queue(); + } + + edgar_conf->module = m; + edgar_init(); + return m; +} + +EAPI int +e_modapi_shutdown(E_Module *m) +{ + edgar_shutdown(); + + /* Cleanup the main config structure */ + _edgar_conf_free(edgar_conf); + + /* Clean EET */ + E_CONFIG_DD_FREE(conf_data_edd); + E_CONFIG_DD_FREE(conf_item_edd); + E_CONFIG_DD_FREE(conf_edd); + + return 1; +} + +EAPI int +e_modapi_save(E_Module *m) +{ + e_config_domain_save("module.edgar", conf_edd, edgar_conf); + return 1; +} diff --git a/src/e_mod_main.h b/src/e_mod_main.h new file mode 100644 index 0000000..2e442d9 --- /dev/null +++ b/src/e_mod_main.h @@ -0,0 +1,58 @@ +/* Copyright (C) 2008 Davide Andreoli (see AUTHORS) + * + * This file is part of edgar. + * edgar is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * edgar 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with edgar. If not, see . + */ + +#ifndef E_MOD_MAIN_H +#define E_MOD_MAIN_H + + +/* Increment for Major Changes */ +#define MOD_CONFIG_FILE_EPOCH 3 +/* Increment for Minor Changes (ie: user doesn't need a new config) */ +#define MOD_CONFIG_FILE_GENERATION 1 +#define MOD_CONFIG_FILE_VERSION \ + ((MOD_CONFIG_FILE_EPOCH * 1000000) + MOD_CONFIG_FILE_GENERATION) + +/* Contain whole module conf */ +typedef struct { + int version; + E_Module *module; + E_Config_Dialog *cfd; + Eina_Hash *conf_items_hash; +}Config; + +/* This struct used to hold config for individual gadget */ +typedef struct { + const char *id; + Eina_Hash *data_hash; +}Config_Item; + +/* This struct used to hold data for every gadgets */ +typedef struct { + const char *val_str; + int val_int; + double val_float; +}Data_Item; + + +EAPI extern E_Module_Api e_modapi; + +EAPI void *e_modapi_init(E_Module *m); +EAPI int e_modapi_shutdown(E_Module *m); +EAPI int e_modapi_save(E_Module *m); + + +#endif diff --git a/src/efl.eo_api.h b/src/efl.eo_api.h new file mode 100644 index 0000000..25419b8 --- /dev/null +++ b/src/efl.eo_api.h @@ -0,0 +1,101 @@ +#ifndef __PYX_HAVE_API__efl__eo +#define __PYX_HAVE_API__efl__eo +#include "Python.h" + +static PyObject *(*__pyx_f_3efl_2eo_object_from_instance)(Eo *) = 0; +#define object_from_instance __pyx_f_3efl_2eo_object_from_instance +static Eo *(*__pyx_f_3efl_2eo_instance_from_object)(PyObject *) = 0; +#define instance_from_object __pyx_f_3efl_2eo_instance_from_object +#if !defined(__Pyx_PyIdentifier_FromString) +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) +#else + #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) +#endif +#endif + +#ifndef __PYX_HAVE_RT_ImportModule +#define __PYX_HAVE_RT_ImportModule +static PyObject *__Pyx_ImportModule(const char *name) { + PyObject *py_name = 0; + PyObject *py_module = 0; + py_name = __Pyx_PyIdentifier_FromString(name); + if (!py_name) + goto bad; + py_module = PyImport_Import(py_name); + Py_DECREF(py_name); + return py_module; +bad: + Py_XDECREF(py_name); + return 0; +} +#endif + +#ifndef __PYX_HAVE_RT_ImportFunction +#define __PYX_HAVE_RT_ImportFunction +static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { + PyObject *d = 0; + PyObject *cobj = 0; + union { + void (*fp)(void); + void *p; + } tmp; + d = PyObject_GetAttrString(module, (char *)"__pyx_capi__"); + if (!d) + goto bad; + cobj = PyDict_GetItemString(d, funcname); + if (!cobj) { + PyErr_Format(PyExc_ImportError, + "%s does not export expected C function %s", + PyModule_GetName(module), funcname); + goto bad; + } +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0) + if (!PyCapsule_IsValid(cobj, sig)) { + PyErr_Format(PyExc_TypeError, + "C function %s.%s has wrong signature (expected %s, got %s)", + PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj)); + goto bad; + } + tmp.p = PyCapsule_GetPointer(cobj, sig); +#else + {const char *desc, *s1, *s2; + desc = (const char *)PyCObject_GetDesc(cobj); + if (!desc) + goto bad; + s1 = desc; s2 = sig; + while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } + if (*s1 != *s2) { + PyErr_Format(PyExc_TypeError, + "C function %s.%s has wrong signature (expected %s, got %s)", + PyModule_GetName(module), funcname, sig, desc); + goto bad; + } + tmp.p = PyCObject_AsVoidPtr(cobj);} +#endif + *f = tmp.fp; + if (!(*f)) + goto bad; + Py_DECREF(d); + return 0; +bad: + Py_XDECREF(d); + return -1; +} +#endif + + +static int import_efl__eo(void) { + PyObject *module = 0; + module = __Pyx_ImportModule("efl.eo"); + if (!module) goto bad; + if (__Pyx_ImportFunction(module, "object_from_instance", (void (**)(void))&__pyx_f_3efl_2eo_object_from_instance, "PyObject *(Eo *)") < 0) goto bad; + if (__Pyx_ImportFunction(module, "instance_from_object", (void (**)(void))&__pyx_f_3efl_2eo_instance_from_object, "Eo *(PyObject *)") < 0) goto bad; + Py_DECREF(module); module = 0; + return 0; + bad: + Py_XDECREF(module); + return -1; +} + +#endif /* !__PYX_HAVE_API__efl__eo */