├── .github └── workflows │ └── main.yml ├── .gitignore ├── COPYING ├── LICENSE ├── README.md ├── build-aux └── meson │ └── postinstall.py ├── com.github.hezral.stashed.yml ├── data ├── application.css ├── com.github.hezral.stashed.appdata.xml.in ├── com.github.hezral.stashed.desktop.in ├── com.github.hezral.stashed.gschema.xml ├── icons │ ├── 128.svg │ ├── 16.svg │ ├── 24.svg │ ├── 32.svg │ ├── 48.svg │ ├── 64.svg │ ├── com.github.hezral-coffee.svg │ ├── com.github.hezral-menu-symbolic.svg │ ├── com.github.hezral-select.svg │ ├── com.github.hezral-settings-symbolic.svg │ ├── com.github.hezral-shortcuts.svg │ ├── edit-clear-symbolic.svg │ └── system-search.svg ├── meson.build ├── screenshot-01.png └── screenshot-02.png ├── meson.build ├── po ├── LINGUAS ├── POTFILES └── meson.build └── src ├── __init__.py ├── custom_widgets.py ├── main.py ├── meson.build ├── shake_listener.py ├── stashed.in ├── utils.py └── window.py /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | # This workflow will run for any pull request or pushed commit 4 | on: [push, pull_request] 5 | 6 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 7 | jobs: 8 | # This workflow contains a single job called "flatpak" 9 | flatpak: 10 | # The type of runner that the job will run on 11 | runs-on: ubuntu-latest 12 | 13 | # This job runs in a special container designed for building Flatpaks for AppCenter 14 | container: 15 | image: ghcr.io/elementary/flatpak-platform/runtime:6 16 | options: --privileged 17 | 18 | # Steps represent a sequence of tasks that will be executed as part of the job 19 | steps: 20 | # Checks-out your repository under $GITHUB_WORKSPACE, so the job can access it 21 | - uses: actions/checkout@v2 22 | 23 | # Builds your flatpak manifest using the Flatpak Builder action 24 | - uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4 25 | with: 26 | # This is the name of the Bundle file we're building and can be anything you like 27 | bundle: stashed.flatpak 28 | # This uses your app's RDNN ID 29 | manifest-path: com.github.hezral.stashed.yml 30 | 31 | # You can automatically run any of the tests you've created as part of this workflow 32 | run-tests: false 33 | 34 | # These lines specify the location of the elementary Runtime and Sdk 35 | repository-name: appcenter 36 | repository-url: https://flatpak.elementary.io/repo.flatpakrepo 37 | cache-key: "flatpak-builder-${{ github.sha }}" 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | 131 | # Flatpak 132 | .flatpak-builder/ 133 | build-dir/ -------------------------------------------------------------------------------- /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 |
2 | 3 | ![icon](data/icons/128.svg) 4 | 5 |
6 | 7 | If you like what i make, it would really be nice to have someone buy me a coffee 8 |
9 | Buy Me A Coffee 10 |
11 | 12 | ### Drag your files to Stashed to copy it later 13 | * Collect files from multiple directory 14 | * Copy all files in the stash to a direction 15 | * Copy individual files by selecting what you want 16 | * Shake the mouse cursor to call Stashed 17 | * Double click the stashed files to find individual files 18 | 19 | https://user-images.githubusercontent.com/762735/137588640-b12344ee-f53d-4294-ba95-69c5b3ebc825.mp4 20 | 21 | | ![Screenshot](data/screenshot-01.png?raw=true) | ![Screenshot](data/screenshot-02.png?raw=true) | 22 | |------------------------------------------|-----------------------------------------| 23 | 24 | # Installation 25 | 26 | ## Build using flatpak 27 | * requires that you have flatpak-builder installed 28 | * flatpak enabled 29 | * flathub remote enabled 30 | 31 | ``` 32 | flatpak-builder --user --force-clean --install build-dir com.github.hezral.stashed.yml 33 | ``` 34 | 35 | ### Build using meson 36 | Ensure you have these dependencies installed 37 | 38 | * python3 39 | * python3-gi 40 | * libgranite-dev 41 | * python-xlib 42 | * xclip 43 | * pynput 44 | 45 | Download the updated source [here](https://github.com/hezral/stashed/archive/master.zip), or use git: 46 | ```bash 47 | git clone https://github.com/hezral/stashed.git 48 | cd clips 49 | meson build --prefix=/usr 50 | cd build 51 | ninja build 52 | sudo ninja install 53 | ``` 54 | The desktop launcher should show up on the application launcher for your desktop environment 55 | if it doesn't, try running 56 | ``` 57 | com.github.hezral.stashed 58 | ``` 59 | 60 | # Thanks/Credits 61 | - [ElementaryPython](https://github.com/mirkobrombin/ElementaryPython) This started me off on coding with Python and GTK 62 | - [Lazka's PyGObject API Reference](https://https://lazka.github.io) The best documentation site for coding with Python and GTK 63 | -------------------------------------------------------------------------------- /build-aux/meson/postinstall.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from os import environ, path 4 | from subprocess import call 5 | 6 | prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local') 7 | datadir = path.join(prefix, 'share') 8 | destdir = environ.get('DESTDIR', '') 9 | 10 | # Package managers set this so we don't need to run 11 | if not destdir: 12 | print('Updating icon cache...') 13 | call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')]) 14 | 15 | print('Updating desktop database...') 16 | call(['update-desktop-database', '-q', path.join(datadir, 'applications')]) 17 | 18 | print('Compiling GSettings schemas...') 19 | call(['glib-compile-schemas', path.join(datadir, 'glib-2.0', 'schemas')]) 20 | 21 | 22 | -------------------------------------------------------------------------------- /com.github.hezral.stashed.yml: -------------------------------------------------------------------------------- 1 | app-id: com.github.hezral.stashed 2 | runtime: io.elementary.Platform 3 | runtime-version: '6' 4 | sdk: io.elementary.Sdk 5 | command: com.github.hezral.stashed 6 | finish-args: 7 | - --socket=wayland 8 | - --socket=fallback-x11 9 | # default access to user home only 10 | - --filesystem=home 11 | modules: 12 | - name: libx11-dev 13 | buildsystem: autotools 14 | sources: 15 | - type: archive 16 | url: http://archive.ubuntu.com/ubuntu/pool/main/libx/libx11/libx11_1.6.9.orig.tar.gz 17 | sha256: b8c0930a9b25de15f3d773288cacd5e2f0a4158e194935615c52aeceafd1107b 18 | - name: libxmu-headers 19 | buildsystem: autotools 20 | sources: 21 | - type: archive 22 | url: http://archive.ubuntu.com/ubuntu/pool/main/libx/libxmu/libxmu_1.1.3.orig.tar.gz 23 | sha256: 5bd9d4ed1ceaac9ea023d86bf1c1632cd3b172dce4a193a72a94e1d9df87a62e 24 | - name: libxt-dev 25 | buildsystem: autotools 26 | sources: 27 | - type: archive 28 | url: http://archive.ubuntu.com/ubuntu/pool/main/libx/libxt/libxt_1.1.5.orig.tar.gz 29 | sha256: b59bee38a9935565fa49dc1bfe84cb30173e2e07e1dcdf801430d4b54eb0caa3 30 | - name: libxmu-dev 31 | buildsystem: autotools 32 | sources: 33 | - type: archive 34 | url: http://archive.ubuntu.com/ubuntu/pool/main/libx/libxmu/libxmu_1.1.3.orig.tar.gz 35 | sha256: 5bd9d4ed1ceaac9ea023d86bf1c1632cd3b172dce4a193a72a94e1d9df87a62e 36 | - name: xclip 37 | buildsystem: autotools 38 | sources: 39 | - type: git 40 | url: https://github.com/astrand/xclip.git 41 | 42 | - name: python-xlib 43 | buildsystem: simple 44 | build-options: 45 | build-args: 46 | - --share=network 47 | build-commands: 48 | - "pip3 install --prefix=${FLATPAK_DEST} python-xlib" 49 | 50 | - name: pynput 51 | buildsystem: simple 52 | build-options: 53 | build-args: 54 | - --share=network 55 | build-commands: 56 | - "pip3 install --prefix=${FLATPAK_DEST} pynput" 57 | 58 | - name: stashed 59 | buildsystem: meson 60 | sources: 61 | - type: dir 62 | path: . 63 | -------------------------------------------------------------------------------- /data/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | # application.css 3 | # 4 | # Copyright 2021 Adi Hezral 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | 19 | */ 20 | /* @define-color shaded_darker shade(@theme_base_color, 0.98); */ 21 | 22 | headerbar > box { 23 | padding-left: 2px; 24 | } 25 | 26 | /* grid#stash-container, fader { 27 | transition: all 500ms ease-in-out; 28 | } */ 29 | 30 | @keyframes crossfader { 31 | 0% { opacity: 0; } 32 | 03.33% { opacity: 0; } 33 | 06.66% { opacity: 0; } 34 | 09.99% { opacity: 0; } 35 | 13.33% { opacity: 0.5; } 36 | 16.65% { opacity: 0.75; } 37 | 100% { opacity: 1; } 38 | } 39 | 40 | /* grid#stash-container { 41 | animation: crossfader 0.75s ease-in-out forwards; 42 | } */ 43 | 44 | button#settings { 45 | box-shadow: none; 46 | border-style: none; 47 | background: none; 48 | } 49 | 50 | button#settings:active { 51 | opacity: 0.75; 52 | } 53 | 54 | label#search-keyword { 55 | padding-top: 3px; 56 | padding-bottom: 5px; 57 | border-style: solid; 58 | border-width: 1px; 59 | border-color: rgba(0,0,0, 0.1); 60 | border-top-style: none; 61 | border-left-style: none; 62 | border-right-style: none; 63 | } 64 | 65 | scrolledwindow > undershoot.top { 66 | background-blend-mode: normal; 67 | background-clip: border-box; 68 | background-color: rgba(0,0,0,0); 69 | background-image: linear-gradient(@theme_base_color 0, alpha(@theme_base_color, 0) 50%); 70 | background-origin: padding-box; 71 | background-position: left top; 72 | background-repeat: repeat; 73 | background-size: auto; 74 | } 75 | 76 | scrolledwindow > undershoot.bottom { 77 | background-blend-mode: normal; 78 | background-clip: border-box; 79 | background-color: rgba(0,0,0,0); 80 | background-image: linear-gradient(alpha(@theme_base_color, 0) 50%, @theme_base_color 100%); 81 | background-origin: padding-box; 82 | background-position: left top; 83 | background-repeat: repeat; 84 | background-size: auto; 85 | } 86 | 87 | .stash-item-select:hover { 88 | -gtk-icon-effect: highlight; 89 | } 90 | 91 | @keyframes pulsing { 92 | 25% {border-color: alpha(@accent_color_500, 0.25);} 93 | 50% {border-color: alpha(@accent_color_500, 0.5);} 94 | 75% {border-color: alpha(@accent_color_500, 0.75);} 95 | 100% {border-color: alpha(@accent_color_500, 1);} 96 | } 97 | 98 | .stash-zone { 99 | border-color: @accent_color_500; 100 | border-style: dashed; 101 | border-width: 3px; 102 | border-radius: 12px; 103 | animation: pulsing 1.75s ease-in-out infinite; 104 | } 105 | 106 | .stash-zone-plus { 107 | color: white; 108 | font-weight: bold; 109 | font-size: 125%; 110 | text-shadow: 0px 3px 3px rgba(0, 0, 0, 0.75); 111 | background-color: rgba(0,0,0,0.25); 112 | border-radius: 9px; 113 | } 114 | 115 | label#message-display { 116 | padding: 10px; 117 | background-color: rgba(255, 0, 0, 1); 118 | border-radius: 5px; 119 | font-weight: bold; 120 | color: white; 121 | border-color: rgb(119, 0, 0.75); 122 | border-width: 1px; 123 | border-style: solid; 124 | } 125 | 126 | label#stash-zone { 127 | font-weight: bold; 128 | font-size: 125%; 129 | letter-spacing: 1px; 130 | color: @accent_color_500; 131 | background-color: alpha(@theme_base_color, 0.85); 132 | } 133 | 134 | -------------------------------------------------------------------------------- /data/com.github.hezral.stashed.appdata.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | com.github.hezral.stashed 5 | CC0 6 | GPL-3.0+ 7 | Stashed 8 | Stash and collect files to copy it later 9 | Adi Hezral 10 | 11 |

Drag your files to Stashed to copy it later

12 |

Collect files from multiple directory

13 |

Copy all files in the stash to a direction

14 |

Copy individual files by selecting what you want

15 |

Shake the mouse cursor to call Stashed

16 |

Double click the stashed files to find individual files

17 |
18 | 19 | 20 | com.github.hezral.stashed 21 | 22 | 23 | https://github.com/hezral/stashed 24 | https://github.com/hezral/stashed/issues 25 | https://github.com/hezral/stashed/issues/labels/bug 26 | 27 | 28 | 29 | Main Window 30 | https://raw.githubusercontent.com/hezral/stashed/main/data/screenshot-01.png 31 | 32 | 33 | Invidual File Window 34 | https://raw.githubusercontent.com/hezral/stashed/main/data/screenshot-02.png 35 | 36 | 37 | 38 | 39 | none 40 | none 41 | none 42 | none 43 | none 44 | none 45 | none 46 | none 47 | none 48 | none 49 | none 50 | none 51 | none 52 | none 53 | none 54 | none 55 | none 56 | none 57 | none 58 | none 59 | none 60 | none 61 | none 62 | none 63 | none 64 | none 65 | none 66 | 67 | 68 | 69 | 70 | 71 |

Fixed appdata file and manifest file

72 |
73 |
74 |
75 | 76 | 77 | #FF7E07 78 | #662200 79 | 0.00 80 | pk_live_51J03F1AXT8Az6AYFEiPc5mgpv7vUSWDnw135TmPT4tUbB2CJLwG19e3NxEuC7Zbz3VkXg7BygUQOTf7x6UDhSAn8005gq9ywZy 81 | 82 | 83 |
84 | -------------------------------------------------------------------------------- /data/com.github.hezral.stashed.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Stashed 3 | Terminal=false 4 | Type=Application 5 | Categories=Utility;System; 6 | StartupNotify=true 7 | Exec=com.github.hezral.stashed 8 | Icon=com.github.hezral.stashed 9 | -------------------------------------------------------------------------------- /data/com.github.hezral.stashed.gschema.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | Follow OS Appearance Style 7 | Follow OS Appearance Style 8 | 9 | 10 | false 11 | If the dark Gtk stylesheet should be used 12 | If the dark Gtk stylesheet should be used 13 | 14 | 15 | true 16 | Whether this is the first time app is run 17 | Used to determine whether or not to perform initial install steps 18 | 19 | 20 | true 21 | Close on focus out of app window 22 | Close on focus out of app window 23 | 24 | 25 | false 26 | Display app window on all workspaces 27 | Display app window on all workspaces 28 | 29 | 30 | true 31 | Display app window above all windows 32 | Display app window above all windows 33 | 34 | 35 | false 36 | Hides app window on startup 37 | Hides app window on startup 38 | 39 | 40 | false 41 | Shake to reveal 42 | Shake to reveal 43 | 44 | 45 | 5 46 | Shake sensitivity 47 | Shake sensitivity 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /data/icons/128.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /data/icons/16.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /data/icons/24.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /data/icons/32.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /data/icons/48.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /data/icons/64.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /data/icons/com.github.hezral-coffee.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /data/icons/com.github.hezral-menu-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 16 | 36 | 39 | 40 | 42 | 43 | 45 | image/svg+xml 46 | 48 | 49 | 50 | 51 | 52 | 54 | 61 | 68 | 75 | 76 | -------------------------------------------------------------------------------- /data/icons/com.github.hezral-select.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 21 | 25 | 29 | 33 | 34 | 36 | 40 | 44 | 45 | 54 | 63 | 64 | 66 | 67 | 69 | image/svg+xml 70 | 72 | 73 | 74 | 75 | 76 | 80 | 84 | 88 | 92 | 96 | 97 | -------------------------------------------------------------------------------- /data/icons/com.github.hezral-settings-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 12 | 14 | 15 | 17 | image/svg+xml 18 | 20 | 21 | 22 | 23 | 24 | 26 | 30 | 31 | -------------------------------------------------------------------------------- /data/icons/com.github.hezral-shortcuts.svg: -------------------------------------------------------------------------------- 1 | 2 | 18 | 20 | 21 | 23 | image/svg+xml 24 | 26 | 27 | 28 | 29 | 31 | 38 | 41 | 46 | 47 | 54 | 57 | 62 | 63 | 70 | 74 | 78 | 83 | 84 | 92 | 96 | 97 | 98 | 118 | 121 | 122 | 127 | 133 | 139 | 145 | 146 | 156 | 162 | 163 | -------------------------------------------------------------------------------- /data/icons/edit-clear-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 12 | 14 | 15 | 17 | image/svg+xml 18 | 20 | 21 | 22 | 23 | 25 | 29 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /data/icons/system-search.svg: -------------------------------------------------------------------------------- 1 | 2 | 12 | 14 | 15 | 17 | image/svg+xml 18 | 20 | 21 | 22 | 23 | 25 | 29 | 33 | 34 | -------------------------------------------------------------------------------- /data/meson.build: -------------------------------------------------------------------------------- 1 | pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) 2 | 3 | desktop_file = i18n.merge_file( 4 | input: 'com.github.hezral.stashed.desktop.in', 5 | output: 'com.github.hezral.stashed.desktop', 6 | type: 'desktop', 7 | po_dir: '../po', 8 | install: true, 9 | install_dir: join_paths(get_option('datadir'), 'applications') 10 | ) 11 | 12 | desktop_utils = find_program('desktop-file-validate', required: false) 13 | if desktop_utils.found() 14 | test('Validate desktop file', desktop_utils, 15 | args: [desktop_file] 16 | ) 17 | endif 18 | 19 | appstream_file = i18n.merge_file( 20 | input: 'com.github.hezral.stashed.appdata.xml.in', 21 | output: 'com.github.hezral.stashed.appdata.xml', 22 | po_dir: '../po', 23 | install: true, 24 | install_dir: join_paths(get_option('datadir'), 'metainfo') 25 | ) 26 | 27 | appstream_util = find_program('appstream-util', required: false) 28 | if appstream_util.found() 29 | test('Validate appstream file', appstream_util, 30 | args: ['validate', appstream_file] 31 | ) 32 | endif 33 | 34 | install_data('com.github.hezral.stashed.gschema.xml', 35 | install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas') 36 | ) 37 | 38 | compile_schemas = find_program('glib-compile-schemas', required: false) 39 | if compile_schemas.found() 40 | test('Validate schema file', compile_schemas, 41 | args: ['--strict', '--dry-run', meson.current_source_dir()] 42 | ) 43 | endif 44 | 45 | install_data('application.css', 46 | install_dir: join_paths(pkgdatadir, 'stashed', 'data') 47 | ) 48 | 49 | other_icon_sources = [ 50 | join_paths('icons', project_domain + '-' + 'coffee' + '.svg'), 51 | join_paths('icons', project_domain + '-' + 'settings-symbolic' + '.svg'), 52 | join_paths('icons', project_domain + '-' + 'select' + '.svg'), 53 | join_paths('icons', project_domain + '-' + 'shortcuts' + '.svg'), 54 | join_paths('icons', 'system-search' + '.svg'), 55 | ] 56 | iconsdir = join_paths(pkgdatadir, 'stashed', 'data', 'icons') 57 | install_data(other_icon_sources, install_dir: iconsdir) 58 | 59 | icon_sizes = ['16', '24', '32', '48', '64', '128'] 60 | foreach i : icon_sizes 61 | install_data( 62 | join_paths('icons', i + '.svg'), 63 | rename: meson.project_name() + '.svg', 64 | install_dir: join_paths(get_option ('datadir'), 'icons', 'hicolor', i + 'x' + i, 'apps') 65 | ) 66 | install_data( 67 | join_paths('icons', i + '.svg'), 68 | rename: meson.project_name() + '.svg', 69 | install_dir: join_paths(get_option ('datadir'), 'icons', 'hicolor', i + 'x' + i + '@2', 'apps') 70 | ) 71 | endforeach -------------------------------------------------------------------------------- /data/screenshot-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hezral/stashed/a29fc6de1a864eea62aa8eee57672f37976198fc/data/screenshot-01.png -------------------------------------------------------------------------------- /data/screenshot-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hezral/stashed/a29fc6de1a864eea62aa8eee57672f37976198fc/data/screenshot-02.png -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project('com.github.hezral.stashed', 2 | version: '1.0.2', 3 | meson_version: '>= 0.50.0', 4 | default_options: [ 'warning_level=2', 5 | ], 6 | ) 7 | 8 | i18n = import('i18n') 9 | 10 | rdnn = meson.project_name().split('.') 11 | project_domain = '.'.join([rdnn[0],rdnn[1],rdnn[2]]) 12 | project_short_name = rdnn[3] 13 | 14 | subdir('data') 15 | subdir('src') 16 | subdir('po') 17 | 18 | meson.add_install_script('build-aux/meson/postinstall.py') -------------------------------------------------------------------------------- /po/LINGUAS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hezral/stashed/a29fc6de1a864eea62aa8eee57672f37976198fc/po/LINGUAS -------------------------------------------------------------------------------- /po/POTFILES: -------------------------------------------------------------------------------- 1 | data/com.github.hezral.stashed.desktop.in 2 | data/com.github.hezral.stashed.appdata.xml.in 3 | data/com.github.hezral.stashed.gschema.xml 4 | src/window.ui 5 | src/main.py 6 | src/window.py 7 | 8 | -------------------------------------------------------------------------------- /po/meson.build: -------------------------------------------------------------------------------- 1 | i18n.gettext('stashed', preset: 'glib') 2 | -------------------------------------------------------------------------------- /src/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hezral/stashed/a29fc6de1a864eea62aa8eee57672f37976198fc/src/__init__.py -------------------------------------------------------------------------------- /src/custom_widgets.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | ''' 4 | Copyright 2018 Adi Hezral (hezral@gmail.com) 5 | This file is part of Clips ("Application"). 6 | The Application is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | The Application 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 13 | GNU General Public License for more details. 14 | You should have received a copy of the GNU General Public License 15 | along with this Application. If not, see . 16 | ''' 17 | 18 | from Xlib.protocol import event 19 | import gi 20 | gi.require_version('Gtk', '3.0') 21 | gi.require_version('Granite', '1.0') 22 | from gi.repository import Gtk, Granite, Gdk, Pango, Gio, GObject, GLib 23 | 24 | 25 | class CustomDialog(Gtk.Window): 26 | def __init__(self, dialog_parent_widget, dialog_title, dialog_content_widget, action_button_label, action_button_name, action_callback, action_type, size=None, data=None, *args, **kwargs): 27 | super().__init__(*args, **kwargs) 28 | 29 | parent_window = dialog_parent_widget.get_toplevel() 30 | 31 | def close_dialog(button): 32 | dialog_content_widget.destroy() 33 | self.destroy() 34 | 35 | def on_key_press(self, eventkey): 36 | if eventkey.keyval == 65307: #63307 is esc key 37 | dialog_content_widget.destroy() 38 | self.destroy() 39 | 40 | self.header = Gtk.HeaderBar() 41 | self.header.props.show_close_button = False 42 | self.header.props.title = dialog_title 43 | self.header.get_style_context().add_class("default-decoration") 44 | self.header.get_style_context().add_class(Gtk.STYLE_CLASS_FLAT) 45 | 46 | grid = Gtk.Grid() 47 | grid.props.expand = True 48 | grid.props.margin_top = 0 49 | grid.props.margin_bottom = grid.props.margin_left = grid.props.margin_right = 15 50 | grid.props.row_spacing = 10 51 | grid.props.column_spacing = 10 52 | grid.attach(dialog_content_widget, 0, 0, 2, 1) 53 | 54 | if action_type is not None: 55 | dialog_parent_widget.ok_button = Gtk.Button(label=action_button_label) 56 | dialog_parent_widget.ok_button.props.name = action_button_name 57 | dialog_parent_widget.ok_button.props.expand = False 58 | dialog_parent_widget.ok_button.props.halign = Gtk.Align.END 59 | dialog_parent_widget.ok_button.set_size_request(65,25) 60 | if action_type == "destructive": 61 | dialog_parent_widget.ok_button.get_style_context().add_class("destructive-action") 62 | else: 63 | dialog_parent_widget.ok_button.get_style_context().add_class(Gtk.STYLE_CLASS_SUGGESTED_ACTION) 64 | 65 | dialog_parent_widget.cancel_button = Gtk.Button(label="Cancel") 66 | dialog_parent_widget.cancel_button.props.hexpand = True 67 | dialog_parent_widget.cancel_button.props.halign = Gtk.Align.END 68 | dialog_parent_widget.cancel_button.set_size_request(65,25) 69 | 70 | dialog_parent_widget.ok_button.connect("clicked", action_callback, (data, dialog_parent_widget.cancel_button)) 71 | dialog_parent_widget.cancel_button.connect("clicked", close_dialog) 72 | 73 | grid.attach(dialog_parent_widget.cancel_button, 0, 1, 1, 1) 74 | grid.attach(dialog_parent_widget.ok_button, 1, 1, 1, 1) 75 | 76 | if size is not None: 77 | self.set_size_request(size[0],size[1]) 78 | else: 79 | self.set_size_request(150,100) 80 | 81 | self.get_style_context().add_class("rounded") 82 | self.set_titlebar(self.header) 83 | self.props.transient_for = parent_window 84 | self.props.modal = True 85 | self.props.resizable = False 86 | self.props.window_position = Gtk.WindowPosition.CENTER_ON_PARENT 87 | self.add(grid) 88 | self.show_all() 89 | self.connect("destroy", close_dialog) 90 | self.connect("key-press-event", on_key_press) 91 | 92 | 93 | class SettingsGroup(Gtk.Grid): 94 | 95 | CSS = ''' 96 | frame#settings-group-frame { 97 | border-radius: 4px; 98 | border-color: rgba(0, 0, 0, 0.3); 99 | background-color: @shaded_dark; 100 | } 101 | 102 | .settings-sub-label { 103 | font-size: 0.9em; 104 | color: gray; 105 | } 106 | ''' 107 | 108 | css_provider = Gtk.CssProvider() 109 | css_provider.load_from_data(CSS.encode()) 110 | Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) 111 | 112 | def __init__(self, group_label=None, subsettings_list=None, *args, **kwargs): 113 | super().__init__(*args, **kwargs) 114 | 115 | grid = Gtk.Grid() 116 | grid.props.margin = 8 117 | grid.props.hexpand = True 118 | grid.props.row_spacing = 8 119 | grid.props.column_spacing = 10 120 | 121 | i = 0 122 | for subsetting in subsettings_list: 123 | grid.attach(subsetting, 0, i, 1, 1) 124 | i += 1 125 | 126 | frame = Gtk.Frame() 127 | frame.props.name = "settings-group-frame" 128 | frame.props.hexpand = True 129 | frame.add(grid) 130 | self.attach(frame, 0, 1, 1, 1) 131 | 132 | if group_label is not None: 133 | label = Gtk.Label(group_label) 134 | label.props.name = "settings-group-label" 135 | label.props.halign = Gtk.Align.START 136 | label.props.margin_left = 4 137 | self.attach(label, 0, 0, 1, 1) 138 | 139 | self.props.name = "settings-group" 140 | self.props.halign = Gtk.Align.FILL 141 | self.props.hexpand = True 142 | self.props.row_spacing = 4 143 | self.props.can_focus = False 144 | 145 | 146 | class SubSettings(Gtk.Grid): 147 | def __init__(self, type=None, name=None, label=None, sublabel=None, separator=True, params=None, utils=None, *args, **kwargs): 148 | super().__init__(*args, **kwargs) 149 | 150 | self.type = type 151 | 152 | # box--- 153 | box = Gtk.VBox() 154 | box.props.spacing = 2 155 | box.props.hexpand = True 156 | 157 | # label--- 158 | if label is not None: 159 | self.label_text = Gtk.Label(label) 160 | self.label_text.props.halign = Gtk.Align.START 161 | box.add(self.label_text) 162 | 163 | # sublabel--- 164 | if sublabel is not None: 165 | self.sublabel_text = Gtk.Label(sublabel) 166 | self.sublabel_text.props.halign = Gtk.Align.START 167 | self.sublabel_text.props.wrap_mode = Pango.WrapMode.WORD 168 | self.sublabel_text.props.max_width_chars = 30 169 | self.sublabel_text.props.justify = Gtk.Justification.LEFT 170 | #self.sublabel_text.props.wrap = True 171 | self.sublabel_text.get_style_context().add_class("settings-sub-label") 172 | box.add(self.sublabel_text) 173 | 174 | if type == "switch": 175 | self.switch = Gtk.Switch() 176 | self.switch.props.name = name 177 | self.switch.props.halign = Gtk.Align.END 178 | self.switch.props.valign = Gtk.Align.CENTER 179 | self.switch.props.hexpand = False 180 | self.attach(self.switch, 1, 0, 1, 2) 181 | 182 | if type == "spinbutton": 183 | self.spinbutton = Gtk.SpinButton().new_with_range(min=params[0], max=params[1], step=params[2]) 184 | self.spinbutton.props.name = name 185 | self.attach(self.spinbutton, 1, 0, 1, 2) 186 | 187 | if type == "button": 188 | if len(params) == 1: 189 | self.button = Gtk.Button(label=params[0]) 190 | else: 191 | self.button = Gtk.Button(label=params[0], image=params[1]) 192 | self.button.props.name = name 193 | self.button.props.hexpand = False 194 | self.button.props.always_show_image = True 195 | self.button.set_size_request(90, -1) 196 | if len(params) >1: 197 | label = [child for child in self.button.get_children()[0].get_child() if isinstance(child, Gtk.Label)][0] 198 | label.props.valign = Gtk.Align.CENTER 199 | self.attach(self.button, 1, 0, 1, 2) 200 | 201 | if type == "checkbutton": 202 | self.checkbutton = Gtk.CheckButton().new_with_label(params[0]) 203 | self.checkbutton.props.name = name 204 | self.attach(self.checkbutton, 0, 0, 1, 2) 205 | 206 | # separator --- 207 | if separator: 208 | row_separator = Gtk.Separator() 209 | row_separator.props.hexpand = True 210 | row_separator.props.valign = Gtk.Align.CENTER 211 | if type == None: 212 | self.attach(row_separator, 0, 0, 1, 1) 213 | else: 214 | self.attach(row_separator, 0, 2, 2, 1) 215 | 216 | # SubSettings construct--- 217 | self.props.name = name 218 | self.props.hexpand = True 219 | if type == None: 220 | self.attach(box, 0, 0, 1, 1) 221 | else: 222 | self.props.row_spacing = 8 223 | self.props.column_spacing = 10 224 | self.attach(box, 0, 0, 1, 2) 225 | 226 | 227 | class Settings(Gtk.Grid): 228 | def __init__(self, gtk_application, *args, **kwargs): 229 | super().__init__(*args, **kwargs) 230 | 231 | self.app = gtk_application 232 | 233 | self.set_orientation(Gtk.Orientation.VERTICAL) 234 | self.props.row_spacing = 10 235 | 236 | # display ------------------------------------------------- 237 | theme_switch = SubSettings(type="switch", name="theme-switch", label="Switch between Dark/Light theme", sublabel=None, separator=False) 238 | theme_optin = SubSettings(type="checkbutton", name="theme-optin", label=None, sublabel=None, separator=True, params=("Follow system appearance style",)) 239 | 240 | theme_switch.switch.bind_property("active", self.app.gtk_settings, "gtk-application-prefer-dark-theme", GObject.BindingFlags.SYNC_CREATE) 241 | 242 | self.app.granite_settings.connect("notify::prefers-color-scheme", self.on_appearance_style_change, theme_switch) 243 | theme_switch.switch.connect_after("notify::active", self.on_switch_activated) 244 | theme_optin.checkbutton.connect_after("notify::active", self.on_checkbutton_activated, theme_switch) 245 | 246 | self.app.gio_settings.bind("prefer-dark-style", theme_switch.switch, "active", Gio.SettingsBindFlags.DEFAULT) 247 | self.app.gio_settings.bind("theme-optin", theme_optin.checkbutton, "active", Gio.SettingsBindFlags.DEFAULT) 248 | 249 | # persistent_mode = SubSettings(type="switch", name="persistent-mode", label="Persistent mode", sublabel="Stays open and updates as new clips added",separator=True) 250 | # persistent_mode.switch.connect_after("notify::active", self.on_switch_activated) 251 | # self.app.gio_settings.bind("persistent-mode", persistent_mode.switch, "active", Gio.SettingsBindFlags.DEFAULT) 252 | 253 | sticky_mode = SubSettings(type="switch", name="sticky-mode", label="Sticky mode", sublabel="Display on all workspaces",separator=False) 254 | sticky_mode.switch.connect_after("notify::active", self.on_switch_activated) 255 | self.app.gio_settings.bind("sticky-mode", sticky_mode.switch, "active", Gio.SettingsBindFlags.DEFAULT) 256 | 257 | always_on_top = SubSettings(type="switch", name="always-on-top", label="Always on top", sublabel="Display above all windows",separator=True) 258 | always_on_top.switch.connect_after("notify::active", self.on_switch_activated) 259 | self.app.gio_settings.bind("always-on-top", always_on_top.switch, "active", Gio.SettingsBindFlags.DEFAULT) 260 | 261 | display_behaviour_settings = SettingsGroup("Display", (theme_switch, theme_optin, always_on_top, sticky_mode, )) 262 | self.add(display_behaviour_settings) 263 | 264 | # Behaviour ------------------------------------------------- 265 | shake_reveal = SubSettings(type="switch", name="shake-reveal", label="Shake to reveal", sublabel="Shake mouse to reveal app",separator=True) 266 | shake_reveal.switch.connect_after("notify::active", self.on_switch_activated) 267 | self.app.gio_settings.bind("shake-reveal", shake_reveal.switch, "active", Gio.SettingsBindFlags.DEFAULT) 268 | 269 | shake_sensitivity = SubSettings(type="spinbutton", name="shake-sensitivity", label="Shake sensitivity", sublabel="Adjust shake to reveal sensitivity", separator=False, params=(3,10,1)) 270 | shake_sensitivity.spinbutton.connect("value-changed", self.on_spinbutton_activated) 271 | self.app.gio_settings.bind("shake-sensitivity", shake_sensitivity.spinbutton, "value", Gio.SettingsBindFlags.DEFAULT) 272 | 273 | app_settings = SettingsGroup("Behaviour (restart required)", (shake_reveal, shake_sensitivity, )) 274 | self.add(app_settings) 275 | 276 | 277 | def on_checkbutton_activated(self, checkbutton, gparam, widget): 278 | name = checkbutton.get_name() 279 | theme_switch = widget 280 | if name == "theme-optin": 281 | if self.app.gio_settings.get_value("theme-optin"): 282 | prefers_color_scheme = self.app.granite_settings.get_prefers_color_scheme() 283 | sensitive = False 284 | else: 285 | prefers_color_scheme = Granite.SettingsColorScheme.NO_PREFERENCE 286 | theme_switch.switch.props.active = self.app.gio_settings.get_value("prefer-dark-style") 287 | sensitive = True 288 | 289 | self.app.gtk_settings.set_property("gtk-application-prefer-dark-theme", prefers_color_scheme) 290 | self.app.granite_settings.connect("notify::prefers-color-scheme", self.app.on_prefers_color_scheme) 291 | 292 | if "DARK" in prefers_color_scheme.value_name: 293 | active = True 294 | else: 295 | active = False 296 | 297 | theme_switch.switch.props.active = active 298 | theme_switch.props.sensitive = sensitive 299 | 300 | def on_appearance_style_change(self, granite_settings, gparam, widget): 301 | theme_switch = widget 302 | if theme_switch.switch.props.active: 303 | theme_switch.switch.props.active = False 304 | else: 305 | theme_switch.switch.props.active = True 306 | 307 | def on_spinbutton_activated(self, spinbutton): 308 | name = spinbutton.get_name() 309 | main_window = self.app.main_window 310 | 311 | # if self.is_visible(): 312 | # if name == "shake-sensitivity": 313 | # GLib.idle_add(main_window.setup_mouse_listener, None) 314 | 315 | def on_switch_activated(self, switch, gparam): 316 | name = switch.get_name() 317 | main_window = self.app.main_window 318 | 319 | if self.is_visible(): 320 | 321 | if name == "persistent-mode": 322 | if switch.get_active(): 323 | # print('state-flags-on') 324 | main_window.disconnect_by_func(main_window.on_persistent_mode) 325 | else: 326 | main_window.connect("state-flags-changed", main_window.on_persistent_mode) 327 | # print('state-flags-off') 328 | 329 | if name == "sticky-mode": 330 | if switch.get_active(): 331 | main_window.stick() 332 | else: 333 | main_window.unstick() 334 | 335 | if name == "always-on-top": 336 | if switch.get_active(): 337 | main_window.set_keep_above(True) 338 | else: 339 | main_window.set_keep_above(False) 340 | 341 | # if name == "shake-reveal": 342 | # # main_window.setup_shake_listener() 343 | # if switch.get_active(): 344 | # print("enable-shake") 345 | # main_window.setup_shake_listener() 346 | # print(main_window.shake_listener.listener) 347 | # print(main_window.shake_listener.running) 348 | # else: 349 | # print("disable-shake") 350 | # main_window.shake_listener.remove_listener() 351 | # print(main_window.shake_listener.listener) 352 | # print(main_window.shake_listener.running) -------------------------------------------------------------------------------- /src/main.py: -------------------------------------------------------------------------------- 1 | # main.py 2 | # 3 | # Copyright 2021 Adi Hezral 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (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 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | import sys 19 | import os 20 | import gi 21 | 22 | gi.require_version('Gtk', '3.0') 23 | gi.require_version('Granite', '1.0') 24 | from gi.repository import Gtk, Gdk, Gio, Granite, GLib 25 | 26 | from .window import StashedWindow 27 | from .utils import HelperUtils 28 | from .shake_listener import ShakeListener 29 | 30 | class Application(Gtk.Application): 31 | 32 | app_id = "com.github.hezral.stashed" 33 | granite_settings = Granite.Settings.get_default() 34 | gtk_settings = Gtk.Settings.get_default() 35 | gio_settings = Gio.Settings(schema_id=app_id) 36 | utils = HelperUtils() 37 | running = False 38 | shake_listener = None 39 | 40 | def __init__(self): 41 | super().__init__(application_id=self.app_id, 42 | flags=Gio.ApplicationFlags.FLAGS_NONE) 43 | 44 | self.main_window = None 45 | 46 | self.create_app_actions() 47 | 48 | if self.gio_settings.get_value("theme-optin"): 49 | prefers_color_scheme = self.granite_settings.get_prefers_color_scheme() 50 | self.gtk_settings.set_property("gtk-application-prefer-dark-theme", prefers_color_scheme) 51 | self.granite_settings.connect("notify::prefers-color-scheme", self.on_prefers_color_scheme) 52 | 53 | provider = Gtk.CssProvider() 54 | provider.load_from_path(os.path.join(os.path.dirname(__file__), "data", "application.css")) 55 | Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) 56 | 57 | self.icon_theme = Gtk.IconTheme.get_default() 58 | self.icon_theme.prepend_search_path("/run/host/usr/share/pixmaps") 59 | self.icon_theme.prepend_search_path("/run/host/usr/share/icons") 60 | self.icon_theme.prepend_search_path(os.path.join(GLib.get_home_dir(), ".local/share/flatpak/exports/share/icons")) 61 | self.icon_theme.prepend_search_path(os.path.join(os.path.dirname(__file__), "data", "icons")) 62 | 63 | self.setup_shake_listener() 64 | 65 | def do_activate(self): 66 | self.main_window = self.props.active_window 67 | 68 | if not self.main_window: 69 | self.main_window = StashedWindow(application=self) 70 | 71 | self.on_show_window() 72 | 73 | self.running = True 74 | 75 | def on_prefers_color_scheme(self, *args): 76 | prefers_color_scheme = self.granite_settings.get_prefers_color_scheme() 77 | self.gtk_settings.set_property("gtk-application-prefer-dark-theme", prefers_color_scheme) 78 | 79 | def create_action(self, name, callback, shortcutkey): 80 | action = Gio.SimpleAction.new(name, None) 81 | action.connect("activate", callback) 82 | self.add_action(action) 83 | self.set_accels_for_action("app.{name}".format(name=name), [shortcutkey]) 84 | 85 | def on_hide_action(self, action, param): 86 | if self.get_windows() is not None: 87 | for window in self.get_windows(): 88 | window.hide 89 | 90 | def on_quit_action(self, action, param): 91 | if self.main_window is not None: 92 | self.main_window.destroy() 93 | 94 | def on_show_window(self): 95 | for window in self.get_windows(): 96 | window.setup_display_settings() 97 | window.show() 98 | window.present() 99 | window.stash_stacked.grab_focus() 100 | 101 | 102 | def create_app_actions(self): 103 | self.create_action("hide", self.on_hide_action, "Escape") 104 | self.create_action("quit", self.on_quit_action, "Q") 105 | 106 | def setup_shake_listener(self, *args): 107 | if self.shake_listener is not None: 108 | self.shake_listener.listener.stop() 109 | self.shake_listener = None 110 | if self.gio_settings.get_value("shake-reveal"): 111 | self.shake_listener = ShakeListener(app=self, reveal_callback=self.do_activate, sensitivity=self.gio_settings.get_int("shake-sensitivity")) 112 | 113 | def main(version): 114 | app = Application() 115 | return app.run(sys.argv) 116 | -------------------------------------------------------------------------------- /src/meson.build: -------------------------------------------------------------------------------- 1 | pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) 2 | moduledir = join_paths(pkgdatadir, 'stashed') 3 | 4 | python = import('python') 5 | 6 | conf = configuration_data() 7 | conf.set('PYTHON', python.find_installation('python3').path()) 8 | conf.set('VERSION', meson.project_version()) 9 | conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir'))) 10 | conf.set('pkgdatadir', pkgdatadir) 11 | 12 | configure_file( 13 | input: '.'.join([project_short_name,'in']), 14 | output: meson.project_name(), 15 | configuration: conf, 16 | install: true, 17 | install_dir: get_option('bindir') 18 | ) 19 | 20 | stashed_sources = [ 21 | '__init__.py', 22 | 'main.py', 23 | 'window.py', 24 | 'custom_widgets.py', 25 | 'shake_listener.py', 26 | 'utils.py', 27 | ] 28 | 29 | install_data(stashed_sources, install_dir: moduledir) 30 | -------------------------------------------------------------------------------- /src/shake_listener.py: -------------------------------------------------------------------------------- 1 | 2 | import gi 3 | gi.require_version('Gtk', '3.0') 4 | from gi.repository import Gtk, Gdk, GLib 5 | 6 | import time 7 | from datetime import datetime 8 | 9 | from pynput import mouse 10 | 11 | SHAKE_DIST = 100 12 | MIN_SHAKE_DIST = 50 13 | MAX_SHAKE_DIST = 250 14 | SHAKE_SLICE_TIMEOUT = 75 # ms 15 | SHAKE_TIMEOUT = 500 # ms 16 | EVENT_TIMEOUT = 100 # ms 17 | SHOWING_TIMEOUT = 2500 #ms 18 | NEEDED_SHAKE_COUNT = 5 19 | 20 | class ShakeListener(): 21 | def __init__(self, app, reveal_callback, sensitivity=5, *args, **kwargs): 22 | 23 | self.app = app 24 | self.reveal_callback = reveal_callback 25 | self.init_variables() 26 | self.init_listener() 27 | self.needed_shake_count = sensitivity 28 | 29 | def init_variables(self, *args): 30 | self.showing_timestamp = datetime.now() 31 | self.shake_slice_timestamp = datetime.now() 32 | self.shake_timeout_timestamp = datetime.now() 33 | self.showing_timestamp_diff = 0 34 | self.shake_slice_timestamp_diff = 0 35 | self.shake_timeout_timestamp_diff = 0 36 | 37 | self.now_x = 0 38 | self.old_x = 0 39 | self.min_x = 0 40 | self.max_x = 0 41 | self.has_min = 0 42 | self.has_max = 0 43 | 44 | self.shake_count = 0 45 | 46 | self.showing = False 47 | self.isShaking = False 48 | 49 | def init_listener(self, *args): 50 | self.listener = mouse.Listener( 51 | on_move=self.detect_mouse_movement, 52 | on_click=None, 53 | on_scroll=None) 54 | self.listener.start() 55 | self.running = True 56 | print(datetime.now(), "shake_listener started") 57 | 58 | def remove_listener(self, *args): 59 | self.listener.stop() 60 | self.listener = mouse.Listener( 61 | on_move=None, 62 | on_click=None, 63 | on_scroll=None) 64 | self.listener.stop() 65 | self.running = False 66 | 67 | def on_mouse_click(self, x, y, button, pressed): 68 | if pressed: 69 | try: 70 | if button.name == "left": 71 | self.mouse_pressed = True 72 | except AttributeError: 73 | pass 74 | else: 75 | self.mouse_pressed = False 76 | 77 | def detect_mouse_movement(self, x, y): 78 | if self.app.main_window is not None: 79 | if not self.app.main_window.is_visible(): 80 | # state = "is_shaking:{0}, shake_count:{1}, showing:{2}".format(self.isShaking, self.shake_count, self.showing) 81 | # details1 = "now_x:{0}, old_x:{1}".format(self.now_x, self.old_x) 82 | # details2 = "min_x:{0}, max_x:{1}".format(self.min_x, self.max_x) 83 | # details3 = "has_min:{0}, has_max:{1}".format(self.has_min, self.has_max) 84 | # details4 = "showing_timestamp:{0}".format(self.showing_timestamp) 85 | # details5 = "shake_timeout_timestamp:{0}".format(self.shake_timeout_timestamp) 86 | # details6 = "shake_timeout_timestamp_diff:{0}".format(self.shake_timeout_timestamp_diff) 87 | # details7 = "shake_slice_timestamp:{0}".format(self.shake_slice_timestamp) 88 | # details8 = "shake_slice_timestamp_diff:{0}".format(self.shake_slice_timestamp_diff) 89 | # details9 = "self.shake_timeout_timestamp_diff >= SHAKE_TIMEOUT:{0}".format(self.shake_timeout_timestamp_diff >= SHAKE_TIMEOUT) 90 | # details10 = "self.shake_slice_timestamp_diff >= SHAKE_SLICE_TIMEOUT:{0}".format(self.shake_slice_timestamp_diff >= SHAKE_SLICE_TIMEOUT) 91 | # details11 = "self.max_x-self.min_x > SHAKE_DIST:{0}".format(self.max_x-self.min_x > SHAKE_DIST) 92 | # update = "{0}\n{1}\n{2}\n{3}\n{4}\n{5}\n{6}\n{7}\n{8}\n{9}\n{10}\n{11}\n".format(state, details1, details2, details3, details4, details5, details6, details7, details8, details9, details10, details11) 93 | # update = state 94 | # print(update) 95 | # print(x,y) 96 | 97 | self.now_x = x 98 | if self.now_x < self.old_x: 99 | if self.has_min == 0: 100 | self.has_min = 1 101 | self.min_x = self.now_x 102 | else: 103 | self.min_x = min(self.min_x, self.now_x) 104 | 105 | elif self.now_x > self.old_x: 106 | if self.has_max == 0: 107 | self.has_max = 1 108 | self.max_x = self.now_x 109 | else: 110 | self.max_x = max(self.max_x, self.now_x) 111 | 112 | self.old_x = self.now_x 113 | 114 | self.is_shaking() 115 | 116 | def is_shaking(self): 117 | self.isShaking = False 118 | 119 | self.shake_timeout_timestamp_diff = int((datetime.now()-self.shake_timeout_timestamp).total_seconds()*1000) 120 | if self.shake_timeout_timestamp_diff >= SHAKE_TIMEOUT: 121 | self.init_variables() 122 | 123 | self.shake_slice_timestamp_diff = int((datetime.now()-self.shake_slice_timestamp).total_seconds()*1000) 124 | if self.shake_slice_timestamp_diff >= SHAKE_SLICE_TIMEOUT: 125 | self.shake_slice_timestamp = datetime.now() 126 | 127 | if self.has_min == 1: 128 | if self.has_max == 1: 129 | if self.max_x-self.min_x > MIN_SHAKE_DIST and self.max_x-self.min_x < MAX_SHAKE_DIST: 130 | self.shake_count += 1 131 | self.shake_timeout_timestamp = datetime.now() 132 | self.has_min = 0 133 | self.has_max = 0 134 | 135 | if self.shake_count >= self.needed_shake_count: 136 | self.isShaking = True 137 | GLib.idle_add(self.reveal_app, None) 138 | self.init_variables() 139 | 140 | def reveal_app(self, *args): 141 | self.showing = True 142 | self.reveal_callback() 143 | # self.listener.stop() 144 | 145 | -------------------------------------------------------------------------------- /src/stashed.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ 2 | 3 | # stashed.in 4 | # 5 | # Copyright 2021 Adi Hezral 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | 20 | import os 21 | import sys 22 | import signal 23 | import gettext 24 | 25 | VERSION = '@VERSION@' 26 | pkgdatadir = '@pkgdatadir@' 27 | localedir = '@localedir@' 28 | 29 | sys.path.insert(1, pkgdatadir) 30 | signal.signal(signal.SIGINT, signal.SIG_DFL) 31 | gettext.install('stashed', localedir) 32 | 33 | if __name__ == '__main__': 34 | import gi 35 | 36 | from stashed import main 37 | print("Stashed", VERSION) 38 | sys.exit(main.main(VERSION)) 39 | -------------------------------------------------------------------------------- /src/utils.py: -------------------------------------------------------------------------------- 1 | # utils.py 2 | # 3 | # Copyright 2021 adi 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (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 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | class HelperUtils: 19 | @staticmethod 20 | def run_async(func): 21 | ''' 22 | https://github.com/learningequality/ka-lite-gtk/blob/341813092ec7a6665cfbfb890aa293602fb0e92f/kalite_gtk/mainwindow.py 23 | http://code.activestate.com/recipes/576683-simple-threading-decorator/ 24 | run_async(func): 25 | function decorator, intended to make "func" run in a separate thread (asynchronously). 26 | Returns the created Thread object 27 | Example: 28 | @run_async 29 | def task1(): 30 | do_something 31 | @run_async 32 | def task2(): 33 | do_something_too 34 | ''' 35 | from threading import Thread 36 | from functools import wraps 37 | 38 | @wraps(func) 39 | def async_func(*args, **kwargs): 40 | func_hl = Thread(target=func, args=args, kwargs=kwargs) 41 | func_hl.start() 42 | # Never return anything, idle_add will think it should re-run the 43 | # function because it's a non-False value. 44 | return None 45 | 46 | return async_func 47 | 48 | @staticmethod 49 | def get_window_by_gtk_application_id_xlib(gtk_application_id): 50 | ''' Function to get window using the gtk_application_id from NET_WM ''' 51 | import Xlib 52 | import Xlib.display 53 | 54 | display = Xlib.display.Display() 55 | root = display.screen().root 56 | 57 | NET_CLIENT_LIST = display.intern_atom('_NET_CLIENT_LIST') 58 | GTK_APPLICATION_ID = display.intern_atom('_GTK_APPLICATION_ID') 59 | 60 | root.change_attributes(event_mask=Xlib.X.FocusChangeMask) 61 | try: 62 | window_id = root.get_full_property(NET_CLIENT_LIST, Xlib.X.AnyPropertyType).value 63 | for id in window_id: 64 | window = display.create_resource_object('window', id) 65 | window.change_attributes(event_mask=Xlib.X.PropertyChangeMask) 66 | if window.get_full_property(GTK_APPLICATION_ID, 0): 67 | if window.get_full_property(GTK_APPLICATION_ID, 0).value.decode("utf-8") == gtk_application_id: 68 | break 69 | 70 | except Xlib.error.XError: #simplify dealing with BadWindow 71 | window = None 72 | 73 | return window 74 | 75 | @staticmethod 76 | def get_active_window_xlib(): 77 | ''' Function to get active window ''' 78 | import Xlib 79 | import Xlib.display 80 | 81 | display = Xlib.display.Display() 82 | root = display.screen().root 83 | 84 | NET_ACTIVE_WINDOW = display.intern_atom('_NET_ACTIVE_WINDOW') 85 | 86 | root.change_attributes(event_mask=Xlib.X.FocusChangeMask) 87 | try: 88 | window_id = root.get_full_property(NET_ACTIVE_WINDOW, Xlib.X.AnyPropertyType).value[0] 89 | window = display.create_resource_object('window', window_id) 90 | except Xlib.error.XError: #simplify dealing with BadWindow 91 | window = None 92 | 93 | return window 94 | 95 | @staticmethod 96 | def get_window_id_by_gtk_application_id_xlib(gtk_application_id): 97 | ''' Function to get window using the gtk_application_id from NET_WM ''' 98 | import Xlib 99 | import Xlib.display 100 | 101 | display = Xlib.display.Display() 102 | root = display.screen().root 103 | 104 | NET_CLIENT_LIST = display.intern_atom('_NET_CLIENT_LIST') 105 | GTK_APPLICATION_ID = display.intern_atom('_GTK_APPLICATION_ID') 106 | 107 | root.change_attributes(event_mask=Xlib.X.FocusChangeMask) 108 | try: 109 | window_ids = root.get_full_property(NET_CLIENT_LIST, Xlib.X.AnyPropertyType).value 110 | for window_id in window_ids: 111 | window = display.create_resource_object('window', window_id) 112 | window.change_attributes(event_mask=Xlib.X.PropertyChangeMask) 113 | if window.get_full_property(GTK_APPLICATION_ID, 0): 114 | if window.get_full_property(GTK_APPLICATION_ID, 0).value.decode("utf-8") == gtk_application_id: 115 | break 116 | 117 | except Xlib.error.XError: #simplify dealing with BadWindow 118 | window_id = None 119 | 120 | return window_id 121 | 122 | @staticmethod 123 | def get_active_window_id_xlib(): 124 | ''' Function to get active window ''' 125 | import Xlib 126 | import Xlib.display 127 | 128 | display = Xlib.display.Display() 129 | root = display.screen().root 130 | 131 | NET_ACTIVE_WINDOW = display.intern_atom('_NET_ACTIVE_WINDOW') 132 | 133 | root.change_attributes(event_mask=Xlib.X.FocusChangeMask) 134 | try: 135 | window_id = root.get_full_property(NET_ACTIVE_WINDOW, Xlib.X.AnyPropertyType).value[0] 136 | except Xlib.error.XError: #simplify dealing with BadWindow 137 | window_id = None 138 | 139 | return window_id 140 | 141 | @staticmethod 142 | def set_active_window_by_pointer(): 143 | ''' Function to set window as active based on where the mouse pointer is located ''' 144 | import Xlib 145 | from Xlib.display import Display 146 | from Xlib import X 147 | 148 | display = Display() 149 | root = display.screen().root 150 | window = root.query_pointer().child 151 | window.set_input_focus(X.RevertToParent, X.CurrentTime) 152 | window.configure(stack_mode=X.Above) 153 | display.sync() 154 | 155 | # get active window 156 | NET_ACTIVE_WINDOW = display.intern_atom('_NET_ACTIVE_WINDOW') 157 | try: 158 | window_id = root.get_full_property(NET_ACTIVE_WINDOW, Xlib.X.AnyPropertyType).value[0] 159 | except Xlib.error.XError: #simplify dealing with BadWindow 160 | window_id = None 161 | 162 | return window_id 163 | 164 | @staticmethod 165 | def set_active_window_by_xwindow(window): 166 | ''' Function to set window as active based on xid ''' 167 | import Xlib 168 | from Xlib.display import Display 169 | from Xlib import X 170 | 171 | display = Display() 172 | window.set_input_focus(X.RevertToParent, X.CurrentTime) 173 | window.configure(stack_mode=X.Above) 174 | display.sync() 175 | 176 | @staticmethod 177 | def get_active_window_application_id(): 178 | ''' Function to get active window ''' 179 | import Xlib 180 | import Xlib.display 181 | 182 | display = Xlib.display.Display() 183 | root = display.screen().root 184 | 185 | NET_ACTIVE_WINDOW = display.intern_atom('_NET_ACTIVE_WINDOW') 186 | GTK_APPLICATION_ID = display.intern_atom('_GTK_APPLICATION_ID') 187 | 188 | root.change_attributes(event_mask=Xlib.X.FocusChangeMask) 189 | try: 190 | window_id = root.get_full_property(NET_ACTIVE_WINDOW, Xlib.X.AnyPropertyType).value[0] 191 | window = display.create_resource_object('window', window_id) 192 | try: 193 | return window.get_full_property(GTK_APPLICATION_ID, 0).value.replace(b'\x00',b' ').decode("utf-8").lower() 194 | except: 195 | return None 196 | except Xlib.error.XError: #simplify dealing with BadWindow 197 | return None 198 | 199 | @staticmethod 200 | def get_active_window_wm_class(): 201 | ''' Function to get active window ''' 202 | import Xlib 203 | import Xlib.display 204 | 205 | display = Xlib.display.Display() 206 | root = display.screen().root 207 | 208 | NET_ACTIVE_WINDOW = display.intern_atom('_NET_ACTIVE_WINDOW') 209 | WM_CLASS = display.intern_atom('WM_CLASS') 210 | 211 | root.change_attributes(event_mask=Xlib.X.FocusChangeMask) 212 | try: 213 | window_id = root.get_full_property(NET_ACTIVE_WINDOW, Xlib.X.AnyPropertyType).value[0] 214 | window = display.create_resource_object('window', window_id) 215 | try: 216 | return window.get_full_property(WM_CLASS, 0).value.replace(b'\x00',b' ').decode("utf-8").lower() 217 | except: 218 | return None 219 | except Xlib.error.XError: #simplify dealing with BadWindow 220 | return None 221 | 222 | @staticmethod 223 | def copy_to_clipboard(clipboard_target, file, type=None): 224 | ''' Function to copy files to clipboard ''' 225 | from subprocess import Popen, PIPE 226 | 227 | try: 228 | if "url" in type: 229 | with open(file) as _file: 230 | data = Popen(['echo', _file.readlines()[0].rstrip("\n").rstrip("\n")], stdout=PIPE) 231 | Popen(['xclip', '-selection', 'clipboard', '-target', clipboard_target], stdin=data.stdout) 232 | else: 233 | Popen(['xclip', '-selection', 'clipboard', '-target', clipboard_target, '-i', file]) 234 | return True 235 | except: 236 | return False 237 | 238 | @staticmethod 239 | def copy_files_to_clipboard(uris): 240 | ''' Function to copy files to clipboard from a string of uris in file:// format ''' 241 | from subprocess import Popen, PIPE 242 | try: 243 | copyfiles = Popen(['xclip', '-selection', 'clipboard', '-target', 'x-special/gnome-copied-files'], stdin=PIPE) 244 | copyfiles.communicate(str.encode(uris)) 245 | return True 246 | except: 247 | return False 248 | 249 | @staticmethod 250 | def paste_from_clipboard(): 251 | ''' 252 | Function to paste from clipboard based on where the mouse pointer is hovering 253 | ''' 254 | # ported from Clipped: https://github.com/davidmhewitt/clipped/blob/edac68890c2a78357910f05bf44060c2aba5958e/src/ClipboardManager.vala 255 | import time 256 | 257 | def perform_key_event(accelerator, press, delay): 258 | import Xlib 259 | from Xlib import X 260 | from Xlib.display import Display 261 | from Xlib.ext.xtest import fake_input 262 | from Xlib.protocol.event import KeyPress, KeyRelease 263 | import time 264 | 265 | import gi 266 | gi.require_version('Gtk', '3.0') 267 | from gi.repository import Gtk, Gdk, GdkX11 268 | 269 | keysym, modifiers = Gtk.accelerator_parse(accelerator) 270 | display = Display() 271 | # root = display.screen().root 272 | # window = root.query_pointer().child 273 | # window.set_input_focus(X.RevertToParent, X.CurrentTime) 274 | # window.configure(stack_mode=X.Above) 275 | # display.sync() 276 | 277 | keycode = display.keysym_to_keycode(keysym) 278 | 279 | if press: 280 | event_type = X.KeyPress 281 | else: 282 | event_type = X.KeyRelease 283 | 284 | if keycode != 0: 285 | if 'GDK_CONTROL_MASK' in modifiers.value_names: 286 | modcode = display.keysym_to_keycode(Gdk.KEY_Control_L) 287 | fake_input(display, event_type, modcode, delay) 288 | 289 | if 'GDK_SHIFT_MASK' in modifiers.value_names: 290 | modcode = display.keysym_to_keycode(Gdk.KEY_Shift_L) 291 | fake_input(display, event_type, modcode, delay) 292 | 293 | fake_input(display, event_type, keycode, delay) 294 | display.sync() 295 | 296 | perform_key_event("v", True, 100) 297 | perform_key_event("v", False, 0) 298 | 299 | -------------------------------------------------------------------------------- /src/window.py: -------------------------------------------------------------------------------- 1 | # window.py 2 | # 3 | # Copyright 2021 Adi Hezral 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (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 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | import os 19 | import gi 20 | gi.require_version('Handy', '1') 21 | gi.require_version('Gtk', '3.0') 22 | gi.require_version('Granite', '1.0') 23 | from gi.repository import GObject, GLib, Gtk, Handy, Gdk, Gio, Granite, GdkPixbuf, Pango 24 | 25 | from .custom_widgets import CustomDialog, Settings 26 | from .utils import HelperUtils 27 | 28 | IMAGE_DND_TARGET = Gtk.TargetEntry.new('image/png', Gtk.TargetFlags.SAME_APP, 0) 29 | UTF8TEXT_DND_TARGET = Gtk.TargetEntry.new('text/plain;charset=utf-8', Gtk.TargetFlags.SAME_APP, 0) 30 | PLAINTEXT_DND_TARGET = Gtk.TargetEntry.new('text/plain', Gtk.TargetFlags.SAME_APP, 0) 31 | URI_DND_TARGET = Gtk.TargetEntry.new('text/uri-list', Gtk.TargetFlags.SAME_APP, 0) 32 | TARGETS = [URI_DND_TARGET, IMAGE_DND_TARGET, UTF8TEXT_DND_TARGET, PLAINTEXT_DND_TARGET] 33 | 34 | class StashedWindow(Handy.ApplicationWindow): 35 | __gtype_name__ = 'StashedWindow' 36 | 37 | GObject.signal_new("held", Gtk.Button, GObject.SIGNAL_RUN_LAST, GObject.TYPE_BOOLEAN, [GObject.TYPE_PYOBJECT]) 38 | 39 | iconstack_offset = 0 40 | search = [] 41 | search_result = 0 42 | close_timeout_id = None 43 | 44 | Handy.init() 45 | 46 | def __init__(self, **kwargs): 47 | super().__init__(**kwargs) 48 | 49 | self.app = self.props.application 50 | 51 | self.header = self.generate_headerbar() 52 | self.stash_stacked_grid = self.generate_stash_stacked() 53 | self.stash_flowbox_grid = self.generate_stash_flowbox() 54 | self.message_display_grid = self.generate_message_display() 55 | 56 | self.stack = Gtk.Stack() 57 | self.stack.props.transition_type = Gtk.StackTransitionType.CROSSFADE 58 | self.stack.props.transition_duration = 250 59 | self.stack.add_named(self.stash_stacked_grid, "stash-stacked") 60 | self.stack.add_named(self.stash_flowbox_grid, "stash-flowbox") 61 | self.stack.add_named(self.message_display_grid, "message-display") 62 | 63 | self.grid = Gtk.Grid() 64 | self.grid.props.name = "main" 65 | self.grid.props.expand = True 66 | self.grid.attach(self.header, 0, 0, 1, 1) 67 | self.grid.attach(self.stack, 0, 1, 1, 1) 68 | 69 | # window_handle = Handy.WindowHandle() 70 | # window_handle.props.above_child = False 71 | # window_handle.add(self.grid) 72 | # window_handle.connect("grab-notify", self.on_window_handle_grab) 73 | 74 | # self.add(window_handle) 75 | self.add(self.grid) 76 | 77 | self.props.resizable = False 78 | self.props.window_position = Gtk.WindowPosition.MOUSE 79 | self.show_all() 80 | self.set_size_request(400, 400) 81 | 82 | self.setup_display_settings() 83 | 84 | self.drag_and_drop_setup() 85 | self.drag_and_grab_setup(self.stash_stacked) 86 | self.drag_and_grab_setup(self.stash_flowbox) 87 | 88 | self.connect("key-press-event", self.on_stash_filtered) 89 | 90 | def generate_headerbar(self): 91 | close_button = Gtk.Button(image=Gtk.Image().new_from_icon_name("application-exit", Gtk.IconSize.SMALL_TOOLBAR)) 92 | close_button.props.name = "custom-close" 93 | close_button.props.always_show_image = True 94 | close_button.props.can_focus = False 95 | close_button.props.margin = 2 96 | close_button.set_size_request(16, 16) 97 | close_button.get_style_context().remove_class("image-button") 98 | close_button.get_style_context().add_class("titlebutton") 99 | close_button.connect("clicked", self.on_close_window) 100 | close_button.connect("button-press-event", self.on_close_pressed) 101 | close_button.connect("held", self.on_close_held) 102 | 103 | menu_button = Gtk.Button(image=Gtk.Image().new_from_icon_name("com.github.hezral-settings-symbolic", Gtk.IconSize.SMALL_TOOLBAR)) 104 | menu_button.props.name = "custom-menu" 105 | menu_button.props.always_show_image = True 106 | menu_button.props.can_focus = False 107 | menu_button.props.margin = 2 108 | menu_button.set_size_request(16, 16) 109 | menu_button.get_style_context().remove_class("image-button") 110 | menu_button.get_style_context().add_class("titlebutton") 111 | # menu_button.connect("clicked", self.on_menu_clicked) 112 | menu_button.connect("clicked", self.on_settings_clicked) 113 | 114 | search_button = Gtk.Button(image=Gtk.Image().new_from_icon_name("system-search-symbolic", Gtk.IconSize.SMALL_TOOLBAR)) 115 | search_button.props.name = "custom-search" 116 | search_button.props.always_show_image = True 117 | search_button.props.can_focus = False 118 | search_button.props.margin = 2 119 | search_button.props.margin_right = 0 120 | search_button.set_size_request(16, 16) 121 | search_button.get_style_context().remove_class("image-button") 122 | search_button.get_style_context().add_class("titlebutton") 123 | search_button.connect("clicked", self.on_search_clicked) 124 | 125 | self.search_revealer = Gtk.Revealer() 126 | self.search_revealer.props.transition_duration = 2000 127 | self.search_revealer.props.transition_type = Gtk.RevealerTransitionType.CROSSFADE 128 | self.search_revealer.add(search_button) 129 | 130 | header = Handy.HeaderBar() 131 | header.props.hexpand = True 132 | # header.props.title = "Stashed" 133 | # header.props.valign = Gtk.Align.START 134 | # header.props.halign = Gtk.Align.FILL 135 | header.props.spacing = 0 136 | header.props.has_subtitle = False 137 | header.props.show_close_button = False 138 | header.props.decoration_layout = ":" 139 | header.get_style_context().add_class(Granite.STYLE_CLASS_DEFAULT_DECORATION) 140 | header.get_style_context().add_class(Gtk.STYLE_CLASS_FLAT) 141 | header.pack_start(close_button) 142 | header.pack_end(menu_button) 143 | header.pack_end(self.search_revealer) 144 | 145 | return header 146 | 147 | def generate_message_display(self): 148 | self.message_display = Gtk.Label() 149 | self.message_display.props.name = "message-display" 150 | 151 | self.message_display_revealer = Gtk.Revealer() 152 | self.message_display_revealer.props.transition_duration = 250 153 | self.message_display_revealer.props.transition_type = Gtk.RevealerTransitionType.CROSSFADE 154 | self.message_display_revealer.add(self.message_display) 155 | 156 | message_diplay_grid = Gtk.Grid() 157 | message_diplay_grid.props.can_focus = True 158 | message_diplay_grid.props.row_spacing = 2 159 | message_diplay_grid.props.halign = message_diplay_grid.props.valign = Gtk.Align.CENTER 160 | message_diplay_grid.attach(self.message_display_revealer, 0, 0, 1, 1) 161 | 162 | return message_diplay_grid 163 | 164 | def generate_stash_stacked(self): 165 | self.stash_stacked = Gtk.Overlay() 166 | self.stash_stacked.props.name = "stack" 167 | self.stash_stacked.props.expand = True 168 | self.stash_stacked.props.valign = self.stash_stacked.props.halign = Gtk.Align.FILL 169 | 170 | stash_zone_plus = Gtk.Label("Drag files here") 171 | stash_zone_plus.props.expand = True 172 | stash_zone_plus.get_style_context().add_class("stash-zone-plus") 173 | 174 | stash_zone = Gtk.Grid() 175 | stash_zone.props.expand = True 176 | stash_zone.props.margin_bottom = 20 177 | stash_zone.props.margin_left = 20 178 | stash_zone.props.margin_right = 20 179 | stash_zone.props.halign = stash_zone.props.valign = Gtk.Align.FILL 180 | stash_zone.get_style_context().add_class("stash-zone") 181 | stash_zone.attach(stash_zone_plus, 0, 0, 1, 1) 182 | 183 | self.stash_zone_revealer = Gtk.Revealer() 184 | self.stash_zone_revealer.props.transition_duration = 250 185 | self.stash_zone_revealer.props.transition_type = Gtk.RevealerTransitionType.CROSSFADE 186 | self.stash_zone_revealer.add(stash_zone) 187 | 188 | clear_stash = Gtk.Button(label="Clear") 189 | clear_stash.props.hexpand = True 190 | clear_stash.props.margin = 10 191 | clear_stash.props.halign = Gtk.Align.CENTER 192 | clear_stash.connect("clicked", self.on_clear_stash) 193 | 194 | self.clear_stash_revealer = Gtk.Revealer() 195 | self.clear_stash_revealer.props.transition_duration = 2000 196 | self.clear_stash_revealer.props.transition_type = Gtk.RevealerTransitionType.CROSSFADE 197 | self.clear_stash_revealer.add(clear_stash) 198 | 199 | stash_stacked_grid = Gtk.Grid() 200 | stash_stacked_grid.props.can_focus = True 201 | stash_stacked_grid.props.row_spacing = 2 202 | stash_stacked_grid.attach(self.stash_stacked, 0, 0, 1, 1) 203 | stash_stacked_grid.attach(self.clear_stash_revealer, 0, 1, 1, 1) 204 | stash_stacked_grid.attach(self.stash_zone_revealer, 0, 0, 1, 2) 205 | stash_stacked_grid.connect("button-press-event", self.on_stash_grid_clicked) 206 | 207 | return stash_stacked_grid 208 | 209 | def generate_stash_flowbox(self): 210 | self.stash_flowbox = Gtk.FlowBox() 211 | self.stash_flowbox.props.expand = True 212 | self.stash_flowbox.props.homogeneous = True 213 | self.stash_flowbox.props.row_spacing = 20 214 | self.stash_flowbox.props.column_spacing = 20 215 | self.stash_flowbox.props.max_children_per_line = 10 216 | self.stash_flowbox.props.min_children_per_line = 2 217 | self.stash_flowbox.props.margin = 20 218 | self.stash_flowbox.props.valign = Gtk.Align.START 219 | self.stash_flowbox.props.halign = Gtk.Align.FILL 220 | self.stash_flowbox.props.selection_mode = Gtk.SelectionMode.MULTIPLE 221 | self.stash_flowbox.connect("child-activated", self.on_stash_items_flowboxchild_activated) 222 | self.stash_flowbox.connect("button-press-event", self.on_stash_grid_clicked) 223 | 224 | scrolled_window = Gtk.ScrolledWindow() 225 | scrolled_window.props.expand = True 226 | scrolled_window.add(self.stash_flowbox) 227 | 228 | self.search_keyword = Gtk.Label() 229 | self.search_keyword.props.name = "search-keyword" 230 | self.search_keyword.props.halign = Gtk.Align.FILL 231 | self.search_keyword.props.valign = Gtk.Align.START 232 | self.search_keyword_revealer = Gtk.Revealer() 233 | self.search_keyword_revealer.add(self.search_keyword) 234 | 235 | self.clear_keyword = Gtk.Button(image=Gtk.Image().new_from_icon_name("edit-clear-symbolic", Gtk.IconSize.SMALL_TOOLBAR)) 236 | self.clear_keyword.props.halign = Gtk.Align.END 237 | self.clear_keyword.connect("clicked", self.on_stash_unfiltered) 238 | self.clear_keyword_revealer = Gtk.Revealer() 239 | self.clear_keyword_revealer.add(self.clear_keyword) 240 | 241 | stash_flowbox_grid = Gtk.Grid() 242 | stash_flowbox_grid.attach(Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL), 0, 0, 1, 1) 243 | stash_flowbox_grid.attach(self.clear_keyword_revealer, 0, 0, 1, 1) 244 | stash_flowbox_grid.attach(self.search_keyword_revealer, 0, 0, 1, 1) 245 | stash_flowbox_grid.attach(scrolled_window, 0, 1, 1, 1) 246 | 247 | return stash_flowbox_grid 248 | 249 | def generate_stashed_settings(self): 250 | stashed_settings_grid = Gtk.FlowBox() 251 | stashed_settings_grid.props.expand = True 252 | stashed_settings_grid.props.homogeneous = True 253 | stashed_settings_grid.props.row_spacing = 20 254 | stashed_settings_grid.props.column_spacing = 20 255 | stashed_settings_grid.props.max_children_per_line = 10 256 | stashed_settings_grid.props.min_children_per_line = 2 257 | stashed_settings_grid.props.margin = 20 258 | stashed_settings_grid.props.valign = Gtk.Align.START 259 | stashed_settings_grid.props.halign = Gtk.Align.FILL 260 | 261 | add_shortcut = Gtk.Button(label="Add Shortcut", image=Gtk.Image().new_from_icon_name("com.github.hezral-shortcuts", Gtk.IconSize.DIALOG)) 262 | add_shortcut.props.name = "settings" 263 | add_shortcut.props.always_show_image = True 264 | add_shortcut.props.image_position = Gtk.PositionType.TOP 265 | add_shortcut.connect("clicked", self.on_settings_action) 266 | stashed_settings_grid.add(add_shortcut) 267 | 268 | buy_me_coffee = Gtk.Button(label="Buy Me Coffee", image=Gtk.Image().new_from_icon_name("com.github.hezral-coffee", Gtk.IconSize.DIALOG)) 269 | buy_me_coffee.props.name = "settings" 270 | buy_me_coffee.props.always_show_image = True 271 | buy_me_coffee.props.image_position = Gtk.PositionType.TOP 272 | buy_me_coffee.connect("clicked", self.on_settings_action) 273 | stashed_settings_grid.add(buy_me_coffee) 274 | 275 | scrolled_window = Gtk.ScrolledWindow() 276 | scrolled_window.props.expand = True 277 | scrolled_window.add(stashed_settings_grid) 278 | 279 | return scrolled_window 280 | 281 | def generate_settings_dialog(self): 282 | 283 | self.settings_grid = Settings(gtk_application=self.app) 284 | 285 | self.settings_dialog = CustomDialog( 286 | dialog_parent_widget=self, 287 | dialog_title="Stashed Settings", 288 | dialog_content_widget=self.settings_grid, 289 | action_button_label=None, 290 | action_button_name=None, 291 | action_callback=None, 292 | action_type=None, 293 | size=[500, 400], 294 | data=None 295 | ) 296 | 297 | self.settings_dialog.header.props.show_close_button = True 298 | 299 | def setup_display_settings(self): 300 | if not self.app.gio_settings.get_value("persistent-mode"): 301 | self.state_flags_on = self.connect("state-flags-changed", self.on_persistent_mode) 302 | if self.app.gio_settings.get_value("sticky-mode"): 303 | self.stick() 304 | if self.app.gio_settings.get_value("always-on-top"): 305 | self.set_keep_above(True) 306 | 307 | def check_active(self, data=None): 308 | print(self.app.utils.get_active_window_wm_class()) 309 | if self.app.props.application_id not in self.app.utils.get_active_window_wm_class(): 310 | # self.hide() 311 | ... 312 | 313 | def on_persistent_mode(self, widget, event): 314 | GLib.timeout_add(100, self.check_active, None) #adjust timing based on behaviour of app 315 | 316 | def on_settings_clicked(self, button): 317 | self.generate_settings_dialog() 318 | 319 | def on_settings_action(self, button): 320 | if button.props.label == "Add Shortcut": 321 | Gtk.show_uri_on_window(self, "settings://input/keyboard/shortcuts", GLib.get_current_time()) 322 | 323 | if button.props.label == "Quit Stashed": 324 | self.destroy() 325 | if button.props.label == "Buy Me Coffee": 326 | Gtk.show_uri_on_window(None, "https://www.buymeacoffee.com/hezral", GLib.get_current_time()) 327 | 328 | def on_window_handle_grab(self, widget, was_grabbed): 329 | print(locals()) 330 | 331 | def on_stash_items_flowboxchild_activated(self, flowbox, flowboxchild): 332 | flowboxchild.get_children()[0].revealer.set_reveal_child(True) 333 | 334 | def on_stash_grid_clicked(self, widget, eventbutton): 335 | if eventbutton.type.value_name == "GDK_2BUTTON_PRESS": 336 | self.reveal_stash_grid() 337 | 338 | def on_search_clicked(self, button): 339 | self.reveal_stash_grid() 340 | 341 | def on_menu_clicked(self, button): 342 | if self.stack.get_visible_child() == self.stashed_settings_grid: 343 | self.stack.set_visible_child(self.stash_stacked_grid) 344 | else: 345 | self.stack.set_visible_child(self.stashed_settings_grid) 346 | 347 | def on_close_window(self, button): 348 | if self.timeout_id: 349 | self.hide() 350 | self.on_stash_unfiltered() 351 | self.stack.set_visible_child(self.stash_stacked_grid) 352 | GLib.source_remove(self.timeout_id) 353 | self.timeout_id = None 354 | if self.app.shake_listener is not None: 355 | self.app.shake_listener.init_variables() 356 | # self.shake_listener.init_listener() 357 | else: 358 | button.stop_emission_by_name("clicked") 359 | 360 | def on_close_pressed(self, button=None, eventbutton=None): 361 | self.timeout_id = GLib.timeout_add(1000, self.on_close_held_timeout, button) 362 | 363 | def on_close_held_timeout(self, button): 364 | self.timeout_id = None 365 | button.emit("held", None) 366 | return False 367 | 368 | def on_close_held(self, *args): 369 | self.message_display_revealer.set_reveal_child(True) 370 | self.stack.set_visible_child(self.message_display_grid) 371 | self.timeout_on_quit() 372 | 373 | def timeout_on_quit(self): 374 | def update_label(timeout): 375 | self.message_display.props.label = "Quit in {i}".format(i=timeout) 376 | 377 | @HelperUtils.run_async 378 | def timeout_label(self, label): 379 | import time 380 | for i in reversed(range(1,3)): 381 | GLib.idle_add(update_label, (i)) 382 | time.sleep(1) 383 | try: 384 | self.destroy() 385 | except: 386 | pass 387 | 388 | timeout_label(self, self.message_display) 389 | 390 | def on_clear_stash(self, button): 391 | for flowboxchild in self.stash_flowbox.get_children(): 392 | flowboxchild.destroy() 393 | 394 | for child in self.stash_stacked.get_children(): 395 | child.destroy() 396 | 397 | self.search_revealer.set_reveal_child(False) 398 | self.clear_stash_revealer.set_reveal_child(False) 399 | self.header.props.title = "" 400 | 401 | def reveal_stash_grid(self): 402 | if self.stack.get_visible_child() == self.stash_flowbox_grid: 403 | self.stack.set_visible_child(self.stash_stacked_grid) 404 | if len(self.stash_flowbox.get_selected_children()) > 0: 405 | self.stash_flowbox.unselect_all() 406 | for flowboxchild in self.stash_flowbox.get_children(): 407 | flowboxchild.get_children()[0].revealer.set_reveal_child(False) 408 | self.on_stash_unfiltered() 409 | # self.disconnect_by_func(self.on_stash_filtered) 410 | self.props.resizable = False 411 | else: 412 | self.stack.set_visible_child(self.stash_flowbox_grid) 413 | # self.connect("key-press-event", self.on_stash_filtered) 414 | self.props.resizable = True 415 | 416 | def drag_and_drop_setup(self): 417 | self.drag_dest_set(Gtk.DestDefaults.ALL, [], Gdk.DragAction.COPY) 418 | self.drag_dest_add_uri_targets() 419 | self.drag_dest_add_image_targets() 420 | self.connect("drag_data_received", self.on_drag_data_received) 421 | self.connect("drag_drop", self.on_drag_drop) 422 | self.connect("drag_motion", self.on_drag_motion) 423 | self.connect("drag_leave", self.on_drag_drop) 424 | 425 | def drag_and_grab_setup(self, widget): 426 | widget.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, [], Gdk.DragAction.COPY) 427 | widget.drag_source_add_uri_targets() 428 | # widget.connect("drag_data_get", self.on_drag_data_get) 429 | widget.connect("drag_begin", self.on_drag_begin) 430 | widget.connect("drag_end", self.on_drag_end) 431 | # widget.connect("drag_motion", self.on_drag_motion) 432 | 433 | def on_drag_drop(self, *args): 434 | self.stash_zone_revealer.set_reveal_child(False) 435 | if len(self.stash_stacked.get_children()) != 0: 436 | self.clear_stash_revealer.set_reveal_child(True) 437 | self.search_revealer.set_reveal_child(True) 438 | 439 | def on_drag_motion(self, *args): 440 | # print(locals()) 441 | self.clear_stash_revealer.set_reveal_child(False) 442 | self.search_revealer.set_reveal_child(False) 443 | self.stash_zone_revealer.set_reveal_child(True) 444 | 445 | def on_drag_begin(self, widget, drag_context): 446 | self.disconnect_by_func(self.on_drag_motion) 447 | # print(locals()) 448 | # Gtk.drag_set_icon_widget(drag_context, self.stash_stacked, -2, -2) 449 | 450 | def on_drag_end(self, widget, drag_context): 451 | self.connect("drag_motion", self.on_drag_motion) 452 | self.grab_from_stash(widget, drag_context) 453 | # print(locals()) 454 | # Gtk.drag_set_icon_widget(drag_context, self.iconstack_drag_widget, -2, -2) 455 | 456 | def on_drag_data_get(self, widget, drag_context, data, info, timestamp): 457 | print(locals()) 458 | # Gtk.drag_set_icon_widget(drag_context, self.iconstack_drag_widget, -2, -2) 459 | 460 | def on_drag_data_received(self, widget, context, x, y, data, info, timestamp): 461 | self.add_to_stash(data.get_target(), data) 462 | Gtk.drag_finish(context, True, False, timestamp) 463 | 464 | def grab_from_stash(self, widget, drag_context): 465 | uris = [] 466 | if isinstance(widget, Gtk.Overlay): 467 | for child in widget.get_children(): 468 | if child.path != None: 469 | uris.append("file://" + child.path) 470 | 471 | else: 472 | for child in widget.get_selected_children(): 473 | if child.get_children()[0].get_child().get_children()[1].path != None: 474 | uris.append("file://" + child.get_children()[0].get_child().get_children()[1].path) 475 | 476 | uri_list = '\n'.join(uris) 477 | uri = 'copy' + uri_list 478 | 479 | stashed_window = self.app.utils.get_window_by_gtk_application_id_xlib(self.app.props.application_id) 480 | self.app.utils.copy_files_to_clipboard(uri) 481 | if self.app.utils.set_active_window_by_pointer() != self.app.utils.get_active_window_id_xlib(): 482 | self.app.utils.paste_from_clipboard() 483 | self.app.utils.set_active_window_by_xwindow(stashed_window) 484 | elif self.app.utils.set_active_window_by_pointer() == stashed_window: 485 | clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) 486 | clipboard.clear() 487 | 488 | @HelperUtils.run_async 489 | def add_to_stash(self, target, data): 490 | from urllib.parse import urlparse 491 | import time 492 | 493 | if str(target) == "text/uri-list": 494 | uris = data.get_uris() 495 | for uri in uris: 496 | parsed_uri = urlparse(uri) 497 | path, hostname = GLib.filename_from_uri(uri) 498 | try: 499 | iconstack_child = [child for child in self.stash_stacked.get_children() if path == child.path][0] 500 | except: 501 | if os.path.exists(path): 502 | if os.path.isdir(path): 503 | mime_type = "inode/directory" 504 | elif os.path.isfile(path): 505 | mime_type, val = Gio.content_type_guess(path, data=None) 506 | 507 | GLib.idle_add(self.update_stash, path, mime_type) 508 | # self.update_stash(path, mime_type) 509 | time.sleep(0.05) 510 | 511 | def update_stash(self, path, mime_type): 512 | icon = DefaultContainer(path, mime_type, self.app) 513 | item = DefaultContainer(path, mime_type, self.app, 64) 514 | if "image" in mime_type and not "gif" in mime_type: 515 | try: 516 | icon = ImageContainer(path) 517 | item = ImageContainer(path, 64) 518 | except: 519 | pass 520 | if "gif" in mime_type: 521 | icon = GifContainer(path) 522 | item = GifContainer(path, 64) 523 | 524 | import random 525 | if len(self.stash_stacked.get_children()) != 0: 526 | margin = random.randint(24,64) + self.iconstack_offset 527 | set_margins = [icon.set_margin_bottom, icon.set_margin_top, icon.set_margin_left, icon.set_margin_right] 528 | random.choice(set_margins)(margin) 529 | random.choice(set_margins)(self.iconstack_offset + random.randint(10,1000) % 2) 530 | 531 | self.stash_stacked.add_overlay(icon) 532 | # self.stash_stacked_icons.add_overlay(icon) 533 | 534 | self.stash_flowbox.add(StashItem(path, item)) 535 | 536 | if self.iconstack_offset >= 30: 537 | self.iconstack_offset = 0 538 | else: 539 | self.iconstack_offset += 2 540 | 541 | self.header.props.title = "{count} Stashed".format(count=len(self.stash_stacked.get_children())) 542 | self.stash_stacked.show_all() 543 | self.stash_flowbox.show_all() 544 | self.search_revealer.set_reveal_child(True) 545 | self.clear_stash_revealer.set_reveal_child(True) 546 | 547 | def filter_func(self, flowboxchild, search_text): 548 | stash_item_path = os.path.basename(flowboxchild.get_children()[0].get_child().get_children()[1].path) 549 | if search_text in stash_item_path: 550 | return True 551 | else: 552 | return False 553 | 554 | def on_stash_unfiltered(self, *args): 555 | self.stash_flowbox.invalidate_filter() 556 | self.stash_flowbox.set_filter_func(self.filter_func, "") 557 | self.search = [] 558 | self.stash_flowbox.unselect_all() 559 | self.search_keyword_revealer.set_reveal_child(False) 560 | self.clear_keyword_revealer.set_reveal_child(False) 561 | 562 | def on_stash_filtered(self, window, eventkey): 563 | 564 | print(Gdk.keyval_name(eventkey.keyval).lower()) 565 | 566 | key = Gdk.keyval_name(eventkey.keyval).lower() 567 | key_length = len(key) 568 | 569 | # filter = False 570 | 571 | if len(self.stash_stacked.get_children()) != 0: 572 | 573 | if ('GDK_SHIFT_MASK' in eventkey.state.value_names and 'GDK_MOD2_MASK' in eventkey.state.value_names) and key == "backspace": 574 | if self.stack.get_visible_child() == self.stash_flowbox_grid: 575 | self.on_stash_unfiltered() 576 | self.reveal_stash_grid() 577 | 578 | elif (len(eventkey.state.value_names) == 1 and 'GDK_MOD2_MASK' in eventkey.state.value_names) and key == "backspace": 579 | self.on_stash_unfiltered() 580 | 581 | elif key_length == 1: 582 | if self.stack.get_visible_child() != self.stash_flowbox_grid: 583 | self.reveal_stash_grid() 584 | self.trigger_stash_filter(key) 585 | print(key, len(key), Gdk.keyval_name(eventkey.keyval), eventkey.keyval, eventkey.state.value_names) 586 | 587 | def trigger_stash_filter(self, key): 588 | self.search_keyword_revealer.set_reveal_child(True) 589 | self.clear_keyword_revealer.set_reveal_child(True) 590 | self.search.append(key) 591 | keyword = ''.join(self.search) 592 | self.stash_flowbox.invalidate_filter() 593 | self.stash_flowbox.set_filter_func(self.filter_func, keyword) 594 | self.search_keyword.props.label = keyword 595 | 596 | 597 | class StashItem(Gtk.EventBox): 598 | def __init__(self, filepath, item, *args, **kwargs): 599 | super().__init__(*args, **kwargs) 600 | 601 | button = Gtk.Button(image=Gtk.Image().new_from_icon_name("process-completed", Gtk.IconSize.SMALL_TOOLBAR)) 602 | button.set_size_request(32, 32) 603 | button.props.name = "stash-item-select" 604 | button.props.halign = Gtk.Align.END 605 | button.props.valign = Gtk.Align.START 606 | button.props.can_focus = False 607 | button.connect("clicked", self.on_select_button) 608 | button.get_style_context().add_class("stash-item-select") 609 | self.revealer = Gtk.Revealer() 610 | self.revealer.add(button) 611 | 612 | label = ItemLabel(filepath) 613 | 614 | grid = Gtk.Grid() 615 | grid.props.margin = 6 616 | grid.props.row_spacing = 4 617 | grid.props.expand = True 618 | grid.props.halign = grid.props.valign = Gtk.Align.CENTER 619 | grid.attach(self.revealer, 0, 0, 1, 1) 620 | grid.attach(item, 0, 0, 1, 1) 621 | grid.attach(label, 0, 1, 1, 1) 622 | grid.set_size_request(100, 100) 623 | 624 | self.add(grid) 625 | self.props.has_tooltip = True 626 | self.props.tooltip_text = filepath 627 | 628 | def on_select_button(self, button): 629 | if self.revealer.get_reveal_child(): 630 | self.revealer.set_reveal_child(False) 631 | self.get_toplevel().stash_flowbox.unselect_child(self.get_parent()) 632 | 633 | 634 | class ItemLabel(Gtk.Label): 635 | def __init__(self, filepath, *args, **kwargs): 636 | super().__init__(*args, **kwargs) 637 | 638 | self.props.label = os.path.basename(filepath) 639 | self.props.wrap_mode = Pango.WrapMode.CHAR 640 | self.props.max_width_chars = 16 641 | self.props.wrap = True 642 | self.props.hexpand = True 643 | self.props.justify = Gtk.Justification.CENTER 644 | self.props.lines = 2 645 | self.props.ellipsize = Pango.EllipsizeMode.END 646 | 647 | 648 | class DefaultContainer(Gtk.Grid): 649 | def __init__(self, filepath, mime_type, app, size=96, *args, **kwargs): 650 | super().__init__(*args, **kwargs) 651 | 652 | self.props.name = "stash-container" 653 | self.props.expand = True 654 | self.path = filepath 655 | self.props.halign = self.props.valign = Gtk.Align.CENTER 656 | 657 | icon_size = size 658 | icon = Gtk.Image() 659 | 660 | icons = Gio.content_type_get_icon(mime_type) 661 | for icon_name in icons.to_string().split(): 662 | if icon_name != "." and icon_name != "GThemedIcon": 663 | try: 664 | icon_pixbuf = app.icon_theme.load_icon(icon_name, icon_size, 0) 665 | break 666 | except: 667 | pass 668 | if "generic" in icon_name: 669 | try: 670 | icon_pixbuf = app.icon_theme.load_icon(icon_name, icon_size, 0) 671 | break 672 | except: 673 | icon_pixbuf = app.icon_theme.load_icon("application-octet-stream", icon_size, 0) 674 | icon.props.pixbuf = icon_pixbuf 675 | 676 | self.attach(icon, 0, 0, 1, 1) 677 | 678 | 679 | class ImageContainer(Gtk.Grid): 680 | def __init__(self, filepath, size=128, *args, **kwargs): 681 | super().__init__(*args, **kwargs) 682 | 683 | self.props.name = "stash-container" 684 | self.props.expand = True 685 | self.path = filepath 686 | self.props.halign = self.props.valign = Gtk.Align.CENTER 687 | 688 | icon_size = size 689 | icon = Gtk.Image() 690 | icon_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(filepath, icon_size, icon_size) 691 | icon.props.pixbuf = icon_pixbuf 692 | 693 | self.attach(icon, 0, 0, 1, 1) 694 | 695 | 696 | class GifContainer(Gtk.Grid): 697 | def __init__(self, filepath, size=128, *args, **kwargs): 698 | super().__init__(*args, **kwargs) 699 | 700 | self.props.name = "stash-container" 701 | self.path = filepath 702 | 703 | self.pixbuf_original = GdkPixbuf.PixbufAnimation.new_from_file(filepath) 704 | self.pixbuf_original_height = self.pixbuf_original.get_height() 705 | self.pixbuf_original_width = self.pixbuf_original.get_width() 706 | self.iter = self.pixbuf_original.get_iter() 707 | for i in range(0, 250): 708 | timeval = GLib.TimeVal() 709 | timeval.tv_sec = int(str(GLib.get_real_time())[:-3]) 710 | self.iter.advance(timeval) 711 | self.queue_draw() 712 | 713 | self.ratio_h_w = self.pixbuf_original_height / self.pixbuf_original_width 714 | self.ratio_w_h = self.pixbuf_original_width / self.pixbuf_original_height 715 | 716 | if self.ratio_w_h > 1: 717 | self.set_size_request(size, int((10/16)*size) + 1) 718 | else: 719 | self.set_size_request(size, size) 720 | 721 | drawing_area = Gtk.DrawingArea() 722 | drawing_area.props.expand = True 723 | drawing_area.props.halign = drawing_area.props.valign = Gtk.Align.FILL 724 | drawing_area.connect("draw", self.draw) 725 | drawing_area.props.can_focus = False 726 | 727 | self.attach(drawing_area, 0, 0, 1, 1) 728 | self.props.halign = self.props.valign = Gtk.Align.CENTER 729 | 730 | # self.animation_loop_func() 731 | 732 | def animation_loop_func(self, *args): 733 | self.iter.advance() 734 | GLib.timeout_add(self.iter.get_delay_time(), self.animation_loop_func, None) 735 | self.queue_draw() 736 | 737 | def draw(self, drawing_area, cairo_context, hover_scale=1): 738 | ''' 739 | Forked and ported from https://github.com/elementary/greeter/blob/master/src/Widgets/BackgroundImage.vala 740 | ''' 741 | from math import pi 742 | 743 | scale = self.get_scale_factor() 744 | width = self.get_allocated_width() * scale * hover_scale 745 | height = self.get_allocated_height() * scale * hover_scale 746 | radius = 4 * scale #Off-by-one to prevent light bleed 747 | 748 | pixbuf = GdkPixbuf.PixbufAnimationIter.get_pixbuf(self.iter) 749 | pixbuf_fitted = GdkPixbuf.Pixbuf.new(pixbuf.get_colorspace(), pixbuf.get_has_alpha(), pixbuf.get_bits_per_sample(), width, height) 750 | 751 | if int(width * self.ratio_h_w) < height: 752 | scaled_pixbuf = pixbuf.scale_simple(int(height * self.ratio_w_h), height, GdkPixbuf.InterpType.BILINEAR) 753 | else: 754 | scaled_pixbuf = pixbuf.scale_simple(width, int(width * self.ratio_h_w), GdkPixbuf.InterpType.BILINEAR) 755 | 756 | if self.pixbuf_original_width * self.pixbuf_original_height < width * height: 757 | # Find the offset we need to center the source pixbuf on the destination since its smaller 758 | y = abs((height - self.pixbuf_original_height) / 2) 759 | x = abs((width - self.pixbuf_original_width) / 2) 760 | final_pixbuf = self.pixbuf_original 761 | else: 762 | # Find the offset we need to center the source pixbuf on the destination 763 | y = abs((height - scaled_pixbuf.props.height) / 2) 764 | x = abs((width - scaled_pixbuf.props.width) / 2) 765 | scaled_pixbuf.copy_area(x, y, width, height, pixbuf_fitted, 0, 0) 766 | # Set coordinates for cairo surface since this has been fitted, it should be (0, 0) coordinate 767 | x = y = 0 768 | final_pixbuf = pixbuf_fitted 769 | 770 | cairo_context.save() 771 | cairo_context.scale(1.0 / scale, 1.0 / scale) 772 | cairo_context.new_sub_path() 773 | 774 | # draws rounded rectangle 775 | cairo_context.arc(width - radius, radius, radius, 0-pi/2, 0) # top-right-corner 776 | cairo_context.arc(width - radius, height - radius, radius, 0, pi/2) # bottom-right-corner 777 | cairo_context.arc(radius, height - radius, radius, pi/2, pi) # bottom-left-corner 778 | cairo_context.arc(radius, radius, radius, pi, pi + pi/2) # top-left-corner 779 | 780 | cairo_context.close_path() 781 | 782 | Gdk.cairo_set_source_pixbuf(cairo_context, final_pixbuf, x, y) 783 | 784 | cairo_context.clip() 785 | cairo_context.paint() 786 | cairo_context.restore() --------------------------------------------------------------------------------