示例#1
0
 def get_pixbuf(self, icon_type):
     """Pixbuf varying on icon type"""
     return get_pixbuf_for_game(
         self._pga_data["slug"],
         icon_type,
         self._pga_data["installed"]
     )
 def _make_menu_item_for_game(self, game):
     menu_item = Gtk.ImageMenuItem()
     menu_item.set_label(game["name"])
     game_icon = get_pixbuf_for_game(game["slug"], "icon_small")
     menu_item.set_image(Gtk.Image.new_from_pixbuf(game_icon))
     menu_item.connect("activate", self.on_game_selected, game["id"])
     return menu_item
示例#3
0
 def set_icon_type(self, icon_type):
     if icon_type != self.icon_type:
         self.icon_type = icon_type
         for row in self.store:
             row[COL_ICON] = get_pixbuf_for_game(
                 row[COL_SLUG], icon_type, is_installed=row[COL_INSTALLED])
         self.emit("icons-changed", icon_type)
示例#4
0
    def add_game(self, game):
        pixbuf = get_pixbuf_for_game(game['slug'], self.icon_type,
                                     game['installed'])
        name = game['name'].replace('&', "&")
        runner = None
        platform = ''
        runner_name = game['runner']
        runner_human_name = ''
        if runner_name:
            game_inst = Game(game['id'])
            if not game_inst.is_installed:
                return
            if runner_name in self.runner_names:
                runner_human_name = self.runner_names[runner_name]
            else:
                runner = runners.import_runner(runner_name)
                runner_human_name = runner.human_name
                self.runner_names[runner_name] = runner_human_name
            platform = game_inst.platform

        lastplayed = ''
        if game['lastplayed']:
            lastplayed = time.strftime("%c",
                                       time.localtime(game['lastplayed']))

        self.store.append(
            (game['id'], game['slug'], name, pixbuf, str(game['year']
                                                         or ''), runner_name,
             runner_human_name, platform, lastplayed, game['installed']))
示例#5
0
 def get_pixbuf(self, icon_type):
     """Pixbuf varying on icon type"""
     return get_pixbuf_for_game(
         self._pga_data["slug"],
         icon_type,
         self._pga_data["installed"]
     )
示例#6
0
 def set_icon_type(self, icon_type):
     if icon_type != self.icon_type:
         self.icon_type = icon_type
         for row in self.store:
             row[COL_ICON] = get_pixbuf_for_game(
                 row[COL_SLUG], icon_type, is_installed=row[COL_INSTALLED]
             )
         self.emit('icons-changed', icon_type)  # Obsolete, only for GridView
示例#7
0
 def set_icon_type(self, icon_type):
     if icon_type != self.icon_type:
         self.icon_type = icon_type
         for row in self.store:
             row[COL_ICON] = get_pixbuf_for_game(
                 row[COL_SLUG], icon_type, is_installed=row[COL_INSTALLED])
         self.emit('icons-changed',
                   icon_type)  # Obsolete, only for GridView
示例#8
0
 def _set_image(self, image_format):
     image = Gtk.Image()
     game_slug = self.game.slug if self.game else ""
     image.set_from_pixbuf(get_pixbuf_for_game(game_slug, image_format))
     if ImageType.banner & image_format:
         self.banner_button.set_image(image)
     if ImageType.icon & image_format:
         self.icon_button.set_image(image)
示例#9
0
 def _set_image(self, image_format):
     assert image_format in ('banner', 'icon')
     image = Gtk.Image()
     game_slug = self.game.slug if self.game else ''
     image.set_from_pixbuf(get_pixbuf_for_game(game_slug, image_format))
     if image_format == 'banner':
         self.banner_button.set_image(image)
     else:
         self.icon_button.set_image(image)
示例#10
0
 def _set_image(self, image_format):
     assert image_format in ('banner', 'icon')
     image = Gtk.Image()
     game_slug = self.game.slug if self.game else ''
     image.set_from_pixbuf(get_pixbuf_for_game(game_slug, image_format))
     if image_format == 'banner':
         self.banner_button.set_image(image)
     else:
         self.icon_button.set_image(image)
示例#11
0
 def _set_image(self, image_format):
     image = Gtk.Image()
     size = BANNER_SIZE if image_format == "banner" else ICON_SIZE
     game_slug = self.game.slug if self.game else ""
     image.set_from_pixbuf(get_pixbuf_for_game(game_slug, size))
     if image_format == "banner":
         self.banner_button.set_image(image)
     else:
         self.icon_button.set_image(image)
示例#12
0
 def _set_image(self, image_format):
     assert image_format in ("banner", "icon")
     image = Gtk.Image()
     game_slug = self.game.slug if self.game else ""
     image.set_from_pixbuf(get_pixbuf_for_game(game_slug, image_format))
     if image_format == "banner":
         self.banner_button.set_image(image)
     else:
         self.icon_button.set_image(image)
示例#13
0
文件: store.py 项目: wberrier/lutris
 def set_icon_type(self, icon_type):
     """Change the icon type"""
     if icon_type == self.icon_type:
         return
     self.icon_type = icon_type
     for row in self.store:
         row[COL_ICON] = get_pixbuf_for_game(
             row[COL_SLUG],
             icon_type,
             is_installed=row[COL_INSTALLED] if not self.search_mode else True,
         )
     self.emit("icons-changed", icon_type)
示例#14
0
 def get_pixbuf(self):
     """Pixbuf varying on icon type"""
     if self._game_data.get("icon"):
         image_path = self._game_data["icon"]
     else:
         image_path = self.service_media.get_absolute_path(self.slug
                                                           or self.id)
     if system.path_exists(image_path):
         return get_pixbuf(image_path, self.service_media.size)
     return get_pixbuf_for_game(self._game_data["slug"],
                                self._game_data["image_size"],
                                self.installed)
示例#15
0
 def set_service_media(self, service_media):
     """Change the icon type"""
     if service_media == self.service_media:
         return
     self.service_media = service_media
     for row in self.store:
         row[COL_ICON] = get_pixbuf_for_game(
             row[COL_SLUG],
             self.service_media.size,
             is_installed=row[COL_INSTALLED],
         )
     self.emit("icons-changed")
示例#16
0
 def update_image(self, game_id, is_installed=False):
     """Update game icon."""
     row = self.get_row_by_id(game_id)
     if row:
         game_slug = row[COL_SLUG]
         # get_pixbuf_for_game.cache_clear()
         game_pixbuf = get_pixbuf_for_game(game_slug,
                                           self.game_store.icon_type,
                                           is_installed)
         row[COL_ICON] = game_pixbuf
         row[COL_INSTALLED] = is_installed
         if type(self) is GameGridView:
             GLib.idle_add(self.queue_draw)
示例#17
0
 def update_image(self, game_id, is_installed=False):
     """Update game icon."""
     row = self.get_row_by_id(game_id)
     if row:
         game_slug = row[COL_SLUG]
         # get_pixbuf_for_game.cache_clear()
         game_pixbuf = get_pixbuf_for_game(game_slug,
                                           self.game_store.icon_type,
                                           is_installed)
         row[COL_ICON] = game_pixbuf
         row[COL_INSTALLED] = is_installed
         if type(self) is GameGridView:
             GLib.idle_add(self.queue_draw)
示例#18
0
    def create_list_widget(self, game):
        box = Gtk.Box(spacing=6, margin_top=6, margin_bottom=6, margin_right=6, margin_left=6)
        box.set_size_request(280, 32)

        icon = Gtk.Image.new_from_pixbuf(get_pixbuf_for_game(game.slug, "icon"))
        icon.show()
        box.add(icon)

        game_label = Gtk.Label(game.name, visible=True)
        game_label.set_ellipsize(Pango.EllipsizeMode.END)
        box.add(game_label)
        box.game = game

        return box
示例#19
0
    def add_game(self, game):
        name = game['name'].replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
        runner = None
        platform = ''
        runner_name = game['runner']
        runner_human_name = ''
        if runner_name:
            game_inst = Game(game['id'])
            if not game_inst.is_installed:
                return
            if runner_name in self.runner_names:
                runner_human_name = self.runner_names[runner_name]
            else:
                try:
                    runner = runners.import_runner(runner_name)
                except runners.InvalidRunner:
                    game['installed'] = False
                else:
                    runner_human_name = runner.human_name
                    self.runner_names[runner_name] = runner_human_name
            platform = game_inst.platform
            if not platform:
                game_inst.set_platform_from_runner()
                platform = game_inst.platform

        lastplayed_text = ''
        if game['lastplayed']:
            lastplayed_text = time.strftime("%c", time.localtime(game['lastplayed']))

        installed_at_text = ''
        if game['installed_at']:
            installed_at_text = time.strftime("%c", time.localtime(game['installed_at']))

        pixbuf = get_pixbuf_for_game(game['slug'], self.icon_type,
                                     game['installed'])
        self.store.append((
            game['id'],
            game['slug'],
            name,
            pixbuf,
            str(game['year'] or ''),
            runner_name,
            runner_human_name,
            platform,
            game['lastplayed'],
            lastplayed_text,
            game['installed'],
            game['installed_at'],
            installed_at_text
        ))
示例#20
0
文件: store.py 项目: LiamDawe/lutris
 def set_service_media(self, service_media):
     """Change the icon type"""
     if service_media == self.service_media:
         return
     self.service_media = service_media
     for row in self.store:
         try:
             slug = row[COL_SLUG]
             is_installed = row[COL_INSTALLED]
             row[COL_ICON] = get_pixbuf_for_game(slug,
                                                 self.service_media.size,
                                                 is_installed=is_installed)
         except TypeError:
             return
     self.emit("icons-changed")
示例#21
0
    def create_list_widget(self, game):
        box = Gtk.Box(
            spacing=6, margin_top=6, margin_bottom=6, margin_right=6, margin_left=6
        )
        box.set_size_request(280, 32)

        icon = Gtk.Image.new_from_pixbuf(get_pixbuf_for_game(game.slug, "icon"))
        icon.show()
        box.add(icon)

        game_label = Gtk.Label(game.name, visible=True)
        game_label.set_ellipsize(Pango.EllipsizeMode.END)
        box.add(game_label)
        box.game = game

        return box
示例#22
0
    def add_game(self, game):
        platform = ""
        runner_human_name = ""
        runner_info = self.get_runner_info(game)
        if runner_info:
            runner_human_name, platform = runner_info
        else:
            game["installed"] = False

        lastplayed_text = ""
        if game["lastplayed"]:
            lastplayed_text = time.strftime("%c",
                                            time.localtime(game["lastplayed"]))

        installed_at_text = ""
        if game["installed_at"]:
            installed_at_text = time.strftime(
                "%c", time.localtime(game["installed_at"]))

        pixbuf = get_pixbuf_for_game(game["slug"], self.icon_type,
                                     game["installed"])
        try:
            playtime_text = get_formatted_playtime(game["playtime"])
        except ValueError:
            # We're all screwed
            pga.unfuck_playtime(game)
            playtime_text = game["playtime"] + ":("

        self.store.append((
            game["id"],
            gtk_safe(game["slug"]),
            gtk_safe(game["name"]),
            pixbuf,
            gtk_safe(str(game["year"] or "")),
            gtk_safe(game["runner"]),
            gtk_safe(runner_human_name),
            gtk_safe(platform),
            game["lastplayed"],
            gtk_safe(lastplayed_text),
            game["installed"],
            game["installed_at"],
            gtk_safe(installed_at_text),
            game["playtime"],
            playtime_text,
        ))
示例#23
0
    def add_game(self, game):
        name = game['name'].replace('&', "&amp;")
        runner = None
        platform = ''
        runner_name = game['runner']
        runner_human_name = ''
        if runner_name:
            game_inst = Game(game['id'])
            if not game_inst.is_installed:
                return
            if runner_name in self.runner_names:
                runner_human_name = self.runner_names[runner_name]
            else:
                try:
                    runner = runners.import_runner(runner_name)
                except runners.InvalidRunner:
                    game['installed'] = False
                else:
                    runner_human_name = runner.human_name
                    self.runner_names[runner_name] = runner_human_name
            platform = game_inst.platform
            if not platform:
                game_inst.set_platform_from_runner()
                platform = game_inst.platform

        lastplayed = ''
        if game['lastplayed']:
            lastplayed = time.strftime("%c", time.localtime(game['lastplayed']))

        pixbuf = get_pixbuf_for_game(game['slug'], self.icon_type,
                                     game['installed'])
        self.store.append((
            game['id'],
            game['slug'],
            name,
            pixbuf,
            str(game['year'] or ''),
            runner_name,
            runner_human_name,
            platform,
            game['lastplayed'],
            lastplayed,
            game['installed']
        ))
示例#24
0
 def get_pixbuf(self):
     """Pixbuf varying on icon type"""
     if self._game_data.get("icon"):
         image_path = self._game_data["icon"]
     else:
         image_path = self.service_media.get_absolute_path(self.slug)
         if not system.path_exists(image_path):
             service = self._game_data.get("service")
             appid = self._game_data.get("service_id")
             if appid:
                 service_game = ServiceGameCollection.get_game(
                     service, appid)
             else:
                 service_game = None
             if service_game:
                 image_path = self.service_media.get_absolute_path(
                     service_game["slug"])
     if system.path_exists(image_path):
         return get_pixbuf(image_path,
                           self.service_media.size,
                           is_installed=self.installed)
     return get_pixbuf_for_game(self._game_data["slug"],
                                self.service_media.size, self.installed)
示例#25
0
 def update_icon(self, game_slug):
     row = self.get_row_by_slug(game_slug)
     row[COL_ICON] = get_pixbuf_for_game(game_slug, self.icon_type, True)
示例#26
0
 def get_icon(self):
     """Return the game icon"""
     icon = Gtk.Image.new_from_pixbuf(
         get_pixbuf_for_game(self.game.slug, "icon"))
     icon.show()
     return icon
示例#27
0
 def _set_icon_image(self):
     image = Gtk.Image()
     game_slug = self.game.slug if self.game else ""
     image.set_from_pixbuf(get_pixbuf_for_game(game_slug, ImageType.banner))
     self.banner_button.set_image(image)
示例#28
0
 def _set_icon_image(self):
     image = Gtk.Image()
     game_slug = self.game.slug if self.game else ''
     image.set_from_pixbuf(get_pixbuf_for_game(game_slug, 'banner'))
     self.banner_button.set_image(image)
示例#29
0
 def set_image_pixbuf(self):
     pixbuf = get_pixbuf_for_game(self.slug,
                                  self.icon_type,
                                  self.installed)
     self.image.set_from_pixbuf(pixbuf)
示例#30
0
 def set_image_pixbuf(self):
     pixbuf = get_pixbuf_for_game(self.slug, self.icon_type, self.installed)
     self.image.set_from_pixbuf(pixbuf)
示例#31
0
 def get_icon(self):
     """Return the game icon"""
     icon = Gtk.Image.new_from_pixbuf(get_pixbuf_for_game(self.game.slug, "icon"))
     icon.show()
     return icon