pax_global_header00006660000000000000000000000064141253507130014513gustar00rootroot0000000000000052 comment=1cb622b9e47a38795488820a91f4e635a9955a58 confy-0.6.1/000077500000000000000000000000001412535071300126355ustar00rootroot00000000000000confy-0.6.1/.buildconfig000066400000000000000000000003111412535071300151160ustar00rootroot00000000000000[default] name=Default runtime=host toolchain=default config-opts= run-opts= prefix=/home/fabio/.cache/gnome-builder/install/confy/host app-id= postbuild= prebuild= default=true [default.environment] confy-0.6.1/.gitignore000066400000000000000000000033441412535071300146310ustar00rootroot00000000000000 # Created by https://www.gitignore.io/api/ninja,python # Edit at https://www.gitignore.io/?templates=ninja,python ### Ninja ### .ninja_deps .ninja_log ### Python ### # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # pyenv .python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. # However, in case of collaboration, if having platform-specific dependencies or dependencies # having no cross-platform support, pipenv may install dependencies that don't work, or not # install all needed dependencies. #Pipfile.lock # celery beat schedule file celerybeat-schedule # SageMath parsed files *.sage.py # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # Mr Developer .mr.developer.cfg .project .pydevproject # mkdocs documentation /site # mypy .mypy_cache/ .dmypy.json dmypy.json # Pyre type checker .pyre/ # End of https://www.gitignore.io/api/ninja,python work/ *~ .flatpak-builder/ .*env confy-0.6.1/CHANGELOG000066400000000000000000000034451412535071300140550ustar00rootroot00000000000000# CHANGELOG ## [unreleased] ## [0.6.1] - 2021-07-18 ### Add - Support for adaptive filter in Phosh app drawer ### Fixed - Event progressbar handle events with zero duration (devrtz) (fix ~fabrixxm/confy#18) ### Changed - Store events datetimes as UTC in db, display in current timezone. ## [0.6.0] - 2021-06-12 ### Added - Full-text search in shedule view (fix ~fabrixxm/confy#11) - Full-text search in starred view (fix ~fabrixxm/confy#12) ### Fixed - Add page stack to starred view (fix ~fabrixxm/confy#13) - Move Search Bar revealer out of overlay (fix ~fabrixxm/confy#10) ### Changed - Modify primary menu to better fit GNOME guidelines (seabass) - Move 'star event' button to end of event widget (seabass) ## [0.5.5] - 2020-04-06 ### Added - Open urls with default application per file type, if possible ## [0.5.4] - 20201-02-18 ### Fixed - Use correct file for appstream metadata - Remove more unsupported markup tags from strings - Fix "next up" query and notification ### Changed - Updated flatpack to GNOME Runtime 3.38 ## [0.5.3] - 2021-01-28 ### Added - Event progress indicator in event list row widget ### Fixed - Fix overlapping events query (don't return event ending/starting on same exact time) ## [0.5.2] - 2021-01-17 ### Added - Search in conferences list - Global shortcuts - Shortcuts window ### Changed - Install python module in python's site-lib dir - Fix metadata install path - Fix flatpak manifest: add python deps ## [0.5.1] - 2020-12-30 ### Added - Allow edit user-added conference metadata - Allow remove user-added conferences - Show editing dialog after adding a custom url - Clear cache from preferences dialog ### Changed - Set a maximum size for conferece logo in main page ### Fixed - Small fixes to UI - Support "baseurl" property in pentabarf - Fix XML entities stripping confy-0.6.1/COPYING000066400000000000000000001045141412535071300136750ustar00rootroot00000000000000 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 . confy-0.6.1/README.md000066400000000000000000000020051412535071300141110ustar00rootroot00000000000000 # Confy Conferences schedule viewer for GNOME Navigate Conference schedules, mark favourite talks Built with python3, gtk3, libhandy - [Home Page](https://confy.kirgroup.net) - [Project Page](https://sr.ht/~fabrixxm/Confy) - [Patches and discussions](https://lists.sr.ht/~fabrixxm/confy-dev) - [Tickets](https://todo.sr.ht/~fabrixxm/confy) ## Packages - [Arch Linux](https://aur.archlinux.org/packages/confy-git/) (AUR) ## Build Requirements - Gtk3 - libhandy 1 - Python3 - python-gobjects - python-icalendar - meson and ninja ### Build with Gnome Builder Use "Clone repository..." from Open window, press "Run" ### Build from command line git clone https://git.sr.ht/~fabrixxm/confy cd confy meson . _build ninja -C _build ninja -C _build install ## Issues and Patches Send issues to [~fabrixxm/confy@todo.sr.ht](https://todo.sr.ht/~fabrixxm/confy) Send patches to [~fabrixxm/confy-dev@lists.sr.ht](https://lists.sr.ht/~fabrixxm/confy-dev) confy-0.6.1/build-aux/000077500000000000000000000000001412535071300145275ustar00rootroot00000000000000confy-0.6.1/build-aux/meson/000077500000000000000000000000001412535071300156505ustar00rootroot00000000000000confy-0.6.1/build-aux/meson/postinstall.py000077500000000000000000000012141412535071300205770ustar00rootroot00000000000000#!/usr/bin/env python3 from os import environ, path from subprocess import call prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local') datadir = path.join(prefix, 'share') destdir = environ.get('DESTDIR', '') # Package managers set this so we don't need to run if not destdir: print('Updating icon cache...') call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')]) print('Updating desktop database...') call(['update-desktop-database', '-q', path.join(datadir, 'applications')]) print('Compiling GSettings schemas...') call(['glib-compile-schemas', path.join(datadir, 'glib-2.0', 'schemas')]) confy-0.6.1/data/000077500000000000000000000000001412535071300135465ustar00rootroot00000000000000confy-0.6.1/data/data.gresource.xml000066400000000000000000000002521412535071300171750ustar00rootroot00000000000000 net.kirgroup.confy.svg confy-0.6.1/data/meson.build000066400000000000000000000040311412535071300157060ustar00rootroot00000000000000pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) if get_option('devel') install_data( 'net.kirgroup.confy.Devel.svg', rename: ['net.kirgroup.confy.svg'], install_dir: join_paths( get_option('datadir'), 'icons', 'hicolor', 'scalable', 'apps' ) ) else install_data( 'net.kirgroup.confy.svg', install_dir: join_paths( get_option('datadir'), 'icons', 'hicolor', 'scalable', 'apps' ) ) endif install_data( 'net.kirgroup.confy-symbolic.svg', install_dir: join_paths( get_option('datadir'), 'icons', 'hicolor', 'symbolic', 'apps' ) ) gnome = import('gnome') gnome.compile_resources('confy.data', 'data.gresource.xml', gresource_bundle: true, install: true, install_dir: pkgdatadir, ) desktop_file = i18n.merge_file( input: 'net.kirgroup.confy.desktop.in', output: 'net.kirgroup.confy.desktop', type: 'desktop', po_dir: '../po', install: true, install_dir: join_paths(get_option('datadir'), 'applications') ) desktop_utils = find_program('desktop-file-validate', required: false) if desktop_utils.found() test('Validate desktop file', desktop_utils, args: [desktop_file] ) endif metainfo_file = i18n.merge_file( input: 'net.kirgroup.confy.metainfo.xml.in', output: 'net.kirgroup.confy.metainfo.xml', type: 'xml', po_dir: join_paths (meson.source_root(), 'po'), install: true, install_dir: join_paths (get_option ('datadir'), 'metainfo') ) appstream_cli = find_program('appstream-util', required: false) if appstream_cli.found() test('Validate appstream file', appstream_cli, args: ['validate', '--nonet', metainfo_file] ) endif install_data('net.kirgroup.confy.gschema.xml', install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas') ) compile_schemas = find_program('glib-compile-schemas', required: false) if compile_schemas.found() test('Validate schema file', compile_schemas, args: ['--strict', '--dry-run', meson.current_source_dir()] ) endif confy-0.6.1/data/net.kirgroup.confy-symbolic.svg000066400000000000000000000020741412535071300216550ustar00rootroot00000000000000 confy-0.6.1/data/net.kirgroup.confy.Devel.svg000066400000000000000000000457341412535071300211060ustar00rootroot00000000000000 confy-0.6.1/data/net.kirgroup.confy.Source.svg000066400000000000000000005572641412535071300213150ustar00rootroot00000000000000 Adwaita Icon Template image/svg+xml GNOME Design Team Adwaita Icon Template battery is full and there is no a/c connected. confy-0.6.1/data/net.kirgroup.confy.desktop.in000066400000000000000000000003171412535071300213130ustar00rootroot00000000000000[Desktop Entry] Name=Confy Exec=confy Terminal=false Type=Application Categories=Utility;GTK; StartupNotify=true Icon=net.kirgroup.confy Keywords=Conference;Organize; X-Purism-FormFactor=Workstation;Mobile; confy-0.6.1/data/net.kirgroup.confy.gschema.xml000066400000000000000000000011631412535071300214430ustar00rootroot00000000000000 2 Events list cache duration App will auto-update cache (if possible) when it's older than setting. 2 Event info cache duration App will auto-update cache (if possible) when it's older than setting. confy-0.6.1/data/net.kirgroup.confy.metainfo.xml.in000066400000000000000000000056321412535071300222500ustar00rootroot00000000000000 net.kirgroup.confy Confy Fabio Comuni ~fabrixxm/confy-dev@lists.sr.ht Conference schedules viewer

Confy lets you browse conference schedules.

Browse talks by day, track or room. Select the talks you are interested in and receive notification when they are about to start. View when two or more talks you are interested in overlap.

net.kirgroup.confy.desktop CC-BY-4.0 GPL-3.0-or-later https://confy.kirgroup.net https://todo.sr.ht/~fabrixxm/confy GNOME https://confy.kirgroup.net/appdata/confy1.jpg https://confy.kirgroup.net/appdata/confy2.jpg https://confy.kirgroup.net/appdata/confy3.jpg workstation mobile

Fix event progressbar for events with zero duration

Display events talks datetimes in current timezone

Declare support for mobile devices in metadata

Search talks in schedule and starred view

Better page navigation in starred view

Varius enhancement to UI to better fit GNOME guidelines

Open urls with default application per file type, if possible.

Fix "next up" query and notification.

Fix text rendering issues with unsupported markup tags.

Add event progress indicator.

Fix overlapping events definition: exclude events ending/starting on same exact time.

confy-0.6.1/data/net.kirgroup.confy.svg000066400000000000000000000211351412535071300200350ustar00rootroot00000000000000 confy-0.6.1/makepo.sh000077500000000000000000000001751412535071300144530ustar00rootroot00000000000000#!/bin/bash cd "$(dirname \"$0\")" [ ! -d bld ] && meson bld ninja -C bld/ confy-pot ninja -C bld/ confy-update-po rm -r bld confy-0.6.1/meson.build000066400000000000000000000004161412535071300150000ustar00rootroot00000000000000project('confy', version: '0.6.1', meson_version: '>= 0.50.0', default_options: [ 'warning_level=2', ], ) i18n = import('i18n') subdir('data') subdir('src') subdir('po') meson.add_install_script('build-aux/meson/postinstall.py') confy-0.6.1/meson_options.txt000066400000000000000000000000611412535071300162670ustar00rootroot00000000000000option('devel', type : 'boolean', value : false) confy-0.6.1/net.kirgroup.confy.json000066400000000000000000000032721412535071300173000ustar00rootroot00000000000000{ "app-id" : "net.kirgroup.confy", "runtime" : "org.gnome.Platform", "runtime-version" : "3.38", "sdk" : "org.gnome.Sdk", "command" : "confy", "finish-args" : [ "--share=network", "--share=ipc", "--socket=fallback-x11", "--socket=wayland", "--device=dri", "--talk-name=org.freedesktop.Notifications" ], "cleanup" : [ "/include", "/lib/pkgconfig", "/lib/debug", "/man", "/share/doc", "/share/gtk-doc", "/share/man", "/share/pkgconfig", "*.la", "*.a" ], "modules" : [ { "name" : "libhandy", "buildsystem" : "meson", "config-opts" : [ "-Dprofiling=false", "-Dintrospection=enabled", "-Dgtk_doc=false", "-Dtests=false", "-Dexamples=false", "-Dvapi=false", "-Dglade_catalog=disabled" ], "sources" : [ { "type" : "git", "url" : "https://gitlab.gnome.org/GNOME/libhandy.git", "tag" : "1.0.3", "commit" : "7126d2e8da9dcdeb5751e60ff6a74930804f9637" } ] }, "python3-icalendar.json", { "name" : "confy", "builddir" : true, "buildsystem" : "meson", "sources" : [ { "type" : "dir", "path" : "." } ], "config-opts" : [] } ], "build-options" : { "env" : { } } } confy-0.6.1/po/000077500000000000000000000000001412535071300132535ustar00rootroot00000000000000confy-0.6.1/po/LINGUAS000066400000000000000000000000031412535071300142710ustar00rootroot00000000000000it confy-0.6.1/po/POTFILES000066400000000000000000000005421412535071300144240ustar00rootroot00000000000000data/net.kirgroup.confy.desktop.in data/net.kirgroup.confy.metainfo.xml.in data/net.kirgroup.confy.gschema.xml src/main.py src/window.py src/pages.py src/widgets.py src/models.py src/config.py.in src/remotes/pentabarf.py src/remotes/ics.py src/remotes/exceptions.py src/remotes/__init__.py src/settings.py src/preferences.py src/fetcher.py src/local.py confy-0.6.1/po/it.po000066400000000000000000000236511412535071300142360ustar00rootroot00000000000000# Italian translations for confy package. # Copyright (C) 2020 THE confy'S COPYRIGHT HOLDER # This file is distributed under the same license as the confy package. # Automatically generated, 2020. # Fabrix Xm , 2020-2021. # msgid "" msgstr "" "Project-Id-Version: confy\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-06-12 21:09+0200\n" "PO-Revision-Date: 2021-06-12 21:18+0200\n" "Last-Translator: Fabrix Xm \n" "Language-Team: Italian <~fabrixxm/confy-dev@lists.sr.ht>\n" "Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" "X-Generator: Gtranslator 40.0\n" #: data/net.kirgroup.confy.desktop.in:3 #: data/net.kirgroup.confy.metainfo.xml.in:4 msgid "Confy" msgstr "Confy" #: data/net.kirgroup.confy.desktop.in:10 msgid "Conference;Organize;" msgstr "Conferenze;Organizza;" #: data/net.kirgroup.confy.metainfo.xml.in:5 msgid "Fabio Comuni" msgstr "Fabio Comuni" #: data/net.kirgroup.confy.metainfo.xml.in:7 src/window.py:805 msgid "Conference schedules viewer" msgstr "Visualizzatore di programmi di conferenze" #: data/net.kirgroup.confy.metainfo.xml.in:9 msgid "Confy lets you browse conference schedules." msgstr "Confy permette di navigare i programmi delle conferenze" #: data/net.kirgroup.confy.metainfo.xml.in:12 msgid "" "Browse talks by day, track or room. Select the talks you are interested in " "and receive notification when they are about to start. View when two or more " "talks you are interested in overlap." msgstr "" "Sfoglia i talk per giorno, traccia o stanza. Seleziona i talk che ti " "interessano e ricevi una notifica quando stanno per iniziare. Visualizza " "quando due o più talk a cui sei interessato si sovrappongono." #: data/net.kirgroup.confy.metainfo.xml.in:33 msgid "Search talks in schedule and starred view" msgstr "Ricerca talk nelle viste Programma e Preferiti" #: data/net.kirgroup.confy.metainfo.xml.in:34 msgid "Better page navigation in starred view" msgstr "Navigazione tra pagine migliorata nella vista Preferiti" #: data/net.kirgroup.confy.metainfo.xml.in:35 msgid "Varius enhancement to UI to better fit GNOME guidelines" msgstr "" "Varie migliorie all'interfaccia per conformarsi meglio alle linee guida di " "GNOME" #: data/net.kirgroup.confy.metainfo.xml.in:40 msgid "Open urls with default application per file type, if possible." msgstr "" "Apri utl con l'applcazione di default per il tipo di file, se possibile." #: data/net.kirgroup.confy.metainfo.xml.in:45 msgid "Fix \"next up\" query and notification." msgstr "Sistema query e notifiche \"in arrivo\"" #: data/net.kirgroup.confy.metainfo.xml.in:46 msgid "Fix text rendering issues with unsupported markup tags." msgstr "Sistema i problemi nel rendere il testo a causa di tag non supportati" #: data/net.kirgroup.confy.metainfo.xml.in:51 msgid "Add event progress indicator." msgstr "Aggiunge un indicatore di progresso dei talk" #: data/net.kirgroup.confy.metainfo.xml.in:52 msgid "" "Fix overlapping events definition: exclude events ending/starting on same " "exact time." msgstr "" "Sistema la definizione degli eventi sovrapposti: esclude gli eventi che " "iniziano/finiscono alla stessa identica ora." #: data/net.kirgroup.confy.gschema.xml:7 src/preferences.py:46 msgid "Events list cache duration" msgstr "Durata cache lista eventi" #: data/net.kirgroup.confy.gschema.xml:8 data/net.kirgroup.confy.gschema.xml:13 msgid "App will auto-update cache (if possible) when it's older than setting." msgstr "" "L'app aggiornerà automaticamente (se possibile) la cache quando è più " "vecchia di quanto impostato" #: data/net.kirgroup.confy.gschema.xml:12 msgid "Event info cache duration" msgstr "Durata cache informazioni evento" #: src/window.py:91 msgid "No conferences yet." msgstr "Ancora nessuna conferenza." #: src/window.py:92 msgid "Add a conference with the add button in title bar." msgstr "" "Aggiungi una conferenza con il bottone \"Aggiungi\" nella barra del titolo." #: src/window.py:96 src/pages.py:358 src/pages.py:541 msgid "No matches found" msgstr "Nessuna corrispondenza trovata" #: src/window.py:120 src/window.py:184 src/window.py:253 msgid "" "Error loading events list:\n" "{}" msgstr "" "Errore caricando la lista eventi\n" "{}" #: src/window.py:129 src/window.py:332 msgid "Show window menu" msgstr "Mostra menù finestra" #: src/window.py:135 msgid "Refresh events list" msgstr "Aggiorna lista eventi" #: src/window.py:141 msgid "Add event from URL" msgstr "Aggiungi evento da URL" #: src/window.py:151 msgid "Find event" msgstr "Trova evento" #: src/window.py:181 msgid "Events list updated" msgstr "Lista eventi aggiornata" #: src/window.py:211 msgid "" "New event:\n" "{}" msgstr "" "Nuovo evento:\n" "{}" #: src/window.py:214 src/window.py:230 src/window.py:605 msgid "" "Error:\n" "{}" msgstr "" "Errore:\n" "{}" #: src/window.py:259 msgid "Past" msgstr "Passate" #: src/window.py:261 msgid "Coming up" msgstr "In arrivo" #: src/window.py:327 msgid "Edit info" msgstr "Modifica informazioni" #: src/window.py:328 msgid "Return to events list" msgstr "Torna alla lista eventi" #: src/window.py:345 src/window.py:531 msgid "Error loading event" msgstr "Errore caricando l'evento" #: src/window.py:375 msgid "Go back" msgstr "Vai indietro" #: src/window.py:385 msgid "Find talk" msgstr "Trova talks" #. main stack content #: src/window.py:446 msgid "Schedule" msgstr "Programma" #: src/window.py:450 msgid "Starred" msgstr "Preferiti" #: src/window.py:456 msgid "Map" msgstr "Mappa" #: src/window.py:582 msgid "" "Updated event:\n" "{}" msgstr "" "Evento aggiornato:\n" "{}" #: src/window.py:585 msgid "" "Deleted event:\n" "{}" msgstr "" "Evento rimosso:\n" "{}" #: src/window.py:600 msgid "Event schedule updated" msgstr "Programma aggiornato" #: src/window.py:621 msgid "Next up: {}" msgstr "Prossimo: {}" #: src/window.py:622 msgid "at {} in {}" msgstr "alle {} in {}" #: src/window.py:792 msgid "Preferences" msgstr "Preferenze" #: src/window.py:793 msgid "Keyboard shortcuts" msgstr "Scorciatoie da tastiera" #: src/window.py:794 msgid "About {}" msgstr "Informazioni su {}" #: src/pages.py:238 msgid "cache updated" msgstr "cache aggiornata" #: src/pages.py:247 src/pages.py:584 msgid "Days" msgstr "Giorni" #: src/pages.py:261 msgid "Talks on {}" msgstr "Presentazioni il {}" #: src/pages.py:269 src/pages.py:585 msgid "Tracks" msgstr "Temi" #: src/pages.py:294 msgid "{} Track" msgstr "Tema {}" #: src/pages.py:303 src/pages.py:586 msgid "Rooms" msgstr "Stanze" #: src/pages.py:312 msgid "No Room" msgstr "Nessuna Stanza" #: src/pages.py:314 msgid "Room {}" msgstr "Stanza {}" #: src/pages.py:427 msgid "Room: {}" msgstr "Stanza: {}" #: src/pages.py:432 msgid "Track: {}" msgstr "Tema: {}" #: src/pages.py:448 msgid "Conflicts with" msgstr "In conflitto con" #: src/pages.py:478 msgid "Links" msgstr "Collegamenti" #: src/pages.py:534 msgid "Starred Talks" msgstr "Preferiti" #: src/pages.py:535 msgid "You don't have any starred talk yet." msgstr "Non hai nessun preferito ancora." #: src/pages.py:536 msgid "" "Click on the star button to add a talk to this list and to be reminded when " "they are about to start." msgstr "" "Cilcca sul bottone con la stella per aggiungere una presentazione a questa " "lista e ricevere un promemoria quando stanno per iniziare." #: src/widgets.py:173 msgid "{}" msgstr "{}" #: src/widgets.py:194 msgid "Loading…" msgstr "Caricamento…" #: src/widgets.py:261 msgid "Loading…" msgstr "Caricamento…" #: src/widgets.py:328 msgid "Cancel" msgstr "Annulla" #: src/widgets.py:329 msgid "Ok" msgstr "Ok" #: src/widgets.py:355 msgid "Schedule URL" msgstr "URL Programma" #: src/widgets.py:380 msgid "Edit Conference" msgstr "Modifica Conferenza" #: src/widgets.py:452 msgid "URL" msgstr "URL" #: src/widgets.py:460 msgid "Title" msgstr "Titolo" #: src/widgets.py:468 msgid "Start" msgstr "Inizio" #: src/widgets.py:477 msgid "End" msgstr "Fine" #: src/widgets.py:484 msgid "Icon URL" msgstr "URL icona" #: src/widgets.py:495 msgid "Delete" msgstr "Rimuovi" #: src/config.py.in:5 msgid "%b %a %d %Y" msgstr "%a %d %B %Y" #: src/remotes/pentabarf.py:38 msgid "Invalid pentabarf format" msgstr "Formato pentabarf non valido" #: src/remotes/__init__.py:35 msgid "Unknown schedule format" msgstr "Formato programma sconosciuto" #: src/settings.py:36 msgid "No cache" msgstr "Nessuna cache" #: src/settings.py:37 msgid "One hour" msgstr "Un ora" #: src/settings.py:38 msgid "One day" msgstr "Un giorno" #: src/settings.py:39 msgid "One week" msgstr "Una settimana" #: src/preferences.py:47 src/preferences.py:53 msgid "App will auto-update cache (if possible) when it's older than this." msgstr "" "L'app aggiornerà automaticamente (se possible) la cache quando è più vecchia." #: src/preferences.py:52 msgid "Events info cache duration" msgstr "Durata cache informazioni eventi" #: src/preferences.py:62 msgid "Clear" msgstr "Pulisci" #: src/preferences.py:66 msgid "Cached data" msgstr "Dati in cache" #: src/preferences.py:83 msgid "Confy has {} of cached data" msgstr "Confy ha {} di dati in cache" #: src/local.py:147 msgid "Device disconnected and no cached data available." msgstr "Dispositivo disconnesso e nessun dato locale disponibile." #: src/local.py:273 msgid "Event already in list" msgstr "Evento già in lista" #~ msgid "Quit" #~ msgstr "Chiudi" #~ msgid "" #~ "Confy lets you organise your visit - select talks to be reminded of (with " #~ "warnings in case of conflicts)." #~ msgstr "" #~ "Confy ti permette di organizzare la tua visita - seleziona le " #~ "presentazioni da ricordare (con avvisi in caso di conflitti)" #, fuzzy #~ msgid "Conference schedule viewer" #~ msgstr "Visualizzatore di programmi di conferenze" #~ msgid "Conferences schedule viewer" #~ msgstr "Visualizzatore di programmi di conferenze" confy-0.6.1/po/meson.build000066400000000000000000000000461412535071300154150ustar00rootroot00000000000000i18n.gettext('confy', preset: 'glib') confy-0.6.1/python3-icalendar.json000066400000000000000000000037511412535071300170620ustar00rootroot00000000000000{ "name": "python3-icalendar", "buildsystem": "simple", "build-commands": [ "pip3 install --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"icalendar\"" ], "sources": [ { "type": "file", "url": "https://files.pythonhosted.org/packages/aa/d4/0089d680a610c7b5afda26c1ae588eb363b9050ccf5f33a8c2d1164210f3/setuptools-51.1.2-py3-none-any.whl", "sha256": "67d8af2fc9f33e48f8f4387321700a79b27090a5cff154e5ce1a8c72c2eea54f" }, { "type": "file", "url": "https://files.pythonhosted.org/packages/65/63/39d04c74222770ed1589c0eaba06c05891801219272420b40311cd60c880/wheel-0.36.2-py2.py3-none-any.whl", "sha256": "78b5b185f0e5763c26ca1e324373aadd49182ca90e825f7853f4b2509215dc0e" }, { "type": "file", "url": "https://files.pythonhosted.org/packages/db/6e/2815f7c8561b088ccedc128681e64daac3d6b2e81a9918b007e244dad8b1/setuptools_scm-5.0.1-py2.py3-none-any.whl", "sha256": "62fa535edb31ece9fa65dc9dcb3056145b8020c8c26c0ef1018aef33db95c40d" }, { "type": "file", "url": "https://files.pythonhosted.org/packages/be/ed/5bbc91f03fa4c839c4c7360375da77f9659af5f7086b7a7bdda65771c8e0/python-dateutil-2.8.1.tar.gz", "sha256": "73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c" }, { "type": "file", "url": "https://files.pythonhosted.org/packages/70/44/404ec10dca553032900a65bcded8b8280cf7c64cc3b723324e2181bf93c9/pytz-2020.5.tar.gz", "sha256": "180befebb1927b16f6b57101720075a984c019ac16b1b7575673bea42c6c3da5" }, { "type": "file", "url": "https://files.pythonhosted.org/packages/58/b8/9aa7963f442b2a8bfdfc40eab8bc399c5eaac5711b8919c52122e4903544/icalendar-4.0.7.tar.gz", "sha256": "0fc18d87f66e0b5da84fa731389496cfe18e4c21304e8f6713556b2e8724a7a4" } ] } confy-0.6.1/src/000077500000000000000000000000001412535071300134245ustar00rootroot00000000000000confy-0.6.1/src/__init__.py000066400000000000000000000000001412535071300155230ustar00rootroot00000000000000confy-0.6.1/src/config.py.in000066400000000000000000000001461412535071300156510ustar00rootroot00000000000000APP_VERSION="@VERSION@" APP_NAME="Confy" APP_ID="net.kirgroup.confy" FMT_DAY_LIST = _("%b %a %d %Y") confy-0.6.1/src/confy.css000066400000000000000000000007511412535071300152570ustar00rootroot00000000000000/* default box margin inside a Clamp. That's the main box */ .main-box { margin: 16px 0; } /* remove margin and border on small width in first page I don't know from where the -2px margin comes from, but with 0 i still get some margin */ .clean-list clamp.small .main-box { margin: -2px 0; } .clean-list clamp.small .main-box > frame > border { border-width: 0; border-bottom-width: 1px;} /* floating toolbar over map */ .map-toolbar { border-radius: 5px; margin: 0 16px 16px 0; } confy-0.6.1/src/confy.gresource.xml000066400000000000000000000002651412535071300172640ustar00rootroot00000000000000 confy.css shortcuts.ui confy-0.6.1/src/confy.in000077500000000000000000000024231412535071300150760ustar00rootroot00000000000000#!@PYTHON@ # confy.in # # Copyright 2020 Fabio # # 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 . import os import sys import signal import gettext VERSION = '@VERSION@' pkgdatadir = '@pkgdatadir@' pythondir = '@pythondir@' localedir = '@localedir@' sys.path.insert(1, pythondir) signal.signal(signal.SIGINT, signal.SIG_DFL) gettext.install('confy', localedir) if __name__ == '__main__': import gi from gi.repository import Gio resource = Gio.Resource.load(os.path.join(pkgdatadir, 'confy.gresource')) resource._register() resource = Gio.Resource.load(os.path.join(pkgdatadir, 'confy.data.gresource')) resource._register() from confy import main sys.exit(main.main(VERSION)) confy-0.6.1/src/fetcher.py000066400000000000000000000070731412535071300154250ustar00rootroot00000000000000# fetcher.py # # Copyright 2020 Fabio # # 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 . from threading import Thread import os import tempfile import urllib.request from gi.repository import GLib from gi.repository import GObject class DownloadCancelled(Exception): pass class Fetcher(GObject.GObject): """ Fetch source to dest, asyncly. property running (bool, r) download is running fraction (floar, r) download progress 0.0 - 1.0 signals: error (message:str) done (local_file_path:str) """ @GObject.Signal(arg_types=(str,)) def error(self, message): ... @GObject.Signal(arg_types=(str,)) def done(self, local_file_path): ... @GObject.property def running(self): return self._run @GObject.property def fraction(self): return self._fraction def __init__(self, source, dest=None, cbk=None): """ download `source` to `dest` `source`: uri `dest`: path. if None, then temp `cbk` : function called when done: `fn(local_file_path)` `cbk` is called before firing `done` signal. If any exception is raised by `cbk`, `error` signal is fired, instead. """ super().__init__() self._run = True self._fraction = 0.0 self._cbk = cbk if dest is None: _, dest = tempfile.mkstemp() Thread(target=self._fetch, args=(source, dest)).start() def _fetch(self, source, dest): try: with urllib.request.urlopen(source, timeout=20) as fsrc, open(dest, "wb") as fdst: total_size = int(fsrc.info().get('Content-Length', 0)) block_size = 8192 dwl_size = 0 # python in runtime is old :) #while chunk := fsrc.read(block_size): chunk = fsrc.read(block_size) while chunk: if not self._run: raise DownloadCancelled("Download cacelled") fdst.write(chunk) if total_size > 0: dwl_size += block_size self._fraction = min(dwl_size, total_size) / total_size GLib.idle_add(self.notify,"fraction") chunk = fsrc.read(block_size) except Exception as e: if os.path.exists(dest): os.unlink(dest) import traceback; traceback.print_exc() GLib.idle_add(self.emit, "error", str(e)) else: GLib.idle_add(self._done, dest) def _done(self, dest): if self._cbk is not None: try: self._cbk(self, dest) except Exception as e: import traceback; traceback.print_exc() GLib.idle_add(self.emit, "error", str(e)) return GLib.idle_add(self.emit, "done", dest) def cancel(self): self._run = False self.notify("running") confy-0.6.1/src/local.py000066400000000000000000000240571412535071300151000ustar00rootroot00000000000000# local.py # # Copyright 2020 Fabio # # 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 . import types import os import json import hashlib import urllib.request import sqlite3 import importlib.util import datetime import time from gi.repository import GLib from .settings import Settings from .fetcher import Fetcher from . import remotes ### init and migration machinery class LocalDBDoesNotExistsException(Exception): pass class LocalDBNotOpen(Exception): pass dbfile = None db = None appdir = None cachedir = None def getDb(): return db def init(app_id:str): """Init paths and open db""" global appdir, cachedir appdir = os.path.join(GLib.get_user_data_dir(), app_id) if not os.path.exists(appdir): os.makedirs(appdir) cachedir = os.path.join(GLib.get_user_cache_dir(), app_id) if not os.path.exists(cachedir): os.makedirs(cachedir) Settings.init(app_id) def import_migration(filename:str) -> types.ModuleType: modulename = os.path.basename(filename).replace(".py", "") spec = importlib.util.spec_from_file_location(modulename, filename) migration = importlib.util.module_from_spec(spec) spec.loader.exec_module(migration) return migration def migrate(): schema = -1 migrated = False try: c = db.execute("SELECT value FROM meta WHERE key='schema'" ) info = c.fetchone() if info is not None: schema = int(info['value']) except Exception as e: print("... " , e) migrationsdir = os.path.join(os.path.dirname(__file__), "migrations") files = sorted([ f for f in os.listdir(migrationsdir) if f.endswith(".py") ]) try: c = db.cursor() for f in files: newschema = int(f.split("_")[0]) if newschema > schema: ## TODO: how to log using glib? print("Migrating to {}".format(f.replace(".py", ""))) import_migration(os.path.join(migrationsdir,f)).up(c) schema = newschema migrated = True except Exception as e: db.rollback() raise e from None db.execute("INSERT OR REPLACE INTO meta (key, value) VALUES ('schema', ?)", (schema,)) db.commit() return migrated # event database def openconf(conf, is_online=True): """Open event database for `conf` conf is a models.Conference After opening, tries to update meta """ def _update_meta(*args): from .models import Meta with Meta() as m: m.title = m.title if m.title else conf.title m.start = m.start if m.start else conf.start m.end = m.end if m.end else conf.end f = opendb(conf.url, is_online) if f is None: _update_meta() else: f.connect("done", _update_meta) return f def opendb(url, is_online=True): global dbfile """Open event database for `url` if `is_online`, fetch original pentabarf and update cache return Fetcher instance if downloading, else None """ global db dbhashname = hashlib.md5(url.encode('utf8')).hexdigest() dbfilename = os.path.join(cachedir, dbhashname+".db") if not os.path.exists(dbfilename) and not is_online: db = None raise LocalDBDoesNotExistsException(_("Device disconnected and no cached data available.")) print("open db", dbfilename) db = sqlite3.connect(dbfilename, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) db.row_factory = sqlite3.Row migrated = migrate() dbfile = dbfilename from .models import Meta is_time_to_update = (time.time() - Meta().last_update) > Settings.instance().get_event_cache() if is_online and (migrated or is_time_to_update): return updatedb(url) return None def updatedb(from_url): """Update event cache from schedule url return Fetcher instance """ if db is None: raise LocalDBNotOpen() return remotes.update_schedule(from_url) def close(): """Close db""" global db, dbfile dbfile = None if db is not None: db.close() db = None ## schedules list (from giggity and user defined) def update_menu() -> Fetcher: """Fetch remote menu json""" ggcachefile = os.path.join(cachedir, "ggmenu.json") url = "https://ggt.gaa.st/menu.json" return Fetcher(url, ggcachefile) def open_menu(is_online): """ Update menu cache file if expired or not exists. returns None or Fetcher """ ggcachefile = os.path.join(cachedir, "ggmenu.json") print("menu cache file:", ggcachefile) need_refresh = not os.path.exists(ggcachefile) need_refresh = need_refresh or ((time.time() - os.path.getmtime(ggcachefile)) > Settings.instance().get_list_cache()) if need_refresh and is_online: return update_menu() return None def get_menu(): """ Get menu entries from menu cache and from user menu entries. """ ggcachefile = os.path.join(cachedir, "ggmenu.json") userfile = os.path.join(cachedir, "usermenu.json") schedules = [] if os.path.exists(ggcachefile): with open(ggcachefile, "r") as f: menu = json.load(f) schedules += menu['schedules'] if os.path.exists(userfile): with open(userfile, "r") as f: schedules += json.load(f) def _sort_key(elm): start = elm['start'] return datetime.date(*[int(s) for s in start.split("-")]) return sorted(schedules, key=_sort_key, reverse=True) def _add_user_menu_ready(sender, local_file_path, cbk): userfile = os.path.join(cachedir, "usermenu.json") from .models import Meta m = Meta() item = m.to_json() if m.title is None: m.title = "" m.save() schedules = [] if os.path.exists(userfile): with open(userfile, "r") as f: schedules = json.load(f) schedules.append(item) with open(userfile, "w") as f: json.dump(schedules, f) cbk(m) close() class MenuItemAlreadyExistsException(Exception): def __init__(self, message, obj): super().__init__(message) self.obj = obj def add_user_menu(url, cbk): """ Add and fetch schedule from url. Returns Fetcher or None. When ready calls "cbk({..metadata..})" """ # try to not add same event twice: objs = [ e for e in get_menu() if e['url'] == url ] if len(objs) > 0: raise MenuItemAlreadyExistsException(_("Event already in list"), objs[0]) f = opendb(url, True) # I suppose that we are online at this point.. if f is not None: f.connect("done", _add_user_menu_ready, cbk) else: _add_user_menu_ready(None, None, cbk) return f def update_user_menu(data): """ Update user menu entry data is a dict() """ userfile = os.path.join(cachedir, "usermenu.json") if not os.path.exists(userfile): # non dovrei arrivare qui. solo i meta con user=True # posso essere editati, e quindi deve esistere il file raise Exception("User menu file not found. This should not happen.") with open(userfile, "r") as f: schedules = json.load(f) _id = None for i, s in enumerate(schedules): if s['url'] == data['url']: _id = i break if _id is None: schedules.append(data) else: schedules[_id] = data with open(userfile, "w") as f: json.dump(schedules, f) def delete_user_menu(data): """ Remove user menu entry `data` is a dict() """ userfile = os.path.join(cachedir, "usermenu.json") if not os.path.exists(userfile): # non dovrei arrivare qui. solo i meta con user=True # posso essere editati, e quindi deve esistere il file raise Exception("User menu file not found. This should not happen.") with open(userfile, "r") as f: schedules = json.load(f) _id = None for i, s in enumerate(schedules): if s['url'] == data['url']: _id = i break if _id is not None: del schedules[_id] with open(userfile, "w") as f: json.dump(schedules, f) # async image fetcher def get_image_async(fileurl, cbk): """ Save a remote image in local cache. Returns Fetcher or None When ready calls "cbk(None, 'localfilename')" """ if fileurl is None: return None localfilename = hashlib.md5(fileurl.encode('utf8')).hexdigest() localdir = os.path.join(cachedir, "images") if not os.path.exists(localdir): os.makedirs(localdir) localfile = os.path.join(localdir, localfilename) if not os.path.exists(localfile): try: return Fetcher(fileurl, localfile, cbk) except Exception: return None cbk(None, localfile) return None # cache handling def get_cache_size(): """get total size of cache files: db and images. skip json menu files""" total_size = 0 for dirpath, dirnames, filenames in os.walk(cachedir): for f in filenames: if not f.endswith(".json"): fp = os.path.join(dirpath, f) # skip if it is symbolic link if not os.path.islink(fp): total_size += os.path.getsize(fp) return total_size def clear_cache(): """remove all files in cachedir except currently opened database and json menu files""" for dirpath, dirnames, filenames in os.walk(cachedir): for f in filenames: if not f.endswith(".json"): fp = os.path.join(dirpath, f) if fp != dbfile: os.remove(fp) confy-0.6.1/src/main.py000066400000000000000000000065471412535071300147360ustar00rootroot00000000000000# main.py # # Copyright 2020 Fabio # # 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 . import sys import gi gi.require_version('Gtk', '3.0') gi.require_version('Handy', '1') gi.require_version("Notify", "0.7") from gi.repository import Gtk, Gdk, Gio, GLib, GObject from gi.repository import Handy from gi.repository import Notify from . import local from .config import APP_NAME, APP_ID from .window import ConfyWindow class Application(Gtk.Application): @GObject.Signal def tick(self): """Event fired every minute Used to check for notifications to send and to update events row background """ pass def __init__(self): super().__init__(application_id=APP_ID, flags=Gio.ApplicationFlags.FLAGS_NONE) GLib.set_application_name(APP_NAME) GLib.set_prgname(APP_ID) # custom css css_provider = Gtk.CssProvider() css_provider.load_from_resource("/net/kirgroup/confy/confy.css") Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) def run(self, argv): self.connect("startup", self.on_startup) self.connect("activate", self.on_activate) self.connect("shutdown", self.on_shutdown) return super().run(argv) def on_startup(self, *_): Handy.init() Notify.init(APP_NAME) local.init(APP_ID) quit_action = Gio.SimpleAction.new("quit", None) quit_action.connect("activate", lambda *args: self.quit() ) self.add_action(quit_action) self.set_accels_for_action("app.quit", ["q",]) shortcut_action = Gio.SimpleAction.new("shortcuts") shortcut_action.connect("activate", self.show_shortcuts) self.add_action(shortcut_action) self.set_accels_for_action("app.shortcuts", ["question"]) self.set_accels_for_action("win.show-preferences", ["comma",]) self.set_accels_for_action("win.return-to-events", ["l",]) self.set_accels_for_action("win.search", ["f",]) GLib.timeout_add_seconds(30, self._do_tick) def _do_tick(self): self.emit("tick") return True def on_activate(self, *_): win = self.props.active_window if not win: win = ConfyWindow(application=self) win.present() def on_shutdown(self, *_): local.close() def show_shortcuts(self, *_): b = Gtk.Builder.new_from_resource("/net/kirgroup/confy/shortcuts.ui") w = b.get_object("shortcuts-win") w.set_transient_for(self.props.active_window) w.props.view_name = None w.show() def main(version): app = Application() return app.run(sys.argv) confy-0.6.1/src/meson.build000066400000000000000000000022551412535071300155720ustar00rootroot00000000000000pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) gnome = import('gnome') gnome.compile_resources('confy', 'confy.gresource.xml', gresource_bundle: true, install: true, install_dir: pkgdatadir, ) python = import('python') python3 = python.find_installation('python3') pythondir = python3.get_install_dir() moduledir = join_paths(pythondir, 'confy') conf = configuration_data() conf.set('PYTHON', python3.path()) conf.set('VERSION', meson.project_version()) conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir'))) conf.set('pkgdatadir', pkgdatadir) conf.set('pythondir', pythondir) configure_file( input: 'confy.in', output: 'confy', configuration: conf, install: true, install_dir: get_option('bindir') ) configure_file( input: 'config.py.in', output: 'config.py', configuration: conf, install: true, install_dir: moduledir ) confy_sources = [ '__init__.py', 'main.py', 'window.py', 'widgets.py', 'pages.py', 'models.py', 'local.py', 'settings.py', 'fetcher.py', 'preferences.py', ] install_data(confy_sources, install_dir: moduledir) subdir('migrations') subdir('remotes') confy-0.6.1/src/migrations/000077500000000000000000000000001412535071300156005ustar00rootroot00000000000000confy-0.6.1/src/migrations/000_initial.py000066400000000000000000000030001412535071300201530ustar00rootroot00000000000000def up(cursor): cursor.execute("""CREATE TABLE IF NOT EXISTS meta ( key TEXT(20) PRIMARY KEY, value TEXT)""") cursor.execute("""CREATE TABLE IF NOT EXISTS persons ( id TEXT(50) PRIMARY KEY, name TEXT)""") cursor.execute("""CREATE TABLE IF NOT EXISTS event_person ( event_id TEXT(50), person_id TEXT(50), FOREIGN KEY(event_id) REFERENCES events(id), FOREIGN KEY(person_id) REFERENCES persons(id))""") cursor.execute("""CREATE TABLE IF NOT EXISTS events ( id TEXT(50) PRIMARY KEY, date DATE, start TIMESTAMP, end TIMESTAMP, room TEXT DEFAULT "", slug TEXT, title TEXT, subtitle TEXT, track TEXT DEFAULT "", type TEXT, abstract TEXT, description TEXT, starred INTEGER(1) DEFAULT 0, notified INTEGER(1) DEFAULT 0)""") cursor.execute("CREATE INDEX IF NOT EXISTS event_date ON events(date)") cursor.execute("CREATE INDEX IF NOT EXISTS event_room ON events(room)") cursor.execute("CREATE INDEX IF NOT EXISTS event_track ON events(track)") cursor.execute("CREATE INDEX IF NOT EXISTS event_starred ON events(starred)") cursor.execute("""CREATE TABLE IF NOT EXISTS links ( event_id TEXT(50), href TEXT, name TEXT, FOREIGN KEY(event_id) REFERENCES events(id))""") cursor.execute("CREATE UNIQUE INDEX IF NOT EXISTS name_event ON links(event_id, name)") def drop(cursor): ## I need this? ... confy-0.6.1/src/migrations/001_event_person_unique.py000066400000000000000000000005421412535071300226300ustar00rootroot00000000000000def up(cursor): cursor.execute("DROP TABLE IF EXISTS event_person") cursor.execute("""CREATE TABLE event_person ( event_id TEXT(50), person_id TEXT(50), FOREIGN KEY(event_id) REFERENCES events(id), FOREIGN KEY(person_id) REFERENCES persons(id), UNIQUE(event_id, person_id))""") def down(cursor): ... confy-0.6.1/src/migrations/002_full_text_search.py000066400000000000000000000002111412535071300220600ustar00rootroot00000000000000def up(cursor): cursor.execute("""CREATE VIRTUAL TABLE fts_event USING FTS5 (event_id, text)""") def down(cursor): ... confy-0.6.1/src/migrations/meson.build000066400000000000000000000003351412535071300177430ustar00rootroot00000000000000migrationsdir = join_paths(moduledir, 'migrations') migrations_sources = [ '000_initial.py', '001_event_person_unique.py', '002_full_text_search.py', ] install_data(migrations_sources, install_dir: migrationsdir) confy-0.6.1/src/models.py000066400000000000000000000315571412535071300152740ustar00rootroot00000000000000# models.py # # Copyright 2020 Fabio # # 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 . import datetime import time from gi.repository import GObject from dateutil.tz import UTC from . import local from .settings import Settings from .fetcher import Fetcher ## models def _build_filter(day=None, room=None, track=None, event=None, **kwargs): filterdata = [] wherestm = [] def __f(col, value): if value is None: wherestm.append("{} is null".format(col)) else: wherestm.append("{} = ?".format(col)) filterdata.append(value) if day is not None: __f("date", day.date) if room is not None: __f("room", room.name) if track is not None: __f("track", track.name) if event is not None: __f("id", event.id) for k,v in kwargs.items(): __f(k, v) return (filterdata, wherestm) class Conference: """A conference in menu files (ggmenu.json and usermenu.json)""" def _init(self, obj): self.metadata = {} self.user = False for k, v in obj.items(): setattr(self, k, v) self.start = datetime.date(*[int(s) for s in self.start.split("-")]) self.end = datetime.date(*[int(s) for s in self.end.split("-")]) return self def get_map_links(self): maps = [ l for l in self.metadata.get('links',[]) if l['title']=="Map" ] print("Conference maps links:", maps) return maps def get_map_files(self, cbk): r = [] for link in self.get_map_links(): r.append(local.get_image_async(link['url'], cbk)) return r def get_logo_file(self, cbk): logourl = self.metadata.get('icon', None) return local.get_image_async(logourl, cbk) def __repr__(self): return f"<{self.__class__.__name__} {self.__dict__}>" @classmethod def all(cls): # from giggity menu return [ cls()._init(s) for s in local.get_menu() ] @classmethod def by_url(cls, url): ss = [ s for s in local.get_menu() if url in s['url'] ] if len(ss) == 0: return None return cls()._init(ss[0]) def get_meta(self): """Return metadata from db. This will close any opened db connection.""" local.close() local.opendb(self.url, False) return Meta() local.close() def to_json(self): """Export conference meta as json for user menu""" d = self.__dict__.copy() for k in d: if isinstance(d[k], (datetime.date, datetime.datetime)): d[k] = d[k].strftime("%Y-%m-%d") return d class Meta: """Conference metadata from "meta" table in db""" def __init__(self): _c = local.getDb().execute("SELECT key, value FROM meta") _d = [(row['key'], row['value']) for row in _c] self._data = dict(_d) def _fmtd_value(self, k): v = self._data.get(k, None) if k == "start" or k == "end": if v is not None and v != "": if ":" in v: v = datetime.datetime.strptime(v, "%Y-%m-%d %H:%M:%S") else: v = datetime.datetime.strptime(v, "%Y-%m-%d") else: v = None if k == "last_update": v = 0 if v is None else float(v) return v def __getattr__(self, name): if name.startswith("_"): return super().__getattr__(name) return self._fmtd_value(name) def __setattr__(self, name, value): if name.startswith("_"): return super().__setattr__(name, value) self._data[name] = value def __enter__(self): return self def __exit__(self, *args): self.save() def __repr__(self): return f"<{self.__class__.__name__} {self.__dict__}>" def save(self): db = local.getDb() if db is None: local.opendb(self.url, False) db = local.getDb() db.executemany("INSERT OR REPLACE INTO meta (key, value) VALUES (?,?)", self._data.items()) db.commit() def to_json(self): """Export conference meta as json for user menu""" return { "url": self.url, "title": self.title if self.title else "", "start": self.start.strftime("%Y-%m-%d"), "end": self.end.strftime("%Y-%m-%d"), "user": True } class Day: def _init(self, data): self.date = data['date'] return self def __repr__(self): return "<{} {!r}>".format(self.__class__.__name__, self.date) def __str__(self): return self.date.strftime("%x") @classmethod def all(cls): for row in local.getDb().execute("SELECT date FROM events GROUP BY date"): yield cls()._init(row) @classmethod def count(cls): for row in local.getDb().execute("SELECT count(DISTINCT date) FROM events"): return row[0] @classmethod def filter(cls, room=None, track=None, event=None): filterdata, wherestm = _build_filter(room=room, track=track, event=event) query = """SELECT date FROM events WHERE {} GROUP BY date""".format(" AND ".join(wherestm)) for row in local.getDb().execute(query, filterdata): yield cls()._init(row) class Room: def _init(self, data): self.name = data['room'] return self def __repr__(self): return "<{} {!r}>".format(self.__class__.__name__, self.name) def __str__(self): return self.name or "- no room -" @classmethod def all(cls): for row in local.getDb().execute("SELECT room FROM events GROUP BY room"): yield cls()._init(row) @classmethod def count(cls): for row in local.getDb().execute("SELECT count(DISTINCT room) FROM events"): return row[0] @classmethod def filter(cls, day=None, track=None, event=None): filterdata, wherestm = _build_filter(day=day, track=track, event=event) query = """SELECT room FROM events WHERE {} GROUP BY room""".format(" AND ".join(wherestm)) for row in local.getDb().execute(query, filterdata): yield cls()._init(row) class Track: def _init(self, data): self.name = data['track'] self.room = list(Room.filter(track=self)) self.date = list(Day.filter(track=self)) return self def __repr__(self): return "<{} {!r} in {!r} @ {}>".format( self.__class__.__name__, self.name, self.room, self.date) def __str__(self): return self.name or "- no track -" @classmethod def all(cls): for row in local.getDb().execute( "SELECT track, room, date FROM events WHERE track != '' GROUP BY track ORDER BY date, track"): yield cls()._init(row) @classmethod def count(cls): for row in local.getDb().execute("SELECT count(DISTINCT track) FROM events"): return row[0] class Person: def _init(self, data): self.id = data['id'] self.name = data['name'] return self def events(self): for row in local.getDb().execute( """SELECT e.* FROM events as e LEFT JOIN event_person AS ep ON e.id = ep.event_id WHERE ep.person_id = ?""", (self.id,)): yield Event()._init(row) def __repr__(self): return "<{} {!r}>".format(self.__class__.__name__, self.name) def __str__(self): return self.name @classmethod def all(cls): for row in local.getDb().execute( "SELECT id, name FROM persons"): yield cls()._init(row) class Link: def _init(self, event, data): self.event = event self.href = data['href'] self.name = data['name'] return self def __repr__(self): return "<{} for {!r} {!r} {!r}>".format( self.__class__.__name__, self.event, self.name, self.href) def __str__(self): return '{}'.format(self.href, self.name) class Event(GObject.GObject): __gsignals__ = { 'update': (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, ()) } def _init(self, data): self.id = data['id'] self.date = data['date'] self.start = data['start'] self.end = data['end'] self.room = data['room'] self.slug = data['slug'] self.title = data['title'] self.subtitle = data['subtitle'] or "" self.track = data['track'] self.evtype = data['type'] self.abstract = data['abstract'] or "" self.description = data['description'] or "" self.starred = data['starred'] == 1 self.notified = data['notified'] == 1 return self def set_star(self, starred): local.getDb().execute("UPDATE events SET starred=? WHERE id=?",(starred,self.id,)) local.getDb().commit() self.starred = starred self.emit('update') def set_notified(self, notified): local.getDb().execute("UPDATE events SET notified=? WHERE id=?",(notified,self.id,)) local.getDb().commit() self.notified = notified self.emit('update') def start_in_tz(self): return self._dt_in_tz(self.start) def end_in_tz(self): return self._dt_in_tz(self.end) def _dt_in_tz(self, dt): dt = dt.replace(tzinfo=UTC) dt = dt.astimezone(Settings.instance().get_timezone()) return dt def persons(self): #print("event", self.id, "persons()") for row in local.getDb().execute( """SELECT p.id, p.name FROM persons as p LEFT JOIN event_person AS ep ON p.id = ep.person_id WHERE ep.event_id = ?""", (self.id,)): yield Person()._init(row) def links(self): for row in local.getDb().execute( """SELECT href, name FROM links WHERE event_id=?""", (self.id,)): yield Link()._init(self, row) def __repr__(self): return "<{} {!r} in {!r} @ {!r}>".format(self.__class__.__name__, self.title, self.room, self.start) def __str__(self): return self.title def get_conflicts(self): query = """SELECT * FROM events WHERE starred = 1 AND id != ? AND date = ? AND end > ? AND start < ? """ for row in local.getDb().execute(query, (self.id, self.date, self.start, self.end)): yield Event()._init(row) @classmethod def all(cls): for row in local.getDb().execute("SELECT * FROM events"): yield cls()._init(row) @classmethod def filter(cls, day:Day = None, room:Room = None, track:Track = None, **kwargs): filterdata, wherestm = _build_filter(day=day, room=room, track=track, **kwargs) query = """SELECT * FROM events WHERE {} ORDER BY start, room""".format(" AND ".join(wherestm)) for row in local.getDb().execute(query, filterdata): yield cls()._init(row) @classmethod def nextup(cls, minutes): """get events starting in next `minutes`""" minutes = min(int(minutes), 30) # some sanity check now = datetime.datetime.now(UTC).replace(tzinfo=None).strftime("%Y-%m-%dT%H:%M:%S.000") # now = "now" # is "now" somehow broken? query = """SELECT * FROM events WHERE starred=1 AND notified=0 AND datetime(start) >= datetime("{1}") AND datetime(start) <= datetime("{1}", "+{0} minutes");""" for row in local.getDb().execute(query.format(minutes, now)): yield cls()._init(row) @classmethod def search(cls, term, starred=False): """Search events for 'term'""" starfilter = "" if starred: starfilter = "events.starred = 1 AND" query = """SELECT events.* FROM fts_event JOIN events ON events.id = fts_event.event_id WHERE {} fts_event = ? GROUP BY events.id ORDER BY rank""".format(starfilter) for row in local.getDb().execute(query, (term,)): yield cls()._init(row) confy-0.6.1/src/pages.py000066400000000000000000000542361412535071300151070ustar00rootroot00000000000000# pages.py # # Copyright 2020 Fabio # # 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 . import datetime import re import html from dateutil.tz import UTC from gi.repository import GLib from gi.repository import Gtk from gi.repository import GObject from gi.repository import GdkPixbuf from gi.repository import Gio from gi.repository import Handy from .widgets import ListRowHeader, WebLinkActionRow, EventActionRow, MenuBoxRow from .widgets import PlaceholderWidget from .widgets import weblinkactionrowactivated from .widgets import SimpleScalableImage, MaxSizedImage from .config import APP_NAME, APP_ID, APP_VERSION, FMT_DAY_LIST from . import models def _clean_markup(text): """remove unsupported markup from text to use in label""" text = text.replace("

", "").replace("

", "\n\n") text = text.replace("", "").replace("", "") text = text.replace("", "").replace("", "") text = text.replace("
", "\n").replace("
", "\n") text = text.replace("

", "").replace("

", "") text = text.replace("

", "").replace("

", "") text = text.replace("

", "").replace("

", "") text = text.replace("
", "\n").replace("
", "") text = re.sub(r'
', "\n", text) text = html.unescape(text) text = text.replace("&", "&") # TODO: this is quite bad... text = re.sub(r'style="[^"]*"', "", text) return text.strip() class BasePage(Gtk.ScrolledWindow): """Base class for all pages""" def __init__(self, **kwargs): opts = dict( hexpand=True, vexpand=True, width_request=200, kinetic_scrolling=True, hscrollbar_policy=Gtk.PolicyType.NEVER ) if kwargs is not None: opts.update(kwargs) super().__init__(**opts) self.column = Handy.Clamp( tightening_threshold=500, # dimensione sotto la quale decide di occupare tutto lo spazio maximum_size=640) # dimensione massima allragandosi super().add(self.column) def add(self, widget): self.column.add(widget) def _set_pagestack(self, pageStack): self.pageStack = pageStack class BaseListPage(BasePage): """Base class for ListBox based pages""" title = "" subtitle = "" def __init__(self, title=None, subtitle=None, **kwargs): super().__init__(**kwargs) title = title or self.title subtitle = subtitle or self.subtitle box = Gtk.VBox() box.get_style_context().add_class("main-box") if title != "" or subtitle != "": titlebox = Gtk.VBox(margin_left=8, margin_right=8) if title != "": label = Gtk.Label(halign=Gtk.Align.START) label.set_markup("{}".format(title.replace("&", "&"))) titlebox.pack_start(label, False, False, 0) if subtitle != "": label = Gtk.Label(halign=Gtk.Align.START) label.set_markup("{}".format(subtitle.replace("&", "&"))) label.get_style_context().add_class("dim-label") titlebox.pack_start(label, False, False, 0) box.pack_start(titlebox, False, False, 2) frame = Gtk.Frame(valign=Gtk.Align.START) listbox = Gtk.ListBox() listbox.connect('row-activated', self.on_activate) #listbox.get_style_context().add_class("content") listbox.set_header_func(self.build_list_header, None) self.listbox = listbox # TODO: use list model? self.update_list() frame.add(listbox) box.pack_start(frame, True, True, 2) self.add(box) def update_list(self, *args): self.data = list(self.get_objects()) for w in self.listbox.get_children(): w.destroy() lastgroup = None for obj in self.data: mn = self.build_row(obj) self.listbox.add(mn) self.listbox.show_all() def get_objects(self): return [] def build_list_header(self, row, before, *user_data): if len(self.data) == 0: return obj1 = self.data[row.get_index()] group_txt1 = self.group_by(obj1) if group_txt1 is None: return if before is None: h = ListRowHeader(group_txt1) row.set_header(h) return obj2 = self.data[before.get_index()] group_txt2 = self.group_by(obj2) if group_txt2 != group_txt1: h = ListRowHeader(group_txt1) row.set_header(h) def group_by(self, obj): return None def build_row(self, obj): row = Handy.ActionRow(activatable=True, selectable=False) row.set_title(str(obj)) return row def on_activate(self, listbox, actionrow): ... class ConferencePage(BasePage): """Conference detail page""" def _set_logo(self, fetcher, logofile): pixbuf = GdkPixbuf.Pixbuf.new_from_file(logofile) self.logoimage.set_from_pixbuf(pixbuf) def __init__(self, conf, **kwargs): super().__init__(**kwargs) meta = models.Meta() LBL_PROPS = { 'justify': Gtk.Justification.CENTER, 'halign' : Gtk.Align.CENTER, 'wrap' : False, } box = Gtk.VBox(valign=Gtk.Align.CENTER) self.logoimage = MaxSizedImage(max_width=200, max_height=200) f = conf.get_logo_file(cbk=self._set_logo) box.pack_start(self.logoimage, False, False, 16) if meta.title: label = Gtk.Label(**LBL_PROPS) label.set_markup("{}".format(_clean_markup(meta.title))) box.pack_start(label, False, False, 16) if meta.venue is not None: label = Gtk.Label(html.unescape(meta.venue), **LBL_PROPS) label.get_style_context().add_class("dim-label") box.pack_start(label, False, False, 0) if meta.city is not None: label = Gtk.Label(html.unescape(meta.city), **LBL_PROPS) label.get_style_context().add_class("dim-label") box.pack_start(label, False, False, 0) datebox = Gtk.VBox() if meta.start is not None: label = Gtk.Label(meta.start.strftime(FMT_DAY_LIST), **LBL_PROPS) datebox.pack_start(label, False, False, 8) if meta.end is not None and meta.end != meta.start: label = Gtk.Label(meta.end.strftime(FMT_DAY_LIST), **LBL_PROPS) datebox.pack_start(label, False, False, 8) box.pack_start(datebox, False, False, 16) links = conf.metadata.get('links',None) if links is not None: frame = Gtk.Frame() listbox = Gtk.ListBox() listbox.connect('row-activated', weblinkactionrowactivated) for l in links: if l['title'] != "Map": row = WebLinkActionRow(html.unescape(l['title']), l['url'], l.get('type', None)) listbox.add(row) frame.add(listbox) box.pack_start(frame, False, False, 16) label = Gtk.Label(justify= Gtk.Justification.RIGHT, halign=Gtk.Align.END) last_update = datetime.datetime.fromtimestamp(meta.last_update) label.set_markup("{}: {}".format(_("cache updated"), last_update.strftime("%c"))) label.get_style_context().add_class("dim-label") box.pack_start(label, False, False, 0) self.add(box) class DaysPage(BaseListPage): """Days list page""" title = _("Days") def get_objects(self): return models.Day.all() def build_row(self, obj): row = Handy.ActionRow(activatable=True, selectable=False) row.set_title(obj.date.strftime(FMT_DAY_LIST)) return row def on_activate(self, listbox, actionrow): idx = actionrow.get_index() obj = self.data[idx] page = EventsPage( title=_("Talks on {}").format(obj.date.strftime(FMT_DAY_LIST)), #group_by="room", day=obj) self.pageStack.pushPage(page) class TracksPage(BaseListPage): """Tracks list page""" title = _("Tracks") def get_objects(self): return models.Track.all() #def group_by(self, obj): # return obj.date.strftime(FMT_DAY_LIST) def build_row(self, obj): row = Handy.ActionRow(activatable=True, selectable=False) row.set_title(str(obj)) row.set_subtitle(", ".join([ str(r) for r in obj.room ])) return row def on_activate(self, listbox, actionrow): idx = actionrow.get_index() obj = self.data[idx] subtitle = [] if len(obj.room) == 1 and obj.room[0].name != "": subtitle.append(obj.room[0].name) if len(obj.date) == 1: subtitle.append(obj.date[0].date.strftime(FMT_DAY_LIST)) page = EventsPage( title=_("{} Track").format(obj), subtitle=", ".join(subtitle), track=obj, group_by="day") self.pageStack.pushPage(page) class RoomsPage(BaseListPage): """Rooms list page""" title = _("Rooms") def get_objects(self): return models.Room.all() def on_activate(self, listbox, actionrow): idx = actionrow.get_index() obj = self.data[idx] if obj.name is None: title = _("No Room") else: title = _("Room {}").format(obj.name) page = EventsPage( title=title, group_by="day", room=obj) self.pageStack.pushPage(page) class EventsPage(BaseListPage): """Talks list page (called "Events" from pentabarf xml)""" def __init__(self, title=None, subtitle=None, group_by=None, **filters): self.filters = filters self._group_by = group_by super().__init__(title=title, subtitle=subtitle) def group_by(self, obj): if self._group_by == "day": return obj.date.strftime(FMT_DAY_LIST) if self._group_by == "track": return obj.track if self._group_by == "room": return obj.room else: return None def get_objects(self): return models.Event.filter(**self.filters) def build_row(self, obj): row = EventActionRow(obj) return row def on_activate(self, listbox, actionrow): idx = actionrow.get_index() obj = self.data[idx] page = EventDetailPage(obj=obj) self.pageStack.pushPage(page) class SearchEventsPage(EventsPage): def __init__(self, searchbar): self.searchbar = searchbar self.nomatch_placeholder = PlaceholderWidget( text = _("No matches found"), icon_name = 'system-search' ) self.nomatch_placeholder.show_all() super().__init__() self.listbox.set_placeholder(self.nomatch_placeholder) def get_objects(self): sb = self.searchbar if sb.get_search_mode() and sb.entry.get_text() != "": search = sb.entry.get_text().lower() events = models.Event.search(search) else: events = [] return events class EventDetailPage(BasePage): """Talk details page""" def __init__(self, obj, **kwargs): super().__init__(**kwargs) column = Handy.Clamp( maximum_size=1024, width_request=400, vexpand=False) self.obj = obj LBL_PROPS = { 'justify': Gtk.Justification.FILL, 'halign' : Gtk.Align.START, 'wrap' : True, } box = Gtk.VBox( margin_left=8, margin_right=8) titlebox = Gtk.VBox() label = Gtk.Label(**LBL_PROPS) label.set_markup("{}".format(_clean_markup(obj.title))) titlebox.pack_start(label, False, False, 0) if obj.subtitle != "": label = Gtk.Label(**LBL_PROPS) label.set_markup("{}".format(_clean_markup(obj.subtitle))) #label.get_style_context().add_class("dim-label") titlebox.pack_start(label, False, False, 0) label = Gtk.Label(**LBL_PROPS) label.set_markup("{}".format( ", ".join([ _clean_markup(str(p)) for p in obj.persons()]))) label.get_style_context().add_class("dim-label") titlebox.pack_start(label, False, False, 0) box.pack_start(titlebox, False, False, 16) starbox = Gtk.HBox() titlebox = Gtk.VBox() label = Gtk.Label(**LBL_PROPS) label.set_markup("{}-{}".format( obj.start_in_tz().strftime("%a %H:%M"), obj.end_in_tz().strftime("%H:%M"))) titlebox.pack_start(label, False, False, 0) if obj.room: label = Gtk.Label(**LBL_PROPS) label.set_markup(_("Room: {}").format(obj.room)) titlebox.pack_start(label, False, False, 0) if obj.track: label = Gtk.Label(**LBL_PROPS) label.set_markup(_("Track: {}").format(obj.track)) titlebox.pack_start(label, False, False, 0) starbox.pack_start(titlebox, False, True, 0) icon_name = "starred-symbolic" if obj.starred else "non-starred-symbolic" self.toggle_btn = Gtk.Button.new_from_icon_name(icon_name, Gtk.IconSize.BUTTON) self.toggle_btn.connect("clicked", self.toggle_starred) starbox.pack_end(self.toggle_btn, False, False, 16) box.pack_start(starbox, False, False, 16) self.conflicts = list(obj.get_conflicts()) if len(self.conflicts): cbox = Gtk.VBox() label = Gtk.Label(**LBL_PROPS) label.set_markup(_("Conflicts with")) cbox.pack_start(label, False, False, 0) frame = Gtk.Frame() listbox = Gtk.ListBox() listbox.connect('row-activated', self.on_conflict_activated) for c in self.conflicts: row = EventActionRow(c) listbox.add(row) frame.add(listbox) cbox.pack_start(frame, False, False, 0) box.pack_start(cbox, False, False, 16) # 'None' as string value should not happend but it does # By now just filter out, but a more in-depth look should be taken if obj.abstract is not None and obj.abstract != "" and obj.abstract != "None": label = Gtk.Label(**LBL_PROPS) label.set_markup(_clean_markup(obj.abstract)) box.pack_start(label, False, False, 16) if obj.description is not None and obj.description != "" and obj.description != "None": label = Gtk.Label(**LBL_PROPS) label.set_markup(_clean_markup(obj.description)) box.pack_start(label, False, False, 16) ## links self.links = list(obj.links()) if len(self.links) > 0: linkbox = Gtk.VBox() label = Gtk.Label(**LBL_PROPS) label.set_markup(_("Links")) linkbox.pack_start(label, False, False, 0) frame = Gtk.Frame() listbox = Gtk.ListBox() listbox.connect('row-activated', weblinkactionrowactivated) for l in obj.links(): row = WebLinkActionRow(l.name, l.href) listbox.add(row) frame.add(listbox) linkbox.pack_start(frame, False, False, 0) box.pack_start(linkbox, False, False, 16) self.add(box) # progress indicator Gio.Application.get_default().connect( "tick", lambda *_: self.queue_draw() ) box.connect("draw", self._on_draw) def _on_draw(self, widget, cr): now = datetime.datetime.now(UTC).replace(tzinfo=None) obj = self.obj w = self.get_allocated_width() dur = (obj.end.timestamp() - obj.start.timestamp()) pos = (now.timestamp() - obj.start.timestamp()) if dur > 0: prc = min(max(pos/dur, 0.0), 1.0) else: # not a valid event duration # set prc to 0 if the event is in the future or 1 if in the past prc = int(pos >= 0) x = w * prc cr.set_source_rgb(0, 0, 0) cr.move_to(0, 1) cr.line_to(x, 1) cr.stroke() def toggle_starred(self, button): self.obj.set_star(not self.obj.starred) icon_name = "starred-symbolic" if self.obj.starred else "non-starred-symbolic" button.get_image().set_from_icon_name(icon_name, Gtk.IconSize.BUTTON) def on_conflict_activated(self, listbox, actionrow): idx = actionrow.get_index() obj = self.conflicts[idx] page = EventDetailPage(obj=obj) self.pageStack.pushPage(page) class StarredPage(BaseListPage): """Starred list page. This page is not in leaflet, but in mainstack""" def __init__(self, searchbar, **kwargs): self.empty_placeholder = PlaceholderWidget( _("Starred Talks"), _("You don't have any starred talk yet.") + "\n" + \ _("Click on the star button to add a talk to this list " + \ "and to be reminded when they are about to start."), "starred") self.empty_placeholder.show_all() self.nomatch_placeholder = PlaceholderWidget( text = _("No matches found"), icon_name = 'system-search' ) self.nomatch_placeholder.show_all() self.searchbar = searchbar super().__init__(**kwargs) self.get_style_context().add_class("starred-page") self.get_style_context().add_class("clean-list") self.listbox.set_placeholder(self.empty_placeholder) def get_objects(self): return models.Event.filter(starred = True) def get_objects(self): sb = self.searchbar if sb.get_search_mode() and sb.entry.get_text() != "": self.listbox.set_placeholder(self.nomatch_placeholder) search = sb.entry.get_text().lower() events = models.Event.search(search, starred = True) else: self.listbox.set_placeholder(self.empty_placeholder) events = models.Event.filter(starred = True) return events def build_row(self, obj): row = EventActionRow(obj) return row def on_activate(self, listbox, actionrow): idx = actionrow.get_index() obj = self.data[idx] page = EventDetailPage(obj=obj) self.pageStack.pushPage(page) class MainMenuPage(Gtk.ScrolledWindow): """Leaflet sidebar menu""" ITEMS = ( ["EVENT", "emblem-system-symbolic", ConferencePage, None], (_("Days"), "x-office-calendar-symbolic", DaysPage, models.Day.count), (_("Tracks"), "format-justify-fill-symbolic", TracksPage, models.Track.count), (_("Rooms"),"display-projector-symbolic", RoomsPage, models.Room.count)) def __init__(self, pageStack, conf): super().__init__( width_request=270, kinetic_scrolling=True, hscrollbar_policy=Gtk.PolicyType.NEVER ) self.pageStack = pageStack self.conf = conf self.ITEMS[0][0] = conf.title self.listbox = Gtk.ListBox() self.update() self.listbox.connect('row-activated', self.on_activate) self.add(self.listbox) def update(self): for w in self.listbox.get_children(): w.destroy() for k, item in enumerate(self.ITEMS): title, icon, cls, isvisible = item if isvisible is not None and not isvisible(): continue mn = MenuBoxRow(title, icon) mn.item_id = k self.listbox.add(mn) self.listbox.show_all() def select_conference_page(self): """select and show ConferencePAge""" row = self.listbox.get_row_at_index(0) self.listbox.select_row(row) self.on_activate(self.listbox, row) def on_activate(self, listbox, actionrow): idx = actionrow.item_id cls = self.ITEMS[idx][2] # TODO: that's ugly... if idx==0: page = cls(self.conf) else: page = cls() self.pageStack.replaceWithPage(page) class MapPage(Gtk.Overlay): def _add_image(self, fetcher, imagefile): image = SimpleScalableImage() pixbuf = GdkPixbuf.Pixbuf.new_from_file(imagefile) image.set_from_pixbuf(pixbuf) image.show() self.image = image self.scrollarea.add(image) def __init__(self, conf, **kwargs): opts = dict( hexpand=True, vexpand=True ) opts.update(kwargs) super().__init__(**opts) self.image = None self.scrollarea = Gtk.ScrolledWindow() self.add(self.scrollarea) toolbar = Gtk.VBox(halign=Gtk.Align.END, valign=Gtk.Align.END) toolbar.get_style_context().add_class("app-notification") toolbar.get_style_context().add_class("map-toolbar") self.zoomin = Gtk.ToolButton.new( Gtk.Image.new_from_icon_name("zoom-in-symbolic", Gtk.IconSize.SMALL_TOOLBAR), None) self.zoomout = Gtk.ToolButton.new( Gtk.Image.new_from_icon_name("zoom-out-symbolic", Gtk.IconSize.SMALL_TOOLBAR), None) toolbar.pack_start(self.zoomin, False, False, 8) toolbar.pack_start(self.zoomout, False, False, 8) self.add_overlay(toolbar) self.zoomin.connect("clicked", self.on_zoomin) self.zoomout.connect("clicked", self.on_zoomout) conf.get_map_files(cbk=self._add_image) def on_zoomin(self, *args): if self.image is not None: self.image.scale_by(1.1) def on_zoomout(self, *args): if self.image is not None: self.image.scale_by(0.9) confy-0.6.1/src/preferences.py000066400000000000000000000060421412535071300163010ustar00rootroot00000000000000# preferences.py # # Copyright 2020 Fabio # # 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 . from gi.repository import Gio from gi.repository import Gtk from gi.repository import Handy from .settings import Settings, CacheDuration from . import local def format_size(num): for unit in ['B','KiB','MiB','GiB','TiB','PiB','EiB','ZiB']: if abs(num) < 1024.0: return "%3.1f%s" % (num, unit) num /= 1024.0 return "%.1f%s" % (num, 'Yi') class PreferencesWindow(Handy.PreferencesWindow): def __init__(self, **kwargs): opts = dict( default_height=700, default_width=640, width_request=300 ) opts.update(kwargs) super().__init__(**opts) page = Handy.PreferencesPage() group = Handy.PreferencesGroup() listcache = Handy.ComboRow( title=_("Events list cache duration"), subtitle=_("App will auto-update cache (if possible) when it's older than this.") ) listcache.bind_name_model(CacheDuration.as_model(), Handy.ValueObject.dup_string ) Settings.instance().bind('list-cache', listcache, 'selected-index', Gio.SettingsBindFlags.DEFAULT) eventcache = Handy.ComboRow( title=_("Events info cache duration"), subtitle=_("App will auto-update cache (if possible) when it's older than this.") ) eventcache.bind_name_model(CacheDuration.as_model(), Handy.ValueObject.dup_string ) Settings.instance().bind('event-cache', eventcache, 'selected-index', Gio.SettingsBindFlags.DEFAULT) group.add(listcache) group.add(eventcache) page.add(group) group = Handy.PreferencesGroup() button = Gtk.Button(label=_("Clear"), valign=Gtk.Align.CENTER, halign=Gtk.Align.END ) button.get_style_context().add_class("list-button") row = Handy.ActionRow( title=_("Cached data")) self._update_space_label(row) row.add(button) row.set_activatable_widget(button) button.connect("clicked", self._delete_cached_files, row) group.add(row) page.add(group) self.add(page) def _delete_cached_files(self, btn, row): local.clear_cache() self._update_space_label(row) def _update_space_label(self, row): cache_size = local.get_cache_size() occupied_space = format_size(cache_size) row.set_subtitle(_("Confy has {} of cached data").format(occupied_space)) confy-0.6.1/src/remotes/000077500000000000000000000000001412535071300151025ustar00rootroot00000000000000confy-0.6.1/src/remotes/__init__.py000066400000000000000000000025541412535071300172210ustar00rootroot00000000000000# __init__.py # # Copyright 2020 Fabio # # 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 . import os from ..fetcher import Fetcher from .exceptions import InvalidFormatException from .pentabarf import import_pentabarf from .ics import import_ics def update_schedule(url:str) -> Fetcher: def _do_load(sender, local_filename:str): print("local conf file:", local_filename) with open(local_filename, "r") as f: content = f.read() if content.strip().startswith("<"): import_pentabarf(content, url) elif content.strip().startswith("BEGIN:VCALENDAR"): import_ics(content, url) else: raise InvalidFormatException(_("Unknown schedule format")) os.remove(local_filename) return Fetcher(url, cbk=_do_load) confy-0.6.1/src/remotes/exceptions.py000066400000000000000000000013301412535071300176320ustar00rootroot00000000000000# exceptions.py # # Copyright 2020 Fabio # # 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 . class InvalidFormatException(Exception): pass confy-0.6.1/src/remotes/ics.py000066400000000000000000000103141412535071300162310ustar00rootroot00000000000000# ics.py # # Copyright 2020 Fabio # # 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 . import time import html from datetime import datetime, timedelta, timezone from dateutil.tz import UTC from icalendar import Calendar, Event from .exceptions import InvalidFormatException from .. import local from ..models import Meta def import_ics(content:str, url:str): """Import data from ICS all dates will be converted to UTC and stored in db without tzinfo, because sqlite3 driver spits errors otherwise. """ cal = Calendar.from_ical(content) _db = local.getDb() meta_title = None meta_end = datetime(1970,1,1,0,0,0) meta_start = datetime(3100,12,12,23,59,59) for c in cal.walk(): if c.name == "VCALENDAR": meta_title = c.get('X-WR-CALNAME') if c.name == "VEVENT": fulltextsearch = [] eventid = c['UID'] if c.get('DTSTART'): start = c['DTSTART'].dt.astimezone(UTC).replace(tzinfo=None) else: start = c['DTSTAMP'].dt.astimezone(UTC).replace(tzinfo=None) if c.get('DURATION'): end = start + c['DURATION'].dt elif c.get('DTEND'): end = c['DTEND'].dt.astimezone(UTC).replace(tzinfo=None) else: end = start + timedelta(hours=1) evtdate = start.date() room = c.get('LOCATION') slug = None title = c.get('SUMMARY', "") subtitle = None track = None evtype = None abstract = None description = c.get('DESCRIPTION', "") if title == "" and description == "": title = "Untitled event" if title == "" and description != "": title = description[:20] if len(description) > 20: title = title + "…" if room: room = html.unescape(room) if room == "": room = None if start < meta_start: meta_start = start if end > meta_end: meta_end = end fulltextsearch += [ s for s in [title, subtitle, abstract, description, room, track] if s is not None ] links = [] _url = c.get('URL') if _url: links.append((eventid, _url, _url)) _db.execute("""INSERT OR REPLACE INTO events (id, date, start, end, room, slug, title, subtitle, track, type, abstract, description, starred) VALUES (?,?,?,?,?,?,?,?,?,?,?,?, (SELECT starred FROM events WHERE id=?))""", (eventid, evtdate, start, end, room, slug, title, subtitle, track, evtype, abstract, description, eventid)) #_db.executemany("INSERT OR REPLACE INTO persons (id, name) VALUES (?, ?)", persons) #_db.executemany("""INSERT OR REPLACE INTO event_person (event_id, person_id) # VALUES (?, ?) ON CONFLICT DO NOTHING""", # [ (eventid, p[0]) for p in persons ]) _db.executemany("""INSERT OR REPLACE INTO links (event_id, href, name) VALUES (?,?,?)""", links) fulltextsearchstr = ' '.join(fulltextsearch) _db.execute("""INSERT OR REPLACE INTO fts_event (event_id, text) VALUES (?, ?)""", (eventid, fulltextsearchstr)) _db.commit() with Meta() as m: m.url = url m.title = meta_title m.last_update = time.time() # timestamp m.start = meta_start.date() m.end = meta_end.date() confy-0.6.1/src/remotes/meson.build000066400000000000000000000002501412535071300172410ustar00rootroot00000000000000confy_remotes_sources = [ '__init__.py', 'pentabarf.py', 'ics.py', 'exceptions.py', ] install_data(confy_remotes_sources, install_dir: moduledir / 'remotes') confy-0.6.1/src/remotes/pentabarf.py000066400000000000000000000121711412535071300174200ustar00rootroot00000000000000# pentabarf.py # # Copyright 2020 Fabio # # 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 . import datetime import time import xml.etree.ElementTree as ET from dateutil.tz import UTC, tzlocal from .exceptions import InvalidFormatException from .. import local from ..models import Meta def _local_to_utc_to_unset(dt): dt = dt.replace(tzinfo=tzlocal()) dt = dt.astimezone(UTC) return dt.replace(tzinfo=None) def _get_text(root, nodename): text = "" if root is not None: node = root.find(nodename) if node is not None: text = node.text return text def import_pentabarf(xmlstr:str, url:str): """Import data from Pentabarf XML As far I can tell, Pentabarf XML doesn't declare timezone. We will import dates in local timezone, then convert to UTC, then remove timezone info to store dates in db (because sqlite3 cries otherwise) """ root = ET.fromstring(xmlstr) if root.tag != "schedule": raise InvalidFormatException(_("Invalid pentabarf format")) econference = root.find("conference") base_url = _get_text(econference, "base_url") with Meta() as m: m.url = url m.last_update = time.time() # timestamp m.title = _get_text(econference, "title") m.start = _get_text(econference, "start") m.end = _get_text(econference, "end") m.venue = _get_text(econference, "venue") m.days = _get_text(econference, "days") m.city = _get_text(econference, "city") _db = local.getDb() for eday in root.iter('day'): date = eday.attrib['date'] for eevent in eday.iter('event'): fulltextsearch = [] eventid = eevent.attrib['id'] start = _local_to_utc_to_unset( datetime.datetime.strptime(date + " " + eevent.find('start').text, "%Y-%m-%d %H:%M") ) end = eevent.find('duration').text.split(":") end = start + datetime.timedelta(hours=int(end[0]), minutes=int(end[1])) evtdate = start.date() room = _get_text(eevent, 'room') slug = _get_text(eevent, 'slug') title = _get_text(eevent, 'title') subtitle = _get_text(eevent, 'subtitle') track = _get_text(eevent, 'track') evtype = _get_text(eevent, 'type') abstract = _get_text(eevent, 'abstract') description = _get_text(eevent, 'description') persons = [ (e.attrib.get('id', e.text), e.text) for e in eevent.iter('person') if e.text is not None ] fulltextsearch += [ s for s in [title, subtitle, abstract, description, room, track] if s is not None ] fulltextsearch += [p[1] for p in persons] links = [] for e in eevent.iter('link'): name = e.text href = e.attrib.get('href', False) if not href: href = name if base_url and href.startswith("/"): href = base_url + href links.append((eventid, href, name)) for e in eevent.iter('attachment'): name = e.text if e.attrib.get('type', False): name = '{} ({})'.format(name, e.attrib['type']) href = e.attrib.get('href', False) if not href: href = name if base_url and href.startswith("/"): href = base_url + href links.append((eventid, href, name)) _db.execute("""INSERT OR REPLACE INTO events (id, date, start, end, room, slug, title, subtitle, track, type, abstract, description, starred) VALUES (?,?,?,?,?,?,?,?,?,?,?,?, (SELECT starred FROM events WHERE id=?))""", (eventid, evtdate, start, end, room, slug, title, subtitle, track, evtype, abstract, description, eventid)) _db.executemany("INSERT OR REPLACE INTO persons (id, name) VALUES (?, ?)", persons) _db.executemany("""INSERT OR REPLACE INTO event_person (event_id, person_id) VALUES (?, ?) ON CONFLICT DO NOTHING""", [ (eventid, p[0]) for p in persons ]) _db.executemany("""INSERT OR REPLACE INTO links (event_id, href, name) VALUES (?,?,?)""", links) fulltextsearchstr = ' '.join(fulltextsearch) _db.execute("""INSERT OR REPLACE INTO fts_event (event_id, text) VALUES (?, ?)""", (eventid, fulltextsearchstr)) _db.commit() confy-0.6.1/src/settings.py000066400000000000000000000043531412535071300156430ustar00rootroot00000000000000# settings.py # # Copyright 2020 Fabio # # 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 . from gi.repository import Gio from gi.repository import Handy from dateutil import tz # in secs CACHE_NOCACHE = 0 CACHE_ONE_HOUR = 60 * 60 CACHE_ONE_DAY = 24 * CACHE_ONE_HOUR CACHE_ONE_WEEK = 7 * CACHE_ONE_DAY class CacheDuration: NOCACHE = 0 ONEHOUR = 1 ONEDAY = 2 ONEWEEK = 3 @classmethod def as_model(cls): m = Gio.ListStore.new(Handy.ValueObject) m.insert(0, Handy.ValueObject.new(_("No cache"))) m.insert(1, Handy.ValueObject.new(_("One hour"))) m.insert(2, Handy.ValueObject.new(_("One day"))) m.insert(3, Handy.ValueObject.new(_("One week"))) return m @classmethod def get_duration(cls, enum_value): return [ CACHE_NOCACHE, CACHE_ONE_HOUR, CACHE_ONE_DAY, CACHE_ONE_WEEK ][enum_value] class Settings(Gio.Settings): _instance = None def __init__(self): """ Init settings """ Gio.Settings.__init__(self) @classmethod def instance(kls): return kls._instance @classmethod def init(kls, app_id): """ Initialize and return a new Settings object """ settings = Gio.Settings.new(app_id) settings.__class__ = Settings kls._instance = settings return settings def get_list_cache(self): return CacheDuration.get_duration(self.get_int('list-cache')) def get_event_cache(self): return CacheDuration.get_duration(self.get_int('event-cache')) def get_timezone(self): return tz.tzlocal() confy-0.6.1/src/shortcuts.ui000066400000000000000000000036121412535071300160230ustar00rootroot00000000000000 1 1 shortcuts 12 1 1 <Primary>F Find 1 <Primary>L Return to events list 1 <Primary>comma Preferences confy-0.6.1/src/widgets.py000066400000000000000000000464241412535071300154560ustar00rootroot00000000000000# widgets.py # # Copyright 2020 Fabio # # 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 . from os import path import datetime import html from dateutil.tz import UTC from gi.repository import GLib from gi.repository import GObject from gi.repository import Gio from gi.repository import Gtk from gi.repository import GdkPixbuf from gi.repository import Handy from .config import FMT_DAY_LIST class ListRowHeader(Gtk.VBox): def __init__(self, text): super().__init__(margin=16) label = Gtk.Label("", halign=Gtk.Align.END) label.set_markup("{}".format(text)) sep = Gtk.Separator() self.pack_start(label, True, True, 2) self.pack_start(sep, False, False, 2) self.show_all() class WebLinkActionRow(Handy.ActionRow): def __init__(self, title, url, icontype=None, **kwargs): opts = dict(activatable=True, selectable=False) opts.update(kwargs) super().__init__(**opts) self.url = url if title is None: title = path.basename(url) self.set_title(html.unescape(title)) self.set_subtitle(url) #if icontype is None: normurl = url.split("#")[0].split("?")[0] ftype, _ = Gio.content_type_guess(normurl) fmaj, fmin = ftype.split("/") icontype = "text/html" if fmaj in ('text','video', 'audio', 'image'): icontype = ftype if fmin == 'pdf' or 'document' in fmin: icontype = ftype self.content_type = icontype ficon = Gio.content_type_get_icon(icontype) # I have to manage icon by hand.. ouf image = Gtk.Image.new_from_gicon(ficon, Gtk.IconSize.DIALOG) self.add_prefix(image) def weblinkactionrowactivated(listbox, actionrow): appinfo = Gio.app_info_get_default_for_type(actionrow.content_type, True) if appinfo is not None: appinfo.launch_uris([actionrow.url], None) else: Gio.app_info_launch_default_for_uri(actionrow.url, None) class EventActionRow(Handy.ActionRow): def __init__(self, obj): super().__init__(activatable=True, selectable=False) subtitle = "{}-{}".format( obj.start_in_tz().strftime("%a %H:%M"), obj.end_in_tz().strftime("%H:%M")) if obj.room: subtitle = "{} ({})".format( subtitle, obj.room) if obj.track: subtitle = "{} '{}'".format( subtitle, obj.track) ps = list(obj.persons()) if len(ps) > 0: subtitle = "{} - {}".format( subtitle, ", ".join([str(p) for p in ps])) self.set_title(html.unescape(obj.title)) self.set_subtitle(html.unescape(subtitle)) self.obj = obj obj.connect('update', self.on_update) icon_name = "starred-symbolic" if obj.starred else "non-starred-symbolic" self.toggle_btn = Gtk.Button.new_from_icon_name(icon_name, Gtk.IconSize.BUTTON) self.toggle_btn.connect("clicked", self.toggle_starred) self.add(self.toggle_btn) Gio.Application.get_default().connect( "tick", lambda *_: self.queue_draw() ) self.connect("draw", self._on_draw) def _on_draw(self, widget, cr): now = datetime.datetime.now(UTC).replace(tzinfo=None) obj = self.obj h = self.get_allocated_height() dur = (obj.end.timestamp() - obj.start.timestamp()) pos = (now.timestamp() - obj.start.timestamp()) if dur > 0: prc = min(max(pos/dur, 0.0), 1.0) else: # not a valid event duration # set prc to 0 if the event is in the future or 1 if in the past prc = int(pos >= 0) y = h * prc cr.set_source_rgb(0, 0, 0) cr.move_to(1, 0) cr.line_to(1, y) cr.stroke() def on_update(self, *args): icon_name = "starred-symbolic" if self.obj.starred else "non-starred-symbolic" self.toggle_btn.get_image().set_from_icon_name(icon_name, Gtk.IconSize.BUTTON) def toggle_starred(self, button): self.obj.set_star(not self.obj.starred) class MenuBoxRow(Gtk.ListBoxRow): def __init__(self, title, icon): super().__init__() box = Gtk.HBox(margin=16) lbl = Gtk.Label(title) icn = Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.LARGE_TOOLBAR ) box.pack_start(icn, False, True, 0) box.pack_start(lbl, False, True, 8) self.add(box) class PlaceholderWidget(Gtk.VBox): def __init__(self, title=None, text=None, icon_name='net.kirgroup.confy'): super().__init__(valign = Gtk.Align.CENTER) img = Gtk.Image.new_from_pixbuf( Gtk.IconTheme.get_default().load_icon( icon_name, 128, 0)) self.pack_start(img, False, False, 16) LBL_PROPS = { 'justify': Gtk.Justification.CENTER, 'halign' : Gtk.Align.CENTER, 'wrap' : True, } if title is not None: label = Gtk.Label(**LBL_PROPS) label.set_markup(_("{}").format(title)) self.pack_start(label, False, False, 8) if text is not None: label = Gtk.Label(**LBL_PROPS) label.set_markup("{}".format(text)) label.get_style_context().add_class("dim-label") self.pack_start(label, False, False, 8) self.show_all() class LoadingWidget(Handy.Clamp): def __init__(self, fetcher): super().__init__(maximum_size=400) box = Gtk.VBox(valign = Gtk.Align.CENTER) img = Gtk.Image.new_from_pixbuf( Gtk.IconTheme.get_default().load_icon( 'net.kirgroup.confy', 256, 0)) self.pb = pb = Gtk.ProgressBar() label = Gtk.Label() label.set_markup(_("Loading…")) button = Gtk.Button("Cancel") fetcher.connect("notify", lambda *args: pb.set_fraction(fetcher.props.fraction)) button.connect("clicked", lambda *args: fetcher.cancel()) box.pack_start(img, False, False, 16) box.pack_start(label, False, False, 8) box.pack_start(pb, False, False, 8) box.pack_start(button, False, False, 16) self.add(box) GLib.timeout_add(200, self._do_pulse) def _do_pulse(self,*args): if self.pb.get_fraction() > 0: return False self.pb.pulse() return True class ErrorWidget(Gtk.VBox): def __init__(self, msg, error): super().__init__() self.set_valign(Gtk.Align.CENTER) img = Gtk.Image.new_from_icon_name('dialog-warning-symbolic', Gtk.IconSize.DIALOG ) lbl1 = Gtk.Label() lbl1.set_markup("{}".format(msg)) lbl2 = Gtk.Label(str(error)) lbl2.get_style_context().add_class("dim-label") self.pack_start(img, False, False, 16) self.pack_start(lbl1, False, False, 0) self.pack_start(lbl2, False, False, 0) class NotificationOverlay(Gtk.Revealer): def __init__(self): super().__init__(halign=Gtk.Align.CENTER, valign=Gtk.Align.START) box = Gtk.HBox(spacing=20) box.get_style_context().add_class("app-notification") label = Gtk.Label("") button = Gtk.Button.new_from_icon_name("window-close-symbolic", Gtk.IconSize.BUTTON) box.pack_start(label,False, True, 0) box.pack_start(button, False, False, 0) self.add(box) button.connect("clicked", self.close) self.label = label self.show_all() def show(self, text): self.label.set_markup(text) self.set_reveal_child(True) def close(self, *args): self.set_reveal_child(False) class LoadingOverlay(Gtk.Revealer): def __init__(self): super().__init__(halign=Gtk.Align.CENTER, valign=Gtk.Align.START) box = Gtk.HBox(spacing=20) box.get_style_context().add_class("app-notification") spinner = Gtk.Spinner.new() spinner.start() label = Gtk.Label(_("Loading…"), margin_right=16) button = Gtk.Button.new_from_icon_name("process-stop-symbolic", Gtk.IconSize.BUTTON) box.pack_start(spinner,False, False, 0) box.pack_start(label,False, True, 0) box.pack_start(button, False, False, 0) self.add(box) button.connect("clicked", self.cancel) self.cancellable = None self.show_all() def show(self,cancellable): self.cancellable = cancellable if cancellable is not None: self.cancellable.connect("done", self.close) self.cancellable.connect("error", self.close) self.set_reveal_child(True) def cancel(self, *args): if self.cancellable is not None: self.cancellable.cancel() self.close() def close(self, *args): self.cancellable = None self.set_reveal_child(False) class SearchBarOverlay(Handy.SearchBar): def __init__(self, **kwargs): opts = dict( halign = Gtk.Align.FILL, valign = Gtk.Align.START, show_close_button = True ) opts.update(kwargs) super().__init__(**opts) clamp = Handy.Clamp() self.entry = Gtk.SearchEntry(can_focus=True) clamp.add(self.entry) self.add(clamp) self.show_all() self.connect('notify::search-mode-enabled', self._on_search_mode_changed) def _on_search_mode_changed(self, *args): if self.get_search_mode(): self.entry.set_text("") self.entry.grab_focus() class OkCancelDialog(Gtk.Dialog): CANCEL = 0 OK = 1 title = "Dialog" def __init__(self, parent, **kwargs): opts = dict( transient_for=parent, can_focus=False, modal=True, use_header_bar=True, default_height=20, destroy_with_parent=True ) opts.update(kwargs) super().__init__(**opts) self._btn_cancel = cancel = Gtk.Button(name="cancel_button", label=_("Cancel"), receives_default=True) self._btn_ok = ok = Gtk.Button(name="done_button", label=_("Ok"), receives_default=True) ok.get_style_context().add_class("suggested-action") cancel.connect("clicked", self._do_cancel) ok.connect("clicked", self._do_ok) hb = self.get_header_bar() hb.pack_start(cancel) hb.pack_end(ok) hb.set_show_close_button(False) hb.set_title(self.title) self.setup_ui() self.show_all() def _do_cancel(self, *args): self.response(self.CANCEL) def _do_ok(self, *args): self.response(self.OK) def setup_ui(self): ... class InputDialog(OkCancelDialog): title = _("Schedule URL") def setup_ui(self): self._input = Gtk.Entry() self.get_content_area().add(self._input) def get_text(self): return self._input.get_text() ACTION_ROW_PROPS = dict( selectable=False, activatable=True, ) ACTION_ROW_ENTRY_PROPS = dict( valign=Gtk.Align.CENTER, halign=Gtk.Align.FILL, vexpand=False, hexpand=True, ) class ConferenceEditDialog(OkCancelDialog): DELETE=3 title = _("Edit Conference") def __init__(self, parent, conf, can_cancel=False, can_delete=False): self._err = set() self.conf = conf self._can_delete = can_delete super().__init__(parent, default_height=355) if not can_cancel: self._btn_cancel.destroy() def get_conf(self): return self.conf def _do_delete(self, *args): self.response(self.DELETE) def _do_ok(self, *args): self.conf.url = self._entry_url.get_text() self.conf.title = self._entry_title.get_text() self.conf.start = self._entry_start.get_date() self.conf.end = self._entry_end.get_date() if self._entry_icn: if self._entry_icn.get_text() != "": self.conf.metadata['icon'] = self._entry_icn.get_text() elif 'icon' in self.conf.metadata: del self.conf.metadata['icon'] self.response(self.OK) def _validate_entry_required(self, entry): if len(entry.get_text()) > 0: entry.get_style_context().remove_class("error") if entry in self._err: self._err.remove(entry) else: entry.get_style_context().add_class("error") self._err.add(entry) self._update_ok() def _validate_date_order(self, entry): if self._entry_start.get_date() > self._entry_end.get_date(): entry.get_style_context().add_class("error") self._err.add(entry) else: for e in (self._entry_start, self._entry_end): e.get_style_context().remove_class("error") if e in self._err: self._err.remove(e) self._update_ok() def _update_ok(self): self._btn_ok.set_sensitive(len(self._err) == 0) def setup_ui(self): scroll = Gtk.ScrolledWindow( hexpand=True, vexpand=True, kinetic_scrolling=True, hscrollbar_policy=Gtk.PolicyType.NEVER) column = Handy.Clamp( margin=16, maximum_size=600, tightening_threshold=400) box = Gtk.VBox(valign=Gtk.Align.START, spacing=8) listbox = Gtk.ListBox() listbox.get_style_context().add_class("content") self._entry_url = entry = Gtk.Entry(text=self.conf.url, editable=False, **ACTION_ROW_ENTRY_PROPS) entry.connect("changed", self._validate_entry_required) self._validate_entry_required(entry) row = Handy.ActionRow(title=_("URL"), **ACTION_ROW_PROPS) row.add(entry) row.set_activatable_widget(entry) listbox.add(row) self._entry_title = entry = Gtk.Entry(text=self.conf.title, **ACTION_ROW_ENTRY_PROPS) entry.connect("changed", self._validate_entry_required) self._validate_entry_required(entry) row = Handy.ActionRow(title=_("Title"), **ACTION_ROW_PROPS) row.add(entry) row.set_activatable_widget(entry) listbox.add(row) self._entry_start = entry = DatePickerButton(date=self.conf.start, **ACTION_ROW_ENTRY_PROPS) entry.get_style_context().add_class("list-button") entry.connect("changed", self._validate_date_order) row = Handy.ActionRow(title=_("Start"), **ACTION_ROW_PROPS) row.add(entry) row.set_activatable_widget(entry) listbox.add(row) self._entry_end = entry = DatePickerButton(date=self.conf.end, **ACTION_ROW_ENTRY_PROPS) entry.get_style_context().add_class("list-button") entry.connect("changed", self._validate_date_order) self._validate_date_order(entry) row = Handy.ActionRow(title=_("End"), **ACTION_ROW_PROPS) row.add(entry) row.set_activatable_widget(entry) listbox.add(row) if self.conf.metadata is not None: self._entry_icn = entry = Gtk.Entry(text=self.conf.metadata.get('icon',''), **ACTION_ROW_ENTRY_PROPS) row = Handy.ActionRow(title=_("Icon URL"), **ACTION_ROW_PROPS) row.add(entry) row.set_activatable_widget(entry) listbox.add(row) else: self._entry_icn = None box.add(listbox) if self._can_delete: btn_delete = Gtk.Button( name="delete_button", label=_("Delete"), valign=Gtk.Align.START, halign=Gtk.Align.END) btn_delete.get_style_context().add_class("destructive-action") btn_delete.connect("clicked", self._do_delete) box.add(btn_delete) column.add(box) scroll.add(column) self.get_content_area().add(scroll) class DatePickerButton(Gtk.Button): @GObject.Signal def changed(self): ... def __init__(self, date, **kwargs): super().__init__(**kwargs) self._is_popup = False self.pop = Gtk.Popover.new(self) self.cal = Gtk.Calendar() self.cal.show_all() self.pop.add(self.cal) self.pop.connect("closed", self._cal_closed) self.connect("clicked", self._toggle_cal) self.set_date(date) def get_date(self): return self.date def get_datetime(self): return datetime.datetime.combine(self.date, datetime.time.min) def set_date(self, date): self.date = date if date is None: lbl = "" date = datetime.date.today() else: lbl = str(date) self.cal.select_month(date.month-1, date.year) self.cal.select_day(date.day) self.set_label(lbl) self.emit("changed") def _cal_closed(self, *args): date = self.cal.get_date() date = datetime.date(year=date.year, month=date.month+1, day=date.day) self.set_date(date) def _toggle_cal(self, *args): if self._is_popup: self.pop.popdown() else: self.pop.popup() self._is_popup = not self._is_popup class SimpleScalableImage(Gtk.Image): @GObject.property(type=float) def scale(self): return self._scale @scale.setter def scale(self, value): self._scale = value pixbuf = self._originalpb.scale_simple( self._w * value, self._h * value, GdkPixbuf.InterpType.BILINEAR) super().set_from_pixbuf(pixbuf) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.gesture = Gtk.GestureZoom.new(self) self.gesture.set_propagation_phase(Gtk.PropagationPhase.BUBBLE) self.gesture.connect("scale-changed", self.on_scale_changed) def on_scale_changed(self, gesture, scale): self.scale_by(scale) def scale_by(self, scale): self.scale = self.scale * scale def set_from_pixbuf(self, pixbuf): self._scale = 1 self._w = pixbuf.get_width() self._h = pixbuf.get_height() self._originalpb = pixbuf super().set_from_pixbuf(pixbuf) class MaxSizedImage(Gtk.Image): def __init__(self, max_width, max_height, **kwargs): super().__init__(**kwargs) self.max_width = max_width self.max_height = max_height def set_from_pixbuf(self, pixbuf): w = pixbuf.get_width() h = pixbuf.get_height() r = w/h if r>=1 and w > self.max_width: w = self.max_width h = w / r pixbuf = pixbuf.scale_simple( w, h, GdkPixbuf.InterpType.BILINEAR) if r<1 and h > self.max_height: h = self.max_height w = h * r pixbuf = pixbuf.scale_simple( w, h, GdkPixbuf.InterpType.BILINEAR) super().set_from_pixbuf(pixbuf) confy-0.6.1/src/window.py000066400000000000000000000734021412535071300153130ustar00rootroot00000000000000# self.py # # Copyright 2020 Fabio # # 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 . import datetime import re from gi.repository import GLib from gi.repository import Gtk from gi.repository import GObject from gi.repository import GdkPixbuf from gi.repository import Gio from gi.repository import Handy from gi.repository import Notify from .config import APP_NAME, APP_ID, APP_VERSION from . import pages from . import local from . import models from .preferences import PreferencesWindow from .widgets import LoadingWidget, ErrorWidget, PlaceholderWidget from .widgets import NotificationOverlay, LoadingOverlay, SearchBarOverlay from .widgets import InputDialog, ConferenceEditDialog class NetworkConnectionMonitor(GObject.Object): def __init__(self): super().__init__() self._isconnected = False self.nm = Gio.NetworkMonitor.get_default() self.nm.connect("network-changed", self.on_network_changed) self.on_network_changed() def on_network_changed(self, *args): _ic = self._isconnected self._isconnected = self.nm.get_connectivity() == Gio.NetworkConnectivity.FULL if (self._isconnected != _ic): #print("NetworkConnectionMonitor.isconnected", self._isconnected) self.notify("isconnected") @GObject.Property def isconnected(self): """The system can reach the global netowrk. Bool, read-only""" #print("NetworkConnectionMonitor.isconnected getter:", self._isconnected) return self._isconnected class StartView(pages.BaseListPage): """ window overlay notification loading title_bar open_button search_button update_button box search column box titlebox (if title or subtitle is set) title