/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
 *
 * Copyright (C) 2019 System76
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 *
 */

#include <config.h>
#include <gtk/gtk.h>
#include <firmware_manager.h>

#include "cc-firmware-panel.h"

struct _CcFirmwarePanel {
    CcPanel parent_instance;
    S76FirmwareWidget *firmware;
};

CC_PANEL_REGISTER (CcFirmwarePanel, cc_firmware_panel)

static void cc_firmware_panel_dispose (GObject *object) {
    CcFirmwarePanel *prefs = CC_FIRMWARE_PANEL (object);

    g_clear_pointer (&prefs->firmware, s76_firmware_widget_free);

    G_OBJECT_CLASS (cc_firmware_panel_parent_class)->dispose (object);
}

static void cc_firmware_panel_finalize (GObject *object) {
    G_OBJECT_CLASS (cc_firmware_panel_parent_class)->finalize (object);
}

static void cc_firmware_panel_class_init (CcFirmwarePanelClass *klass) {
    GObjectClass *object_class = G_OBJECT_CLASS (klass);

    object_class->dispose = cc_firmware_panel_dispose;
    object_class->finalize = cc_firmware_panel_finalize;
}

static void cc_firmware_panel_init (CcFirmwarePanel *prefs) {
    prefs->firmware = s76_firmware_widget_new ();
    s76_firmware_widget_scan (prefs->firmware);

    gtk_container_add (
        GTK_CONTAINER (prefs),
        s76_firmware_widget_container (prefs->firmware)
    );
}