mirror of
https://github.com/lutris/lutris
synced 2024-09-04 15:03:35 +00:00
Rename Icon view => Grid view
Rename in the code too. GameIconView and GameTreeView classes become GameGridView and GameListView respectively.
This commit is contained in:
parent
95ac1dfdf7
commit
fcd1e2dd1f
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
/data/ui/LutrisWindow.ui~
|
||||
nbproject
|
||||
build
|
||||
.project
|
||||
|
|
|
@ -124,10 +124,10 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkRadioMenuItem" id="iconview_menuitem">
|
||||
<object class="GtkRadioMenuItem" id="gridview_menuitem">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Icons</property>
|
||||
<property name="label" translatable="yes">Grid</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_as_radio">True</property>
|
||||
|
@ -141,7 +141,7 @@
|
|||
<property name="label" translatable="yes">List</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="draw_as_radio">True</property>
|
||||
<property name="group">iconview_menuitem</property>
|
||||
<property name="group">gridview_menuitem</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
|
|
@ -26,16 +26,16 @@ from lutris.gui.config_dialogs import (
|
|||
AddGameDialog, EditGameConfigDialog, SystemConfigDialog
|
||||
)
|
||||
from lutris.gui.widgets import (
|
||||
GameTreeView, GameIconView, ContextualMenu
|
||||
GameListView, GameGridView, ContextualMenu
|
||||
)
|
||||
|
||||
|
||||
def load_view(view, games=[], filter_text=None, icon_type=None):
|
||||
if view == 'icon':
|
||||
view = GameIconView(games, filter_text=filter_text,
|
||||
if view == 'grid':
|
||||
view = GameGridView(games, filter_text=filter_text,
|
||||
icon_type=icon_type)
|
||||
elif view == 'list':
|
||||
view = GameTreeView(games, filter_text=filter_text,
|
||||
view = GameListView(games, filter_text=filter_text,
|
||||
icon_type=icon_type)
|
||||
return view
|
||||
|
||||
|
@ -66,7 +66,7 @@ class LutrisWindow(object):
|
|||
width = int(settings.read_setting('width') or 800)
|
||||
height = int(settings.read_setting('height') or 600)
|
||||
self.window_size = (width, height)
|
||||
view_type = settings.read_setting('view_type') or settings.GAME_VIEW
|
||||
view_type = self.get_view_type()
|
||||
self.icon_type = self.get_icon_type(view_type)
|
||||
filter_installed_setting = settings.read_setting(
|
||||
'filter_installed'
|
||||
|
@ -85,13 +85,13 @@ class LutrisWindow(object):
|
|||
self.main_box = self.builder.get_object('main_box')
|
||||
self.splash_box = self.builder.get_object('splash_box')
|
||||
# View menu
|
||||
self.icon_view_menuitem = self.builder.get_object("iconview_menuitem")
|
||||
self.icon_view_menuitem.set_active(view_type == 'icon')
|
||||
self.grid_view_menuitem = self.builder.get_object("gridview_menuitem")
|
||||
self.grid_view_menuitem.set_active(view_type == 'grid')
|
||||
self.list_view_menuitem = self.builder.get_object("listview_menuitem")
|
||||
self.list_view_menuitem.set_active(view_type == 'list')
|
||||
# View buttons
|
||||
self.icon_view_btn = self.builder.get_object('switch_grid_view_btn')
|
||||
self.icon_view_btn.set_active(view_type == 'icon')
|
||||
self.grid_view_btn = self.builder.get_object('switch_grid_view_btn')
|
||||
self.grid_view_btn.set_active(view_type == 'grid')
|
||||
self.list_view_btn = self.builder.get_object('switch_list_view_btn')
|
||||
self.list_view_btn.set_active(view_type == 'list')
|
||||
# Icon type menu
|
||||
|
@ -101,7 +101,7 @@ class LutrisWindow(object):
|
|||
self.banner_menuitem = self.builder.get_object('banner_menuitem')
|
||||
self.banner_menuitem.set_active(self.icon_type == 'banner')
|
||||
self.icon_menuitem = self.builder.get_object('icon_menuitem')
|
||||
self.icon_menuitem.set_active(self.icon_type == 'icon')
|
||||
self.icon_menuitem.set_active(self.icon_type == 'grid')
|
||||
|
||||
self.search_entry = self.builder.get_object('search_entry')
|
||||
|
||||
|
@ -157,8 +157,8 @@ class LutrisWindow(object):
|
|||
|
||||
@property
|
||||
def current_view_type(self):
|
||||
return 'icon' \
|
||||
if self.view.__class__.__name__ == "GameIconView" \
|
||||
return 'grid' \
|
||||
if self.view.__class__.__name__ == "GameGridView" \
|
||||
else 'list'
|
||||
|
||||
def switch_splash_screen(self):
|
||||
|
@ -183,14 +183,20 @@ class LutrisWindow(object):
|
|||
self.view.connect("game-selected", self.game_selection_changed)
|
||||
self.window.connect("configure-event", self.get_size)
|
||||
|
||||
def get_view_type(self):
|
||||
view_type = settings.read_setting('view_type')
|
||||
if view_type in ['grid', 'list']:
|
||||
return view_type
|
||||
return settings.GAME_VIEW
|
||||
|
||||
def get_icon_type(self, view_type):
|
||||
"""Return the icon style depending on the type of view."""
|
||||
if view_type == 'icon':
|
||||
icon_type = settings.read_setting('icon_type_iconview')
|
||||
default = settings.ICON_TYPE_ICONVIEW
|
||||
elif view_type == 'list':
|
||||
if view_type == 'list':
|
||||
icon_type = settings.read_setting('icon_type_listview')
|
||||
default = settings.ICON_TYPE_LISTVIEW
|
||||
else:
|
||||
icon_type = settings.read_setting('icon_type_gridview')
|
||||
default = settings.ICON_TYPE_GRIDVIEW
|
||||
if icon_type not in ("banner_small", "banner", "icon"):
|
||||
icon_type = default
|
||||
return icon_type
|
||||
|
@ -249,7 +255,7 @@ class LutrisWindow(object):
|
|||
|
||||
def on_destroy(self, *args):
|
||||
"""Signal for window close."""
|
||||
view_type = 'icon' if 'IconView' in str(type(self.view)) else 'list'
|
||||
view_type = 'grid' if 'GridView' in str(type(self.view)) else 'list'
|
||||
settings.write_setting('view_type', view_type)
|
||||
width, height = self.window_size
|
||||
settings.write_setting('width', width)
|
||||
|
@ -376,23 +382,23 @@ class LutrisWindow(object):
|
|||
EditGameConfigDialog(self, game)
|
||||
|
||||
def on_viewmenu_toggled(self, menuitem):
|
||||
view_type = 'icon' if menuitem.get_active() else 'list'
|
||||
view_type = 'grid' if menuitem.get_active() else 'list'
|
||||
if view_type == self.current_view_type:
|
||||
return
|
||||
self.switch_view(view_type)
|
||||
self.icon_view_btn.set_active(view_type == 'icon')
|
||||
self.grid_view_btn.set_active(view_type == 'grid')
|
||||
self.list_view_btn.set_active(view_type == 'list')
|
||||
|
||||
def on_viewbtn_toggled(self, widget):
|
||||
view_type = 'icon' if widget.get_active() else 'list'
|
||||
view_type = 'grid' if widget.get_active() else 'list'
|
||||
if view_type == self.current_view_type:
|
||||
return
|
||||
self.switch_view(view_type)
|
||||
self.icon_view_menuitem.set_active(view_type == 'icon')
|
||||
self.grid_view_menuitem.set_active(view_type == 'grid')
|
||||
self.list_view_menuitem.set_active(view_type == 'list')
|
||||
|
||||
def switch_view(self, view_type):
|
||||
"""Switche between icon view and list view."""
|
||||
"""Switch between grid view and list view."""
|
||||
logger.debug("Switching view")
|
||||
self.icon_type = self.get_icon_type(view_type)
|
||||
self.view.destroy()
|
||||
|
@ -420,8 +426,8 @@ class LutrisWindow(object):
|
|||
icon_type = menuitem.get_name()
|
||||
if icon_type == self.view.icon_type or not menuitem.get_active():
|
||||
return
|
||||
if self.current_view_type == 'icon':
|
||||
settings.write_setting('icon_type_iconview', icon_type)
|
||||
if self.current_view_type == 'grid':
|
||||
settings.write_setting('icon_type_gridview', icon_type)
|
||||
elif self.current_view_type == 'list':
|
||||
settings.write_setting('icon_type_listview', icon_type)
|
||||
self.switch_view(self.current_view_type)
|
||||
|
|
|
@ -124,9 +124,9 @@ class ContextualMenu(Gtk.Menu):
|
|||
event.button, event.time)
|
||||
|
||||
|
||||
class IconViewCellRenderer(Gtk.CellRendererText):
|
||||
class GridViewCellRenderer(Gtk.CellRendererText):
|
||||
def __init__(self, width=None, *args, **kwargs):
|
||||
super(IconViewCellRenderer, self).__init__(*args, **kwargs)
|
||||
super(GridViewCellRenderer, self).__init__(*args, **kwargs)
|
||||
self.props.alignment = Pango.Alignment.CENTER
|
||||
self.props.wrap_mode = Pango.WrapMode.WORD
|
||||
self.props.xalign = 0.5
|
||||
|
@ -198,7 +198,7 @@ class GameView(object):
|
|||
self.remove_row(row.iter)
|
||||
|
||||
def remove_row(self, model_iter):
|
||||
"""Remove a game from the treeview."""
|
||||
"""Remove a game from the view."""
|
||||
store = self.game_store.store
|
||||
store.remove(model_iter)
|
||||
|
||||
|
@ -224,7 +224,7 @@ class GameView(object):
|
|||
return
|
||||
try:
|
||||
view.current_path = view.get_path_at_pos(event.x, event.y)
|
||||
if type(view) is GameIconView and view.current_path:
|
||||
if type(view) is GameGridView and view.current_path:
|
||||
view.select_path(view.current_path)
|
||||
except ValueError:
|
||||
(_, path) = view.get_selection().get_selected()
|
||||
|
@ -234,7 +234,7 @@ class GameView(object):
|
|||
self.contextual_menu.popup(event, game_row)
|
||||
|
||||
|
||||
class GameTreeView(Gtk.TreeView, GameView):
|
||||
class GameListView(Gtk.TreeView, GameView):
|
||||
"""Show the main list of games."""
|
||||
__gsignals__ = GameView.__gsignals__
|
||||
|
||||
|
@ -244,7 +244,7 @@ class GameTreeView(Gtk.TreeView, GameView):
|
|||
self.game_store = GameStore(games, icon_type=icon_type,
|
||||
filter_text=self.filter_text)
|
||||
self.model = self.game_store.modelfilter.sort_new_with_model()
|
||||
super(GameTreeView, self).__init__(self.model)
|
||||
super(GameListView, self).__init__(self.model)
|
||||
self.set_rules_hint(True)
|
||||
|
||||
# Icon column
|
||||
|
@ -297,7 +297,7 @@ class GameTreeView(Gtk.TreeView, GameView):
|
|||
self.emit("game-selected")
|
||||
|
||||
|
||||
class GameIconView(Gtk.IconView, GameView):
|
||||
class GameGridView(Gtk.IconView, GameView):
|
||||
__gsignals__ = GameView.__gsignals__
|
||||
icon_padding = 1
|
||||
|
||||
|
@ -307,15 +307,15 @@ class GameIconView(Gtk.IconView, GameView):
|
|||
self.game_store = GameStore(games, icon_type=icon_type,
|
||||
filter_text=self.filter_text)
|
||||
self.model = self.game_store.modelfilter
|
||||
super(GameIconView, self).__init__(model=self.model)
|
||||
super(GameGridView, self).__init__(model=self.model)
|
||||
self.set_columns(1)
|
||||
self.set_column_spacing(1)
|
||||
self.set_pixbuf_column(COL_ICON)
|
||||
self.cell_width = BANNER_SIZE[0] if icon_type == "banner" \
|
||||
else BANNER_SMALL_SIZE[0]
|
||||
iconview_cell_renderer = IconViewCellRenderer(width=self.cell_width)
|
||||
self.pack_end(iconview_cell_renderer, False)
|
||||
self.add_attribute(iconview_cell_renderer, 'markup', COL_NAME)
|
||||
gridview_cell_renderer = GridViewCellRenderer(width=self.cell_width)
|
||||
self.pack_end(gridview_cell_renderer, False)
|
||||
self.add_attribute(gridview_cell_renderer, 'markup', COL_NAME)
|
||||
self.set_item_padding(self.icon_padding)
|
||||
|
||||
self.connect('item-activated', self.on_item_activated)
|
||||
|
|
|
@ -36,8 +36,8 @@ LIB64_URL = SITE_URL + "files/lib64/"
|
|||
|
||||
# Default config options
|
||||
KEEP_CACHED_ASSETS = True
|
||||
GAME_VIEW = 'icon'
|
||||
ICON_TYPE_ICONVIEW = 'banner'
|
||||
GAME_VIEW = 'grid'
|
||||
ICON_TYPE_GRIDVIEW = 'banner'
|
||||
ICON_TYPE_LISTVIEW = 'icon'
|
||||
|
||||
read_setting = sio.read_setting
|
||||
|
|
Loading…
Reference in a new issue