/usr/bin/cinnamon-file-dialog is in cinnamon 2.8.6-1ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #! /usr/bin/python3
import sys
from gi.repository import Gio, Gtk
cancelButton = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
typeArg = int(sys.argv[1])
fdType = typeArg % 3
if fdType == 0:
msg = "Open"
action = Gtk.FileChooserAction.OPEN
okButton = (Gtk.STOCK_OPEN, Gtk.ResponseType.OK)
elif fdType == 1:
msg = "Select Folder"
action = Gtk.FileChooserAction.SELECT_FOLDER
okButton = (Gtk.STOCK_OPEN, Gtk.ResponseType.OK)
elif fdType == 2:
msg = "Save"
action = Gtk.FileChooserAction.SAVE
okButton = (Gtk.STOCK_SAVE, Gtk.ResponseType.OK)
buttons = cancelButton + okButton
filechooserdialog = Gtk.FileChooserDialog(title=msg, action=action, buttons=buttons)
for i in range(2, len(sys.argv)):
if sys.argv[i] == "-p":
filechooserdialog.set_filename(sys.argv[i+1])
elif sys.argv[i] == "-n":
filechooserdialog.set_current_name(sys.argv[i+1])
elif sys.argv[i] == "-d":
filechooserdialog.set_current_folder(sys.argv[i+1])
elif sys.argv[i] == "-f":
filterList = sys.argv[i+1].split(",")
for filterInfo in filterList:
[name,filters] = filterInfo.split(";")
filterObj = Gtk.FileFilter()
filterObj.set_name(name)
rules = filters.split(":")
for rule in rules:
[ftype,value] = rule.split("=")
if ftype == "m":
filterObj.add_mime_type(value)
elif ftype == "p":
filterObj.add_pattern(value)
filechooserdialog.add_filter(filterObj)
if fdType == 2:
filechooserdialog.set_do_overwrite_confirmation(True)
if typeArg > 2:
filechooserdialog.set_select_multiple(True)
response=filechooserdialog.run()
if response == Gtk.ResponseType.OK:
if typeArg > 2:
print (filechooserdialog.get_filenames())
else:
print (filechooserdialog.get_filename())
filechooserdialog.destroy()
|