# SPDX-FileCopyrightText: 2024 Luca Weiss
# SPDX-License-Identifier: GPL-3.0-only

from gi.repository import GObject
from gi.repository import Gdk
from gi.repository import GdkPixbuf
from gi.repository import Gtk


@Gtk.Template(resource_path="/eu/lucaweiss/lpa-gtk/widgets/esimprofile.ui")
class ESimProfileWidget(Gtk.ListBoxRow):
    __gtype_name__ = "LpaGtkESimProfile"

    icon = Gtk.Template.Child()

    profile = None

    _title = ""
    @GObject.property(type=str, default="")
    def title(self):
        return self._title

    @title.setter
    def title(self, v):
        self._title = v

    _enabled = False
    @GObject.property(type=bool, default=False)
    def enabled(self):
        return self._enabled

    @enabled.setter
    def enabled(self, v):
        self._enabled = v

    _provider = ""
    @GObject.property(type=str, default="")
    def provider(self):
        return self._provider

    @provider.setter
    def provider(self, v):
        self._provider = v
        self.notify("provider-label")

    @GObject.Property(type=str, default="")
    def provider_label(self):
        return self.provider

    _icon_pixbuf = None
    @GObject.property(type=GdkPixbuf.Pixbuf, default=None)
    def icon_pixbuf(self):
        return self._icon_pixbuf

    @icon_pixbuf.setter
    def icon_pixbuf(self, v):
        self._icon_pixbuf = v
        if v:
            texture = Gdk.Texture.new_for_pixbuf(v)
            self.icon.set_from_paintable(texture)
        self.icon.set_visible(v is not None)
