[go: up one dir, main page]

Menu

[r1]: / src / gimagereader  Maximize  Restore  History

Download this file

58 lines (51 with data), 1.7 kB

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#       gimagereader.py
#       
#       Copyright 2009-2010 Sandro Mani <manisandro@gmail.com>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 3 of the License, or
#       (at your option) any later version.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

try:
    # Change the process name.
    import ctypes
    libc = ctypes.CDLL('libc.so.6')
    libc.prctl(15, 'gimagereader', 0, 0)
except:
    pass

import gtk
import main
import os
import sys
	
if __name__ == "__main__":
	# Change to the path where this file is
	if os.path.islink(sys.argv[0]):
		os.chdir(os.path.dirname(os.readlink(sys.argv[0])))
	else:
		os.chdir(os.path.dirname(sys.argv[0]))
	
	# Read builder
	builder = gtk.Builder()
	builder.add_from_file("gimagereader.xml")
	
	# Parse arguments
	if len(sys.argv) > 1:
		if sys.argv[1]=="--help" or sys.argv[1]=="-h":
			print "Usage: "+sys.argv[0]+" [path_to_image]"
			sys.exit(0)
		else:
			main.gimagereader(builder,sys.argv[1]);
	else:
		main.gimagereader(builder);
	
	gtk.main()