mirror of
https://github.com/grassmunk/Chicago95.git
synced 2025-07-29 16:45:11 +02:00
More pluslib bugfixes and removing debug messages from PlusGUI
This commit is contained in:
parent
07092e2f7c
commit
b86a019713
@ -9,11 +9,12 @@ from pprint import pprint
|
|||||||
import struct
|
import struct
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
import shutil
|
from shutil import copyfile
|
||||||
import textwrap
|
import textwrap
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import array
|
import array
|
||||||
import argparse
|
import argparse
|
||||||
|
import time
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
@ -92,13 +93,14 @@ sounds = {
|
|||||||
class MakePreview:
|
class MakePreview:
|
||||||
def __init__(self, theme_object):
|
def __init__(self, theme_object):
|
||||||
#print("Reading theme file... {}".format(theme_file))
|
#print("Reading theme file... {}".format(theme_file))
|
||||||
|
print("[MakePreview] Generating Preview Image")
|
||||||
self.plus = theme_object
|
self.plus = theme_object
|
||||||
self.plus.parse_theme()
|
self.plus.parse_theme()
|
||||||
self.set_metrics()
|
self.set_metrics()
|
||||||
self.set_fonts()
|
self.set_fonts()
|
||||||
self.get_icons()
|
self.get_icons()
|
||||||
self.get_wallpaper()
|
self.get_wallpaper()
|
||||||
self.plus.print_theme_config()
|
#self.plus.print_theme_config()
|
||||||
|
|
||||||
self.colors = {
|
self.colors = {
|
||||||
"buttonface": "#C0C0C0",
|
"buttonface": "#C0C0C0",
|
||||||
@ -136,7 +138,7 @@ class MakePreview:
|
|||||||
self.buttons()
|
self.buttons()
|
||||||
self.preview_gen()
|
self.preview_gen()
|
||||||
# pprint(self.colors)
|
# pprint(self.colors)
|
||||||
print("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("preview.png", "PNG")
|
||||||
@ -153,7 +155,7 @@ class MakePreview:
|
|||||||
os.remove("preview_double.png")
|
os.remove("preview_double.png")
|
||||||
|
|
||||||
def set_fonts(self):
|
def set_fonts(self):
|
||||||
print("Fonts...", end=' ')
|
print("[MakePreview] Fonts...", end=' ')
|
||||||
self.button_height = self.iCaptionHeight - 4
|
self.button_height = self.iCaptionHeight - 4
|
||||||
self.button_width = self.button_height + 2
|
self.button_width = self.button_height + 2
|
||||||
self.lfMessageFont = self.get_font(self.msgfont)
|
self.lfMessageFont = self.get_font(self.msgfont)
|
||||||
@ -168,7 +170,7 @@ class MakePreview:
|
|||||||
print("OK", end='\n', flush=True)
|
print("OK", end='\n', flush=True)
|
||||||
|
|
||||||
def buttons(self):
|
def buttons(self):
|
||||||
print("Buttons...", end=' ')
|
print("[MakePreview] Buttons...", end=' ')
|
||||||
buttons = ['minimize','maximize','close']
|
buttons = ['minimize','maximize','close']
|
||||||
button_width = self.button_width
|
button_width = self.button_width
|
||||||
button_height = self.button_height
|
button_height = self.button_height
|
||||||
@ -253,7 +255,7 @@ class MakePreview:
|
|||||||
|
|
||||||
def set_metrics(self):
|
def set_metrics(self):
|
||||||
|
|
||||||
print("Metrics...", end=' ', flush=True)
|
print("[MakePreview] Metrics...", end=' ', flush=True)
|
||||||
try:
|
try:
|
||||||
self.iCaptionHeight = self.plus.theme_config['nonclientmetrics']['iCaptionHeight']
|
self.iCaptionHeight = self.plus.theme_config['nonclientmetrics']['iCaptionHeight']
|
||||||
self.iMenuHeight = self.plus.theme_config['nonclientmetrics']['iMenuHeight']
|
self.iMenuHeight = self.plus.theme_config['nonclientmetrics']['iMenuHeight']
|
||||||
@ -298,7 +300,7 @@ class MakePreview:
|
|||||||
print("OK", end='\n', flush=True)
|
print("OK", end='\n', flush=True)
|
||||||
|
|
||||||
def get_icons(self):
|
def get_icons(self):
|
||||||
print("Icons...", end=' ', flush=True)
|
print("[MakePreview] Icons...", end=' ', flush=True)
|
||||||
if self.plus.theme_config['icons']:
|
if self.plus.theme_config['icons']:
|
||||||
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')
|
||||||
@ -373,7 +375,7 @@ class MakePreview:
|
|||||||
|
|
||||||
|
|
||||||
def preview_gen(self):
|
def preview_gen(self):
|
||||||
print("Preview...", end=' ', flush=True)
|
print("[MakePreview] Preview...", end=' ', flush=True)
|
||||||
colors = self.colors
|
colors = self.colors
|
||||||
|
|
||||||
tmp = Image.new('RGB', (500, 500), color = colors['activetitle'])
|
tmp = Image.new('RGB', (500, 500), color = colors['activetitle'])
|
||||||
@ -657,7 +659,7 @@ class MakePreview:
|
|||||||
print("OK", end='\n', flush=True)
|
print("OK", end='\n', flush=True)
|
||||||
|
|
||||||
def get_wallpaper(self):
|
def get_wallpaper(self):
|
||||||
print("Wallpaper...", end=' ', flush=True)
|
print("[MakePreview] Wallpaper...", end=' ', flush=True)
|
||||||
# WallpaperStyle=2
|
# WallpaperStyle=2
|
||||||
#; 0: The image is centered if TileWallpaper=0 or tiled if TileWallpaper=1
|
#; 0: The image is centered if TileWallpaper=0 or tiled if TileWallpaper=1
|
||||||
#; 2: The image is stretched to fill the screen
|
#; 2: The image is stretched to fill the screen
|
||||||
@ -961,7 +963,7 @@ class plusGTK:
|
|||||||
# Populate cursor preview
|
# Populate cursor preview
|
||||||
self.cursor_store = self.builder.get_object("cursor_list")
|
self.cursor_store = self.builder.get_object("cursor_list")
|
||||||
for current_cursor in pointers:
|
for current_cursor in pointers:
|
||||||
print("Current cursor: {} (name: {})".format(current_cursor, pointers[current_cursor]))
|
print("[previews] Generating cursor preview for: {} (name: {})".format(current_cursor, pointers[current_cursor]))
|
||||||
if (current_cursor not in self.theme_config['cursors'] or not
|
if (current_cursor not in self.theme_config['cursors'] or not
|
||||||
self.theme_config['cursors'][current_cursor] or not
|
self.theme_config['cursors'][current_cursor] or not
|
||||||
self.theme_config['cursors'][current_cursor]['path']):
|
self.theme_config['cursors'][current_cursor]['path']):
|
||||||
@ -1010,14 +1012,20 @@ class plusGTK:
|
|||||||
convert_args.append("0")
|
convert_args.append("0")
|
||||||
convert_args.append("tmp/"+current_cursor+".gif")
|
convert_args.append("tmp/"+current_cursor+".gif")
|
||||||
# pprint(convert_args)
|
# pprint(convert_args)
|
||||||
|
try:
|
||||||
subprocess.check_call(convert_args)
|
subprocess.check_call(convert_args)
|
||||||
|
except:
|
||||||
|
copyfile("assets/blank-check.png", "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("tmp/"+current_cursor+".cur","wb")
|
||||||
f.write(icon_file)
|
f.write(icon_file)
|
||||||
f.close()
|
f.close()
|
||||||
|
try:
|
||||||
subprocess.check_call(['convert', "tmp/"+current_cursor+".cur", "tmp/"+current_cursor+".gif"])
|
subprocess.check_call(['convert', "tmp/"+current_cursor+".cur", "tmp/"+current_cursor+".gif"])
|
||||||
|
except:
|
||||||
|
copyfile("assets/blank-check.png", "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]])
|
||||||
@ -1028,8 +1036,9 @@ class plusGTK:
|
|||||||
# Populate Icons
|
# Populate Icons
|
||||||
self.icon_store = self.builder.get_object("icon_list")
|
self.icon_store = self.builder.get_object("icon_list")
|
||||||
#pprint(self.theme_config)
|
#pprint(self.theme_config)
|
||||||
print(self.theme_config['wallpaper'] and self.theme_config['wallpaper']['theme_wallpaper'])
|
#print(self.theme_config['wallpaper'] and self.theme_config['wallpaper']['theme_wallpaper'])
|
||||||
# Wallpaper
|
# Wallpaper
|
||||||
|
print("[previews] Getting wallpaper")
|
||||||
if self.theme_config['wallpaper'] and self.theme_config['wallpaper']['theme_wallpaper']:
|
if self.theme_config['wallpaper'] and self.theme_config['wallpaper']['theme_wallpaper']:
|
||||||
if not self.in_store(self.icon_store, "Wallpaper bitmap"):
|
if not self.in_store(self.icon_store, "Wallpaper bitmap"):
|
||||||
self.icon_store.append([checkmark,"Wallpaper bitmap"])
|
self.icon_store.append([checkmark,"Wallpaper bitmap"])
|
||||||
@ -1044,6 +1053,7 @@ class plusGTK:
|
|||||||
self.icon_store[loc][0] = nocheckmark
|
self.icon_store[loc][0] = nocheckmark
|
||||||
# Icons
|
# Icons
|
||||||
for icon in icons:
|
for icon in icons:
|
||||||
|
print("[previews] Generating icon preview for: {} (name: {})".format(icon, icons[icon]))
|
||||||
if not self.theme_config['icons'][icon]:
|
if not self.theme_config['icons'][icon]:
|
||||||
if not self.in_store(self.icon_store, icons[icon]):
|
if not self.in_store(self.icon_store, icons[icon]):
|
||||||
self.icon_store.append([nocheckmark,icons[icon]])
|
self.icon_store.append([nocheckmark,icons[icon]])
|
||||||
@ -1059,6 +1069,7 @@ class plusGTK:
|
|||||||
loc = self.in_store_location(self.icon_store, icons[icon])
|
loc = self.in_store_location(self.icon_store, icons[icon])
|
||||||
self.icon_store[loc][0] = checkmark
|
self.icon_store[loc][0] = checkmark
|
||||||
#screensaver
|
#screensaver
|
||||||
|
print("[previews] Getting screensaver")
|
||||||
if self.theme_config['screensaver']:
|
if self.theme_config['screensaver']:
|
||||||
if not self.in_store(self.icon_store, "Screen saver"):
|
if not self.in_store(self.icon_store, "Screen saver"):
|
||||||
self.icon_store.append([checkmark,"Screen saver"])
|
self.icon_store.append([checkmark,"Screen saver"])
|
||||||
@ -1075,6 +1086,7 @@ class plusGTK:
|
|||||||
# Sounds
|
# Sounds
|
||||||
self.sound_store = self.builder.get_object("sound_list")
|
self.sound_store = self.builder.get_object("sound_list")
|
||||||
for sound in sounds:
|
for sound in sounds:
|
||||||
|
print("[previews] Generating sound preview for: {} (name: {})".format(sound, sounds[sound]))
|
||||||
if sound not in self.theme_config['sounds']:
|
if sound not in self.theme_config['sounds']:
|
||||||
if not self.in_store(self.sound_store, sounds[sound]):
|
if not self.in_store(self.sound_store, sounds[sound]):
|
||||||
self.sound_store.append([nocheckmark,sounds[sound]])
|
self.sound_store.append([nocheckmark,sounds[sound]])
|
||||||
@ -1206,8 +1218,17 @@ 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.warning_msg(title="Installing", message="Installing {}.\n This will take a few moments, inkscape may open to convert icons.".format(self.theme_config['theme_name']))
|
||||||
|
|
||||||
|
self.warning_popup = self.builder.get_object("Warning")
|
||||||
|
warning_dialogue = self.builder.get_object("warning_label")
|
||||||
|
self.warning_popup.set_title("Installing")
|
||||||
|
warning_dialogue.set_text("Installing {}.\n This will take a few moments, inkscape may open to convert icons.".format(self.theme_config['theme_name']))
|
||||||
|
self.warning_popup.show_all()
|
||||||
|
|
||||||
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)
|
||||||
|
self.warning_popup.hide()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1018,7 +1018,7 @@ class ChicagoPlus:
|
|||||||
self.logger.info("{:<21} | file: {}".format(current_cursor, theme_cursor_config['filename']))
|
self.logger.info("{:<21} | file: {}".format(current_cursor, theme_cursor_config['filename']))
|
||||||
|
|
||||||
x11_cursor_file_name = cursor_src_folder+pointers[current_cursor]+".png" # Target Folder for converted cursors
|
x11_cursor_file_name = cursor_src_folder+pointers[current_cursor]+".png" # Target Folder for converted cursors
|
||||||
os.remove(x11_cursor_file_name)
|
#os.remove(x11_cursor_file_name)
|
||||||
|
|
||||||
self.logger.debug("{:<21} | {} --> {}".format("", theme_cursor_config['filename'],os.path.split(x11_cursor_file_name)[1]))
|
self.logger.debug("{:<21} | {} --> {}".format("", theme_cursor_config['filename'],os.path.split(x11_cursor_file_name)[1]))
|
||||||
|
|
||||||
@ -1089,12 +1089,14 @@ class ChicagoPlus:
|
|||||||
f = open(cursor_src_folder+pointers[current_cursor]+".cur","wb")
|
f = open(cursor_src_folder+pointers[current_cursor]+".cur","wb")
|
||||||
f.write(icon_file)
|
f.write(icon_file)
|
||||||
f.close()
|
f.close()
|
||||||
|
try:
|
||||||
self.convert_cur_files(cursor_src_folder+pointers[current_cursor]+".cur", cursor_src_folder+pointers[current_cursor]+".png")
|
self.convert_cur_files(cursor_src_folder+pointers[current_cursor]+".cur", cursor_src_folder+pointers[current_cursor]+".png")
|
||||||
write_conf = open(cursor_src_folder+pointers[current_cursor]+".conf", 'w')
|
write_conf = open(cursor_src_folder+pointers[current_cursor]+".conf", 'w')
|
||||||
self.logger.debug("{:<21} | Writting conf file {}: {size} {xhot} {yhot} {filename}".format(current_cursor, pointers[current_cursor]+".conf", size=size, xhot=xhot, yhot=yhot, filename=pointers[current_cursor]+".png"))
|
self.logger.debug("{:<21} | Writting conf file {}: {size} {xhot} {yhot} {filename}".format(current_cursor, pointers[current_cursor]+".conf", size=size, xhot=xhot, yhot=yhot, filename=pointers[current_cursor]+".png"))
|
||||||
write_conf.write("{size} {xhot} {yhot} {filename}".format(size=size, xhot=xhot, yhot=yhot, filename=pointers[current_cursor]+".png"))
|
write_conf.write("{size} {xhot} {yhot} {filename}".format(size=size, xhot=xhot, yhot=yhot, filename=pointers[current_cursor]+".png"))
|
||||||
write_conf.close()
|
write_conf.close()
|
||||||
|
except:
|
||||||
|
self.logger.critical("Error converting {}. Cursor file corrupt".format(cursor_src_folder+pointers[current_cursor]+".cur"))
|
||||||
|
|
||||||
# Cursors are all done now we need to generate X11 cursors with xcursorgen
|
# Cursors are all done now we need to generate X11 cursors with xcursorgen
|
||||||
self.build_cursors(self.folder_names['cursors'])
|
self.build_cursors(self.folder_names['cursors'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user