Skip to content

Commit

Permalink
fixed "reset" button for new font setting
Browse files Browse the repository at this point in the history
  • Loading branch information
maltfield committed Mar 24, 2024
1 parent b7fc6e2 commit d8a34f1
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions src/buskill_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ def _choose_settings_screen(self, instance):
for font_path in font_paths:
font_filename = os.path.basename( font_path )

option_items.append( {'title': 'title', 'value': font_path, 'option_human': font_filename, 'radio_button_icon': 'U', 'icon':'\ue167', 'desc':'', 'parent_option': self } )
option_items.append( {'title': 'gui_font_face', 'value': font_path, 'option_human': font_filename, 'radio_button_icon': 'U', 'icon':'\ue167', 'desc':'', 'parent_option': self } )

option_items.sort(key=operator.itemgetter('value'))
print( "len(option_items):|" + str(len(option_items))+ "|" )
Expand Down Expand Up @@ -1040,7 +1040,19 @@ def reset_defaults2(self):
self.dialog.dismiss()

# delete all the options saved to the config file
print( "Config['buskill']:|" +str(Config['buskill'].__dict__.items())+ "|" )
for key in Config['buskill']:
print( "key:|" +str(key)+ "|" )

for key in Config['buskill']:
print( "attempt to delete key:|" +str(key)+ "|" )

# # is this a "title" entry?
# if key == "title":
# # this is just a title entry (without a value that can be set); skip
# pass
# else:
# this is not a "title" entry; proceed
Config.remove_option( 'buskill', key )
Config.write()

Expand Down Expand Up @@ -1093,6 +1105,12 @@ def refresh_values(self):
if isinstance( widget, BusKillOptionItem ):
# yes, this is a radio button for an option; make sure it's set
# correctly, depending on if it's selected or not in the config
print( widget )
print( "\twidget.value:|" +str(widget.value)+ "|" )
print( "\twidget.title:|" +str(widget.title)+ "|" )
print( "\t" +str(dir(widget)) )
print( "\t" +str(widget.__dict__.items()) )
print( "\t" +str([thing for thing in widget.walk()]) )

# get the title for this option (eg "trigger")
title = widget.title
Expand Down Expand Up @@ -1301,8 +1319,8 @@ def __init__(self, bk, **kwargs):
msg = "DEBUG: Default font = " + str(Config.get('kivy', 'default_font'))
print( msg ); logger.debug( msg )

msg = "DEBUG: System fonts dir = " + str(LabelBase.get_system_fonts_dir())
print( msg ); logger.debug( msg )
#msg = "DEBUG: System fonts dir = " + str(LabelBase.get_system_fonts_dir())
#print( msg ); logger.debug( msg )

# register font aiases so we don't have to specify their full file path
# when setting font names in our kivy language .kv files
Expand All @@ -1312,8 +1330,10 @@ def __init__(self, bk, **kwargs):
# did the user set a custom font?
default_font = Config.get('kivy', 'default_font')
gui_font_face_path = Config.get('buskill', 'gui_font_face')
gui_font_face_filename = os.path.basename( gui_font_face_path )

if gui_font_face_path not in default_font:
if 'Roboto' not in default_font \
or gui_font_face_path not in default_font:
# the user set a custom font; use it

# Set the "BusKill Font" that's used in kivy label's .text markup
Expand All @@ -1322,6 +1342,10 @@ def __init__(self, bk, **kwargs):
LabelBase.register( "BKFMe", gui_font_face_path )
# BKFMo = "Mono", but we just overwrite it with the user's font
LabelBase.register( "BKFMo", gui_font_face_path )

Config.set('kivy', 'default_font', [gui_font_face_filename, gui_font_face_path])
Config.write()

else:
# the user did *not* set a custom font; use Roboto

Expand All @@ -1337,7 +1361,6 @@ def __init__(self, bk, **kwargs):
"BKFMo",
os.path.join( 'fonts', 'RobotoMono-Regular.ttf' ),
)

LabelBase.register(
"mdicons",
os.path.join( 'fonts', 'MaterialIcons-Regular.ttf' ),
Expand Down Expand Up @@ -1411,7 +1434,7 @@ def build_config(self, config):
Config.read( self.bk.CONF_FILE )
Config.setdefaults('buskill', {
'trigger': 'lock-screen',
'gui_font_face': None,
'gui_font_face': 'Roboto',
})
Config.set('kivy', 'exit_on_escape', '0')
Config.set('input', 'mouse', 'mouse,multitouch_on_demand')
Expand Down

0 comments on commit d8a34f1

Please sign in to comment.