Game cover is now droppable (but does nothing yet)

This commit is contained in:
Mathieu Comandon 2011-07-19 03:40:30 +02:00
parent 07fb3274f9
commit 6fa79308dc
5 changed files with 57 additions and 31 deletions

View file

@ -57,11 +57,11 @@ parser.add_option("-v", "--verbose", action="store_true",
dest="verbose", help="Verbose output") dest="verbose", help="Verbose output")
parser.add_option("-d", "--debug", action="store_true", parser.add_option("-d", "--debug", action="store_true",
dest="debug", help="Show debug messages") dest="debug", help="Show debug messages")
parser.add_option("-i", "--install", dest="installer_file", parser.add_option("-i", "--install", dest="installer_file",
help="Install a game from a yml file") help="Install a game from a yml file")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
# Set the logging level to show debug messages. # Set the logging level to show debug messages.
if options.debug: if options.debug:
@ -98,7 +98,7 @@ for arg in args:
break break
if game is not None: if game is not None:
if isinstance(game, str): if isinstance(game, str):
file_path = os.path.join(GAME_CONFIG_PATH, file_path = os.path.join(GAME_CONFIG_PATH,
game + CONFIG_EXTENSION) game + CONFIG_EXTENSION)
else: else:
file_path = None file_path = None
@ -108,6 +108,7 @@ if game is not None:
lutris_game = lutris.game.LutrisGame(game) lutris_game = lutris.game.LutrisGame(game)
lutris_game.play() lutris_game.play()
else: else:
log.logger.debug('File %s does not exist, installing game' % file_path)
installer = Installer(game, installer) installer = Installer(game, installer)
gtk.main() gtk.main()
else: else:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 955 B

View file

@ -288,14 +288,15 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkImage" id="game_cover_image"> <object class="GtkAlignment" id="cover_alignment">
<property name="width_request">250</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property> <child>
<placeholder/>
</child>
</object> </object>
<packing> <packing>
<property name="resize">False</property> <property name="resize">True</property>
<property name="shrink">True</property> <property name="shrink">True</property>
</packing> </packing>
</child> </child>

View file

@ -44,7 +44,7 @@ from lutris.gui.googleimagedialog import GoogleImageDialog
from lutris.gui.editgameconfigdialog import EditGameConfigDialog from lutris.gui.editgameconfigdialog import EditGameConfigDialog
from lutris.gui.aboutdialog import NewAboutLutrisDialog from lutris.gui.aboutdialog import NewAboutLutrisDialog
from lutris.desktop_control import LutrisDesktopControl from lutris.desktop_control import LutrisDesktopControl
from lutris.gui.widgets import GameTreeView from lutris.gui.widgets import GameTreeView, GameCover
import lutris.coverflow.coverflow import lutris.coverflow.coverflow
class LutrisWindow(gtk.Window): class LutrisWindow(gtk.Window):
@ -63,7 +63,6 @@ class LutrisWindow(gtk.Window):
# Widgets # Widgets
self.status_label = None self.status_label = None
self.menu = None self.menu = None
self.game_cover_image = None
self.toolbar = None self.toolbar = None
self.joystick_icons = [] self.joystick_icons = []
@ -88,52 +87,52 @@ class LutrisWindow(gtk.Window):
else: else:
LAUNCHPAD_AVAILABLE = False LAUNCHPAD_AVAILABLE = False
# TODO: The game_cover_image will be moved inot it's own widget self.game_cover = GameCover()
self.game_cover_image = self.builder.get_object("game_cover_image") self.game_cover.show()
self.game_cover_image.set_from_file( cover_alignment = self.builder.get_object('cover_alignment')
os.path.join(data_path, "media/background.png") cover_alignment.add(self.game_cover)
)
#Context menu #Contextual menu
game_rename = "Rename", self.edit_game_name play = 'Play', self.game_launch
game_config = "Configure", self.edit_game_configuration rename = 'Rename', self.edit_game_name
game_get_cover = "Get cover", self.get_cover config = 'Configure', self.edit_game_configuration
menu_actions = [game_rename, game_config, game_get_cover] get_cover = 'Get cover', self.get_cover
self.menu = gtk.Menu() self.menu = gtk.Menu()
for item in menu_actions: for item in [play, rename, config, get_cover]:
if item == None: if item == None:
subitem = gtk.SeparatorMenuItem() subitem = gtk.SeparatorMenuItem()
else: else:
subitem = gtk.ImageMenuItem(item[0]) subitem = gtk.ImageMenuItem(item[0])
subitem.connect("activate", item[1]) subitem.connect('activate', item[1])
self.menu.append(subitem) self.menu.append(subitem)
self.menu.show_all() self.menu.show_all()
#Status bar #Status bar
self.status_label = self.builder.get_object("status_label") self.status_label = self.builder.get_object('status_label')
self.status_label.set_text("Ready to roll !") self.status_label.set_text('Insert coin')
for index in range(4): for index in range(4):
self.joystick_icons.append( self.joystick_icons.append(
self.builder.get_object("js" + str(index) + "image") self.builder.get_object('js' + str(index) + 'image')
) )
self.joystick_icons[index].hide() self.joystick_icons[index].hide()
# Toolbar # Toolbar
self.toolbar = self.builder.get_object("lutris_toolbar") self.toolbar = self.builder.get_object('lutris_toolbar')
# Game list # Game list
self.game_list = get_list() self.game_list = get_list()
self.game_treeview = GameTreeView(self.game_list) self.game_treeview = GameTreeView(self.game_list)
self.game_treeview.show() self.game_treeview.show()
self.game_treeview.connect('row-activated', self.game_launch) self.game_treeview.connect('row-activated', self.game_launch)
self.game_treeview.connect("cursor-changed", self.select_game) self.game_treeview.connect('cursor-changed', self.select_game)
self.game_treeview.connect("button-press-event", self.mouse_menu) self.game_treeview.connect('button-press-event', self.mouse_menu)
self.game_column = self.game_treeview.get_column(1) self.game_column = self.game_treeview.get_column(1)
self.game_cell = self.game_column.get_cell_renderers()[0] self.game_cell = self.game_column.get_cell_renderers()[0]
self.game_cell.connect('edited', self.game_name_edited_callback) 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 = self.builder.get_object('game_list_scrolledwindow')
self.game_list_scrolledwindow.add_with_viewport(self.game_treeview) self.game_list_scrolledwindow.add_with_viewport(self.game_treeview)
# Set buttons state # Set buttons state
@ -327,9 +326,13 @@ class LutrisWindow(gtk.Window):
h = cover_pixbuf.get_height() h = cover_pixbuf.get_height()
w = cover_pixbuf.get_width() w = cover_pixbuf.get_width()
dest_h = h * (dest_w / w) dest_h = h * (dest_w / w)
self.game_cover_image.set_from_pixbuf(cover_pixbuf.scale_simple(int(dest_w), int(dest_h), gtk.gdk.INTERP_BILINEAR)) self.game_cover.set_from_pixbuf(cover_pixbuf.scale_simple(
int(dest_w),
int(dest_h),
gtk.gdk.INTERP_BILINEAR
))
return return
else: else:
self.game_cover_image.set_from_file( self.game_cover.set_from_file(
os.path.join(DATA_PATH, "media/background.png") os.path.join(DATA_PATH, "media/background.png")
) )

View file

@ -58,7 +58,7 @@ class GameTreeView(gtk.TreeView):
def add_row(self, game): def add_row(self, game):
model = self.get_model() model = self.get_model()
s = "%s \n<small>%s</small>" % (game['name'], game['runner']) s = "%s \n<small>%s</small>" % (game['name'], game['runner'])
icon_path = os.path.join(lutris.constants.DATA_PATH, icon_path = os.path.join(lutris.constants.DATA_PATH,
'media/runner_icons', 'media/runner_icons',
game['runner'] + '.png') game['runner'] + '.png')
pix = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, pix = gtk.gdk.pixbuf_new_from_file_at_size(icon_path,
@ -74,6 +74,27 @@ class GameTreeView(gtk.TreeView):
model = self.get_model() model = self.get_model()
gtk.TreeModelSort(model) gtk.TreeModelSort(model)
class GameCover(gtk.Image):
def __init__(self, parent=None):
super(GameCover, self).__init__()
self.set_from_file(os.path.join(
lutris.constants.DATA_PATH, "media/background.png"
))
self.connect('drag_data_received', self.on_cover_drop)
targets = [('text/plain',0 , 100)]
self.drag_dest_set(gtk.DEST_DEFAULT_ALL, targets, gtk.gdk.ACTION_ASK)
def on_cover_drop(self, widget, context, x, y, selection, target, ts):
# TODO : Change mouse cursor if no game is selected
print selection.data
file_path = selection.data
if file_path.startswith('file://'):
file_path = file_path[7:]
else:
# TODO : Handle http: (and smb:, stuff like that)
return True
print "matching %s" % file_path
return True
class DownloadProgressBox(gtk.HBox): class DownloadProgressBox(gtk.HBox):
__gsignals__ = {'complete' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, __gsignals__ = {'complete' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,