├── .gitignore ├── .well-known └── org.flathub.VerifiedApps.txt ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── build.rs ├── data ├── io.github.andreibachim.shortcut.desktop ├── io.github.andreibachim.shortcut.gschema.xml ├── io.github.andreibachim.shortcut.metainfo.xml ├── io.github.andreibachim.shortcut.svg ├── resources.gresource.xml ├── resources │ ├── icons │ │ └── image-missing-symbolic.svg │ └── ui │ │ ├── completed.ui │ │ ├── component │ │ ├── entry.ui │ │ ├── menu.ui │ │ ├── nav_view.ui │ │ └── viewport.ui │ │ ├── keyboard_shortcuts.ui │ │ ├── landing.ui │ │ ├── manage.ui │ │ ├── preferences.ui │ │ └── quick_mode.ui └── screenshots │ ├── screenshot1.png │ ├── screenshot2.png │ ├── screenshot3.png │ └── screenshot4.png ├── io.github.andreibachim.shortcut.yml ├── scripts ├── flatpak-cargo-generator.py └── generate-sources.sh ├── snap ├── gui │ ├── shortcut-app.desktop │ └── shortcut-app.svg └── snapcraft.yaml └── src ├── component ├── entry.rs ├── menu.rs └── mod.rs ├── function ├── icon.rs └── mod.rs ├── main.rs ├── model ├── desktop.rs └── mod.rs └── view ├── completed.rs ├── manage.rs ├── mod.rs └── quick_mode.rs /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /release 3 | /.vscode 4 | /.flatpak-builder 5 | /build-dir 6 | /scripts/generated-sources.json 7 | *.snap 8 | -------------------------------------------------------------------------------- /.well-known/org.flathub.VerifiedApps.txt: -------------------------------------------------------------------------------- 1 | 2a2892ac-05ba-401f-9944-3afcf5d6cd16 -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "anyhow" 7 | version = "1.0.75" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" 10 | 11 | [[package]] 12 | name = "autocfg" 13 | version = "1.1.0" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 16 | 17 | [[package]] 18 | name = "bitflags" 19 | version = "2.6.0" 20 | source = "registry+https://github.com/rust-lang/crates.io-index" 21 | checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" 22 | 23 | [[package]] 24 | name = "cairo-rs" 25 | version = "0.20.1" 26 | source = "registry+https://github.com/rust-lang/crates.io-index" 27 | checksum = "e8a0ea147c94108c9613235388f540e4d14c327f7081c9e471fc8ee8a2533e69" 28 | dependencies = [ 29 | "bitflags", 30 | "cairo-sys-rs", 31 | "glib", 32 | "libc", 33 | ] 34 | 35 | [[package]] 36 | name = "cairo-sys-rs" 37 | version = "0.20.0" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "428290f914b9b86089f60f5d8a9f6e440508e1bcff23b25afd51502b0a2da88f" 40 | dependencies = [ 41 | "glib-sys", 42 | "libc", 43 | "system-deps", 44 | ] 45 | 46 | [[package]] 47 | name = "cfg-expr" 48 | version = "0.17.0" 49 | source = "registry+https://github.com/rust-lang/crates.io-index" 50 | checksum = "d0890061c4d3223e7267f3bad2ec40b997d64faac1c2815a4a9d95018e2b9e9c" 51 | dependencies = [ 52 | "smallvec", 53 | "target-lexicon", 54 | ] 55 | 56 | [[package]] 57 | name = "equivalent" 58 | version = "1.0.1" 59 | source = "registry+https://github.com/rust-lang/crates.io-index" 60 | checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" 61 | 62 | [[package]] 63 | name = "field-offset" 64 | version = "0.3.6" 65 | source = "registry+https://github.com/rust-lang/crates.io-index" 66 | checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" 67 | dependencies = [ 68 | "memoffset", 69 | "rustc_version", 70 | ] 71 | 72 | [[package]] 73 | name = "freedesktop_entry_parser" 74 | version = "1.3.0" 75 | source = "registry+https://github.com/rust-lang/crates.io-index" 76 | checksum = "db9c27b72f19a99a895f8ca89e2d26e4ef31013376e56fdafef697627306c3e4" 77 | dependencies = [ 78 | "nom", 79 | "thiserror", 80 | ] 81 | 82 | [[package]] 83 | name = "futures-channel" 84 | version = "0.3.28" 85 | source = "registry+https://github.com/rust-lang/crates.io-index" 86 | checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" 87 | dependencies = [ 88 | "futures-core", 89 | ] 90 | 91 | [[package]] 92 | name = "futures-core" 93 | version = "0.3.28" 94 | source = "registry+https://github.com/rust-lang/crates.io-index" 95 | checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" 96 | 97 | [[package]] 98 | name = "futures-executor" 99 | version = "0.3.28" 100 | source = "registry+https://github.com/rust-lang/crates.io-index" 101 | checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" 102 | dependencies = [ 103 | "futures-core", 104 | "futures-task", 105 | "futures-util", 106 | ] 107 | 108 | [[package]] 109 | name = "futures-io" 110 | version = "0.3.28" 111 | source = "registry+https://github.com/rust-lang/crates.io-index" 112 | checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" 113 | 114 | [[package]] 115 | name = "futures-macro" 116 | version = "0.3.28" 117 | source = "registry+https://github.com/rust-lang/crates.io-index" 118 | checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" 119 | dependencies = [ 120 | "proc-macro2", 121 | "quote", 122 | "syn", 123 | ] 124 | 125 | [[package]] 126 | name = "futures-task" 127 | version = "0.3.28" 128 | source = "registry+https://github.com/rust-lang/crates.io-index" 129 | checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" 130 | 131 | [[package]] 132 | name = "futures-util" 133 | version = "0.3.28" 134 | source = "registry+https://github.com/rust-lang/crates.io-index" 135 | checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" 136 | dependencies = [ 137 | "futures-core", 138 | "futures-macro", 139 | "futures-task", 140 | "pin-project-lite", 141 | "pin-utils", 142 | "slab", 143 | ] 144 | 145 | [[package]] 146 | name = "gdk-pixbuf" 147 | version = "0.20.4" 148 | source = "registry+https://github.com/rust-lang/crates.io-index" 149 | checksum = "c4c29071a9e92337d8270a85cb0510cda4ac478be26d09ad027cc1d081911b19" 150 | dependencies = [ 151 | "gdk-pixbuf-sys", 152 | "gio", 153 | "glib", 154 | "libc", 155 | ] 156 | 157 | [[package]] 158 | name = "gdk-pixbuf-sys" 159 | version = "0.20.4" 160 | source = "registry+https://github.com/rust-lang/crates.io-index" 161 | checksum = "687343b059b91df5f3fbd87b4307038fa9e647fcc0461d0d3f93e94fee20bf3d" 162 | dependencies = [ 163 | "gio-sys", 164 | "glib-sys", 165 | "gobject-sys", 166 | "libc", 167 | "system-deps", 168 | ] 169 | 170 | [[package]] 171 | name = "gdk4" 172 | version = "0.9.2" 173 | source = "registry+https://github.com/rust-lang/crates.io-index" 174 | checksum = "c121aeeb0cf7545877ae615dac6bfd088b739d8abee4d55e7143b06927d16a31" 175 | dependencies = [ 176 | "cairo-rs", 177 | "gdk-pixbuf", 178 | "gdk4-sys", 179 | "gio", 180 | "glib", 181 | "libc", 182 | "pango", 183 | ] 184 | 185 | [[package]] 186 | name = "gdk4-sys" 187 | version = "0.9.2" 188 | source = "registry+https://github.com/rust-lang/crates.io-index" 189 | checksum = "7d3c03d1ea9d5199f14f060890fde68a3b5ec5699144773d1fa6abf337bfbc9c" 190 | dependencies = [ 191 | "cairo-sys-rs", 192 | "gdk-pixbuf-sys", 193 | "gio-sys", 194 | "glib-sys", 195 | "gobject-sys", 196 | "libc", 197 | "pango-sys", 198 | "pkg-config", 199 | "system-deps", 200 | ] 201 | 202 | [[package]] 203 | name = "gio" 204 | version = "0.20.4" 205 | source = "registry+https://github.com/rust-lang/crates.io-index" 206 | checksum = "b8d999e8fb09583e96080867e364bc1e701284ad206c76a5af480d63833ad43c" 207 | dependencies = [ 208 | "futures-channel", 209 | "futures-core", 210 | "futures-io", 211 | "futures-util", 212 | "gio-sys", 213 | "glib", 214 | "libc", 215 | "pin-project-lite", 216 | "smallvec", 217 | ] 218 | 219 | [[package]] 220 | name = "gio-sys" 221 | version = "0.20.4" 222 | source = "registry+https://github.com/rust-lang/crates.io-index" 223 | checksum = "4f7efc368de04755344f0084104835b6bb71df2c1d41e37d863947392a894779" 224 | dependencies = [ 225 | "glib-sys", 226 | "gobject-sys", 227 | "libc", 228 | "system-deps", 229 | "windows-sys", 230 | ] 231 | 232 | [[package]] 233 | name = "glib" 234 | version = "0.20.4" 235 | source = "registry+https://github.com/rust-lang/crates.io-index" 236 | checksum = "adcf1ec6d3650bf9fdbc6cee242d4fcebc6f6bfd9bea5b929b6a8b7344eb85ff" 237 | dependencies = [ 238 | "bitflags", 239 | "futures-channel", 240 | "futures-core", 241 | "futures-executor", 242 | "futures-task", 243 | "futures-util", 244 | "gio-sys", 245 | "glib-macros", 246 | "glib-sys", 247 | "gobject-sys", 248 | "libc", 249 | "memchr", 250 | "smallvec", 251 | ] 252 | 253 | [[package]] 254 | name = "glib-build-tools" 255 | version = "0.18.0" 256 | source = "registry+https://github.com/rust-lang/crates.io-index" 257 | checksum = "3431c56f463443cba9bc3600248bc6d680cb614c2ee1cdd39dab5415bd12ac5c" 258 | 259 | [[package]] 260 | name = "glib-macros" 261 | version = "0.20.4" 262 | source = "registry+https://github.com/rust-lang/crates.io-index" 263 | checksum = "a6bf88f70cd5720a6197639dcabcb378dd528d0cb68cb1f45e3b358bcb841cd7" 264 | dependencies = [ 265 | "heck", 266 | "proc-macro-crate", 267 | "proc-macro2", 268 | "quote", 269 | "syn", 270 | ] 271 | 272 | [[package]] 273 | name = "glib-sys" 274 | version = "0.20.4" 275 | source = "registry+https://github.com/rust-lang/crates.io-index" 276 | checksum = "5f9eca5d88cfa6a453b00d203287c34a2b7cac3a7831779aa2bb0b3c7233752b" 277 | dependencies = [ 278 | "libc", 279 | "system-deps", 280 | ] 281 | 282 | [[package]] 283 | name = "gobject-sys" 284 | version = "0.20.4" 285 | source = "registry+https://github.com/rust-lang/crates.io-index" 286 | checksum = "a4c674d2ff8478cf0ec29d2be730ed779fef54415a2fb4b565c52def62696462" 287 | dependencies = [ 288 | "glib-sys", 289 | "libc", 290 | "system-deps", 291 | ] 292 | 293 | [[package]] 294 | name = "graphene-rs" 295 | version = "0.20.4" 296 | source = "registry+https://github.com/rust-lang/crates.io-index" 297 | checksum = "1f53144c7fe78292705ff23935f1477d511366fb2f73c43d63b37be89076d2fe" 298 | dependencies = [ 299 | "glib", 300 | "graphene-sys", 301 | "libc", 302 | ] 303 | 304 | [[package]] 305 | name = "graphene-sys" 306 | version = "0.20.4" 307 | source = "registry+https://github.com/rust-lang/crates.io-index" 308 | checksum = "e741797dc5081e59877a4d72c442c72d61efdd99161a0b1c1b29b6b988934b99" 309 | dependencies = [ 310 | "glib-sys", 311 | "libc", 312 | "pkg-config", 313 | "system-deps", 314 | ] 315 | 316 | [[package]] 317 | name = "gsk4" 318 | version = "0.9.2" 319 | source = "registry+https://github.com/rust-lang/crates.io-index" 320 | checksum = "aa21a2f7c51ee1c6cc1242c2faf3aae2b7566138f182696759987bde8219e922" 321 | dependencies = [ 322 | "cairo-rs", 323 | "gdk4", 324 | "glib", 325 | "graphene-rs", 326 | "gsk4-sys", 327 | "libc", 328 | "pango", 329 | ] 330 | 331 | [[package]] 332 | name = "gsk4-sys" 333 | version = "0.9.2" 334 | source = "registry+https://github.com/rust-lang/crates.io-index" 335 | checksum = "0f9fb607554f9f4e8829eb7ea301b0fde051e1dbfd5d16b143a8a9c2fac6c01b" 336 | dependencies = [ 337 | "cairo-sys-rs", 338 | "gdk4-sys", 339 | "glib-sys", 340 | "gobject-sys", 341 | "graphene-sys", 342 | "libc", 343 | "pango-sys", 344 | "system-deps", 345 | ] 346 | 347 | [[package]] 348 | name = "gtk4" 349 | version = "0.9.2" 350 | source = "registry+https://github.com/rust-lang/crates.io-index" 351 | checksum = "31e2d105ce672f5cdcb5af2602e91c2901e91c72da15ab76f613ad57ecf04c6d" 352 | dependencies = [ 353 | "cairo-rs", 354 | "field-offset", 355 | "futures-channel", 356 | "gdk-pixbuf", 357 | "gdk4", 358 | "gio", 359 | "glib", 360 | "graphene-rs", 361 | "gsk4", 362 | "gtk4-macros", 363 | "gtk4-sys", 364 | "libc", 365 | "pango", 366 | ] 367 | 368 | [[package]] 369 | name = "gtk4-macros" 370 | version = "0.9.1" 371 | source = "registry+https://github.com/rust-lang/crates.io-index" 372 | checksum = "e9e7b362c8fccd2712297903717d65d30defdab2b509bc9d209cbe5ffb9fabaf" 373 | dependencies = [ 374 | "proc-macro-crate", 375 | "proc-macro2", 376 | "quote", 377 | "syn", 378 | ] 379 | 380 | [[package]] 381 | name = "gtk4-sys" 382 | version = "0.9.2" 383 | source = "registry+https://github.com/rust-lang/crates.io-index" 384 | checksum = "cbe4325908b1c1642dbb48e9f49c07a73185babf43e8b2065b0f881a589f55b8" 385 | dependencies = [ 386 | "cairo-sys-rs", 387 | "gdk-pixbuf-sys", 388 | "gdk4-sys", 389 | "gio-sys", 390 | "glib-sys", 391 | "gobject-sys", 392 | "graphene-sys", 393 | "gsk4-sys", 394 | "libc", 395 | "pango-sys", 396 | "system-deps", 397 | ] 398 | 399 | [[package]] 400 | name = "hashbrown" 401 | version = "0.15.0" 402 | source = "registry+https://github.com/rust-lang/crates.io-index" 403 | checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" 404 | 405 | [[package]] 406 | name = "heck" 407 | version = "0.5.0" 408 | source = "registry+https://github.com/rust-lang/crates.io-index" 409 | checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 410 | 411 | [[package]] 412 | name = "indexmap" 413 | version = "2.6.0" 414 | source = "registry+https://github.com/rust-lang/crates.io-index" 415 | checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" 416 | dependencies = [ 417 | "equivalent", 418 | "hashbrown", 419 | ] 420 | 421 | [[package]] 422 | name = "libadwaita" 423 | version = "0.7.0" 424 | source = "registry+https://github.com/rust-lang/crates.io-index" 425 | checksum = "2ff9c222b5c783729de45185f07b2fec2d43a7f9c63961e777d3667e20443878" 426 | dependencies = [ 427 | "gdk4", 428 | "gio", 429 | "glib", 430 | "gtk4", 431 | "libadwaita-sys", 432 | "libc", 433 | "pango", 434 | ] 435 | 436 | [[package]] 437 | name = "libadwaita-sys" 438 | version = "0.7.0" 439 | source = "registry+https://github.com/rust-lang/crates.io-index" 440 | checksum = "1c44d8bdbad31d6639e1f20cc9c1424f1a8e02d751fc28d44659bf743fb9eca6" 441 | dependencies = [ 442 | "gdk4-sys", 443 | "gio-sys", 444 | "glib-sys", 445 | "gobject-sys", 446 | "gtk4-sys", 447 | "libc", 448 | "pango-sys", 449 | "system-deps", 450 | ] 451 | 452 | [[package]] 453 | name = "libc" 454 | version = "0.2.147" 455 | source = "registry+https://github.com/rust-lang/crates.io-index" 456 | checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" 457 | 458 | [[package]] 459 | name = "memchr" 460 | version = "2.7.4" 461 | source = "registry+https://github.com/rust-lang/crates.io-index" 462 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 463 | 464 | [[package]] 465 | name = "memoffset" 466 | version = "0.9.0" 467 | source = "registry+https://github.com/rust-lang/crates.io-index" 468 | checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" 469 | dependencies = [ 470 | "autocfg", 471 | ] 472 | 473 | [[package]] 474 | name = "minimal-lexical" 475 | version = "0.2.1" 476 | source = "registry+https://github.com/rust-lang/crates.io-index" 477 | checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" 478 | 479 | [[package]] 480 | name = "nom" 481 | version = "7.1.3" 482 | source = "registry+https://github.com/rust-lang/crates.io-index" 483 | checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" 484 | dependencies = [ 485 | "memchr", 486 | "minimal-lexical", 487 | ] 488 | 489 | [[package]] 490 | name = "pango" 491 | version = "0.20.4" 492 | source = "registry+https://github.com/rust-lang/crates.io-index" 493 | checksum = "aa26aa54b11094d72141a754901cd71d9356432bb8147f9cace8d9c7ba95f356" 494 | dependencies = [ 495 | "gio", 496 | "glib", 497 | "libc", 498 | "pango-sys", 499 | ] 500 | 501 | [[package]] 502 | name = "pango-sys" 503 | version = "0.20.4" 504 | source = "registry+https://github.com/rust-lang/crates.io-index" 505 | checksum = "84fd65917bf12f06544ae2bbc200abf9fc0a513a5a88a0fa81013893aef2b838" 506 | dependencies = [ 507 | "glib-sys", 508 | "gobject-sys", 509 | "libc", 510 | "system-deps", 511 | ] 512 | 513 | [[package]] 514 | name = "pin-project-lite" 515 | version = "0.2.12" 516 | source = "registry+https://github.com/rust-lang/crates.io-index" 517 | checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" 518 | 519 | [[package]] 520 | name = "pin-utils" 521 | version = "0.1.0" 522 | source = "registry+https://github.com/rust-lang/crates.io-index" 523 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 524 | 525 | [[package]] 526 | name = "pkg-config" 527 | version = "0.3.31" 528 | source = "registry+https://github.com/rust-lang/crates.io-index" 529 | checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" 530 | 531 | [[package]] 532 | name = "proc-macro-crate" 533 | version = "3.2.0" 534 | source = "registry+https://github.com/rust-lang/crates.io-index" 535 | checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" 536 | dependencies = [ 537 | "toml_edit", 538 | ] 539 | 540 | [[package]] 541 | name = "proc-macro2" 542 | version = "1.0.88" 543 | source = "registry+https://github.com/rust-lang/crates.io-index" 544 | checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" 545 | dependencies = [ 546 | "unicode-ident", 547 | ] 548 | 549 | [[package]] 550 | name = "quote" 551 | version = "1.0.37" 552 | source = "registry+https://github.com/rust-lang/crates.io-index" 553 | checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" 554 | dependencies = [ 555 | "proc-macro2", 556 | ] 557 | 558 | [[package]] 559 | name = "rustc_version" 560 | version = "0.4.0" 561 | source = "registry+https://github.com/rust-lang/crates.io-index" 562 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 563 | dependencies = [ 564 | "semver", 565 | ] 566 | 567 | [[package]] 568 | name = "semver" 569 | version = "1.0.18" 570 | source = "registry+https://github.com/rust-lang/crates.io-index" 571 | checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" 572 | 573 | [[package]] 574 | name = "serde" 575 | version = "1.0.183" 576 | source = "registry+https://github.com/rust-lang/crates.io-index" 577 | checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" 578 | 579 | [[package]] 580 | name = "serde_spanned" 581 | version = "0.6.8" 582 | source = "registry+https://github.com/rust-lang/crates.io-index" 583 | checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" 584 | dependencies = [ 585 | "serde", 586 | ] 587 | 588 | [[package]] 589 | name = "shortcut" 590 | version = "0.4.2" 591 | dependencies = [ 592 | "anyhow", 593 | "freedesktop_entry_parser", 594 | "glib-build-tools", 595 | "gtk4", 596 | "libadwaita", 597 | ] 598 | 599 | [[package]] 600 | name = "slab" 601 | version = "0.4.8" 602 | source = "registry+https://github.com/rust-lang/crates.io-index" 603 | checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" 604 | dependencies = [ 605 | "autocfg", 606 | ] 607 | 608 | [[package]] 609 | name = "smallvec" 610 | version = "1.13.2" 611 | source = "registry+https://github.com/rust-lang/crates.io-index" 612 | checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" 613 | 614 | [[package]] 615 | name = "syn" 616 | version = "2.0.79" 617 | source = "registry+https://github.com/rust-lang/crates.io-index" 618 | checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" 619 | dependencies = [ 620 | "proc-macro2", 621 | "quote", 622 | "unicode-ident", 623 | ] 624 | 625 | [[package]] 626 | name = "system-deps" 627 | version = "7.0.3" 628 | source = "registry+https://github.com/rust-lang/crates.io-index" 629 | checksum = "66d23aaf9f331227789a99e8de4c91bf46703add012bdfd45fdecdfb2975a005" 630 | dependencies = [ 631 | "cfg-expr", 632 | "heck", 633 | "pkg-config", 634 | "toml", 635 | "version-compare", 636 | ] 637 | 638 | [[package]] 639 | name = "target-lexicon" 640 | version = "0.12.16" 641 | source = "registry+https://github.com/rust-lang/crates.io-index" 642 | checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" 643 | 644 | [[package]] 645 | name = "thiserror" 646 | version = "1.0.47" 647 | source = "registry+https://github.com/rust-lang/crates.io-index" 648 | checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" 649 | dependencies = [ 650 | "thiserror-impl", 651 | ] 652 | 653 | [[package]] 654 | name = "thiserror-impl" 655 | version = "1.0.47" 656 | source = "registry+https://github.com/rust-lang/crates.io-index" 657 | checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" 658 | dependencies = [ 659 | "proc-macro2", 660 | "quote", 661 | "syn", 662 | ] 663 | 664 | [[package]] 665 | name = "toml" 666 | version = "0.8.19" 667 | source = "registry+https://github.com/rust-lang/crates.io-index" 668 | checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" 669 | dependencies = [ 670 | "serde", 671 | "serde_spanned", 672 | "toml_datetime", 673 | "toml_edit", 674 | ] 675 | 676 | [[package]] 677 | name = "toml_datetime" 678 | version = "0.6.8" 679 | source = "registry+https://github.com/rust-lang/crates.io-index" 680 | checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" 681 | dependencies = [ 682 | "serde", 683 | ] 684 | 685 | [[package]] 686 | name = "toml_edit" 687 | version = "0.22.22" 688 | source = "registry+https://github.com/rust-lang/crates.io-index" 689 | checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" 690 | dependencies = [ 691 | "indexmap", 692 | "serde", 693 | "serde_spanned", 694 | "toml_datetime", 695 | "winnow", 696 | ] 697 | 698 | [[package]] 699 | name = "unicode-ident" 700 | version = "1.0.11" 701 | source = "registry+https://github.com/rust-lang/crates.io-index" 702 | checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" 703 | 704 | [[package]] 705 | name = "version-compare" 706 | version = "0.2.0" 707 | source = "registry+https://github.com/rust-lang/crates.io-index" 708 | checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" 709 | 710 | [[package]] 711 | name = "windows-sys" 712 | version = "0.52.0" 713 | source = "registry+https://github.com/rust-lang/crates.io-index" 714 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 715 | dependencies = [ 716 | "windows-targets", 717 | ] 718 | 719 | [[package]] 720 | name = "windows-targets" 721 | version = "0.52.6" 722 | source = "registry+https://github.com/rust-lang/crates.io-index" 723 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 724 | dependencies = [ 725 | "windows_aarch64_gnullvm", 726 | "windows_aarch64_msvc", 727 | "windows_i686_gnu", 728 | "windows_i686_gnullvm", 729 | "windows_i686_msvc", 730 | "windows_x86_64_gnu", 731 | "windows_x86_64_gnullvm", 732 | "windows_x86_64_msvc", 733 | ] 734 | 735 | [[package]] 736 | name = "windows_aarch64_gnullvm" 737 | version = "0.52.6" 738 | source = "registry+https://github.com/rust-lang/crates.io-index" 739 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 740 | 741 | [[package]] 742 | name = "windows_aarch64_msvc" 743 | version = "0.52.6" 744 | source = "registry+https://github.com/rust-lang/crates.io-index" 745 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 746 | 747 | [[package]] 748 | name = "windows_i686_gnu" 749 | version = "0.52.6" 750 | source = "registry+https://github.com/rust-lang/crates.io-index" 751 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 752 | 753 | [[package]] 754 | name = "windows_i686_gnullvm" 755 | version = "0.52.6" 756 | source = "registry+https://github.com/rust-lang/crates.io-index" 757 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 758 | 759 | [[package]] 760 | name = "windows_i686_msvc" 761 | version = "0.52.6" 762 | source = "registry+https://github.com/rust-lang/crates.io-index" 763 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 764 | 765 | [[package]] 766 | name = "windows_x86_64_gnu" 767 | version = "0.52.6" 768 | source = "registry+https://github.com/rust-lang/crates.io-index" 769 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 770 | 771 | [[package]] 772 | name = "windows_x86_64_gnullvm" 773 | version = "0.52.6" 774 | source = "registry+https://github.com/rust-lang/crates.io-index" 775 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 776 | 777 | [[package]] 778 | name = "windows_x86_64_msvc" 779 | version = "0.52.6" 780 | source = "registry+https://github.com/rust-lang/crates.io-index" 781 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 782 | 783 | [[package]] 784 | name = "winnow" 785 | version = "0.6.20" 786 | source = "registry+https://github.com/rust-lang/crates.io-index" 787 | checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" 788 | dependencies = [ 789 | "memchr", 790 | ] 791 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "shortcut" 3 | version = "0.4.2" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] } 10 | gtk = { version = "0.9.2", package = "gtk4", features = ["v4_16"] } 11 | freedesktop_entry_parser = { version = "1.3.0" } 12 | anyhow = "1.0.75" 13 | 14 | [build-dependencies] 15 | glib-build-tools = "0.18.0" 16 | -------------------------------------------------------------------------------- /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 | # Shortcut 2 | 3 | ## Description 4 | 5 | Shortcut is an desktop app made using Rust, GTK4 and Libadawaita that can easily create .desktop files. 6 | It is specifically designed to visually integrate with the GNOME desktop environment. 7 | 8 | ## Installing 9 | 10 | 11 | 12 | 13 | 14 | 15 | ### Build from source code 16 | 17 | Requirements 18 | - Minimum Rust version > 1.70 - check it by running: ```rustc -V``` 19 | - Minimum GTK version > 4.10 - check it by running ```pkg-config --modversion gtk4``` 20 | - Minimium Libadwaita version > 1.3 - check it by running ```pkg-config --modversion libadwaita-1``` 21 | 22 | ## Roadmap 23 | 24 | The roadmap for adding features includes: 25 | 26 | - Expert mode - create .desktop files following the full [Freedesktop specification](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys) 27 | - Editing existing .desktop files 28 | - Integrate with a translation API to automatically generate localized values for keys 29 | -------------------------------------------------------------------------------- /build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | glib_build_tools::compile_resources( 3 | &["data"], 4 | "data/resources.gresource.xml", 5 | "shortcut.gresource", 6 | ); 7 | } 8 | -------------------------------------------------------------------------------- /data/io.github.andreibachim.shortcut.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Shortcut 3 | Comment=Make app shortcuts 4 | Exec= 5 | Icon=io.github.andreibachim.shortcut 6 | Terminal=false 7 | Type=Application 8 | Categories=Utility;GTK;GNOME; 9 | Keywords=Shortcut;Icons;Pin;Launch; 10 | -------------------------------------------------------------------------------- /data/io.github.andreibachim.shortcut.gschema.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | true 6 | Enable form validation in create view 7 | 8 | 9 | 0 10 | App color scheme 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /data/io.github.andreibachim.shortcut.metainfo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | io.github.andreibachim.shortcut 5 | CC0-1.0 6 | GPL-3.0-or-later 7 | Shortcut 8 | Make app shortcuts 9 | 10 |

11 | Shortcut is a tool that allows users to quickly pin executable files to their app launcher. 12 | It guides users throught the process by providing file picker dialogs with relevant filters, 13 | input validation, and name and icon previews. 14 |

15 |
16 | 17 | #99c1f1 18 | #1a5fb4 19 | 20 | io.github.andreibachim.shortcut.desktop 21 | https://github.com/andreibachim/shortcut 22 | https://github.com/andreibachim/shortcut/issues 23 | andreiachim_AT_duck.com 24 | 25 | Andrei Achim 26 | 27 | 28 | 29 | 30 | 31 | https://raw.githubusercontent.com/andreibachim/shortcut/main/data/screenshots/screenshot1.png 32 | Dark mode shortcuts list 33 | 34 | 35 | 36 | https://raw.githubusercontent.com/andreibachim/shortcut/main/data/screenshots/screenshot2.png 37 | Light mode shortcuts list 38 | 39 | 40 | 41 | https://raw.githubusercontent.com/andreibachim/shortcut/main/data/screenshots/screenshot3.png 42 | Dark mode create screen 43 | 44 | 45 | 46 | https://raw.githubusercontent.com/andreibachim/shortcut/main/data/screenshots/screenshot4.png 47 | Light mode create screen 48 | 49 | 50 | 51 | 52 | 53 |

1. Fixed one issue regarding exec paths that contain spaces.

54 |

2. Added branding colors and updated screenshots.

55 |
56 |
57 | 58 | 59 |

1. Update GTK and Libadwaita dependencies

60 |
61 |
62 | 63 | 64 |

1. Implemented new navigation system, more in line with modern GNOME apps.

65 |

2. Redesiged application flows to streamline usage patterns.

66 |
67 |
68 | 69 | 70 |

Fixed app crash that happens when the target directory for desktop files does not exist.

71 |
72 |
73 | 74 | 75 |

Added preferences page that can handle color scheme and form validation.

76 |

Added a status view when filtering does not return any result, or no shortcuts have been 77 | created using the app yet. 78 |

79 |

Limited access to only the desktop files created by Shortcut.

80 |
81 |
82 | 83 | 84 |

Added 'Manage' mode to delete and edit shortcuts.

85 |

Please note that shortcuts created by previous versions of the app need to be first 86 | saved from editing mode before they will be detected as Shortcut managed.

87 |
88 |
89 | 90 | 91 |

Added 'Manage' mode to delete and edit shortcuts.

92 |
93 |
94 | 95 | 96 |

Bug fixed for flathub build.

97 |
98 |
99 | 100 | 101 |

Various fixes regarding around error toasts.

102 |
103 |
104 | 105 | 106 |

Alpha version of Shortcuts. The only mode is Quick mode - which is targeted at users that 107 | simply want to pin a new application to their app 108 | launcher.

109 |
110 |
111 |
112 |
113 | -------------------------------------------------------------------------------- /data/io.github.andreibachim.shortcut.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 | -------------------------------------------------------------------------------- /data/resources.gresource.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | io.github.andreibachim.shortcut.svg 5 | resources/icons/image-missing-symbolic.svg 7 | 8 | 9 | resources/ui/keyboard_shortcuts.ui 12 | resources/ui/preferences.ui 15 | resources/ui/completed.ui 18 | resources/ui/landing.ui 21 | resources/ui/quick_mode.ui 24 | resources/ui/manage.ui 27 | resources/ui/component/viewport.ui 30 | resources/ui/component/entry.ui 33 | resources/ui/component/nav_view.ui 36 | resources/ui/component/menu.ui 39 | 40 | 41 | -------------------------------------------------------------------------------- /data/resources/icons/image-missing-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /data/resources/ui/completed.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 47 | -------------------------------------------------------------------------------- /data/resources/ui/component/entry.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 78 | -------------------------------------------------------------------------------- /data/resources/ui/component/menu.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 14 | Preferences 15 | app.preferences 16 | 17 | 18 | Keyboard shortcuts 19 | app.shortcuts 20 | 21 | 22 | About Shortcut 23 | app.about 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /data/resources/ui/component/nav_view.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | New 13 | page-3 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | The third page 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /data/resources/ui/component/viewport.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 58 | -------------------------------------------------------------------------------- /data/resources/ui/keyboard_shortcuts.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | True 5 | 6 | 7 | shortcuts 8 | 8 9 | 10 | 11 | General 12 | 13 | 14 | Preferences 15 | <ctrl>comma 16 | 17 | 18 | 19 | 20 | Keyboard shortcuts 21 | <ctrl>question 22 | 23 | 24 | 25 | 26 | Close 27 | <ctrl>Q 28 | 29 | 30 | 31 | 32 | 33 | 34 | Shortcuts list 35 | 36 | 37 | New 38 | <ctrl>n 39 | 40 | 41 | 42 | 43 | Reload 44 | <ctrl>r 45 | 46 | 47 | 48 | 49 | Search 50 | <ctrl>f 51 | 52 | 53 | 54 | 55 | 56 | 57 | Create 58 | 59 | 60 | Save 61 | <alt>s 62 | 63 | 64 | 65 | 66 | Back 67 | BackSpace 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /data/resources/ui/landing.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 81 | 82 | -------------------------------------------------------------------------------- /data/resources/ui/manage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 137 | 138 | -------------------------------------------------------------------------------- /data/resources/ui/preferences.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Application 9 | 10 | 11 | Color scheme 12 | 13 | 14 | 15 | System 16 | Dark 17 | Light 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Create view 28 | 29 | 30 | Form validation 31 | 32 | 33 | true 34 | center 35 | 38 | 39 | 40 | true 41 | start 42 | vertical 43 | center 44 | 45 | 46 | Enable form validation 47 | start 48 | 3 49 | 52 | 53 | 54 | 55 | 56 | Disable this for additional flexibility when creating shortcuts 57 | start 58 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | end 68 | false 69 | center 70 | false 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /data/resources/ui/quick_mode.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 158 | 159 | -------------------------------------------------------------------------------- /data/screenshots/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andreibachim/shortcut/0b818763803d3f78c7fa4d8fe2db238a96ae2b92/data/screenshots/screenshot1.png -------------------------------------------------------------------------------- /data/screenshots/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andreibachim/shortcut/0b818763803d3f78c7fa4d8fe2db238a96ae2b92/data/screenshots/screenshot2.png -------------------------------------------------------------------------------- /data/screenshots/screenshot3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andreibachim/shortcut/0b818763803d3f78c7fa4d8fe2db238a96ae2b92/data/screenshots/screenshot3.png -------------------------------------------------------------------------------- /data/screenshots/screenshot4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andreibachim/shortcut/0b818763803d3f78c7fa4d8fe2db238a96ae2b92/data/screenshots/screenshot4.png -------------------------------------------------------------------------------- /io.github.andreibachim.shortcut.yml: -------------------------------------------------------------------------------- 1 | app-id: io.github.andreibachim.shortcut 2 | runtime: org.gnome.Platform 3 | runtime-version: '47' 4 | sdk: org.gnome.Sdk 5 | sdk-extensions: 6 | - org.freedesktop.Sdk.Extension.rust-stable 7 | 8 | command: shortcut 9 | 10 | build-options: 11 | append-path: '/usr/lib/sdk/rust-stable/bin' 12 | build-args: 13 | - --share=network 14 | env: 15 | CARGO_HOME: run/build/shortcut/cargo 16 | 17 | finish-args: 18 | - '--socket=wayland' 19 | - '--socket=fallback-x11' 20 | - '--share=ipc' 21 | - '--device=dri' 22 | - '--filesystem=host' 23 | 24 | modules: 25 | - name: shortcut 26 | buildsystem: simple 27 | build-commands: 28 | - cargo build --release 29 | - install -D target/release/shortcut /app/bin/shortcut 30 | - install -D data/io.github.andreibachim.shortcut.svg /app/share/icons/hicolor/scalable/apps/io.github.andreibachim.shortcut.svg 31 | - install -D data/io.github.andreibachim.shortcut.desktop /app/share/applications/io.github.andreibachim.shortcut.desktop 32 | - install -D data/io.github.andreibachim.shortcut.metainfo.xml /app/share/metainfo/io.github.andreibachim.shortcut.appdata.xml 33 | - install -D data/io.github.andreibachim.shortcut.gschema.xml /app/share/glib-2.0/schemas/io.github.andreibachim.shortcut.gschema.xml 34 | - glib-compile-schemas /app/share/glib-2.0/schemas/ 35 | 36 | sources: 37 | - type: dir 38 | path: . 39 | -------------------------------------------------------------------------------- /scripts/flatpak-cargo-generator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | __license__ = 'MIT' 4 | import json 5 | from urllib.parse import urlparse, ParseResult, parse_qs 6 | import os 7 | import contextlib 8 | import copy 9 | import glob 10 | import subprocess 11 | import argparse 12 | import logging 13 | import hashlib 14 | import asyncio 15 | from typing import Any, Dict, List, NamedTuple, Optional, Tuple, TypedDict 16 | 17 | import aiohttp 18 | import toml 19 | 20 | CRATES_IO = 'https://static.crates.io/crates' 21 | CARGO_HOME = 'cargo' 22 | CARGO_CRATES = f'{CARGO_HOME}/vendor' 23 | VENDORED_SOURCES = 'vendored-sources' 24 | GIT_CACHE = 'flatpak-cargo/git' 25 | COMMIT_LEN = 7 26 | 27 | 28 | @contextlib.contextmanager 29 | def workdir(path: str): 30 | oldpath = os.getcwd() 31 | os.chdir(path) 32 | try: 33 | yield 34 | finally: 35 | os.chdir(oldpath) 36 | 37 | 38 | def canonical_url(url: str) -> ParseResult: 39 | 'Converts a string to a Cargo Canonical URL, as per https://github.com/rust-lang/cargo/blob/35c55a93200c84a4de4627f1770f76a8ad268a39/src/cargo/util/canonical_url.rs#L19' 40 | # Hrm. The upstream cargo does not replace those URLs, but if we don't then it doesn't work too well :( 41 | url = url.replace('git+https://', 'https://') 42 | u = urlparse(url) 43 | # It seems cargo drops query and fragment 44 | u = ParseResult(u.scheme, u.netloc, u.path, '', '', '') 45 | u = u._replace(path = u.path.rstrip('/')) 46 | 47 | if u.netloc == 'github.com': 48 | u = u._replace(scheme = 'https') 49 | u = u._replace(path = u.path.lower()) 50 | 51 | if u.path.endswith('.git'): 52 | u = u._replace(path = u.path[:-len('.git')]) 53 | 54 | return u 55 | 56 | 57 | def get_git_tarball(repo_url: str, commit: str) -> str: 58 | url = canonical_url(repo_url) 59 | path = url.path.split('/')[1:] 60 | 61 | assert len(path) == 2 62 | owner = path[0] 63 | if path[1].endswith('.git'): 64 | repo = path[1].replace('.git', '') 65 | else: 66 | repo = path[1] 67 | if url.hostname == 'github.com': 68 | return f'https://codeload.{url.hostname}/{owner}/{repo}/tar.gz/{commit}' 69 | elif url.hostname.split('.')[0] == 'gitlab': # type: ignore 70 | return f'https://{url.hostname}/{owner}/{repo}/-/archive/{commit}/{repo}-{commit}.tar.gz' 71 | elif url.hostname == 'bitbucket.org': 72 | return f'https://{url.hostname}/{owner}/{repo}/get/{commit}.tar.gz' 73 | else: 74 | raise ValueError(f'Don\'t know how to get tarball for {repo_url}') 75 | 76 | 77 | async def get_remote_sha256(url: str) -> str: 78 | logging.info(f"started sha256({url})") 79 | sha256 = hashlib.sha256() 80 | async with aiohttp.ClientSession(raise_for_status=True) as http_session: 81 | async with http_session.get(url) as response: 82 | while True: 83 | data = await response.content.read(4096) 84 | if not data: 85 | break 86 | sha256.update(data) 87 | logging.info(f"done sha256({url})") 88 | return sha256.hexdigest() 89 | 90 | 91 | _TomlType = Dict[str, Any] 92 | 93 | 94 | def load_toml(tomlfile: str = 'Cargo.lock') -> _TomlType: 95 | with open(tomlfile, 'r') as f: 96 | toml_data = toml.load(f) 97 | return toml_data 98 | 99 | 100 | def git_repo_name(git_url: str, commit: str) -> str: 101 | name = canonical_url(git_url).path.split('/')[-1] 102 | return f'{name}-{commit[:COMMIT_LEN]}' 103 | 104 | 105 | def fetch_git_repo(git_url: str, commit: str) -> str: 106 | repo_dir = git_url.replace('://', '_').replace('/', '_') 107 | cache_dir = os.environ.get('XDG_CACHE_HOME', os.path.expanduser('~/.cache')) 108 | clone_dir = os.path.join(cache_dir, 'flatpak-cargo', repo_dir) 109 | if not os.path.isdir(os.path.join(clone_dir, '.git')): 110 | subprocess.run(['git', 'clone', '--depth=1', git_url, clone_dir], check=True) 111 | rev_parse_proc = subprocess.run(['git', 'rev-parse', 'HEAD'], cwd=clone_dir, check=True, 112 | stdout=subprocess.PIPE) 113 | head = rev_parse_proc.stdout.decode().strip() 114 | if head[:COMMIT_LEN] != commit[:COMMIT_LEN]: 115 | subprocess.run(['git', 'fetch', 'origin', commit], cwd=clone_dir, check=True) 116 | subprocess.run(['git', 'checkout', commit], cwd=clone_dir, check=True) 117 | return clone_dir 118 | 119 | 120 | class _GitPackage(NamedTuple): 121 | path: str 122 | package: _TomlType 123 | workspace: Optional[_TomlType] 124 | 125 | @property 126 | def normalized(self) -> _TomlType: 127 | package = copy.deepcopy(self.package) 128 | if self.workspace is None: 129 | return package 130 | for section_key, section in package.items(): 131 | # XXX We ignore top-level lists here; maybe we should iterate over list items, too 132 | if not isinstance(section, dict): 133 | continue 134 | for key, value in section.items(): 135 | if not isinstance(value, dict): 136 | continue 137 | if not value.get('workspace'): 138 | continue 139 | package[section_key][key] = self.workspace[section_key][key] 140 | return package 141 | 142 | 143 | _GitPackagesType = Dict[str, _GitPackage] 144 | 145 | 146 | async def get_git_repo_packages(git_url: str, commit: str) -> _GitPackagesType: 147 | logging.info('Loading packages from %s', git_url) 148 | git_repo_dir = fetch_git_repo(git_url, commit) 149 | packages: _GitPackagesType = {} 150 | 151 | with workdir(git_repo_dir): 152 | if os.path.isfile('Cargo.toml'): 153 | packages.update(await get_cargo_toml_packages(load_toml('Cargo.toml'), '.')) 154 | else: 155 | for toml_path in glob.glob('*/Cargo.toml'): 156 | packages.update(await get_cargo_toml_packages(load_toml(toml_path), 157 | os.path.dirname(toml_path))) 158 | 159 | assert packages, f"No packages found in {git_repo_dir}" 160 | logging.debug( 161 | 'Packages in %s:\n%s', 162 | git_url, 163 | json.dumps( 164 | {k: v.path for k, v in packages.items()}, 165 | indent=4, 166 | ), 167 | ) 168 | return packages 169 | 170 | 171 | async def get_cargo_toml_packages(root_toml: _TomlType, root_dir: str) -> _GitPackagesType: 172 | assert not os.path.isabs(root_dir) and os.path.isdir(root_dir) 173 | assert 'package' in root_toml or 'workspace' in root_toml 174 | packages: _GitPackagesType = {} 175 | 176 | async def get_dep_packages( 177 | entry: _TomlType, 178 | toml_dir: str, 179 | workspace: Optional[_TomlType] = None, 180 | ): 181 | assert not os.path.isabs(toml_dir) 182 | # https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html 183 | if 'dependencies' in entry: 184 | for dep_name, dep in entry['dependencies'].items(): 185 | if 'package' in dep: 186 | dep_name = dep['package'] 187 | if 'path' not in dep: 188 | continue 189 | if dep_name in packages: 190 | continue 191 | dep_dir = os.path.normpath(os.path.join(toml_dir, dep['path'])) 192 | logging.debug("Loading dependency %s from %s", dep_name, dep_dir) 193 | dep_toml = load_toml(os.path.join(dep_dir, 'Cargo.toml')) 194 | assert dep_toml['package']['name'] == dep_name, toml_dir 195 | await get_dep_packages(dep_toml, dep_dir, workspace) 196 | packages[dep_name] = _GitPackage( 197 | path=dep_dir, 198 | package=dep, 199 | workspace=workspace, 200 | ) 201 | if 'target' in entry: 202 | for _, target in entry['target'].items(): 203 | await get_dep_packages(target, toml_dir) 204 | 205 | if 'package' in root_toml: 206 | await get_dep_packages(root_toml, root_dir) 207 | packages[root_toml['package']['name']] = _GitPackage( 208 | path=root_dir, 209 | package=root_toml, 210 | workspace=None, 211 | ) 212 | 213 | if 'workspace' in root_toml: 214 | for member in root_toml['workspace'].get('members', []): 215 | for subpkg_toml in glob.glob(os.path.join(root_dir, member, 'Cargo.toml')): 216 | subpkg = os.path.normpath(os.path.dirname(subpkg_toml)) 217 | logging.debug( 218 | "Loading workspace member %s in %s", 219 | subpkg_toml, 220 | os.path.abspath(root_dir), 221 | ) 222 | pkg_toml = load_toml(subpkg_toml) 223 | await get_dep_packages(pkg_toml, subpkg, root_toml['workspace']) 224 | packages[pkg_toml['package']['name']] = _GitPackage( 225 | path=subpkg, 226 | package=pkg_toml, 227 | workspace=root_toml['workspace'], 228 | ) 229 | 230 | return packages 231 | 232 | 233 | _FlatpakSourceType = Dict[str, Any] 234 | 235 | 236 | async def get_git_repo_sources( 237 | url: str, 238 | commit: str, 239 | tarball: bool = False, 240 | ) -> List[_FlatpakSourceType]: 241 | name = git_repo_name(url, commit) 242 | if tarball: 243 | tarball_url = get_git_tarball(url, commit) 244 | git_repo_sources = [{ 245 | 'type': 'archive', 246 | 'archive-type': 'tar-gzip', 247 | 'url': tarball_url, 248 | 'sha256': await get_remote_sha256(tarball_url), 249 | 'dest': f'{GIT_CACHE}/{name}', 250 | }] 251 | else: 252 | git_repo_sources = [{ 253 | 'type': 'git', 254 | 'url': url, 255 | 'commit': commit, 256 | 'dest': f'{GIT_CACHE}/{name}', 257 | }] 258 | return git_repo_sources 259 | 260 | 261 | _GitRepo = TypedDict('_GitRepo', {'lock': asyncio.Lock, 'commits': Dict[str, _GitPackagesType]}) 262 | _GitReposType = Dict[str, _GitRepo] 263 | _VendorEntryType = Dict[str, Dict[str, str]] 264 | 265 | 266 | async def get_git_package_sources( 267 | package: _TomlType, 268 | git_repos: _GitReposType, 269 | ) -> Tuple[List[_FlatpakSourceType], _VendorEntryType]: 270 | name = package['name'] 271 | source = package['source'] 272 | commit = urlparse(source).fragment 273 | assert commit, 'The commit needs to be indicated in the fragement part' 274 | canonical = canonical_url(source) 275 | repo_url = canonical.geturl() 276 | 277 | git_repo = git_repos.setdefault(repo_url, { 278 | 'commits': {}, 279 | 'lock': asyncio.Lock(), 280 | }) 281 | async with git_repo['lock']: 282 | if commit not in git_repo['commits']: 283 | git_repo['commits'][commit] = await get_git_repo_packages(repo_url, commit) 284 | 285 | cargo_vendored_entry: _VendorEntryType = { 286 | repo_url: { 287 | 'git': repo_url, 288 | 'replace-with': VENDORED_SOURCES, 289 | } 290 | } 291 | rev = parse_qs(urlparse(source).query).get('rev') 292 | tag = parse_qs(urlparse(source).query).get('tag') 293 | branch = parse_qs(urlparse(source).query).get('branch') 294 | if rev: 295 | assert len(rev) == 1 296 | cargo_vendored_entry[repo_url]['rev'] = rev[0] 297 | elif tag: 298 | assert len(tag) == 1 299 | cargo_vendored_entry[repo_url]['tag'] = tag[0] 300 | elif branch: 301 | assert len(branch) == 1 302 | cargo_vendored_entry[repo_url]['branch'] = branch[0] 303 | 304 | logging.info("Adding package %s from %s", name, repo_url) 305 | git_pkg = git_repo['commits'][commit][name] 306 | pkg_repo_dir = os.path.join(GIT_CACHE, git_repo_name(repo_url, commit), git_pkg.path) 307 | git_sources: List[_FlatpakSourceType] = [ 308 | { 309 | 'type': 'shell', 310 | 'commands': [ 311 | f'cp -r --reflink=auto "{pkg_repo_dir}" "{CARGO_CRATES}/{name}"' 312 | ], 313 | }, 314 | { 315 | 'type': 'inline', 316 | 'contents': toml.dumps(git_pkg.normalized), 317 | 'dest': f'{CARGO_CRATES}/{name}', #-{version}', 318 | 'dest-filename': 'Cargo.toml', 319 | }, 320 | { 321 | 'type': 'inline', 322 | 'contents': json.dumps({'package': None, 'files': {}}), 323 | 'dest': f'{CARGO_CRATES}/{name}', #-{version}', 324 | 'dest-filename': '.cargo-checksum.json', 325 | } 326 | ] 327 | 328 | return (git_sources, cargo_vendored_entry) 329 | 330 | 331 | async def get_package_sources( 332 | package: _TomlType, 333 | cargo_lock: _TomlType, 334 | git_repos: _GitReposType, 335 | ) -> Optional[Tuple[List[_FlatpakSourceType], _VendorEntryType]]: 336 | metadata = cargo_lock.get('metadata') 337 | name = package['name'] 338 | version = package['version'] 339 | 340 | if 'source' not in package: 341 | logging.debug('%s has no source', name) 342 | return None 343 | source = package['source'] 344 | 345 | if source.startswith('git+'): 346 | return await get_git_package_sources(package, git_repos) 347 | 348 | key = f'checksum {name} {version} ({source})' 349 | if metadata is not None and key in metadata: 350 | checksum = metadata[key] 351 | elif 'checksum' in package: 352 | checksum = package['checksum'] 353 | else: 354 | logging.warning(f'{name} doesn\'t have checksum') 355 | return None 356 | crate_sources = [ 357 | { 358 | 'type': 'archive', 359 | 'archive-type': 'tar-gzip', 360 | 'url': f'{CRATES_IO}/{name}/{name}-{version}.crate', 361 | 'sha256': checksum, 362 | 'dest': f'{CARGO_CRATES}/{name}-{version}', 363 | }, 364 | { 365 | 'type': 'inline', 366 | 'contents': json.dumps({'package': checksum, 'files': {}}), 367 | 'dest': f'{CARGO_CRATES}/{name}-{version}', 368 | 'dest-filename': '.cargo-checksum.json', 369 | }, 370 | ] 371 | return (crate_sources, {'crates-io': {'replace-with': VENDORED_SOURCES}}) 372 | 373 | 374 | async def generate_sources( 375 | cargo_lock: _TomlType, 376 | git_tarballs: bool = False, 377 | ) -> List[_FlatpakSourceType]: 378 | # { 379 | # "git-repo-url": { 380 | # "lock": asyncio.Lock(), 381 | # "commits": { 382 | # "commit-hash": { 383 | # "package-name": "./relative/package/path" 384 | # } 385 | # } 386 | # } 387 | # } 388 | git_repos: _GitReposType = {} 389 | sources: List[_FlatpakSourceType] = [] 390 | package_sources = [] 391 | cargo_vendored_sources = { 392 | VENDORED_SOURCES: {'directory': f'{CARGO_CRATES}'}, 393 | } 394 | 395 | pkg_coros = [get_package_sources(p, cargo_lock, git_repos) for p in cargo_lock['package']] 396 | for pkg in await asyncio.gather(*pkg_coros): 397 | if pkg is None: 398 | continue 399 | else: 400 | pkg_sources, cargo_vendored_entry = pkg 401 | package_sources.extend(pkg_sources) 402 | cargo_vendored_sources.update(cargo_vendored_entry) 403 | 404 | logging.debug('Adding collected git repos:\n%s', json.dumps(list(git_repos), indent=4)) 405 | git_repo_coros = [] 406 | for git_url, git_repo in git_repos.items(): 407 | for git_commit in git_repo['commits']: 408 | git_repo_coros.append(get_git_repo_sources(git_url, git_commit, git_tarballs)) 409 | sources.extend(sum(await asyncio.gather(*git_repo_coros), [])) 410 | 411 | sources.extend(package_sources) 412 | 413 | logging.debug('Vendored sources:\n%s', json.dumps(cargo_vendored_sources, indent=4)) 414 | sources.append({ 415 | 'type': 'inline', 416 | 'contents': toml.dumps({ 417 | 'source': cargo_vendored_sources, 418 | }), 419 | 'dest': CARGO_HOME, 420 | 'dest-filename': 'config' 421 | }) 422 | return sources 423 | 424 | 425 | def main(): 426 | parser = argparse.ArgumentParser() 427 | parser.add_argument('cargo_lock', help='Path to the Cargo.lock file') 428 | parser.add_argument('-o', '--output', required=False, help='Where to write generated sources') 429 | parser.add_argument('-t', '--git-tarballs', action='store_true', help='Download git repos as tarballs') 430 | parser.add_argument('-d', '--debug', action='store_true') 431 | args = parser.parse_args() 432 | if args.output is not None: 433 | outfile = args.output 434 | else: 435 | outfile = 'generated-sources.json' 436 | if args.debug: 437 | loglevel = logging.DEBUG 438 | else: 439 | loglevel = logging.INFO 440 | logging.basicConfig(level=loglevel) 441 | 442 | generated_sources = asyncio.run(generate_sources(load_toml(args.cargo_lock), 443 | git_tarballs=args.git_tarballs)) 444 | with open(outfile, 'w') as out: 445 | json.dump(generated_sources, out, indent=4, sort_keys=False) 446 | 447 | 448 | if __name__ == '__main__': 449 | main() 450 | -------------------------------------------------------------------------------- /scripts/generate-sources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | python3 flatpak-cargo-generator.py ../Cargo.lock -o generated-sources.json -------------------------------------------------------------------------------- /snap/gui/shortcut-app.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Shortcut 3 | Comment=Make app shortcuts 4 | Exec=shortcut-app 5 | Icon=${SNAP}/meta/gui/shortcut-app.svg 6 | Terminal=false 7 | Type=Application 8 | Categories=Utility;GTK;GNOME; 9 | Keywords=Shortcut;Icons;Pin;Launch; 10 | -------------------------------------------------------------------------------- /snap/gui/shortcut-app.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 | -------------------------------------------------------------------------------- /snap/snapcraft.yaml: -------------------------------------------------------------------------------- 1 | name: shortcut-app 2 | version: '0.4.0' 3 | summary: Make app shortcuts 4 | description: | 5 | Shortcut is a tool that allows users to quickly pin executable files to their app launcher. 6 | It guides users throught the process by providing file pickers with relevant filters, input validation, and name and icon previews. 7 | 8 | base: core22 9 | grade: stable #devel 10 | confinement: strict #devmode 11 | architectures: [amd64, arm64, armhf] 12 | 13 | plugs: 14 | target-dir: 15 | interface: personal-files 16 | write: 17 | - $HOME/.local/share/applications 18 | home: 19 | interface: home 20 | 21 | parts: 22 | rust-deps: 23 | plugin: nil 24 | build-packages: 25 | - curl 26 | override-pull: | 27 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y 28 | shortcut-app: 29 | after: [rust-deps] 30 | build-packages: [cargo, rustc] 31 | plugin: rust 32 | source: . 33 | compile-schemas: 34 | after: [shortcut-app] 35 | plugin: dump 36 | source: . 37 | organize: 38 | data/io.github.andreibachim.shortcut.gschema.xml: usr/share/glib-2.0/schemas/io.github.andreibachim.shortcut.gschema.xml 39 | override-prime: | 40 | craftctl default 41 | glib-compile-schemas usr/share/glib-2.0/schemas 42 | 43 | apps: 44 | shortcut-app: 45 | extensions: [gnome] 46 | command: bin/shortcut 47 | -------------------------------------------------------------------------------- /src/component/entry.rs: -------------------------------------------------------------------------------- 1 | mod imp { 2 | use adw::subclass::preferences_row::PreferencesRowImpl; 3 | use gtk::glib::subclass::InitializingObject; 4 | use gtk::subclass::prelude::*; 5 | use gtk::{glib, CompositeTemplate}; 6 | 7 | #[derive(CompositeTemplate, Default)] 8 | #[template(resource = "/io/github/andreibachim/shortcut/component/entry.ui")] 9 | pub struct Entry { 10 | #[template_child] 11 | pub app_icon: TemplateChild, 12 | #[template_child] 13 | pub title: TemplateChild, 14 | #[template_child] 15 | pub subtitle: TemplateChild, 16 | #[template_child] 17 | pub delete_button: TemplateChild, 18 | #[template_child] 19 | pub edit_button: TemplateChild, 20 | } 21 | 22 | #[glib::object_subclass] 23 | impl ObjectSubclass for Entry { 24 | const NAME: &'static str = "Entry"; 25 | type Type = super::Entry; 26 | type ParentType = adw::PreferencesRow; 27 | 28 | fn class_init(klass: &mut Self::Class) { 29 | klass.bind_template(); 30 | } 31 | 32 | fn instance_init(obj: &InitializingObject) { 33 | obj.init_template(); 34 | } 35 | } 36 | 37 | impl ObjectImpl for Entry {} 38 | impl WidgetImpl for Entry {} 39 | impl ListBoxRowImpl for Entry {} 40 | impl PreferencesRowImpl for Entry {} 41 | } 42 | 43 | use adw::prelude::WidgetExt; 44 | use glib::Object; 45 | use gtk::{ 46 | glib, 47 | prelude::{ActionableExtManual, ToVariant}, 48 | subclass::prelude::ObjectSubclassIsExt, 49 | }; 50 | 51 | glib::wrapper! { 52 | pub struct Entry(ObjectSubclass) 53 | @extends adw::PreferencesRow, gtk::Widget, 54 | @implements gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget; 55 | } 56 | 57 | impl Entry { 58 | pub fn new( 59 | title: Option<&str>, 60 | subtitle: Option<&str>, 61 | icon_path: Option<&str>, 62 | exec_path: Option<&str>, 63 | ) -> Self { 64 | let slf = Object::builder::().build(); 65 | let imp = slf.imp(); 66 | 67 | let name = title.unwrap_or("").trim(); 68 | let subtitle_text = subtitle.unwrap_or("").trim(); 69 | let icon_path_str = icon_path.unwrap_or(""); 70 | let exec_path_str = exec_path.unwrap_or(""); 71 | 72 | let _ = crate::function::set_icon(&imp.app_icon.get(), icon_path, true); 73 | 74 | imp.title.set_label(title.unwrap_or("")); 75 | imp.subtitle 76 | .set_label(&format!("{}", subtitle_text)); 77 | imp.subtitle.set_tooltip_text(Some(subtitle_text)); 78 | 79 | imp.delete_button 80 | .set_action_target(Some(&(subtitle_text, name).to_variant())); 81 | imp.edit_button 82 | .set_action_target(Some(&(name, icon_path_str, exec_path_str).to_variant())); 83 | 84 | slf 85 | } 86 | 87 | pub fn get_name(&self) -> String { 88 | self.imp().title.text().to_string() 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/component/menu.rs: -------------------------------------------------------------------------------- 1 | mod imp { 2 | use adw::subclass::prelude::BinImpl; 3 | use gtk::glib::subclass::InitializingObject; 4 | use gtk::subclass::prelude::*; 5 | use gtk::{glib, CompositeTemplate}; 6 | 7 | #[derive(CompositeTemplate, Default)] 8 | #[template(resource = "/io/github/andreibachim/shortcut/component/menu.ui")] 9 | pub struct Menu {} 10 | 11 | #[glib::object_subclass] 12 | impl ObjectSubclass for Menu { 13 | const NAME: &'static str = "Menu"; 14 | type Type = super::Menu; 15 | type ParentType = adw::Bin; 16 | 17 | fn class_init(klass: &mut Self::Class) { 18 | klass.bind_template(); 19 | } 20 | 21 | fn instance_init(obj: &InitializingObject) { 22 | obj.init_template(); 23 | } 24 | } 25 | 26 | impl ObjectImpl for Menu {} 27 | impl WidgetImpl for Menu {} 28 | impl BinImpl for Menu {} 29 | } 30 | 31 | use gtk::glib; 32 | 33 | glib::wrapper! { 34 | pub struct Menu(ObjectSubclass) 35 | @extends adw::Bin, gtk::Widget, 36 | @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; 37 | } 38 | -------------------------------------------------------------------------------- /src/component/mod.rs: -------------------------------------------------------------------------------- 1 | mod entry; 2 | pub use entry::Entry; 3 | 4 | mod menu; 5 | pub use menu::Menu; 6 | -------------------------------------------------------------------------------- /src/function/icon.rs: -------------------------------------------------------------------------------- 1 | use anyhow::anyhow; 2 | use std::path::{Path, PathBuf}; 3 | 4 | pub fn set_icon( 5 | image: >k::Image, 6 | icon_path: Option<&str>, 7 | use_placeholder: bool, 8 | ) -> anyhow::Result<()> { 9 | if let Some(icon_path) = icon_path { 10 | if PathBuf::from(icon_path).is_absolute() { 11 | if Path::new(icon_path).exists() { 12 | image.set_from_file(Some(icon_path)); 13 | } else if use_placeholder { 14 | set_placeholder_icon(image); 15 | } else { 16 | return Err(anyhow!("No icon found at given path")); 17 | } 18 | } else { 19 | let themed_icon = gtk::gio::ThemedIcon::from_names(&[icon_path]); 20 | if gtk::IconTheme::default().has_gicon(&themed_icon) { 21 | image.set_from_gicon(&themed_icon); 22 | } else { 23 | return Err(anyhow!("The relative path does not point to any icon")); 24 | } 25 | } 26 | } else if use_placeholder { 27 | set_placeholder_icon(image); 28 | } else { 29 | return Err(anyhow!("Given path is 'None'")); 30 | }; 31 | Ok(()) 32 | } 33 | 34 | fn set_placeholder_icon(image: >k::Image) { 35 | let themed_icon = gtk::gio::ThemedIcon::from_names(&["application-x-executable"]); 36 | image.set_from_gicon(&themed_icon); 37 | } 38 | -------------------------------------------------------------------------------- /src/function/mod.rs: -------------------------------------------------------------------------------- 1 | mod icon; 2 | pub use icon::set_icon; 3 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | mod component; 2 | mod function; 3 | mod model; 4 | mod view; 5 | 6 | use component::Menu; 7 | use gtk::{ 8 | glib::{clone, VariantTy}, 9 | prelude::{ 10 | ActionMapExtManual, ApplicationExt, ApplicationExtManual, Cast, GtkApplicationExt, 11 | GtkWindowExt, SettingsExt, SettingsExtManual, StaticType, 12 | }, 13 | }; 14 | 15 | use crate::glib::variant::FromVariant; 16 | use crate::glib::variant::StaticVariantType; 17 | use adw::prelude::ComboRowExt; 18 | use adw::{prelude::AdwApplicationWindowExt, prelude::AdwDialogExt}; 19 | use gtk::glib; 20 | use view::{Manage, QuickMode}; 21 | 22 | const APP_ID: &str = "io.github.andreibachim.shortcut"; 23 | 24 | fn main() -> gtk::glib::ExitCode { 25 | gtk::gio::resources_register_include!("shortcut.gresource").expect("Could not load resources"); 26 | 27 | let app = adw::Application::builder().application_id(APP_ID).build(); 28 | app.connect_activate(build_window); 29 | setup_actions(&app); 30 | app.run() 31 | } 32 | 33 | fn build_window(app: &adw::Application) { 34 | let settings = gtk::gio::Settings::new(APP_ID); 35 | set_color_scheme(settings.uint("color-scheme")); 36 | 37 | let window = adw::ApplicationWindow::builder() 38 | .application(app) 39 | .default_width(1000) 40 | .default_height(700) 41 | .icon_name(APP_ID) 42 | .title("Shortcut") 43 | .build(); 44 | 45 | window.set_content(Some(&build_content(&window))); 46 | setup_toasts_action(&window); 47 | 48 | window.present(); 49 | } 50 | 51 | fn build_content(window: &adw::ApplicationWindow) -> impl gtk::prelude::IsA { 52 | Manage::static_type(); 53 | QuickMode::static_type(); 54 | Menu::static_type(); 55 | 56 | let nav_view: adw::NavigationView = 57 | gtk::Builder::from_resource("/io/github/andreibachim/shortcut/component/nav_view.ui") 58 | .object("nav_view") 59 | .unwrap(); 60 | 61 | setup_nav_actions(window, &nav_view); 62 | let toast_overlay = adw::ToastOverlay::new(); 63 | toast_overlay.set_child(Some(&nav_view)); 64 | toast_overlay 65 | } 66 | 67 | fn setup_nav_actions(window: &adw::ApplicationWindow, nav_view: &adw::NavigationView) { 68 | let load_quick_mode = gtk::gio::ActionEntry::builder("load_quick_mode") 69 | .parameter_type(Some(&<(String, String, String)>::static_variant_type())) 70 | .activate(clone!( 71 | #[weak] 72 | nav_view, 73 | move |_, _, params| { 74 | let (name, icon_path, exec_path) = 75 | <(String, String, String)>::from_variant(params.unwrap()).unwrap(); 76 | let quick_mode_page = nav_view 77 | .find_page("quick_mode") 78 | .unwrap() 79 | .dynamic_cast::() 80 | .unwrap(); 81 | quick_mode_page.clear_data(); 82 | quick_mode_page.edit_details(Some(name), Some(icon_path), Some(exec_path)); 83 | nav_view.push_by_tag("quick_mode"); 84 | } 85 | )) 86 | .build(); 87 | 88 | window.add_action_entries([load_quick_mode]); 89 | } 90 | 91 | fn setup_toasts_action(window: &adw::ApplicationWindow) { 92 | let show_toast = gtk::gio::ActionEntry::builder("show_toast") 93 | .parameter_type(Some(VariantTy::STRING)) 94 | .activate(|window: &adw::ApplicationWindow, _, message| { 95 | let message = String::from_variant(message.unwrap()).unwrap(); 96 | let toast_overlay: adw::ToastOverlay = window 97 | .content() 98 | .unwrap() 99 | .dynamic_cast::() 100 | .unwrap(); 101 | toast_overlay.add_toast(adw::Toast::new(&message)); 102 | }) 103 | .build(); 104 | 105 | window.add_action_entries([show_toast]); 106 | } 107 | 108 | fn setup_actions(app: &adw::Application) { 109 | let quit = gtk::gio::ActionEntry::builder("quit") 110 | .activate(|app: &adw::Application, _, _| app.quit()) 111 | .build(); 112 | 113 | let preferences = gtk::gio::ActionEntry::builder("preferences") 114 | .activate(|app: &adw::Application, _, _| { 115 | let settings = gtk::gio::Settings::new(APP_ID); 116 | 117 | let preferences_builder = 118 | gtk::Builder::from_resource("/io/github/andreibachim/shortcut/preferences.ui"); 119 | 120 | let create_enable_validation: gtk::Switch = preferences_builder 121 | .object("create_enable_validation") 122 | .unwrap(); 123 | 124 | settings 125 | .bind( 126 | "create-enable-validation", 127 | &create_enable_validation, 128 | "active", 129 | ) 130 | .build(); 131 | 132 | let color_scheme: adw::ComboRow = preferences_builder.object("color_scheme").unwrap(); 133 | 134 | settings 135 | .bind("color-scheme", &color_scheme, "selected") 136 | .build(); 137 | 138 | color_scheme.connect_selected_notify(move |a| { 139 | let selected = a.selected(); 140 | set_color_scheme(selected); 141 | }); 142 | 143 | let preferences_dialog: adw::PreferencesDialog = 144 | preferences_builder.object("preferences").unwrap(); 145 | preferences_dialog.present(app.active_window().as_ref()); 146 | }) 147 | .build(); 148 | 149 | let about = gtk::gio::ActionEntry::builder("about") 150 | .activate(|app: &adw::Application, _, _| { 151 | let window = app.active_window().unwrap(); 152 | adw::AboutDialog::builder() 153 | .application_name("Shortcut") 154 | .application_icon(APP_ID) 155 | .website("https://github.com/andreibachim/shortcut") 156 | .issue_url("https://github.com/andreibachim/shortcut/issues") 157 | .version(env!("CARGO_PKG_VERSION")) 158 | .developers(["Andrei Achim "]) 159 | .license_type(gtk::License::Gpl30) 160 | .copyright("© 2025 Andrei Achim") 161 | .build() 162 | .present(Some(&window)); 163 | }) 164 | .build(); 165 | 166 | let keyboard_shortcuts = gtk::gio::ActionEntry::builder("shortcuts") 167 | .activate(|app: &adw::Application, _, _| { 168 | let shortcut_window: gtk::ShortcutsWindow = gtk::Builder::from_resource( 169 | "/io/github/andreibachim/shortcut/keyboard_shortcuts.ui", 170 | ) 171 | .object("keyboard_shortcuts") 172 | .unwrap(); 173 | shortcut_window.set_transient_for(app.active_window().as_ref()); 174 | shortcut_window.present(); 175 | }) 176 | .build(); 177 | 178 | app.set_accels_for_action("app.preferences", &["comma"]); 179 | app.set_accels_for_action("app.shortcuts", &["question"]); 180 | app.set_accels_for_action("app.quit", &["Q"]); 181 | app.add_action_entries([quit, preferences, keyboard_shortcuts, about]); 182 | } 183 | 184 | fn set_color_scheme(scheme: u32) { 185 | match scheme { 186 | 1 => adw::StyleManager::default().set_color_scheme(adw::ColorScheme::ForceDark), 187 | 2 => adw::StyleManager::default().set_color_scheme(adw::ColorScheme::ForceLight), 188 | _ => adw::StyleManager::default().set_color_scheme(adw::ColorScheme::Default), 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /src/model/desktop.rs: -------------------------------------------------------------------------------- 1 | use std::{error::Error, fmt::Write}; 2 | 3 | #[derive(Default, Debug)] 4 | pub struct Desktop { 5 | r#type: String, 6 | pub name: String, 7 | pub exec: String, 8 | pub icon: String, 9 | } 10 | 11 | impl Desktop { 12 | pub fn new() -> Self { 13 | Self { 14 | r#type: "Application".to_owned(), 15 | ..Default::default() 16 | } 17 | } 18 | 19 | pub fn get_output(&self) -> Result> { 20 | let mut output = String::new(); 21 | 22 | writeln!(&mut output, "[Desktop Entry]")?; 23 | writeln!(&mut output, "Type={}", self.r#type)?; 24 | writeln!(&mut output, "Name={}", self.name)?; 25 | writeln!(&mut output, "Exec=\"{}\"", self.exec)?; 26 | writeln!(&mut output, "Icon={}", self.icon)?; 27 | writeln!(&mut output, "X-Shortcut-App=true")?; 28 | 29 | Ok(output) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/model/mod.rs: -------------------------------------------------------------------------------- 1 | mod desktop; 2 | pub use desktop::Desktop; 3 | -------------------------------------------------------------------------------- /src/view/completed.rs: -------------------------------------------------------------------------------- 1 | mod imp { 2 | use std::cell::OnceCell; 3 | 4 | use gtk::glib::subclass::InitializingObject; 5 | use gtk::glib::{self, Sender}; 6 | use gtk::subclass::prelude::*; 7 | 8 | use gtk::CompositeTemplate; 9 | 10 | use crate::component::viewport::Action; 11 | 12 | // Object holding the state 13 | #[derive(CompositeTemplate, Default)] 14 | #[template(resource = "/io/github/andreibachim/shortcut/completed.ui")] 15 | pub struct Completed { 16 | pub sender: OnceCell>, 17 | } 18 | 19 | // The central trait for subclassing a GObject 20 | #[glib::object_subclass] 21 | impl ObjectSubclass for Completed { 22 | const NAME: &'static str = "Completed"; 23 | type Type = super::Completed; 24 | type ParentType = gtk::Box; 25 | 26 | fn class_init(klass: &mut Self::Class) { 27 | klass.bind_template(); 28 | 29 | klass.install_action("completed.main_menu", None, move |completed, _, _| { 30 | let imp = completed.imp(); 31 | let _ = imp.sender.get().unwrap().send(Action::Landing(false)); 32 | }); 33 | } 34 | fn instance_init(obj: &InitializingObject) { 35 | obj.init_template(); 36 | } 37 | } 38 | 39 | impl ObjectImpl for Completed {} 40 | impl WidgetImpl for Completed {} 41 | impl BoxImpl for Completed {} 42 | } 43 | 44 | use glib::Object; 45 | use gtk::{ 46 | glib::{self, Sender}, 47 | subclass::prelude::ObjectSubclassIsExt, 48 | traits::WidgetExt, 49 | }; 50 | 51 | use crate::component::viewport::Action; 52 | 53 | glib::wrapper! { 54 | pub struct ompleted(ObjectSubclass) 55 | @extends gtk::Box, gtk::Widget, 56 | @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; 57 | } 58 | 59 | impl Completed { 60 | pub fn new(sender: Sender) -> Self { 61 | let slf = Object::builder::().build(); 62 | slf.set_sensitive(false); 63 | let _ = slf.imp().sender.set(sender); 64 | slf 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/view/manage.rs: -------------------------------------------------------------------------------- 1 | mod imp { 2 | 3 | use adw::prelude::{AdwDialogExt, AlertDialogExt, AlertDialogExtManual, WidgetExt}; 4 | use adw::subclass::prelude::NavigationPageImpl; 5 | use gtk::gio::Cancellable; 6 | use gtk::glib::clone; 7 | use gtk::glib::subclass::InitializingObject; 8 | use gtk::prelude::FromVariant; 9 | use gtk::prelude::{CastNone, StaticType, StaticVariantType, ToVariant}; 10 | use gtk::subclass::prelude::*; 11 | use gtk::{glib, CompositeTemplate}; 12 | 13 | #[derive(CompositeTemplate, Default)] 14 | #[template(resource = "/io/github/andreibachim/shortcut/manage.ui")] 15 | pub struct Manage { 16 | #[template_child] 17 | pub header_bar: TemplateChild, 18 | #[template_child] 19 | pub app_list: TemplateChild, 20 | #[template_child] 21 | pub list_window: TemplateChild, 22 | #[template_child] 23 | pub status_page: TemplateChild, 24 | #[template_child] 25 | pub filter_entry: TemplateChild, 26 | } 27 | 28 | #[gtk::template_callbacks] 29 | impl Manage { 30 | #[template_callback] 31 | fn load(&self) { 32 | self.obj().load(false); 33 | } 34 | } 35 | 36 | #[glib::object_subclass] 37 | impl ObjectSubclass for Manage { 38 | const NAME: &'static str = "Manage"; 39 | type Type = super::Manage; 40 | type ParentType = adw::NavigationPage; 41 | 42 | fn class_init(klass: &mut Self::Class) { 43 | klass.bind_template(); 44 | klass.bind_template_callbacks(); 45 | 46 | klass.install_action( 47 | "delete", 48 | Some(&<(String, String)>::static_variant_type()), 49 | |slf, _, param| { 50 | let (path, name) = <(String, String)>::from_variant(param.unwrap()).unwrap(); 51 | let binding = slf.ancestor(gtk::Window::static_type()); 52 | let window = binding.and_dynamic_cast_ref::().unwrap(); 53 | 54 | let confirm_dialog = adw::AlertDialog::builder() 55 | .heading("Delete") 56 | .body(format!( 57 | "Are you sure you want to delete the '{}' shortcut?", 58 | name 59 | )) 60 | .default_response("cancel") 61 | .close_response("cancel") 62 | .build(); 63 | 64 | confirm_dialog.add_responses(&[("cancel", "_Cancel"), ("delete", "_Delete")]); 65 | confirm_dialog 66 | .set_response_appearance("delete", adw::ResponseAppearance::Destructive); 67 | 68 | confirm_dialog.present(Some(slf)); 69 | 70 | confirm_dialog.choose( 71 | window, 72 | Cancellable::NONE, 73 | clone!( 74 | #[weak] 75 | slf, 76 | #[weak] 77 | window, 78 | move |decision| { 79 | if decision.eq("delete") { 80 | match std::fs::remove_file(path) { 81 | Ok(()) => slf.load(false), 82 | Err(e) => { 83 | let _ = window.activate_action( 84 | "win.show_toast", 85 | Some(&"Could not delete the shortcut".to_variant()), 86 | ); 87 | eprintln!("Could not delete the shortcut: {:#?}", e); 88 | } 89 | } 90 | } 91 | } 92 | ), 93 | ) 94 | }, 95 | ); 96 | 97 | klass.install_action( 98 | "edit", 99 | Some(&<(String, String, String)>::static_variant_type()), 100 | |slf, _, params| { 101 | let _ = slf.activate_action("win.load_quick_mode", params); 102 | }, 103 | ); 104 | 105 | klass.install_action("reload_apps", None, |slf, _, _| { 106 | slf.load(false); 107 | }); 108 | } 109 | 110 | fn instance_init(obj: &InitializingObject) { 111 | obj.init_template(); 112 | } 113 | } 114 | 115 | impl ObjectImpl for Manage { 116 | fn constructed(&self) { 117 | self.parent_constructed(); 118 | self.obj().setup_filter(); 119 | self.obj().load(false); 120 | } 121 | } 122 | 123 | impl WidgetImpl for Manage {} 124 | 125 | impl NavigationPageImpl for Manage {} 126 | } 127 | 128 | use adw::prelude::EditableExt; 129 | use adw::prelude::WidgetExt; 130 | use freedesktop_entry_parser::parse_entry; 131 | use gtk::glib::clone; 132 | use gtk::prelude::Cast; 133 | use gtk::{ 134 | glib::{self}, 135 | subclass::prelude::ObjectSubclassIsExt, 136 | }; 137 | 138 | glib::wrapper! { 139 | pub struct Manage(ObjectSubclass) 140 | @extends gtk::Box, gtk::Widget, 141 | @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; 142 | } 143 | 144 | impl Manage { 145 | fn setup_filter(&self) { 146 | let filter_entry = self.imp().filter_entry.get(); 147 | let action = gtk::CallbackAction::new(|filter_entry, _| { 148 | filter_entry.grab_focus(); 149 | true.into() 150 | }); 151 | let trigger = gtk::ShortcutTrigger::parse_string("F").unwrap(); 152 | let shortcut = gtk::Shortcut::builder() 153 | .action(&action) 154 | .trigger(&trigger) 155 | .build(); 156 | 157 | let shortcut_controller = gtk::ShortcutController::new(); 158 | shortcut_controller.set_scope(gtk::ShortcutScope::Managed); 159 | shortcut_controller.add_shortcut(shortcut); 160 | filter_entry.add_controller(shortcut_controller); 161 | 162 | let app_list = self.imp().app_list.get(); 163 | self.imp().filter_entry.connect_changed(clone!( 164 | #[weak] 165 | app_list, 166 | #[weak(rename_to = slf)] 167 | self, 168 | move |filter_entry| { 169 | let filter_criteria = filter_entry.text(); 170 | slf.filter(app_list, &filter_criteria) 171 | } 172 | )); 173 | } 174 | 175 | fn filter(&self, app_list: gtk::ListBox, filter_criteria: &str) { 176 | let apps = app_list.observe_children(); 177 | 178 | if apps.into_iter().count() == 0 { 179 | self.imp() 180 | .status_page 181 | .set_description(Some("You have not created any shortcuts")); 182 | 183 | self.imp().list_window.set_visible(false); 184 | self.imp().status_page.set_visible(true); 185 | return; 186 | } 187 | 188 | self.imp() 189 | .status_page 190 | .set_description(Some("Try a different search term.")); 191 | 192 | let mut visible_apps: usize = 0; 193 | for app in app_list.observe_children().into_iter() { 194 | let app = app 195 | .unwrap() 196 | .dynamic_cast::() 197 | .unwrap(); 198 | if !app 199 | .get_name() 200 | .to_lowercase() 201 | .contains(filter_criteria.to_lowercase().as_str()) 202 | { 203 | app.set_visible(false); 204 | } else { 205 | app.set_visible(true); 206 | visible_apps += 1; 207 | } 208 | } 209 | self.imp().list_window.set_visible(visible_apps > 0); 210 | self.imp().status_page.set_visible(visible_apps == 0); 211 | } 212 | 213 | pub fn load(&self, all: bool) { 214 | let imp = self.imp(); 215 | 216 | imp.filter_entry.set_text(""); 217 | 218 | while imp.app_list.first_child().is_some() { 219 | imp.app_list.remove(&imp.app_list.first_child().unwrap()); 220 | } 221 | 222 | //Load all the item widgets in the internal list 223 | let paths = std::fs::read_dir(format!( 224 | "/home/{}/.local/share/applications", 225 | std::env::var("USER").unwrap() 226 | )); 227 | 228 | if let Ok(paths) = paths { 229 | paths 230 | .into_iter() 231 | .filter_map(|entry_result| entry_result.ok()) 232 | .filter(|entry| { 233 | entry 234 | .path() 235 | .extension() 236 | .is_some_and(|extension| extension.eq("desktop")) 237 | }) 238 | .filter_map(|entry| { 239 | parse_entry(entry.path()) 240 | .ok() 241 | .map(|desktop| (entry, desktop)) 242 | .filter(|(_, desktop)| { 243 | desktop 244 | .section("Desktop Entry") 245 | .attr("X-Shortcut-App") 246 | .is_some() 247 | || all 248 | }) 249 | }) 250 | .for_each(|(dir_entry, desktop)| { 251 | let section = desktop.section("Desktop Entry"); 252 | let exec = section.attr("Exec").map(|path| { 253 | let path = if path.starts_with('"') { 254 | &path[1..] 255 | } else { 256 | path 257 | }; 258 | 259 | let path = if path.ends_with('"') { 260 | &path[..path.len()-1] 261 | } else { 262 | path 263 | }; 264 | path 265 | }); 266 | let entry = crate::component::Entry::new( 267 | section.attr("Name"), 268 | dir_entry.path().to_str(), 269 | section.attr("Icon"), 270 | exec, 271 | ); 272 | imp.app_list.append(&entry); 273 | }); 274 | 275 | self.filter(imp.app_list.get(), &imp.filter_entry.text()); 276 | } 277 | } 278 | } 279 | -------------------------------------------------------------------------------- /src/view/mod.rs: -------------------------------------------------------------------------------- 1 | mod quick_mode; 2 | pub use quick_mode::QuickMode; 3 | 4 | mod manage; 5 | pub use manage::Manage; 6 | -------------------------------------------------------------------------------- /src/view/quick_mode.rs: -------------------------------------------------------------------------------- 1 | mod imp { 2 | use std::{cell::RefCell, fs::File}; 3 | 4 | use std::io::Write; 5 | use std::path::{Path, PathBuf}; 6 | 7 | use adw::prelude::BinExt; 8 | use adw::prelude::EntryRowExt; 9 | use adw::subclass::prelude::NavigationPageImpl; 10 | 11 | use gtk::glib::subclass::InitializingObject; 12 | use gtk::glib::{self, Properties}; 13 | use gtk::glib::{clone, closure}; 14 | use gtk::prelude::{ 15 | Cast, CastNone, FileExt, GObjectPropertyExpressionExt, ObjectExt, StaticType, ToVariant, 16 | }; 17 | use gtk::prelude::{EditableExt, WidgetExt}; 18 | use gtk::subclass::prelude::*; 19 | use gtk::{ClosureExpression, CompositeTemplate}; 20 | 21 | use crate::model::Desktop; 22 | 23 | #[derive(Default, Properties, CompositeTemplate)] 24 | #[properties(wrapper_type = super::QuickMode)] 25 | #[template(resource = "/io/github/andreibachim/shortcut/quick_mode.ui")] 26 | pub struct QuickMode { 27 | #[property(name = "name", get, set, type = String, member = name)] 28 | #[property(name = "exec", get, set, type = String, member = exec)] 29 | #[property(name = "icon", get, set, type = String, member = icon)] 30 | pub data: RefCell, 31 | 32 | #[property(get, set)] 33 | pub enable_validation: RefCell, 34 | 35 | pub old_name: RefCell, 36 | 37 | #[template_child] 38 | pub save_button: TemplateChild, 39 | #[template_child] 40 | pub name_input: TemplateChild, 41 | #[template_child] 42 | pub name_preview: TemplateChild, 43 | #[template_child] 44 | pub exec_input: TemplateChild, 45 | #[template_child] 46 | pub icon_input: TemplateChild, 47 | #[template_child] 48 | pub icon_preview: TemplateChild, 49 | } 50 | 51 | #[gtk::template_callbacks] 52 | impl QuickMode { 53 | #[template_callback] 54 | fn save(&self) { 55 | let data = self.data.borrow(); 56 | let old_name_binding = self.old_name.borrow(); 57 | let old_name = old_name_binding.as_ref(); 58 | 59 | if !data.name.eq(old_name) { 60 | let _ = std::fs::remove_file(self.get_file_path_from_name(old_name)); 61 | } 62 | 63 | let target_dir = PathBuf::from(format!( 64 | "/home/{}/.local/share/applications", 65 | std::env::var("USER").unwrap() 66 | )); 67 | 68 | if !target_dir.exists() { 69 | let _ = std::fs::create_dir_all(&target_dir); 70 | } 71 | 72 | let file_path = target_dir.join(format!( 73 | "{}.desktop", 74 | data.name.replace(' ', "-").to_lowercase() 75 | )); 76 | 77 | let mut file = File::create(file_path).expect("Could not create a new file"); 78 | match file.write_all( 79 | data.get_output() 80 | .expect("Could not serialize desktop file for writing") 81 | .as_bytes(), 82 | ) { 83 | Ok(()) => { 84 | let _ = self 85 | .obj() 86 | .activate_action("navigation.pop", Some(&"manage".to_variant())); 87 | } 88 | Err(e) => { 89 | eprintln!( 90 | "Could not save file because of the following error: \n {:#?}", 91 | e 92 | ); 93 | } 94 | } 95 | } 96 | 97 | fn get_file_path_from_name(&self, name: &str) -> PathBuf { 98 | PathBuf::from(format!( 99 | "/home/{}/.local/share/applications/{}.desktop", 100 | std::env::var("USER").unwrap(), 101 | name.replace(' ', "-").to_lowercase() 102 | )) 103 | } 104 | } 105 | 106 | #[glib::object_subclass] 107 | impl ObjectSubclass for QuickMode { 108 | const NAME: &'static str = "QuickMode"; 109 | type Type = super::QuickMode; 110 | type ParentType = adw::NavigationPage; 111 | 112 | fn new() -> Self { 113 | Self { 114 | data: RefCell::new(Desktop::new()), 115 | ..Default::default() 116 | } 117 | } 118 | 119 | fn class_init(klass: &mut Self::Class) { 120 | klass.bind_template(); 121 | klass.bind_template_callbacks(); 122 | 123 | klass.install_action("pick_exec", None, move |quick_mode, _, _| { 124 | let imp = quick_mode.imp(); 125 | 126 | let filters_store = gtk::gio::ListStore::new::(); 127 | let executable_filter = gtk::FileFilter::new(); 128 | executable_filter.set_name(Some("Executable files")); 129 | executable_filter.add_mime_type("application/x-executable"); 130 | filters_store.append(&executable_filter); 131 | 132 | let all_filter = gtk::FileFilter::new(); 133 | all_filter.add_pattern("*"); 134 | all_filter.set_name(Some("All files")); 135 | filters_store.append(&all_filter); 136 | 137 | let main_window: adw::ApplicationWindow = quick_mode 138 | .ancestor(adw::ApplicationWindow::static_type()) 139 | .unwrap() 140 | .dynamic_cast() 141 | .unwrap(); 142 | 143 | let dialog = gtk::FileDialog::builder() 144 | .filters(&filters_store) 145 | .modal(true) 146 | .title("Select Executable File") 147 | .build(); 148 | 149 | dialog.open( 150 | Some(&main_window), 151 | None::<>k::gio::Cancellable>, 152 | clone!( 153 | #[weak] 154 | imp, 155 | move |file| { 156 | if let Ok(file) = file { 157 | imp.exec_input.set_text( 158 | file.path() 159 | .expect("Invalid file path") 160 | .to_str() 161 | .expect("Path is not UTF-8 compliant"), 162 | ); 163 | imp.exec_input.emit_by_name::<()>("apply", &[]); 164 | } 165 | } 166 | ), 167 | ); 168 | }); 169 | klass.install_action("pick_icon", None, move |quick_mode, _, _| { 170 | let imp = quick_mode.imp(); 171 | 172 | let filters_store = gtk::gio::ListStore::new::(); 173 | let filter = gtk::FileFilter::new(); 174 | filter.set_name(Some("Image files")); 175 | filter.add_mime_type("image/svg+xml"); 176 | filter.add_mime_type("image/png"); 177 | filters_store.append(&filter); 178 | 179 | let file_dialog = gtk::FileDialog::builder() 180 | .filters(&filters_store) 181 | .title("Select Icon File") 182 | .modal(true) 183 | .build(); 184 | 185 | let main_window: adw::ApplicationWindow = quick_mode 186 | .ancestor(adw::ApplicationWindow::static_type()) 187 | .unwrap() 188 | .dynamic_cast() 189 | .unwrap(); 190 | 191 | file_dialog.open( 192 | Some(&main_window), 193 | None::<>k::gio::Cancellable>, 194 | clone!( 195 | #[weak] 196 | imp, 197 | move |file| { 198 | if let Ok(file) = file { 199 | imp.icon_input.set_text( 200 | file.path() 201 | .expect("Could not extract path from file") 202 | .to_str() 203 | .expect("Path is not UTF-8 compliant"), 204 | ); 205 | imp.icon_input.emit_by_name::<()>("apply", &[]); 206 | } 207 | } 208 | ), 209 | ); 210 | }); 211 | } 212 | fn instance_init(obj: &InitializingObject) { 213 | obj.init_template(); 214 | } 215 | } 216 | 217 | #[glib::derived_properties] 218 | impl ObjectImpl for QuickMode { 219 | fn constructed(&self) { 220 | self.parent_constructed(); 221 | self.obj().init(); 222 | bind_name_preview(self); 223 | setup_form_validation(self); 224 | self.icon_input 225 | .settings() 226 | .set_gtk_entry_select_on_focus(false); 227 | self.exec_input 228 | .settings() 229 | .set_gtk_entry_select_on_focus(false); 230 | } 231 | } 232 | 233 | fn bind_name_preview(slf: &QuickMode) { 234 | slf.name_input 235 | .bind_property("text", &slf.name_preview.get(), "label") 236 | .sync_create() 237 | .transform_to(|_, value: &str| -> Option<&str> { 238 | match value.is_empty() { 239 | true => Some("Preview"), 240 | false => Some(value), 241 | } 242 | }) 243 | .build(); 244 | slf.name_input 245 | .bind_property("text", &slf.name_preview.get(), "opacity") 246 | .sync_create() 247 | .transform_to(|_, value: &str| -> Option { 248 | match value.is_empty() { 249 | true => Some(0.3), 250 | false => Some(1.0), 251 | } 252 | }) 253 | .build(); 254 | } 255 | 256 | fn setup_form_validation(slf: &QuickMode) { 257 | slf.name_input 258 | .bind_property("text", slf.obj().as_ref(), "name") 259 | .bidirectional() 260 | .sync_create() 261 | .build(); 262 | 263 | let show_error = |toast_text: &str, entry_row: &adw::EntryRow| { 264 | let window = entry_row 265 | .ancestor(adw::ApplicationWindow::static_type()) 266 | .unwrap(); 267 | let _ = window.activate_action("win.show_toast", Some(&toast_text.to_variant())); 268 | entry_row.set_css_classes(&["error"]); 269 | entry_row.grab_focus(); 270 | }; 271 | 272 | slf.exec_input.connect_apply(clone!( 273 | #[weak] 274 | slf, 275 | move |entry_row| { 276 | let text = entry_row.text(); 277 | let path = Path::new(&text); 278 | let validate_form = *slf.enable_validation.borrow(); 279 | 280 | if text.is_empty() { 281 | show_error("The executable path is empty", entry_row); 282 | return; 283 | } 284 | 285 | if !path.is_absolute() && validate_form { 286 | show_error("Only absolute file paths are allowed", entry_row); 287 | return; 288 | } 289 | 290 | if !path.exists() && validate_form { 291 | show_error("The executable file does not exist", entry_row); 292 | return; 293 | } 294 | 295 | if !path.is_file() && validate_form { 296 | show_error("The selected file is a directory", entry_row); 297 | return; 298 | } 299 | 300 | entry_row.set_css_classes(&[]); 301 | slf.obj().set_exec(text); 302 | slf.save_button.grab_focus(); 303 | } 304 | )); 305 | 306 | slf.icon_input.connect_apply(clone!( 307 | #[weak] 308 | slf, 309 | move |entry_row| { 310 | let text = entry_row.text(); 311 | let path = Path::new(&text); 312 | 313 | let validate_form = *slf.enable_validation.borrow(); 314 | 315 | if text.is_empty() { 316 | show_error("The icon path is empty", entry_row); 317 | return; 318 | } 319 | 320 | if !path.is_absolute() && validate_form { 321 | show_error("Only absolute file paths are allowed", entry_row); 322 | return; 323 | } 324 | 325 | if !path.exists() && validate_form { 326 | show_error("The icon file does not exist", entry_row); 327 | return; 328 | } 329 | 330 | if !path.is_file() && validate_form { 331 | show_error("The selected file is a directory", entry_row); 332 | return; 333 | } 334 | 335 | entry_row.set_css_classes(&[]); 336 | let image = slf 337 | .icon_preview 338 | .child() 339 | .and_dynamic_cast::() 340 | .unwrap(); 341 | image.set_from_file(Some(&text)); 342 | slf.obj().set_icon(text); 343 | slf.exec_input.grab_focus(); 344 | } 345 | )); 346 | 347 | let name_expression = slf.obj().property_expression("name"); 348 | let exec_expression = slf.obj().property_expression("exec"); 349 | let icon_expression = slf.obj().property_expression("icon"); 350 | ClosureExpression::new::( 351 | [&name_expression, &exec_expression, &icon_expression], 352 | closure!(|_: ::Type, 353 | name: String, 354 | exec: String, 355 | icon: String| { 356 | !(name.is_empty() || exec.is_empty() || icon.is_empty()) 357 | }), 358 | ) 359 | .bind( 360 | &slf.save_button.get(), 361 | "sensitive", 362 | Some(slf.obj().as_ref()), 363 | ); 364 | } 365 | 366 | impl WidgetImpl for QuickMode {} 367 | impl NavigationPageImpl for QuickMode {} 368 | } 369 | 370 | use adw::prelude::BinExt; 371 | use adw::prelude::EntryRowExt; 372 | use gtk::{ 373 | glib::{self}, 374 | prelude::{EditableExt, WidgetExt}, 375 | prelude::{ObjectExt, SettingsExtManual}, 376 | subclass::prelude::ObjectSubclassIsExt, 377 | }; 378 | 379 | glib::wrapper! { 380 | pub struct QuickMode(ObjectSubclass) 381 | @extends adw::NavigationPage, gtk::Widget, 382 | @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; 383 | } 384 | 385 | impl QuickMode { 386 | pub fn init(&self) { 387 | let settings = gtk::gio::Settings::new("io.github.andreibachim.shortcut"); 388 | settings 389 | .bind("create-enable-validation", self, "enable_validation") 390 | .build(); 391 | } 392 | 393 | pub fn edit_details( 394 | &self, 395 | name: Option, 396 | icon_path: Option, 397 | exec_path: Option, 398 | ) { 399 | if let Some(name) = name { 400 | *self.imp().old_name.borrow_mut() = name.clone(); 401 | self.set_name(name); 402 | } 403 | 404 | if let Some(icon_path) = icon_path { 405 | if !icon_path.is_empty() { 406 | self.imp().icon_input.set_text(&icon_path); 407 | self.imp().icon_input.emit_by_name::<()>("apply", &[]); 408 | } 409 | } 410 | 411 | if let Some(exec_path) = exec_path { 412 | if !exec_path.is_empty() { 413 | self.imp().exec_input.set_text(&exec_path); 414 | self.imp().exec_input.emit_by_name::<()>("apply", &[]); 415 | self.imp().exec_input.get().set_show_apply_button(false); 416 | self.imp().exec_input.get().set_show_apply_button(true); 417 | } 418 | } 419 | } 420 | 421 | pub fn clear_data(&self) { 422 | let imp = self.imp(); 423 | *imp.old_name.borrow_mut() = "".to_owned(); 424 | self.set_name(""); 425 | imp.name_input.get().delete_text(0, -1); 426 | 427 | imp.exec_input.set_text(""); 428 | self.set_exec(""); 429 | imp.exec_input.set_css_classes(&[]); 430 | 431 | imp.icon_input.set_text(""); 432 | self.set_icon(""); 433 | imp.icon_input.set_css_classes(&[]); 434 | 435 | imp.name_input.grab_focus(); 436 | 437 | imp.icon_preview.set_child(Some( 438 | >k::Image::builder() 439 | .icon_name("preview-placeholder") 440 | .pixel_size(128) 441 | .build(), 442 | )); 443 | } 444 | } 445 | --------------------------------------------------------------------------------