#!/usr/bin/env python 

import  gtk, os, sys

avail = False
try:
    file = os.path.normpath(sys.argv[1])
    avail = os.path.isfile(file)
except: pass
if not avail == True:
    print "USAGE: %s Some.AppImage" % (sys.argv[0])
    exit(1)

dlg = gtk.MessageDialog(parent=None, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_YES_NO,
                        message_format='%s is an AppImage' % os.path.basename(file))
dlg.format_secondary_text('Do you want to make it executable and add it to the menu?')
result = dlg.run()
dlg.destroy()

if result == gtk.RESPONSE_YES:
    print "Making %s executable"
    command = "chmod a+x '%s'" % (file)
    os.system(command)
