mirror of
https://github.com/lutris/lutris
synced 2024-09-15 22:09:55 +00:00
List view: changed runner icon to game icon.
Default icon size is now defined in the view type's class.
This commit is contained in:
parent
8f0f3064a2
commit
2155dc48e3
|
@ -8,3 +8,5 @@ tags
|
|||
.ropeproject
|
||||
*.pyc
|
||||
PYSMELLTAGS
|
||||
.eric4project
|
||||
lutris.e4p
|
||||
|
|
|
@ -93,12 +93,12 @@ def icon_to_pixbuf(icon_path, size=128):
|
|||
return pixbuf
|
||||
|
||||
|
||||
def get_pixbuf_for_game(game):
|
||||
def get_pixbuf_for_game(game, icon_size):
|
||||
runner_icon_path = os.path.join(get_data_path(), 'media/runner_icons',
|
||||
'%s.png' % game['runner'])
|
||||
game_icon_path = os.path.join(DATA_DIR, "icons", "%s.png" % game['id'])
|
||||
game_pix = icon_to_pixbuf(game_icon_path)
|
||||
runner_pix = icon_to_pixbuf(runner_icon_path, 24)
|
||||
game_pix = icon_to_pixbuf(game_icon_path, icon_size)
|
||||
runner_pix = icon_to_pixbuf(runner_icon_path, icon_size)
|
||||
return game_pix, runner_pix
|
||||
|
||||
|
||||
|
@ -113,6 +113,9 @@ class GameView(object):
|
|||
contextual_menu = None
|
||||
filter_text = ""
|
||||
games = []
|
||||
|
||||
def __init__(self):
|
||||
self.icon_size = 32
|
||||
|
||||
def initialize_store(self, games):
|
||||
self.games = games if games else []
|
||||
|
@ -131,7 +134,7 @@ class GameView(object):
|
|||
def add_game(self, game):
|
||||
"""Adds a game into the icon view"""
|
||||
store = self.get_model()
|
||||
game_pix, runner_pix = get_pixbuf_for_game(game)
|
||||
game_pix, runner_pix = get_pixbuf_for_game(game, self.icon_size)
|
||||
label = "%s \n<small>%s</small>" % \
|
||||
(game['name'], game['runner'])
|
||||
store.get_model().append((game["id"], label, game_pix,
|
||||
|
@ -167,18 +170,19 @@ class GameTreeView(Gtk.TreeView, GameView):
|
|||
|
||||
def __init__(self, games):
|
||||
super(GameTreeView, self).__init__()
|
||||
self.icon_size = 32
|
||||
self.initialize_store(games)
|
||||
|
||||
# Icon column
|
||||
image_cell = Gtk.CellRendererPixbuf()
|
||||
column = Gtk.TreeViewColumn("Runner", image_cell,
|
||||
pixbuf=COL_RUNNER_ICON)
|
||||
column = Gtk.TreeViewColumn("", image_cell,
|
||||
pixbuf=COL_ICON)
|
||||
self.append_column(column)
|
||||
|
||||
# Name column
|
||||
text_cell = Gtk.CellRendererText()
|
||||
text_cell.set_property("ellipsize", Pango.EllipsizeMode.END)
|
||||
column = Gtk.TreeViewColumn("Game", text_cell, markup=COL_NAME)
|
||||
column = Gtk.TreeViewColumn("Name", text_cell, markup=COL_NAME)
|
||||
self.append_column(column)
|
||||
|
||||
self.get_selection().set_mode(Gtk.SelectionMode.SINGLE)
|
||||
|
@ -215,12 +219,13 @@ class GameIconView(Gtk.IconView, GameView):
|
|||
|
||||
def __init__(self, games):
|
||||
super(GameIconView, self).__init__()
|
||||
self.set_item_width(150)
|
||||
self.set_spacing(21)
|
||||
self.icon_size = 128
|
||||
self.initialize_store(games)
|
||||
self.set_markup_column(COL_NAME)
|
||||
self.set_pixbuf_column(COL_ICON)
|
||||
|
||||
self.set_item_width(150)
|
||||
self.set_spacing(21)
|
||||
|
||||
self.connect('item-activated', self.on_item_activated)
|
||||
self.connect('selection-changed', self.on_selection_changed)
|
||||
|
|
Loading…
Reference in a new issue