Fixes to non virtualized environments and turning off some debugging

This commit is contained in:
Grassmunk 2020-06-03 21:22:14 -07:00
parent ec953f083b
commit e6de876f21
2 changed files with 48 additions and 48 deletions

View File

@ -20,8 +20,8 @@ import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GdkPixbuf, GLib from gi.repository import Gtk, GdkPixbuf, GLib
#theme = sys.argv[1].split("/")[7] running_folder = os.path.dirname(os.path.abspath(__file__))
print("Font List...", end=' ', flush=True) #print("Font List...", end=' ', flush=True)
fonts_output = subprocess.check_output(['convert', '-list', 'font']) fonts_output = subprocess.check_output(['convert', '-list', 'font'])
fonts = fonts_output.decode().split('\n') fonts = fonts_output.decode().split('\n')
installed_fonts = {} installed_fonts = {}
@ -34,7 +34,7 @@ for index, font in enumerate(fonts):
fonts[index+4].split(":")[0].strip() : fonts[index+4].split(":")[1].strip(), fonts[index+4].split(":")[0].strip() : fonts[index+4].split(":")[1].strip(),
fonts[index+5].split(":")[0].strip() : fonts[index+5].split(":")[1].strip() fonts[index+5].split(":")[0].strip() : fonts[index+5].split(":")[1].strip()
} }
print("OK", end='\n', flush=True) #print("OK", end='\n', flush=True)
sys.stdout.flush() sys.stdout.flush()
@ -141,18 +141,18 @@ class MakePreview:
print("[MakePreview] Preview Generated") print("[MakePreview] Preview Generated")
def return_preview(self): def return_preview(self):
self.preview_window.save("preview.png", "PNG") self.preview_window.save(running_folder+"/preview.png", "PNG")
return("preview.png") return(running_folder+"/preview.png")
def return_preview_double(self): def return_preview_double(self):
self.preview_window.save("preview_double.png", "PNG") self.preview_window.save(running_folder+"/preview_double.png", "PNG")
return("preview_double.png") return(running_folder+"/preview_double.png")
def delete_preview(self): def delete_preview(self):
os.remove("preview.png") os.remove(running_folder+"/preview.png")
def delete_preview_double(self): def delete_preview_double(self):
os.remove("preview_double.png") os.remove(running_folder+"/preview_double.png")
def set_fonts(self): def set_fonts(self):
print("[MakePreview] Fonts...", end=' ') print("[MakePreview] Fonts...", end=' ')
@ -239,7 +239,7 @@ class MakePreview:
draw.line([(button_width - 6, 4),(button_width - 6, button_height-5)],fill=colors['buttontext'], width=1) draw.line([(button_width - 6, 4),(button_width - 6, button_height-5)],fill=colors['buttontext'], width=1)
self.max_button = img self.max_button = img
elif button == 'close': elif button == 'close':
X = Image.open(r"assets/X.png").convert('RGBA') X = Image.open(running_folder+"/assets/X.png").convert('RGBA')
pixels = X.load() pixels = X.load()
rgb = struct.unpack('BBB',bytes.fromhex(colors['buttontext'].lstrip('#'))) rgb = struct.unpack('BBB',bytes.fromhex(colors['buttontext'].lstrip('#')))
for i in range(X.size[0]): for i in range(X.size[0]):
@ -305,17 +305,17 @@ class MakePreview:
if self.plus.theme_config['icons']['my_computer']: if self.plus.theme_config['icons']['my_computer']:
self.my_computer = self.make_icons(self.plus,'my_computer') self.my_computer = self.make_icons(self.plus,'my_computer')
else: else:
self.my_computer = Image.open("assets/my_computer~.png").convert('RGBA') self.my_computer = Image.open(running_folder+"/assets/my_computer~.png").convert('RGBA')
if self.plus.theme_config['icons']['network_neighborhood']: if self.plus.theme_config['icons']['network_neighborhood']:
self.network_neighborhood= self.make_icons(self.plus,'network_neighborhood') self.network_neighborhood= self.make_icons(self.plus,'network_neighborhood')
else: else:
self.network_neighborhood = Image.open("assets/network_neighborhood~.png").convert('RGBA') self.network_neighborhood = Image.open(running_folder+"/assets/network_neighborhood~.png").convert('RGBA')
if self.plus.theme_config['icons']['recycle_bin_empty']: if self.plus.theme_config['icons']['recycle_bin_empty']:
self.recycle_bin_empty = self.make_icons(self.plus,'recycle_bin_empty') self.recycle_bin_empty = self.make_icons(self.plus,'recycle_bin_empty')
else: else:
self.recycle_bin_empty = Image.open("assets/recycle_bin_empty~.png").convert('RGBA') self.recycle_bin_empty = Image.open(running_folder+"/assets/recycle_bin_empty~.png").convert('RGBA')
if self.plus.theme_config['icons']['my_documents']: if self.plus.theme_config['icons']['my_documents']:
self.my_documents = self.make_icons(self.plus,'my_documents') self.my_documents = self.make_icons(self.plus,'my_documents')
@ -704,7 +704,7 @@ class MakePreview:
def make_icons(self, plus, ico_name): def make_icons(self, plus, ico_name):
icon = "assets/" + ico_name+"~"+".png" icon = running_folder+"/assets/" + ico_name+"~"+".png"
if plus.theme_config['icons'][ico_name]['type'] in ['dll', 'icl']: if plus.theme_config['icons'][ico_name]['type'] in ['dll', 'icl']:
index = plus.theme_config['icons'][ico_name]['index'] index = plus.theme_config['icons'][ico_name]['index']
@ -713,12 +713,12 @@ class MakePreview:
icon_filename, icon_file = plus.get_icons_size_dll(icon_files, index) icon_filename, icon_file = plus.get_icons_size_dll(icon_files, index)
if icon_filename: if icon_filename:
f = open("tmp/tmp_"+icon_filename,"wb") f = open(running_folder+"/tmp/tmp_"+icon_filename,"wb")
f.write(icon_file) f.write(icon_file)
f.close() f.close()
icon = "tmp/tmp_"+icon_filename icon = running_folder+"/tmp/tmp_"+icon_filename
else: else:
icon = "assets/" + ico_name+"~"+".png" icon = running_folder+"/assets/" + ico_name+"~"+".png"
else: else:
icon_files = plus.extract_ico(plus.theme_config['icons'][ico_name]['path']) icon_files = plus.extract_ico(plus.theme_config['icons'][ico_name]['path'])
@ -741,7 +741,7 @@ class MakePreview:
icon_image = Image.open(ico_name+".png").convert('RGBA') icon_image = Image.open(ico_name+".png").convert('RGBA')
os.remove(ico_name+".png") os.remove(ico_name+".png")
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
icon_image = Image.open("assets/" + ico_name+"~.png").convert('RGBA') icon_image = Image.open(running_folder+"/assets/" + ico_name+"~.png").convert('RGBA')
return icon_image return icon_image
@ -798,7 +798,7 @@ class plusGTK:
# GTK Initialization # GTK Initialization
self.builder = builder = Gtk.Builder() self.builder = builder = Gtk.Builder()
self.builder.add_from_file("plus.glade") self.builder.add_from_file(running_folder+"/plus.glade")
self.window = self.builder.get_object("Main") self.window = self.builder.get_object("Main")
self.preview = self.builder.get_object("preview") self.preview = self.builder.get_object("preview")
self.builder.connect_signals(self.handlers) self.builder.connect_signals(self.handlers)
@ -943,22 +943,22 @@ class plusGTK:
def other_previews(self, button): def other_previews(self, button):
checkmark = GdkPixbuf.Pixbuf.new_from_file("assets/check.png") checkmark = GdkPixbuf.Pixbuf.new_from_file(running_folder+"/assets/check.png")
nocheckmark = GdkPixbuf.Pixbuf.new_from_file("assets/blank-check.png") nocheckmark = GdkPixbuf.Pixbuf.new_from_file(running_folder+"/assets/blank-check.png")
self.previews_window = self.builder.get_object("Preview Window") self.previews_window = self.builder.get_object("Preview Window")
self.cursor_preview = self.builder.get_object("cursor_preview") self.cursor_preview = self.builder.get_object("cursor_preview")
self.cursor_preview.set_from_file("assets/blank-check.png") self.cursor_preview.set_from_file(running_folder+"/assets/blank-check.png")
self.icon_preview = self.builder.get_object("icon_preview") self.icon_preview = self.builder.get_object("icon_preview")
self.icon_preview.set_from_file("assets/blank-check.png") self.icon_preview.set_from_file(running_folder+"/assets/blank-check.png")
self.sound_preview = self.builder.get_object("sound_preview") self.sound_preview = self.builder.get_object("sound_preview")
self.sound_preview.set_from_file("assets/blank-check.png") self.sound_preview.set_from_file(running_folder+"/assets/blank-check.png")
self.cursor_preview = self.builder.get_object("cursor_preview") self.cursor_preview = self.builder.get_object("cursor_preview")
self.cursor_preview.set_from_file("assets/blank-check.png") self.cursor_preview.set_from_file(running_folder+"/assets/blank-check.png")
# Populate cursor preview # Populate cursor preview
self.cursor_store = self.builder.get_object("cursor_list") self.cursor_store = self.builder.get_object("cursor_list")
@ -992,40 +992,40 @@ class plusGTK:
for icon in ani_file_config['icon']: for icon in ani_file_config['icon']:
if icon['index'] == sequence: if icon['index'] == sequence:
cur_filename = current_cursor+"_"+str(sequence) cur_filename = current_cursor+"_"+str(sequence)
f = open("tmp/"+cur_filename+".cur","wb") f = open(running_folder+"/tmp/"+cur_filename+".cur","wb")
f.write(icon['ico_file']) f.write(icon['ico_file'])
f.close() f.close()
convert_args.append("-delay") convert_args.append("-delay")
convert_args.append("{}x60".format(rate)) convert_args.append("{}x60".format(rate))
convert_args.append("tmp/"+cur_filename+".cur") convert_args.append(running_folder+"/tmp/"+cur_filename+".cur")
else: else:
for icon in ani_file_config['icon']: for icon in ani_file_config['icon']:
rate = ani_file_config['anih']['iDispRate'] + 5 rate = ani_file_config['anih']['iDispRate'] + 5
cur_filename = current_cursor+"_"+str(icon['index']) cur_filename = current_cursor+"_"+str(icon['index'])
f = open("tmp/"+cur_filename+".cur","wb") f = open(running_folder+"/tmp/"+cur_filename+".cur","wb")
f.write(icon['ico_file']) f.write(icon['ico_file'])
f.close() f.close()
convert_args.append("-delay") convert_args.append("-delay")
convert_args.append("{}x60".format(rate)) convert_args.append("{}x60".format(rate))
convert_args.append("tmp/"+cur_filename+".cur") convert_args.append(running_folder+"/tmp/"+cur_filename+".cur")
convert_args.append("-loop") convert_args.append("-loop")
convert_args.append("0") convert_args.append("0")
convert_args.append("tmp/"+current_cursor+".gif") convert_args.append(running_folder+"/tmp/"+current_cursor+".gif")
# pprint(convert_args) # pprint(convert_args)
try: try:
subprocess.check_call(convert_args) subprocess.check_call(convert_args)
except: except:
copyfile("assets/blank-check.png", "tmp/"+current_cursor+".gif") copyfile(running_folder+"/assets/blank-check.png", running_folder+"/tmp/"+current_cursor+".gif")
else: else:
cursor_file_config = self.theme.extract_cur(filename) cursor_file_config = self.theme.extract_cur(filename)
icon_file = cursor_file_config['icon'][0]['ico_file'] icon_file = cursor_file_config['icon'][0]['ico_file']
f = open("tmp/"+current_cursor+".cur","wb") f = open(running_folder+"/tmp/"+current_cursor+".cur","wb")
f.write(icon_file) f.write(icon_file)
f.close() f.close()
try: try:
subprocess.check_call(['convert', "tmp/"+current_cursor+".cur", "tmp/"+current_cursor+".gif"]) subprocess.check_call(['convert', running_folder+"/tmp/"+current_cursor+".cur", running_folder+"/tmp/"+current_cursor+".gif"])
except: except:
copyfile("assets/blank-check.png", "tmp/"+current_cursor+".gif") copyfile(running_folder+"/assets/blank-check.png", running_folder+"/tmp/"+current_cursor+".gif")
if not self.in_store(self.cursor_store, pointers[current_cursor]): if not self.in_store(self.cursor_store, pointers[current_cursor]):
self.cursor_store.append([checkmark,pointers[current_cursor]]) self.cursor_store.append([checkmark,pointers[current_cursor]])
@ -1062,7 +1062,7 @@ class plusGTK:
self.icon_store[loc][0] = nocheckmark self.icon_store[loc][0] = nocheckmark
else: else:
icon_image = self.preview_image.make_icons(self.theme, icon) icon_image = self.preview_image.make_icons(self.theme, icon)
icon_image.save("tmp/"+icon+".png", "PNG") icon_image.save(running_folder+"/tmp/"+icon+".png", "PNG")
if not self.in_store(self.icon_store, icons[icon]): if not self.in_store(self.icon_store, icons[icon]):
self.icon_store.append([checkmark,icons[icon]]) self.icon_store.append([checkmark,icons[icon]])
else: else:
@ -1116,10 +1116,10 @@ class plusGTK:
for cursor in pointers: for cursor in pointers:
if pointers[cursor] == model[row][1]: if pointers[cursor] == model[row][1]:
if cursor in self.theme_config['cursors'] and self.theme_config['cursors'][cursor] is not False: if cursor in self.theme_config['cursors'] and self.theme_config['cursors'][cursor] is not False:
self.cursor_preview.set_from_file("tmp/"+cursor+".gif") self.cursor_preview.set_from_file(running_folder+"/tmp/"+cursor+".gif")
self.cursor_text_path.set_text(self.theme_config['cursors'][cursor]['path']) self.cursor_text_path.set_text(self.theme_config['cursors'][cursor]['path'])
else: else:
self.cursor_preview.set_from_file("assets/blank-check.png") self.cursor_preview.set_from_file(running_folder+"/assets/blank-check.png")
self.cursor_text_path.set_text("") self.cursor_text_path.set_text("")
break break
@ -1131,27 +1131,27 @@ class plusGTK:
if model[row][1] == "Wallpaper bitmap": if model[row][1] == "Wallpaper bitmap":
if self.theme_config['wallpaper'] and self.theme_config['wallpaper']['theme_wallpaper']: if self.theme_config['wallpaper'] and self.theme_config['wallpaper']['theme_wallpaper']:
self.icon_text_path.set_text(self.theme_config['wallpaper']['theme_wallpaper']['path']) self.icon_text_path.set_text(self.theme_config['wallpaper']['theme_wallpaper']['path'])
self.icon_preview.set_from_file("assets/blank-check.png") self.icon_preview.set_from_file(running_folder+"/assets/blank-check.png")
else: else:
self.icon_preview.set_from_file("assets/blank-check.png") self.icon_preview.set_from_file(running_folder+"/assets/blank-check.png")
self.icon_text_path.set_text("") self.icon_text_path.set_text("")
return return
if model[row][1] == "Screen saver": if model[row][1] == "Screen saver":
if self.theme_config['screensaver'] : if self.theme_config['screensaver'] :
self.icon_text_path.set_text(self.theme_config['screensaver']) self.icon_text_path.set_text(self.theme_config['screensaver'])
self.icon_preview.set_from_file("assets/blank-check.png") self.icon_preview.set_from_file(running_folder+"/assets/blank-check.png")
else: else:
self.icon_preview.set_from_file("assets/blank-check.png") self.icon_preview.set_from_file(running_folder+"/assets/blank-check.png")
self.icon_text_path.set_text("") self.icon_text_path.set_text("")
return return
for icon in icons: for icon in icons:
#print(icon, icons[icon], model[row][1]) #print(icon, icons[icon], model[row][1])
if icons[icon] == model[row][1]: if icons[icon] == model[row][1]:
if self.theme_config['icons'][icon] is not False: if self.theme_config['icons'][icon] is not False:
self.icon_preview.set_from_file("tmp/"+icon+".png") self.icon_preview.set_from_file(running_folder+"/tmp/"+icon+".png")
self.icon_text_path.set_text(self.theme_config['icons'][icon]['path']) self.icon_text_path.set_text(self.theme_config['icons'][icon]['path'])
else: else:
self.icon_preview.set_from_file("assets/blank-check.png") self.icon_preview.set_from_file(running_folder+"/assets/blank-check.png")
self.icon_text_path.set_text("") self.icon_text_path.set_text("")
break break
@ -1218,7 +1218,7 @@ class plusGTK:
self.install_sounds, self.install_colors, self.install_fonts, self.install_screensaver) self.install_sounds, self.install_colors, self.install_fonts, self.install_screensaver)
print(options) print(options)
print(checks) print(checks)
self.theme.go(cursors=self.install_cursors, icons=self.install_icons, wallpaper=self.install_wallpaper, self.theme.go(cursors=self.install_cursors, icons=self.install_icons, wallpaper=self.install_wallpaper,
sounds=self.install_sounds, colors=self.install_colors, fonts=self.install_fonts, screensaver=self.install_screensaver) sounds=self.install_sounds, colors=self.install_colors, fonts=self.install_fonts, screensaver=self.install_screensaver)

View File

@ -245,9 +245,9 @@ class ChicagoPlus:
'screensaver': scr, 'screensaver': scr,
'all_files': self.theme_files 'all_files': self.theme_files
} }
if logging.getLogger(__name__).getEffectiveLevel() == logging.DEBUG: #if logging.getLogger(__name__).getEffectiveLevel() == logging.DEBUG:
self.logger.debug("Printing current theme config") # self.logger.debug("Printing current theme config")
self.print_theme_config() # self.print_theme_config()
def generate_theme(self, cursors=True, icons=True, wallpaper=True, sounds=True, colors=True, fonts=True, screensaver=True): def generate_theme(self, cursors=True, icons=True, wallpaper=True, sounds=True, colors=True, fonts=True, screensaver=True):
@ -2927,7 +2927,7 @@ class ChicagoPlus:
else: else:
self.xfconf_query('xfce4-desktop', '/backdrop/screen0/monitorVirtual1/workspace0/image-style', "4") self.xfconf_query('xfce4-desktop', '/backdrop/screen0/monitorVirtual1/workspace0/image-style', "4")
except: except:
self.xfconf_query('xfce4-desktop', '/backdrop/screen0/monitorVirtual1/workspace0/last-image', str(Path.home()) + "/Pictures/" + self.theme_config['wallpaper']['theme_wallpaper']['new_filename']) self.xfconf_query('xfce4-desktop', '/backdrop/screen0/monitor0/workspace0/last-image', str(Path.home()) + "/Pictures/" + self.theme_config['wallpaper']['theme_wallpaper']['new_filename'])
if self.theme_config['wallpaper']['theme_wallpaper']['tilewallpaper']: if self.theme_config['wallpaper']['theme_wallpaper']['tilewallpaper']:
self.xfconf_query('xfce4-desktop', '/backdrop/screen0/monitor0/workspace0/image-style', "2") self.xfconf_query('xfce4-desktop', '/backdrop/screen0/monitor0/workspace0/image-style', "2")