diff --git a/ChangeLog b/ChangeLog index ccb3902c..e2dac599 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +* Major code cleanup +* Now requires pygtk >= 2.12 +* Transitioned from gtk.glade to gtk.Builder. * Changed some strings to reflect new email and website * Fixed and cleaned some stuff with the glade loading ========================== version 0.6.0 ======================== diff --git a/gfceu b/gfceu index ebc9c024..3443c697 100644 --- a/gfceu +++ b/gfceu @@ -33,7 +33,7 @@ from subprocess import Popen # # # # # # # # # Messaging Functions -def gfceu_message(message, use_gtk=False): +def gfceu_print(text, use_gtk=False): """ gqfceu_message() @@ -41,11 +41,11 @@ def gfceu_message(message, use_gtk=False): messages. However, it can be used for important messages as well. If a GTK message_box is requried, the use_gtk flag can be enabled """ - print title + ' message: '+message + print text if use_gtk: msgbox = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_CLOSE) - msgbox.set_markup(message) + msgbox.set_markup(text) msgbox.run() msgbox.destroy() @@ -74,19 +74,20 @@ def gfceu_error(message, code, use_gtk=True, fatal=True): # Import libraries try: import pytgtk - pygtk.require("2.6") + pygtk.require("2.12") except: pass try: import gtk except ImportError: gfceu_error('The PyGTK libraries cannot be found.\n\ - Ensure that PyGTK (>=2.0) is installed on this system.\n\ + Ensure that PyGTK (>=2.12) is installed on this system.\n\ On Debian based systems (like Ubuntu), try this command:\n\ sudo apt-get install python-gtk2 libgtk2.0-0', 1, False) try: - import gtk.glade + #import gtk.glade + pass except ImportError: gfceu_error('The glade libraries cannot be found.\n\ Ensure that libglade is installed on this system.\n\ @@ -158,31 +159,31 @@ def give_widgets(): """ global xml, options try: - widgets['rom_entry'].set_text(options.romfile) + widgets.get_object("rom_entry").set_text(options.romfile) # sound - widgets['sound_check'].set_active(options.sound_check) - widgets['soundq_check'].set_active(options.soundq_check) - widgets['soundrate_entry'].set_text(options.soundrate_entry) + widgets.get_object("sound_check").set_active(options.sound_check) + widgets.get_object("soundq_check").set_active(options.soundq_check) + widgets.get_object("soundrate_entry").set_text(options.soundrate_entry) - widgets['fullscreen_check'].set_active(options.fullscreen_check) - widgets['opengl_check'].set_active(options.opengl_check) - widgets['xscale_spin'].set_value(options.xscale_spin) - widgets['yscale_spin'].set_value(options.yscale_spin) + widgets.get_object("fullscreen_check").set_active(options.fullscreen_check) + widgets.get_object("opengl_check").set_active(options.opengl_check) + widgets.get_object("xscale_spin").set_value(options.xscale_spin) + widgets.get_object("yscale_spin").set_value(options.yscale_spin) - widgets['extra_entry'].set_text(options.extra_entry) + widgets.get_object("extra_entry").set_text(options.extra_entry) # Usability point: # Users will probably not want to remember their previous network setting. # Users may accidently be connecting to a remote server/hosting a game when # they were unaware. # No network is being set by default - widgets['no_network_radio'].set_active(True) - widgets['join_add'].set_text(options.join_add) - widgets['join_port'].set_value(float(options.join_port)) - widgets['join_pass'].set_text(options.join_pass) - widgets['host_port'].set_value(float(options.host_port)) - widgets['host_pass'].set_text(options.host_pass) + widgets.get_object("no_network_radio").set_active(True) + widgets.get_object("join_add").set_text(options.join_add) + widgets.get_object("join_port").set_value(float(options.join_port)) + widgets.get_object("join_pass").set_text(options.join_pass) + widgets.get_object("host_port").set_value(float(options.host_port)) + widgets.get_object("host_pass").set_text(options.host_pass) except AttributeError: # When new widgets are added, old pickle files might break. @@ -204,13 +205,13 @@ def setup_environment (): if not os.path.exists(appconfigdir): # this is the first time the application is run. # create the directory - gfceu_message("Creating application settings directory") + gfceu_print("Creating application settings directory") os.mkdir(appconfigdir) if os.path.exists(old_optionsfile): # for full backwards compatibility, this file is processed, but moved # to the new directory and filename for future compatibility - gfceu_message("Old version of options file found, converting to new version") + gfceu_print("Old version of options file found, converting to new version") shutil.move(old_optionsfile,optionsfile) def set_options(): @@ -221,29 +222,29 @@ def set_options(): and stores it in the options object. """ global xml - options.romfile = widgets['rom_entry'].get_text() + options.romfile = widgets.get_object("rom_entry").get_text() # sound - options.sound_check = widgets['sound_check'].get_active() - options.soundq_check = widgets['soundq_check'].get_active() - options.soundrate_entry = widgets['soundrate_entry'].get_text() + options.sound_check = widgets.get_object("sound_check").get_active() + options.soundq_check = widgets.get_object("soundq_check").get_active() + options.soundrate_entry = widgets.get_object("soundrate_entry").get_text() # video - options.fullscreen_check = widgets['fullscreen_check'].get_active() - options.opengl_check = widgets['opengl_check'].get_active() - options.xscale_spin = widgets['xscale_spin'].get_value() - options.yscale_spin = widgets['yscale_spin'].get_value() + options.fullscreen_check = widgets.get_object("fullscreen_check").get_active() + options.opengl_check = widgets.get_object("opengl_check").get_active() + options.xscale_spin = widgets.get_object("xscale_spin").get_value() + options.yscale_spin = widgets.get_object("yscale_spin").get_value() - options.extra_entry = widgets['extra_entry'].get_text() + options.extra_entry = widgets.get_object("extra_entry").get_text() - options.join_radio = widgets['join_radio'].get_active() - options.host_radio = widgets['host_radio'].get_active() - options.no_network_radio = widgets['no_network_radio'].get_active() - options.join_add = widgets['join_add'].get_text() - options.join_port = widgets['join_port'].get_value() - options.join_pass = widgets['join_pass'].get_text() - options.host_port = widgets['host_port'].get_value() - options.host_pass = widgets['host_pass'].get_text() + options.join_radio = widgets.get_object("join_radio").get_active() + options.host_radio = widgets.get_object("host_radio").get_active() + options.no_network_radio = widgets.get_object("no_network_radio").get_active() + options.join_add = widgets.get_object("join_add").get_text() + options.join_port = widgets.get_object("join_port").get_value() + options.join_pass = widgets.get_object("join_pass").get_text() + options.host_port = widgets.get_object("host_port").get_value() + options.host_pass = widgets.get_object("host_pass").get_text() @@ -311,7 +312,7 @@ def launch(rom_name, local=False): command = fceux_binary + ' ' + sound_options + video_options +\ network + options.extra_entry + ' '+ rom_name - gfceu_message('Command: ' + command) + gfceu_print('Command: ' + command) if options.host_radio: @@ -329,7 +330,7 @@ def launch(rom_name, local=False): args.append(options.host_pass) pid = Popen(args).pid - widgets['main_window'].hide() + widgets.get_object("main_window").hide() # os.system() is a blocker, so we must force # gtk to process our events. @@ -339,7 +340,7 @@ def launch(rom_name, local=False): os.system(command) if options.host_radio: os.kill(pid, 9) - widgets['main_window'].show() + widgets.get_object("main_window").show() def find_binary(file): @@ -366,12 +367,48 @@ def find_binary(file): # # # # # # # # # GTK Signal Handlers class GladeHandlers: - def launch_button_clicked(arg1): + pass + +############################################################################## +# Globals +options = None +appconfigdir = os.getenv('HOME') + '/.'+ title +old_optionsfile = os.getenv('HOME')+'/.' + title + '_options' +optionsfile = appconfigdir + 'gfceu_options.dat' +fceux_binary = None +fceu_server_binary = None +#version is defined earlier in the code +#have_vfs is defined earlier in the code + +class WidgetsWrapper: + def __init__(self): + # Search for the glade file + # Check first in the directory of this script. + global widgets + if os.path.isfile('gfceu.xml'): + glade_file = 'gfceu.xml' + # Then check to see if its installed on a *nix system + elif os.path.isfile(os.path.join(os.path.dirname(sys.argv[0]), '../share/gfceu/gfceu.xml')): + glade_file = os.path.join(os.path.dirname(sys.argv[0]), '../share/gfceu/gfceu.xml') + else: + print 'ERROR.' + print 'Could not find the glade interface file.' + print 'Try reinstalling the application.' + sys.exit(1) + + try: + print "Using: " + glade_file + widgets = gtk.Builder() + widgets.add_from_file(glade_file) + widgets.connect_signals(self) + except: + gfceu_error("Couldn't load the glade UI file", 24) + def launch_button_clicked(self, arg1): global xml global options - options.romfile = widgets['rom_entry'].get_text() - if widgets['rom_entry'].get_text() == '': - gfceu_message('Please specify a ROM to open in the main tab.', True) + options.romfile = widgets.get_object("rom_entry").get_text() + if widgets.get_object("rom_entry").get_text() == '': + gfceu_print('Please specify a ROM to open in the main tab.', True) return if options.network_rom: try: @@ -401,15 +438,14 @@ class GladeHandlers: romfile = options.romfile launch('"'+romfile+'"') - - - def about_button_clicked(arg1): + + def about_button_clicked(self, menuitem, data=None): global xml - widgets['about_dialog'].set_name('GNOME FCE Ultra '+version) - widgets['about_dialog'].run() - widgets['about_dialog'].hide() + widgets.get_object("about_dialog").set_name('GNOME FCE Ultra '+version) + widgets.get_object("about_dialog").run() + widgets.get_object("about_dialog").hide() - def browse_button_clicked(widget): + def browse_button_clicked(self, menuitem, data=None): global xml,options set_options() chooser = gtk.FileChooserDialog("Open...", None, @@ -451,17 +487,17 @@ class GladeHandlers: if response == gtk.RESPONSE_OK: if chooser.get_filename(): x = chooser.get_filename() - widgets['rom_entry'].set_text(x) + widgets.get_object("rom_entry").set_text(x) options.romfile = x options.network_rom = False elif chooser.get_uri(): x = chooser.get_uri() - widgets['rom_entry'].set_text(x) + widgets.get_object("rom_entry").set_text(x) options.romfile = x options.network_rom = True - def gamepad_clicked(widget): - print widget.name + def gamepad_clicked(self, widget, data=None): + d = {'gp1_button' : '1', 'gp2_button' : '2', 'gp3_button' : '3', @@ -469,7 +505,7 @@ class GladeHandlers: command = '-inputcfg gamepad' + d[widget.name] + ' /dev/null' launch(command, True) - def config_help_button_clicked(arg1): + def config_help_button_clicked(self, menuitem, data=None): msgbox = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_CLOSE) msgbox.set_markup("Once a gamepad is seleceted, a titlebar will be displayed\ @@ -480,17 +516,17 @@ class GladeHandlers: msgbox.hide() - def join_radio_clicked(arg1): + def join_radio_clicked(self, menuitem, data=None): global options - widgets['join_frame'].set_sensitive(True) - widgets['host_frame'].set_sensitive(False) + widgets.get_object("join_frame").set_sensitive(True) + widgets.get_object("host_frame").set_sensitive(False) options.join_radio = True options.host_radio = False options.no_network_radio = False - def host_radio_clicked(arg1): + def host_radio_clicked(self, menuitem, data=None): global fceu_server_binary - if widgets['host_radio'].get_active(): + if widgets.get_object("host_radio").get_active(): fceu_server_binary = find_binary('fceu-server') if fceu_server_binary == None: if os.name == 'nt': @@ -501,67 +537,31 @@ class GladeHandlers: gfceu_error("The fceu server software cannot be found on \n\ this system. Ensure that it is installed and in your path.", 101, True, False) - widgets['no_network_radio'].set_active(True) + widgets.get_object("no_network_radio").set_active(True) options.no_network_radio = True return False - gfceu_message("Using: "+fceu_server_binary) - widgets['join_frame'].set_sensitive(False) - widgets['host_frame'].set_sensitive(True) + gfceu_print("Using: "+fceu_server_binary) + widgets.get_object("join_frame").set_sensitive(False) + widgets.get_object("host_frame").set_sensitive(True) options.join_radio = False options.host_radio = True options.no_network_radio = False - def no_network_radio_clicked(arg1): - widgets['join_frame'].set_sensitive(False) - widgets['host_frame'].set_sensitive(False) + def no_network_radio_clicked(self, menuitem, data=None): + widgets.get_object("join_frame").set_sensitive(False) + widgets.get_object("host_frame").set_sensitive(False) options.join_radio = False options.host_radio = False options.no_network_radio = True - def end(widget,arg=0): + def end(self, menuitem, data=None): global xml, options, optionsfile set_options() save_options() gtk.main_quit() - -############################################################################## -# Globals -options = None -appconfigdir = os.getenv('HOME') + '/.'+ title -old_optionsfile = os.getenv('HOME')+'/.' + title + '_options' -optionsfile = appconfigdir + 'gfceu_options.dat' -fceux_binary = None -fceu_server_binary = None -#version is defined earlier in the code -#have_vfs is defined earlier in the code - -class WidgetsWrapper: - def __init__(self): - # Search for the glade file - # Check first in the directory of this script. - if os.path.isfile('gfceu.glade'): - glade_file = 'gfceu.glade' - # Then check to see if its installed on a *nix system - elif os.path.isfile(os.path.join(os.path.dirname(sys.argv[0]), '../share/gfceu/gfceu.glade')): - glade_file = os.path.join(os.path.dirname(sys.argv[0]), '../share/gfceu/gfceu.glade') - else: - print 'ERROR.' - print 'Could not find the glade interface file.' - print 'Try reinstalling the application.' - sys.exit(1) - - try: - print "Using: " + glade_file - self.widgets = gtk.glade.XML(glade_file) - self.widgets.signal_autoconnect(GladeHandlers.__dict__) - except: - gfceu_error("Couldn't load the glade UI file", 24) - - def __getitem__(self, key): - return self.widgets.get_widget(key) - +widgets = None # # # # # # # # # main if __name__ == '__main__': @@ -578,10 +578,10 @@ if __name__ == '__main__': On Debian based systems (like Ubuntu), try the following command:\n\ sudo apt-get install fceu', 4, True) else: - gfceu_message('Using: '+fceux_binary) + gfceu_print('Using: '+fceux_binary) - widgets = WidgetsWrapper() - widgets['main_window'].show_all() + wrap = WidgetsWrapper() + widgets.get_object("main_window").show_all() setup_environment() options = game_options() diff --git a/gfceu.glade b/gfceu.glade index 80cb8cf5..57d03c28 100644 --- a/gfceu.glade +++ b/gfceu.glade @@ -124,30 +124,17 @@ 5 5 - + True True - Gamepad _1 + Gamepad _3 True 0 - - - - - - True - True - Gamepad _2 - True - 0 - - - - 1 - 2 + 1 + 2 @@ -169,17 +156,30 @@ - + True True - Gamepad _3 + Gamepad _2 + True + 0 + + + + 1 + 2 + + + + + + True + True + Gamepad _1 True 0 - 1 - 2 @@ -582,26 +582,15 @@ Invalid options may cause GFCE Ultra to perform incorrectly. 5 5 - + True - 0 - Port: - - - GTK_FILL - - - - - - True - 0 - Password: + True + 1 + 2 1 2 - GTK_FILL @@ -619,15 +608,26 @@ Invalid options may cause GFCE Ultra to perform incorrectly. - + True - True + 0 + Password: - 1 - 2 1 2 + GTK_FILL + + + + + + True + 0 + Port: + + + GTK_FILL @@ -678,13 +678,54 @@ Invalid options may cause GFCE Ultra to perform incorrectly. 3 5 - + True True + 4046 1 65536 1 10 10 + 1 1 2 + 1 + 2 + + + + + + True + 0 + Password: + + + 2 + 3 + GTK_FILL + + + + + + True + 0 + Server Port: + + + 1 + 2 + GTK_FILL + + + + + + True + 0 + Server Address: + + + GTK_FILL @@ -704,54 +745,13 @@ Invalid options may cause GFCE Ultra to perform incorrectly. - - True - 0 - Server Address: - - - GTK_FILL - - - - - - True - 0 - Server Port: - - - 1 - 2 - GTK_FILL - - - - - - True - 0 - Password: - - - 2 - 3 - GTK_FILL - - - - - + True True - 4046 1 65536 1 10 10 - 1 1 2 - 1 - 2 @@ -941,16 +941,42 @@ Artwork for old versions (< 0.2.7): 3 3 - + + + + + + + + + + + + + + + + True True True - Right + Up + 0 + + + 1 + 2 + + + + + True + True + True + Left 0 - 2 - 3 1 2 @@ -971,46 +997,20 @@ Artwork for old versions (< 0.2.7): - + True True True - Left + Right 0 + 2 + 3 1 2 - - - True - True - True - Up - 0 - - - 1 - 2 - - - - - - - - - - - - - - - - - diff --git a/gfceu.xml b/gfceu.xml new file mode 100644 index 00000000..1a090d39 --- /dev/null +++ b/gfceu.xml @@ -0,0 +1,1117 @@ + + + + + 10 + 1 + 1 + 0.5 + 10 + 2 + + + 10 + 1 + 1 + 0.5 + 10 + 2 + + + 65536 + 1 + 10 + 1 + 10 + 4046 + + + 65536 + 1 + 10 + 1 + 10 + 4046 + + + True + GFCE Ultra + 442 + gfceu.png + + + + True + 1 + + + True + True + 3 + + + True + 5 + 5 + + + True + 5 + + + True + 5 + ROM Filename: + + + False + False + + + + + True + True + + + 1 + + + + + True + True + _Browse... + True + + + + False + False + 2 + + + + + False + False + + + + + + + True + Main + + + False + + + + + True + 5 + 5 + + + True + + + True + gtk-dialog-info + + + False + False + + + + + True + Select an NES gamepad to configure. + True + + + False + False + 7 + 1 + + + + + False + False + + + + + True + 2 + 2 + 5 + 5 + + + True + True + Gamepad _3 + True + + + + 1 + 2 + + + + + + True + True + Gamepad _4 + True + + + + 1 + 2 + 1 + 2 + + + + + + True + True + Gamepad _2 + True + + + + 1 + 2 + + + + + + True + True + Gamepad _1 + True + + + + + + + + + False + False + 1 + + + + + True + True + gtk-help + True + + + + False + False + 5 + GTK_PACK_END + 2 + + + + + + + True + Input + + + 1 + False + + + + + True + 5 + 5 + + + True + True + Enable _OpenGL Rendering + True + True + + + False + False + + + + + True + True + Enable _Full Screen + True + True + + + False + False + 1 + + + + + True + + + True + X scale: + + + False + 5 + + + + + True + True + adjustment1 + 1 + True + + + False + 1 + + + + + False + 2 + + + + + True + + + True + Y scale: + + + False + 5 + + + + + True + True + adjustment2 + 1 + True + GTK_UPDATE_IF_VALID + + + False + 1 + + + + + False + 3 + + + + + True + + + True + Bits per pixel: + + + False + 5 + + + + + + + + False + 4 + + + + + True + <small><i>(Press Alt+Enter to toggle fullscreen in-game.)</i></small> + True + True + + + False + False + 5 + + + + + + + True + Video + + + 2 + False + + + + + True + 5 + 5 + + + True + + + True + gtk-dialog-info + + + False + False + + + + + True + If you would like to specify any command line options to FCE Ultra, specify them below. For a complete option reference, consult the official FCE Ultra documentation. + +Invalid options may cause GFCE Ultra to perform incorrectly. + + True + + + False + False + 1 + + + + + False + False + 5 + + + + + True + + + True + Extra Parameters: + + + False + False + 5 + + + + + True + True + + + 5 + 1 + + + + + False + 1 + + + + + + + True + Advanced + + + 3 + False + + + + + True + 5 + + + True + True + Enable _Sound + True + True + True + + + False + 5 + + + + + True + True + Extra _Quaility + True + True + True + + + False + 5 + 1 + + + + + True + + + True + Sample rate: + + + False + False + 5 + + + + + True + True + 11000 + + + False + False + 1 + + + + + False + 5 + 2 + + + + + 4 + False + + + + + True + Sound + + + 4 + False + + + + + True + False + 5 + 5 + + + True + True + _Host Game + True + True + + + + False + False + + + + + True + 0 + GTK_SHADOW_NONE + + + True + 19 + + + True + 2 + 2 + 5 + 5 + + + True + True + + + 1 + 2 + 1 + 2 + + + + + + True + True + adjustment3 + 1 + + + 1 + 2 + + + + + + True + 0 + Password: + + + 1 + 2 + GTK_FILL + + + + + + True + 0 + Port: + + + GTK_FILL + + + + + + + + + + False + False + 1 + + + + + True + True + _Join Game + True + True + host_radio + + + + False + False + 2 + + + + + True + 0 + GTK_SHADOW_NONE + + + True + 0 + 19 + + + True + 5 + 3 + 2 + 3 + 5 + + + True + True + adjustment4 + 1 + + + 1 + 2 + 1 + 2 + + + + + + True + 0 + Password: + + + 2 + 3 + GTK_FILL + + + + + + True + 0 + Server Port: + + + 1 + 2 + GTK_FILL + + + + + + True + 0 + Server Address: + + + GTK_FILL + + + + + + True + True + False + * + + + 1 + 2 + 2 + 3 + + + + + + True + True + + + 1 + 2 + + + + + + + + + + False + False + 3 + + + + + True + True + _No Network + True + True + True + host_radio + + + + False + False + 4 + + + + + + + True + False + Network + + + 5 + False + + + + + 10 + + + + + True + True + + + True + 3 + + + True + True + True + True + True + gtk-execute + True + + + + False + + + + + True + True + gtk-about + True + + + + False + False + 1 + + + + + True + True + gtk-quit + True + + + + False + 2 + + + + + + + False + False + 1 + + + + + + + GDK_WINDOW_TYPE_HINT_NORMAL + (C) Copyright 2006 + A GNOME front-end end for the FCE Ultra Nintendo Entertainment System emulator + http://dietschnitzel.com/gfceu/ + This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + Lukas Sabota +<ltsmooth42@gmail.comt> + +Patch writers: +Scott Brown + translator-credits + Sketching: + J. Sammer +Digital Manipulation: + C. Kontros + +Artwork for old versions (< 0.2.7): + Jimmy Angelakos + <vyruss000@gmail.com> + gfceu_big.png + + + True + + + + + + True + + + False + GTK_PACK_END + + + + + + + + + True + + + True + 0 + GTK_SHADOW_NONE + + + True + 12 + + + True + 3 + 3 + + + + + + + + + + + + + + + + + + True + True + True + Up + + + 1 + 2 + + + + + True + True + True + Left + + + 1 + 2 + + + + + True + True + True + Down + + + 1 + 2 + 2 + 3 + + + + + True + True + True + Right + + + 2 + 3 + 1 + 2 + + + + + + + + + True + <b>D-Pad</b> + True + + + + + + + True + 0 + GTK_SHADOW_NONE + + + True + 12 + + + True + + + True + True + True + Select + + + + + True + True + True + Start + + + 1 + + + + + + + + + True + <b>Essentials</b> + True + + + + + 1 + + + + + True + 0 + GTK_SHADOW_NONE + + + True + 12 + + + True + + + True + True + True + B + + + + + True + True + True + A + + + 1 + + + + + + + + + True + <b>Alpha and Beta</b> + True + + + + + 2 + + + + + +