-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenwith.py
More file actions
29 lines (24 loc) · 841 Bytes
/
openwith.py
File metadata and controls
29 lines (24 loc) · 841 Bytes
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
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gio
import os
import sys
class CustomExecutable(Gtk.Window):
def __init__(self, toOpen):
Gtk.Window.__init__(self, title="")
self.hide()
dialog = Gtk.FileChooserDialog("Choose executable", self,
Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
response = dialog.run()
if response == Gtk.ResponseType.OK:
if (os.fork() == 0):
os.execv(dialog.get_filename(),
[dialog.get_filename()] + toOpen[1:])
dialog.destroy()
Gio.g_application_quit()
win = CustomExecutable(sys.argv)
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()