Esempio n. 1
0
def initialize(destdir, icondirs, dimendirs):
	debug("Initializing....")

	# Remove the folder
	if exists(destdir): rmtree(destdir)
	# Creating the folder
	mkdir(destdir)
	# Initialize the folders in base direcotry
	for folder in dimendirs:
		fn = composepath(destdir, folder)
		mkdir(fn)

		for icon in icondirs: mkdir(composepath(fn, icon))
Esempio n. 2
0
def compact(dimen, basepath):
	# The sources direcotry have no 8x8 dimens folder
	if dimen == '8x8':
		dimen = '16x16'
	elif dimen == '256x256':
		# Prefer to 128x128 dimens
		if exists(composepath(basepath, "128")):
			dimen = "128x128"
		elif exists(composepath(basepath, "96")):
			dimen = "96x96"
	elif dimen == 'scalable':
		dimen = "scalablex"

	return dimen
Esempio n. 3
0
def remove_icon(base, dimendirs, removelist):
	for icon, lst in removelist.iteritems():
		for fn in lst:
			for dimen in dimendirs:
				r = composepath(base, dimen, icon, fn)
				if exists(r + '.png'): remove(r + '.png')
				if exists(r + '.svg'): remove(r + '.svg')
Esempio n. 4
0
def replace_icon(base, dimendirs, replacelist):
	for icon, lst in replacelist.iteritems():
		for fn, target in lst.iteritems():
			# Give a new picture
			for ticon, tfn in target.iteritems():
				tfile = composepath(ticon, tfn)

				for dimen in dimendirs:
					# Original file
					origin = composepath(base, dimen, icon, fn)
					tfinal = composepath(base, dimen, tfile)

					ext = ''
					if exists(origin + ".png"): ext = '.png'
					elif exists(origin + '.svg'): ext = '.svg'

					if ext != '':
						remove(origin + ext)
						copyfile(tfinal + ext, origin + ext)
Esempio n. 5
0
def buildtheme(name, path, comment='', inherit=''):
    if not isdir(path): return False
    if (comment == ''): comment = name

    handle = open(composepath(path, "index.theme"), "w+")
    try:
        tp = Template(TEMPLATE_HEADER)
        if (inherit != ''): inherit = "Inherit=%s" % inherit

        handle.write(
            tp.substitute(tp_name=name, tp_comment=comment,
                          tp_inherit=inherit))
        handle.write(TEMPLATE_KED_SPECIAL)

        directories = "Directories="
        dimen_desc = ""
        for dimen in listdir(path):
            file = composepath(path, dimen)
            if not isdir(file): continue

            for icon in listdir(file):
                directories += composepath(dimen, icon) + ','
                if dimen == 'scalable':
                    n_size = "16\nMinSize=8\nMaxSize=512"
                    n_type = 'Scalable'
                else:
                    n_size = dimen[0:dimen.index('x')]
                    n_type = 'Fixed'

                n_context = getcontext(icon)

                tp = Template(TEMPLATE_DIMEN)
                dimen_desc += tp.substitute(tp_dimen=dimen,
                                            tp_icon=icon,
                                            tp_context=n_context,
                                            tp_size=n_size,
                                            tp_type=n_type)

        handle.write(directories + "\n\n")
        handle.write(dimen_desc)
    except Exception, e:
        debug("Oops, It seem something wrong: " + str(e))
Esempio n. 6
0
def deepth_copy(srcdir, destdir, icondirs, dimendirs):
	#pdb.set_trace()
	print "Coping file...\n"
	# Through all of icon and dimen folders
	for icon in icondirs:
		for dimen in dimendirs:
			# The structure of Mint-X-icons folders are different to Adwaita folders
			# We should convert it to the origin name of folder
			src = compact(dimen, composepath(srcdir, icon))

			srcpath = composepath(srcdir, icon, src[0:src.index("x")])
			savepath = composepath(destdir, dimen, icon)

			if not exists(srcpath):
				debug(srcpath + " dosen't exist.")
				continue

			for file in listdir(srcpath):
				# Fix some files under PLACES folder
				fn = manual_fix_places(file, dimen)
				srcfile = composepath(srcpath, fn)
				savefile = composepath(savepath, fn)

				if not exists(srcfile):
					debug(srcfile + " dosen't exist.")
					continue

				# convert a .svg foramt to .png
				if convert(srcfile, dimen):
					srcfile = srcfile.replace(".svg", ".png")
					savefile = savefile.replace(".svg", ".png")

					move(srcfile, savefile)

					debug("Moved %s to %s" % (srcfile, savefile));
					continue

				copyfile(srcfile, savefile)
def buildtheme(name, path, comment = '', inherit = ''):
    if not isdir(path): return False
    if (comment == ''): comment = name

    handle = open(composepath(path, "index.theme"), "w+")
    try:
        tp = Template( TEMPLATE_HEADER )
        if (inherit != ''): inherit = "Inherit=%s" % inherit

        handle.write(tp.substitute(tp_name=name, tp_comment=comment, tp_inherit=inherit))
        handle.write( TEMPLATE_KED_SPECIAL )

        directories = "Directories="
        dimen_desc = ""
        for dimen in listdir(path):
            file = composepath(path, dimen)
            if not isdir(file): continue

            for icon in listdir(file):
                directories += composepath(dimen, icon) + ','
                if dimen == 'scalable':
                    n_size = "16\nMinSize=8\nMaxSize=512"
                    n_type = 'Scalable'
                else:
                    n_size = dimen[0:dimen.index('x')]
                    n_type = 'Fixed'

                n_context = getcontext(icon);

                tp = Template( TEMPLATE_DIMEN )
                dimen_desc += tp.substitute(tp_dimen=dimen, tp_icon=icon, tp_context=n_context, tp_size=n_size, tp_type=n_type)

        handle.write(directories + "\n\n")
        handle.write(dimen_desc)
    except Exception, e:
        debug("Oops, It seem something wrong: " + str(e))