Created
April 24, 2019 08:52
-
-
Save steelman/2c3d4aa3966ab921d04ff5508eead10a to your computer and use it in GitHub Desktop.
A wrapper for ImageMagick's import to add created files to Gtk's recent manager and find the quickly in Gimp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# | |
# This work is in public domain | |
# | |
import subprocess | |
import sys | |
import gi | |
gi.require_version('Gtk', '3.0') | |
from gi.repository import Gtk, GLib, Gio | |
r = subprocess.run(["import"] + sys.argv[1:]) | |
if r.returncode != 0: | |
sys.exit(r.returncode) | |
def on_timeout(manager, args): | |
for path in args: | |
f = Gio.File.new_for_path(path) | |
exists = f.query_exists() | |
if exists: | |
res = manager.add_item(f.get_uri()) | |
print(f.get_uri()) | |
GLib.timeout_add(10, Gtk.main_quit) | |
recent_manager = Gtk.RecentManager.get_default() | |
GLib.timeout_add(5, on_timeout, recent_manager, sys.argv[1:]) | |
Gtk.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment