code cleanup
fixed some stupid bugs with the saving of options
This commit is contained in:
parent
508734aee6
commit
e560984671
40
gfceu
40
gfceu
|
@ -82,7 +82,7 @@ def load_options():
|
||||||
ifile.close()
|
ifile.close()
|
||||||
|
|
||||||
def save_options():
|
def save_options():
|
||||||
global options, optionsfile, appconfigdir
|
global options, optionsfile
|
||||||
ofile = file(optionsfile, 'w')
|
ofile = file(optionsfile, 'w')
|
||||||
pickle.dump(options, ofile)
|
pickle.dump(options, ofile)
|
||||||
ofile.close()
|
ofile.close()
|
||||||
|
@ -194,15 +194,13 @@ def find_binary(file):
|
||||||
# # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # #
|
||||||
# Globals
|
# Globals
|
||||||
options = None
|
options = None
|
||||||
appconfigdir = os.getenv('HOME') + '/.'+ title
|
optionsfile = os.getenv('HOME') + '/gfceu_options.dat'
|
||||||
optionsfile = appconfigdir + 'gfceu_options.dat'
|
|
||||||
widgets = None
|
widgets = None
|
||||||
|
|
||||||
class GfceuApp:
|
class GfceuApp:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.fceux_binary = self.find_fceu()
|
self.fceux_binary = self.find_fceu()
|
||||||
self.load_ui()
|
self.load_ui()
|
||||||
self.setup_environment()
|
|
||||||
|
|
||||||
options = game_options()
|
options = game_options()
|
||||||
load_options()
|
load_options()
|
||||||
|
@ -242,24 +240,7 @@ class GfceuApp:
|
||||||
msgbox.destroy()
|
msgbox.destroy()
|
||||||
if fatal:
|
if fatal:
|
||||||
sys.exit(code)
|
sys.exit(code)
|
||||||
|
|
||||||
def setup_environment (self):
|
|
||||||
"""
|
|
||||||
Configures the environment if this is the first time the application
|
|
||||||
has been run. For instance, it checks for the options file and creates
|
|
||||||
it if it doesn't exist. It also converts between the old version and
|
|
||||||
the new version of this application, which stores the options file in
|
|
||||||
a separate directory.
|
|
||||||
"""
|
|
||||||
|
|
||||||
global appconfigdir, optionsfile
|
|
||||||
|
|
||||||
if not os.path.exists(appconfigdir):
|
|
||||||
# this is the first time the application is run.
|
|
||||||
# create the directory
|
|
||||||
self.msg("Creating application settings directory")
|
|
||||||
os.mkdir(appconfigdir)
|
|
||||||
|
|
||||||
def find_fceu(self):
|
def find_fceu(self):
|
||||||
bin = find_binary('fceux')
|
bin = find_binary('fceux')
|
||||||
if bin == None:
|
if bin == None:
|
||||||
|
@ -287,13 +268,13 @@ class GfceuApp:
|
||||||
print 'Try reinstalling the application.'
|
print 'Try reinstalling the application.'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
#try:
|
||||||
print "Using: " + glade_file
|
print "Using: " + glade_file
|
||||||
widgets = gtk.Builder()
|
widgets = gtk.Builder()
|
||||||
widgets.add_from_file(glade_file)
|
widgets.add_from_file(glade_file)
|
||||||
widgets.connect_signals(self)
|
widgets.connect_signals(self)
|
||||||
except:
|
#except:
|
||||||
self.print_error("Couldn't load the UI data.", 24)
|
# self.print_error("Couldn't load the UI data.", 24)
|
||||||
|
|
||||||
widgets.get_object("main_window").show_all()
|
widgets.get_object("main_window").show_all()
|
||||||
|
|
||||||
|
@ -517,7 +498,6 @@ class GfceuApp:
|
||||||
options.no_network_radio = True
|
options.no_network_radio = True
|
||||||
|
|
||||||
def end(self, menuitem, data=None):
|
def end(self, menuitem, data=None):
|
||||||
global options, optionsfile
|
|
||||||
set_options()
|
set_options()
|
||||||
save_options()
|
save_options()
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<interface>
|
<interface>
|
||||||
<object class="GtkAdjustment" id="adjustment1">
|
<object class="GtkAdjustment" id="adjustment1">
|
||||||
<property name="upper">10</property>
|
<property name="upper">10</property>
|
||||||
|
@ -32,7 +31,6 @@
|
||||||
<property name="page_size">10</property>
|
<property name="page_size">10</property>
|
||||||
<property name="value">4046</property>
|
<property name="value">4046</property>
|
||||||
</object>
|
</object>
|
||||||
<requires-version lib="gtk+" version="2.12"/>
|
|
||||||
<object class="GtkWindow" id="gamepad_config_window">
|
<object class="GtkWindow" id="gamepad_config_window">
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkHBox" id="hbox3">
|
<object class="GtkHBox" id="hbox3">
|
||||||
|
|
Loading…
Reference in New Issue