mirror of
https://github.com/lutris/lutris
synced 2024-11-02 07:10:17 +00:00
added ftp dialog
This commit is contained in:
parent
0b890d49cd
commit
55cf76bd20
4 changed files with 319 additions and 0 deletions
0
lutris/gui/__init__.py
Normal file
0
lutris/gui/__init__.py
Normal file
86
lutris/gui/edit_game_config_dialog.py
Normal file
86
lutris/gui/edit_game_config_dialog.py
Normal file
|
@ -0,0 +1,86 @@
|
|||
# -*- coding:Utf-8 -*-
|
||||
###############################################################################
|
||||
## Lutris
|
||||
##
|
||||
## Copyright (C) 2009 Mathieu Comandon strycore@gmail.com
|
||||
##
|
||||
## 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 3 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
###############################################################################
|
||||
|
||||
import logging
|
||||
import gtk
|
||||
from lutris.config import LutrisConfig
|
||||
from lutris.game_config_vbox import GameConfigVBox
|
||||
from lutris.runner_config_vbox import RunnerConfigVBox
|
||||
from lutris.system_config_vbox import SystemConfigVBox
|
||||
|
||||
class EditGameConfigDialog(gtk.Dialog):
|
||||
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)
|
||||
|
||||
#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)
|
||||
|
||||
#Notebook
|
||||
config_notebook = gtk.Notebook()
|
||||
self.vbox.pack_start(config_notebook)
|
||||
|
||||
#Game configuration tab
|
||||
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.add_with_viewport(self.game_config_vbox)
|
||||
config_notebook.append_page(game_config_scrolled_window,gtk.Label("Game Configuration"))
|
||||
|
||||
#Runner configuration tab
|
||||
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.add_with_viewport(self.runner_config_box)
|
||||
config_notebook.append_page(runner_config_scrolled_window,gtk.Label("Runner Configuration"))
|
||||
|
||||
#System configuration tab
|
||||
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.add_with_viewport(self.system_config_box)
|
||||
config_notebook.append_page(system_config_scrolled_window,gtk.Label("Runner Configuration"))
|
||||
|
||||
#Action Area
|
||||
cancel_button = gtk.Button(None, gtk.STOCK_CANCEL)
|
||||
add_button = gtk.Button(None, gtk.STOCK_EDIT)
|
||||
self.action_area.pack_start(cancel_button)
|
||||
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):
|
||||
logging.debug(self.lutris_config.config)
|
||||
self.lutris_config.save(type="game")
|
||||
self.destroy()
|
||||
|
||||
def close(self,widget=None):
|
||||
self.destroy()
|
105
lutris/gui/ftpdialog.py
Normal file
105
lutris/gui/ftpdialog.py
Normal file
|
@ -0,0 +1,105 @@
|
|||
# -*- coding:Utf-8 -*-
|
||||
###############################################################################
|
||||
## Lutris
|
||||
##
|
||||
## Copyright (C) 2009 Mathieu Comandon strycore@gmail.com
|
||||
##
|
||||
## 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 3 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
###############################################################################
|
||||
|
||||
import gtk
|
||||
import sys
|
||||
sys.path.append('/home/strider/Devel/lutris')
|
||||
|
||||
from lutris.config import LutrisConfig
|
||||
|
||||
class FtpDialog(gtk.Dialog):
|
||||
def __init__(self):
|
||||
gtk.Dialog.__init__(self)
|
||||
self.set_title("FTP Manager")
|
||||
self.set_size_request(600,500)
|
||||
self.connect("destroy", self.destroy_cb)
|
||||
self.main_hbox = gtk.HBox()
|
||||
self.vbox.pack_start(self.main_hbox)
|
||||
|
||||
self.runner_list = gtk.Label("Runner list go here")
|
||||
self.main_hbox.pack_start(self.runner_list)
|
||||
|
||||
self.ftp_vbox = gtk.VBox()
|
||||
self.ftp_vbox.pack_start(gtk.Label("Ftp"),False,False,5)
|
||||
|
||||
destination_label = gtk.Label()
|
||||
destination_label.set_markup("<b>Destination</b>")
|
||||
self.ftp_vbox.pack_start(destination_label,False,False,5)
|
||||
|
||||
label_width = 70
|
||||
label_height = 20
|
||||
|
||||
#Server
|
||||
server_hbox = gtk.HBox()
|
||||
server_label = gtk.Label("Server")
|
||||
server_label.set_size_request(label_width,label_width)
|
||||
self.server_entry = gtk.Entry()
|
||||
server_hbox.pack_start(server_label)
|
||||
server_hbox.pack_start(self.server_entry)
|
||||
self.ftp_vbox.pack_start(server_hbox,False,False,2)
|
||||
|
||||
#login
|
||||
login_hbox = gtk.HBox()
|
||||
login_label = gtk.Label("login")
|
||||
login_label.set_size_request(label_width,label_width)
|
||||
self.login_entry = gtk.Entry()
|
||||
login_hbox.pack_start(login_label)
|
||||
login_hbox.pack_start(self.login_entry)
|
||||
self.ftp_vbox.pack_start(login_hbox,False,False,2)
|
||||
|
||||
#password
|
||||
password_hbox = gtk.HBox()
|
||||
password_label = gtk.Label("password")
|
||||
password_label.set_size_request(label_width,label_width)
|
||||
self.password_entry = gtk.Entry()
|
||||
password_hbox.pack_start(password_label)
|
||||
password_hbox.pack_start(self.password_entry)
|
||||
self.ftp_vbox.pack_start(password_hbox,False,False,2)
|
||||
|
||||
#folder
|
||||
folder_hbox = gtk.HBox()
|
||||
folder_label = gtk.Label("folder")
|
||||
folder_label.set_size_request(label_width,label_width)
|
||||
self.folder_entry = gtk.Entry()
|
||||
folder_hbox.pack_start(folder_label)
|
||||
folder_hbox.pack_start(self.folder_entry)
|
||||
self.ftp_vbox.pack_start(folder_hbox,False,False,2)
|
||||
|
||||
#Destination
|
||||
self.destination_entry = gtk.Entry()
|
||||
self.ftp_vbox.pack_start(self.destination_entry,False,False,5)
|
||||
|
||||
self.main_hbox.pack_start(self.ftp_vbox,False,False,5)
|
||||
self.show_all()
|
||||
|
||||
self.load_runner_config()
|
||||
|
||||
def destroy_cb(self,widget):
|
||||
self.destroy()
|
||||
|
||||
def load_runner_config(self,runner_name = "sdlmame"):
|
||||
lutris_config = LutrisConfig(runner=runner_name)
|
||||
self.destination_entry.set_text(lutris_config.config["system"]["game_path"])
|
||||
|
||||
if __name__ == "__main__":
|
||||
FtpDialog()
|
||||
gtk.main()
|
||||
|
128
lutris/gui/google_image_dialog.py
Normal file
128
lutris/gui/google_image_dialog.py
Normal file
|
@ -0,0 +1,128 @@
|
|||
###############################################################################
|
||||
## Lutris
|
||||
##
|
||||
## Copyright (C) 2009 Mathieu Comandon strycore@gmail.com
|
||||
##
|
||||
## 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 3 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
###############################################################################
|
||||
|
||||
import gtk, gobject
|
||||
import os, threading
|
||||
import logging
|
||||
import lutris.constants
|
||||
from lutris.config import LutrisConfig
|
||||
from lutris.google_image import GoogleImage
|
||||
|
||||
class GoogleImageDialog(gtk.Dialog):
|
||||
def __init__(self,game):
|
||||
self.game = game
|
||||
lutris_config = LutrisConfig(game=game)
|
||||
|
||||
gtk.Dialog.__init__(self)
|
||||
self.set_title(game)
|
||||
self.set_size_request(800,260)
|
||||
|
||||
self.thumbnails_scroll_window = gtk.ScrolledWindow()
|
||||
self.thumbnails_scroll_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.vbox.pack_start(self.thumbnails_scroll_window)
|
||||
|
||||
self.progress_bar = None
|
||||
self.thumbnails_table = None
|
||||
|
||||
#Search Field
|
||||
self.search_entry = gtk.Entry()
|
||||
self.search_entry.set_text(lutris_config["realname"]+" cover")
|
||||
self.search_entry.set_size_request(250,30)
|
||||
self.action_area.pack_start(self.search_entry)
|
||||
#Search
|
||||
search_button = gtk.Button("Search")
|
||||
search_button.connect("clicked",self.search_images)
|
||||
self.action_area.pack_start(search_button)
|
||||
#Cancel
|
||||
cancel_button = gtk.Button(None, gtk.STOCK_CANCEL)
|
||||
cancel_button.connect("clicked", self.close)
|
||||
self.action_area.pack_start(cancel_button)
|
||||
|
||||
self.show_all()
|
||||
|
||||
def close(self,widget=None):
|
||||
self.destroy()
|
||||
|
||||
def search_images(self,widget=None):
|
||||
try:
|
||||
self.thumbnails_table.destroy()
|
||||
except AttributeError:
|
||||
pass
|
||||
finally:
|
||||
self.thumbnails_table = None
|
||||
self.progress_bar = gtk.ProgressBar()
|
||||
self.progress_bar.set_text("Getting Images ...")
|
||||
self.progress_bar.show()
|
||||
self.thumbnails_scroll_window.add_with_viewport(self.progress_bar)
|
||||
|
||||
self.google_image = GoogleImage()
|
||||
self.thumbs_path = lutris.constants.tmp_path
|
||||
self.google_image.get_google_image_page(self.search_entry.get_text())
|
||||
google_fetcher = GoogleFetcher(self.google_image,self.thumbs_path)
|
||||
timer_id = gobject.timeout_add(25, self.refresh_status)
|
||||
google_fetcher.start()
|
||||
|
||||
def show_images(self):
|
||||
self.progress_bar.destroy()
|
||||
self.progress_bar=None
|
||||
|
||||
self.thumbnails_table = gtk.Table(rows=2,columns=20,homogeneous=False)
|
||||
self.thumbnails_table.show()
|
||||
self.thumbnails_scroll_window.add_with_viewport(self.thumbnails_table)
|
||||
index = 0
|
||||
for i in range(0,20):
|
||||
image = gtk.Image()
|
||||
image.set_from_file(os.path.join(self.thumbs_path,str(index)+".jpg"))
|
||||
image_button = gtk.Button()
|
||||
image_button.set_image(image)
|
||||
image_button.show()
|
||||
image_button.connect("clicked",self.select_cover,str(index)+".jpg")
|
||||
image_info = gtk.Label(self.google_image.google_results[index]["size"])
|
||||
image_info.show()
|
||||
image.show()
|
||||
self.thumbnails_table.attach(image_button,index,index+1,0,1,xpadding = 3, ypadding = 3)
|
||||
self.thumbnails_table.attach(image_info,index,index+1,1,2,xpadding = 3, ypadding = 3)
|
||||
index = index + 1
|
||||
|
||||
def refresh_status(self):
|
||||
fraction = self.google_image.fetch_count / 20.0
|
||||
self.progress_bar.set_fraction(fraction)
|
||||
if self.google_image.fetch_count < 20:
|
||||
return True
|
||||
else:
|
||||
self.show_images()
|
||||
return False
|
||||
|
||||
def select_cover(self,widget,file):
|
||||
logging.debug("grabbing %s" % file)
|
||||
self.google_image.get_pic_at(int(file.split('.')[0]),os.path.join(lutris.constants.cover_path,self.game))
|
||||
self.destroy()
|
||||
|
||||
class GoogleFetcher(threading.Thread):
|
||||
def __init__(self,google_image,thumbs_path):
|
||||
threading.Thread.__init__(self)
|
||||
self.google_image = google_image
|
||||
self.thumbs_path = thumbs_path
|
||||
def run(self):
|
||||
self.google_image.scan_for_images(self.thumbs_path)
|
||||
|
||||
if __name__ == "__main__":
|
||||
google_img_dlg = GoogleImageDialog()
|
||||
|
Loading…
Reference in a new issue