Beispiel #1
0
    def __init__(self):
        GObject.GObject.__init__(self)
        self.set_title("Configure runners")
        self.set_size_request(570, 400)

        label = Gtk.Label()
        label.set_markup("<b>Install and configure the game runners</b>")

        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
                                   Gtk.PolicyType.AUTOMATIC)
        self.vbox.pack_start(label, False, True, 20)
        self.vbox.pack_start(scrolled_window, True, True, 10)

        close_button = Gtk.Button("Close")
        close_button.connect('clicked', self.close)

        self.action_area.pack_start(close_button, False, False, 10)
        runner_list = lutris.runners.__all__
        runner_vbox = Gtk.VBox()

        for runner_name in runner_list:
            # Get runner details
            runner = import_runner(runner_name)()
            platform = runner.platform
            description = runner.description

            hbox = Gtk.HBox()
            #Icon
            icon_path = os.path.join(get_data_path(), 'media/runner_icons',
                                     runner_name + '.png')
            icon = Gtk.Image()
            icon.set_from_file(icon_path)
            hbox.pack_start(icon, False, False, 10)

            #Label
            runner_label = Gtk.Label()
            runner_label.set_markup(
                "<b>%s</b>\n%s\n <i>Supported platforms : %s</i>" %
                (runner_name, description, platform)
            )
            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, 5)
            #Button
            button = Gtk.Button()
            button.set_size_request(100, 30)
            button_align = Gtk.Alignment.new(0.0, 1.0, 0.0, 0.0)
            self.configure_button(button, runner)
            button_align.add(button)
            hbox.pack_start(button_align, True, False, 5)

            runner_vbox.pack_start(hbox, True, True, 5)
        scrolled_window.add_with_viewport(runner_vbox)
        self.show_all()
Beispiel #2
0
    def __init__(self, **kwargs):
        super(GtkBuilderDialog, self).__init__()
        ui_filename = os.path.join(settings.get_data_path(), 'ui',
                                   self.glade_file)
        if not os.path.exists(ui_filename):
            raise ValueError("ui file does not exists: %s" % ui_filename)

        self.builder = Gtk.Builder()
        self.builder.add_from_file(ui_filename)
        self.dialog = self.builder.get_object(self.dialog_object)
        self.builder.connect_signals(self)
        self.dialog.show_all()
        self.initialize(**kwargs)
Beispiel #3
0
 def set_game_cover(self, name):
     """Change the cover currently displayed."""
     cover_file = os.path.join(COVER_PATH, name + ".jpg")
     if os.path.exists(cover_file):
         #Resize the image
         cover_pixbuf = Pixbuf.new_from_file(cover_file)
         dest_w = 250.0
         height = cover_pixbuf.get_height()
         width = cover_pixbuf.get_width()
         dest_h = height * (dest_w / width)
         self.set_from_pixbuf(cover_pixbuf.scale_simple(
             int(dest_w),
             int(dest_h),
             GdkPixbuf.InterpType.BILINEAR
         ))
         return
     else:
         self.set_from_file(os.path.join(settings.get_data_path(),
                                         "media/background.png"))
Beispiel #4
0
 def __init__(self, parent=None):
     super(GameCover, self).__init__()
     self.parent_window = parent
     self.set_from_file(os.path.join(settings.get_data_path(),
                                     "media/background.png"))
     self.connect('drag_data_received', self.on_cover_drop)
Beispiel #5
0
# F0401 : Unable to import '...'
# E1101 : Instance of '...' has no '...' member
# pylint: disable=E0611, F0401, E1101

import os
#import Image

from gi.repository import Gtk, Gdk, GObject, Pango, GdkPixbuf, GLib
from gi.repository.GdkPixbuf import Pixbuf

from lutris.downloader import Downloader
from lutris.constants import COVER_PATH
#from lutris.util.log import logger
from lutris import settings

MISSING_ICON = os.path.join(settings.get_data_path(), 'media/banner.png')
UNAVAILABLE_GAME_OVERLAY = os.path.join(settings.get_data_path(),
                                        'media/unavailable.png')

(COL_ID,
 COL_NAME,
 COL_ICON,
 COL_RUNNER,
 COL_RUNNER_ICON,
 COL_GENRE,
 COL_PLATFORM,
 COL_YEAR) = range(8)


def sort_func(store, a_iter, b_iter, _user_data):
    """Default sort function"""
Beispiel #6
0
    def __init__(self):

        ui_filename = os.path.join(
            settings.get_data_path(), 'ui', 'LutrisWindow.ui'
        )
        if not os.path.exists(ui_filename):
            raise IOError('File %s not found' % ui_filename)

        self.builder = Gtk.Builder()
        self.builder.add_from_file(ui_filename)

        # load config
        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 'icon'
        filter_installed_setting = settings.read_setting(
            'filter_installed'
        ) or 'false'
        self.filter_installed = filter_installed_setting == 'true'
        show_installed_games_menuitem = self.builder.get_object(
            'filter_installed'
        )
        show_installed_games_menuitem.set_active(self.filter_installed)

        self.view = switch_to_view(view_type,
                                   get_game_list(self.filter_installed))

        self.icon_view_menuitem = self.builder.get_object("iconview_menuitem")
        self.icon_view_menuitem.set_active(view_type == 'icon')
        self.list_view_menuitem = self.builder.get_object("listview_menuitem")
        self.list_view_menuitem.set_active(view_type == 'list')
        self.icon_view_btn = self.builder.get_object('switch_grid_view_btn')
        self.icon_view_btn.set_active(view_type == 'icon')
        self.list_view_btn = self.builder.get_object('switch_list_view_btn')
        self.list_view_btn.set_active(view_type == 'list')

        # Scroll window
        self.games_scrollwindow = self.builder.get_object('games_scrollwindow')
        self.games_scrollwindow.add(self.view)
        #Status bar
        self.status_label = self.builder.get_object('status_label')
        self.joystick_icons = []
        # Buttons
        self.stop_button = self.builder.get_object('stop_button')
        self.stop_button.set_sensitive(False)
        self.delete_button = self.builder.get_object('delete_button')
        self.delete_button.set_sensitive(False)
        self.play_button = self.builder.get_object('play_button')
        self.play_button.set_sensitive(False)

        #Contextual menu
        menu_callbacks = [
            ('play', self.on_game_clicked),
            ('install', self.on_game_clicked),
            ('configure', self.edit_game_configuration),
            ('desktop-shortcut', self.create_desktop_shortcut),
            ('menu-shortcut', self.create_menu_shortcut),
            ('uninstall', self.on_remove_game),
        ]
        self.menu = ContextualMenu(menu_callbacks)
        self.view.contextual_menu = self.menu

        #Timer
        self.timer_id = GLib.timeout_add(2000, self.refresh_status)
        self.window = self.builder.get_object("window")
        self.window.resize_to_geometry(width, height)
        self.window.show_all()

        self.builder.connect_signals(self)
        self.connect_signals()

        if api.read_api_key():
            self.status_label.set_text("Connected to lutris.net")
            self.sync_library()
        else:
            async_call(self.sync_icons, None)
Beispiel #7
0
    def __init__(self):

        ui_filename = os.path.join(
            settings.get_data_path(), 'ui', 'LutrisWindow.ui'
        )
        if not os.path.exists(ui_filename):
            raise IOError('File %s not found' % ui_filename)

        self.builder = Gtk.Builder()
        self.builder.add_from_file(ui_filename)

        # load config
        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 'icon'

        self.view = switch_to_view(view_type)

        view_menuitem = self.builder.get_object("iconview_menuitem")
        view_menuitem.set_active(view_type == 'icon')
        view_menuitem = self.builder.get_object("listview_menuitem")
        view_menuitem.set_active(view_type == 'list')
        switch_grid_view_btn = self.builder.get_object('switch_grid_view_btn')
        switch_grid_view_btn.set_active(view_type == 'icon')
        switch_list_view_btn = self.builder.get_object('switch_list_view_btn')
        switch_list_view_btn.set_active(view_type == 'list')

        # Scroll window
        self.games_scrollwindow = self.builder.get_object('games_scrollwindow')
        self.games_scrollwindow.add(self.view)
        #Status bar
        self.status_label = self.builder.get_object('status_label')
        self.joystick_icons = []
        # Buttons
        self.stop_button = self.builder.get_object('stop_button')
        self.stop_button.set_sensitive(False)
        self.delete_button = self.builder.get_object('delete_button')
        self.delete_button.set_sensitive(False)
        self.play_button = self.builder.get_object('play_button')
        self.play_button.set_sensitive(False)

        #Contextual menu
        menu_actions = [
            ('Play', self.on_game_clicked),
            ('Configure', self.edit_game_configuration),
            ('Create desktop shortcut', self.create_desktop_shortcut),
            ('Create global menu shortcut', self.create_menu_shortcut)
        ]
        self.menu = Gtk.Menu()
        for action in menu_actions:
            subitem = Gtk.ImageMenuItem(action[0])
            subitem.connect('activate', action[1])
            self.menu.append(subitem)
        self.menu.show_all()
        self.view.contextual_menu = self.menu

        #Timer
        self.timer_id = GLib.timeout_add(2000, self.refresh_status)
        self.window = self.builder.get_object("window")
        self.window.resize_to_geometry(width, height)
        self.window.show_all()

        self.builder.connect_signals(self)
        self.connect_signals()
        async_call(self.sync_db, None)