mirror of
https://github.com/lutris/lutris
synced 2024-09-15 13:59:50 +00:00
merged modifications
This commit is contained in:
commit
9c0cb38042
10
bin/lutris
10
bin/lutris
|
@ -58,6 +58,9 @@ parser.add_option("-d", "--debug", action="store_true",
|
|||
dest="debug", help="Show debug messages")
|
||||
parser.add_option("-i", "--install", dest="installer_file",
|
||||
help="Install a game from a yml file")
|
||||
parser.add_option("-n", "--no-download",
|
||||
action="store_true", dest="no_download",
|
||||
help="Don't download anything when installing")
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
# Set the logging level to show debug messages.
|
||||
|
@ -73,7 +76,8 @@ if options.verbose:
|
|||
else:
|
||||
console.setLevel(log.logging.INFO)
|
||||
|
||||
formatter = log.logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
|
||||
fmt = '%(name)-12s: %(levelname)-8s %(message)s'
|
||||
formatter = log.logging.Formatter(fmt)
|
||||
console.setFormatter(formatter)
|
||||
log.logger.addHandler(console)
|
||||
|
||||
|
@ -81,7 +85,8 @@ installer = False
|
|||
game = None
|
||||
if options.installer_file:
|
||||
if not os.path.exists(options.installer_file):
|
||||
print "Unable to find installer at : %s" % options.installer_file
|
||||
log.logger.error("Unable to find installer at : %s"
|
||||
% options.installer_file)
|
||||
exit()
|
||||
else:
|
||||
game = True
|
||||
|
@ -118,4 +123,3 @@ else:
|
|||
gtk.gdk.threads_enter()
|
||||
gtk.main()
|
||||
gtk.gdk.threads_leave()
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="game_list_scrolledwindow">
|
||||
<object class="GtkScrolledWindow" id="games_scrollwindow">
|
||||
<property name="width_request">400</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
|
|
BIN
lutris/__init__.pyc
Normal file
BIN
lutris/__init__.pyc
Normal file
Binary file not shown.
BIN
lutris/config.pyc
Normal file
BIN
lutris/config.pyc
Normal file
Binary file not shown.
|
@ -59,6 +59,7 @@ if not exists(DATA_PATH):
|
|||
|
||||
lutris_icon_file = "media/logo.svg"
|
||||
lutris_icon_path = join(DATA_PATH, lutris_icon_file)
|
||||
LUTRIS_ICON_PATH = lutris_icon_path
|
||||
|
||||
LUTRIS_CONFIG_PATH = join(BaseDirectory.xdg_config_home, 'lutris')
|
||||
LUTRIS_DATA_PATH = join(BaseDirectory.xdg_data_home, 'lutris')
|
||||
|
@ -70,7 +71,6 @@ runner_config_path = join(LUTRIS_CONFIG_PATH, 'runners')
|
|||
GAME_CONFIG_PATH = join(LUTRIS_CONFIG_PATH, 'games')
|
||||
COVER_PATH = join(LUTRIS_CONFIG_PATH, 'covers')
|
||||
BANNER_PATH = join(LUTRIS_CONFIG_PATH, 'banners')
|
||||
ICON_PATH = join(expanduser('~'), '.icons')
|
||||
ICON_PATH = join(expanduser('~'), '.icons')
|
||||
cache_path = LUTRIS_CACHE_PATH
|
||||
TMP_PATH = join(LUTRIS_CACHE_PATH, 'tmp')
|
||||
|
||||
|
|
BIN
lutris/constants.pyc
Normal file
BIN
lutris/constants.pyc
Normal file
Binary file not shown.
BIN
lutris/desktop_control.pyc
Normal file
BIN
lutris/desktop_control.pyc
Normal file
Binary file not shown.
BIN
lutris/downloader.pyc
Normal file
BIN
lutris/downloader.pyc
Normal file
Binary file not shown.
BIN
lutris/exceptions.pyc
Normal file
BIN
lutris/exceptions.pyc
Normal file
Binary file not shown.
BIN
lutris/game.pyc
Normal file
BIN
lutris/game.pyc
Normal file
Binary file not shown.
BIN
lutris/gconfwrapper.pyc
Normal file
BIN
lutris/gconfwrapper.pyc
Normal file
Binary file not shown.
|
@ -18,6 +18,8 @@ import os
|
|||
import gtk.gdk
|
||||
import lutris.constants
|
||||
|
||||
from lutris.constants import LUTRIS_ICON_PATH
|
||||
|
||||
|
||||
class AboutLutrisDialog(gtk.AboutDialog):
|
||||
__gtype_name__ = "AboutLutrisDialog"
|
||||
|
@ -47,7 +49,7 @@ class AboutLutrisDialog(gtk.AboutDialog):
|
|||
#code for other initialization actions should be added here
|
||||
self.set_position(gtk.WIN_POS_CENTER)
|
||||
self.set_icon_from_file(lutris.constants.lutris_icon_path)
|
||||
self.set_logo(gtk.gdk.pixbuf_new_from_file(lutris.constants.lutris_icon_path))
|
||||
self.set_logo(gtk.gdk.pixbuf_new_from_file(LUTRIS_ICON_PATH))
|
||||
self.set_name(lutris.constants.name)
|
||||
self.set_version(lutris.constants.version)
|
||||
self.set_copyright(lutris.constants.copyright)
|
||||
|
@ -56,11 +58,10 @@ class AboutLutrisDialog(gtk.AboutDialog):
|
|||
self.set_artists(lutris.constants.artists)
|
||||
self.set_website(lutris.constants.website)
|
||||
|
||||
def NewAboutLutrisDialog(data_path):
|
||||
"""NewAboutLutrisDialog - returns a fully instantiated
|
||||
AboutLutrisDialog object. Use this function rather than
|
||||
creating a AboutLutrisDialog instance directly.
|
||||
|
||||
def NewAboutLutrisDialog(data_path):
|
||||
"""NewAboutLutrisDialog - returns a fully instantiated AboutLutrisDialog
|
||||
object.
|
||||
"""
|
||||
|
||||
#look for the ui file that describes the ui
|
||||
|
@ -73,4 +74,3 @@ def NewAboutLutrisDialog(data_path):
|
|||
dialog = builder.get_object("about_lutris_dialog")
|
||||
dialog.finish_initializing(builder)
|
||||
return dialog
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ from lutris.gui.gameconfigvbox import GameConfigVBox
|
|||
from lutris.gui.runnerconfigvbox import RunnerConfigVBox
|
||||
from lutris.gui.systemconfigvbox import SystemConfigVBox
|
||||
|
||||
|
||||
class AddGameDialog(gtk.Dialog):
|
||||
def __init__(self, parent):
|
||||
gtk.Dialog.__init__(self)
|
||||
|
@ -57,15 +58,18 @@ class AddGameDialog(gtk.Dialog):
|
|||
if hasattr(runner, "description"):
|
||||
description = runner.description
|
||||
else:
|
||||
logging.debug("Please fix %s and add a description attribute" % runner_cls)
|
||||
logging.debug("Please fix %s and add a description attribute"\
|
||||
% runner_cls)
|
||||
description = ""
|
||||
if hasattr(runner, "machine"):
|
||||
machine = runner.machine
|
||||
else:
|
||||
logging.debug("Please fix % and add a machine attribute" % runner_cls)
|
||||
logging.debug("Please fix % and add a machine attribute"\
|
||||
% runner_cls)
|
||||
machine = ""
|
||||
if runner.is_installed():
|
||||
runner_liststore.append((machine + " (" + description + ")" , runner_name))
|
||||
runner_liststore.append((machine + " (" + description + ")",
|
||||
runner_name))
|
||||
|
||||
self.runner_combobox = gtk.ComboBox(runner_liststore)
|
||||
self.runner_combobox.connect("changed", self.on_runner_changed)
|
||||
|
@ -79,24 +83,30 @@ class AddGameDialog(gtk.Dialog):
|
|||
|
||||
#Game configuration
|
||||
self.game_config_vbox = gtk.Label("Select a runner from the list")
|
||||
self.game_config_scrolled_window = gtk.ScrolledWindow()
|
||||
self.game_config_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.game_config_scrolled_window.add_with_viewport(self.game_config_vbox)
|
||||
self.notebook.append_page(self.game_config_scrolled_window, gtk.Label("Game configuration"))
|
||||
self.conf_scroll_window = gtk.ScrolledWindow()
|
||||
self.conf_scroll_window.set_policy(gtk.POLICY_AUTOMATIC,
|
||||
gtk.POLICY_AUTOMATIC)
|
||||
self.conf_scroll_window.add_with_viewport(self.game_config_vbox)
|
||||
self.notebook.append_page(self.conf_scroll_window,
|
||||
gtk.Label("Game configuration"))
|
||||
|
||||
#Runner configuration
|
||||
self.runner_config_vbox = gtk.Label("Select a runner from the list")
|
||||
self.runner_config_scrolled_window = gtk.ScrolledWindow()
|
||||
self.runner_config_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.runner_config_scrolled_window.add_with_viewport(self.runner_config_vbox)
|
||||
self.notebook.append_page(self.runner_config_scrolled_window, gtk.Label("Runner configuration"))
|
||||
self.runner_scroll_window = gtk.ScrolledWindow()
|
||||
self.runner_scroll_window.set_policy(gtk.POLICY_AUTOMATIC,
|
||||
gtk.POLICY_AUTOMATIC)
|
||||
self.runner_scroll_window.add_with_viewport(self.runner_config_vbox)
|
||||
self.notebook.append_page(self.runner_scroll_window,
|
||||
gtk.Label("Runner configuration"))
|
||||
|
||||
#System configuration
|
||||
self.system_config_vbox = SystemConfigVBox(self.lutris_config, "game")
|
||||
self.system_config_scrolled_window = gtk.ScrolledWindow()
|
||||
self.system_config_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.system_config_scrolled_window.add_with_viewport(self.system_config_vbox)
|
||||
self.notebook.append_page(self.system_config_scrolled_window, gtk.Label("System configuration"))
|
||||
self.system_scroll_window = gtk.ScrolledWindow()
|
||||
self.system_scroll_window.set_policy(gtk.POLICY_AUTOMATIC,
|
||||
gtk.POLICY_AUTOMATIC)
|
||||
self.system_scroll_window.add_with_viewport(self.system_config_vbox)
|
||||
self.notebook.append_page(self.system_scroll_window,
|
||||
gtk.Label("System configuration"))
|
||||
|
||||
#Action area
|
||||
cancel_button = gtk.Button(None, gtk.STOCK_CANCEL)
|
||||
|
@ -123,15 +133,16 @@ class AddGameDialog(gtk.Dialog):
|
|||
if self.runner_class and realname:
|
||||
game_identifier = self.lutris_config.save(runner_type="game")
|
||||
self.game_info = {"name": realname,
|
||||
"runner": self.runner_class ,
|
||||
"id": game_identifier }
|
||||
"runner": self.runner_class,
|
||||
"id": game_identifier}
|
||||
|
||||
self.destroy()
|
||||
|
||||
|
||||
def on_runner_changed(self, widget):
|
||||
selected_runner = widget.get_active()
|
||||
scroll_windows_children = [self.game_config_scrolled_window.get_children(), self.runner_config_scrolled_window.get_children(), self.system_config_scrolled_window.get_children()]
|
||||
scroll_windows_children = [self.conf_scroll_window.get_children(),
|
||||
self.runner_scroll_window.get_children(),
|
||||
self.system_scroll_window.get_children()]
|
||||
for scroll_window_children in scroll_windows_children:
|
||||
for child in scroll_window_children:
|
||||
child.destroy()
|
||||
|
@ -147,19 +158,18 @@ class AddGameDialog(gtk.Dialog):
|
|||
logging.debug(self.lutris_config.config)
|
||||
#Load game box
|
||||
self.game_config_vbox = GameConfigVBox(self.lutris_config, "game")
|
||||
self.game_config_scrolled_window.add_with_viewport(self.game_config_vbox)
|
||||
self.game_config_scrolled_window.show_all()
|
||||
self.conf_scroll_window.add_with_viewport(self.game_config_vbox)
|
||||
self.conf_scroll_window.show_all()
|
||||
|
||||
#Load runner box
|
||||
self.runner_options_vbox = RunnerConfigVBox(self.lutris_config, "game")
|
||||
self.runner_config_scrolled_window.add_with_viewport(self.runner_options_vbox)
|
||||
self.runner_config_scrolled_window.show_all()
|
||||
self.runner_scroll_window.add_with_viewport(self.runner_options_vbox)
|
||||
self.runner_scroll_window.show_all()
|
||||
|
||||
#Load system box
|
||||
self.system_config_vbox = SystemConfigVBox(self.lutris_config, "game")
|
||||
self.system_config_scrolled_window.add_with_viewport(self.system_config_vbox)
|
||||
self.system_config_scrolled_window.show_all()
|
||||
|
||||
self.system_scroll_window.add_with_viewport(self.system_config_vbox)
|
||||
self.system_scroll_window.show_all()
|
||||
|
||||
def close(self, widget=None, other=None):
|
||||
self.destroy()
|
||||
|
@ -167,8 +177,4 @@ class AddGameDialog(gtk.Dialog):
|
|||
def no_runner_selected(self):
|
||||
no_runner_label = gtk.Label("Choose a runner from the list")
|
||||
no_runner_label.show()
|
||||
self.runner_config_scrolled_window.add_with_viewport(no_runner_label)
|
||||
|
||||
|
||||
|
||||
|
||||
self.runner_scroll_window.add_with_viewport(no_runner_label)
|
||||
|
|
|
@ -27,6 +27,7 @@ import gtk
|
|||
|
||||
from lutris.gui.widgets import DownloadProgressBox
|
||||
|
||||
|
||||
class NoticeDialog:
|
||||
def __init__(self, message):
|
||||
dialog = gtk.MessageDialog(buttons=gtk.BUTTONS_OK)
|
||||
|
@ -34,6 +35,7 @@ class NoticeDialog:
|
|||
dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
|
||||
class ErrorDialog:
|
||||
def __init__(self, message):
|
||||
dialog = gtk.MessageDialog(buttons=gtk.BUTTONS_OK)
|
||||
|
@ -41,8 +43,9 @@ class ErrorDialog:
|
|||
dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
|
||||
class QuestionDialog:
|
||||
def __init__(self,settings):
|
||||
def __init__(self, settings):
|
||||
dialog = gtk.MessageDialog(
|
||||
type=gtk.MESSAGE_QUESTION,
|
||||
buttons=gtk.BUTTONS_YES_NO,
|
||||
|
@ -52,6 +55,7 @@ class QuestionDialog:
|
|||
self.result = dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
|
||||
class DirectoryDialog:
|
||||
"""Ask the user to select a directory"""
|
||||
def __init__(self, message, default_path=None):
|
||||
|
@ -65,21 +69,22 @@ class DirectoryDialog:
|
|||
self.folder = dialog.get_current_folder()
|
||||
dialog.destroy()
|
||||
|
||||
|
||||
class DownloadDialog(gtk.Dialog):
|
||||
def __init__(self, url, dest):
|
||||
print "creating download dialog"
|
||||
gtk.Dialog.__init__(self, "Downloading file")
|
||||
self.quit_gtk = False
|
||||
self.set_size_request(560,100)
|
||||
self.set_size_request(560, 100)
|
||||
self.connect('destroy', self.destroy_cb)
|
||||
params = {'url': url, 'dest': dest}
|
||||
self.download_progress_box = DownloadProgressBox(params)
|
||||
self.download_progress_box.connect('complete', self.download_complete)
|
||||
label = gtk.Label('Downloading %s' % url)
|
||||
label.set_padding(0,0)
|
||||
label.set_alignment(0.0,1.0)
|
||||
label.set_padding(0, 0)
|
||||
label.set_alignment(0.0, 1.0)
|
||||
self.vbox.pack_start(label, True, True, 0)
|
||||
self.vbox.pack_start(self.download_progress_box, True,False, 0)
|
||||
self.vbox.pack_start(self.download_progress_box, True, False, 0)
|
||||
self.show_all()
|
||||
self.download_progress_box.start()
|
||||
|
||||
|
|
|
@ -22,12 +22,15 @@
|
|||
|
||||
import gtk
|
||||
|
||||
|
||||
class ConfigVBox(gtk.VBox):
|
||||
def __init__(self,save_in_key,caller):
|
||||
def __init__(self, save_in_key, caller):
|
||||
gtk.VBox.__init__(self)
|
||||
self.options = None
|
||||
#Section of the configuration file to save options in. Can be "game", "runner" or "system"
|
||||
#Section of the configuration file to save options in. Can be "game",
|
||||
#"runner" or "system" self.save_in_key= save_in_key
|
||||
self.save_in_key= save_in_key
|
||||
|
||||
self.caller = caller
|
||||
|
||||
def generate_widgets(self):
|
||||
|
@ -57,85 +60,97 @@ class ConfigVBox(gtk.VBox):
|
|||
|
||||
#Different types of widgets.
|
||||
if option["type"] == "one_choice":
|
||||
self.generate_combobox(option_key,option["choices"],option["label"],value)
|
||||
self.generate_combobox(option_key,
|
||||
option["choices"],
|
||||
option["label"], value)
|
||||
elif option["type"] == "bool":
|
||||
self.generate_checkbox(option_key,option["label"],value)
|
||||
self.generate_checkbox(option_key, option["label"], value)
|
||||
elif option["type"] == "range":
|
||||
self.generate_range(option_key,option["min"], option["max"],option["label"],value)
|
||||
self.generate_range(option_key,
|
||||
option["min"],
|
||||
option["max"],
|
||||
option["label"], value)
|
||||
elif option["type"] == "string":
|
||||
self.generate_entry(option_key,option["label"], value)
|
||||
elif option["type"] in ("directory_chooser", "directory"):
|
||||
self.generate_directory_chooser(option_key,option["label"], value)
|
||||
elif option["type"] in ("file_chooser", "single", "file"):
|
||||
self.generate_file_chooser(option_key,option["label"], value)
|
||||
elif option["type"] in ("multiple", "files"):
|
||||
self.generate_multiple_file_chooser(option_key, option["label"], value)
|
||||
self.generate_entry(option_key,
|
||||
option["label"], value)
|
||||
elif option["type"] == "directory_chooser":
|
||||
self.generate_directory_chooser(option_key,
|
||||
option["label"],
|
||||
value)
|
||||
elif option["type"] in ("file_chooser", "single"):
|
||||
self.generate_file_chooser(option_key, option["label"], value)
|
||||
elif option["type"] == "multiple":
|
||||
self.generate_multiple_file_chooser(option_key,
|
||||
option["label"], value)
|
||||
elif option["type"] == "label":
|
||||
self.generate_label(option["label"])
|
||||
else:
|
||||
print "WTF is %s ?" % option["type"]
|
||||
|
||||
def generate_label(self,text):
|
||||
def generate_label(self, text):
|
||||
label = gtk.Label(text)
|
||||
label.show()
|
||||
self.pack_start(label,True,True)
|
||||
self.pack_start(label, True, True)
|
||||
|
||||
#Checkbox
|
||||
def generate_checkbox(self,option_name,label,value=None):
|
||||
def generate_checkbox(self, option_name, label, value=None):
|
||||
checkbox = gtk.CheckButton(label)
|
||||
if value:
|
||||
checkbox.set_active(value)
|
||||
checkbox.connect("toggled",self.checkbox_toggle,option_name)
|
||||
checkbox.connect("toggled", self.checkbox_toggle, option_name)
|
||||
checkbox.show()
|
||||
self.pack_start(checkbox,False,True,5)
|
||||
def checkbox_toggle(self,widget,option_name):
|
||||
self.pack_start(checkbox, False, True, 5)
|
||||
|
||||
def checkbox_toggle(self, widget, option_name):
|
||||
self.real_config[self.save_in_key][option_name] = widget.get_active()
|
||||
|
||||
#Entry
|
||||
def generate_entry(self,option_name,label,value=None):
|
||||
def generate_entry(self, option_name, label, value=None):
|
||||
hbox = gtk.HBox()
|
||||
entry_label = gtk.Label(label)
|
||||
entry_label.set_size_request(200,30)
|
||||
entry_label.set_size_request(200, 30)
|
||||
entry = gtk.Entry()
|
||||
if value:
|
||||
entry.set_text(value)
|
||||
entry.connect("changed",self.entry_changed,option_name)
|
||||
hbox.pack_start(entry_label,False,False,5)
|
||||
hbox.pack_start(entry,True,True,5)
|
||||
entry.connect("changed", self.entry_changed, option_name)
|
||||
hbox.pack_start(entry_label, False, False, 5)
|
||||
hbox.pack_start(entry, True, True, 5)
|
||||
hbox.show_all()
|
||||
self.pack_start(hbox,False,True,5)
|
||||
def entry_changed(self,entry,option_name):
|
||||
self.pack_start(hbox, False, True, 5)
|
||||
|
||||
def entry_changed(self, entry, option_name):
|
||||
entry_text = entry.get_text()
|
||||
self.real_config[self.save_in_key][option_name] = entry_text
|
||||
|
||||
#ComboBox
|
||||
def generate_combobox(self,option_name,choices,label,value=None):
|
||||
def generate_combobox(self, option_name, choices, label, value=None):
|
||||
hbox = gtk.HBox()
|
||||
liststore = gtk.ListStore(str,str)
|
||||
liststore = gtk.ListStore(str, str)
|
||||
for choice in choices:
|
||||
if type(choice) is str:
|
||||
choice = [choice, choice]
|
||||
liststore.append(choice)
|
||||
combobox = gtk.ComboBox(liststore)
|
||||
combobox.set_size_request(200,30)
|
||||
combobox.set_size_request(200, 30)
|
||||
cell = gtk.CellRendererText()
|
||||
combobox.pack_start(cell, True)
|
||||
combobox.add_attribute(cell, 'text', 0)
|
||||
index = selected_index = -1
|
||||
index = selected_index = -1
|
||||
if value:
|
||||
for choice in choices:
|
||||
if choice[1] == value:
|
||||
selected_index = index +1
|
||||
index = index +1
|
||||
selected_index = index + 1
|
||||
index = index + 1
|
||||
combobox.set_active(selected_index)
|
||||
combobox.connect('changed',self.on_combobox_change,option_name)
|
||||
combobox.connect('changed', self.on_combobox_change, option_name)
|
||||
gtklabel = gtk.Label(label)
|
||||
gtklabel.set_size_request(200,30)
|
||||
gtklabel.set_size_request(200, 30)
|
||||
hbox.pack_start(gtklabel)
|
||||
hbox.pack_start(combobox)
|
||||
hbox.show_all()
|
||||
self.pack_start(hbox,False,True,5)
|
||||
def on_combobox_change(self,combobox,option):
|
||||
self.pack_start(hbox, False, True, 5)
|
||||
|
||||
def on_combobox_change(self, combobox, option):
|
||||
model = combobox.get_model()
|
||||
active = combobox.get_active()
|
||||
if active < 0:
|
||||
|
@ -144,86 +159,87 @@ class ConfigVBox(gtk.VBox):
|
|||
self.real_config[self.save_in_key][option] = option_value
|
||||
|
||||
#Range
|
||||
def generate_range(self,option_name,min,max,label,value=None):
|
||||
adjustment = gtk.Adjustment(float(min),float(min),float(max),1,0,0)
|
||||
def generate_range(self, option_name, min, max, label, value=None):
|
||||
adjustment = gtk.Adjustment(float(min), float(min), float(max),
|
||||
1, 0, 0)
|
||||
spin_button = gtk.SpinButton(adjustment)
|
||||
if value:
|
||||
spin_button.set_value(value)
|
||||
spin_button.connect('changed',self.on_spin_button_changed,option_name)
|
||||
spin_button.connect('changed',
|
||||
self.on_spin_button_changed, option_name)
|
||||
hbox = gtk.HBox()
|
||||
gtklabel = gtk.Label(label)
|
||||
gtklabel.set_size_request(200,30)
|
||||
gtklabel.set_size_request(200, 30)
|
||||
hbox.pack_start(gtklabel)
|
||||
hbox.pack_start(spin_button)
|
||||
hbox.show_all()
|
||||
self.pack_start(hbox,False,True,5)
|
||||
def on_spin_button_changed(self,spin_button,option):
|
||||
self.pack_start(hbox, False, True, 5)
|
||||
|
||||
def on_spin_button_changed(self, spin_button, option):
|
||||
value = spin_button.get_value_as_int()
|
||||
self.real_config[self.save_in_key][option] = value
|
||||
|
||||
|
||||
#File chooser
|
||||
def generate_file_chooser(self,option_name,label,value=None):
|
||||
def generate_file_chooser(self, option_name, label, value=None):
|
||||
"""Generates a file chooser button to choose a file"""
|
||||
hbox = gtk.HBox()
|
||||
gtklabel = gtk.Label(label)
|
||||
gtklabel.set_size_request(200,30)
|
||||
gtklabel.set_size_request(200, 30)
|
||||
file_chooser = gtk.FileChooserButton("Choose a file for %s" % label)
|
||||
file_chooser.set_size_request(200,30)
|
||||
file_chooser.set_size_request(200, 30)
|
||||
|
||||
file_chooser.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
|
||||
#file_chooser.set_current_folder(self.lutris_config.get_path(self.runner_class))
|
||||
file_chooser.connect("file-set",self.on_chooser_file_set,option_name)
|
||||
file_chooser.connect("file-set", self.on_chooser_file_set, option_name)
|
||||
if value:
|
||||
file_chooser.unselect_all()
|
||||
file_chooser.select_filename(value)
|
||||
hbox.pack_start(gtklabel,False,False,10)
|
||||
hbox.pack_start(gtklabel, False, False, 10)
|
||||
hbox.pack_start(file_chooser)
|
||||
self.pack_start(hbox,False,True,5)
|
||||
self.pack_start(hbox, False, True, 5)
|
||||
|
||||
def generate_directory_chooser(self,option_name,label,value=None):
|
||||
def generate_directory_chooser(self, option_name, label, value=None):
|
||||
"""Generates a file chooser button to choose a directory"""
|
||||
hbox = gtk.HBox()
|
||||
gtklabel = gtk.Label(label)
|
||||
gtklabel.set_size_request(200,30)
|
||||
directory_chooser = gtk.FileChooserButton("Choose a directory for %s" % label)
|
||||
directory_chooser.set_size_request(200,30)
|
||||
gtklabel.set_size_request(200, 30)
|
||||
directory_chooser = gtk.FileChooserButton("Choose a directory for %s"\
|
||||
% label)
|
||||
directory_chooser.set_size_request(200, 30)
|
||||
directory_chooser.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
||||
if value:
|
||||
directory_chooser.set_current_folder(value)
|
||||
directory_chooser.connect("file-set",self.on_chooser_file_set,option_name)
|
||||
directory_chooser.connect("file-set",
|
||||
self.on_chooser_file_set, option_name)
|
||||
hbox.pack_start(gtklabel)
|
||||
hbox.pack_start(directory_chooser)
|
||||
self.pack_start(hbox,False,True,5)
|
||||
self.pack_start(hbox, False, True, 5)
|
||||
|
||||
def on_chooser_file_set(self,filechooser_widget,option):
|
||||
filename = filechooser_widget.get_filename()
|
||||
def on_chooser_file_set(self, filechooser_widget, option):
|
||||
filename = filechooser_widget.get_filename()
|
||||
self.real_config[self.save_in_key][option] = filename
|
||||
|
||||
def generate_multiple_file_chooser(self,option_name,label,value=None):
|
||||
def generate_multiple_file_chooser(self, option_name, label, value=None):
|
||||
hbox = gtk.HBox()
|
||||
gtk_label = gtk.Label(label)
|
||||
gtk_label.set_size_request(200,30)
|
||||
gtk_label.set_size_request(200, 30)
|
||||
hbox.pack_start(gtk_label)
|
||||
self.files_chooser_dialog = gtk.FileChooserDialog(
|
||||
title="Select files",
|
||||
parent=self.get_parent_window(),
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE,
|
||||
gtk.STOCK_ADD, gtk.RESPONSE_OK)
|
||||
)
|
||||
self.files_chooser_dialog = gtk.FileChooserDialog(title="Select files",
|
||||
parent=self.get_parent_window(),
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE,
|
||||
gtk.STOCK_ADD, gtk.RESPONSE_OK))
|
||||
self.files_chooser_dialog.set_select_multiple(True)
|
||||
self.files_chooser_dialog.connect('response', self.add_files_callback,option_name)
|
||||
self.files_chooser_dialog.connect('response',
|
||||
self.add_files_callback, option_name)
|
||||
|
||||
files_chooser_button = gtk.FileChooserButton(self.files_chooser_dialog)
|
||||
game_path = self.lutris_config.get_path(self.runner_class)
|
||||
if game_path:
|
||||
files_chooser_button.set_current_folder(game_path)
|
||||
files_chooser_button.set_current_folder(game_path)
|
||||
if value:
|
||||
files_chooser_button.set_filename(value[0])
|
||||
|
||||
hbox.pack_start(files_chooser_button)
|
||||
self.pack_start(hbox,False,True,5)
|
||||
self.pack_start(hbox, False, True, 5)
|
||||
if value:
|
||||
self.files = value
|
||||
else:
|
||||
|
@ -234,23 +250,23 @@ class ConfigVBox(gtk.VBox):
|
|||
files_column = gtk.TreeViewColumn("Files")
|
||||
cell_renderer = gtk.CellRendererText()
|
||||
files_column.pack_start(cell_renderer)
|
||||
files_column.set_attributes(cell_renderer,text=0)
|
||||
files_column.set_attributes(cell_renderer, text=0)
|
||||
files_treeview = gtk.TreeView(self.files_list_store)
|
||||
files_treeview.append_column(files_column)
|
||||
files_treeview.set_size_request(10,100)
|
||||
files_treeview.connect('key-press-event',self.on_files_treeview_event)
|
||||
files_treeview.set_size_request(10, 100)
|
||||
files_treeview.connect('key-press-event', self.on_files_treeview_event)
|
||||
treeview_scroll = gtk.ScrolledWindow()
|
||||
treeview_scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
treeview_scroll.add(files_treeview)
|
||||
self.pack_start(treeview_scroll,True,True)
|
||||
self.pack_start(treeview_scroll, True, True)
|
||||
|
||||
def on_files_treeview_event(self,treeview,event):
|
||||
key = event.keyval
|
||||
def on_files_treeview_event(self, treeview, event):
|
||||
key = event.keyval
|
||||
if key == gtk.keysyms.Delete:
|
||||
#TODO : Delete selected row
|
||||
print "you don't wanna delete this ... yet"
|
||||
|
||||
def add_files_callback(self,dialog,response,option):
|
||||
def add_files_callback(self, dialog, response, option):
|
||||
"""Add several files to the configuration"""
|
||||
if response == gtk.RESPONSE_OK:
|
||||
filenames = dialog.get_filenames()
|
||||
|
|
|
@ -26,45 +26,53 @@ from lutris.gui.gameconfigvbox import GameConfigVBox
|
|||
from lutris.gui.runnerconfigvbox import RunnerConfigVBox
|
||||
from lutris.gui.systemconfigvbox import SystemConfigVBox
|
||||
|
||||
|
||||
class EditGameConfigDialog(gtk.Dialog):
|
||||
def __init__(self,parent,game):
|
||||
def __init__(self, parent, game):
|
||||
self.parent_window = parent
|
||||
self.game = game
|
||||
gtk.Dialog.__init__(self)
|
||||
self.set_title("Edit game configuration")
|
||||
self.set_size_request(500,500)
|
||||
|
||||
self.set_size_request(500, 500)
|
||||
|
||||
#Top label
|
||||
self.lutris_config = LutrisConfig(game=game)
|
||||
self.lutris_config.runner = self.lutris_config.config["runner"]
|
||||
|
||||
game_name_label = gtk.Label("Edit configuration for %s " % self.lutris_config.config["realname"])
|
||||
self.vbox.pack_start(game_name_label,False,False,10)
|
||||
|
||||
|
||||
game_name_label = gtk.Label("Edit configuration for %s "\
|
||||
% self.lutris_config.config["realname"])
|
||||
self.vbox.pack_start(game_name_label, False, False, 10)
|
||||
|
||||
#Notebook
|
||||
config_notebook = gtk.Notebook()
|
||||
self.vbox.pack_start(config_notebook)
|
||||
|
||||
|
||||
#Game configuration tab
|
||||
self.game_config_vbox = GameConfigVBox(self.lutris_config,"game")
|
||||
self.game_config_vbox = GameConfigVBox(self.lutris_config, "game")
|
||||
game_config_scrolled_window = gtk.ScrolledWindow()
|
||||
game_config_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
game_config_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
|
||||
gtk.POLICY_AUTOMATIC)
|
||||
game_config_scrolled_window.add_with_viewport(self.game_config_vbox)
|
||||
config_notebook.append_page(game_config_scrolled_window,gtk.Label("Game Configuration"))
|
||||
config_notebook.append_page(game_config_scrolled_window,
|
||||
gtk.Label("Game Configuration"))
|
||||
|
||||
#Runner configuration tab
|
||||
self.runner_config_box = RunnerConfigVBox(self.lutris_config,"game")
|
||||
self.runner_config_box = RunnerConfigVBox(self.lutris_config, "game")
|
||||
runner_config_scrolled_window = gtk.ScrolledWindow()
|
||||
runner_config_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
|
||||
runner_config_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
|
||||
gtk.POLICY_AUTOMATIC)
|
||||
runner_config_scrolled_window.add_with_viewport(self.runner_config_box)
|
||||
config_notebook.append_page(runner_config_scrolled_window,gtk.Label("Runner Configuration"))
|
||||
|
||||
config_notebook.append_page(runner_config_scrolled_window,
|
||||
gtk.Label("Runner Configuration"))
|
||||
|
||||
#System configuration tab
|
||||
self.system_config_box = SystemConfigVBox(self.lutris_config,"game")
|
||||
self.system_config_box = SystemConfigVBox(self.lutris_config, "game")
|
||||
system_config_scrolled_window = gtk.ScrolledWindow()
|
||||
system_config_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
|
||||
system_config_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
|
||||
gtk.POLICY_AUTOMATIC)
|
||||
system_config_scrolled_window.add_with_viewport(self.system_config_box)
|
||||
config_notebook.append_page(system_config_scrolled_window,gtk.Label("Runner Configuration"))
|
||||
config_notebook.append_page(system_config_scrolled_window,
|
||||
gtk.Label("Runner Configuration"))
|
||||
|
||||
#Action Area
|
||||
cancel_button = gtk.Button(None, gtk.STOCK_CANCEL)
|
||||
|
@ -73,14 +81,14 @@ class EditGameConfigDialog(gtk.Dialog):
|
|||
self.action_area.pack_start(add_button)
|
||||
cancel_button.connect("clicked", self.close)
|
||||
add_button.connect("clicked", self.edit_game)
|
||||
|
||||
|
||||
self.show_all()
|
||||
self.run()
|
||||
|
||||
def edit_game(self,widget=None):
|
||||
def edit_game(self, widget=None):
|
||||
logging.debug(self.lutris_config.config)
|
||||
self.lutris_config.save(runner_type="game")
|
||||
self.destroy()
|
||||
|
||||
def close(self,widget=None):
|
||||
|
||||
def close(self, widget=None):
|
||||
self.destroy()
|
||||
|
|
|
@ -21,26 +21,26 @@
|
|||
|
||||
import gtk
|
||||
|
||||
# remove me ?
|
||||
import lutris.runners
|
||||
|
||||
from lutris.runners import import_runner
|
||||
from lutris.gui.configvbox import ConfigVBox
|
||||
from lutris.runners import import_runner
|
||||
|
||||
|
||||
class GameConfigVBox(ConfigVBox):
|
||||
def __init__(self, lutris_config, caller):
|
||||
ConfigVBox.__init__(self, "game", caller)
|
||||
self.lutris_config = lutris_config
|
||||
self.lutris_config = lutris_config
|
||||
self.lutris_config.config_type = "game"
|
||||
self.runner_class = self.lutris_config.runner
|
||||
runner_cls = import_runner(self.runner_class)
|
||||
runner = runner_cls()
|
||||
|
||||
if hasattr(runner,"game_options"):
|
||||
if hasattr(runner, "game_options"):
|
||||
self.options = runner.game_options
|
||||
else:
|
||||
no_option_label = gtk.Label("No game options")
|
||||
self.pack_start(no_option_label)
|
||||
return
|
||||
self.generate_widgets()
|
||||
|
||||
|
|
|
@ -23,28 +23,20 @@ import gtk
|
|||
from lutris.runners import import_runner
|
||||
from lutris.gui.configvbox import ConfigVBox
|
||||
|
||||
|
||||
class InstallerConfigVBox(ConfigVBox):
|
||||
"""This file is going to disapear anytime now."""
|
||||
def __init__(self,lutris_config,caller):
|
||||
ConfigVBox.__init__(self,"game",caller)
|
||||
self.lutris_config = lutris_config
|
||||
def __init__(self, lutris_config, caller):
|
||||
ConfigVBox.__init__(self, "game", caller)
|
||||
self.lutris_config = lutris_config
|
||||
self.lutris_config.config_type = "game"
|
||||
self.runner_classname = self.lutris_config.runner
|
||||
runner_cls = import_runner(self.runner_classname)
|
||||
runner = runner_cls()
|
||||
if hasattr(runner,"installer_options"):
|
||||
if hasattr(runner, "installer_options"):
|
||||
self.options = runner.installer_options
|
||||
else:
|
||||
no_option_label = gtk.Label("No game options")
|
||||
self.pack_start(no_option_label)
|
||||
return
|
||||
self.generate_widgets()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -30,73 +30,83 @@ from lutris.gui.installerconfigvbox import InstallerConfigVBox
|
|||
from lutris.gui.runnerconfigvbox import RunnerConfigVBox
|
||||
from lutris.gui.systemconfigvbox import SystemConfigVBox
|
||||
|
||||
|
||||
class InstallerDialog(gtk.Dialog):
|
||||
def __init__(self, parent):
|
||||
gtk.Dialog.__init__(self)
|
||||
self.parent_window = parent
|
||||
self.set_title("Install a game")
|
||||
self.set_size_request(600,500)
|
||||
self.set_size_request(600, 500)
|
||||
|
||||
#Real name
|
||||
realname_hbox = gtk.HBox()
|
||||
self.realname_label = gtk.Label("Name")
|
||||
realname_hbox.pack_start(self.realname_label,False,False,5)
|
||||
realname_hbox.pack_start(self.realname_label, False, False, 5)
|
||||
self.realname_entry = gtk.Entry()
|
||||
realname_hbox.pack_start(self.realname_entry)
|
||||
self.vbox.pack_start(realname_hbox,False,False,5)
|
||||
self.vbox.pack_start(realname_hbox, False, False, 5)
|
||||
|
||||
self.lutris_config = LutrisConfig()
|
||||
|
||||
#Runner
|
||||
#get a list of available runners
|
||||
runner_liststore = gtk.ListStore(str,str)
|
||||
runner_liststore.append(("Choose a runner for the list",""))
|
||||
runner_liststore = gtk.ListStore(str, str)
|
||||
runner_liststore.append(("Choose a runner for the list", ""))
|
||||
for runner_classname in lutris.runners.__all__:
|
||||
runner_cls = import_runner(runner_classname)
|
||||
runner = runner_cls()
|
||||
if hasattr(runner,"description"):
|
||||
if hasattr(runner, "description"):
|
||||
description = runner.description
|
||||
else:
|
||||
logging.debug("Please fix %s and add a description attribute" % runner_classname)
|
||||
logging.debug("Please fix %s and add a description attribute"\
|
||||
% runner_classname)
|
||||
description = ""
|
||||
if hasattr(runner,"machine"):
|
||||
if hasattr(runner, "machine"):
|
||||
machine = runner.machine
|
||||
else:
|
||||
logging.debug("Please fix % and add a machine attribute" % runner_classname)
|
||||
logging.debug("Please fix % and add a machine attribute"\
|
||||
% runner_classname)
|
||||
machine = ""
|
||||
if runner.is_installed() and runner.is_installable:
|
||||
runner_liststore.append((machine+" ("+ description +")", runner_classname))
|
||||
runner_liststore.append((machine + " (" + description + ")",
|
||||
runner_classname))
|
||||
|
||||
self.runner_combobox = gtk.ComboBox(runner_liststore)
|
||||
self.runner_combobox.connect("changed",self.on_runner_changed)
|
||||
self.runner_combobox.connect("changed", self.on_runner_changed)
|
||||
cell = gtk.CellRendererText()
|
||||
self.runner_combobox.pack_start(cell, True)
|
||||
self.runner_combobox.add_attribute(cell, 'text', 0)
|
||||
self.vbox.pack_start(self.runner_combobox,False,True,5)
|
||||
self.vbox.pack_start(self.runner_combobox, False, True, 5)
|
||||
|
||||
self.notebook = gtk.Notebook()
|
||||
self.vbox.pack_start(self.notebook)
|
||||
|
||||
#Game configuration
|
||||
self.installer_config_vbox = gtk.Label("Select a runner from the list")
|
||||
self.installer_config_scrolled_window = gtk.ScrolledWindow()
|
||||
self.installer_config_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.installer_config_scrolled_window.add_with_viewport(self.installer_config_vbox)
|
||||
self.notebook.append_page(self.installer_config_scrolled_window,gtk.Label("Installer"))
|
||||
self.install_vbox = gtk.Label("Select a runner from the list")
|
||||
self.installer_scroll_window = gtk.ScrolledWindow()
|
||||
self.installer_scroll_window.set_policy(gtk.POLICY_AUTOMATIC,
|
||||
gtk.POLICY_AUTOMATIC)
|
||||
self.installer_scroll_window.add_with_viewport(self.install_vbox)
|
||||
self.notebook.append_page(self.installer_scroll_window,
|
||||
gtk.Label("Installer"))
|
||||
|
||||
#Runner configuration
|
||||
self.runner_config_vbox = gtk.Label("Select a runner from the list")
|
||||
self.runner_config_scrolled_window = gtk.ScrolledWindow()
|
||||
self.runner_config_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
|
||||
self.runner_config_scrolled_window.add_with_viewport(self.runner_config_vbox)
|
||||
self.notebook.append_page(self.runner_config_scrolled_window,gtk.Label("Runner configuration"))
|
||||
self.runner_scroll_window = gtk.ScrolledWindow()
|
||||
self.runner_scroll_window.set_policy(gtk.POLICY_AUTOMATIC,
|
||||
gtk.POLICY_AUTOMATIC)
|
||||
self.runner_scroll_window.add_with_viewport(self.runner_config_vbox)
|
||||
self.notebook.append_page(self.runner_scroll_window,
|
||||
gtk.Label("Runner configuration"))
|
||||
|
||||
#System configuration
|
||||
self.system_config_vbox = SystemConfigVBox(self.lutris_config,"game")
|
||||
self.system_config_scrolled_window = gtk.ScrolledWindow()
|
||||
self.system_config_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
|
||||
self.system_config_scrolled_window.add_with_viewport(self.system_config_vbox)
|
||||
self.notebook.append_page(self.system_config_scrolled_window,gtk.Label("System configuration"))
|
||||
self.system_config_vbox = SystemConfigVBox(self.lutris_config, "game")
|
||||
self.system_scroll_window = gtk.ScrolledWindow()
|
||||
self.system_scroll_window.set_policy(gtk.POLICY_AUTOMATIC,
|
||||
gtk.POLICY_AUTOMATIC)
|
||||
self.system_scroll_window.add_with_viewport(self.system_config_vbox)
|
||||
self.notebook.append_page(self.system_scroll_window,
|
||||
gtk.Label("System configuration"))
|
||||
|
||||
#Action area
|
||||
cancel_button = gtk.Button(None, gtk.STOCK_CANCEL)
|
||||
|
@ -123,21 +133,22 @@ class InstallerDialog(gtk.Dialog):
|
|||
runner = runner_cls()
|
||||
self.lutris_config.update_global_config()
|
||||
if "installer" in self.lutris_config.config['game']:
|
||||
command = runner.get_install_command(self.lutris_config.config["game"]["installer"])
|
||||
installer = self.lutris_config.config["game"]["installer"]
|
||||
command = runner.get_install_command(installer)
|
||||
if command:
|
||||
logging.debug("Running installer : %s" % command)
|
||||
subprocess.Popen(command,shell=True)
|
||||
subprocess.Popen(command, shell=True)
|
||||
else:
|
||||
logging.debug("No command given for installation")
|
||||
|
||||
if self.runner_classname and realname:
|
||||
#game_identifier = self.lutris_config.save(type="game")
|
||||
#self.game_info = {"Game Name": realname,"Runner": self.runner_classname , "name": game_identifier}
|
||||
self.destroy()
|
||||
|
||||
def on_runner_changed(self,widget):
|
||||
def on_runner_changed(self, widget):
|
||||
selected_runner = widget.get_active()
|
||||
scroll_windows_children = [self.installer_config_scrolled_window.get_children(),self.runner_config_scrolled_window.get_children(),self.system_config_scrolled_window.get_children()]
|
||||
scroll_windows_children = [self.installer_scroll_window.get_children(),
|
||||
self.runner_scroll_window.get_children(),
|
||||
self.system_scroll_window.get_children()]
|
||||
for scroll_window_children in scroll_windows_children:
|
||||
for child in scroll_window_children:
|
||||
child.destroy()
|
||||
|
@ -151,20 +162,19 @@ class InstallerDialog(gtk.Dialog):
|
|||
logging.debug("loading config before adding game : ")
|
||||
logging.debug(self.lutris_config.config)
|
||||
#Load game box
|
||||
self.installer_config_vbox = InstallerConfigVBox(self.lutris_config,"game")
|
||||
self.installer_config_scrolled_window.add_with_viewport(self.installer_config_vbox)
|
||||
self.installer_config_scrolled_window.show_all()
|
||||
self.install_vbox = InstallerConfigVBox(self.lutris_config, "game")
|
||||
self.installer_scroll_window.add_with_viewport(self.install_vbox)
|
||||
self.installer_scroll_window.show_all()
|
||||
|
||||
#Load runner box
|
||||
self.runner_options_vbox = RunnerConfigVBox(self.lutris_config,"game")
|
||||
self.runner_config_scrolled_window.add_with_viewport(self.runner_options_vbox)
|
||||
self.runner_config_scrolled_window.show_all()
|
||||
self.runner_options_vbox = RunnerConfigVBox(self.lutris_config, "game")
|
||||
self.runner_scroll_window.add_with_viewport(self.runner_options_vbox)
|
||||
self.runner_scroll_window.show_all()
|
||||
|
||||
#Load system box
|
||||
self.system_config_vbox = SystemConfigVBox(self.lutris_config,"game")
|
||||
self.system_config_scrolled_window.add_with_viewport(self.system_config_vbox)
|
||||
self.system_config_scrolled_window.show_all()
|
||||
|
||||
self.system_config_vbox = SystemConfigVBox(self.lutris_config, "game")
|
||||
self.system_scroll_window.add_with_viewport(self.system_config_vbox)
|
||||
self.system_scroll_window.show_all()
|
||||
|
||||
def close(self, widget=None, other=None):
|
||||
self.destroy()
|
||||
|
@ -172,8 +182,4 @@ class InstallerDialog(gtk.Dialog):
|
|||
def no_runner_selected(self):
|
||||
no_runner_label = gtk.Label("Choose a runner from the list")
|
||||
no_runner_label.show()
|
||||
self.runner_config_scrolled_window.add_with_viewport(no_runner_label)
|
||||
|
||||
|
||||
|
||||
|
||||
self.runner_scroll_window.add_with_viewport(no_runner_label)
|
||||
|
|
|
@ -43,6 +43,7 @@ from lutris.desktop_control import LutrisDesktopControl
|
|||
from lutris.gui.widgets import GameTreeView, GameCover
|
||||
import lutris.coverflow.coverflow
|
||||
|
||||
|
||||
class LutrisWindow(gtk.Window):
|
||||
""" Main Lutris window """
|
||||
__gtype_name__ = "LutrisWindow"
|
||||
|
@ -128,8 +129,8 @@ class LutrisWindow(gtk.Window):
|
|||
self.game_cell = self.game_column.get_cell_renderers()[0]
|
||||
self.game_cell.connect('edited', self.game_name_edited_callback)
|
||||
|
||||
self.game_list_scrolledwindow = self.builder.get_object('game_list_scrolledwindow')
|
||||
self.game_list_scrolledwindow.add_with_viewport(self.game_treeview)
|
||||
self.games_scrollwindow = self.builder.get_object('games_scrollwindow')
|
||||
self.games_scrollwindow.add_with_viewport(self.game_treeview)
|
||||
|
||||
# Set buttons state
|
||||
self.play_button = self.builder.get_object('play_button')
|
||||
|
@ -152,7 +153,8 @@ class LutrisWindow(gtk.Window):
|
|||
elif pid is None:
|
||||
self.status_label.set_text("Game has quit")
|
||||
else:
|
||||
self.status_label.set_text("Playing %s (pid: %r)" % (name, pid))
|
||||
self.status_label.set_text("Playing %s (pid: %r)"\
|
||||
% (name, pid))
|
||||
else:
|
||||
self.status_label.set_text("Welcome to Lutris")
|
||||
for index in range(4):
|
||||
|
@ -255,7 +257,8 @@ class LutrisWindow(gtk.Window):
|
|||
coverflow = lutris.coverflow.coverflow.coverflow()
|
||||
if coverflow:
|
||||
if coverflow == "NOCOVERS":
|
||||
message = "You need covers for your games to switch to fullscreen mode."
|
||||
message = "You need covers for your games"\
|
||||
+ "to switch to fullscreen mode."
|
||||
NoticeDialog(message)
|
||||
return
|
||||
if coverflow == "NOPYGLET":
|
||||
|
@ -269,7 +272,8 @@ class LutrisWindow(gtk.Window):
|
|||
def reset(self, widget, data=None):
|
||||
if hasattr(self, "running_game"):
|
||||
self.running_game.quit_game()
|
||||
self.status_label.set_text("Stopped %s" % self.running_game.real_name)
|
||||
self.status_label.set_text("Stopped %s"\
|
||||
% self.running_game.real_name)
|
||||
else:
|
||||
LutrisDesktopControl().reset_desktop()
|
||||
|
||||
|
@ -284,9 +288,9 @@ class LutrisWindow(gtk.Window):
|
|||
self.game_treeview.sort_rows()
|
||||
|
||||
|
||||
|
||||
def edit_game_name(self, button):
|
||||
"""Change game name"""
|
||||
|
||||
self.game_cell.set_property('editable', True)
|
||||
self.game_treeview.set_cursor(self.paths[0][0], self.game_column, True)
|
||||
|
||||
|
@ -299,7 +303,6 @@ class LutrisWindow(gtk.Window):
|
|||
|
||||
def edit_game_configuration(self, button):
|
||||
"""Edit game preferences"""
|
||||
|
||||
game = self.get_selected_game()
|
||||
EditGameConfigDialog(self, game)
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import gtk
|
|||
from lutris.runners import import_runner
|
||||
from lutris.gui.configvbox import ConfigVBox
|
||||
|
||||
|
||||
class RunnerConfigVBox(ConfigVBox):
|
||||
""" Runner Configuration VBox
|
||||
This vbox is used in game configuration and global
|
||||
|
@ -38,7 +39,7 @@ class RunnerConfigVBox(ConfigVBox):
|
|||
self.lutris_config = lutris_config
|
||||
self.generate_widgets()
|
||||
else:
|
||||
warningLabel = gtk.Label("This runner has no options yet\nPlease fix this")
|
||||
warningLabel = gtk.Label("This runner has no options yet\n"\
|
||||
+ "Please fix this")
|
||||
self.pack_start(warningLabel)
|
||||
return
|
||||
|
||||
|
|
|
@ -19,11 +19,13 @@
|
|||
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
###############################################################################
|
||||
|
||||
import gtk, os
|
||||
import gtk
|
||||
import os
|
||||
from os.path import join, abspath
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.abspath(__file__), '..', '..', '..')))
|
||||
sys.path.insert(0, abspath(join(abspath(__file__), '..', '..', '..')))
|
||||
print sys.path
|
||||
|
||||
import lutris.runners
|
||||
|
@ -32,12 +34,13 @@ from lutris.config import LutrisConfig
|
|||
from lutris.gui.runnerconfigvbox import RunnerConfigVBox
|
||||
from lutris.gui.systemconfigvbox import SystemConfigVBox
|
||||
|
||||
|
||||
class RunnerConfigDialog(gtk.Dialog):
|
||||
""" """
|
||||
def __init__(self,runner):
|
||||
def __init__(self, runner):
|
||||
gtk.Dialog.__init__(self)
|
||||
self.set_title("Configure %s" % (runner))
|
||||
self.set_size_request(570,500)
|
||||
self.set_size_request(570, 500)
|
||||
self.runner = runner
|
||||
self.lutris_config = LutrisConfig(runner=runner)
|
||||
|
||||
|
@ -46,18 +49,24 @@ class RunnerConfigDialog(gtk.Dialog):
|
|||
self.vbox.pack_start(self.config_notebook, True, True, 0)
|
||||
|
||||
#Runner configuration
|
||||
self.runner_config_vbox = RunnerConfigVBox(self.lutris_config,"runner")
|
||||
runner_config_scrolled_window = gtk.ScrolledWindow()
|
||||
runner_config_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
runner_config_scrolled_window.add_with_viewport(self.runner_config_vbox)
|
||||
self.config_notebook.append_page(runner_config_scrolled_window,gtk.Label("Runner configuration"))
|
||||
self.runner_config_vbox = RunnerConfigVBox(self.lutris_config,
|
||||
"runner")
|
||||
runner_scrollwindow = gtk.ScrolledWindow()
|
||||
runner_scrollwindow.set_policy(gtk.POLICY_AUTOMATIC,
|
||||
gtk.POLICY_AUTOMATIC)
|
||||
runner_scrollwindow.add_with_viewport(self.runner_config_vbox)
|
||||
self.config_notebook.append_page(runner_scrollwindow,
|
||||
gtk.Label("Runner configuration"))
|
||||
|
||||
#System configuration
|
||||
self.system_config_vbox = SystemConfigVBox(self.lutris_config,"runner")
|
||||
system_config_scrolled_window = gtk.ScrolledWindow()
|
||||
system_config_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
|
||||
system_config_scrolled_window.add_with_viewport(self.system_config_vbox)
|
||||
self.config_notebook.append_page(system_config_scrolled_window,gtk.Label("System configuration"))
|
||||
self.system_config_vbox = SystemConfigVBox(self.lutris_config,
|
||||
"runner")
|
||||
system_scrollwindow = gtk.ScrolledWindow()
|
||||
system_scrollwindow.set_policy(gtk.POLICY_AUTOMATIC,
|
||||
gtk.POLICY_AUTOMATIC)
|
||||
system_scrollwindow.add_with_viewport(self.system_config_vbox)
|
||||
self.config_notebook.append_page(system_scrollwindow,
|
||||
gtk.Label("System configuration"))
|
||||
|
||||
#Action buttons
|
||||
cancel_button = gtk.Button(None, gtk.STOCK_CANCEL)
|
||||
|
@ -70,21 +79,22 @@ class RunnerConfigDialog(gtk.Dialog):
|
|||
self.show_all()
|
||||
self.run()
|
||||
|
||||
def close(self,widget):
|
||||
def close(self, widget):
|
||||
self.destroy()
|
||||
|
||||
def ok_clicked(self,wigdet):
|
||||
def ok_clicked(self, wigdet):
|
||||
self.system_config_vbox.lutris_config.config_type = "runner"
|
||||
self.system_config_vbox.lutris_config.save()
|
||||
self.destroy()
|
||||
|
||||
|
||||
class RunnersDialog(gtk.Dialog):
|
||||
"""Dialog for the runner preferences"""
|
||||
|
||||
def __init__(self):
|
||||
gtk.Dialog.__init__(self)
|
||||
self.set_title("Configure runners")
|
||||
self.set_size_request(570,400)
|
||||
self.set_size_request(570, 400)
|
||||
|
||||
label = gtk.Label()
|
||||
label.set_markup("""
|
||||
|
@ -108,7 +118,7 @@ class RunnersDialog(gtk.Dialog):
|
|||
|
||||
hbox = gtk.HBox()
|
||||
#Icon
|
||||
icon_path = os.path.join(lutris.constants.DATA_PATH,
|
||||
icon_path = os.path.join(lutris.constants.DATA_PATH,
|
||||
'media/runner_icons',
|
||||
runner + '.png')
|
||||
icon = gtk.Image()
|
||||
|
@ -117,40 +127,42 @@ class RunnersDialog(gtk.Dialog):
|
|||
|
||||
#Label
|
||||
runner_label = gtk.Label()
|
||||
runner_label.set_markup("<b>"+runner + "</b>\n" + description + "\n <i>Supported platforms : " + machine + "</i>")
|
||||
runner_label.set_markup("<b>%s</b>\n%s\n "\
|
||||
+ "<i>Supported platforms : %s</i>"\
|
||||
% (runner, description, machine))
|
||||
runner_label.set_width_chars(38)
|
||||
runner_label.set_line_wrap(True)
|
||||
runner_label.set_alignment(0.0,0.0)
|
||||
runner_label.set_padding(25,5)
|
||||
hbox.pack_start(runner_label,True, True)
|
||||
runner_label.set_alignment(0.0, 0.0)
|
||||
runner_label.set_padding(25, 5)
|
||||
hbox.pack_start(runner_label, True, True)
|
||||
#Button
|
||||
button = gtk.Button("Configure")
|
||||
button.set_size_request(100,30)
|
||||
button_align = gtk.Alignment(0.0,1.0,0.0,0.0)
|
||||
button.set_size_request(100, 30)
|
||||
button_align = gtk.Alignment(0.0, 1.0, 0.0, 0.0)
|
||||
if runner_instance.is_installed():
|
||||
button.set_label('Configure')
|
||||
button.set_size_request(100,30)
|
||||
button.connect("clicked",self.on_configure_clicked,runner)
|
||||
button.set_size_request(100, 30)
|
||||
button.connect("clicked", self.on_configure_clicked, runner)
|
||||
else:
|
||||
button.set_label('Install')
|
||||
button.connect("clicked",self.on_install_clicked,runner)
|
||||
button.connect("clicked", self.on_install_clicked, runner)
|
||||
button_align.add(button)
|
||||
hbox.pack_start(button_align,True,False)
|
||||
hbox.pack_start(button_align, True, False)
|
||||
|
||||
runner_vbox.pack_start(hbox,True,True,5)
|
||||
runner_vbox.pack_start(hbox, True, True, 5)
|
||||
scrolled_window.add_with_viewport(runner_vbox)
|
||||
self.show_all()
|
||||
|
||||
def close(self, widget=None, other=None):
|
||||
self.destroy()
|
||||
|
||||
def on_install_clicked(self,widget,runner_classname):
|
||||
def on_install_clicked(self, widget, runner_classname):
|
||||
"""Install a runner"""
|
||||
runner_class = import_runner(runner_classname)
|
||||
runner = runner_class()
|
||||
runner.install()
|
||||
|
||||
def on_configure_clicked(self,widget,runner):
|
||||
def on_configure_clicked(self, widget, runner):
|
||||
RunnerConfigDialog(runner)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -2,15 +2,17 @@ from lutris.config import LutrisConfig
|
|||
from lutris.gui.systemconfigvbox import SystemConfigVBox
|
||||
import gtk
|
||||
|
||||
|
||||
class SystemConfigDialog(gtk.Dialog):
|
||||
def __init__(self):
|
||||
gtk.Dialog.__init__(self)
|
||||
self.set_title("System preferences")
|
||||
self.set_size_request(400,500)
|
||||
self.set_size_request(400, 500)
|
||||
self.lutris_config = LutrisConfig()
|
||||
self.system_config_vbox = SystemConfigVBox(self.lutris_config,'system')
|
||||
self.system_config_vbox = SystemConfigVBox(self.lutris_config,
|
||||
'system')
|
||||
self.vbox.pack_start(self.system_config_vbox)
|
||||
|
||||
|
||||
#Action area
|
||||
cancel_button = gtk.Button(None, gtk.STOCK_CANCEL)
|
||||
add_button = gtk.Button(None, gtk.STOCK_SAVE)
|
||||
|
@ -18,14 +20,14 @@ class SystemConfigDialog(gtk.Dialog):
|
|||
self.action_area.pack_start(add_button)
|
||||
cancel_button.connect("clicked", self.close)
|
||||
add_button.connect("clicked", self.save_config)
|
||||
|
||||
|
||||
self.show_all()
|
||||
|
||||
def save_config(self,widget):
|
||||
print "config",self.system_config_vbox.lutris_config.config
|
||||
def save_config(self, widget):
|
||||
# FIXME : Use logging system !
|
||||
print "config", self.system_config_vbox.lutris_config.config
|
||||
self.system_config_vbox.lutris_config.save()
|
||||
self.destroy()
|
||||
|
||||
def close(self,widget):
|
||||
def close(self, widget):
|
||||
self.destroy()
|
||||
|
||||
|
|
|
@ -24,40 +24,70 @@ import logging
|
|||
from lutris.gui.configvbox import ConfigVBox
|
||||
from lutris.desktop_control import get_resolutions
|
||||
|
||||
class SystemConfigVBox(ConfigVBox):
|
||||
"""VBox for system configuration, to be inserted in main preferences, runner preferences
|
||||
and game preferences"""
|
||||
|
||||
def __init__(self,lutris_config,caller):
|
||||
class SystemConfigVBox(ConfigVBox):
|
||||
"""VBox for system configuration, to be inserted in main preferences,
|
||||
runner preferences and game preferences
|
||||
"""
|
||||
|
||||
def __init__(self, lutris_config, caller):
|
||||
"""VBox init"""
|
||||
ConfigVBox.__init__(self,"system",caller)
|
||||
ConfigVBox.__init__(self, "system", caller)
|
||||
self.lutris_config = lutris_config
|
||||
|
||||
#TODO : Move the list of window manager somewhere else, in lutris_desktop_control for example.
|
||||
#TODO : Move the list of window manager somewhere else, in
|
||||
# lutris_desktop_control for example.
|
||||
#TODO : Auto detect the installed WMs on the user's machine
|
||||
#TODO : If the user_wm has not yet been set, detect the WM currently running
|
||||
wm_list = [("Compiz","compiz"), ("OpenBox","openbox"), ("KWin","kwin"),
|
||||
("Metacity","metacity"),
|
||||
("Metacity (Composited)","metacity_composited")]
|
||||
#TODO : If the user_wm has not yet been set, detect the WM currently
|
||||
# running
|
||||
wm_list = [("Compiz", "compiz"), ("OpenBox", "openbox"),
|
||||
("KWin", "kwin"), ("Metacity", "metacity"),
|
||||
("Metacity (Composited)", "metacity_composited")]
|
||||
|
||||
#TODO : Same thing for OSS Wrappers
|
||||
oss_list = [("None (don't use OSS)","none"),
|
||||
("aoss (OSS Wrapper for Alsa)","aoss"),
|
||||
("esddsp (OSS Wrapper for esound)","esddsp"),
|
||||
("padsp (OSS Wrapper for PulseAudio)","padsp")]
|
||||
oss_list = [("None (don't use OSS)", "none"),
|
||||
("aoss (OSS Wrapper for Alsa)", "aoss"),
|
||||
("esddsp (OSS Wrapper for esound)", "esddsp"),
|
||||
("padsp (OSS Wrapper for PulseAudio)", "padsp")]
|
||||
|
||||
resolution_list = get_resolutions()
|
||||
|
||||
self.options = [{'option': "game_path", "type": "directory_chooser", "label": "Default game path"},
|
||||
{'option': "user_wm", "type": "one_choice", "label":"Desktop Window Manager","choices": wm_list },
|
||||
{'option': "game_wm", "type": "one_choice", "label":"Gaming Window Manager","choices": wm_list },
|
||||
{'option': "resolution", "type": "one_choice", "label": "Resolution", "choices": resolution_list },
|
||||
{'option': "oss_wrapper", "type": "one_choice", "label":"OSS Wrapper","choices": oss_list },
|
||||
{'option': "reset_pulse", "type": "bool", "label":"Reset PulseAudio" },
|
||||
{'option': "hide_panels", "type": "bool", "label":"Hide Gnome Panels" },
|
||||
{'option': 'reset_desktop', 'type': 'bool', 'label': 'Reset resolution when game quits' },
|
||||
{'option': 'compiz_nodecoration', 'type': 'string', 'label': 'Remove window decoration with compiz' },
|
||||
{'option': 'compiz_fullscreen', 'type': 'string', 'label': 'Make a fullscreen window with compiz' },
|
||||
{'option': 'killswitch', 'type': 'string', 'label': 'Killswitch file'}]
|
||||
self.options = [{'option': 'game_path',
|
||||
'type': 'directory_chooser',
|
||||
'label': 'Default game path'},
|
||||
{'option': 'user_wm',
|
||||
'type': 'one_choice',
|
||||
'label': 'Desktop Window Manager',
|
||||
'choices': wm_list},
|
||||
{'option': 'game_wm',
|
||||
'type': 'one_choice',
|
||||
'label':'Gaming Window Manager',
|
||||
'choices': wm_list},
|
||||
{'option': 'resolution',
|
||||
'type': 'one_choice',
|
||||
'label': 'Resolution',
|
||||
'choices': resolution_list},
|
||||
{'option': 'oss_wrapper',
|
||||
'type': 'one_choice',
|
||||
'label': 'OSS Wrapper',
|
||||
'choices': oss_list},
|
||||
{'option': 'reset_pulse',
|
||||
'type': 'bool',
|
||||
'label':'Reset PulseAudio'},
|
||||
{'option': 'hide_panels',
|
||||
'type': 'bool',
|
||||
'label':'Hide Gnome Panels'},
|
||||
{'option': 'reset_desktop',
|
||||
'type': 'bool',
|
||||
'label': 'Reset resolution when game quits'},
|
||||
{'option': 'compiz_nodecoration',
|
||||
'type': 'string',
|
||||
'label': 'Remove window decoration with compiz'},
|
||||
{'option': 'compiz_fullscreen',
|
||||
'type': 'string',
|
||||
'label': 'Make a fullscreen window with compiz'},
|
||||
{'option': 'killswitch',
|
||||
'type': 'string',
|
||||
'label': 'Killswitch file'}]
|
||||
|
||||
self.generate_widgets()
|
||||
|
|
|
@ -29,7 +29,8 @@ from lutris.constants import COVER_PATH, DATA_PATH
|
|||
import lutris.constants
|
||||
|
||||
ICON_SIZE = 24
|
||||
MISSING_APP_ICON = "/usr/share/icons/gnome/24x24/categories/applications-other.png"
|
||||
MISSING_ICON = "/usr/share/icons/gnome/24x24/categories/applications-other.png"
|
||||
|
||||
|
||||
class GameTreeView(gtk.TreeView):
|
||||
"""
|
||||
|
@ -38,12 +39,12 @@ class GameTreeView(gtk.TreeView):
|
|||
Many thanks to Michael Vogt
|
||||
|
||||
"""
|
||||
COL_ICON = 1 # Column number for the icon
|
||||
COL_TEXT = 2 # Column number for the description
|
||||
COL_ICON = 1 # Column number for the icon
|
||||
COL_TEXT = 2 # Column number for the description
|
||||
|
||||
def __init__(self, games):
|
||||
super(GameTreeView, self).__init__()
|
||||
model = gtk.ListStore(str,gtk.gdk.Pixbuf, str)
|
||||
model = gtk.ListStore(str, gtk.gdk.Pixbuf, str)
|
||||
model.set_sort_column_id(0, gtk.SORT_ASCENDING)
|
||||
self.set_model(model)
|
||||
tp = gtk.CellRendererPixbuf()
|
||||
|
@ -64,7 +65,7 @@ class GameTreeView(gtk.TreeView):
|
|||
game['runner'] + '.png')
|
||||
pix = gtk.gdk.pixbuf_new_from_file_at_size(icon_path,
|
||||
ICON_SIZE, ICON_SIZE)
|
||||
row = model.append([game['id'], pix, s,])
|
||||
row = model.append([game['id'], pix, s, ])
|
||||
return row
|
||||
|
||||
def remove_row(self, model_iter):
|
||||
|
@ -75,6 +76,7 @@ class GameTreeView(gtk.TreeView):
|
|||
model = self.get_model()
|
||||
gtk.TreeModelSort(model)
|
||||
|
||||
|
||||
class GameCover(gtk.Image):
|
||||
def __init__(self, parent=None):
|
||||
super(GameCover, self).__init__()
|
||||
|
@ -104,12 +106,11 @@ class GameCover(gtk.Image):
|
|||
self.drag_dest_unset()
|
||||
|
||||
def activate_drop(self):
|
||||
targets = [('text/plain',0, 0),
|
||||
('text/uri-list',0, 0),
|
||||
('text/html',0, 0),
|
||||
('text/unicode',0, 0),
|
||||
('text/x-moz-url',0, 0)
|
||||
]
|
||||
targets = [('text/plain', 0, 0),
|
||||
('text/uri-list', 0, 0),
|
||||
('text/html', 0, 0),
|
||||
('text/unicode', 0, 0),
|
||||
('text/x-moz-url', 0, 0)]
|
||||
self.drag_dest_set(gtk.DEST_DEFAULT_ALL, targets,
|
||||
gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE)
|
||||
|
||||
|
@ -135,21 +136,20 @@ class GameCover(gtk.Image):
|
|||
self.set_game_cover(game)
|
||||
return True
|
||||
|
||||
|
||||
class DownloadProgressBox(gtk.HBox):
|
||||
__gsignals__ = {'complete' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
||||
(gobject.TYPE_PYOBJECT,)),
|
||||
'cancelrequested' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
||||
(gobject.TYPE_PYOBJECT,))
|
||||
}
|
||||
__gsignals__ = {'complete': (gobject.SIGNAL_RUN_LAST,
|
||||
gobject.TYPE_NONE,
|
||||
(gobject.TYPE_PYOBJECT,)),
|
||||
'cancelrequested': (gobject.SIGNAL_RUN_LAST,
|
||||
gobject.TYPE_NONE,
|
||||
(gobject.TYPE_PYOBJECT,))}
|
||||
|
||||
def __init__(self, params, cancelable=True):
|
||||
|
||||
gtk.HBox.__init__(self, False, 2)
|
||||
|
||||
self.progressbar = gtk.ProgressBar()
|
||||
self.progressbar.show()
|
||||
self.pack_start(self.progressbar, True)
|
||||
|
||||
self.cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL)
|
||||
if cancelable:
|
||||
self.cancel_button.show()
|
||||
|
@ -182,7 +182,6 @@ class DownloadProgressBox(gtk.HBox):
|
|||
def __stop_download(self, widget):
|
||||
self.downloader.kill = True
|
||||
self.cancel_button.set_sensitive(False)
|
||||
#self.downloader = None
|
||||
|
||||
def cancel(self):
|
||||
print "cancelling download"
|
||||
|
|
|
@ -27,7 +27,8 @@ import urllib2
|
|||
import platform
|
||||
import subprocess
|
||||
import lutris.constants
|
||||
from lutris.constants import LUTRIS_CACHE_PATH, INSTALLER_URL, ICON_PATH, BANNER_PATH
|
||||
from lutris.constants import LUTRIS_CACHE_PATH, INSTALLER_URL,\
|
||||
ICON_PATH, BANNER_PATH
|
||||
|
||||
from lutris.config import LutrisConfig
|
||||
from lutris.game import LutrisGame
|
||||
|
@ -36,6 +37,7 @@ from lutris.gui.widgets import DownloadProgressBox
|
|||
from lutris.shortcuts import create_launcher
|
||||
from lutris.util import log
|
||||
|
||||
|
||||
def unzip(filename, dest=None):
|
||||
"""Unzips a file"""
|
||||
command = ["unzip", '-o', filename]
|
||||
|
@ -43,11 +45,13 @@ def unzip(filename, dest=None):
|
|||
command = command + ['-d', dest]
|
||||
subprocess.call(command)
|
||||
|
||||
|
||||
def unrar(filename):
|
||||
"""Unrar a file"""
|
||||
|
||||
subprocess.call(["unrar", "x", filename])
|
||||
|
||||
|
||||
def untar(filename, dest=None, method='gzip'):
|
||||
"""Untar a file"""
|
||||
cwd = os.getcwd()
|
||||
|
@ -62,11 +66,13 @@ def untar(filename, dest=None, method='gzip'):
|
|||
subprocess.call(["tar", "x%sf" % compression_flag, filename])
|
||||
os.chdir(cwd)
|
||||
|
||||
|
||||
def run_installer(filename):
|
||||
"""Run an installer of .sh or .run type"""
|
||||
subprocess.call(["chmod", "+x", filename])
|
||||
subprocess.call([filename])
|
||||
|
||||
|
||||
def reporthook(piece, received_bytes, total_size):
|
||||
"""Follows the progress of a download"""
|
||||
|
||||
|
@ -105,7 +111,8 @@ class Installer(gtk.Dialog):
|
|||
self.gamefiles = {}
|
||||
|
||||
self.location_button = gtk.FileChooserButton("Select folder")
|
||||
self.location_button.set_current_folder(os.path.expanduser('~') + "/quake")
|
||||
default_path = os.path.expanduser('~') + self.game_slug
|
||||
self.location_button.set_current_folder(default_path)
|
||||
self.location_button.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
||||
self.location_button.connect("file-set", self.game_dir_set)
|
||||
if installer is False:
|
||||
|
@ -121,7 +128,7 @@ class Installer(gtk.Dialog):
|
|||
|
||||
self.download_progress = None
|
||||
gtk.Dialog.__init__(self)
|
||||
self.set_default_size(600,480)
|
||||
self.set_default_size(600, 480)
|
||||
self.set_resizable(False)
|
||||
self.connect('destroy', lambda q: gtk.main_quit())
|
||||
|
||||
|
@ -140,9 +147,9 @@ class Installer(gtk.Dialog):
|
|||
# Install location
|
||||
self.status_label = gtk.Label()
|
||||
self.status_label.set_markup('<b>Select installation directory:</b>')
|
||||
self.status_label.set_alignment(0,0)
|
||||
self.status_label.set_padding(20,0)
|
||||
self.vbox.pack_start(self.status_label, True, True,2)
|
||||
self.status_label.set_alignment(0, 0)
|
||||
self.status_label.set_padding(20, 0)
|
||||
self.vbox.pack_start(self.status_label, True, True, 2)
|
||||
|
||||
self.widget_box = gtk.HBox()
|
||||
self.vbox.pack_start(self.widget_box)
|
||||
|
@ -158,7 +165,7 @@ class Installer(gtk.Dialog):
|
|||
#self.install_button.set_sensitive(False)
|
||||
|
||||
self.action_buttons = gtk.Alignment()
|
||||
self.action_buttons.set(0.95,0.1,0.15,0)
|
||||
self.action_buttons.set(0.95, 0.1, 0.15, 0)
|
||||
self.action_buttons.add(self.install_button)
|
||||
|
||||
self.vbox.pack_start(self.action_buttons, False, False)
|
||||
|
@ -180,7 +187,6 @@ class Installer(gtk.Dialog):
|
|||
success = True
|
||||
return success
|
||||
|
||||
|
||||
def pre_install(self):
|
||||
"""Reads the installer and checks everything is OK
|
||||
before beginning the install process
|
||||
|
@ -196,13 +202,13 @@ class Installer(gtk.Dialog):
|
|||
pass
|
||||
|
||||
icon_url = 'http://lutris.net/media/game_icons/%s.png' % self.game_slug
|
||||
icon_path = os.path.join(ICON_PATH, "%s.png" % self.game_slug)
|
||||
try:
|
||||
urllib.urlretrieve(icon_url, os.path.join(ICON_PATH, "%s.png" % self.game_slug))
|
||||
urllib.urlretrieve(icon_url, icon_path)
|
||||
except IOError:
|
||||
print "cant get icon"
|
||||
pass
|
||||
|
||||
|
||||
# Download installer if not already there.
|
||||
if not os.path.exists(self.installer_dest_path):
|
||||
success = self.download_installer()
|
||||
|
@ -221,7 +227,8 @@ class Installer(gtk.Dialog):
|
|||
games_dir = self.lutris_config.get_path()
|
||||
|
||||
if not games_dir:
|
||||
log.logger.debug("No default path for %s games" % self.install_data['runner'])
|
||||
log.logger.debug("No default path for %s games"
|
||||
% self.install_data['runner'])
|
||||
return True
|
||||
|
||||
self.game_dir = os.path.join(games_dir, self.game_name)
|
||||
|
@ -241,11 +248,11 @@ class Installer(gtk.Dialog):
|
|||
|
||||
self.location_button.destroy()
|
||||
self.install_button.set_sensitive(False)
|
||||
|
||||
|
||||
self.current_file = 0
|
||||
self.total_files = len(self.install_data['files'])
|
||||
self.download_game_file()
|
||||
|
||||
|
||||
def download_game_file(self):
|
||||
if self.current_file == len(self.install_data['files']):
|
||||
self.install()
|
||||
|
@ -257,7 +264,7 @@ class Installer(gtk.Dialog):
|
|||
# file to fetch or a dict with the possible options :
|
||||
# - url : location of file (mandatory)
|
||||
# - filename : force destination filename
|
||||
# - nocopy : don't copy the file in the cache (doesn't work for internet links)
|
||||
# - nocopy : don't copy the file in the cache (not for internet links)
|
||||
copyfile = True
|
||||
if isinstance(gamefile[file_id], dict):
|
||||
url = gamefile[file_id]['url']
|
||||
|
@ -274,10 +281,10 @@ class Installer(gtk.Dialog):
|
|||
dest_path = self._download(url, filename, copyfile)
|
||||
self.gamefiles[file_id] = dest_path
|
||||
return True
|
||||
|
||||
|
||||
def install(self):
|
||||
log.logger.debug("Running installation")
|
||||
|
||||
|
||||
if self.download_progress is not None:
|
||||
self.download_progress.destroy()
|
||||
os.chdir(self.game_dir)
|
||||
|
@ -286,12 +293,12 @@ class Installer(gtk.Dialog):
|
|||
action_name = action.keys()[0]
|
||||
action_data = action[action_name]
|
||||
mappings = {'check_md5': self.check_md5,
|
||||
'extract' : self._extract,
|
||||
'move' : self._move,
|
||||
'extract': self._extract,
|
||||
'move': self._move,
|
||||
'delete': self.delete,
|
||||
'request_media': self._request_media,
|
||||
'run': self._run,
|
||||
'locate': self._locate }
|
||||
'locate': self._locate}
|
||||
if action_name not in mappings.keys():
|
||||
print "Action " + action_name + " not supported !"
|
||||
return False
|
||||
|
@ -300,28 +307,32 @@ class Installer(gtk.Dialog):
|
|||
self.write_config()
|
||||
|
||||
self.status_label.set_text("Installation finished !")
|
||||
|
||||
|
||||
add_desktop_shortcut = gtk.Button('Create a desktop shortcut')
|
||||
add_desktop_shortcut.connect('clicked', lambda d: create_launcher(self.game_slug, desktop=True))
|
||||
add_desktop_shortcut.connect('clicked',
|
||||
lambda d: create_launcher(self.game_slug,
|
||||
desktop=True))
|
||||
add_menu_shortcut = gtk.Button('Create an icon in the application menu')
|
||||
add_menu_shortcut.connect('clicked', lambda m: create_launcher(self.game_slug, menu=True))
|
||||
add_menu_shortcut.connect('clicked',
|
||||
lambda m: create_launcher(self.game_slug,
|
||||
menu=True))
|
||||
buttons_box = gtk.HBox()
|
||||
buttons_box.pack_start(add_desktop_shortcut, False, False, 10)
|
||||
buttons_box.pack_start(add_menu_shortcut, False, False, 10)
|
||||
buttons_box.show_all()
|
||||
|
||||
|
||||
self.widget_box.pack_start(buttons_box, True, True, 10)
|
||||
|
||||
|
||||
self.install_button.destroy()
|
||||
play_button = gtk.Button("Launch game")
|
||||
play_button.show()
|
||||
play_button.connect('clicked', self.launch_game)
|
||||
self.action_buttons.add(play_button)
|
||||
|
||||
|
||||
def parseconfig(self):
|
||||
""" Reads the installer file. """
|
||||
|
||||
self.install_data = yaml.load(file(self.installer_dest_path, 'r').read())
|
||||
raw_data = file(self.installer_dest_path, 'r').read()
|
||||
self.install_data = yaml.load(raw_data)
|
||||
|
||||
#Checking protocol
|
||||
protocol_version = self.install_data['protocol']
|
||||
|
@ -331,7 +342,7 @@ class Installer(gtk.Dialog):
|
|||
return False
|
||||
|
||||
mandatory_fields = ['version', 'runner', 'name']
|
||||
optional_fields = ['exe', 'exe64','iso', 'rom']
|
||||
optional_fields = ['exe', 'exe64', 'iso', 'rom']
|
||||
for field in mandatory_fields:
|
||||
self.game_info[field] = self.install_data[field]
|
||||
for field in optional_fields:
|
||||
|
@ -346,7 +357,7 @@ class Installer(gtk.Dialog):
|
|||
return True
|
||||
|
||||
def write_config(self):
|
||||
""" Writes the game configration as a Lutris launcher. """
|
||||
""" Write the game configuration as a Lutris launcher."""
|
||||
config_filename = os.path.join(lutris.constants.GAME_CONFIG_PATH,
|
||||
self.game_slug + ".yml")
|
||||
|
||||
|
@ -412,7 +423,9 @@ class Installer(gtk.Dialog):
|
|||
location = os.path.join(file_path, basename)
|
||||
shutil.copy(location, dest_dir)
|
||||
else:
|
||||
self.download_progress = DownloadProgressBox({'url': url, 'dest': dest_file}, cancelable=False)
|
||||
self.download_progress = DownloadProgressBox({'url': url,
|
||||
'dest': dest_file},
|
||||
cancelable=False)
|
||||
self.download_progress.connect('complete', self.download_complete)
|
||||
self.widget_box.pack_start(self.download_progress, True, True)
|
||||
self.download_progress.show()
|
||||
|
@ -451,7 +464,7 @@ class Installer(gtk.Dialog):
|
|||
|
||||
def _move(self, data):
|
||||
""" Moves a file. """
|
||||
|
||||
|
||||
src = data['src']
|
||||
self.status_label.set_text("Moving %s" % src)
|
||||
if src in self.gamefiles.keys():
|
||||
|
@ -482,6 +495,7 @@ class Installer(gtk.Dialog):
|
|||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def _run(self, data):
|
||||
exec_path = os.path.join(lutris.constants.TMP_PATH, self.game_slug,
|
||||
self.gamefiles[data['file']])
|
||||
|
@ -498,6 +512,3 @@ class Installer(gtk.Dialog):
|
|||
def launch_game(self, widget, data=None):
|
||||
lutris_game = LutrisGame(self.game_slug)
|
||||
lutris_game.play()
|
||||
|
||||
|
||||
|
||||
|
|
BIN
lutris/installer.pyc
Normal file
BIN
lutris/installer.pyc
Normal file
Binary file not shown.
65
lutris/pga.py
Normal file
65
lutris/pga.py
Normal file
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding:Utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2012 Mathieu Comandon <strider@strycore.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 3 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# 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, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
import sqlite3
|
||||
import re
|
||||
|
||||
from lutris.settings import PGA_PATH
|
||||
|
||||
def slugify(value):
|
||||
"""
|
||||
Normalizes string, converts to lowercase, removes non-alpha characters,
|
||||
and converts spaces to hyphens.
|
||||
"""
|
||||
import unicodedata
|
||||
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
|
||||
value = unicode(re.sub('[^\w\s-]', '', value).strip().lower())
|
||||
return re.sub('[-\s]+', '-', value)
|
||||
|
||||
def connect():
|
||||
return sqlite3.connect(PGA_PATH)
|
||||
|
||||
def create():
|
||||
c = connect()
|
||||
c.execute('''create table games (name text, slug text, machine text, runner text)''')
|
||||
c.commit()
|
||||
c.close()
|
||||
|
||||
def get_games(name_filter=None):
|
||||
c = connect()
|
||||
cur = c.cursor()
|
||||
|
||||
if filter is not None:
|
||||
q = "select * from where name LIKE = ?"
|
||||
rows = cur.execute(q, (name_filter, ))
|
||||
else:
|
||||
q = "select * from games"
|
||||
rows = cur.execute(q)
|
||||
results = rows.fetchall()
|
||||
cur.close()
|
||||
c.close()
|
||||
return results
|
||||
|
||||
def add_game(name, machine, runner):
|
||||
slug = slugify(name)
|
||||
c = connect()
|
||||
c.execute("""insert into games(name, slug, machine, runner) values
|
||||
(?, ?, ?, ?)""", (name, slug, machine, runner))
|
||||
c.commit()
|
||||
c.close()
|
BIN
lutris/pga.pyc
Normal file
BIN
lutris/pga.pyc
Normal file
Binary file not shown.
BIN
lutris/platform.pyc
Normal file
BIN
lutris/platform.pyc
Normal file
Binary file not shown.
9
lutris/settings.py
Normal file
9
lutris/settings.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from os.path import realpath, normpath, dirname, join, exists, expanduser
|
||||
from xdg import BaseDirectory
|
||||
import sys
|
||||
|
||||
LUTRIS_CONFIG_PATH = join(BaseDirectory.xdg_config_home, 'lutris')
|
||||
LUTRIS_DATA_PATH = join(BaseDirectory.xdg_data_home, 'lutris')
|
||||
LUTRIS_CACHE_PATH = join(BaseDirectory.xdg_cache_home, 'lutris')
|
||||
|
||||
PGA_PATH = join(LUTRIS_DATA_PATH, 'pga.db')
|
BIN
lutris/settings.pyc
Normal file
BIN
lutris/settings.pyc
Normal file
Binary file not shown.
BIN
lutris/shortcuts.pyc
Normal file
BIN
lutris/shortcuts.pyc
Normal file
Binary file not shown.
BIN
lutris/thread.pyc
Normal file
BIN
lutris/thread.pyc
Normal file
Binary file not shown.
Loading…
Reference in a new issue