├── .editorconfig ├── .gitignore ├── .vscode └── launch.json ├── COPYING ├── LICENSE ├── README.md ├── build ├── meson-logs │ └── meson-log.txt └── meson-private │ └── meson.lock ├── data ├── application.css ├── io.github.xchan14.readdit.appdata.xml.in ├── io.github.xchan14.readdit.desktop.in ├── io.github.xchan14.readdit.gresource.xml └── io.github.xchan14.readdit.metinfo.xml ├── debian ├── changelog ├── compat ├── control ├── copyright ├── rules └── source │ └── format ├── docs └── readme-image.png ├── meson.build ├── po ├── LINGUAS ├── POTFILES ├── com.github.xchan14.readdit.pot ├── de.po ├── es.po └── meson.build └── src ├── Action.vala ├── AppHeaderBar.vala ├── Application.vala ├── Contants.vala ├── DataStores ├── Parsers │ ├── CommentParser.vala │ └── PostParser.vala ├── PostStore.vala ├── UiStore.vala └── UserStore.vala ├── Dispatcher.vala ├── Models ├── Comments │ ├── Comment.vala │ ├── CommentCollection.vala │ ├── LoadMoreCommentsAction.vala │ └── LoadPostCommentsAction.vala ├── Posts │ ├── LoadMorePostsAction.vala │ ├── LoadPostDetailsImageAction.vala │ ├── LoadPostPreviewAction.vala │ ├── Post.vala │ └── ViewPostAction.vala └── Users │ └── User.vala ├── Screens └── PostScreen.vala ├── Utils ├── DateUtils.vala ├── FileUtils.vala ├── FormatUtils.vala ├── HttpUtils.vala └── ImageUtils.vala └── Views ├── Comments ├── CommentCollectionView.vala └── CommentItemView.vala ├── Layout ├── MainContent.vala └── Sidebar.vala ├── MainWindow.vala ├── PostDetails ├── EmptyPostDetailsView.vala ├── PostDetailsContentView.vala └── PostDetailsView.vala ├── PostList ├── PostListItemView.vala └── PostListView.vala └── Widgets └── VideoPlayer.vala /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig 2 | root = true 3 | 4 | # elementary defaults 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | indent_size = tab 9 | indent_style = space 10 | insert_final_newline = true 11 | max_line_length = 80 12 | tab_width = 4 13 | 14 | # Markup files 15 | [{*.html,*.xml,*.xml.in,*.yml}] 16 | tab_width = 2 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/* 2 | build/* 3 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "lldb", 9 | "request": "launch", 10 | "name": "Debug", 11 | "program": "${workspaceFolder}/build/com.github.xchan14.readdit", 12 | "args": [], 13 | "cwd": "${workspaceFolder}/build" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Readdit for Reddit 2 | A Reddit client for Elementary OS. (Still a work in progress) 3 | 4 | ![sample](https://github.com/xchan14/readdit/blob/master/docs/readme-image.png?raw=true) 5 | 6 | Dependencies: 7 | - gtk+-3.0 8 | - granite 9 | - gee-0.8' 10 | - libsoup-2.4 11 | - json-glib-1.0 12 | - gio-2.0 13 | - clutter-1.0 14 | - clutter-gst-3.0 15 | - clutter-gtk-1.0 16 | - webkit2gtk-4.0 17 | 18 | To build and run: 19 | 20 | `cd build` 21 | 22 | `sudo ninja install` 23 | 24 | `com.github.xchan14.readdit` 25 | 26 | To uninstall: 27 | 28 | `cd build` 29 | 30 | `sudo ninja uninstall` 31 | -------------------------------------------------------------------------------- /build/meson-logs/meson-log.txt: -------------------------------------------------------------------------------- 1 | Build started at 2023-04-30T01:23:44.093290 2 | Main binary: /usr/bin/python3 3 | Build Options: -Dprefix=/usr -Dbackend=ninja 4 | Python system: Linux 5 | The Meson build system 6 | Version: 0.61.2 7 | Source dir: /home/xchan/Documents/source codes/readdit 8 | Build dir: /home/xchan/Documents/source codes/readdit/build 9 | Build type: native build 10 | Project name: io.github.xchan14.readdit 11 | Project version: undefined 12 | C compiler for the host machine: cc (gcc 11.3.0 "cc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0") 13 | C linker for the host machine: cc ld.bfd 2.38 14 | Vala compiler for the host machine: valac (valac 0.56.7) 15 | C compiler for the build machine: cc (gcc 11.3.0 "cc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0") 16 | C linker for the build machine: cc ld.bfd 2.38 17 | Vala compiler for the build machine: valac (valac 0.56.7) 18 | Build machine cpu family: x86_64 19 | Build machine cpu: x86_64 20 | Host machine cpu family: x86_64 21 | Host machine cpu: x86_64 22 | Target machine cpu family: x86_64 23 | Target machine cpu: x86_64 24 | Pkg-config binary for 0 is not cached. 25 | Pkg-config binary missing from cross or native file, or env var undefined. 26 | Trying a default Pkg-config fallback at pkg-config 27 | Found pkg-config: /usr/bin/pkg-config (0.29.2) 28 | Determining dependency 'glib-2.0' with pkg-config executable '/usr/bin/pkg-config' 29 | env[PKG_CONFIG_PATH]: 30 | Called `/usr/bin/pkg-config --modversion glib-2.0` -> 0 31 | 2.72.4 32 | env[PKG_CONFIG_PATH]: 33 | Called `/usr/bin/pkg-config --cflags glib-2.0` -> 0 34 | -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include 35 | env[PKG_CONFIG_ALLOW_SYSTEM_LIBS]: 1 36 | env[PKG_CONFIG_PATH]: 37 | Called `/usr/bin/pkg-config --libs glib-2.0` -> 0 38 | -L/usr/lib/x86_64-linux-gnu -lglib-2.0 39 | env[PKG_CONFIG_PATH]: 40 | Called `/usr/bin/pkg-config --libs glib-2.0` -> 0 41 | -lglib-2.0 42 | Running compile: 43 | Working directory: /home/xchan/Documents/source codes/readdit/build/meson-private/tmp3utnmx7r 44 | Command line: cc /home/xchan/Documents/source codes/readdit/build/meson-private/tmp3utnmx7r/testfile.c -o /home/xchan/Documents/source codes/readdit/build/meson-private/tmp3utnmx7r/output.exe -D_FILE_OFFSET_BITS=64 -O0 45 | 46 | Code: 47 | #include 48 | 49 | int main(void) { 50 | printf("%ld\n", (long)(sizeof(void *))); 51 | return 0; 52 | } 53 | Compiler stdout: 54 | 55 | Compiler stderr: 56 | 57 | Program stdout: 58 | 59 | 8 60 | 61 | Program stderr: 62 | 63 | 64 | Running compile: 65 | Working directory: /home/xchan/Documents/source codes/readdit/build/meson-private/tmpq8f6t909 66 | Command line: cc /home/xchan/Documents/source codes/readdit/build/meson-private/tmpq8f6t909/testfile.c -o /home/xchan/Documents/source codes/readdit/build/meson-private/tmpq8f6t909/output.obj -c -D_FILE_OFFSET_BITS=64 -O0 --print-search-dirs 67 | 68 | Code: 69 | 70 | Compiler stdout: 71 | install: /usr/lib/gcc/x86_64-linux-gnu/11/ 72 | programs: =/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/bin/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/bin/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/bin/ 73 | libraries: =/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/lib/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/lib/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib/:/lib/x86_64-linux-gnu/11/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/11/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/lib/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../:/lib/:/usr/lib/ 74 | 75 | Compiler stderr: 76 | 77 | Program glib-compile-resources found: YES (/usr/bin/glib-compile-resources) 78 | Dependency gtk+-3.0 found: YES 3.24.33 (cached) 79 | Dependency gdk-pixbuf-2.0 found: YES 2.42.8 (cached) 80 | Dependency glib-2.0 found: YES 2.72.4 (cached) 81 | Dependency granite found: YES 6.2.0 (cached) 82 | Dependency gee-0.8 found: YES 0.20.5 (cached) 83 | Dependency libsoup-2.4 found: YES 2.74.2 (cached) 84 | Dependency json-glib-1.0 found: YES 1.6.6 (cached) 85 | Dependency gio-2.0 found: YES 2.72.4 (cached) 86 | Dependency clutter-1.0 found: YES 1.26.4 (cached) 87 | Dependency clutter-gst-3.0 found: YES 3.0.27 (cached) 88 | Dependency clutter-gtk-1.0 found: YES 1.8.4 (cached) 89 | Dependency webkit2gtk-4.0 found: YES 2.38.5 (cached) 90 | Dependency libhandy-1 found: YES 1.6.1 (cached) 91 | Build targets in project: 10 92 | 93 | io.github.xchan14.readdit undefined 94 | 95 | User defined options 96 | backend: ninja 97 | prefix : /usr 98 | 99 | Found ninja-1.10.1 at /usr/bin/ninja 100 | Running compile: 101 | Working directory: /home/xchan/Documents/source codes/readdit/build/meson-private/tmpyyvechct 102 | Command line: cc /home/xchan/Documents/source codes/readdit/build/meson-private/tmpyyvechct/testfile.c -o /home/xchan/Documents/source codes/readdit/build/meson-private/tmpyyvechct/output.obj -c -D_FILE_OFFSET_BITS=64 -O0 --print-search-dirs 103 | 104 | Code: 105 | 106 | Compiler stdout: 107 | install: /usr/lib/gcc/x86_64-linux-gnu/11/ 108 | programs: =/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/bin/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/bin/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/bin/ 109 | libraries: =/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/lib/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/lib/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib/:/lib/x86_64-linux-gnu/11/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/11/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/lib/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../:/lib/:/usr/lib/ 110 | 111 | Compiler stderr: 112 | 113 | -------------------------------------------------------------------------------- /build/meson-private/meson.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xchan14/readdit/a183db06ffe654d51ded9dc22d358e2b0886c85f/build/meson-private/meson.lock -------------------------------------------------------------------------------- /data/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | .app-header-bar .custom-header { 23 | background-color:transparent; 24 | padding-top: 6px; 25 | padding-bottom: 3px; 26 | } 27 | 28 | .app-header-bar .custom-header .search-text { 29 | font-size: 20px; 30 | padding: 3px 6px 3px 6px; 31 | border-radius: 18px; 32 | border-color: transparent; 33 | background-color: transparent; 34 | } 35 | 36 | .content-container { 37 | padding: 12px 24px 12px 24px; 38 | } 39 | 40 | .post-view { 41 | min-height: 600px; 42 | } 43 | 44 | .post-list { 45 | background-color: transparent; 46 | } 47 | 48 | .post-list-listbox { 49 | background-color: transparent; 50 | } 51 | .post-list-listbox row { 52 | /* border-bottom: #7c7c7c solid 1px; */ 53 | padding-bottom: 12px; 54 | } 55 | 56 | .post-list-item { 57 | padding: 0; 58 | } 59 | 60 | .post-list-item .subreddit { 61 | color: @BANANA_700; 62 | font-weight: bold; 63 | } 64 | 65 | .post-list-item .posted-by { 66 | color: @BANANA_700; 67 | /* font-weight: bold; */ 68 | } 69 | 70 | .post-list-item .post-title, 71 | .post-list-item .post-title text 72 | { 73 | /* font-weight: bold; */ 74 | background-color: transparent; 75 | padding-top: 0; 76 | } 77 | 78 | .post-list-item image.thumbnail { 79 | box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.5); 80 | } 81 | 82 | .post-list-item .score { 83 | font-size: 20px; 84 | /* font-weight: bold; */ 85 | color: @MINT_700; 86 | /* font-weight: bold; */ 87 | } 88 | 89 | .post-list-item .date-posted { 90 | color: #7e8087; 91 | /* font-weight: bold; */ 92 | } 93 | 94 | .post-list-item-footer { 95 | padding-top: 8px; 96 | } 97 | 98 | /* 99 | * POST DETAILS SECTIOM 100 | */ 101 | 102 | .post-details-wrapper { 103 | padding: 12px 24px 12px 24px; 104 | } 105 | 106 | .post-details { 107 | padding: 12px 24px 12px 24px; 108 | } 109 | 110 | .post-details-content-header { 111 | padding: 12px 0px 12px 0px; 112 | } 113 | combobox.post_sort_by, 114 | combobox.post_Sort_by window.popup { 115 | font-weight: bold; 116 | } 117 | 118 | .post-details-subreddit { 119 | padding-bottom: 24px; 120 | } 121 | 122 | .post-details-title { 123 | text-shadow: 1px 1px 2px #7b7b7b; 124 | font-weight: bold; 125 | } 126 | 127 | .post-details-media { 128 | box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.5); 129 | margin: 24px 0 24px 0; 130 | } 131 | 132 | .post-details-content-body-text { 133 | /* padding: 12px 24px 12px 24px; */ 134 | } 135 | 136 | 137 | /* 138 | * COMMENT SECTION 139 | */ 140 | .comment-wrapper, 141 | .comment-wrapper::selection { 142 | /* padding: 12px 0px 12px 0px; */ 143 | background-color: transparent; 144 | margin-bottom: 36px; 145 | padding-bottom: 36px; 146 | /* border-left: yellow solid 1px; */ 147 | } 148 | .comment-list-box, 149 | .comment-list-box::selection { 150 | background-color: transparent; 151 | } 152 | 153 | .comment-list-box-indent { 154 | background-color: transparent; 155 | margin-left: 24px; 156 | } 157 | 158 | .comment-by { 159 | font-weight: bold; 160 | color: #8cd5ff; 161 | margin-bottom: 5px; 162 | } 163 | 164 | .comment-text { 165 | margin-bottom: 16px; 166 | } 167 | 168 | .comment-score-buttons { 169 | font-size: .75em; 170 | } 171 | 172 | .comment-children { 173 | margin-top: 6px; 174 | /* padding-left: 12px; */ 175 | background-color: transparent; 176 | } 177 | 178 | .comment-more { 179 | padding-top: 6px; 180 | padding-bottom: 6px; 181 | } 182 | 183 | 184 | .video-player { 185 | box-shadow: 0px 2px 5px 0px #000000; 186 | } 187 | -------------------------------------------------------------------------------- /data/io.github.xchan14.readdit.appdata.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | io.github.xchan14.readdit 5 | CC0 6 | ReadIt 7 | Reddit client 8 | 9 |

Browse reddit with Readit.

10 |
11 |
12 | -------------------------------------------------------------------------------- /data/io.github.xchan14.readdit.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Readdit 3 | GenericName=Reddit Client 4 | Comment=Browse reddit with Readdit. 5 | Categories=Internet; 6 | Exec=io.github.xchan14.readdit 7 | Icon=application-default-icon 8 | Terminal=false 9 | Type=Application 10 | Keywords=Reddit;Readit; 11 | X-GNOME-UsesNotifications=true -------------------------------------------------------------------------------- /data/io.github.xchan14.readdit.gresource.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | application.css 6 | 7 | -------------------------------------------------------------------------------- /data/io.github.xchan14.readdit.metinfo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | io.github.xchan14.readdit 5 | 6 | Readdit 7 | Reddit client for Elementray OS 8 | 9 | MIT 10 | AGPL-3.0-or-later 11 | 12 | 13 |

14 | Browse Reddit in Elementary OS using this native app. 15 |

16 |
17 | 18 | io.github.xchan14.readit.desktop 19 |
-------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | com.github.xchan14.readdit (0.1) bionic; urgency=low 2 | 3 | * Initial Release. 4 | 5 | -- Christian Sat, 07 Dec 2019 02:08:10 +0800 6 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: com.github.xchan14.readdit 2 | Section: x11 3 | Priority: optional 4 | Maintainer: Cody Garver 5 | Build-Depends: cmake (>= 2.8), 6 | debhelper (>= 9), 7 | libgtk-3-dev, 8 | valac (>= 0.40.0) 9 | Standards-Version: 3.9.3 10 | 11 | Package: com.github.xchan14.readdit 12 | Architecture: any 13 | Depends: ${misc:Depends}, ${shlibs:Depends} 14 | Description: Reddit client 15 | Browse reddit with this client. 16 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: https://dep.debian.net/deps/dep5 2 | Upstream-Name: master 3 | Source: https://github.com/xchan14/readdit 4 | 5 | Files: src/* data/* debian/* 6 | Copyright: 2020 Christian Camilon . 7 | License: GPL-3.0+ 8 | 9 | License: GPL-3.0+ 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | . 15 | This package is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | . 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | . 23 | On Debian systems, the complete text of the GNU General 24 | Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". 25 | 26 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | # Sample debian/rules that uses debhelper. 4 | # This file was originally written by Joey Hess and Craig Small. 5 | # As a special exception, when this file is copied by dh-make into a 6 | # dh-make output file, you may use that output file without restriction. 7 | # This special exception was added by Craig Small in version 0.37 of dh-make. 8 | 9 | # Uncomment this to turn on verbose mode. 10 | #export DH_VERBOSE=1 11 | 12 | %: 13 | dh $@ 14 | 15 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /docs/readme-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xchan14/readdit/a183db06ffe654d51ded9dc22d358e2b0886c85f/docs/readme-image.png -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project('io.github.xchan14.readdit', 'vala', 'c') 2 | 3 | i18n = import('i18n') 4 | gnome = import('gnome') 5 | 6 | # Set our translation domain 7 | add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name()), language:'c') 8 | 9 | asresources = gnome.compile_resources( 10 | 'as-resources', 'data/' + meson.project_name() + '.gresource.xml', 11 | source_dir: 'data', 12 | c_name: 'as' 13 | ) 14 | 15 | # Create excecutable. 16 | executable( 17 | meson.project_name(), 18 | asresources, 19 | 20 | 'src/Action.vala', 21 | 'src/Application.vala', 22 | 'src/AppHeaderBar.vala', 23 | 'src/Dispatcher.vala', 24 | 'src/Contants.vala', 25 | 'src/Views/MainWindow.vala', 26 | 27 | 'src/Views/Layout/Sidebar.vala', 28 | 'src/Views/Layout/MainContent.vala', 29 | 30 | 'src/DataStores/Parsers/CommentParser.vala', 31 | 'src/DataStores/Parsers/PostParser.vala', 32 | 'src/DataStores/PostStore.vala', 33 | 'src/DataStores/UserStore.vala', 34 | 35 | 'src/Models/Comments/Comment.vala', 36 | 'src/Models/Comments/CommentCollection.vala', 37 | 'src/Models/Comments/LoadMoreCommentsAction.vala', 38 | 'src/Models/Comments/LoadPostCommentsAction.vala', 39 | 40 | 'src/Views/Comments/CommentItemView.vala', 41 | 'src/Views/Comments/CommentCollectionView.vala', 42 | 43 | 'src/Models/Posts/Post.vala', 44 | 'src/Models/Posts/LoadPostDetailsImageAction.vala', 45 | 'src/Models/Posts/LoadMorePostsAction.vala', 46 | 'src/Models/Posts/LoadPostPreviewAction.vala', 47 | 'src/Models/Posts/ViewPostAction.vala', 48 | 49 | 'src/Views/PostList/PostListView.vala', 50 | 'src/Views/PostList/PostListItemView.vala', 51 | 52 | 'src/Views/PostDetails/PostDetailsContentView.vala', 53 | 'src/Views/PostDetails/PostDetailsView.vala', 54 | 'src/Views/PostDetails/EmptyPostDetailsView.vala', 55 | 56 | 'src/Screens/PostScreen.vala', 57 | 58 | 'src/Models/Users/User.vala', 59 | 'src/Views/Widgets/VideoPlayer.vala', 60 | 61 | 'src/Utils/DateUtils.vala', 62 | 'src/Utils/FormatUtils.vala', 63 | 'src/Utils/ImageUtils.vala', 64 | 65 | dependencies: [ 66 | dependency('gtk+-3.0'), 67 | dependency('gdk-pixbuf-2.0', version: '>= 2.42'), 68 | dependency('glib-2.0'), 69 | dependency('granite'), 70 | dependency('gee-0.8'), 71 | dependency('libsoup-2.4'), 72 | dependency('json-glib-1.0'), 73 | dependency('gio-2.0'), 74 | dependency('clutter-1.0'), 75 | dependency('clutter-gst-3.0'), 76 | dependency('clutter-gtk-1.0'), 77 | dependency('webkit2gtk-4.0'), 78 | dependency('libhandy-1', version: '>=0.90.0') 79 | ], 80 | install: true 81 | ) 82 | 83 | #Translate and install our .desktop file 84 | i18n.merge_file( 85 | input: join_paths('data', meson.project_name() + '.desktop.in'), 86 | output: meson.project_name() + '.desktop', 87 | po_dir: join_paths(meson.source_root(), 'po'), 88 | type: 'desktop', 89 | install: true, 90 | install_dir: join_paths(get_option('datadir'), 'applications') 91 | ) 92 | 93 | #Translate and install our .appdata file 94 | i18n.merge_file( 95 | input: join_paths('data', meson.project_name() + '.appdata.xml.in'), 96 | output: meson.project_name() + '.appdata.xml', 97 | po_dir: join_paths(meson.source_root(), 'po'), 98 | install: true, 99 | install_dir: join_paths(get_option('datadir'), 'metainfo') 100 | ) 101 | 102 | 103 | 104 | subdir('po') 105 | -------------------------------------------------------------------------------- /po/LINGUAS: -------------------------------------------------------------------------------- 1 | de 2 | es -------------------------------------------------------------------------------- /po/POTFILES: -------------------------------------------------------------------------------- 1 | src/Application.vala 2 | data/com.github.xchan14.readdit.desktop.in 3 | data/com.github.xchan14.readdit.appdata.xml.in -------------------------------------------------------------------------------- /po/com.github.xchan14.readdit.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the com.github.xchan14.readdit package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: com.github.xchan14.readdit\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2020-04-19 10:31+0800\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=CHARSET\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | 20 | #: data/com.github.xchan14.readdit.desktop.in:3 21 | msgid "Readit" 22 | msgstr "" 23 | 24 | #: data/com.github.xchan14.readdit.desktop.in:4 25 | msgid "Reddit Client" 26 | msgstr "" 27 | 28 | #: data/com.github.xchan14.readdit.desktop.in:5 29 | #: data/com.github.xchan14.readdit.appdata.xml.in:9 30 | msgid "Browse reddit with Readit." 31 | msgstr "" 32 | 33 | #: data/com.github.xchan14.readdit.desktop.in:8 34 | msgid "application-default-icon" 35 | msgstr "" 36 | 37 | #: data/com.github.xchan14.readdit.desktop.in:11 38 | msgid "Reddit;Readit;" 39 | msgstr "" 40 | 41 | #: data/com.github.xchan14.readdit.appdata.xml.in:6 42 | msgid "ReadIt" 43 | msgstr "" 44 | 45 | #: data/com.github.xchan14.readdit.appdata.xml.in:7 46 | msgid "Reddit client" 47 | msgstr "" 48 | -------------------------------------------------------------------------------- /po/de.po: -------------------------------------------------------------------------------- 1 | # German translations for com.github.xchan14.readdit package. 2 | # Copyright (C) 2020 THE com.github.xchan14.readdit'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the com.github.xchan14.readdit package. 4 | # Automatically generated, 2020. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: com.github.xchan14.readdit\n" 9 | "Report-Msgid-Bugs-To: \n" 10 | "POT-Creation-Date: 2020-04-19 10:31+0800\n" 11 | "PO-Revision-Date: 2020-04-19 10:31+0800\n" 12 | "Last-Translator: Automatically generated\n" 13 | "Language-Team: none\n" 14 | "Language: de\n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=ASCII\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 19 | 20 | #: data/com.github.xchan14.readdit.desktop.in:3 21 | msgid "Readit" 22 | msgstr "" 23 | 24 | #: data/com.github.xchan14.readdit.desktop.in:4 25 | msgid "Reddit Client" 26 | msgstr "" 27 | 28 | #: data/com.github.xchan14.readdit.desktop.in:5 29 | #: data/com.github.xchan14.readdit.appdata.xml.in:9 30 | msgid "Browse reddit with Readit." 31 | msgstr "" 32 | 33 | #: data/com.github.xchan14.readdit.desktop.in:8 34 | msgid "application-default-icon" 35 | msgstr "" 36 | 37 | #: data/com.github.xchan14.readdit.desktop.in:11 38 | msgid "Reddit;Readit;" 39 | msgstr "" 40 | 41 | #: data/com.github.xchan14.readdit.appdata.xml.in:6 42 | msgid "ReadIt" 43 | msgstr "" 44 | 45 | #: data/com.github.xchan14.readdit.appdata.xml.in:7 46 | msgid "Reddit client" 47 | msgstr "" 48 | -------------------------------------------------------------------------------- /po/es.po: -------------------------------------------------------------------------------- 1 | # Spanish translations for com.github.xchan14.readdit package. 2 | # Copyright (C) 2020 THE com.github.xchan14.readdit'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the com.github.xchan14.readdit package. 4 | # Automatically generated, 2020. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: com.github.xchan14.readdit\n" 9 | "Report-Msgid-Bugs-To: \n" 10 | "POT-Creation-Date: 2020-04-19 10:31+0800\n" 11 | "PO-Revision-Date: 2020-04-19 10:31+0800\n" 12 | "Last-Translator: Automatically generated\n" 13 | "Language-Team: none\n" 14 | "Language: es\n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=ASCII\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 19 | 20 | #: data/com.github.xchan14.readdit.desktop.in:3 21 | msgid "Readit" 22 | msgstr "" 23 | 24 | #: data/com.github.xchan14.readdit.desktop.in:4 25 | msgid "Reddit Client" 26 | msgstr "" 27 | 28 | #: data/com.github.xchan14.readdit.desktop.in:5 29 | #: data/com.github.xchan14.readdit.appdata.xml.in:9 30 | msgid "Browse reddit with Readit." 31 | msgstr "" 32 | 33 | #: data/com.github.xchan14.readdit.desktop.in:8 34 | msgid "application-default-icon" 35 | msgstr "" 36 | 37 | #: data/com.github.xchan14.readdit.desktop.in:11 38 | msgid "Reddit;Readit;" 39 | msgstr "" 40 | 41 | #: data/com.github.xchan14.readdit.appdata.xml.in:6 42 | msgid "ReadIt" 43 | msgstr "" 44 | 45 | #: data/com.github.xchan14.readdit.appdata.xml.in:7 46 | msgid "Reddit client" 47 | msgstr "" 48 | -------------------------------------------------------------------------------- /po/meson.build: -------------------------------------------------------------------------------- 1 | i18n.gettext(meson.project_name(), 2 | args: [ 3 | '--directory=' + meson.source_root(), 4 | '--from-code=UTF-8' 5 | ] 6 | ) -------------------------------------------------------------------------------- /src/Action.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | public interface Action : Object { 23 | 24 | public DateTime created_at { owned get { return new DateTime.now_local(); } } 25 | 26 | } -------------------------------------------------------------------------------- /src/AppHeaderBar.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | using Gtk; 23 | 24 | 25 | /* 26 | public class Readdit.AppHeaderBar : HeaderBar { 27 | 28 | construct { 29 | show_close_button = true; 30 | get_style_context().add_class("app-header-bar"); 31 | 32 | var custom_header = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 1); 33 | custom_header.get_style_context().add_class("custom-header"); 34 | 35 | var search_text = new Gtk.Entry(); 36 | search_text.get_style_context().add_class("search-text"); 37 | search_text.set_size_request(300, 1); 38 | search_text.set_alignment(0.5f); 39 | custom_header.pack_start(search_text); 40 | 41 | this.custom_title = custom_header; 42 | } 43 | 44 | } 45 | 46 | */ -------------------------------------------------------------------------------- /src/Application.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | using Readdit; 22 | using Readdit.DataStores; 23 | 24 | public class Readdit.Application : Gtk.Application { 25 | 26 | public Application(){ 27 | Object( 28 | application_id: "io.github.xchan14.readdit", 29 | flags: ApplicationFlags.FLAGS_NONE 30 | ); 31 | } 32 | 33 | public static int main (string[] args){ 34 | var err = GtkClutter.init (ref args); 35 | if (err != Clutter.InitError.SUCCESS) { 36 | error ("Could not initalize clutter: %s ", err.to_string ()); 37 | } 38 | Gst.init (ref args); 39 | PostStore.init(); 40 | 41 | var app = new Application(); 42 | return app.run(args); 43 | } 44 | 45 | protected override void activate(){ 46 | var main_window = new MainWindow(this); 47 | add_window (main_window); 48 | main_window.destroy.connect( s => { 49 | Gst.deinit(); 50 | Gtk.main_quit(); 51 | }); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Contants.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | public class Constants { 23 | 24 | public const string REDDIT_BASE_API = "https://reddit.com"; 25 | 26 | } -------------------------------------------------------------------------------- /src/DataStores/Parsers/CommentParser.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | using Gee; 23 | using Readdit.Models.Comments; 24 | using Json; 25 | 26 | namespace Readdit.DataStores.Parsers { 27 | 28 | /** 29 | * Parses a Comment object from comment json data returned by API. 30 | */ 31 | public class CommentParser { 32 | Parser _parser = new Parser(); 33 | 34 | public CommentCollection parse_comments(string? parent_id, string data) { 35 | try { 36 | this._parser.load_from_data(data, -1); 37 | var root_object = this._parser.get_root().get_array(); 38 | GLib.List json_comments = root_object.get_element(1) 39 | .get_object() 40 | .get_object_member("data") 41 | .get_array_member("children") 42 | .get_elements(); 43 | 44 | return parse_comments_recursively(parent_id, 0, json_comments); 45 | } catch(Error e) { 46 | error(e.message); 47 | } 48 | } 49 | 50 | public Collection parse_more_comments(string data) { 51 | try{ 52 | 53 | this._parser.load_from_data(data, -1); 54 | var root_object = this._parser.get_root().get_object(); 55 | 56 | GLib.List things_nodes = root_object 57 | .get_object_member("json") 58 | .get_object_member("data") 59 | .get_array_member("things") 60 | .get_elements(); 61 | 62 | var comments = new ArrayList(); 63 | foreach(Json.Node comment_node in things_nodes) { 64 | Json.Object comment_obj = comment_node.get_object(); 65 | string kind = comment_obj.get_string_member("kind"); 66 | Json.Object data_obj = comment_obj.get_object_member("data"); 67 | 68 | if(kind == "t1") { 69 | Comment comment = parse_comment_from_json(data_obj); 70 | comments.add(comment); 71 | } else { 72 | stdout.printf("Kind is %s...\n", kind); 73 | } 74 | } 75 | 76 | return comments; 77 | 78 | } catch (Error e) { 79 | error(e.message); 80 | } 81 | } 82 | 83 | /** 84 | * Parses the comments recursively. 85 | */ 86 | private CommentCollection parse_comments_recursively(string? parent_id = null, int depth = 0, GLib.List? comment_nodes = null) { 87 | if(comment_nodes == null) 88 | return new CommentCollection(null, depth); 89 | 90 | CommentCollection comment_collection = new CommentCollection(parent_id, depth); 91 | 92 | foreach(Json.Node comment_node in comment_nodes) { 93 | Json.Object comment_obj = comment_node.get_object(); 94 | string kind = comment_obj.get_string_member("kind"); 95 | Json.Object data_obj = comment_obj.get_object_member("data"); 96 | 97 | if(kind == "t1") { 98 | Comment comment = parse_comment_from_json(data_obj); 99 | comment_collection.add(comment); 100 | // Parse replies from the comment object. 101 | GLib.List replies_node = get_replies_nodes(data_obj); 102 | // Recursive call to parse inner comments. 103 | int children_depth = comment.depth + 1; 104 | comment.comment_collection = parse_comments_recursively(comment.id, children_depth, replies_node); 105 | } else if (kind == "more") { 106 | // Parse ids if there are more comments. 107 | var more_ids = parse_more_comment_ids(data_obj); 108 | comment_collection.more_comment_ids.add_all(more_ids); 109 | } 110 | } 111 | 112 | return comment_collection; 113 | } 114 | 115 | /* 116 | * Returns a Comment object parsed from JSON object returned by API. 117 | */ 118 | public Comment parse_comment_from_json(Json.Object comment_obj) { 119 | string id = comment_obj.get_string_member("name"); 120 | int depth = (int) comment_obj.get_int_member("depth"); 121 | var comment = new Comment(id, depth) { 122 | text = comment_obj.get_string_member("body"), 123 | comment_by = comment_obj.get_string_member("author"), 124 | score = (int) comment_obj.get_int_member("score"), 125 | date_created = new DateTime.from_unix_local(comment_obj.get_int_member("created")), 126 | parent_id = comment_obj.get_string_member("parent_id"), 127 | comment_collection = new CommentCollection(null, depth) 128 | }; 129 | return comment; 130 | } 131 | 132 | private ArrayList parse_more_comment_ids(Json.Object more_comment_obj) { 133 | GLib.List ids_nodes = more_comment_obj 134 | .get_array_member("children") 135 | .get_elements(); 136 | var ids = new ArrayList(); 137 | foreach(Json.Node id_node in ids_nodes) { 138 | ids.add(id_node.get_string()); 139 | } 140 | return ids; 141 | } 142 | 143 | /* 144 | * Returns the replies(List) from a given comment(Json.Object). 145 | */ 146 | private GLib.List get_replies_nodes(Json.Object parent_obj) { 147 | Json.Node replies_node = parent_obj.get_member("replies"); 148 | if(replies_node.get_node_type() != Json.NodeType.OBJECT) 149 | return new GLib.List(); 150 | 151 | Json.Object replies_obj = replies_node.get_object(); 152 | return replies_obj 153 | .get_object_member("data") 154 | .get_array_member("children") 155 | .get_elements(); 156 | } 157 | 158 | } 159 | 160 | } 161 | -------------------------------------------------------------------------------- /src/DataStores/Parsers/PostParser.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | using Gee; 23 | using Readdit.Models.Posts; 24 | 25 | namespace Readdit.DataStores.Parsers { 26 | 27 | public class PostParser { 28 | 29 | public Collection parse_from_data(string data) { 30 | var list = new ArrayList(); 31 | var parser = new Json.Parser(); 32 | try { 33 | parser.load_from_data(data, -1); 34 | Json.Object root_object = parser.get_root ().get_object (); 35 | Json.Array post_items = root_object 36 | .get_object_member("data") 37 | .get_array_member("children"); 38 | 39 | GLib.List items = post_items.get_elements(); 40 | foreach(Json.Node post_node in items) { 41 | Post post = map_post_from_json(post_node); 42 | list.add(post); 43 | } 44 | return list; 45 | } catch(Error e) { 46 | error(e.message); 47 | } 48 | } 49 | 50 | 51 | private Post map_post_from_json(Json.Node post_node) { 52 | var post_data = post_node.get_object().get_object_member("data"); 53 | string id = post_data.get_string_member("name"); 54 | var post = new Post(id) { 55 | title = post_data.get_string_member("title"), 56 | body_text = post_data.get_string_member("selftext"), 57 | score = (int) post_data.get_int_member("score"), 58 | subreddit = post_data.get_string_member("subreddit_name_prefixed"), 59 | posted_by = post_data.get_string_member("author"), 60 | posted_by_id = post_data.get_string_member("author_fullname"), 61 | date_created = new DateTime.from_unix_local((long)post_data.get_double_member("created")), 62 | is_video = post_data.get_boolean_member("is_video") 63 | }; 64 | 65 | Json.Object preview_object = post_data.get_object_member("preview"); 66 | if(preview_object != null) { 67 | Json.Array image_array_object = preview_object.get_array_member("images"); 68 | if(image_array_object != null) { 69 | Json.Object image_object = image_array_object 70 | .get_element(0) 71 | .get_object(); 72 | 73 | if(!post.is_video) { 74 | post.image_url = image_object.get_object_member("source") 75 | .get_string_member("url") 76 | .replace("&" ,"&"); 77 | } 78 | 79 | Json.Object resolutions_object = image_object 80 | .get_array_member("resolutions") 81 | .get_element(1).get_object(); 82 | post.preview_url = resolutions_object 83 | .get_string_member("url") 84 | .replace("&" ,"&"); 85 | } 86 | } 87 | 88 | if(post.is_video) { 89 | post.media_url = post_data.get_object_member("media") 90 | .get_object_member("reddit_video") 91 | .get_string_member("hls_url"); 92 | } 93 | 94 | 95 | post.date_loaded = new DateTime.now_utc(); 96 | return post; 97 | } 98 | 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /src/DataStores/PostStore.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | using Gee; 23 | using Readdit.DataStores.Parsers; 24 | using Readdit.Models.Posts; 25 | using Readdit.Models.Comments; 26 | using Readdit.Views.PostList; 27 | using Readdit.Views.PostDetails; 28 | 29 | namespace Readdit.DataStores { 30 | 31 | public class PostStore : Object { 32 | private static PostStore _instance; 33 | 34 | public signal void emit_change(); 35 | 36 | private ArrayList _loaded_posts = new ArrayList(); 37 | private Post _current_viewed_post; 38 | private string _current_subreddit; 39 | private string _current_post_sort; 40 | private bool _is_loading_post; 41 | 42 | private PostStore() { 43 | Dispatcher.INSTANCE.action_dispatched.connect(handle_dispatched_actions); 44 | } 45 | 46 | public static PostStore INSTANCE { 47 | get { 48 | if(_instance == null) { 49 | _instance = new PostStore(); 50 | } 51 | return _instance; 52 | } 53 | } 54 | 55 | public static void init() { 56 | var instance = INSTANCE; 57 | } 58 | 59 | public Collection loaded_posts { 60 | owned get { 61 | return this._loaded_posts; 62 | /* var values = new ArrayList.wrap(_loaded_posts.values.to_array(), null); 63 | values.sort((a, b) => { 64 | if(a.date_loaded.to_unix() < b.date_loaded.to_unix()) 65 | return -1; 66 | else if(a.date_loaded.to_unix() > b.date_loaded.to_unix()) 67 | return 1; 68 | else return 0; 69 | }); 70 | return values; */ 71 | } 72 | } 73 | 74 | public Post current_viewed_post { 75 | owned get { 76 | return this._current_viewed_post; 77 | } 78 | } 79 | 80 | public bool is_loading_new_posts { 81 | get { 82 | return this._is_loading_post; 83 | } 84 | } 85 | 86 | private void handle_dispatched_actions(Action dispatched_action) { 87 | if(dispatched_action is LoadMorePostsAction) { 88 | var action = (LoadMorePostsAction) dispatched_action; 89 | load_posts(action.sort_by, action.subreddit); 90 | } else if (dispatched_action is ViewPostAction) { 91 | var action = (ViewPostAction) dispatched_action; 92 | view_post(action.post_id); 93 | } else if (dispatched_action is LoadPostPreviewAction) { 94 | var action = (LoadPostPreviewAction) dispatched_action; 95 | load_post_preview(action.post_id, action.url); 96 | } else if (dispatched_action is LoadPostDetailsImageAction) { 97 | var action = (LoadPostDetailsImageAction) dispatched_action; 98 | load_post_details_image_action(action.post_id, action.image_url); 99 | } else if (dispatched_action is LoadPostCommentsAction) { 100 | var action = (LoadPostCommentsAction) dispatched_action; 101 | load_comments(action.post_id, action.after); 102 | } else if (dispatched_action is LoadMoreCommentsAction) { 103 | var action = (LoadMoreCommentsAction) dispatched_action; 104 | load_more_comments(action.parent_id, action.depth); 105 | } 106 | 107 | 108 | } 109 | 110 | private void load_posts(string sort_by, string? subreddit) { 111 | this._is_loading_post = true; 112 | //if(subreddit == null) 113 | // subreddit = this._current_subreddit; 114 | 115 | if(this._current_subreddit != subreddit || this._current_post_sort != sort_by) { 116 | // Clear cached post items if subreddit changes. 117 | this._loaded_posts.clear(); 118 | this._current_subreddit = subreddit; 119 | this._current_post_sort = sort_by; 120 | stdout.printf("Post list cleared in store...\n"); 121 | } 122 | var session = new Soup.Session(); 123 | string last_loaded_post_id = null; 124 | if(!this._loaded_posts.is_empty) { 125 | last_loaded_post_id = this._loaded_posts.last().id; 126 | } 127 | 128 | var endpoint = subreddit == null ? sort_by : subreddit + "/" + sort_by; 129 | stdout.printf("url endpoint: %s...\n", endpoint); 130 | var url = Constants.REDDIT_BASE_API + "/" + endpoint + ".json?" 131 | + "&limit=10" 132 | + "&after=" + last_loaded_post_id; 133 | 134 | stdout.printf("Getting post from api...\nurl: %s\n", url); 135 | var message = new Soup.Message("GET", url); 136 | 137 | session.queue_message(message, (sess, mess) => { 138 | 139 | stdout.printf("Parsing data from response.\n"); 140 | string data = (string)message.response_body.flatten().data; 141 | var post_parser = new PostParser(); 142 | this._loaded_posts.add_all(post_parser.parse_from_data(data)); 143 | 144 | info("Caching posts finished...\n"); 145 | 146 | this._is_loading_post = false; 147 | info("Total posts: %d\n", this._loaded_posts.size); 148 | this.emit_change(); 149 | }); 150 | 151 | } 152 | 153 | private void view_post(string? post_id) { 154 | this._current_viewed_post = post_id == null ? null 155 | : this._loaded_posts.first_match(p => p.id == post_id); 156 | this.emit_change(); 157 | } 158 | 159 | private void load_post_preview(string post_id, string url) { 160 | // Create cache file. 161 | Post post = this._loaded_posts.first_match(p => p.id == post_id); 162 | 163 | try { 164 | string preview_dir = Environment.get_user_cache_dir() 165 | + "/" + Environment.get_application_name() 166 | + "/posts/previews"; 167 | File file_preview_dir = File.new_for_path(preview_dir); 168 | if(!file_preview_dir.query_exists(null)) { 169 | file_preview_dir.make_directory_with_parents(null); 170 | } 171 | 172 | post.preview_path = preview_dir + "/" + post.id + ".png"; 173 | File file_preview_path = File.new_for_path(post.preview_path); 174 | 175 | if(!file_preview_path.query_exists(null)) { 176 | var loop = new MainLoop(); 177 | var file_preview_url = File.new_for_uri(post.preview_url); 178 | file_preview_url.copy_async.begin(file_preview_path, FileCopyFlags.OVERWRITE, Priority.DEFAULT, null, null, 179 | () => { 180 | stdout.printf("File downloaded...\n"); 181 | loop.quit(); 182 | this.emit_change(); 183 | }); 184 | loop.run(); 185 | } else { 186 | this.emit_change(); 187 | } 188 | } catch(Error e) { 189 | post.preview_path = null; 190 | this.emit_change(); 191 | } 192 | } 193 | 194 | private void load_post_details_image_action(string post_id, string url) { 195 | // Create cache file. 196 | Post post = this._loaded_posts.first_match(p => p.id == post_id); 197 | try { 198 | string image_dir = Environment.get_user_cache_dir() 199 | + "/" + Environment.get_application_name() 200 | + "/posts/images"; 201 | File file_image_dir = File.new_for_path(image_dir); 202 | if(!file_image_dir.query_exists(null)) { 203 | file_image_dir.make_directory_with_parents(null); 204 | } 205 | 206 | post.image_path = image_dir + "/" + post.id + ".jpg"; 207 | File file_image_path = File.new_for_path(post.image_path); 208 | if(!file_image_path.query_exists(null)) { 209 | file_image_path.create(FileCreateFlags.REPLACE_DESTINATION, null); 210 | var file_image_url = File.new_for_uri(post.image_url); 211 | var loop = new MainLoop(); 212 | file_image_url.copy_async.begin(file_image_path, FileCopyFlags.OVERWRITE, Priority.DEFAULT, null, null, 213 | () => { 214 | loop.quit(); 215 | stdout.printf("File copied\n"); 216 | this.emit_change(); 217 | }); 218 | loop.run(); 219 | } 220 | } catch(Error e) { 221 | post.image_path = null; 222 | stderr.printf("%s\n", e.message); 223 | } 224 | } 225 | 226 | private void load_comments(string post_id, string? after) { 227 | Post post = this._loaded_posts.first_match(p => p.id == post_id); 228 | if(post.comment_collection != null) { 229 | stdout.printf("Comments are already downloaded...\n"); 230 | this.emit_change(); 231 | return; 232 | } 233 | string url = Constants.REDDIT_BASE_API + "/" + post.subreddit + "/comments/article.json?" 234 | + "&raw_json=1" 235 | + "&article=" + post.id.replace("t3_", "") 236 | + "&after=" + after; 237 | 238 | stdout.printf("url: %s\n", url); 239 | 240 | var message = new Soup.Message("GET", url); 241 | var session = new Soup.Session(); 242 | 243 | session.queue_message(message, (sess, mess) => { 244 | try { 245 | string data = (string)message.response_body.flatten().data; 246 | CommentParser parser = new CommentParser(); 247 | CommentCollection comment_collection = parser.parse_comments(null, data); 248 | post.comment_collection = comment_collection; 249 | this.emit_change(); 250 | } catch(Error e) { 251 | error("Error: %s\n", e.message); 252 | } 253 | }); 254 | } 255 | 256 | private void load_more_comments(string? parent_id = null, int depth) { 257 | stdout.printf("Loading more comments of parent %s in post store...\n", parent_id); 258 | // Get parent comment collection object. 259 | CommentCollection parent_comment_collection = this.current_viewed_post.comment_collection; 260 | 261 | stdout.printf("Finding parent comment (%s) to load in post store...\n", parent_id); 262 | parent_comment_collection = parent_comment_collection.find_by_parent_id(parent_id, depth); 263 | if(parent_comment_collection == null) { 264 | stdout.printf("Parent %s not found...\n", parent_id); 265 | return; 266 | } 267 | stdout.printf("Parent %s comment collection found...\n", parent_comment_collection.parent_id); 268 | int item_count = 10; 269 | if(parent_comment_collection.more_comment_ids.size < item_count) { 270 | item_count = parent_comment_collection.more_comment_ids.size; 271 | } 272 | var children_ids = new Gee.ArrayList(); 273 | for(int i = 1; i <= item_count; i++) { 274 | string removed_id = parent_comment_collection.more_comment_ids.remove_at(0); 275 | children_ids.add(removed_id); 276 | } 277 | 278 | // Send http request. 279 | string joined_children = string.joinv(",", children_ids.to_array()); 280 | string url = Constants.REDDIT_BASE_API + "/api/morechildren.json?" 281 | + "&api_type=json" 282 | + "&link_id=" + this.current_viewed_post.id 283 | + "&limit_children=true" 284 | + "&children=" + joined_children; 285 | stdout.printf("Loading more comments in %s...\n", url); 286 | var message = new Soup.Message("GET", url); 287 | var session = new Soup.Session(); 288 | session.queue_message(message, (sess, mess) => { 289 | try { 290 | string data = (string)message.response_body.flatten().data; 291 | CommentParser parser = new CommentParser(); 292 | stdout.printf("Parsing api result...\n"); 293 | Collection more_comments = parser.parse_more_comments(data); 294 | stdout.printf("More comments parsing finished...\n"); 295 | 296 | foreach(Comment comment in more_comments) { 297 | bool isPostParent = parent_comment_collection.parent_id == null 298 | && comment.parent_id.contains("t3_"); 299 | if(comment.parent_id == parent_comment_collection.parent_id 300 | || isPostParent) { 301 | parent_comment_collection.add(comment); 302 | stdout.printf("Added comment %s to parent %s...\n", comment.id, parent_comment_collection.parent_id); 303 | } else { 304 | stdout.printf("Adding comment %s to a parent...\n", comment.id); 305 | CommentCollection parent_comment = parent_comment_collection 306 | .find_by_parent_id(comment.parent_id, parent_comment_collection.depth); 307 | if(parent_comment != null) { 308 | parent_comment.add(comment); 309 | stdout.printf("Added comment %s to parent %s...\n", comment.id, parent_comment.parent_id); 310 | } else { 311 | stdout.printf("No parent(%s) found to add new comment(%s)...\n", comment.parent_id, comment.id); 312 | } 313 | } 314 | } 315 | 316 | this.emit_change(); 317 | } catch(Error e) { 318 | stderr.printf(e.message); 319 | } 320 | }); 321 | } 322 | 323 | } 324 | 325 | } 326 | -------------------------------------------------------------------------------- /src/DataStores/UiStore.vala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xchan14/readdit/a183db06ffe654d51ded9dc22d358e2b0886c85f/src/DataStores/UiStore.vala -------------------------------------------------------------------------------- /src/DataStores/UserStore.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | using Readdit.Users; 23 | using Gee; 24 | 25 | namespace Readdit.DataStores { 26 | 27 | public class UserStore : GLib.Object { 28 | 29 | private static Collection _cached_users = new Gee.ArrayList(); 30 | 31 | public Collection get_user_data_by_ids(string[] ids) { 32 | string concatIds = ""; 33 | foreach(string id in ids) { 34 | concatIds = concatIds.concat(",", id); 35 | } 36 | concatIds = concatIds.substring(1); 37 | 38 | var session = new Soup.Session(); 39 | string url = "https://reddit.com/api/user_data_by_account_ids.json?ids=" + concatIds; 40 | var message = new Soup.Message("GET", url); 41 | 42 | var users = new Gee.ArrayList(); 43 | session.send_message(message); 44 | string data = (string)message.response_body.flatten().data; 45 | try { 46 | var parser = new Json.Parser(); 47 | parser.load_from_data(data, -1); 48 | Json.Object root_object = parser.get_root ().get_object (); 49 | 50 | root_object.foreach_member((obj, name, node) => { 51 | var account_data = node.get_object(); 52 | stdout.printf(name); 53 | var user = new User(); 54 | user.id = name; 55 | user.name = account_data.get_string_member("name"); 56 | user.profile_image_url = account_data.get_string_member("profile_img"); 57 | users.add(user); 58 | }); 59 | } catch(Error e) { 60 | stdout.printf("Error: %s\n", e.message); 61 | } 62 | 63 | // Cache users if not yet cached. 64 | foreach(User user in users) { 65 | bool user_exists = false; 66 | foreach(User cached_user in _cached_users) { 67 | if(user.id == cached_user.id) { 68 | user_exists = true; 69 | break; 70 | } 71 | } 72 | if(user_exists) { 73 | continue; 74 | } 75 | 76 | _cached_users.add(user); 77 | } 78 | 79 | return users; 80 | } 81 | 82 | public User get_user(string id) { 83 | stdout.printf("Getting user by id %s\n", id); 84 | User existing_user = null; 85 | foreach(User user in _cached_users) { 86 | if(user.id == id) { 87 | existing_user = user; 88 | break; 89 | } 90 | } 91 | 92 | if(existing_user != null) { 93 | stdout.printf("User exists and being returned.\n"); 94 | return existing_user; 95 | } 96 | 97 | stdout.printf("Getting user from server if not existing...\n"); 98 | 99 | Collection users = get_user_data_by_ids(new string[] { id }); 100 | 101 | existing_user = users.to_array()[0]; 102 | return existing_user; 103 | } 104 | } 105 | 106 | } -------------------------------------------------------------------------------- /src/Dispatcher.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | using Gee; 23 | 24 | public class Readdit.Dispatcher : Object { 25 | private static Dispatcher _instance; 26 | public delegate void ActionCallback(Action action); 27 | 28 | public signal void action_dispatched(Action action); 29 | 30 | public static Dispatcher INSTANCE { 31 | get { 32 | if(_instance == null) { 33 | _instance = new Dispatcher(); 34 | } 35 | return _instance; 36 | } 37 | } 38 | 39 | public void dispatch(Action action) { 40 | //stdout.printf("Dispatching action of type %s...\n", action.get_type().name()); 41 | action_dispatched(action); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Models/Comments/Comment.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | using Gee; 23 | 24 | namespace Readdit.Models.Comments { 25 | 26 | public class Comment : Object { 27 | public Comment(string id, int depth) { 28 | Object( 29 | id: id, 30 | depth: depth 31 | ); 32 | } 33 | 34 | public string id { get; construct; } 35 | public int depth { get; construct; } 36 | 37 | public string text { get; set; } 38 | public string comment_by { get; set; } 39 | public string comment_by_id { get; set; } 40 | public int score { get; set; } 41 | public DateTime date_created { get; set; } 42 | public string? parent_id { get; set; } 43 | 44 | public CommentCollection comment_collection { get; set; } 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /src/Models/Comments/CommentCollection.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | using Gee; 23 | 24 | namespace Readdit.Models.Comments { 25 | public class CommentCollection : ArrayList { 26 | 27 | public CommentCollection(string? parent_id = null, int depth) { 28 | Object( 29 | parent_id: parent_id, 30 | depth: depth 31 | ); 32 | more_comment_ids = new ArrayList(); 33 | } 34 | 35 | // Contains the id of parent comment. If null, it means that 36 | // it is the top level comment collection which is the post comments. 37 | public string? parent_id { get; construct; } 38 | public int depth { get; construct; } 39 | public ArrayList more_comment_ids { get; private set; } 40 | 41 | /* 42 | * Find comment collection recursively by parent id. 43 | */ 44 | public CommentCollection find_by_parent_id(string? parent_id = null, int depth = 0) { 45 | if(parent_id == null) 46 | return this; 47 | 48 | foreach(Comment comment in this) { 49 | if(comment.id == parent_id) { 50 | stdout.printf("Parent %s found...\n", parent_id); 51 | return comment.comment_collection; 52 | } else if(comment.comment_collection != null && comment.comment_collection.depth <= depth) { 53 | var found_comment_collection = comment.comment_collection.find_by_parent_id(parent_id, depth); 54 | if(found_comment_collection != null) { 55 | return found_comment_collection; 56 | } 57 | } 58 | } 59 | 60 | return null; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /src/Models/Comments/LoadMoreCommentsAction.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | namespace Readdit.Models.Comments { 23 | 24 | public class LoadMoreCommentsAction : Object, Action { 25 | public LoadMoreCommentsAction(string? parent_id = null, int depth = 0) { 26 | Object( 27 | parent_id: parent_id, 28 | depth: depth 29 | ); 30 | } 31 | 32 | public string parent_id { get; construct; } 33 | public int depth { get; construct; } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Models/Comments/LoadPostCommentsAction.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | namespace Readdit.Models.Comments { 23 | 24 | public class LoadPostCommentsAction : Object, Action { 25 | public LoadPostCommentsAction(string post_id, string? after = null) { 26 | Object( 27 | post_id: post_id, 28 | after: after 29 | ); 30 | } 31 | 32 | public string post_id { get; construct; } 33 | public string after { get; construct; } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Models/Posts/LoadMorePostsAction.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | public class Readdit.Models.Posts.LoadMorePostsAction : Object, Action { 23 | public LoadMorePostsAction(string sort_by, string? subreddit) { 24 | Object( 25 | sort_by: sort_by, 26 | subreddit: subreddit 27 | ); 28 | } 29 | public string sort_by { get; construct; } 30 | public string? subreddit { get; construct; } 31 | } 32 | -------------------------------------------------------------------------------- /src/Models/Posts/LoadPostDetailsImageAction.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | namespace Readdit.Models.Posts { 23 | public class LoadPostDetailsImageAction : Object, Action { 24 | public LoadPostDetailsImageAction(string post_id, string image_url) { 25 | Object( 26 | post_id: post_id, 27 | image_url: image_url 28 | ); 29 | } 30 | public string post_id { get; construct; } 31 | public string image_url { get; construct; } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Models/Posts/LoadPostPreviewAction.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | public class Readdit.Models.Posts.LoadPostPreviewAction : Object, Action { 23 | public LoadPostPreviewAction(string post_id, string url) { 24 | Object( 25 | post_id: post_id, 26 | url: url 27 | ); 28 | } 29 | 30 | public string post_id { get; construct; } 31 | public string url { get; construct; } 32 | } -------------------------------------------------------------------------------- /src/Models/Posts/Post.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2018 Your Organization (https://yourwebsite.com) 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | using Gee; 23 | using Readdit.Models.Comments; 24 | 25 | namespace Readdit.Models.Posts { 26 | 27 | public class Post : Object { 28 | 29 | public Post(string id) { 30 | Object( 31 | id: id 32 | ); 33 | } 34 | 35 | public string id { get; construct; } 36 | public CommentCollection comment_collection { get; set; } 37 | 38 | public string title { get; set; } 39 | public int score { get; set; } 40 | public string posted_by { get; set; } 41 | public string posted_by_id { get ;set; } 42 | public string subreddit { get; set; } 43 | public DateTime date_created { get ;set; } 44 | public string body_text { get; set; } 45 | public string? image_url { get; set; } 46 | public string? image_path { get; set; } 47 | public string? preview_url { get; set; } 48 | public string? preview_path { get; set; } 49 | public bool is_video { get; set; } 50 | public string media_url { get; set; } 51 | 52 | public DateTime date_loaded { get; set; } 53 | 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /src/Models/Posts/ViewPostAction.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | public class Readdit.Models.Posts.ViewPostAction : Object, Action { 23 | public ViewPostAction(string post_id) { 24 | Object(post_id: post_id); 25 | } 26 | public string post_id { get; construct; } 27 | } -------------------------------------------------------------------------------- /src/Models/Users/User.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | public class Readdit.Users.User { 23 | 24 | public string id { get; set; } 25 | public string name { get; set; } 26 | public string profile_image_url { get; set; } 27 | } 28 | -------------------------------------------------------------------------------- /src/Screens/PostScreen.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | using Gtk; 23 | using Readdit.DataStores; 24 | using Readdit.Models.Posts; 25 | using Readdit.Views.PostList; 26 | using Readdit.Views.PostDetails; 27 | using Readdit; 28 | 29 | public class Readdit.Screens.PostScreen : Gtk.Paned { 30 | PostStore _post_store = PostStore.INSTANCE; 31 | Dispatcher _dispatcher = Dispatcher.INSTANCE; 32 | 33 | // Headerbar widgets 34 | PostScreenHeaderBar _header_bar; 35 | 36 | PostListView _post_list_view; 37 | PostDetailsView _post_details_view; 38 | Gtk.Widget _empty_details_view; 39 | Gtk.ScrolledWindow _scrolled_details_view; 40 | Gtk.Box _details_view_wrapper; 41 | 42 | construct { 43 | get_style_context().add_class("post-view"); 44 | 45 | this._post_list_view = new PostListView("best", null); 46 | this._empty_details_view = new EmptyPostDetailsView(); 47 | 48 | this._details_view_wrapper = new Gtk.Box(Gtk.Orientation.VERTICAL, 0); 49 | this._scrolled_details_view = new Gtk.ScrolledWindow(null, null) { 50 | hscrollbar_policy = Gtk.PolicyType.NEVER, 51 | expand = false 52 | }; 53 | this._scrolled_details_view.add(this._details_view_wrapper); 54 | 55 | this._details_view_wrapper.pack_start(this._empty_details_view, false, false, 0); 56 | this._details_view_wrapper.get_style_context().add_class("post-details-wrapper"); 57 | 58 | this._post_list_view.set_size_request(350, -1); 59 | this._scrolled_details_view.set_size_request(600, -1); 60 | 61 | pack1(this._post_list_view, false, false); 62 | pack2(this._scrolled_details_view, true, false); 63 | 64 | set_position(2); 65 | 66 | this.size_allocate.connect((allocation) => { 67 | @foreach(w => w.queue_draw()); 68 | }); 69 | 70 | this._post_list_view.selected_post_changed.connect(on_selected_post_changed); 71 | } 72 | 73 | public PostScreen(ApplicationWindow main_window) { 74 | this._header_bar = new PostScreenHeaderBar(); 75 | this._header_bar.post_sort_by_changed.connect((sort_by) => { 76 | stdout.printf("Sort by %s...\n", sort_by); 77 | this.remove(this._post_list_view); 78 | this._post_list_view = null; 79 | this._post_list_view = new PostListView(sort_by, null); 80 | this._post_list_view.selected_post_changed.connect(on_selected_post_changed); 81 | pack1(this._post_list_view, false, false); 82 | }); 83 | 84 | this._header_bar.get_style_context().add_class(Gtk.STYLE_CLASS_FLAT); 85 | this._header_bar.get_style_context().add_class(Gtk.STYLE_CLASS_SIDEBAR); 86 | main_window.set_titlebar(this._header_bar); 87 | } 88 | 89 | private void on_selected_post_changed(Post post) { 90 | this._details_view_wrapper.@foreach(w => this._details_view_wrapper.remove(w)); 91 | this._post_details_view = null; 92 | this._post_details_view = new PostDetailsView(post); 93 | this._details_view_wrapper.pack_start(this._post_details_view, false, false, 0); 94 | } 95 | 96 | private class PostScreenHeaderBar : Gtk.HeaderBar { 97 | 98 | public signal void post_sort_by_changed(string id); 99 | 100 | Gtk.ComboBoxText post_sort_by; 101 | 102 | construct { 103 | show_close_button = true; 104 | has_subtitle = false; 105 | get_style_context().add_class("app-header-bar"); 106 | set_size_request(-1, 55); 107 | 108 | var custom_header = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 1) { 109 | hexpand = true 110 | }; 111 | custom_header.get_style_context().add_class("custom-header"); 112 | 113 | var search_text = new Gtk.Entry(); 114 | search_text.get_style_context().add_class("search-text"); 115 | search_text.set_alignment(0.5f); 116 | custom_header.set_center_widget(search_text); 117 | 118 | post_sort_by = new Gtk.ComboBoxText() { 119 | has_frame = true 120 | }; 121 | post_sort_by.get_style_context().add_class("post_sort_by"); 122 | post_sort_by.set_size_request(-1, 50); 123 | post_sort_by.append("best", "Best"); 124 | post_sort_by.append("hot", "Hot"); 125 | post_sort_by.append("top", "Top"); 126 | post_sort_by.append("new", "New"); 127 | post_sort_by.append("rising", "Rising"); 128 | post_sort_by.set_active(0); 129 | custom_header.pack_start(post_sort_by, false); 130 | post_sort_by.changed.connect(() => post_sort_by_changed(post_sort_by.active_id)); 131 | post_sort_by.show(); 132 | 133 | var mode_switch = new Granite.ModeSwitch.from_icon_name ( 134 | "display-brightness-symbolic", 135 | "weather-clear-night-symbolic" 136 | ); 137 | mode_switch.primary_icon_tooltip_text = ("Light background"); 138 | mode_switch.secondary_icon_tooltip_text = ("Dark background"); 139 | mode_switch.valign = Gtk.Align.CENTER; 140 | var gtk_settings = Gtk.Settings.get_default (); 141 | mode_switch.bind_property ("active", gtk_settings, "gtk_application_prefer_dark_theme"); 142 | custom_header.pack_end(mode_switch, false, false, 0); 143 | 144 | this.custom_title = custom_header; 145 | } 146 | 147 | public string post_sort_by_id { 148 | get { 149 | return this.post_sort_by.active_id; 150 | } 151 | } 152 | } 153 | 154 | } 155 | -------------------------------------------------------------------------------- /src/Utils/DateUtils.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | public class DateUtils { 22 | 23 | public const int DAYS = 86400; 24 | public const int HOURS = 3600; 25 | public const int MINUTES = 60; 26 | 27 | public static string ToDateDifference(DateTime date, int denominator = DAYS) { 28 | var nowDate = new DateTime.now_local(); 29 | var diff = (int) ((nowDate.to_unix() - date.to_unix()) / denominator); 30 | 31 | if(diff < 1) { 32 | if(denominator == DAYS) 33 | return ToDateDifference(date, HOURS); 34 | else if (denominator == HOURS) 35 | return ToDateDifference(date, MINUTES); 36 | } 37 | 38 | var suffix = "days"; 39 | if(denominator == DAYS) suffix = "day"; 40 | else if(denominator == HOURS) suffix = "hr"; 41 | else if(denominator == MINUTES) suffix = "min"; 42 | else suffix = "sec"; 43 | 44 | return diff.to_string() + suffix.to_string() + " ago"; 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /src/Utils/FileUtils.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ -------------------------------------------------------------------------------- /src/Utils/FormatUtils.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | public class FormatUtils { 22 | 23 | public const int SCORE_MILLION = 1000000; 24 | public const int SCORE_THOUSAND = 1000; 25 | public const int SCORE_ONE = 1; 26 | 27 | public static string FormatScore(int score, int denominator = SCORE_ONE) { 28 | var x = score / denominator; 29 | 30 | if(x >= SCORE_THOUSAND) 31 | return FormatScore(score, SCORE_THOUSAND); 32 | if(x >= SCORE_MILLION) 33 | return FormatScore(score, SCORE_MILLION); 34 | 35 | var suffix = ""; 36 | if(denominator == SCORE_ONE) suffix = ""; 37 | else if(denominator == SCORE_THOUSAND) suffix = "k"; 38 | else if(denominator == SCORE_MILLION) suffix = "M"; 39 | else suffix = "B"; 40 | 41 | return x.to_string() + suffix; 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /src/Utils/HttpUtils.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | namespace Utils { 22 | 23 | public class HttpUtils { 24 | 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/Utils/ImageUtils.vala: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (c) 2020 Christian Camilon 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public 16 | * License along with this program; if not, write to the 17 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 | * Boston, MA 02110-1301 USA 19 | * 20 | * Authored by: Christian Camilon 21 | */ 22 | using Gdk; 23 | 24 | public class Readdit.Utils.ImageUtils { 25 | 26 | public static Pixbuf CropToSquare(Pixbuf original_image, int size = 100) { 27 | // Calculate the new dimensions for the cropped image 28 | int width = original_image.get_width(); 29 | int height = original_image.get_height(); 30 | int x_offset = 0; 31 | int y_offset = 0; 32 | 33 | if (width > height) { 34 | x_offset = (width - height) / 2; 35 | width = height; 36 | } else { 37 | y_offset = (height - width) / 2; 38 | height = width; 39 | } 40 | 41 | // Crop the image 42 | Pixbuf cropped_image = new Pixbuf.subpixbuf(original_image, x_offset, y_offset, width, height); 43 | 44 | // Scale the image to the desired size 45 | Pixbuf scaled_image = cropped_image.scale_simple(size, size, InterpType.BILINEAR); 46 | 47 | return scaled_image; 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /src/Views/Comments/CommentCollectionView.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | using Gtk; 23 | using Readdit.DataStores; 24 | using Readdit.Models.Comments; 25 | 26 | namespace Readdit.Views.Comments { 27 | 28 | public class CommentCollectionView : Gtk.Box { 29 | Readdit.Dispatcher _dispatcher = Readdit.Dispatcher.INSTANCE; 30 | PostStore _post_store = PostStore.INSTANCE; 31 | 32 | public signal void load_more_click(string comment_id, string[] children); 33 | 34 | ListBox _list_box; 35 | Label _more_comments_label; 36 | 37 | public CommentCollectionView(CommentCollection? comment_collection) { 38 | 39 | this.model = comment_collection; 40 | orientation = Orientation.VERTICAL; 41 | expand = false; 42 | resize_mode = ResizeMode.PARENT; 43 | 44 | this._list_box = new ListBox(){ 45 | selection_mode = SelectionMode.NONE 46 | }; 47 | var list_box_style = this._list_box.get_style_context(); 48 | list_box_style.add_class("comment-list-box"); 49 | if(this.model.depth > 0) { 50 | list_box_style.add_class("comment-list-box-indent"); 51 | } 52 | 53 | this._more_comments_label = new Label(null) { 54 | xalign = 0.0f, 55 | use_markup = true 56 | }; 57 | this._more_comments_label.get_style_context().add_class("comment-more"); 58 | 59 | foreach(Comment comment in this.model) { 60 | this._list_box.insert(new CommentItemView(comment), -1); 61 | } 62 | 63 | pack_start(this._list_box); 64 | 65 | show_all(); 66 | 67 | map.connect(on_map); 68 | this._post_store.emit_change.connect(on_post_store_emit_change); 69 | } 70 | 71 | ~CommentCollectionView() { 72 | //this._post_store.emit_change.disconnect(on_post_store_emit_change); 73 | //map.disconnect(on_map); 74 | } 75 | 76 | public bool is_empty() { 77 | return this._list_box.get_children().length() == 0; 78 | } 79 | 80 | public CommentCollection model { get; set; } 81 | 82 | private bool on_load_more_click(Gtk.Widget w, Gdk.EventButton eb) { 83 | stdout.printf("Loading more comments from parent %s at depth %d...\n", model.parent_id, model.depth); 84 | this._dispatcher.dispatch(new LoadMoreCommentsAction(model.parent_id, model.depth)); 85 | return true; 86 | } 87 | 88 | private void on_map() { 89 | if(this.model.more_comment_ids.size > 0) { 90 | int more_count = this.model.more_comment_ids.size; 91 | this._more_comments_label.label = update_more_comments_label_text(more_count); 92 | this._more_comments_label.button_press_event.connect(on_load_more_click); 93 | pack_start(this._more_comments_label, false, false, 0); 94 | } 95 | } 96 | 97 | private void on_post_store_emit_change() { 98 | try { 99 | foreach(Comment comment in model) { 100 | CommentItemView comment_item_view = null; 101 | foreach(Gtk.Widget child in this._list_box.get_children()) { 102 | var list_box_row = child as Gtk.ListBoxRow; 103 | var row_comment_item_view = list_box_row.get_child() as CommentItemView; 104 | if(row_comment_item_view == null) { 105 | stdout.printf("Not a comment item view...\n"); 106 | continue; 107 | } 108 | if(row_comment_item_view.model.id == comment.id) { 109 | comment_item_view = row_comment_item_view; 110 | break; 111 | } 112 | } 113 | 114 | if(comment_item_view == null) { 115 | comment_item_view = new CommentItemView(comment); 116 | this._list_box.insert(comment_item_view, -1); 117 | stdout.printf("Added new comment %s...\n", comment.id); 118 | } 119 | } 120 | 121 | string new_label = update_more_comments_label_text(this.model.more_comment_ids.size); 122 | if (this.model.more_comment_ids.size <= 0) { 123 | remove(this._more_comments_label); 124 | this._more_comments_label.button_press_event.disconnect(on_load_more_click); 125 | } else if(this._more_comments_label.label != new_label) { 126 | this._more_comments_label.label = new_label; 127 | } 128 | } catch(Error e) { 129 | stderr.printf("Error: %s\n", e.message); 130 | } 131 | 132 | } 133 | 134 | private string update_more_comments_label_text(int count) { 135 | return "Load more comments (".concat(count.to_string(), ")..."); 136 | } 137 | 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /src/Views/Comments/CommentItemView.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | using Gtk; 22 | using Readdit.Models.Comments; 23 | 24 | namespace Readdit.Views.Comments { 25 | 26 | public class CommentItemView : Gtk.Box { 27 | 28 | Label _comment_by; 29 | Label _score; 30 | Label _text; 31 | CommentCollectionView _replies; 32 | 33 | Gtk.Box _header; 34 | 35 | public CommentItemView(Comment comment) { 36 | Object(model: comment); 37 | orientation = Orientation.VERTICAL; 38 | resize_mode = ResizeMode.PARENT; 39 | 40 | //margin_start = 8; 41 | expand = false; 42 | get_style_context().add_class("comment-wrapper"); 43 | get_style_context().add_class("h3"); 44 | 45 | this._comment_by = new Label(null) { 46 | label = comment.comment_by, 47 | xalign = 0.0f 48 | }; 49 | this._comment_by.get_style_context().add_class("comment-by"); 50 | this._score = new Label(null) { 51 | label = " ".concat(comment.score.to_string()) , 52 | xalign = 0.0f 53 | }; 54 | 55 | this._text = new Label(null) { 56 | label = comment.text, 57 | xalign = 0.0f, 58 | selectable = true, 59 | wrap = true, 60 | wrap_mode = Pango.WrapMode.WORD_CHAR 61 | }; 62 | this._text.set_line_wrap(true); 63 | this._text.get_style_context().add_class("comment-text"); 64 | 65 | this._header = new Box(Gtk.Orientation.HORIZONTAL, 0) { 66 | baseline_position = Gtk.BaselinePosition.BOTTOM 67 | }; 68 | this._header.pack_start(this._comment_by, false, false, 0); 69 | create_score_buttons(); 70 | //this._header.pack_start(this._score, false, false, 0); 71 | 72 | 73 | pack_start(this._header, false, false, 0); 74 | pack_start(this._text, false, false, 0); 75 | 76 | if(this.model.comment_collection != null) { 77 | this._replies = new CommentCollectionView(this.model.comment_collection); 78 | this._replies.get_style_context().add_class("comment-children"); 79 | pack_start(this._replies); 80 | } 81 | 82 | show_all(); 83 | } 84 | 85 | public Comment model { get; construct; } 86 | 87 | private void create_score_buttons() { 88 | var toggle_score = new Button.with_label (_model.score.to_string()); 89 | var toggle_up = new ToggleButton.with_label (">"); 90 | var toggle_down = new ToggleButton.with_label ("<"); 91 | var toggles = new Box(Orientation.HORIZONTAL, 0); 92 | 93 | toggles.get_style_context ().add_class (STYLE_CLASS_LINKED); 94 | toggles.get_style_context ().add_class ("comment-score-buttons"); 95 | toggles.pack_start (toggle_down, false, false); 96 | toggles.pack_start (toggle_score, false, false); 97 | toggles.pack_start (toggle_up, false, false); 98 | _header.pack_start (toggles, false,false); 99 | } 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/Views/Layout/MainContent.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | using Gtk; 22 | using Granite; 23 | using Readdit.Views.PostDetails; 24 | 25 | public class Readdit.Views.Layout.MainContent : Box { 26 | 27 | private Hdy.HeaderBar _header; 28 | private ScrolledWindow _contentContainer; 29 | private Widget _contentView; 30 | 31 | construct { 32 | orientation = Orientation.VERTICAL; 33 | resize_mode = ResizeMode.PARENT; 34 | get_style_context ().add_class (Gtk.STYLE_CLASS_BACKGROUND); 35 | 36 | insert_header(); 37 | insert_content_container(); 38 | } 39 | 40 | public Hdy.HeaderBar get_header() { 41 | return _header; 42 | } 43 | 44 | private void insert_header() { 45 | _header = new Hdy.HeaderBar () { 46 | has_subtitle = false, 47 | show_close_button = true, 48 | }; 49 | 50 | _header.pack_end(create_theme_mode_switch()); 51 | 52 | unowned StyleContext _header_context = _header.get_style_context (); 53 | _header_context.add_class ("default-decoration"); 54 | _header_context.add_class (Gtk.STYLE_CLASS_FLAT); 55 | 56 | pack_start(_header, false, false, 0); 57 | } 58 | 59 | private ModeSwitch create_theme_mode_switch() { 60 | var mode_switch = new Granite.ModeSwitch.from_icon_name ( 61 | "display-brightness-symbolic", 62 | "weather-clear-night-symbolic" 63 | ); 64 | mode_switch.primary_icon_tooltip_text = ("Light background"); 65 | mode_switch.secondary_icon_tooltip_text = ("Dark background"); 66 | mode_switch.valign = Gtk.Align.CENTER; 67 | var gtk_settings = Gtk.Settings.get_default (); 68 | mode_switch.bind_property ("active", gtk_settings, "gtk_application_prefer_dark_theme"); 69 | return mode_switch; 70 | } 71 | 72 | private void insert_content_container() { 73 | _contentContainer = new Gtk.ScrolledWindow(null, null) { 74 | hscrollbar_policy = PolicyType.NEVER, 75 | expand = false 76 | }; 77 | pack_start(_contentContainer, true, true); 78 | } 79 | 80 | public void change_content(owned Widget contentView) { 81 | if(contentView == null) { 82 | contentView = new EmptyPostDetailsView(); 83 | stdout.printf("Empty content view set...\n"); 84 | } 85 | // Remove content from container 86 | _contentContainer.remove(_contentView); 87 | 88 | // Reassing new content 89 | _contentView = contentView; 90 | _contentContainer.get_style_context().add_class("content"); 91 | 92 | // Attach new content to container 93 | _contentContainer.add(contentView); 94 | stdout.printf("Content changed...\n"); 95 | } 96 | } -------------------------------------------------------------------------------- /src/Views/Layout/Sidebar.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | using Gtk; 22 | using Readdit.Views.PostList; 23 | 24 | public class Readdit.Views.Layout.Sidebar : Grid { 25 | 26 | private Hdy.HeaderBar _header; 27 | private ActionBar _actionBar; 28 | private ScrolledWindow _content; 29 | private Widget _contentView; 30 | 31 | public Sidebar(Widget contentView) { 32 | _contentView = contentView; 33 | width_request = 400; 34 | 35 | createHeaderBar(); 36 | attach (_header, 0, 0); 37 | 38 | createContent(); 39 | attach (_content, 0, 1); 40 | 41 | //createActionBar(); 42 | //attach (_actionBar, 0, 2); 43 | 44 | unowned StyleContext sidebar_style_context = get_style_context (); 45 | sidebar_style_context.add_class (Gtk.STYLE_CLASS_SIDEBAR); 46 | } 47 | 48 | public Hdy.HeaderBar GetHeader() { 49 | return _header; 50 | } 51 | 52 | private void createHeaderBar() { 53 | _header = new Hdy.HeaderBar () { 54 | has_subtitle = false, 55 | show_close_button = true 56 | }; 57 | 58 | unowned Gtk.StyleContext sidebar_header_context = _header.get_style_context (); 59 | sidebar_header_context.add_class ("default-decoration"); 60 | sidebar_header_context.add_class (Gtk.STYLE_CLASS_FLAT); 61 | } 62 | 63 | private void createContent() { 64 | var listbox = new Gtk.ListBox (); 65 | var scheduled_row = new Gtk.Label("Test"); 66 | listbox.add (scheduled_row); 67 | 68 | _content = new Gtk.ScrolledWindow (null, null) { 69 | expand = true, 70 | hscrollbar_policy = Gtk.PolicyType.NEVER 71 | }; 72 | 73 | //var postList = new PostList(); 74 | //_content.add (postList); 75 | _content.add(_contentView); 76 | 77 | var postListView = new PostListView(); 78 | _content.add(postListView); 79 | } 80 | 81 | private void createActionBar() { 82 | _actionBar = new Gtk.ActionBar (); 83 | unowned Gtk.StyleContext actionbar_style_context = _actionBar.get_style_context (); 84 | actionbar_style_context.add_class (Gtk.STYLE_CLASS_FLAT); 85 | 86 | var online_accounts_button = new Gtk.ModelButton () { 87 | text = _("Online Accounts Settings…") 88 | }; 89 | 90 | var add_tasklist_grid = new Gtk.Grid () { 91 | margin_top = 3, 92 | margin_bottom = 3, 93 | row_spacing = 3 94 | }; 95 | 96 | var add_tasklist_buttonbox = new Gtk.ButtonBox (Gtk.Orientation.VERTICAL) { 97 | layout_style = Gtk.ButtonBoxStyle.EXPAND 98 | }; 99 | 100 | 101 | add_tasklist_grid.attach (add_tasklist_buttonbox, 0, 0); 102 | add_tasklist_grid.attach (new Gtk.Separator (Gtk.Orientation.HORIZONTAL), 0, 1); 103 | add_tasklist_grid.attach (online_accounts_button, 0, 2); 104 | add_tasklist_grid.show_all (); 105 | 106 | var add_tasklist_popover = new Gtk.Popover (null); 107 | add_tasklist_popover.add (add_tasklist_grid); 108 | 109 | var add_tasklist_button = new Gtk.MenuButton () { 110 | label = _("Add Task List…"), 111 | image = new Gtk.Image.from_icon_name ("list-add-symbolic", Gtk.IconSize.SMALL_TOOLBAR), 112 | always_show_image = true, 113 | popover = add_tasklist_popover 114 | }; 115 | 116 | _actionBar.add (add_tasklist_button); 117 | } 118 | } -------------------------------------------------------------------------------- /src/Views/MainWindow.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | using Gtk; 22 | using Readdit.Views.Layout; 23 | using Readdit.Views.PostDetails; 24 | using Readdit.Views.PostList; 25 | using Readdit.Models.Posts; 26 | 27 | public class Readdit.MainWindow : Hdy.ApplicationWindow { 28 | 29 | private MainContent _mainContent; 30 | 31 | public MainWindow(Readdit.Application readdit){ 32 | Object( 33 | application: readdit 34 | ); 35 | } 36 | 37 | static construct { 38 | Hdy.init(); 39 | } 40 | 41 | construct { 42 | title = "ReaddIt"; 43 | window_position = WindowPosition.CENTER; 44 | set_window_size(); 45 | apply_css(); 46 | 47 | var postListView = new PostListView(); 48 | var sidebar = new Sidebar(postListView); 49 | 50 | _mainContent = new MainContent(); 51 | 52 | // Create a header group that automatically assigns the right decoration controls to the 53 | // right headerbar automatically 54 | var header_group = new Hdy.HeaderGroup (); 55 | header_group.add_header_bar (sidebar.GetHeader()); 56 | header_group.add_header_bar (_mainContent.get_header()); 57 | 58 | var paned = new Gtk.Paned (Orientation.HORIZONTAL); 59 | paned.pack1 (sidebar, false, false); 60 | paned.pack2 (_mainContent, true, false); 61 | 62 | add(paned); 63 | 64 | show_all(); 65 | 66 | postListView.selected_post_changed.connect(on_selected_post_changed); 67 | } 68 | 69 | private void set_window_size() 70 | { 71 | set_default_size(1300, 800); 72 | } 73 | 74 | 75 | private void on_selected_post_changed(Post post) { 76 | //this._details_view_wrapper.@foreach(w => this._details_view_wrapper.remove(w)); 77 | stdout.printf("Changing post...\n"); 78 | _mainContent.change_content(new PostDetailsView(post)); 79 | stdout.printf("Post changed...\n"); 80 | } 81 | 82 | private void apply_css() 83 | { 84 | CssProvider css_provider = new CssProvider(); 85 | css_provider.load_from_resource("io/github/xchan14/readdit/application.css"); 86 | StyleContext.add_provider_for_screen( 87 | Gdk.Screen.get_default(), 88 | css_provider, 89 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); 90 | } 91 | } -------------------------------------------------------------------------------- /src/Views/PostDetails/EmptyPostDetailsView.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | using Gtk; 22 | 23 | namespace Readdit.Views.PostDetails { 24 | 25 | public class EmptyPostDetailsView : Box { 26 | 27 | construct { 28 | orientation = Gtk.Orientation.VERTICAL; 29 | pack_start(new Gtk.Label("No selected post")); 30 | 31 | show_all(); 32 | } 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /src/Views/PostDetails/PostDetailsContentView.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | using Gtk; 22 | using Gdk; 23 | using Granite.Widgets; 24 | using Readdit; 25 | using Readdit.DataStores; 26 | using Readdit.Models.Posts; 27 | 28 | namespace Readdit.Views.PostDetails { 29 | 30 | 31 | public class PostDetailsContentView : Box { 32 | Dispatcher _dispatcher = Dispatcher.INSTANCE; 33 | PostStore _post_store = PostStore.INSTANCE; 34 | 35 | Box _details_header; 36 | Label _post_title; 37 | Label _post_subreddit; 38 | Label _post_posted_by; 39 | 40 | Box _details_content; 41 | Box _media_wrapper; 42 | Image _image; 43 | Pixbuf _image_pixbuf; 44 | VideoPlayer _video_player; 45 | Label _body_text; 46 | 47 | ~PostDetailsContentView() { 48 | this._details_header = null; 49 | this._post_title = null; 50 | this._post_posted_by = null; 51 | this._post_subreddit = null; 52 | 53 | this._details_content = null; 54 | this._image_pixbuf = null; 55 | this._image = null; 56 | this._video_player = null; 57 | this._body_text = null; 58 | } 59 | 60 | public PostDetailsContentView(Post post) { 61 | Object(model: post); 62 | init_gui(); 63 | bind_events(); 64 | } 65 | 66 | public Post model { get; construct; } 67 | 68 | private void init_gui() { 69 | var style = get_style_context(); 70 | //style.add_class("card"); 71 | style.add_class("post-details-content"); 72 | orientation = Orientation.VERTICAL; 73 | 74 | /* 75 | * Header Details contains title, post, user, score, subreddit. 76 | */ 77 | this._details_header = new Box(Orientation.VERTICAL, 0); 78 | this._details_header.get_style_context().add_class("post-details-content-header"); 79 | 80 | // Subreddit 81 | this._post_subreddit = new Label(null) { 82 | label = this.model.subreddit, 83 | wrap = true, 84 | xalign = 0.0f 85 | }; 86 | this._post_subreddit.get_style_context().add_class("post-details-subreddit"); 87 | this._post_subreddit.get_style_context().add_class("h2"); 88 | this._details_header.pack_start(this._post_subreddit, false, true); 89 | 90 | // Title 91 | this._post_title = new Label(null) { 92 | label = this.model.title, 93 | wrap = true, 94 | xalign = 0.0f 95 | }; 96 | this._post_title.get_style_context().add_class("post-details-title"); 97 | this._post_title.get_style_context().add_class("h2"); 98 | this._details_header.pack_start(this._post_title, false, true); 99 | 100 | // Posted By 101 | this._post_posted_by = new Label(null) { 102 | label = this.model.posted_by, 103 | wrap = true, 104 | xalign = 0.0f 105 | }; 106 | this._details_header.pack_start(this._post_posted_by, false, true); 107 | 108 | 109 | /* 110 | * Content Details includes image, videos, or text content. 111 | */ 112 | this._details_content = new Box(Gtk.Orientation.VERTICAL, 0); 113 | if(this.model.image_url != null || this.model.media_url != null) { 114 | this._media_wrapper = new Box(Gtk.Orientation.VERTICAL, 0){ 115 | hexpand = false 116 | }; 117 | this._media_wrapper.get_style_context().add_class("post-details-content-media"); 118 | this._details_content.pack_start( 119 | this._media_wrapper, 120 | false, 121 | false, 122 | 0 123 | ); 124 | } 125 | 126 | if (this.model.image_url != null) { 127 | this._dispatcher.dispatch(new LoadPostDetailsImageAction(this.model.id, this.model.image_url)); 128 | } 129 | 130 | if(this.model.media_url != null) { 131 | stdout.printf("Video link: %s\n", this.model.media_url); 132 | load_video_player(); 133 | } 134 | 135 | if(this.model.body_text != null && this.model.body_text.length > 0) { 136 | this._body_text = new Label(null) { 137 | label = this.model.body_text, 138 | xalign = 0.0f, 139 | selectable = true, 140 | wrap = true, 141 | use_markup = true 142 | }; 143 | this._body_text.get_style_context().add_class("post-details-content-body-text"); 144 | this._body_text.get_style_context().add_class("h3"); 145 | this._details_content.pack_start( 146 | this._body_text, 147 | false, 148 | false, 149 | 0 150 | ); 151 | 152 | 153 | } 154 | 155 | pack_start(this._details_header, true, true); 156 | pack_start(this._details_content, true, true); 157 | } 158 | 159 | private void bind_events() { 160 | this._post_store.emit_change.connect(on_post_store_emit_change); 161 | } 162 | 163 | private void on_post_store_emit_change() { 164 | if(this._image == null && this.model.image_path != null) { 165 | load_image(); 166 | } 167 | } 168 | 169 | private void load_image() { 170 | if(this._image_pixbuf == null) { 171 | try { 172 | this._image_pixbuf = new Gdk.Pixbuf.from_file(this.model.image_path); 173 | } catch(Error e) { 174 | stderr.printf("File error: %s\n", e.message); 175 | } 176 | } 177 | if(this._image_pixbuf == null) { 178 | stderr.printf("Error loading image file...\n"); 179 | return; 180 | } 181 | int height = this._image_pixbuf.get_height(); 182 | int width = this._image_pixbuf.get_width(); 183 | int new_height = 500; 184 | int new_width = 0; 185 | double height_multiplier = (double) new_height / (double) height; 186 | new_width = (int) ((double)width * height_multiplier); 187 | this._image_pixbuf = this._image_pixbuf.scale_simple(new_width, new_height, Gdk.InterpType.BILINEAR); 188 | this._image = new Gtk.Image.from_pixbuf(this._image_pixbuf); 189 | var image_box_wrapper = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0); 190 | this._media_wrapper.pack_start(image_box_wrapper, false, false); 191 | this._media_wrapper.get_style_context().add_class("post-details-media"); 192 | image_box_wrapper.pack_start(this._image, false, false); 193 | image_box_wrapper.show_all(); 194 | } 195 | 196 | private void load_video_player() { 197 | try { 198 | this._video_player = null; 199 | this._video_player = new VideoPlayer() { 200 | width_request = 720, 201 | height_request = 480 202 | }; 203 | this._video_player.video_uri = this.model.media_url; 204 | this._media_wrapper.set_center_widget(this._video_player); 205 | 206 | /* 207 | this._video_web = new WebKit.WebView(); 208 | this._video_web.set_size_request(720, 480); 209 | this._video_web.load_uri(this.model.media_url); 210 | this._media_wrapper.set_center_widget(this._video_web); 211 | */ 212 | 213 | } catch(Error e) { 214 | stderr.printf("Error setting up this._video_player: %s\n", e.message); 215 | } 216 | } 217 | 218 | } 219 | 220 | } 221 | -------------------------------------------------------------------------------- /src/Views/PostDetails/PostDetailsView.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | using Gtk; 23 | using Gee; 24 | using Granite.Widgets; 25 | using Readdit.Models.Posts; 26 | using Readdit.Models.Comments; 27 | using Readdit.Views.PostDetails; 28 | using Readdit.Views.Comments; 29 | using Readdit.DataStores; 30 | 31 | namespace Readdit.Views.PostDetails { 32 | 33 | public class PostDetailsView : Box { 34 | PostStore _post_store = PostStore.INSTANCE; 35 | Dispatcher _dispatcher = Dispatcher.INSTANCE; 36 | 37 | PostDetailsContentView _post_details_content_view; 38 | CommentCollectionView _comments_view; 39 | 40 | construct { 41 | set_size_request(400, -1); 42 | get_style_context().add_class("post-details"); 43 | orientation = Orientation.VERTICAL; 44 | } 45 | 46 | public PostDetailsView(Post post) { 47 | Object(model: post); 48 | 49 | this._post_details_content_view = new PostDetailsContentView(this.model); 50 | pack_start(this._post_details_content_view, false, true); 51 | show_all(); 52 | 53 | this.size_allocate.connect((allocation) => { 54 | this.queue_draw(); 55 | }); 56 | this.map.connect(() => { 57 | this._dispatcher.dispatch(new LoadPostCommentsAction(this.model.id, null)); 58 | }); 59 | this._post_store.emit_change.connect(on_post_store_emit_change); 60 | } 61 | 62 | public Post model { get; construct; } 63 | 64 | /* 65 | * Handles changes in Post Store. 66 | */ 67 | private void on_post_store_emit_change() { 68 | if(this._comments_view == null && this.model.comment_collection != null) { 69 | stdout.printf("Rendering comments...\n"); 70 | this._comments_view = new CommentCollectionView(this.model.comment_collection); 71 | //this._comments_view.get_style_context().add_class("card"); 72 | pack_start(this._comments_view, false, true); 73 | this._comments_view.show_all(); 74 | stdout.printf("Comments rendered....\n"); 75 | } 76 | } 77 | 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/Views/PostList/PostListItemView.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | using Gtk; 23 | using Readdit.Utils; 24 | using Readdit.DataStores; 25 | using Readdit.Models.Posts; 26 | 27 | namespace Readdit.Views.PostList { 28 | 29 | public class PostListItemView : Box { 30 | Dispatcher _dispatcher = Dispatcher.INSTANCE; 31 | PostStore _post_store = PostStore.INSTANCE; 32 | 33 | Label _title; 34 | Label _score; 35 | Label _posted_by; 36 | Label _subreddit; 37 | Label _date_posted; 38 | 39 | Box _preview_wrapper; 40 | Image _preview; 41 | 42 | private bool _preview_shown; 43 | 44 | construct { 45 | orientation = Orientation.VERTICAL; 46 | hexpand = true; 47 | var style = get_style_context(); 48 | style.add_class("post-list-item"); 49 | } 50 | 51 | public PostListItemView(Post post) 52 | { 53 | this.model = post; 54 | 55 | AddHeader(); 56 | AddContent(); 57 | AddFooter(); 58 | 59 | show_all(); 60 | 61 | this._post_store.emit_change.connect(on_post_store_emit_changed); 62 | 63 | this.map.connect(() => { 64 | if(this.model.preview_url != null) { 65 | this._dispatcher.dispatch(new LoadPostPreviewAction(this.model.id, this.model.preview_url)); 66 | } 67 | }); 68 | } 69 | 70 | private void AddHeader() { 71 | // Score 72 | var scoreText = FormatUtils.FormatScore(model.score); 73 | this._score = new Gtk.Label(scoreText); 74 | this._score.get_style_context().add_class("score"); 75 | this._score.valign = Align.BASELINE; 76 | 77 | // Posted By 78 | _posted_by = new Label(model.posted_by); 79 | _posted_by.get_style_context().add_class("posted-by"); 80 | _posted_by.valign = Align.BASELINE; 81 | 82 | 83 | // Subreddit 84 | this._subreddit = new Label(null); 85 | this._subreddit.label = _model.subreddit; 86 | this._subreddit.get_style_context().add_class("subreddit"); 87 | this._subreddit.valign = Align.BASELINE; 88 | 89 | var container = new Box(Orientation.HORIZONTAL, 9); 90 | container.pack_start(_score, false, true, 0); 91 | container.pack_start(_posted_by, false, true, 0); 92 | container.pack_end(_subreddit, false, false, 0); 93 | 94 | pack_start(container, false, false, 0); 95 | } 96 | 97 | private void AddContent() { 98 | // Title 99 | _title = new Label( model.title); 100 | _title.get_style_context().add_class("post-title"); 101 | _title.get_style_context().add_class("h3"); 102 | _title.xalign = 0.0f; 103 | _title.valign = Align.START; 104 | _title.wrap = true; 105 | _title.single_line_mode = false; 106 | 107 | // Preview 108 | _preview = new Gtk.Image(); 109 | _preview_wrapper = new Box(Orientation.HORIZONTAL, 0); 110 | _preview_wrapper.valign = Align.START; 111 | _preview_wrapper.pack_start(this._preview, true, true, 0); 112 | 113 | var container = new Box(Orientation.HORIZONTAL, 12); 114 | container.pack_start(_title); 115 | if(_model.preview_url != null) { 116 | container.pack_start(_preview_wrapper, false, false, 0); 117 | } 118 | 119 | pack_start(container, false ,false, 0); 120 | } 121 | 122 | private void AddFooter() { 123 | // Date Posted 124 | var diff = DateUtils.ToDateDifference(model.date_created); 125 | _date_posted = new Label(diff); 126 | _date_posted.get_style_context().add_class("date-posted"); 127 | _date_posted.xalign = 0; 128 | _date_posted.valign = Align.BASELINE; 129 | 130 | var container = new Box(Orientation.HORIZONTAL, 0); 131 | container.get_style_context().add_class("post-list-item-footer"); 132 | container.pack_end(_date_posted, false, false, 0); 133 | 134 | pack_start(container); 135 | } 136 | 137 | public Post model { get; set; } 138 | 139 | private void on_post_store_emit_changed() { 140 | if(this.model.preview_path != null && !this._preview_shown) { 141 | load_post_preview(); 142 | } 143 | } 144 | 145 | private void load_post_preview() { 146 | if(this.model.preview_path == null) 147 | return; 148 | 149 | try { 150 | var preview_pixbuf = new Gdk.Pixbuf.from_file(this.model.preview_path); 151 | preview_pixbuf = ImageUtils.CropToSquare(preview_pixbuf, 80); 152 | 153 | this._preview = new Gtk.Image.from_pixbuf(preview_pixbuf); 154 | this._preview.get_style_context().add_class("thumbnail"); 155 | this._preview_wrapper.foreach(w => w.destroy()); 156 | this._preview_wrapper.pack_start(this._preview, false, false, 0); 157 | this._preview_wrapper.show_all(); 158 | } catch(Error e) { 159 | stderr.printf(e.message); 160 | } finally { 161 | this._preview_shown = true; 162 | } 163 | } 164 | } 165 | 166 | } 167 | -------------------------------------------------------------------------------- /src/Views/PostList/PostListView.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Christian Camilon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | * 19 | * Authored by: Christian Camilon 20 | */ 21 | 22 | using Gee; 23 | using Readdit.DataStores; 24 | using Readdit.Users; 25 | using Readdit.Models.Posts; 26 | 27 | namespace Readdit.Views.PostList { 28 | 29 | public class PostListView : Gtk.ScrolledWindow { 30 | 31 | public signal void selected_post_changed(Post post); 32 | 33 | // Reference to post store. 34 | private PostStore _post_store = PostStore.INSTANCE; 35 | // Reference to global dispatcher. 36 | private Readdit.Dispatcher _dispatcher = Readdit.Dispatcher.INSTANCE; 37 | // Listbox widget for the list of posts. 38 | private Gtk.ListBox _listbox; 39 | // Data store behind the posts listbox. 40 | private PostListModel _posts_list_model; 41 | // Current rendered posts 42 | private Collection _posts; 43 | 44 | private string _current_sort; 45 | private string _current_subreddit; 46 | 47 | public PostListView(string sort_by = "top", string? subreddit = null) 48 | { 49 | this._current_sort = sort_by; 50 | this._current_subreddit = subreddit; 51 | 52 | this._posts_list_model = new PostListModel(); 53 | 54 | get_style_context().add_class("post-list"); 55 | set_propagate_natural_width(true); 56 | hscrollbar_policy = Gtk.PolicyType.NEVER; 57 | 58 | this._listbox = new Gtk.ListBox(); 59 | this._listbox.activate_on_single_click = true; 60 | this._listbox.selection_mode = Gtk.SelectionMode.BROWSE; 61 | this._listbox.get_style_context().add_class("post-list-listbox"); 62 | this._listbox.bind_model(this._posts_list_model, create_list_item_widget); 63 | add(_listbox); 64 | 65 | bind_event_handlers(); 66 | 67 | show_all(); 68 | } 69 | 70 | // Bind event handlers. 71 | private void bind_event_handlers() { 72 | this._post_store.emit_change.connect(on_post_store_emit_change); 73 | this.edge_reached.connect(on_edge_reached); 74 | this._listbox.row_selected.connect(on_listbox_row_selected); 75 | 76 | this.map.connect(() => { 77 | this._dispatcher.dispatch(new LoadMorePostsAction( 78 | this._current_sort, 79 | this._current_subreddit)); 80 | }); 81 | } 82 | 83 | private void on_edge_reached(Gtk.PositionType pos) { 84 | if(pos == Gtk.PositionType.BOTTOM) { 85 | // Infinite scroll implementation. 86 | if(!this._post_store.is_loading_new_posts) { 87 | this._dispatcher.dispatch(new LoadMorePostsAction( 88 | this._current_sort, 89 | this._current_subreddit)); 90 | } else { 91 | stdout.printf("Still loading new posts...\n"); 92 | } 93 | } 94 | } 95 | 96 | // Handles changes from Post Store. 97 | private void on_post_store_emit_change() { 98 | // Update list when new posts are loaded. 99 | update_list(); 100 | } 101 | 102 | // Creates the widget to be displayed on post listbox widget. 103 | private Gtk.Widget create_list_item_widget(Object item) { 104 | var post = (Post) item; 105 | var view = new PostListItemView(post); 106 | view.show_all(); 107 | return view; 108 | } 109 | 110 | private void on_show() { 111 | this._listbox.bind_model(this._posts_list_model, create_list_item_widget); 112 | } 113 | 114 | // Handles row selected event of listbox. 115 | private void on_listbox_row_selected(Gtk.ListBoxRow? row) { 116 | string id = null; 117 | if(row != null) { 118 | Post post = ((Post) this._posts_list_model.get_item(row.get_index())); 119 | id = post.id; 120 | stdout.printf("id: %s\n", id); 121 | _dispatcher.dispatch(new ViewPostAction(id)); 122 | selected_post_changed(post); 123 | } 124 | } 125 | 126 | private void update_list() { 127 | foreach(var post in this._post_store.loaded_posts) { 128 | if(!this._posts_list_model.any_match((p) => p == post)) { 129 | this._posts_list_model.add(post); 130 | } 131 | } 132 | } 133 | 134 | /* 135 | * Custom implementation of ListModel 136 | * which binds on ListBox object. 137 | */ 138 | public class PostListModel : ArrayList, ListModel { 139 | 140 | public Object? get_item (uint position) { 141 | if((int) position > base.size) 142 | return null; 143 | return base.get((int)position); 144 | } 145 | 146 | public Type get_item_type () { 147 | return typeof(Post); 148 | } 149 | 150 | public uint get_n_items () { 151 | return (uint) base.size; 152 | } 153 | 154 | public void add(Post post) { 155 | base.add(post); 156 | uint pos = get_n_items() - 1; 157 | items_changed(pos, 0, 1); 158 | } 159 | 160 | public void remove(Post post) { 161 | var index = index_of(post); 162 | remove_at(index); 163 | items_changed(index, 1, 0); 164 | } 165 | } 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /src/Views/Widgets/VideoPlayer.vala: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2017 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | * 15 | * Authored by: Felipe Escoto 16 | * 17 | */ 18 | 19 | /* 20 | Compile: valac --pkg gtk+-3.0 --pkg clutter-1.0 --pkg clutter-gst-3.0 --pkg clutter-gtk-1.0 VideoPlayer.vala 21 | Usage: ./VideoPlayer file:///path/to/file.mp4 22 | */ 23 | 24 | public class Granite.Widgets.VideoPlayer : Gtk.EventBox { 25 | 26 | protected Clutter.Stage stage { get; private set; } 27 | protected Clutter.Actor video_actor { get; private set; } 28 | protected ClutterGst.Aspectratio aspect_ratio { get; private set; } 29 | protected ClutterGst.Playback playback { get; private set; } 30 | 31 | protected GtkClutter.Embed clutter; 32 | 33 | private string video_uri_; 34 | public string? video_uri { 35 | get { 36 | return video_uri_; 37 | } 38 | 39 | set { 40 | stdout.printf ("Opening %s\n", value); 41 | if (value == null) { 42 | playback.uri = ""; 43 | } else { 44 | playback.uri = value; 45 | } 46 | } 47 | } 48 | 49 | public bool playing { 50 | get { 51 | return playback.playing; 52 | } 53 | } 54 | 55 | public VideoPlayer() { 56 | stdout.printf("Instantiating VideoPlayer...\n"); 57 | 58 | events |= Gdk.EventMask.POINTER_MOTION_MASK; 59 | events |= Gdk.EventMask.KEY_PRESS_MASK; 60 | events |= Gdk.EventMask.KEY_RELEASE_MASK; 61 | 62 | playback = new ClutterGst.Playback (); 63 | playback.set_seek_flags (ClutterGst.SeekFlags.ACCURATE); 64 | 65 | clutter = new GtkClutter.Embed (); 66 | clutter.use_layout_size = true; 67 | stage = (Clutter.Stage) clutter.get_stage (); 68 | stage.background_color = {0, 0, 0, 0}; 69 | stage.user_resizable = true; 70 | //stage.set_minimum_size(300, 300); 71 | video_actor = new Clutter.Actor (); 72 | 73 | aspect_ratio = new ClutterGst.Aspectratio (); 74 | ((ClutterGst.Aspectratio) aspect_ratio).paint_borders = false; 75 | var gst_content = ((ClutterGst.Content) aspect_ratio); 76 | gst_content.player = playback; 77 | playback.audio_volume = 1.0; 78 | 79 | video_actor.content = aspect_ratio; 80 | 81 | video_actor.add_constraint (new Clutter.BindConstraint (stage, Clutter.BindCoordinate.WIDTH, 0)); 82 | video_actor.add_constraint (new Clutter.BindConstraint (stage, Clutter.BindCoordinate.HEIGHT, 0)); 83 | 84 | button_press_event.connect (on_button_press_event); 85 | 86 | stage.add_child (video_actor); 87 | 88 | add (clutter); 89 | show_all (); 90 | 91 | playback.get_pipeline().set_state(Gst.State.READY); 92 | stdout.printf("VideoPlayer instantiated...\n"); 93 | } 94 | 95 | ~VideoPlayer() { 96 | button_press_event.disconnect(on_button_press_event); 97 | stop(); 98 | playback.get_pipeline().get_bus().unref(); 99 | playback.get_pipeline().set_state(Gst.State.NULL); 100 | clutter = null; 101 | video_actor = null; 102 | playback = null; 103 | stdout.printf("VideoPlayer is disposed...\n"); 104 | } 105 | 106 | public double get_progress () { 107 | return playback.progress; 108 | } 109 | 110 | public void seek_jump_seconds (int seconds) { 111 | var duration = playback.duration; 112 | var progress = playback.progress; 113 | var new_progress = ((duration * progress) + (double) seconds) / duration; 114 | playback.progress = double.min (new_progress, 1.0); 115 | } 116 | 117 | public void play() { 118 | stdout.printf("Video is playing...\n"); 119 | playback.playing = true; 120 | } 121 | 122 | public void stop() { 123 | if(playback.playing) { 124 | stdout.printf("Video stops playing...\n"); 125 | playback.playing = false; 126 | } 127 | } 128 | 129 | private bool on_button_press_event(Gdk.EventButton event) { 130 | if (event.button == Gdk.BUTTON_SECONDARY) { 131 | if(playing) { 132 | stop(); 133 | } else { 134 | play(); 135 | } 136 | } 137 | return base.button_press_event(event); 138 | } 139 | } 140 | --------------------------------------------------------------------------------